1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher
4 * Mark Cave-Ayland, Carlo E Prelz, Dick Streefland
5 * Copyright (c) 2002, 2003 Tuukka Toivonen
6 * Copyright (c) 2008 Erik Andrén
8 * P/N 861037: Sensor HDCS1000 ASIC STV0600
9 * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600
10 * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express
11 * P/N 861055: Sensor ST VV6410 ASIC STV0610 - LEGO cam
12 * P/N 861075-0040: Sensor HDCS1000 ASIC
13 * P/N 961179-0700: Sensor ST VV6410 ASIC STV0602 - Dexxa WebCam USB
14 * P/N 861040-0000: Sensor ST VV6410 ASIC STV0610 - QuickCam Web
17 #ifndef STV06XX_VV6410_H_
18 #define STV06XX_VV6410_H_
20 #include "stv06xx_sensor.h"
22 #define VV6410_COLS 416
23 #define VV6410_ROWS 320
25 /* Status registers */
26 /* Chip identification number including revision indicator */
27 #define VV6410_DEVICEH 0x00
28 #define VV6410_DEVICEL 0x01
30 /* User can determine whether timed I2C data
31 has been consumed by interrogating flag states */
32 #define VV6410_STATUS0 0x02
34 /* Current line counter value */
35 #define VV6410_LINECOUNTH 0x03
36 #define VV6410_LINECOUNTL 0x04
38 /* End x coordinate of image size */
39 #define VV6410_XENDH 0x05
40 #define VV6410_XENDL 0x06
42 /* End y coordinate of image size */
43 #define VV6410_YENDH 0x07
44 #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
51 /* This is the average pixel value returned from the
52 black line offset cancellation algorithm */
53 #define VV6410_BLACKAVGH 0x0b
54 #define VV6410_BLACKAVGL 0x0c
56 /* Flags to indicate whether the x or y image coordinates have been clipped */
57 #define VV6410_STATUS1 0x0d
61 /* Low-power/sleep modes & video timing */
62 #define VV6410_SETUP0 0x10
64 /* Various parameters */
65 #define VV6410_SETUP1 0x11
67 /* Contains pixel counter reset value used by external sync */
68 #define VV6410_SYNCVALUE 0x12
70 /* Frame grabbing modes (FST, LST and QCK) */
71 #define VV6410_FGMODES 0x14
73 /* FST and QCK mapping modes. */
74 #define VV6410_PINMAPPING 0x15
77 #define VV6410_DATAFORMAT 0x16
79 /* Output coding formats */
80 #define VV6410_OPFORMAT 0x17
82 /* Various mode select bits */
83 #define VV6410_MODESELECT 0x18
85 /* Exposure registers */
87 #define VV6410_FINEH 0x20
88 #define VV6410_FINEL 0x21
91 #define VV6410_COARSEH 0x22
92 #define VV6410_COARSEL 0x23
94 /* Analog gain setting */
95 #define VV6410_ANALOGGAIN 0x24
98 #define VV6410_CLKDIV 0x25
100 /* Dark line offset cancellation value */
101 #define VV6410_DARKOFFSETH 0x2c
102 #define VV6410_DARKOFFSETL 0x2d
104 /* Dark line offset cancellation enable */
105 #define VV6410_DARKOFFSETSETUP 0x2e
107 /* Video timing registers */
108 /* Line Length (Pixel Clocks) */
109 #define VV6410_LINELENGTHH 0x52
110 #define VV6410_LINELENGTHL 0x53
112 /* X-co-ordinate of top left corner of region of interest (x-offset) */
113 #define VV6410_XOFFSETH 0x57
114 #define VV6410_XOFFSETL 0x58
116 /* Y-coordinate of top left corner of region of interest (y-offset) */
117 #define VV6410_YOFFSETH 0x59
118 #define VV6410_YOFFSETL 0x5a
120 /* Field length (Lines) */
121 #define VV6410_FIELDLENGTHH 0x61
122 #define VV6410_FIELDLENGTHL 0x62
124 /* System registers */
125 /* Black offset cancellation default value */
126 #define VV6410_BLACKOFFSETH 0x70
127 #define VV6410_BLACKOFFSETL 0x71
129 /* Black offset cancellation setup */
130 #define VV6410_BLACKOFFSETSETUP 0x72
132 /* Analog Control Register 0 */
133 #define VV6410_CR0 0x75
135 /* Analog Control Register 1 */
136 #define VV6410_CR1 0x76
138 /* ADC Setup Register */
139 #define VV6410_AS0 0x77
141 /* Analog Test Register */
142 #define VV6410_AT0 0x78
144 /* Audio Amplifier Setup Register */
145 #define VV6410_AT1 0x79
147 #define VV6410_HFLIP (1 << 3)
148 #define VV6410_VFLIP (1 << 4)
150 #define VV6410_LOW_POWER_MODE (1 << 0)
151 #define VV6410_SOFT_RESET (1 << 2)
152 #define VV6410_PAL_25_FPS (0 << 3)
154 #define VV6410_CLK_DIV_2 (1 << 1)
156 #define VV6410_FINE_EXPOSURE 320
157 #define VV6410_COARSE_EXPOSURE 192
158 #define VV6410_DEFAULT_GAIN 5
160 #define VV6410_SUBSAMPLE 0x01
161 #define VV6410_CROP_TO_QVGA 0x02
163 #define VV6410_CIF_LINELENGTH 415
165 static int vv6410_probe(struct sd
*sd
);
166 static int vv6410_start(struct sd
*sd
);
167 static int vv6410_init(struct sd
*sd
);
168 static int vv6410_init_controls(struct sd
*sd
);
169 static int vv6410_stop(struct sd
*sd
);
170 static int vv6410_dump(struct sd
*sd
);
172 /* V4L2 controls supported by the driver */
173 static int vv6410_set_hflip(struct gspca_dev
*gspca_dev
, __s32 val
);
174 static int vv6410_set_vflip(struct gspca_dev
*gspca_dev
, __s32 val
);
175 static int vv6410_set_analog_gain(struct gspca_dev
*gspca_dev
, __s32 val
);
176 static int vv6410_set_exposure(struct gspca_dev
*gspca_dev
, __s32 val
);
178 const struct stv06xx_sensor stv06xx_sensor_vv6410
= {
183 /* FIXME (see if we can lower packet_size-s, needs testing, and also
184 adjusting framerate when the bandwidth gets lower) */
185 .min_packet_size
= { 1023 },
186 .max_packet_size
= { 1023 },
188 .init_controls
= vv6410_init_controls
,
189 .probe
= vv6410_probe
,
190 .start
= vv6410_start
,
195 /* If NULL, only single value to write, stored in len */
201 static const struct stv_init stv_bridge_init
[] = {
202 /* This reg is written twice. Some kind of reset? */
205 {STV_SCAN_RATE
, 0x00},
206 {STV_I2C_FLUSH
, 0x04},
220 static const u8 vv6410_sensor_init
[][2] = {
221 /* Setup registers */
222 {VV6410_SETUP0
, VV6410_SOFT_RESET
},
223 {VV6410_SETUP0
, VV6410_LOW_POWER_MODE
},
224 /* Use shuffled read-out mode */
225 {VV6410_SETUP1
, BIT(6)},
226 /* All modes to 1, FST, Fast QCK, Free running QCK, Free running LST, FST will qualify visible pixels */
227 {VV6410_FGMODES
, BIT(6) | BIT(4) | BIT(2) | BIT(0)},
228 {VV6410_PINMAPPING
, 0x00},
229 /* Pre-clock generator divide off */
230 {VV6410_DATAFORMAT
, BIT(7) | BIT(0)},
232 {VV6410_CLKDIV
, VV6410_CLK_DIV_2
},
234 /* System registers */
235 /* Enable voltage doubler */
236 {VV6410_AS0
, BIT(6) | BIT(4) | BIT(3) | BIT(2) | BIT(1)},
238 /* Power up audio, differential */
239 {VV6410_AT1
, BIT(4) | BIT(0)},