stv06xx_vv6410.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*
  2. * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher
  3. * Mark Cave-Ayland, Carlo E Prelz, Dick Streefland
  4. * Copyright (c) 2002, 2003 Tuukka Toivonen
  5. * Copyright (c) 2008 Erik Andrén
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * P/N 861037: Sensor HDCS1000 ASIC STV0600
  22. * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
  23. * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
  24. * P/N 861055: Sensor ST VV6410 ASIC STV0610 - LEGO cam
  25. * P/N 861075-0040: Sensor HDCS1000 ASIC
  26. * P/N 961179-0700: Sensor ST VV6410 ASIC STV0602 - Dexxa WebCam USB
  27. * P/N 861040-0000: Sensor ST VV6410 ASIC STV0610 - QuickCam Web
  28. */
  29. #ifndef STV06XX_VV6410_H_
  30. #define STV06XX_VV6410_H_
  31. #include "stv06xx_sensor.h"
  32. #define VV6410_COLS 416
  33. #define VV6410_ROWS 320
  34. /* Status registers */
  35. /* Chip identification number including revision indicator */
  36. #define VV6410_DEVICEH 0x00
  37. #define VV6410_DEVICEL 0x01
  38. /* User can determine whether timed I2C data
  39. has been consumed by interrogating flag states */
  40. #define VV6410_STATUS0 0x02
  41. /* Current line counter value */
  42. #define VV6410_LINECOUNTH 0x03
  43. #define VV6410_LINECOUNTL 0x04
  44. /* End x coordinate of image size */
  45. #define VV6410_XENDH 0x05
  46. #define VV6410_XENDL 0x06
  47. /* End y coordinate of image size */
  48. #define VV6410_YENDH 0x07
  49. #define VV6410_YENDL 0x08
  50. /* This is the average pixel value returned from the
  51. dark line offset cancellation algorithm */
  52. #define VV6410_DARKAVGH 0x09
  53. #define VV6410_DARKAVGL 0x0a
  54. /* This is the average pixel value returned from the
  55. black line offset cancellation algorithm */
  56. #define VV6410_BLACKAVGH 0x0b
  57. #define VV6410_BLACKAVGL 0x0c
  58. /* Flags to indicate whether the x or y image coordinates have been clipped */
  59. #define VV6410_STATUS1 0x0d
  60. /* Setup registers */
  61. /* Low-power/sleep modes & video timing */
  62. #define VV6410_SETUP0 0x10
  63. /* Various parameters */
  64. #define VV6410_SETUP1 0x11
  65. /* Contains pixel counter reset value used by external sync */
  66. #define VV6410_SYNCVALUE 0x12
  67. /* Frame grabbing modes (FST, LST and QCK) */
  68. #define VV6410_FGMODES 0x14
  69. /* FST and QCK mapping modes. */
  70. #define VV6410_PINMAPPING 0x15
  71. /* Data resolution */
  72. #define VV6410_DATAFORMAT 0x16
  73. /* Output coding formats */
  74. #define VV6410_OPFORMAT 0x17
  75. /* Various mode select bits */
  76. #define VV6410_MODESELECT 0x18
  77. /* Exposure registers */
  78. /* Fine exposure. */
  79. #define VV6410_FINEH 0x20
  80. #define VV6410_FINEL 0x21
  81. /* Coarse exposure */
  82. #define VV6410_COARSEH 0x22
  83. #define VV6410_COARSEL 0x23
  84. /* Analog gain setting */
  85. #define VV6410_ANALOGGAIN 0x24
  86. /* Clock division */
  87. #define VV6410_CLKDIV 0x25
  88. /* Dark line offset cancellation value */
  89. #define VV6410_DARKOFFSETH 0x2c
  90. #define VV6410_DARKOFFSETL 0x2d
  91. /* Dark line offset cancellation enable */
  92. #define VV6410_DARKOFFSETSETUP 0x2e
  93. /* Video timing registers */
  94. /* Line Length (Pixel Clocks) */
  95. #define VV6410_LINELENGTHH 0x52
  96. #define VV6410_LINELENGTHL 0x53
  97. /* X-co-ordinate of top left corner of region of interest (x-offset) */
  98. #define VV6410_XOFFSETH 0x57
  99. #define VV6410_XOFFSETL 0x58
  100. /* Y-coordinate of top left corner of region of interest (y-offset) */
  101. #define VV6410_YOFFSETH 0x59
  102. #define VV6410_YOFFSETL 0x5a
  103. /* Field length (Lines) */
  104. #define VV6410_FIELDLENGTHH 0x61
  105. #define VV6410_FIELDLENGTHL 0x62
  106. /* System registers */
  107. /* Black offset cancellation default value */
  108. #define VV6410_BLACKOFFSETH 0x70
  109. #define VV6410_BLACKOFFSETL 0x71
  110. /* Black offset cancellation setup */
  111. #define VV6410_BLACKOFFSETSETUP 0x72
  112. /* Analog Control Register 0 */
  113. #define VV6410_CR0 0x75
  114. /* Analog Control Register 1 */
  115. #define VV6410_CR1 0x76
  116. /* ADC Setup Register */
  117. #define VV6410_AS0 0x77
  118. /* Analog Test Register */
  119. #define VV6410_AT0 0x78
  120. /* Audio Amplifier Setup Register */
  121. #define VV6410_AT1 0x79
  122. #define VV6410_HFLIP (1 << 3)
  123. #define VV6410_VFLIP (1 << 4)
  124. #define VV6410_LOW_POWER_MODE (1 << 0)
  125. #define VV6410_SOFT_RESET (1 << 2)
  126. #define VV6410_PAL_25_FPS (0 << 3)
  127. #define VV6410_CLK_DIV_2 (1 << 1)
  128. #define VV6410_FINE_EXPOSURE 320
  129. #define VV6410_COARSE_EXPOSURE 192
  130. #define VV6410_DEFAULT_GAIN 5
  131. #define VV6410_SUBSAMPLE 0x01
  132. #define VV6410_CROP_TO_QVGA 0x02
  133. #define VV6410_CIF_LINELENGTH 415
  134. static int vv6410_probe(struct sd *sd);
  135. static int vv6410_start(struct sd *sd);
  136. static int vv6410_init(struct sd *sd);
  137. static int vv6410_init_controls(struct sd *sd);
  138. static int vv6410_stop(struct sd *sd);
  139. static int vv6410_dump(struct sd *sd);
  140. /* V4L2 controls supported by the driver */
  141. static int vv6410_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
  142. static int vv6410_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
  143. static int vv6410_set_analog_gain(struct gspca_dev *gspca_dev, __s32 val);
  144. static int vv6410_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
  145. const struct stv06xx_sensor stv06xx_sensor_vv6410 = {
  146. .name = "ST VV6410",
  147. .i2c_flush = 5,
  148. .i2c_addr = 0x20,
  149. .i2c_len = 1,
  150. /* FIXME (see if we can lower packet_size-s, needs testing, and also
  151. adjusting framerate when the bandwidth gets lower) */
  152. .min_packet_size = { 1023 },
  153. .max_packet_size = { 1023 },
  154. .init = vv6410_init,
  155. .init_controls = vv6410_init_controls,
  156. .probe = vv6410_probe,
  157. .start = vv6410_start,
  158. .stop = vv6410_stop,
  159. .dump = vv6410_dump,
  160. };
  161. /* If NULL, only single value to write, stored in len */
  162. struct stv_init {
  163. u16 addr;
  164. u8 data;
  165. };
  166. static const struct stv_init stv_bridge_init[] = {
  167. /* This reg is written twice. Some kind of reset? */
  168. {STV_RESET, 0x80},
  169. {STV_RESET, 0x00},
  170. {STV_SCAN_RATE, 0x00},
  171. {STV_I2C_FLUSH, 0x04},
  172. {STV_REG00, 0x0b},
  173. {STV_REG01, 0xa7},
  174. {STV_REG02, 0xb7},
  175. {STV_REG03, 0x00},
  176. {STV_REG04, 0x00},
  177. {0x1536, 0x02},
  178. {0x1537, 0x00},
  179. {0x1538, 0x60},
  180. {0x1539, 0x01},
  181. {0x153a, 0x20},
  182. {0x153b, 0x01},
  183. };
  184. static const u8 vv6410_sensor_init[][2] = {
  185. /* Setup registers */
  186. {VV6410_SETUP0, VV6410_SOFT_RESET},
  187. {VV6410_SETUP0, VV6410_LOW_POWER_MODE},
  188. /* Use shuffled read-out mode */
  189. {VV6410_SETUP1, BIT(6)},
  190. /* All modes to 1, FST, Fast QCK, Free running QCK, Free running LST, FST will qualify visible pixels */
  191. {VV6410_FGMODES, BIT(6) | BIT(4) | BIT(2) | BIT(0)},
  192. {VV6410_PINMAPPING, 0x00},
  193. /* Pre-clock generator divide off */
  194. {VV6410_DATAFORMAT, BIT(7) | BIT(0)},
  195. {VV6410_CLKDIV, VV6410_CLK_DIV_2},
  196. /* System registers */
  197. /* Enable voltage doubler */
  198. {VV6410_AS0, BIT(6) | BIT(4) | BIT(3) | BIT(2) | BIT(1)},
  199. {VV6410_AT0, 0x00},
  200. /* Power up audio, differential */
  201. {VV6410_AT1, BIT(4) | BIT(0)},
  202. };
  203. #endif