ov9640.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * OmniVision OV96xx Camera Header File
  3. *
  4. * Copyright (C) 2009 Marek Vasut <marek.vasut@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __DRIVERS_MEDIA_VIDEO_OV9640_H__
  11. #define __DRIVERS_MEDIA_VIDEO_OV9640_H__
  12. /* Register definitions */
  13. #define OV9640_GAIN 0x00
  14. #define OV9640_BLUE 0x01
  15. #define OV9640_RED 0x02
  16. #define OV9640_VFER 0x03
  17. #define OV9640_COM1 0x04
  18. #define OV9640_BAVE 0x05
  19. #define OV9640_GEAVE 0x06
  20. #define OV9640_RSID 0x07
  21. #define OV9640_RAVE 0x08
  22. #define OV9640_COM2 0x09
  23. #define OV9640_PID 0x0a
  24. #define OV9640_VER 0x0b
  25. #define OV9640_COM3 0x0c
  26. #define OV9640_COM4 0x0d
  27. #define OV9640_COM5 0x0e
  28. #define OV9640_COM6 0x0f
  29. #define OV9640_AECH 0x10
  30. #define OV9640_CLKRC 0x11
  31. #define OV9640_COM7 0x12
  32. #define OV9640_COM8 0x13
  33. #define OV9640_COM9 0x14
  34. #define OV9640_COM10 0x15
  35. /* 0x16 - RESERVED */
  36. #define OV9640_HSTART 0x17
  37. #define OV9640_HSTOP 0x18
  38. #define OV9640_VSTART 0x19
  39. #define OV9640_VSTOP 0x1a
  40. #define OV9640_PSHFT 0x1b
  41. #define OV9640_MIDH 0x1c
  42. #define OV9640_MIDL 0x1d
  43. #define OV9640_MVFP 0x1e
  44. #define OV9640_LAEC 0x1f
  45. #define OV9640_BOS 0x20
  46. #define OV9640_GBOS 0x21
  47. #define OV9640_GROS 0x22
  48. #define OV9640_ROS 0x23
  49. #define OV9640_AEW 0x24
  50. #define OV9640_AEB 0x25
  51. #define OV9640_VPT 0x26
  52. #define OV9640_BBIAS 0x27
  53. #define OV9640_GBBIAS 0x28
  54. /* 0x29 - RESERVED */
  55. #define OV9640_EXHCH 0x2a
  56. #define OV9640_EXHCL 0x2b
  57. #define OV9640_RBIAS 0x2c
  58. #define OV9640_ADVFL 0x2d
  59. #define OV9640_ADVFH 0x2e
  60. #define OV9640_YAVE 0x2f
  61. #define OV9640_HSYST 0x30
  62. #define OV9640_HSYEN 0x31
  63. #define OV9640_HREF 0x32
  64. #define OV9640_CHLF 0x33
  65. #define OV9640_ARBLM 0x34
  66. /* 0x35..0x36 - RESERVED */
  67. #define OV9640_ADC 0x37
  68. #define OV9640_ACOM 0x38
  69. #define OV9640_OFON 0x39
  70. #define OV9640_TSLB 0x3a
  71. #define OV9640_COM11 0x3b
  72. #define OV9640_COM12 0x3c
  73. #define OV9640_COM13 0x3d
  74. #define OV9640_COM14 0x3e
  75. #define OV9640_EDGE 0x3f
  76. #define OV9640_COM15 0x40
  77. #define OV9640_COM16 0x41
  78. #define OV9640_COM17 0x42
  79. /* 0x43..0x4e - RESERVED */
  80. #define OV9640_MTX1 0x4f
  81. #define OV9640_MTX2 0x50
  82. #define OV9640_MTX3 0x51
  83. #define OV9640_MTX4 0x52
  84. #define OV9640_MTX5 0x53
  85. #define OV9640_MTX6 0x54
  86. #define OV9640_MTX7 0x55
  87. #define OV9640_MTX8 0x56
  88. #define OV9640_MTX9 0x57
  89. #define OV9640_MTXS 0x58
  90. /* 0x59..0x61 - RESERVED */
  91. #define OV9640_LCC1 0x62
  92. #define OV9640_LCC2 0x63
  93. #define OV9640_LCC3 0x64
  94. #define OV9640_LCC4 0x65
  95. #define OV9640_LCC5 0x66
  96. #define OV9640_MANU 0x67
  97. #define OV9640_MANV 0x68
  98. #define OV9640_HV 0x69
  99. #define OV9640_MBD 0x6a
  100. #define OV9640_DBLV 0x6b
  101. #define OV9640_GSP 0x6c /* ... till 0x7b */
  102. #define OV9640_GST 0x7c /* ... till 0x8a */
  103. #define OV9640_CLKRC_DPLL_EN 0x80
  104. #define OV9640_CLKRC_DIRECT 0x40
  105. #define OV9640_CLKRC_DIV(x) ((x) & 0x3f)
  106. #define OV9640_PSHFT_VAL(x) ((x) & 0xff)
  107. #define OV9640_ACOM_2X_ANALOG 0x80
  108. #define OV9640_ACOM_RSVD 0x12
  109. #define OV9640_MVFP_V 0x10
  110. #define OV9640_MVFP_H 0x20
  111. #define OV9640_COM1_HREF_NOSKIP 0x00
  112. #define OV9640_COM1_HREF_2SKIP 0x04
  113. #define OV9640_COM1_HREF_3SKIP 0x08
  114. #define OV9640_COM1_QQFMT 0x20
  115. #define OV9640_COM2_SSM 0x10
  116. #define OV9640_COM3_VP 0x04
  117. #define OV9640_COM4_QQ_VP 0x80
  118. #define OV9640_COM4_RSVD 0x40
  119. #define OV9640_COM5_SYSCLK 0x80
  120. #define OV9640_COM5_LONGEXP 0x01
  121. #define OV9640_COM6_OPT_BLC 0x40
  122. #define OV9640_COM6_ADBLC_BIAS 0x08
  123. #define OV9640_COM6_FMT_RST 0x82
  124. #define OV9640_COM6_ADBLC_OPTEN 0x01
  125. #define OV9640_COM7_RAW_RGB 0x01
  126. #define OV9640_COM7_RGB 0x04
  127. #define OV9640_COM7_QCIF 0x08
  128. #define OV9640_COM7_QVGA 0x10
  129. #define OV9640_COM7_CIF 0x20
  130. #define OV9640_COM7_VGA 0x40
  131. #define OV9640_COM7_SCCB_RESET 0x80
  132. #define OV9640_TSLB_YVYU_YUYV 0x04
  133. #define OV9640_TSLB_YUYV_UYVY 0x08
  134. #define OV9640_COM12_YUV_AVG 0x04
  135. #define OV9640_COM12_RSVD 0x40
  136. #define OV9640_COM13_GAMMA_NONE 0x00
  137. #define OV9640_COM13_GAMMA_Y 0x40
  138. #define OV9640_COM13_GAMMA_RAW 0x80
  139. #define OV9640_COM13_RGB_AVG 0x20
  140. #define OV9640_COM13_MATRIX_EN 0x10
  141. #define OV9640_COM13_Y_DELAY_EN 0x08
  142. #define OV9640_COM13_YUV_DLY(x) ((x) & 0x07)
  143. #define OV9640_COM15_OR_00FF 0x00
  144. #define OV9640_COM15_OR_01FE 0x40
  145. #define OV9640_COM15_OR_10F0 0xc0
  146. #define OV9640_COM15_RGB_NORM 0x00
  147. #define OV9640_COM15_RGB_565 0x10
  148. #define OV9640_COM15_RGB_555 0x30
  149. #define OV9640_COM16_RB_AVG 0x01
  150. /* IDs */
  151. #define OV9640_V2 0x9648
  152. #define OV9640_V3 0x9649
  153. #define VERSION(pid, ver) (((pid) << 8) | ((ver) & 0xFF))
  154. /* supported resolutions */
  155. enum {
  156. W_QQCIF = 88,
  157. W_QQVGA = 160,
  158. W_QCIF = 176,
  159. W_QVGA = 320,
  160. W_CIF = 352,
  161. W_VGA = 640,
  162. W_SXGA = 1280
  163. };
  164. #define H_SXGA 960
  165. /* Misc. structures */
  166. struct ov9640_reg_alt {
  167. u8 com7;
  168. u8 com12;
  169. u8 com13;
  170. u8 com15;
  171. };
  172. struct ov9640_reg {
  173. u8 reg;
  174. u8 val;
  175. };
  176. struct ov9640_priv {
  177. struct v4l2_subdev subdev;
  178. struct v4l2_ctrl_handler hdl;
  179. struct v4l2_clk *clk;
  180. int model;
  181. int revision;
  182. };
  183. #endif /* __DRIVERS_MEDIA_VIDEO_OV9640_H__ */