ov5640_regs.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * OV5640 register definitions.
  3. */
  4. #ifndef __OV5640_REG_REGS_H__
  5. #define __OV5640_REG_REGS_H__
  6. /* system control registers */
  7. #define SYSTEM_CTROL0 0x3008 // Bit[7]: Software reset
  8. // Bit[6]: Software power down
  9. // Bit[5]: Reserved
  10. // Bit[4]: SRB clock SYNC enable
  11. // Bit[3]: Isolation suspend select
  12. // Bit[2:0]: Not used
  13. #define DRIVE_CAPABILITY 0x302c // Bit[7:6]:
  14. // 00: 1x
  15. // 01: 2x
  16. // 10: 3x
  17. // 11: 4x
  18. #define SC_PLLS_CTRL0 0x303a // Bit[7]: PLLS bypass
  19. #define SC_PLLS_CTRL1 0x303b // Bit[4:0]: PLLS multiplier
  20. #define SC_PLLS_CTRL2 0x303c // Bit[6:4]: PLLS charge pump control
  21. // Bit[3:0]: PLLS system divider
  22. #define SC_PLLS_CTRL3 0x303d // Bit[5:4]: PLLS pre-divider
  23. // 00: 1
  24. // 01: 1.5
  25. // 10: 2
  26. // 11: 3
  27. // Bit[2]: PLLS root-divider - 1
  28. // Bit[1:0]: PLLS seld5
  29. // 00: 1
  30. // 01: 1
  31. // 10: 2
  32. // 11: 2.5
  33. /* AEC/AGC control functions */
  34. #define AEC_PK_MANUAL 0x3503 // AEC Manual Mode Control
  35. // Bit[7:6]: Reserved
  36. // Bit[5]: Gain delay option
  37. // Valid when 0x3503[4]=1’b0
  38. // 0: Delay one frame latch
  39. // 1: One frame latch
  40. // Bit[4:2]: Reserved
  41. // Bit[1]: AGC manual
  42. // 0: Auto enable
  43. // 1: Manual enable
  44. // Bit[0]: AEC manual
  45. // 0: Auto enable
  46. // 1: Manual enable
  47. //gain = {0x350A[1:0], 0x350B[7:0]} / 16
  48. #define X_ADDR_ST_H 0x3800 //Bit[3:0]: X address start[11:8]
  49. #define X_ADDR_ST_L 0x3801 //Bit[7:0]: X address start[7:0]
  50. #define Y_ADDR_ST_H 0x3802 //Bit[2:0]: Y address start[10:8]
  51. #define Y_ADDR_ST_L 0x3803 //Bit[7:0]: Y address start[7:0]
  52. #define X_ADDR_END_H 0x3804 //Bit[3:0]: X address end[11:8]
  53. #define X_ADDR_END_L 0x3805 //Bit[7:0]:
  54. #define Y_ADDR_END_H 0x3806 //Bit[2:0]: Y address end[10:8]
  55. #define Y_ADDR_END_L 0x3807 //Bit[7:0]:
  56. // Size after scaling
  57. #define X_OUTPUT_SIZE_H 0x3808 //Bit[3:0]: DVP output horizontal width[11:8]
  58. #define X_OUTPUT_SIZE_L 0x3809 //Bit[7:0]:
  59. #define Y_OUTPUT_SIZE_H 0x380a //Bit[2:0]: DVP output vertical height[10:8]
  60. #define Y_OUTPUT_SIZE_L 0x380b //Bit[7:0]:
  61. #define X_TOTAL_SIZE_H 0x380c //Bit[3:0]: Total horizontal size[11:8]
  62. #define X_TOTAL_SIZE_L 0x380d //Bit[7:0]:
  63. #define Y_TOTAL_SIZE_H 0x380e //Bit[7:0]: Total vertical size[15:8]
  64. #define Y_TOTAL_SIZE_L 0x380f //Bit[7:0]:
  65. #define X_OFFSET_H 0x3810 //Bit[3:0]: ISP horizontal offset[11:8]
  66. #define X_OFFSET_L 0x3811 //Bit[7:0]:
  67. #define Y_OFFSET_H 0x3812 //Bit[2:0]: ISP vertical offset[10:8]
  68. #define Y_OFFSET_L 0x3813 //Bit[7:0]:
  69. #define X_INCREMENT 0x3814 //Bit[7:4]: Horizontal odd subsample increment
  70. //Bit[3:0]: Horizontal even subsample increment
  71. #define Y_INCREMENT 0x3815 //Bit[7:4]: Vertical odd subsample increment
  72. //Bit[3:0]: Vertical even subsample increment
  73. // Size before scaling
  74. //#define X_INPUT_SIZE (X_ADDR_END - X_ADDR_ST + 1 - (2 * X_OFFSET))
  75. //#define Y_INPUT_SIZE (Y_ADDR_END - Y_ADDR_ST + 1 - (2 * Y_OFFSET))
  76. /* mirror and flip registers */
  77. #define TIMING_TC_REG20 0x3820 // Timing Control Register
  78. // Bit[2:1]: Vertical flip enable
  79. // 00: Normal
  80. // 11: Vertical flip
  81. // Bit[0]: Vertical binning enable
  82. #define TIMING_TC_REG21 0x3821 // Timing Control Register
  83. // Bit[5]: Compression Enable
  84. // Bit[2:1]: Horizontal mirror enable
  85. // 00: Normal
  86. // 11: Horizontal mirror
  87. // Bit[0]: Horizontal binning enable
  88. #define PCLK_RATIO 0x3824 // Bit[4:0]: PCLK ratio manual
  89. /* frame control registers */
  90. #define FRAME_CTRL01 0x4201 // Control Passed Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode
  91. // Bit[7:4]: Not used
  92. // Bit[3:0]: Frame ON number
  93. #define FRAME_CTRL02 0x4202 // Control Masked Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode
  94. // Bit[7:4]: Not used
  95. // BIT[3:0]: Frame OFF number
  96. /* format control registers */
  97. #define FORMAT_CTRL00 0x4300
  98. #define CLOCK_POL_CONTROL 0x4740// Bit[5]: PCLK polarity 0: active low
  99. // 1: active high
  100. // Bit[3]: Gate PCLK under VSYNC
  101. // Bit[2]: Gate PCLK under HREF
  102. // Bit[1]: HREF polarity
  103. // 0: active low
  104. // 1: active high
  105. // Bit[0] VSYNC polarity
  106. // 0: active low
  107. // 1: active high
  108. #define ISP_CONTROL_01 0x5001 // Bit[5]: Scale enable
  109. // 0: Disable
  110. // 1: Enable
  111. /* output format control registers */
  112. #define FORMAT_CTRL 0x501F // Format select
  113. // Bit[2:0]:
  114. // 000: YUV422
  115. // 001: RGB
  116. // 010: Dither
  117. // 011: RAW after DPC
  118. // 101: RAW after CIP
  119. /* ISP top control registers */
  120. #define PRE_ISP_TEST_SETTING_1 0x503D // Bit[7]: Test enable
  121. // 0: Test disable
  122. // 1: Color bar enable
  123. // Bit[6]: Rolling
  124. // Bit[5]: Transparent
  125. // Bit[4]: Square black and white
  126. // Bit[3:2]: Color bar style
  127. // 00: Standard 8 color bar
  128. // 01: Gradual change at vertical mode 1
  129. // 10: Gradual change at horizontal
  130. // 11: Gradual change at vertical mode 2
  131. // Bit[1:0]: Test select
  132. // 00: Color bar
  133. // 01: Random data
  134. // 10: Square data
  135. // 11: Black image
  136. //exposure = {0x3500[3:0], 0x3501[7:0], 0x3502[7:0]} / 16 × tROW
  137. #define SCALE_CTRL_1 0x5601 // Bit[6:4]: HDIV RW
  138. // DCW scale times
  139. // 000: DCW 1 time
  140. // 001: DCW 2 times
  141. // 010: DCW 4 times
  142. // 100: DCW 8 times
  143. // 101: DCW 16 times
  144. // Others: DCW 16 times
  145. // Bit[2:0]: VDIV RW
  146. // DCW scale times
  147. // 000: DCW 1 time
  148. // 001: DCW 2 times
  149. // 010: DCW 4 times
  150. // 100: DCW 8 times
  151. // 101: DCW 16 times
  152. // Others: DCW 16 times
  153. #define SCALE_CTRL_2 0x5602 // X_SCALE High Bits
  154. #define SCALE_CTRL_3 0x5603 // X_SCALE Low Bits
  155. #define SCALE_CTRL_4 0x5604 // Y_SCALE High Bits
  156. #define SCALE_CTRL_5 0x5605 // Y_SCALE Low Bits
  157. #define SCALE_CTRL_6 0x5606 // Bit[3:0]: V Offset
  158. #define VFIFO_CTRL0C 0x460C // Bit[1]: PCLK manual enable
  159. // 0: Auto
  160. // 1: Manual by PCLK_RATIO
  161. #define VFIFO_X_SIZE_H 0x4602
  162. #define VFIFO_X_SIZE_L 0x4603
  163. #define VFIFO_Y_SIZE_H 0x4604
  164. #define VFIFO_Y_SIZE_L 0x4605
  165. #define COMPRESSION_CTRL00 0x4400 //
  166. #define COMPRESSION_CTRL01 0x4401 //
  167. #define COMPRESSION_CTRL02 0x4402 //
  168. #define COMPRESSION_CTRL03 0x4403 //
  169. #define COMPRESSION_CTRL04 0x4404 //
  170. #define COMPRESSION_CTRL05 0x4405 //
  171. #define COMPRESSION_CTRL06 0x4406 //
  172. #define COMPRESSION_CTRL07 0x4407 // Bit[5:0]: QS
  173. #define COMPRESSION_ISI_CTRL 0x4408 //
  174. #define COMPRESSION_CTRL09 0x4409 //
  175. #define COMPRESSION_CTRL0a 0x440a //
  176. #define COMPRESSION_CTRL0b 0x440b //
  177. #define COMPRESSION_CTRL0c 0x440c //
  178. #define COMPRESSION_CTRL0d 0x440d //
  179. #define COMPRESSION_CTRL0E 0x440e //
  180. /**
  181. * @brief register value
  182. */
  183. #define TEST_COLOR_BAR 0xC0 /* Enable Color Bar roling Test */
  184. #define AEC_PK_MANUAL_AGC_MANUALEN 0x02 /* Enable AGC Manual enable */
  185. #define AEC_PK_MANUAL_AEC_MANUALEN 0x01 /* Enable AEC Manual enable */
  186. #define TIMING_TC_REG20_VFLIP 0x06 /* Vertical flip enable */
  187. #define TIMING_TC_REG21_HMIRROR 0x06 /* Horizontal mirror enable */
  188. #endif // __OV3660_REG_REGS_H__