stv06xx_vv6410.h 6.9 KB

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