m5602_po1030.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * Driver for the po1030 sensor.
  3. *
  4. * Copyright (c) 2008 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. * Register defines taken from Pascal Stangs Procyon Armlib
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation, version 2.
  18. *
  19. */
  20. #ifndef M5602_PO1030_H_
  21. #define M5602_PO1030_H_
  22. #include "m5602_sensor.h"
  23. /*****************************************************************************/
  24. #define PO1030_DEVID_H 0x00
  25. #define PO1030_DEVID_L 0x01
  26. #define PO1030_FRAMEWIDTH_H 0x04
  27. #define PO1030_FRAMEWIDTH_L 0x05
  28. #define PO1030_FRAMEHEIGHT_H 0x06
  29. #define PO1030_FRAMEHEIGHT_L 0x07
  30. #define PO1030_WINDOWX_H 0x08
  31. #define PO1030_WINDOWX_L 0x09
  32. #define PO1030_WINDOWY_H 0x0a
  33. #define PO1030_WINDOWY_L 0x0b
  34. #define PO1030_WINDOWWIDTH_H 0x0c
  35. #define PO1030_WINDOWWIDTH_L 0x0d
  36. #define PO1030_WINDOWHEIGHT_H 0x0e
  37. #define PO1030_WINDOWHEIGHT_L 0x0f
  38. #define PO1030_GLOBALIBIAS 0x12
  39. #define PO1030_PIXELIBIAS 0x13
  40. #define PO1030_GLOBALGAIN 0x15
  41. #define PO1030_RED_GAIN 0x16
  42. #define PO1030_GREEN_1_GAIN 0x17
  43. #define PO1030_BLUE_GAIN 0x18
  44. #define PO1030_GREEN_2_GAIN 0x19
  45. #define PO1030_INTEGLINES_H 0x1a
  46. #define PO1030_INTEGLINES_M 0x1b
  47. #define PO1030_INTEGLINES_L 0x1c
  48. #define PO1030_CONTROL1 0x1d
  49. #define PO1030_CONTROL2 0x1e
  50. #define PO1030_CONTROL3 0x1f
  51. #define PO1030_CONTROL4 0x20
  52. #define PO1030_PERIOD50_H 0x23
  53. #define PO1030_PERIOD50_L 0x24
  54. #define PO1030_PERIOD60_H 0x25
  55. #define PO1030_PERIOD60_L 0x26
  56. #define PO1030_REGCLK167 0x27
  57. #define PO1030_FLICKER_DELTA50 0x28
  58. #define PO1030_FLICKERDELTA60 0x29
  59. #define PO1030_ADCOFFSET 0x2c
  60. /* Gamma Correction Coeffs */
  61. #define PO1030_GC0 0x2d
  62. #define PO1030_GC1 0x2e
  63. #define PO1030_GC2 0x2f
  64. #define PO1030_GC3 0x30
  65. #define PO1030_GC4 0x31
  66. #define PO1030_GC5 0x32
  67. #define PO1030_GC6 0x33
  68. #define PO1030_GC7 0x34
  69. /* Color Transform Matrix */
  70. #define PO1030_CT0 0x35
  71. #define PO1030_CT1 0x36
  72. #define PO1030_CT2 0x37
  73. #define PO1030_CT3 0x38
  74. #define PO1030_CT4 0x39
  75. #define PO1030_CT5 0x3a
  76. #define PO1030_CT6 0x3b
  77. #define PO1030_CT7 0x3c
  78. #define PO1030_CT8 0x3d
  79. #define PO1030_AUTOCTRL1 0x3e
  80. #define PO1030_AUTOCTRL2 0x3f
  81. #define PO1030_YTARGET 0x40
  82. #define PO1030_GLOBALGAINMIN 0x41
  83. #define PO1030_GLOBALGAINMAX 0x42
  84. #define PO1030_AWB_RED_TUNING 0x47
  85. #define PO1030_AWB_BLUE_TUNING 0x48
  86. /* Output format control */
  87. #define PO1030_OUTFORMCTRL1 0x5a
  88. #define PO1030_OUTFORMCTRL2 0x5b
  89. #define PO1030_OUTFORMCTRL3 0x5c
  90. #define PO1030_OUTFORMCTRL4 0x5d
  91. #define PO1030_OUTFORMCTRL5 0x5e
  92. #define PO1030_EDGE_ENH_OFF 0x5f
  93. #define PO1030_EGA 0x60
  94. #define PO1030_Cb_U_GAIN 0x63
  95. #define PO1030_Cr_V_GAIN 0x64
  96. #define PO1030_YCONTRAST 0x74
  97. #define PO1030_YSATURATION 0x75
  98. #define PO1030_HFLIP (1 << 7)
  99. #define PO1030_VFLIP (1 << 6)
  100. #define PO1030_HREF_ENABLE (1 << 6)
  101. #define PO1030_RAW_RGB_BAYER 0x4
  102. #define PO1030_FRAME_EQUAL (1 << 3)
  103. #define PO1030_AUTO_SUBSAMPLING (1 << 4)
  104. #define PO1030_WEIGHT_WIN_2X (1 << 3)
  105. #define PO1030_SHUTTER_MODE (1 << 6)
  106. #define PO1030_AUTO_SUBSAMPLING (1 << 4)
  107. #define PO1030_FRAME_EQUAL (1 << 3)
  108. #define PO1030_SENSOR_RESET (1 << 5)
  109. #define PO1030_SUBSAMPLING (1 << 6)
  110. /*****************************************************************************/
  111. #define PO1030_GLOBAL_GAIN_DEFAULT 0x12
  112. #define PO1030_EXPOSURE_DEFAULT 0x0085
  113. #define PO1030_BLUE_GAIN_DEFAULT 0x36
  114. #define PO1030_RED_GAIN_DEFAULT 0x36
  115. #define PO1030_GREEN_GAIN_DEFAULT 0x40
  116. /*****************************************************************************/
  117. /* Kernel module parameters */
  118. extern int force_sensor;
  119. extern bool dump_sensor;
  120. int po1030_probe(struct sd *sd);
  121. int po1030_init(struct sd *sd);
  122. int po1030_init_controls(struct sd *sd);
  123. int po1030_start(struct sd *sd);
  124. void po1030_disconnect(struct sd *sd);
  125. static const struct m5602_sensor po1030 = {
  126. .name = "PO1030",
  127. .i2c_slave_id = 0xdc,
  128. .i2c_regW = 1,
  129. .probe = po1030_probe,
  130. .init = po1030_init,
  131. .init_controls = po1030_init_controls,
  132. .start = po1030_start,
  133. .disconnect = po1030_disconnect,
  134. };
  135. static const unsigned char preinit_po1030[][3] = {
  136. {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
  137. {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
  138. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  139. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  140. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  141. {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},
  142. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  143. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  144. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  145. {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
  146. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  147. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
  148. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02},
  149. {SENSOR, PO1030_AUTOCTRL2, PO1030_SENSOR_RESET | (1 << 2)},
  150. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04},
  151. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  152. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  153. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  154. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  155. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  156. {BRIDGE, M5602_XB_GPIO_DAT, 0x00}
  157. };
  158. static const unsigned char init_po1030[][3] = {
  159. {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02},
  160. {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0},
  161. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  162. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  163. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0},
  164. {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00},
  165. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0c},
  166. {SENSOR, PO1030_AUTOCTRL2, PO1030_SENSOR_RESET | (1 << 2)},
  167. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  168. {BRIDGE, M5602_XB_GPIO_DAT, 0x04},
  169. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  170. {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
  171. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06},
  172. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x02},
  173. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x04},
  174. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  175. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  176. {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
  177. {SENSOR, PO1030_AUTOCTRL2, 0x04},
  178. {SENSOR, PO1030_OUTFORMCTRL2, PO1030_RAW_RGB_BAYER},
  179. {SENSOR, PO1030_AUTOCTRL1, PO1030_WEIGHT_WIN_2X},
  180. {SENSOR, PO1030_CONTROL2, 0x03},
  181. {SENSOR, 0x21, 0x90},
  182. {SENSOR, PO1030_YTARGET, 0x60},
  183. {SENSOR, 0x59, 0x13},
  184. {SENSOR, PO1030_OUTFORMCTRL1, PO1030_HREF_ENABLE},
  185. {SENSOR, PO1030_EDGE_ENH_OFF, 0x00},
  186. {SENSOR, PO1030_EGA, 0x80},
  187. {SENSOR, 0x78, 0x14},
  188. {SENSOR, 0x6f, 0x01},
  189. {SENSOR, PO1030_GLOBALGAINMAX, 0x14},
  190. {SENSOR, PO1030_Cb_U_GAIN, 0x38},
  191. {SENSOR, PO1030_Cr_V_GAIN, 0x38},
  192. {SENSOR, PO1030_CONTROL1, PO1030_SHUTTER_MODE |
  193. PO1030_AUTO_SUBSAMPLING |
  194. PO1030_FRAME_EQUAL},
  195. {SENSOR, PO1030_GC0, 0x10},
  196. {SENSOR, PO1030_GC1, 0x20},
  197. {SENSOR, PO1030_GC2, 0x40},
  198. {SENSOR, PO1030_GC3, 0x60},
  199. {SENSOR, PO1030_GC4, 0x80},
  200. {SENSOR, PO1030_GC5, 0xa0},
  201. {SENSOR, PO1030_GC6, 0xc0},
  202. {SENSOR, PO1030_GC7, 0xff},
  203. /* Set the width to 751 */
  204. {SENSOR, PO1030_FRAMEWIDTH_H, 0x02},
  205. {SENSOR, PO1030_FRAMEWIDTH_L, 0xef},
  206. /* Set the height to 540 */
  207. {SENSOR, PO1030_FRAMEHEIGHT_H, 0x02},
  208. {SENSOR, PO1030_FRAMEHEIGHT_L, 0x1c},
  209. /* Set the x window to 1 */
  210. {SENSOR, PO1030_WINDOWX_H, 0x00},
  211. {SENSOR, PO1030_WINDOWX_L, 0x01},
  212. /* Set the y window to 1 */
  213. {SENSOR, PO1030_WINDOWY_H, 0x00},
  214. {SENSOR, PO1030_WINDOWY_L, 0x01},
  215. /* with a very low lighted environment increase the exposure but
  216. * decrease the FPS (Frame Per Second) */
  217. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00},
  218. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0},
  219. {BRIDGE, M5602_XB_GPIO_DIR, 0x05},
  220. {BRIDGE, M5602_XB_GPIO_DAT, 0x00},
  221. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06},
  222. {BRIDGE, M5602_XB_GPIO_EN_L, 0x00},
  223. };
  224. #endif