ov7670_regs.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. /*
  2. * This file is for the OpenMV project so the OV7670 can be used
  3. * author: Juan Schiavoni <juanjoseschiavoni@hotmail.com>
  4. *
  5. * OV7670 register definitions.
  6. */
  7. #ifndef __OV7670_REG_REGS_H__
  8. #define __OV7670_REG_REGS_H__
  9. #define GAIN 0x00 /* AGC – Gain control gain setting */
  10. #define BLUE 0x01 /* AWB – Blue channel gain setting */
  11. #define RED 0x02 /* AWB – Red channel gain setting */
  12. #define VREF 0x03 /* AWB – Green channel gain setting */
  13. #define COM1 0x04 /* Common Control 1 */
  14. #define BAVG 0x05 /* U/B Average Level */
  15. #define GAVG 0x06 /* Y/Gb Average Level */
  16. #define AECH 0x07 /* Exposure VAlue - AEC MSB 5 bits */
  17. #define RAVG 0x08 /* V/R Average Level */
  18. #define COM2 0x09 /* Common Control 2 */
  19. #define COM2_SOFT_SLEEP 0x10 /* Soft sleep mode */
  20. #define COM2_OUT_DRIVE_1x 0x00 /* Output drive capability 1x */
  21. #define COM2_OUT_DRIVE_2x 0x01 /* Output drive capability 2x */
  22. #define COM2_OUT_DRIVE_3x 0x02 /* Output drive capability 3x */
  23. #define COM2_OUT_DRIVE_4x 0x03 /* Output drive capability 4x */
  24. #define REG_PID 0x0A /* Product ID Number MSB */
  25. #define REG_VER 0x0B /* Product ID Number LSB */
  26. #define COM3 0x0C /* Common Control 3 */
  27. #define COM3_SWAP_OUT 0x40 /* Output data MSB/LSB swap */
  28. #define COM3_TRI_CLK 0x20 /* Tri-state output clock */
  29. #define COM3_TRI_DATA 0x10 /* Tri-state option output */
  30. #define COM3_SCALE_EN 0x08 /* Scale enable */
  31. #define COM3_DCW 0x04 /* DCW enable */
  32. #define COM4 0x0D /* Common Control 4 */
  33. #define COM4_PLL_BYPASS 0x00 /* Bypass PLL */
  34. #define COM4_PLL_4x 0x40 /* PLL frequency 4x */
  35. #define COM4_PLL_6x 0x80 /* PLL frequency 6x */
  36. #define COM4_PLL_8x 0xc0 /* PLL frequency 8x */
  37. #define COM4_AEC_FULL 0x00 /* AEC evaluate full window */
  38. #define COM4_AEC_1_2 0x10 /* AEC evaluate 1/2 window */
  39. #define COM4_AEC_1_4 0x20 /* AEC evaluate 1/4 window */
  40. #define COM4_AEC_2_3 0x30 /* AEC evaluate 2/3 window */
  41. #define COM5 0x0E /* Common Control 5 */
  42. #define COM5_AFR 0x80 /* Auto frame rate control ON/OFF selection (night mode) */
  43. #define COM5_AFR_SPEED 0x40 /* Auto frame rate control speed selection */
  44. #define COM5_AFR_0 0x00 /* No reduction of frame rate */
  45. #define COM5_AFR_1_2 0x10 /* Max reduction to 1/2 frame rate */
  46. #define COM5_AFR_1_4 0x20 /* Max reduction to 1/4 frame rate */
  47. #define COM5_AFR_1_8 0x30 /* Max reduction to 1/8 frame rate */
  48. #define COM5_AFR_4x 0x04 /* Add frame when AGC reaches 4x gain */
  49. #define COM5_AFR_8x 0x08 /* Add frame when AGC reaches 8x gain */
  50. #define COM5_AFR_16x 0x0c /* Add frame when AGC reaches 16x gain */
  51. #define COM5_AEC_NO_LIMIT 0x01 /* No limit to AEC increase step */
  52. #define COM6 0x0F /* Common Control 6 */
  53. #define COM6_AUTO_WINDOW 0x01 /* Auto window setting ON/OFF selection when format changes */
  54. #define AEC 0x10 /* AEC[7:0] (see register AECH for AEC[15:8]) */
  55. #define CLKRC 0x11 /* Internal Clock */
  56. #define COM7 0x12 /* Common Control 7 */
  57. #define COM7_RESET 0x80 /* SCCB Register Reset */
  58. #define COM7_RES_VGA 0x00 /* Resolution VGA */
  59. #define COM7_RES_QVGA 0x40 /* Resolution QVGA */
  60. #define COM7_BT656 0x20 /* BT.656 protocol ON/OFF */
  61. #define COM7_SENSOR_RAW 0x10 /* Sensor RAW */
  62. #define COM7_FMT_GBR422 0x00 /* RGB output format GBR422 */
  63. #define COM7_FMT_RGB565 0x04 /* RGB output format RGB565 */
  64. #define COM7_FMT_RGB555 0x08 /* RGB output format RGB555 */
  65. #define COM7_FMT_RGB444 0x0C /* RGB output format RGB444 */
  66. #define COM7_FMT_YUV 0x00 /* Output format YUV */
  67. #define COM7_FMT_P_BAYER 0x01 /* Output format Processed Bayer RAW */
  68. #define COM7_FMT_RGB 0x04 /* Output format RGB */
  69. #define COM7_FMT_R_BAYER 0x03 /* Output format Bayer RAW */
  70. #define COM7_SET_FMT(r, x) ((r&0xFC)|((x&0x5)<<0))
  71. #define COM8 0x13 /* Common Control 8 */
  72. #define COM8_FAST_AUTO 0x80 /* Enable fast AGC/AEC algorithm */
  73. #define COM8_STEP_VSYNC 0x00 /* AEC - Step size limited to vertical blank */
  74. #define COM8_STEP_UNLIMIT 0x40 /* AEC - Step size unlimited step size */
  75. #define COM8_BANDF_EN 0x20 /* Banding filter ON/OFF */
  76. #define COM8_AEC_BANDF 0x10 /* Enable AEC below banding value */
  77. #define COM8_AEC_FINE_EN 0x08 /* Fine AEC ON/OFF control */
  78. #define COM8_AGC_EN 0x04 /* AGC Enable */
  79. #define COM8_AWB_EN 0x02 /* AWB Enable */
  80. #define COM8_AEC_EN 0x01 /* AEC Enable */
  81. #define COM8_SET_AGC(r, x) ((r&0xFB)|((x&0x1)<<2))
  82. #define COM8_SET_AWB(r, x) ((r&0xFD)|((x&0x1)<<1))
  83. #define COM8_SET_AEC(r, x) ((r&0xFE)|((x&0x1)<<0))
  84. #define COM9 0x14 /* Common Control 9 */
  85. #define COM9_HISTO_AVG 0x80 /* Histogram or average based AEC/AGC selection */
  86. #define COM9_AGC_GAIN_2x 0x00 /* Automatic Gain Ceiling 2x */
  87. #define COM9_AGC_GAIN_4x 0x10 /* Automatic Gain Ceiling 4x */
  88. #define COM9_AGC_GAIN_8x 0x20 /* Automatic Gain Ceiling 8x */
  89. #define COM9_AGC_GAIN_16x 0x30 /* Automatic Gain Ceiling 16x */
  90. #define COM9_AGC_GAIN_32x 0x40 /* Automatic Gain Ceiling 32x */
  91. #define COM9_DROP_VSYNC 0x04 /* Drop VSYNC output of corrupt frame */
  92. #define COM9_DROP_HREF 0x02 /* Drop HREF output of corrupt frame */
  93. #define COM9_SET_AGC(r, x) ((r&0x8F)|((x&0x07)<<4))
  94. #define COM10 0x15 /* Common Control 10 */
  95. #define COM10_NEGATIVE 0x80 /* Output negative data */
  96. #define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */
  97. #define COM10_PCLK_FREE 0x00 /* PCLK output option: free running PCLK */
  98. #define COM10_PCLK_MASK 0x20 /* PCLK output option: masked during horizontal blank */
  99. #define COM10_PCLK_REV 0x10 /* PCLK reverse */
  100. #define COM10_HREF_REV 0x08 /* HREF reverse */
  101. #define COM10_VSYNC_FALLING 0x00 /* VSYNC changes on falling edge of PCLK */
  102. #define COM10_VSYNC_RISING 0x04 /* VSYNC changes on rising edge of PCLK */
  103. #define COM10_VSYNC_NEG 0x02 /* VSYNC negative */
  104. #define COM10_OUT_RANGE_8 0x01 /* Output data range: Full range */
  105. #define COM10_OUT_RANGE_10 0x00 /* Output data range: Data from [10] to [F0] (8 MSBs) */
  106. #define RSVD_16 0x16 /* Reserved register */
  107. #define HSTART 0x17 /* Horizontal Frame (HREF column) Start high 8-bit(low 3 bits are at HREF[2:0]) */
  108. #define HSTOP 0x18 /* Horizontal Frame (HREF column) end high 8-bit (low 3 bits are at HREF[5:3]) */
  109. #define VSTART 0x19 /* Vertical Frame (row) Start high 8-bit (low 2 bits are at VREF[1:0]) */
  110. #define VSTOP 0x1A /* Vertical Frame (row) End high 8-bit (low 2 bits are at VREF[3:2]) */
  111. #define PSHFT 0x1B /* Data Format - Pixel Delay Select */
  112. #define REG_MIDH 0x1C /* Manufacturer ID Byte – High */
  113. #define REG_MIDL 0x1D /* Manufacturer ID Byte – Low */
  114. #define MVFP 0x1E /* Mirror/Vflip Enable */
  115. #define MVFP_MIRROR 0x20 /* Mirror image */
  116. #define MVFP_FLIP 0x10 /* Vertical flip */
  117. #define MVFP_SUN 0x02 /* Black sun enable */
  118. #define MVFP_SET_MIRROR(r,x) ((r&0xDF)|((x&1)<<5)) /* change only bit5 according to x */
  119. #define MVFP_SET_FLIP(r,x) ((r&0xEF)|((x&1)<<4)) /* change only bit4 according to x */
  120. #define LAEC 0x1F /* Fine AEC Value - defines exposure value less than one row period (Reserved?) */
  121. #define ADCCTR0 0x20 /* ADC control */
  122. #define ADCCTR1 0x21 /* reserved */
  123. #define ADCCTR2 0x22 /* reserved */
  124. #define ADCCTR3 0x23 /* reserved */
  125. #define AEW 0x24 /* AGC/AEC - Stable Operating Region (Upper Limit) */
  126. #define AEB 0x25 /* AGC/AEC - Stable Operating Region (Lower Limit) */
  127. #define VPT 0x26 /* AGC/AEC Fast Mode Operating Region */
  128. #define BBIAS 0x27 /* B channel signal output bias (effective only when COM6[3]=1) */
  129. #define GbBIAS 0x28 /* Gb channel signal output bias (effective only when COM6[3]=1) */
  130. #define RSVD_29 0x29 /* reserved */
  131. #define EXHCH 0x2A /* Dummy Pixel Insert MSB */
  132. #define EXHCL 0x2B /* Dummy Pixel Insert LSB */
  133. #define RBIAS 0x2C /* R channel signal output bias (effective only when COM6[3]=1) */
  134. #define ADVFL 0x2D /* LSB of Insert Dummy Rows in Vertical Sync (1 bit equals 1 row) */
  135. #define ADVFH 0x2E /* MSB of Insert Dummy Rows in Vertical Sync */
  136. #define YAVE 0x2F /* Y/G Channel Average Value */
  137. #define HSYST 0x30 /* HSync rising edge delay */
  138. #define HSYEN 0x31 /* HSync falling edge delay */
  139. #define HREF 0x32 /* Image Start and Size Control DIFFERENT CONTROL SEQUENCE */
  140. #define CHLF 0x33 /* Array Current control */
  141. #define ARBLM 0x34 /* Array reference control */
  142. #define RSVD_35 0x35 /* Reserved */
  143. #define RSVD_36 0x36 /* Reserved */
  144. #define ADC 0x37 /* ADC control */
  145. #define ACOM 0x38 /* ADC and analog common mode control */
  146. #define OFON 0x39 /* ADC offset control */
  147. #define TSLB 0x3A /* Line buffer test option */
  148. #define COM11 0x3B /* Common control 11 */
  149. #define COM11_EXP 0x02
  150. #define COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */
  151. #define COM12 0x3C /* Common control 12 */
  152. #define COM13 0x3D /* Common control 13 */
  153. #define COM13_GAMMA 0x80 /* Gamma enable */
  154. #define COM13_UVSAT 0x40 /* UV saturation auto adjustment */
  155. #define COM14 0x3E /* Common Control 14 */
  156. #define EDGE 0x3F /* edge enhancement adjustment */
  157. #define COM15 0x40 /* Common Control 15 DIFFERENT CONTROLS */
  158. #define COM15_SET_RGB565(r,x) ((r&0xEF)|((x&1)<<4)) /* set rgb565 mode */
  159. #define COM15_RGB565 0x10 /* RGB565 output */
  160. #define COM15_R00FF 0xC0 /* Output range: [00] to [FF] */
  161. #define COM16 0x41 /* Common Control 16 DIFFERENT CONTROLS */
  162. #define COM16_AWBGAIN 0x08 /* AWB gain enable */
  163. #define COM17 0x42 /* Common Control 17 */
  164. #define AWBC1 0x43 /* Reserved */
  165. #define AWBC2 0x44 /* Reserved */
  166. #define AWBC3 0x45 /* Reserved */
  167. #define AWBC4 0x46 /* Reserved */
  168. #define AWBC5 0x47 /* Reserved */
  169. #define AWBC6 0x48 /* Reserved */
  170. #define RSVD_49 0x49 /* Reserved */
  171. #define RSVD_4A 0x4A /* Reserved */
  172. #define REG4B 0x4B /* Register 4B */
  173. #define DNSTH 0x4C /* Denoise strength */
  174. #define RSVD_4D 0x4D /* Reserved */
  175. #define RSVD_4E 0x4E /* Reserved */
  176. #define MTX1 0x4F /* Matrix coefficient 1 */
  177. #define MTX2 0x50 /* Matrix coefficient 2 */
  178. #define MTX3 0x51 /* Matrix coefficient 3 */
  179. #define MTX4 0x52 /* Matrix coefficient 4 */
  180. #define MTX5 0x53 /* Matrix coefficient 5 */
  181. #define MTX6 0x54 /* Matrix coefficient 6 */
  182. #define BRIGHTNESS 0x55 /* Brightness control */
  183. #define CONTRAST 0x56 /* Contrast control */
  184. #define CONTRASCENTER 0x57 /* Contrast center */
  185. #define MTXS 0x58 /* Matrix coefficient sign for coefficient 5 to 0*/
  186. #define RSVD_59 0x59 /* Reserved */
  187. #define RSVD_5A 0x5A /* Reserved */
  188. #define RSVD_5B 0x5B /* Reserved */
  189. #define RSVD_5C 0x5C /* Reserved */
  190. #define RSVD_5D 0x5D /* Reserved */
  191. #define RSVD_5E 0x5E /* Reserved */
  192. #define RSVD_5F 0x5F /* Reserved */
  193. #define RSVD_60 0x60 /* Reserved */
  194. #define RSVD_61 0x61 /* Reserved */
  195. #define LCC1 0x62 /* Lens correction option 1 */
  196. #define LCC2 0x63 /* Lens correction option 2 */
  197. #define LCC3 0x64 /* Lens correction option 3 */
  198. #define LCC4 0x65 /* Lens correction option 4 */
  199. #define LCC5 0x66 /* Lens correction option 5 */
  200. #define MANU 0x67 /* Manual U Value */
  201. #define MANV 0x68 /* Manual V Value */
  202. #define GFIX 0x69 /* Fix gain control */
  203. #define GGAIN 0x6A /* G channel AWB gain */
  204. #define DBLV 0x6B /* PLL and clock ? */
  205. #define AWBCTR3 0x6C /* AWB Control 3 */
  206. #define AWBCTR2 0x6D /* AWB Control 2 */
  207. #define AWBCTR1 0x6E /* AWB Control 1 */
  208. #define AWBCTR0 0x6F /* AWB Control 0 */
  209. #define SCALING_XSC 0x70 /* test pattern and horizontal scaling factor */
  210. #define SCALING_XSC_CBAR(r) (r&0x7F) /* make sure bit7 is 0 for color bar */
  211. #define SCALING_YSC 0x71 /* test pattern and vertical scaling factor */
  212. #define SCALING_YSC_CBAR(r,x) ((r&0x7F)|((x&1)<<7)) /* change bit7 for color bar on/off */
  213. #define SCALING_DCWCTR 0x72 /* DCW control */
  214. #define SCALING_PCLK_DIV 0x73 /* */
  215. #define REG74 0x74 /* */
  216. #define REG75 0x75 /* */
  217. #define REG76 0x76 /* */
  218. #define REG77 0x77 /* */
  219. #define RSVD_78 0x78 /* Reserved */
  220. #define RSVD_79 0x79 /* Reserved */
  221. #define SLOP 0x7A /* Gamma curve highest segment slope */
  222. #define GAM1 0x7B /* Gamma Curve 1st Segment Input End Point 0x04 Output Value */
  223. #define GAM2 0x7C /* Gamma Curve 2nd Segment Input End Point 0x08 Output Value */
  224. #define GAM3 0x7D /* Gamma Curve 3rd Segment Input End Point 0x10 Output Value */
  225. #define GAM4 0x7E /* Gamma Curve 4th Segment Input End Point 0x20 Output Value */
  226. #define GAM5 0x7F /* Gamma Curve 5th Segment Input End Point 0x28 Output Value */
  227. #define GAM6 0x80 /* Gamma Curve 6rd Segment Input End Point 0x30 Output Value */
  228. #define GAM7 0x81 /* Gamma Curve 7th Segment Input End Point 0x38 Output Value */
  229. #define GAM8 0x82 /* Gamma Curve 8th Segment Input End Point 0x40 Output Value */
  230. #define GAM9 0x83 /* Gamma Curve 9th Segment Input End Point 0x48 Output Value */
  231. #define GAM10 0x84 /* Gamma Curve 10th Segment Input End Point 0x50 Output Value */
  232. #define GAM11 0x85 /* Gamma Curve 11th Segment Input End Point 0x60 Output Value */
  233. #define GAM12 0x86 /* Gamma Curve 12th Segment Input End Point 0x70 Output Value */
  234. #define GAM13 0x87 /* Gamma Curve 13th Segment Input End Point 0x90 Output Value */
  235. #define GAM14 0x88 /* Gamma Curve 14th Segment Input End Point 0xB0 Output Value */
  236. #define GAM15 0x89 /* Gamma Curve 15th Segment Input End Point 0xD0 Output Value */
  237. #define RSVD_8A 0x8A /* Reserved */
  238. #define RSVD_8B 0x8B /* Reserved */
  239. #define RGB444 0x8C /* */
  240. #define RSVD_8D 0x8D /* Reserved */
  241. #define RSVD_8E 0x8E /* Reserved */
  242. #define RSVD_8F 0x8F /* Reserved */
  243. #define RSVD_90 0x90 /* Reserved */
  244. #define RSVD_91 0x91 /* Reserved */
  245. #define DM_LNL 0x92 /* Dummy line low 8 bit */
  246. #define DM_LNH 0x93 /* Dummy line high 8 bit */
  247. #define LCC6 0x94 /* Lens correction option 6 */
  248. #define LCC7 0x95 /* Lens correction option 7 */
  249. #define RSVD_96 0x96 /* Reserved */
  250. #define RSVD_97 0x97 /* Reserved */
  251. #define RSVD_98 0x98 /* Reserved */
  252. #define RSVD_99 0x99 /* Reserved */
  253. #define RSVD_9A 0x9A /* Reserved */
  254. #define RSVD_9B 0x9B /* Reserved */
  255. #define RSVD_9C 0x9C /* Reserved */
  256. #define BD50ST 0x9D /* 50 Hz banding filter value */
  257. #define BD60ST 0x9E /* 60 Hz banding filter value */
  258. #define HAECC1 0x9F /* Histogram-based AEC/AGC control 1 */
  259. #define HAECC2 0xA0 /* Histogram-based AEC/AGC control 2 */
  260. #define RSVD_A1 0xA1 /* Reserved */
  261. #define SCALING_PCLK_DELAY 0xA2 /* Pixel clock delay */
  262. #define RSVD_A3 0xA3 /* Reserved */
  263. #define NT_CNTRL 0xA4 /* */
  264. #define BD50MAX 0xA5 /* 50 Hz banding step limit */
  265. #define HAECC3 0xA6 /* Histogram-based AEC/AGC control 3 */
  266. #define HAECC4 0xA7 /* Histogram-based AEC/AGC control 4 */
  267. #define HAECC5 0xA8 /* Histogram-based AEC/AGC control 5 */
  268. #define HAECC6 0xA9 /* Histogram-based AEC/AGC control 6 */
  269. #define HAECC7 0xAA /* Histogram-based AEC/AGC control 7 */
  270. #define HAECC_EN 0x80 /* Histogram-based AEC algorithm enable */
  271. #define BD60MAX 0xAB /* 60 Hz banding step limit */
  272. #define STR_OPT 0xAC /* Register AC */
  273. #define STR_R 0xAD /* R gain for led output frame */
  274. #define STR_G 0xAE /* G gain for led output frame */
  275. #define STR_B 0xAF /* B gain for led output frame */
  276. #define RSVD_B0 0xB0 /* Reserved */
  277. #define ABLC1 0xB1 /* */
  278. #define RSVD_B2 0xB2 /* Reserved */
  279. #define THL_ST 0xB3 /* ABLC target */
  280. #define THL_DLT 0xB5 /* ABLC stable range */
  281. #define RSVD_B6 0xB6 /* Reserved */
  282. #define RSVD_B7 0xB7 /* Reserved */
  283. #define RSVD_B8 0xB8 /* Reserved */
  284. #define RSVD_B9 0xB9 /* Reserved */
  285. #define RSVD_BA 0xBA /* Reserved */
  286. #define RSVD_BB 0xBB /* Reserved */
  287. #define RSVD_BC 0xBC /* Reserved */
  288. #define RSVD_BD 0xBD /* Reserved */
  289. #define AD_CHB 0xBE /* blue channel black level compensation */
  290. #define AD_CHR 0xBF /* Red channel black level compensation */
  291. #define AD_CHGb 0xC0 /* Gb channel black level compensation */
  292. #define AD_CHGr 0xC1 /* Gr channel black level compensation */
  293. #define RSVD_C2 0xC2 /* Reserved */
  294. #define RSVD_C3 0xC3 /* Reserved */
  295. #define RSVD_C4 0xC4 /* Reserved */
  296. #define RSVD_C5 0xC5 /* Reserved */
  297. #define RSVD_C6 0xC6 /* Reserved */
  298. #define RSVD_C7 0xC7 /* Reserved */
  299. #define RSVD_C8 0xC8 /* Reserved */
  300. #define SATCTR 0xC9 /* Saturation control */
  301. #define SET_REG(reg, x) (##reg_DEFAULT|x)
  302. #endif //__OV7670_REG_REGS_H__