Linux 4.19.133
[linux/fpc-iii.git] / drivers / media / usb / gspca / stv06xx / stv06xx_vv6410.h
blobe8598893791efd4915b7d2dea69f7d082d6b737b
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
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.
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.
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
26 #ifndef STV06XX_VV6410_H_
27 #define STV06XX_VV6410_H_
29 #include "stv06xx_sensor.h"
31 #define VV6410_COLS 416
32 #define VV6410_ROWS 320
34 /* Status registers */
35 /* Chip identification number including revision indicator */
36 #define VV6410_DEVICEH 0x00
37 #define VV6410_DEVICEL 0x01
39 /* User can determine whether timed I2C data
40 has been consumed by interrogating flag states */
41 #define VV6410_STATUS0 0x02
43 /* Current line counter value */
44 #define VV6410_LINECOUNTH 0x03
45 #define VV6410_LINECOUNTL 0x04
47 /* End x coordinate of image size */
48 #define VV6410_XENDH 0x05
49 #define VV6410_XENDL 0x06
51 /* End y coordinate of image size */
52 #define VV6410_YENDH 0x07
53 #define VV6410_YENDL 0x08
55 /* This is the average pixel value returned from the
56 dark line offset cancellation algorithm */
57 #define VV6410_DARKAVGH 0x09
58 #define VV6410_DARKAVGL 0x0a
60 /* This is the average pixel value returned from the
61 black line offset cancellation algorithm */
62 #define VV6410_BLACKAVGH 0x0b
63 #define VV6410_BLACKAVGL 0x0c
65 /* Flags to indicate whether the x or y image coordinates have been clipped */
66 #define VV6410_STATUS1 0x0d
68 /* Setup registers */
70 /* Low-power/sleep modes & video timing */
71 #define VV6410_SETUP0 0x10
73 /* Various parameters */
74 #define VV6410_SETUP1 0x11
76 /* Contains pixel counter reset value used by external sync */
77 #define VV6410_SYNCVALUE 0x12
79 /* Frame grabbing modes (FST, LST and QCK) */
80 #define VV6410_FGMODES 0x14
82 /* FST and QCK mapping modes. */
83 #define VV6410_PINMAPPING 0x15
85 /* Data resolution */
86 #define VV6410_DATAFORMAT 0x16
88 /* Output coding formats */
89 #define VV6410_OPFORMAT 0x17
91 /* Various mode select bits */
92 #define VV6410_MODESELECT 0x18
94 /* Exposure registers */
95 /* Fine exposure. */
96 #define VV6410_FINEH 0x20
97 #define VV6410_FINEL 0x21
99 /* Coarse exposure */
100 #define VV6410_COARSEH 0x22
101 #define VV6410_COARSEL 0x23
103 /* Analog gain setting */
104 #define VV6410_ANALOGGAIN 0x24
106 /* Clock division */
107 #define VV6410_CLKDIV 0x25
109 /* Dark line offset cancellation value */
110 #define VV6410_DARKOFFSETH 0x2c
111 #define VV6410_DARKOFFSETL 0x2d
113 /* Dark line offset cancellation enable */
114 #define VV6410_DARKOFFSETSETUP 0x2e
116 /* Video timing registers */
117 /* Line Length (Pixel Clocks) */
118 #define VV6410_LINELENGTHH 0x52
119 #define VV6410_LINELENGTHL 0x53
121 /* X-co-ordinate of top left corner of region of interest (x-offset) */
122 #define VV6410_XOFFSETH 0x57
123 #define VV6410_XOFFSETL 0x58
125 /* Y-coordinate of top left corner of region of interest (y-offset) */
126 #define VV6410_YOFFSETH 0x59
127 #define VV6410_YOFFSETL 0x5a
129 /* Field length (Lines) */
130 #define VV6410_FIELDLENGTHH 0x61
131 #define VV6410_FIELDLENGTHL 0x62
133 /* System registers */
134 /* Black offset cancellation default value */
135 #define VV6410_BLACKOFFSETH 0x70
136 #define VV6410_BLACKOFFSETL 0x71
138 /* Black offset cancellation setup */
139 #define VV6410_BLACKOFFSETSETUP 0x72
141 /* Analog Control Register 0 */
142 #define VV6410_CR0 0x75
144 /* Analog Control Register 1 */
145 #define VV6410_CR1 0x76
147 /* ADC Setup Register */
148 #define VV6410_AS0 0x77
150 /* Analog Test Register */
151 #define VV6410_AT0 0x78
153 /* Audio Amplifier Setup Register */
154 #define VV6410_AT1 0x79
156 #define VV6410_HFLIP (1 << 3)
157 #define VV6410_VFLIP (1 << 4)
159 #define VV6410_LOW_POWER_MODE (1 << 0)
160 #define VV6410_SOFT_RESET (1 << 2)
161 #define VV6410_PAL_25_FPS (0 << 3)
163 #define VV6410_CLK_DIV_2 (1 << 1)
165 #define VV6410_FINE_EXPOSURE 320
166 #define VV6410_COARSE_EXPOSURE 192
167 #define VV6410_DEFAULT_GAIN 5
169 #define VV6410_SUBSAMPLE 0x01
170 #define VV6410_CROP_TO_QVGA 0x02
172 #define VV6410_CIF_LINELENGTH 415
174 static int vv6410_probe(struct sd *sd);
175 static int vv6410_start(struct sd *sd);
176 static int vv6410_init(struct sd *sd);
177 static int vv6410_init_controls(struct sd *sd);
178 static int vv6410_stop(struct sd *sd);
179 static int vv6410_dump(struct sd *sd);
181 /* V4L2 controls supported by the driver */
182 static int vv6410_set_hflip(struct gspca_dev *gspca_dev, __s32 val);
183 static int vv6410_set_vflip(struct gspca_dev *gspca_dev, __s32 val);
184 static int vv6410_set_analog_gain(struct gspca_dev *gspca_dev, __s32 val);
185 static int vv6410_set_exposure(struct gspca_dev *gspca_dev, __s32 val);
187 const struct stv06xx_sensor stv06xx_sensor_vv6410 = {
188 .name = "ST VV6410",
189 .i2c_flush = 5,
190 .i2c_addr = 0x20,
191 .i2c_len = 1,
192 /* FIXME (see if we can lower packet_size-s, needs testing, and also
193 adjusting framerate when the bandwidth gets lower) */
194 .min_packet_size = { 1023 },
195 .max_packet_size = { 1023 },
196 .init = vv6410_init,
197 .init_controls = vv6410_init_controls,
198 .probe = vv6410_probe,
199 .start = vv6410_start,
200 .stop = vv6410_stop,
201 .dump = vv6410_dump,
204 /* If NULL, only single value to write, stored in len */
205 struct stv_init {
206 u16 addr;
207 u8 data;
210 static const struct stv_init stv_bridge_init[] = {
211 /* This reg is written twice. Some kind of reset? */
212 {STV_RESET, 0x80},
213 {STV_RESET, 0x00},
214 {STV_SCAN_RATE, 0x00},
215 {STV_I2C_FLUSH, 0x04},
216 {STV_REG00, 0x0b},
217 {STV_REG01, 0xa7},
218 {STV_REG02, 0xb7},
219 {STV_REG03, 0x00},
220 {STV_REG04, 0x00},
221 {0x1536, 0x02},
222 {0x1537, 0x00},
223 {0x1538, 0x60},
224 {0x1539, 0x01},
225 {0x153a, 0x20},
226 {0x153b, 0x01},
229 static const u8 vv6410_sensor_init[][2] = {
230 /* Setup registers */
231 {VV6410_SETUP0, VV6410_SOFT_RESET},
232 {VV6410_SETUP0, VV6410_LOW_POWER_MODE},
233 /* Use shuffled read-out mode */
234 {VV6410_SETUP1, BIT(6)},
235 /* All modes to 1, FST, Fast QCK, Free running QCK, Free running LST, FST will qualify visible pixels */
236 {VV6410_FGMODES, BIT(6) | BIT(4) | BIT(2) | BIT(0)},
237 {VV6410_PINMAPPING, 0x00},
238 /* Pre-clock generator divide off */
239 {VV6410_DATAFORMAT, BIT(7) | BIT(0)},
241 {VV6410_CLKDIV, VV6410_CLK_DIV_2},
243 /* System registers */
244 /* Enable voltage doubler */
245 {VV6410_AS0, BIT(6) | BIT(4) | BIT(3) | BIT(2) | BIT(1)},
246 {VV6410_AT0, 0x00},
247 /* Power up audio, differential */
248 {VV6410_AT1, BIT(4) | BIT(0)},
251 #endif