m5602_ov7660.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /*
  2. * Driver for the ov7660 sensor
  3. *
  4. * Copyright (C) 2009 Erik Andrén
  5. * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
  6. * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
  7. *
  8. * Portions of code to USB interface and ALi driver software,
  9. * Copyright (c) 2006 Willem Duinker
  10. * v4l2 interface modeled after the V4L2 driver
  11. * for SN9C10x PC Camera Controllers
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation, version 2.
  16. *
  17. */
  18. #ifndef M5602_OV7660_H_
  19. #define M5602_OV7660_H_
  20. #include "m5602_sensor.h"
  21. #define OV7660_GAIN 0x00
  22. #define OV7660_BLUE_GAIN 0x01
  23. #define OV7660_RED_GAIN 0x02
  24. #define OV7660_VREF 0x03
  25. #define OV7660_COM1 0x04
  26. #define OV7660_BAVE 0x05
  27. #define OV7660_GEAVE 0x06
  28. #define OV7660_AECHH 0x07
  29. #define OV7660_RAVE 0x08
  30. #define OV7660_COM2 0x09
  31. #define OV7660_PID 0x0a
  32. #define OV7660_VER 0x0b
  33. #define OV7660_COM3 0x0c
  34. #define OV7660_COM4 0x0d
  35. #define OV7660_COM5 0x0e
  36. #define OV7660_COM6 0x0f
  37. #define OV7660_AECH 0x10
  38. #define OV7660_CLKRC 0x11
  39. #define OV7660_COM7 0x12
  40. #define OV7660_COM8 0x13
  41. #define OV7660_COM9 0x14
  42. #define OV7660_COM10 0x15
  43. #define OV7660_RSVD16 0x16
  44. #define OV7660_HSTART 0x17
  45. #define OV7660_HSTOP 0x18
  46. #define OV7660_VSTART 0x19
  47. #define OV7660_VSTOP 0x1a
  48. #define OV7660_PSHFT 0x1b
  49. #define OV7660_MIDH 0x1c
  50. #define OV7660_MIDL 0x1d
  51. #define OV7660_MVFP 0x1e
  52. #define OV7660_LAEC 0x1f
  53. #define OV7660_BOS 0x20
  54. #define OV7660_GBOS 0x21
  55. #define OV7660_GROS 0x22
  56. #define OV7660_ROS 0x23
  57. #define OV7660_AEW 0x24
  58. #define OV7660_AEB 0x25
  59. #define OV7660_VPT 0x26
  60. #define OV7660_BBIAS 0x27
  61. #define OV7660_GbBIAS 0x28
  62. #define OV7660_RSVD29 0x29
  63. #define OV7660_RBIAS 0x2c
  64. #define OV7660_HREF 0x32
  65. #define OV7660_ADC 0x37
  66. #define OV7660_OFON 0x39
  67. #define OV7660_TSLB 0x3a
  68. #define OV7660_COM12 0x3c
  69. #define OV7660_COM13 0x3d
  70. #define OV7660_LCC1 0x62
  71. #define OV7660_LCC2 0x63
  72. #define OV7660_LCC3 0x64
  73. #define OV7660_LCC4 0x65
  74. #define OV7660_LCC5 0x66
  75. #define OV7660_HV 0x69
  76. #define OV7660_RSVDA1 0xa1
  77. #define OV7660_DEFAULT_GAIN 0x0e
  78. #define OV7660_DEFAULT_RED_GAIN 0x80
  79. #define OV7660_DEFAULT_BLUE_GAIN 0x80
  80. #define OV7660_DEFAULT_SATURATION 0x00
  81. #define OV7660_DEFAULT_EXPOSURE 0x20
  82. /* Kernel module parameters */
  83. extern int force_sensor;
  84. extern bool dump_sensor;
  85. int ov7660_probe(struct sd *sd);
  86. int ov7660_init(struct sd *sd);
  87. int ov7660_init(struct sd *sd);
  88. int ov7660_init_controls(struct sd *sd);
  89. int ov7660_start(struct sd *sd);
  90. int ov7660_stop(struct sd *sd);
  91. void ov7660_disconnect(struct sd *sd);
  92. static const struct m5602_sensor ov7660 = {
  93. .name = "ov7660",
  94. .i2c_slave_id = 0x42,
  95. .i2c_regW = 1,
  96. .probe = ov7660_probe,
  97. .init = ov7660_init,
  98. .init_controls = ov7660_init_controls,
  99. .start = ov7660_start,
  100. .stop = ov7660_stop,
  101. .disconnect = ov7660_disconnect,
  102. };
  103. static const unsigned char preinit_ov7660[][4] = {
  104. {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
  105. {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
  106. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  107. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  108. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  109. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d},
  110. {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},
  111. {BRIDGE, M5602_XB_GPIO_DIR, 0x03},
  112. {BRIDGE, M5602_XB_GPIO_DIR, 0x03},
  113. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  114. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  115. {SENSOR, OV7660_OFON, 0x0c},
  116. {SENSOR, OV7660_COM2, 0x11},
  117. {SENSOR, OV7660_COM7, 0x05},
  118. {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
  119. {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
  120. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  121. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
  122. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},
  123. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x08},
  124. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  125. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  126. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  127. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  128. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  129. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  130. {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
  131. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  132. {BRIDGE, M5602_XB_GPIO_EN_L, 0x00}
  133. };
  134. static const unsigned char init_ov7660[][4] = {
  135. {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
  136. {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
  137. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  138. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  139. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  140. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d},
  141. {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},
  142. {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
  143. {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
  144. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  145. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  146. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  147. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  148. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  149. {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
  150. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  151. {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
  152. {SENSOR, OV7660_COM7, 0x80},
  153. {SENSOR, OV7660_CLKRC, 0x80},
  154. {SENSOR, OV7660_COM9, 0x4c},
  155. {SENSOR, OV7660_OFON, 0x43},
  156. {SENSOR, OV7660_COM12, 0x28},
  157. {SENSOR, OV7660_COM8, 0x00},
  158. {SENSOR, OV7660_COM10, 0x40},
  159. {SENSOR, OV7660_HSTART, 0x0c},
  160. {SENSOR, OV7660_HSTOP, 0x61},
  161. {SENSOR, OV7660_HREF, 0xa4},
  162. {SENSOR, OV7660_PSHFT, 0x0b},
  163. {SENSOR, OV7660_VSTART, 0x01},
  164. {SENSOR, OV7660_VSTOP, 0x7a},
  165. {SENSOR, OV7660_VSTOP, 0x00},
  166. {SENSOR, OV7660_COM7, 0x05},
  167. {SENSOR, OV7660_COM6, 0x42},
  168. {SENSOR, OV7660_BBIAS, 0x94},
  169. {SENSOR, OV7660_GbBIAS, 0x94},
  170. {SENSOR, OV7660_RSVD29, 0x94},
  171. {SENSOR, OV7660_RBIAS, 0x94},
  172. {SENSOR, OV7660_COM1, 0x00},
  173. {SENSOR, OV7660_AECH, 0x00},
  174. {SENSOR, OV7660_AECHH, 0x00},
  175. {SENSOR, OV7660_ADC, 0x05},
  176. {SENSOR, OV7660_COM13, 0x00},
  177. {SENSOR, OV7660_RSVDA1, 0x23},
  178. {SENSOR, OV7660_TSLB, 0x0d},
  179. {SENSOR, OV7660_HV, 0x80},
  180. {SENSOR, OV7660_LCC1, 0x00},
  181. {SENSOR, OV7660_LCC2, 0x00},
  182. {SENSOR, OV7660_LCC3, 0x10},
  183. {SENSOR, OV7660_LCC4, 0x40},
  184. {SENSOR, OV7660_LCC5, 0x01},
  185. {SENSOR, OV7660_AECH, 0x20},
  186. {SENSOR, OV7660_COM1, 0x00},
  187. {SENSOR, OV7660_OFON, 0x0c},
  188. {SENSOR, OV7660_COM2, 0x11},
  189. {SENSOR, OV7660_COM7, 0x05},
  190. {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
  191. {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
  192. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  193. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
  194. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},
  195. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x08},
  196. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  197. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  198. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  199. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  200. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  201. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  202. {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
  203. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  204. {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
  205. {SENSOR, OV7660_AECH, 0x5f},
  206. {SENSOR, OV7660_COM1, 0x03},
  207. {SENSOR, OV7660_OFON, 0x0c},
  208. {SENSOR, OV7660_COM2, 0x11},
  209. {SENSOR, OV7660_COM7, 0x05},
  210. {BRIDGE, M5602_XB_GPIO_DIR, 0x01},
  211. {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
  212. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  213. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
  214. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00},
  215. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x08},
  216. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  217. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  218. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  219. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  220. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  221. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  222. {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
  223. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  224. {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
  225. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06},
  226. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  227. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  228. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  229. {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81},
  230. {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82},
  231. {BRIDGE, M5602_XB_SIG_INI, 0x01},
  232. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
  233. {BRIDGE, M5602_XB_VSYNC_PARA, 0x08},
  234. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
  235. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
  236. {BRIDGE, M5602_XB_VSYNC_PARA, 0x01},
  237. {BRIDGE, M5602_XB_VSYNC_PARA, 0xec},
  238. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
  239. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00},
  240. {BRIDGE, M5602_XB_SIG_INI, 0x00},
  241. {BRIDGE, M5602_XB_SIG_INI, 0x02},
  242. {BRIDGE, M5602_XB_HSYNC_PARA, 0x00},
  243. {BRIDGE, M5602_XB_HSYNC_PARA, 0x27},
  244. {BRIDGE, M5602_XB_HSYNC_PARA, 0x02},
  245. {BRIDGE, M5602_XB_HSYNC_PARA, 0xa7},
  246. {BRIDGE, M5602_XB_SIG_INI, 0x00},
  247. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  248. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  249. };
  250. #endif