V4L/DVB (13380): sms-cards: make id unsigned in sms_get_board()
[deliverable/linux.git] / drivers / media / video / gspca / sonixj.c
1 /*
2 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
3 * Copyright (C) 2009 Jean-Francois Moine <http://moinejf.free.fr>
4 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #define MODULE_NAME "sonixj"
22
23 #include "gspca.h"
24 #include "jpeg.h"
25
26 #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
27
28 MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29 MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
30 MODULE_LICENSE("GPL");
31
32 /* specific webcam descriptor */
33 struct sd {
34 struct gspca_dev gspca_dev; /* !! must be the first item */
35
36 atomic_t avg_lum;
37 u32 exposure;
38
39 u16 brightness;
40 u8 contrast;
41 u8 colors;
42 u8 autogain;
43 u8 blue;
44 u8 red;
45 u8 gamma;
46 u8 vflip; /* ov7630/ov7648 only */
47 u8 infrared; /* mt9v111 only */
48 u8 freq; /* ov76xx only */
49 u8 quality; /* image quality */
50 #define QUALITY_MIN 60
51 #define QUALITY_MAX 95
52 #define QUALITY_DEF 80
53 u8 jpegqual; /* webcam quality */
54
55 u8 reg18;
56
57 s8 ag_cnt;
58 #define AG_CNT_START 13
59
60 u8 bridge;
61 #define BRIDGE_SN9C102P 0
62 #define BRIDGE_SN9C105 1
63 #define BRIDGE_SN9C110 2
64 #define BRIDGE_SN9C120 3
65 u8 sensor; /* Type of image sensor chip */
66 #define SENSOR_HV7131R 0
67 #define SENSOR_MI0360 1
68 #define SENSOR_MO4000 2
69 #define SENSOR_MT9V111 3
70 #define SENSOR_OM6802 4
71 #define SENSOR_OV7630 5
72 #define SENSOR_OV7648 6
73 #define SENSOR_OV7660 7
74 #define SENSOR_SP80708 8
75 u8 i2c_base;
76
77 u8 *jpeg_hdr;
78 };
79
80 /* V4L2 controls supported by the driver */
81 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
82 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
83 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
84 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
85 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
86 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
87 static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
88 static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
89 static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
90 static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
91 static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
92 static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
93 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
94 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
95 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
96 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
97 static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
98 static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
99 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
100 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
101
102 static struct ctrl sd_ctrls[] = {
103 #define BRIGHTNESS_IDX 0
104 {
105 {
106 .id = V4L2_CID_BRIGHTNESS,
107 .type = V4L2_CTRL_TYPE_INTEGER,
108 .name = "Brightness",
109 .minimum = 0,
110 #define BRIGHTNESS_MAX 0xffff
111 .maximum = BRIGHTNESS_MAX,
112 .step = 1,
113 #define BRIGHTNESS_DEF 0x8000
114 .default_value = BRIGHTNESS_DEF,
115 },
116 .set = sd_setbrightness,
117 .get = sd_getbrightness,
118 },
119 #define CONTRAST_IDX 1
120 {
121 {
122 .id = V4L2_CID_CONTRAST,
123 .type = V4L2_CTRL_TYPE_INTEGER,
124 .name = "Contrast",
125 .minimum = 0,
126 #define CONTRAST_MAX 127
127 .maximum = CONTRAST_MAX,
128 .step = 1,
129 #define CONTRAST_DEF 63
130 .default_value = CONTRAST_DEF,
131 },
132 .set = sd_setcontrast,
133 .get = sd_getcontrast,
134 },
135 #define COLOR_IDX 2
136 {
137 {
138 .id = V4L2_CID_SATURATION,
139 .type = V4L2_CTRL_TYPE_INTEGER,
140 .name = "Saturation",
141 .minimum = 0,
142 .maximum = 40,
143 .step = 1,
144 #define COLOR_DEF 25
145 .default_value = COLOR_DEF,
146 },
147 .set = sd_setcolors,
148 .get = sd_getcolors,
149 },
150 #define BLUE_BALANCE_IDX 3
151 {
152 {
153 .id = V4L2_CID_BLUE_BALANCE,
154 .type = V4L2_CTRL_TYPE_INTEGER,
155 .name = "Blue Balance",
156 .minimum = 24,
157 .maximum = 40,
158 .step = 1,
159 #define BLUE_BALANCE_DEF 32
160 .default_value = BLUE_BALANCE_DEF,
161 },
162 .set = sd_setblue_balance,
163 .get = sd_getblue_balance,
164 },
165 #define RED_BALANCE_IDX 4
166 {
167 {
168 .id = V4L2_CID_RED_BALANCE,
169 .type = V4L2_CTRL_TYPE_INTEGER,
170 .name = "Red Balance",
171 .minimum = 24,
172 .maximum = 40,
173 .step = 1,
174 #define RED_BALANCE_DEF 32
175 .default_value = RED_BALANCE_DEF,
176 },
177 .set = sd_setred_balance,
178 .get = sd_getred_balance,
179 },
180 #define GAMMA_IDX 5
181 {
182 {
183 .id = V4L2_CID_GAMMA,
184 .type = V4L2_CTRL_TYPE_INTEGER,
185 .name = "Gamma",
186 .minimum = 0,
187 .maximum = 40,
188 .step = 1,
189 #define GAMMA_DEF 20
190 .default_value = GAMMA_DEF,
191 },
192 .set = sd_setgamma,
193 .get = sd_getgamma,
194 },
195 #define AUTOGAIN_IDX 6
196 {
197 {
198 .id = V4L2_CID_AUTOGAIN,
199 .type = V4L2_CTRL_TYPE_BOOLEAN,
200 .name = "Auto Gain",
201 .minimum = 0,
202 .maximum = 1,
203 .step = 1,
204 #define AUTOGAIN_DEF 1
205 .default_value = AUTOGAIN_DEF,
206 },
207 .set = sd_setautogain,
208 .get = sd_getautogain,
209 },
210 /* ov7630/ov7648 only */
211 #define VFLIP_IDX 7
212 {
213 {
214 .id = V4L2_CID_VFLIP,
215 .type = V4L2_CTRL_TYPE_BOOLEAN,
216 .name = "Vflip",
217 .minimum = 0,
218 .maximum = 1,
219 .step = 1,
220 #define VFLIP_DEF 0
221 .default_value = VFLIP_DEF,
222 },
223 .set = sd_setvflip,
224 .get = sd_getvflip,
225 },
226 /* mt9v111 only */
227 #define INFRARED_IDX 8
228 {
229 {
230 .id = V4L2_CID_INFRARED,
231 .type = V4L2_CTRL_TYPE_BOOLEAN,
232 .name = "Infrared",
233 .minimum = 0,
234 .maximum = 1,
235 .step = 1,
236 #define INFRARED_DEF 0
237 .default_value = INFRARED_DEF,
238 },
239 .set = sd_setinfrared,
240 .get = sd_getinfrared,
241 },
242 /* ov7630/ov7648/ov7660 only */
243 #define FREQ_IDX 9
244 {
245 {
246 .id = V4L2_CID_POWER_LINE_FREQUENCY,
247 .type = V4L2_CTRL_TYPE_MENU,
248 .name = "Light frequency filter",
249 .minimum = 0,
250 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
251 .step = 1,
252 #define FREQ_DEF 2
253 .default_value = FREQ_DEF,
254 },
255 .set = sd_setfreq,
256 .get = sd_getfreq,
257 },
258 };
259
260 /* table of the disabled controls */
261 static __u32 ctrl_dis[] = {
262 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
263 /* SENSOR_HV7131R 0 */
264 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
265 /* SENSOR_MI0360 1 */
266 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
267 /* SENSOR_MO4000 2 */
268 (1 << VFLIP_IDX) | (1 << FREQ_IDX),
269 /* SENSOR_MT9V111 3 */
270 (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX),
271 /* SENSOR_OM6802 4 */
272 (1 << INFRARED_IDX),
273 /* SENSOR_OV7630 5 */
274 (1 << INFRARED_IDX),
275 /* SENSOR_OV7648 6 */
276 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX),
277 /* SENSOR_OV7660 7 */
278 (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) |
279 (1 << FREQ_IDX), /* SENSOR_SP80708 8 */
280 };
281
282 static const struct v4l2_pix_format vga_mode[] = {
283 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
284 .bytesperline = 160,
285 .sizeimage = 160 * 120 * 4 / 8 + 590,
286 .colorspace = V4L2_COLORSPACE_JPEG,
287 .priv = 2},
288 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
289 .bytesperline = 320,
290 .sizeimage = 320 * 240 * 3 / 8 + 590,
291 .colorspace = V4L2_COLORSPACE_JPEG,
292 .priv = 1},
293 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
294 .bytesperline = 640,
295 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
296 .sizeimage = 640 * 480 * 3 / 4 + 590,
297 .colorspace = V4L2_COLORSPACE_JPEG,
298 .priv = 0},
299 };
300
301 /*Data from sn9c102p+hv7131r */
302 static const u8 sn_hv7131[0x1c] = {
303 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
304 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
305 /* reg8 reg9 rega regb regc regd rege regf */
306 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
308 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
309 /* reg18 reg19 reg1a reg1b */
310 0x0a, 0x00, 0x00, 0x00
311 };
312
313 static const u8 sn_mi0360[0x1c] = {
314 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
315 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
316 /* reg8 reg9 rega regb regc regd rege regf */
317 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
318 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
319 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
320 /* reg18 reg19 reg1a reg1b */
321 0x06, 0x00, 0x00, 0x00
322 };
323
324 static const u8 sn_mo4000[0x1c] = {
325 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
326 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
327 /* reg8 reg9 rega regb regc regd rege regf */
328 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
329 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
330 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
331 /* reg18 reg19 reg1a reg1b */
332 0x08, 0x00, 0x00, 0x00
333 };
334
335 static const u8 sn_mt9v111[0x1c] = {
336 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
337 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
338 /* reg8 reg9 rega regb regc regd rege regf */
339 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
340 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
341 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
342 /* reg18 reg19 reg1a reg1b */
343 0x06, 0x00, 0x00, 0x00
344 };
345
346 static const u8 sn_om6802[0x1c] = {
347 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
348 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
349 /* reg8 reg9 rega regb regc regd rege regf */
350 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
351 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
352 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
353 /* reg18 reg19 reg1a reg1b */
354 0x05, 0x00, 0x00, 0x00
355 };
356
357 static const u8 sn_ov7630[0x1c] = {
358 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
359 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
360 /* reg8 reg9 rega regb regc regd rege regf */
361 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
363 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
364 /* reg18 reg19 reg1a reg1b */
365 0x0b, 0x00, 0x00, 0x00
366 };
367
368 static const u8 sn_ov7648[0x1c] = {
369 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
370 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
371 /* reg8 reg9 rega regb regc regd rege regf */
372 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
374 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
375 /* reg18 reg19 reg1a reg1b */
376 0x0b, 0x00, 0x00, 0x00
377 };
378
379 static const u8 sn_ov7660[0x1c] = {
380 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
381 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
382 /* reg8 reg9 rega regb regc regd rege regf */
383 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
384 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
385 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
386 /* reg18 reg19 reg1a reg1b */
387 0x07, 0x00, 0x00, 0x00
388 };
389
390 static const u8 sn_sp80708[0x1c] = {
391 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
392 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
393 /* reg8 reg9 rega regb regc regd rege regf */
394 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
395 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
396 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
397 /* reg18 reg19 reg1a reg1b */
398 0x07, 0x00, 0x00, 0x00
399 };
400
401 /* sequence specific to the sensors - !! index = SENSOR_xxx */
402 static const u8 *sn_tb[] = {
403 sn_hv7131,
404 sn_mi0360,
405 sn_mo4000,
406 sn_mt9v111,
407 sn_om6802,
408 sn_ov7630,
409 sn_ov7648,
410 sn_ov7660,
411 sn_sp80708
412 };
413
414 /* default gamma table */
415 static const u8 gamma_def[17] = {
416 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
417 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
418 };
419 /* gamma for sensors HV7131R and MT9V111 */
420 static const u8 gamma_spec_1[17] = {
421 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
422 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
423 };
424 /* gamma for sensor SP80708 */
425 static const u8 gamma_spec_2[17] = {
426 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
427 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
428 };
429
430 /* color matrix and offsets */
431 static const u8 reg84[] = {
432 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
433 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
434 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
435 0x00, 0x00, 0x00 /* YUV offsets */
436 };
437 static const u8 hv7131r_sensor_init[][8] = {
438 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
439 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
440 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
441 /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
442 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
443 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
444 /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
445
446 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
447 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
448 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
449 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
450 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
451 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
452 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
453 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
454
455 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
456 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
457 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
458 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
459 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
460
461 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
462 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
463 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
464 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
465 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
466 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
467 /* set sensor clock */
468 {}
469 };
470 static const u8 mi0360_sensor_init[][8] = {
471 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
472 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
473 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
474 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
475 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
476 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
477 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
478 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
479 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
480 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
481 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
482 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
483 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
484 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
485 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
486 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
487 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
488 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
489 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
490 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
491 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
492 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
493 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
494 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
495 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
496 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
497 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
498 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
499 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
500 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
501 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
502 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
503 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
504
505 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
506 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
507 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
508 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
509 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
510
511 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
512 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
513 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
514 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
515
516 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
517 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
518 /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
519 /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
520 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
521 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
522 {}
523 };
524 static const u8 mo4000_sensor_init[][8] = {
525 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
526 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
527 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
528 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
529 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
530 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
531 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
532 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
533 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
534 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
535 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
536 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
537 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
538 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
539 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
540 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
541 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
542 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
543 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
544 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
545 {}
546 };
547 static const u8 mt9v111_sensor_init[][8] = {
548 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
549 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
550 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
551 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
552 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
553 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
554 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
555 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
556 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
557 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
558 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
559 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
560 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
561 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
562 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
563 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
564 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
565 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
566 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
567 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
568 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
569 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
570 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
571 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
572 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
573 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
574 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
575 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
576 {}
577 };
578 static const u8 mt9v111_sensor_param1[][8] = {
579 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
580 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
581 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
582 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
583 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
584 /*******/
585 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
586 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
587 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
588 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
589 {}
590 };
591 static const u8 om6802_init0[2][8] = {
592 /*fixme: variable*/
593 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
594 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
595 };
596 static const u8 om6802_sensor_init[][8] = {
597 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
598 /* factory mode */
599 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
600 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
601 /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
602 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
603 /* white balance & auto-exposure */
604 /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
605 * set color mode */
606 /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
607 * max AGC value in AE */
608 /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
609 * preset AGC */
610 /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
611 * preset brightness */
612 /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
613 * preset contrast */
614 /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
615 * preset gamma */
616 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
617 /* luminance mode (0x4f = AE) */
618 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
619 /* preset shutter */
620 /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
621 * auto frame rate */
622 /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
623 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
624 {}
625 };
626 static const u8 om6802_sensor_param1[][8] = {
627 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
631 {}
632 };
633 static const u8 ov7630_sensor_init[][8] = {
634 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
635 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
636 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
637 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
638 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
639 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
640 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
641 /* win: i2c_r from 00 to 80 */
642 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
643 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
644 /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
645 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
646 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
647 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
648 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
649 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
650 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
651 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
652 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
653 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
654 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
655 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
656 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
657 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
658 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
659 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
660 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
661 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
662 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
663 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
664 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
665 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
666 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
667 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
668 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
669 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
670 /* */
671 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
672 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
673 /*fixme: + 0x12, 0x04*/
674 /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
675 * set by setvflip */
676 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
677 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
678 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
679 /* */
680 /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
681 /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
682 /* */
683 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
684 /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
685 {}
686 };
687
688 static const u8 ov7648_sensor_init[][8] = {
689 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
690 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
691 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
692 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
693 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
694 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
695 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
696 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
697 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
698 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
699 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
700 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
701 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
702 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
703 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
704 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
705 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
706 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
707 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
708 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
709 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
710 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
711
712 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
713 /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
714 /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
715 /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
716 {}
717 };
718 static const u8 ov7648_sensor_param1[][8] = {
719 /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
720 /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
721 * set by setvflip */
722 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
723 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
724 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
725 /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
726 /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
727 /*...*/
728 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
729 /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
730 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
731 /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
732 /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
733 /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
734
735 {}
736 };
737
738 static const u8 ov7660_sensor_init[][8] = {
739 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
740 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
741 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
742 /* Outformat = rawRGB */
743 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
744 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
745 /* GAIN BLUE RED VREF */
746 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
747 /* COM 1 BAVE GEAVE AECHH */
748 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
749 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
750 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
751 /* AECH CLKRC COM7 COM8 */
752 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
753 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
754 /* HSTART HSTOP VSTRT VSTOP */
755 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
756 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
757 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
758 /* BOS GBOS GROS ROS (BGGR offset) */
759 /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
760 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
761 /* AEW AEB VPT BBIAS */
762 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
763 /* GbBIAS RSVD EXHCH EXHCL */
764 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
765 /* RBIAS ADVFL ASDVFH YAVE */
766 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
767 /* HSYST HSYEN HREF */
768 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
769 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
770 /* ADC ACOM OFON TSLB */
771 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
772 /* COM11 COM12 COM13 COM14 */
773 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
774 /* EDGE COM15 COM16 COM17 */
775 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
776 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
777 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
778 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
779 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
780 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
781 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
782 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
783 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
784 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
785 /* LCC1 LCC2 LCC3 LCC4 */
786 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
787 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
788 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
789 /* band gap reference [0:3] DBLV */
790 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
791 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
792 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
793 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
794 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
795 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
796 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
797 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
798 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
799 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
800 /* not in all ms-win traces*/
801 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
802 {}
803 };
804 static const u8 ov7660_sensor_param1[][8] = {
805 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
806 /* bits[3..0]reserved */
807 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
808 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
809 /* VREF vertical frame ctrl */
810 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
811 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
812 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
813 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
814 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
815 /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
816 /****** (some exchanges in the win trace) ******/
817 /*fixme:param2*/
818 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
819 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
820 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
821 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
822 /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
823 /****** (some exchanges in the win trace) ******/
824 /******!! startsensor KO if changed !!****/
825 /*fixme: param3*/
826 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
830 {}
831 };
832
833 static const u8 sp80708_sensor_init[][8] = {
834 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
850 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
851 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
852 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
853 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
854 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
855 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
856 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
857 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
858 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
859 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
860 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
861 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
863 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
864 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
866 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
867 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
868 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
869 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
870 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
871 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
872 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
873 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
874 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
875 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
876 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
877 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
878 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
879 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
880 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
881 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
882 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
883 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
884 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
885 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
886 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
887 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
888 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
889 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
890 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
891 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
892 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
893 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
894 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
895 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
896 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
897 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
898 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
899 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
900 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
901 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
902 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
903 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
904 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
905 {}
906 };
907 static const u8 sp80708_sensor_param1[][8] = {
908 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
909 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
910 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
911 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
912 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
913 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
914 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
915 {}
916 };
917
918 static const u8 (*sensor_init[9])[8] = {
919 hv7131r_sensor_init, /* HV7131R 0 */
920 mi0360_sensor_init, /* MI0360 1 */
921 mo4000_sensor_init, /* MO4000 2 */
922 mt9v111_sensor_init, /* MT9V111 3 */
923 om6802_sensor_init, /* OM6802 4 */
924 ov7630_sensor_init, /* OV7630 5 */
925 ov7648_sensor_init, /* OV7648 6 */
926 ov7660_sensor_init, /* OV7660 7 */
927 sp80708_sensor_init, /* SP80708 8 */
928 };
929
930 /* read <len> bytes to gspca_dev->usb_buf */
931 static void reg_r(struct gspca_dev *gspca_dev,
932 u16 value, int len)
933 {
934 #ifdef GSPCA_DEBUG
935 if (len > USB_BUF_SZ) {
936 err("reg_r: buffer overflow");
937 return;
938 }
939 #endif
940 usb_control_msg(gspca_dev->dev,
941 usb_rcvctrlpipe(gspca_dev->dev, 0),
942 0,
943 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
944 value, 0,
945 gspca_dev->usb_buf, len,
946 500);
947 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
948 }
949
950 static void reg_w1(struct gspca_dev *gspca_dev,
951 u16 value,
952 u8 data)
953 {
954 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
955 gspca_dev->usb_buf[0] = data;
956 usb_control_msg(gspca_dev->dev,
957 usb_sndctrlpipe(gspca_dev->dev, 0),
958 0x08,
959 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
960 value,
961 0,
962 gspca_dev->usb_buf, 1,
963 500);
964 }
965 static void reg_w(struct gspca_dev *gspca_dev,
966 u16 value,
967 const u8 *buffer,
968 int len)
969 {
970 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
971 value, buffer[0], buffer[1]);
972 #ifdef GSPCA_DEBUG
973 if (len > USB_BUF_SZ) {
974 err("reg_w: buffer overflow");
975 return;
976 }
977 #endif
978 memcpy(gspca_dev->usb_buf, buffer, len);
979 usb_control_msg(gspca_dev->dev,
980 usb_sndctrlpipe(gspca_dev->dev, 0),
981 0x08,
982 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
983 value, 0,
984 gspca_dev->usb_buf, len,
985 500);
986 }
987
988 /* I2C write 1 byte */
989 static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
990 {
991 struct sd *sd = (struct sd *) gspca_dev;
992
993 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
994 switch (sd->sensor) {
995 case SENSOR_OM6802: /* i2c command = a0 (100 kHz) */
996 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
997 break;
998 default: /* i2c command = a1 (400 kHz) */
999 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1000 break;
1001 }
1002 gspca_dev->usb_buf[1] = sd->i2c_base;
1003 gspca_dev->usb_buf[2] = reg;
1004 gspca_dev->usb_buf[3] = val;
1005 gspca_dev->usb_buf[4] = 0;
1006 gspca_dev->usb_buf[5] = 0;
1007 gspca_dev->usb_buf[6] = 0;
1008 gspca_dev->usb_buf[7] = 0x10;
1009 usb_control_msg(gspca_dev->dev,
1010 usb_sndctrlpipe(gspca_dev->dev, 0),
1011 0x08,
1012 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1013 0x08, /* value = i2c */
1014 0,
1015 gspca_dev->usb_buf, 8,
1016 500);
1017 }
1018
1019 /* I2C write 8 bytes */
1020 static void i2c_w8(struct gspca_dev *gspca_dev,
1021 const u8 *buffer)
1022 {
1023 memcpy(gspca_dev->usb_buf, buffer, 8);
1024 usb_control_msg(gspca_dev->dev,
1025 usb_sndctrlpipe(gspca_dev->dev, 0),
1026 0x08,
1027 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1028 0x08, 0, /* value, index */
1029 gspca_dev->usb_buf, 8,
1030 500);
1031 msleep(2);
1032 }
1033
1034 /* read 5 bytes in gspca_dev->usb_buf */
1035 static void i2c_r5(struct gspca_dev *gspca_dev, u8 reg)
1036 {
1037 struct sd *sd = (struct sd *) gspca_dev;
1038 u8 mode[8];
1039
1040 switch (sd->sensor) {
1041 case SENSOR_OM6802: /* i2c command = 90 (100 kHz) */
1042 mode[0] = 0x80 | 0x10;
1043 break;
1044 default: /* i2c command = 91 (400 kHz) */
1045 mode[0] = 0x81 | 0x10;
1046 break;
1047 }
1048 mode[1] = sd->i2c_base;
1049 mode[2] = reg;
1050 mode[3] = 0;
1051 mode[4] = 0;
1052 mode[5] = 0;
1053 mode[6] = 0;
1054 mode[7] = 0x10;
1055 i2c_w8(gspca_dev, mode);
1056 msleep(2);
1057 mode[0] = (mode[0] & 0x81) | (5 << 4) | 0x02;
1058 mode[2] = 0;
1059 i2c_w8(gspca_dev, mode);
1060 msleep(2);
1061 reg_r(gspca_dev, 0x0a, 5);
1062 }
1063
1064 static void i2c_w_seq(struct gspca_dev *gspca_dev,
1065 const u8 (*data)[8])
1066 {
1067 while ((*data)[0] != 0) {
1068 if ((*data)[0] != 0xdd)
1069 i2c_w8(gspca_dev, *data);
1070 else
1071 msleep((*data)[1]);
1072 data++;
1073 }
1074 }
1075
1076 static void hv7131r_probe(struct gspca_dev *gspca_dev)
1077 {
1078 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
1079 msleep(10);
1080 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
1081 msleep(10);
1082 i2c_r5(gspca_dev, 0); /* read sensor id */
1083 if (gspca_dev->usb_buf[0] == 0x02
1084 && gspca_dev->usb_buf[1] == 0x09
1085 && gspca_dev->usb_buf[2] == 0x01
1086 && gspca_dev->usb_buf[3] == 0x00
1087 && gspca_dev->usb_buf[4] == 0x00) {
1088 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1089 return;
1090 }
1091 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
1092 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1093 gspca_dev->usb_buf[2]);
1094 }
1095
1096 static void mi0360_probe(struct gspca_dev *gspca_dev)
1097 {
1098 struct sd *sd = (struct sd *) gspca_dev;
1099 int i, j;
1100 u16 val = 0;
1101 static const u8 probe_tb[][4][8] = {
1102 { /* mi0360 */
1103 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1104 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1105 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1106 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1107 },
1108 { /* mt9v111 */
1109 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1110 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1111 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1112 {}
1113 },
1114 };
1115
1116 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1117 reg_w1(gspca_dev, 0x17, 0x62);
1118 reg_w1(gspca_dev, 0x01, 0x08);
1119 for (j = 0; j < 3; j++)
1120 i2c_w8(gspca_dev, probe_tb[i][j]);
1121 msleep(2);
1122 reg_r(gspca_dev, 0x0a, 5);
1123 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1124 if (probe_tb[i][3][0] != 0)
1125 i2c_w8(gspca_dev, probe_tb[i][3]);
1126 reg_w1(gspca_dev, 0x01, 0x29);
1127 reg_w1(gspca_dev, 0x17, 0x42);
1128 if (val != 0xffff)
1129 break;
1130 }
1131 switch (val) {
1132 case 0x823a:
1133 PDEBUG(D_PROBE, "Sensor mt9v111");
1134 sd->sensor = SENSOR_MT9V111;
1135 sd->i2c_base = 0x5c;
1136 break;
1137 case 0x8243:
1138 PDEBUG(D_PROBE, "Sensor mi0360");
1139 break;
1140 default:
1141 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1142 break;
1143 }
1144 }
1145
1146 static void bridge_init(struct gspca_dev *gspca_dev,
1147 const u8 *sn9c1xx)
1148 {
1149 struct sd *sd = (struct sd *) gspca_dev;
1150 const u8 *reg9a;
1151 static const u8 reg9a_def[] =
1152 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1153 static const u8 reg9a_spec[] =
1154 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1155 static const u8 regd4[] = {0x60, 0x00, 0x00};
1156
1157 reg_w1(gspca_dev, 0xf1, 0x00);
1158 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1159
1160 /* configure gpio */
1161 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
1162 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
1163 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5); /* jfm len was 3 */
1164 switch (sd->sensor) {
1165 case SENSOR_OV7660:
1166 case SENSOR_SP80708:
1167 reg9a = reg9a_spec;
1168 break;
1169 default:
1170 reg9a = reg9a_def;
1171 break;
1172 }
1173 reg_w(gspca_dev, 0x9a, reg9a, 6);
1174
1175 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4); /*fixme:jfm was 60 only*/
1176
1177 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
1178
1179 switch (sd->sensor) {
1180 case SENSOR_MT9V111:
1181 reg_w1(gspca_dev, 0x01, 0x61);
1182 reg_w1(gspca_dev, 0x17, 0x61);
1183 reg_w1(gspca_dev, 0x01, 0x60);
1184 reg_w1(gspca_dev, 0x01, 0x40);
1185 break;
1186 case SENSOR_OM6802:
1187 msleep(10);
1188 reg_w1(gspca_dev, 0x02, 0x73);
1189 reg_w1(gspca_dev, 0x17, 0x60);
1190 reg_w1(gspca_dev, 0x01, 0x22);
1191 msleep(100);
1192 reg_w1(gspca_dev, 0x01, 0x62);
1193 reg_w1(gspca_dev, 0x17, 0x64);
1194 reg_w1(gspca_dev, 0x17, 0x64);
1195 reg_w1(gspca_dev, 0x01, 0x42);
1196 msleep(10);
1197 reg_w1(gspca_dev, 0x01, 0x42);
1198 i2c_w8(gspca_dev, om6802_init0[0]);
1199 i2c_w8(gspca_dev, om6802_init0[1]);
1200 msleep(15);
1201 reg_w1(gspca_dev, 0x02, 0x71);
1202 msleep(150);
1203 break;
1204 case SENSOR_OV7630:
1205 reg_w1(gspca_dev, 0x01, 0x61);
1206 reg_w1(gspca_dev, 0x17, 0xe2);
1207 reg_w1(gspca_dev, 0x01, 0x60);
1208 reg_w1(gspca_dev, 0x01, 0x40);
1209 break;
1210 case SENSOR_OV7648:
1211 reg_w1(gspca_dev, 0x01, 0x63);
1212 reg_w1(gspca_dev, 0x17, 0x20);
1213 reg_w1(gspca_dev, 0x01, 0x62);
1214 reg_w1(gspca_dev, 0x01, 0x42);
1215 break;
1216 case SENSOR_OV7660:
1217 case SENSOR_SP80708:
1218 reg_w1(gspca_dev, 0x01, 0x63);
1219 reg_w1(gspca_dev, 0x17, 0x20);
1220 reg_w1(gspca_dev, 0x01, 0x62);
1221 reg_w1(gspca_dev, 0x01, 0x42);
1222 msleep(100);
1223 reg_w1(gspca_dev, 0x02, 0x62);
1224 break;
1225 /* case SENSOR_HV7131R: */
1226 /* case SENSOR_MI0360: */
1227 /* case SENSOR_MO4000: */
1228 default:
1229 reg_w1(gspca_dev, 0x01, 0x43);
1230 reg_w1(gspca_dev, 0x17, 0x61);
1231 reg_w1(gspca_dev, 0x01, 0x42);
1232 if (sd->sensor == SENSOR_HV7131R)
1233 hv7131r_probe(gspca_dev);
1234 break;
1235 }
1236 }
1237
1238 /* this function is called at probe time */
1239 static int sd_config(struct gspca_dev *gspca_dev,
1240 const struct usb_device_id *id)
1241 {
1242 struct sd *sd = (struct sd *) gspca_dev;
1243 struct cam *cam;
1244
1245 cam = &gspca_dev->cam;
1246 cam->cam_mode = vga_mode;
1247 cam->nmodes = ARRAY_SIZE(vga_mode);
1248 cam->npkt = 24; /* 24 packets per ISOC message */
1249
1250 sd->bridge = id->driver_info >> 16;
1251 sd->sensor = id->driver_info >> 8;
1252 sd->i2c_base = id->driver_info;
1253
1254 sd->brightness = BRIGHTNESS_DEF;
1255 sd->contrast = CONTRAST_DEF;
1256 sd->colors = COLOR_DEF;
1257 sd->blue = BLUE_BALANCE_DEF;
1258 sd->red = RED_BALANCE_DEF;
1259 sd->gamma = GAMMA_DEF;
1260 sd->autogain = AUTOGAIN_DEF;
1261 sd->ag_cnt = -1;
1262 sd->vflip = VFLIP_DEF;
1263 sd->infrared = INFRARED_DEF;
1264 sd->freq = FREQ_DEF;
1265 sd->quality = QUALITY_DEF;
1266 sd->jpegqual = 80;
1267
1268 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1269 return 0;
1270 }
1271
1272 /* this function is called at probe and resume time */
1273 static int sd_init(struct gspca_dev *gspca_dev)
1274 {
1275 struct sd *sd = (struct sd *) gspca_dev;
1276 u8 regGpio[] = { 0x29, 0x74 };
1277 u8 regF1;
1278
1279 /* setup a selector by bridge */
1280 reg_w1(gspca_dev, 0xf1, 0x01);
1281 reg_r(gspca_dev, 0x00, 1);
1282 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1283 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
1284 regF1 = gspca_dev->usb_buf[0];
1285 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
1286 switch (sd->bridge) {
1287 case BRIDGE_SN9C102P:
1288 if (regF1 != 0x11)
1289 return -ENODEV;
1290 reg_w1(gspca_dev, 0x02, regGpio[1]);
1291 break;
1292 case BRIDGE_SN9C105:
1293 if (regF1 != 0x11)
1294 return -ENODEV;
1295 if (sd->sensor == SENSOR_MI0360)
1296 mi0360_probe(gspca_dev);
1297 reg_w(gspca_dev, 0x01, regGpio, 2);
1298 break;
1299 case BRIDGE_SN9C120:
1300 if (regF1 != 0x12)
1301 return -ENODEV;
1302 if (sd->sensor == SENSOR_MI0360)
1303 mi0360_probe(gspca_dev);
1304 regGpio[1] = 0x70;
1305 reg_w(gspca_dev, 0x01, regGpio, 2);
1306 break;
1307 default:
1308 /* case BRIDGE_SN9C110: */
1309 /* case BRIDGE_SN9C325: */
1310 if (regF1 != 0x12)
1311 return -ENODEV;
1312 reg_w1(gspca_dev, 0x02, 0x62);
1313 break;
1314 }
1315
1316 reg_w1(gspca_dev, 0xf1, 0x01);
1317
1318 return 0;
1319 }
1320
1321 static u32 setexposure(struct gspca_dev *gspca_dev,
1322 u32 expo)
1323 {
1324 struct sd *sd = (struct sd *) gspca_dev;
1325
1326 switch (sd->sensor) {
1327 case SENSOR_HV7131R: {
1328 u8 Expodoit[] =
1329 { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
1330
1331 Expodoit[3] = expo >> 16;
1332 Expodoit[4] = expo >> 8;
1333 Expodoit[5] = expo;
1334 i2c_w8(gspca_dev, Expodoit);
1335 break;
1336 }
1337 case SENSOR_MI0360: {
1338 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
1339 { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
1340 static const u8 doit[] = /* update sensor */
1341 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1342 static const u8 sensorgo[] = /* sensor on */
1343 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
1344
1345 if (expo > 0x0635)
1346 expo = 0x0635;
1347 else if (expo < 0x0001)
1348 expo = 0x0001;
1349 expoMi[3] = expo >> 8;
1350 expoMi[4] = expo;
1351 i2c_w8(gspca_dev, expoMi);
1352 i2c_w8(gspca_dev, doit);
1353 i2c_w8(gspca_dev, sensorgo);
1354 break;
1355 }
1356 case SENSOR_MO4000: {
1357 u8 expoMof[] =
1358 { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
1359 u8 expoMo10[] =
1360 { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
1361 static const u8 gainMo[] =
1362 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
1363
1364 if (expo > 0x1fff)
1365 expo = 0x1fff;
1366 else if (expo < 0x0001)
1367 expo = 0x0001;
1368 expoMof[3] = (expo & 0x03fc) >> 2;
1369 i2c_w8(gspca_dev, expoMof);
1370 expoMo10[3] = ((expo & 0x1c00) >> 10)
1371 | ((expo & 0x0003) << 4);
1372 i2c_w8(gspca_dev, expoMo10);
1373 i2c_w8(gspca_dev, gainMo);
1374 PDEBUG(D_FRAM, "set exposure %d",
1375 ((expoMo10[3] & 0x07) << 10)
1376 | (expoMof[3] << 2)
1377 | ((expoMo10[3] & 0x30) >> 4));
1378 break;
1379 }
1380 case SENSOR_MT9V111: {
1381 u8 expo_c1[] =
1382 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1383
1384 if (expo > 0x0280)
1385 expo = 0x0280;
1386 else if (expo < 0x0040)
1387 expo = 0x0040;
1388 expo_c1[3] = expo >> 8;
1389 expo_c1[4] = expo;
1390 i2c_w8(gspca_dev, expo_c1);
1391 break;
1392 }
1393 case SENSOR_OM6802: {
1394 u8 gainOm[] =
1395 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
1396
1397 if (expo > 0x03ff)
1398 expo = 0x03ff;
1399 if (expo < 0x0001)
1400 expo = 0x0001;
1401 gainOm[3] = expo >> 2;
1402 i2c_w8(gspca_dev, gainOm);
1403 reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f);
1404 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
1405 break;
1406 }
1407 }
1408 return expo;
1409 }
1410
1411 static void setbrightness(struct gspca_dev *gspca_dev)
1412 {
1413 struct sd *sd = (struct sd *) gspca_dev;
1414 unsigned int expo;
1415 u8 k2;
1416
1417 k2 = ((int) sd->brightness - 0x8000) >> 10;
1418 switch (sd->sensor) {
1419 case SENSOR_HV7131R:
1420 expo = sd->brightness << 4;
1421 if (expo > 0x002dc6c0)
1422 expo = 0x002dc6c0;
1423 else if (expo < 0x02a0)
1424 expo = 0x02a0;
1425 sd->exposure = setexposure(gspca_dev, expo);
1426 break;
1427 case SENSOR_MI0360:
1428 case SENSOR_MO4000:
1429 expo = sd->brightness >> 4;
1430 sd->exposure = setexposure(gspca_dev, expo);
1431 break;
1432 case SENSOR_MT9V111:
1433 expo = sd->brightness >> 8;
1434 sd->exposure = setexposure(gspca_dev, expo);
1435 break;
1436 case SENSOR_OM6802:
1437 expo = sd->brightness >> 6;
1438 sd->exposure = setexposure(gspca_dev, expo);
1439 k2 = sd->brightness >> 11;
1440 break;
1441 }
1442
1443 if (sd->sensor != SENSOR_MT9V111)
1444 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
1445 }
1446
1447 static void setcontrast(struct gspca_dev *gspca_dev)
1448 {
1449 struct sd *sd = (struct sd *) gspca_dev;
1450 u8 k2;
1451 u8 contrast[6];
1452
1453 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
1454 contrast[0] = (k2 + 1) / 2; /* red */
1455 contrast[1] = 0;
1456 contrast[2] = k2; /* green */
1457 contrast[3] = 0;
1458 contrast[4] = (k2 + 1) / 5; /* blue */
1459 contrast[5] = 0;
1460 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
1461 }
1462
1463 static void setcolors(struct gspca_dev *gspca_dev)
1464 {
1465 struct sd *sd = (struct sd *) gspca_dev;
1466 int i, v;
1467 u8 reg8a[12]; /* U & V gains */
1468 static s16 uv[6] = { /* same as reg84 in signed decimal */
1469 -24, -38, 64, /* UR UG UB */
1470 62, -51, -9 /* VR VG VB */
1471 };
1472 for (i = 0; i < 6; i++) {
1473 v = uv[i] * sd->colors / COLOR_DEF;
1474 reg8a[i * 2] = v;
1475 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
1476 }
1477 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
1478 }
1479
1480 static void setredblue(struct gspca_dev *gspca_dev)
1481 {
1482 struct sd *sd = (struct sd *) gspca_dev;
1483
1484 reg_w1(gspca_dev, 0x05, sd->red);
1485 /* reg_w1(gspca_dev, 0x07, 32); */
1486 reg_w1(gspca_dev, 0x06, sd->blue);
1487 }
1488
1489 static void setgamma(struct gspca_dev *gspca_dev)
1490 {
1491 struct sd *sd = (struct sd *) gspca_dev;
1492 int i;
1493 u8 gamma[17];
1494 const u8 *gamma_base;
1495 static const u8 delta[17] = {
1496 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1497 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1498 };
1499
1500 switch (sd->sensor) {
1501 case SENSOR_HV7131R:
1502 case SENSOR_MT9V111:
1503 gamma_base = gamma_spec_1;
1504 break;
1505 case SENSOR_SP80708:
1506 gamma_base = gamma_spec_2;
1507 break;
1508 default:
1509 gamma_base = gamma_def;
1510 break;
1511 }
1512
1513 for (i = 0; i < sizeof gamma; i++)
1514 gamma[i] = gamma_base[i]
1515 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
1516 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
1517 }
1518
1519 static void setautogain(struct gspca_dev *gspca_dev)
1520 {
1521 struct sd *sd = (struct sd *) gspca_dev;
1522
1523 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
1524 return;
1525 switch (sd->sensor) {
1526 case SENSOR_OV7630:
1527 case SENSOR_OV7648: {
1528 u8 comb;
1529
1530 if (sd->sensor == SENSOR_OV7630)
1531 comb = 0xc0;
1532 else
1533 comb = 0xa0;
1534 if (sd->autogain)
1535 comb |= 0x03;
1536 i2c_w1(&sd->gspca_dev, 0x13, comb);
1537 return;
1538 }
1539 }
1540 if (sd->autogain)
1541 sd->ag_cnt = AG_CNT_START;
1542 else
1543 sd->ag_cnt = -1;
1544 }
1545
1546 /* ov7630/ov7648 only */
1547 static void setvflip(struct sd *sd)
1548 {
1549 u8 comn;
1550
1551 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
1552 return;
1553 if (sd->sensor == SENSOR_OV7630) {
1554 comn = 0x02;
1555 if (!sd->vflip)
1556 comn |= 0x80;
1557 } else {
1558 comn = 0x06;
1559 if (sd->vflip)
1560 comn |= 0x80;
1561 }
1562 i2c_w1(&sd->gspca_dev, 0x75, comn);
1563 }
1564
1565 static void setinfrared(struct sd *sd)
1566 {
1567 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
1568 return;
1569 /*fixme: different sequence for StarCam Clip and StarCam 370i */
1570 /* Clip */
1571 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
1572 sd->infrared ? 0x66 : 0x64);
1573 }
1574
1575 static void setfreq(struct gspca_dev *gspca_dev)
1576 {
1577 struct sd *sd = (struct sd *) gspca_dev;
1578
1579 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
1580 return;
1581 if (sd->sensor == SENSOR_OV7660) {
1582 u8 com8;
1583
1584 com8 = 0xdf; /* auto gain/wb/expo */
1585 switch (sd->freq) {
1586 case 0: /* Banding filter disabled */
1587 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
1588 break;
1589 case 1: /* 50 hz */
1590 i2c_w1(gspca_dev, 0x13, com8);
1591 i2c_w1(gspca_dev, 0x3b, 0x0a);
1592 break;
1593 case 2: /* 60 hz */
1594 i2c_w1(gspca_dev, 0x13, com8);
1595 i2c_w1(gspca_dev, 0x3b, 0x02);
1596 break;
1597 }
1598 } else {
1599 u8 reg2a = 0, reg2b = 0, reg2d = 0;
1600
1601 /* Get reg2a / reg2d base values */
1602 switch (sd->sensor) {
1603 case SENSOR_OV7630:
1604 reg2a = 0x08;
1605 reg2d = 0x01;
1606 break;
1607 case SENSOR_OV7648:
1608 reg2a = 0x11;
1609 reg2d = 0x81;
1610 break;
1611 }
1612
1613 switch (sd->freq) {
1614 case 0: /* Banding filter disabled */
1615 break;
1616 case 1: /* 50 hz (filter on and framerate adj) */
1617 reg2a |= 0x80;
1618 reg2b = 0xac;
1619 reg2d |= 0x04;
1620 break;
1621 case 2: /* 60 hz (filter on, no framerate adj) */
1622 reg2a |= 0x80;
1623 reg2d |= 0x04;
1624 break;
1625 }
1626 i2c_w1(gspca_dev, 0x2a, reg2a);
1627 i2c_w1(gspca_dev, 0x2b, reg2b);
1628 i2c_w1(gspca_dev, 0x2d, reg2d);
1629 }
1630 }
1631
1632 static void setjpegqual(struct gspca_dev *gspca_dev)
1633 {
1634 struct sd *sd = (struct sd *) gspca_dev;
1635 int i, sc;
1636
1637 if (sd->jpegqual < 50)
1638 sc = 5000 / sd->jpegqual;
1639 else
1640 sc = 200 - sd->jpegqual * 2;
1641 #if USB_BUF_SZ < 64
1642 #error "No room enough in usb_buf for quantization table"
1643 #endif
1644 for (i = 0; i < 64; i++)
1645 gspca_dev->usb_buf[i] =
1646 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
1647 usb_control_msg(gspca_dev->dev,
1648 usb_sndctrlpipe(gspca_dev->dev, 0),
1649 0x08,
1650 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1651 0x0100, 0,
1652 gspca_dev->usb_buf, 64,
1653 500);
1654 for (i = 0; i < 64; i++)
1655 gspca_dev->usb_buf[i] =
1656 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
1657 usb_control_msg(gspca_dev->dev,
1658 usb_sndctrlpipe(gspca_dev->dev, 0),
1659 0x08,
1660 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1661 0x0140, 0,
1662 gspca_dev->usb_buf, 64,
1663 500);
1664
1665 sd->reg18 ^= 0x40;
1666 reg_w1(gspca_dev, 0x18, sd->reg18);
1667 }
1668
1669 /* -- start the camera -- */
1670 static int sd_start(struct gspca_dev *gspca_dev)
1671 {
1672 struct sd *sd = (struct sd *) gspca_dev;
1673 int i;
1674 u8 reg1, reg2, reg17;
1675 const u8 *sn9c1xx;
1676 const u8 (*init)[8];
1677 int mode;
1678 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1679 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1680 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1681 static const u8 CE_ov76xx[] =
1682 { 0x32, 0xdd, 0x32, 0xdd };
1683
1684 /* create the JPEG header */
1685 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
1686 if (!sd->jpeg_hdr)
1687 return -ENOMEM;
1688 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
1689 0x21); /* JPEG 422 */
1690 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
1691
1692 /* initialize the bridge */
1693 sn9c1xx = sn_tb[sd->sensor];
1694 bridge_init(gspca_dev, sn9c1xx);
1695 /* initialize the sensor */
1696 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
1697
1698 switch (sd->sensor) {
1699 case SENSOR_OM6802:
1700 reg2 = 0x71;
1701 break;
1702 case SENSOR_SP80708:
1703 reg2 = 0x62;
1704 break;
1705 default:
1706 reg2 = 0x40;
1707 break;
1708 }
1709 reg_w1(gspca_dev, 0x02, reg2);
1710 reg_w1(gspca_dev, 0x02, reg2);
1711
1712 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
1713 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
1714 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
1715 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
1716 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1717 reg_w1(gspca_dev, 0xd2, 0x6a); /* DC29 */
1718 reg_w1(gspca_dev, 0xd3, 0x50);
1719 reg_w1(gspca_dev, 0xc6, 0x00);
1720 reg_w1(gspca_dev, 0xc7, 0x00);
1721 reg_w1(gspca_dev, 0xc8, 0x50);
1722 reg_w1(gspca_dev, 0xc9, 0x3c);
1723 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
1724 switch (sd->sensor) {
1725 case SENSOR_MT9V111:
1726 reg17 = 0xe0;
1727 break;
1728 case SENSOR_OV7630:
1729 reg17 = 0xe2;
1730 break;
1731 case SENSOR_OV7648:
1732 reg17 = 0x20;
1733 break;
1734 case SENSOR_OV7660:
1735 reg17 = 0xa0;
1736 break;
1737 default:
1738 reg17 = 0x60;
1739 break;
1740 }
1741 reg_w1(gspca_dev, 0x17, reg17);
1742 /* set reg1 was here */
1743 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
1744 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1745 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
1746 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
1747
1748 setgamma(gspca_dev);
1749
1750 for (i = 0; i < 8; i++)
1751 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1752 switch (sd->sensor) {
1753 case SENSOR_MT9V111:
1754 reg_w1(gspca_dev, 0x9a, 0x07);
1755 reg_w1(gspca_dev, 0x99, 0x59);
1756 break;
1757 case SENSOR_OM6802:
1758 reg_w1(gspca_dev, 0x9a, 0x08);
1759 reg_w1(gspca_dev, 0x99, 0x10);
1760 break;
1761 case SENSOR_OV7648:
1762 reg_w1(gspca_dev, 0x9a, 0x0a);
1763 reg_w1(gspca_dev, 0x99, 0x60);
1764 break;
1765 case SENSOR_OV7660:
1766 case SENSOR_SP80708:
1767 reg_w1(gspca_dev, 0x9a, 0x05);
1768 reg_w1(gspca_dev, 0x99, 0x59);
1769 break;
1770 default:
1771 reg_w1(gspca_dev, 0x9a, 0x08);
1772 reg_w1(gspca_dev, 0x99, 0x59);
1773 break;
1774 }
1775
1776 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1777 reg_w1(gspca_dev, 0x05, sn9c1xx[5]); /* red */
1778 reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */
1779 reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */
1780
1781 init = NULL;
1782 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1783 if (mode)
1784 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
1785 else
1786 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
1787 reg17 = 0x61; /* 0x:20: enable sensor clock */
1788 switch (sd->sensor) {
1789 case SENSOR_MO4000:
1790 if (mode) {
1791 /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
1792 reg1 = 0x06; /* clk 24Mz */
1793 } else {
1794 reg17 = 0x22; /* 640 MCKSIZE */
1795 /* reg1 = 0x06; * 640 clk 24Mz (done) */
1796 }
1797 break;
1798 case SENSOR_MT9V111:
1799 init = mt9v111_sensor_param1;
1800 if (mode) {
1801 reg1 = 0x04; /* 320 clk 48Mhz */
1802 } else {
1803 /* reg1 = 0x06; * 640 clk 24Mz (done) */
1804 reg17 = 0xc2;
1805 }
1806 break;
1807 case SENSOR_OM6802:
1808 init = om6802_sensor_param1;
1809 reg17 = 0x64; /* 640 MCKSIZE */
1810 break;
1811 case SENSOR_OV7630:
1812 setvflip(sd);
1813 reg17 = 0xe2;
1814 reg1 = 0x44;
1815 break;
1816 case SENSOR_OV7648:
1817 init = ov7648_sensor_param1;
1818 reg17 = 0x21;
1819 /* reg1 = 0x42; * 42 - 46? */
1820 break;
1821 case SENSOR_OV7660:
1822 init = ov7660_sensor_param1;
1823 if (sd->bridge == BRIDGE_SN9C120) {
1824 if (mode) { /* 320x240 - 160x120 */
1825 reg17 = 0xa2;
1826 reg1 = 0x44; /* 48 Mhz, video trf eneble */
1827 }
1828 } else {
1829 reg17 = 0x22;
1830 reg1 = 0x06; /* 24 Mhz, video trf eneble
1831 * inverse power down */
1832 }
1833 break;
1834 default:
1835 /* case SENSOR_SP80708: */
1836 init = sp80708_sensor_param1;
1837 if (mode) {
1838 /*?? reg1 = 0x04; * 320 clk 48Mhz */
1839 } else {
1840 reg1 = 0x46; /* 640 clk 48Mz */
1841 reg17 = 0xa2;
1842 }
1843 break;
1844 }
1845
1846 /* more sensor initialization - param1 */
1847 if (init != NULL) {
1848 i2c_w_seq(gspca_dev, init);
1849 /* init = NULL; */
1850 }
1851
1852 reg_w(gspca_dev, 0xc0, C0, 6);
1853 reg_w(gspca_dev, 0xca, CA, 4);
1854 switch (sd->sensor) {
1855 case SENSOR_OV7630:
1856 case SENSOR_OV7648:
1857 case SENSOR_OV7660:
1858 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
1859 break;
1860 default:
1861 reg_w(gspca_dev, 0xce, CE, 4);
1862 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
1863 break;
1864 }
1865
1866
1867 /* here change size mode 0 -> VGA; 1 -> CIF */
1868 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
1869 reg_w1(gspca_dev, 0x18, sd->reg18);
1870 setjpegqual(gspca_dev);
1871
1872 reg_w1(gspca_dev, 0x17, reg17);
1873 reg_w1(gspca_dev, 0x01, reg1);
1874
1875 switch (sd->sensor) {
1876 case SENSOR_OV7630:
1877 setvflip(sd);
1878 break;
1879 }
1880 setbrightness(gspca_dev);
1881 setcontrast(gspca_dev);
1882 setautogain(gspca_dev);
1883 setfreq(gspca_dev);
1884 return 0;
1885 }
1886
1887 static void sd_stopN(struct gspca_dev *gspca_dev)
1888 {
1889 struct sd *sd = (struct sd *) gspca_dev;
1890 static const u8 stophv7131[] =
1891 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
1892 static const u8 stopmi0360[] =
1893 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
1894 static const u8 stopov7648[] =
1895 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
1896 u8 data;
1897 const u8 *sn9c1xx;
1898
1899 data = 0x0b;
1900 switch (sd->sensor) {
1901 case SENSOR_HV7131R:
1902 i2c_w8(gspca_dev, stophv7131);
1903 data = 0x2b;
1904 break;
1905 case SENSOR_MI0360:
1906 i2c_w8(gspca_dev, stopmi0360);
1907 data = 0x29;
1908 break;
1909 case SENSOR_OV7648:
1910 i2c_w8(gspca_dev, stopov7648);
1911 /* fall thru */
1912 case SENSOR_MT9V111:
1913 case SENSOR_OV7630:
1914 data = 0x29;
1915 break;
1916 default:
1917 /* case SENSOR_MO4000: */
1918 /* case SENSOR_OV7660: */
1919 break;
1920 }
1921 sn9c1xx = sn_tb[(int) sd->sensor];
1922 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1923 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
1924 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1925 reg_w1(gspca_dev, 0x01, data);
1926 reg_w1(gspca_dev, 0xf1, 0x00);
1927 }
1928
1929 static void sd_stop0(struct gspca_dev *gspca_dev)
1930 {
1931 struct sd *sd = (struct sd *) gspca_dev;
1932
1933 kfree(sd->jpeg_hdr);
1934 }
1935
1936 static void do_autogain(struct gspca_dev *gspca_dev)
1937 {
1938 struct sd *sd = (struct sd *) gspca_dev;
1939 int delta;
1940 int expotimes;
1941 u8 luma_mean = 130;
1942 u8 luma_delta = 20;
1943
1944 /* Thanks S., without your advice, autobright should not work :) */
1945 if (sd->ag_cnt < 0)
1946 return;
1947 if (--sd->ag_cnt >= 0)
1948 return;
1949 sd->ag_cnt = AG_CNT_START;
1950
1951 delta = atomic_read(&sd->avg_lum);
1952 PDEBUG(D_FRAM, "mean lum %d", delta);
1953 if (delta < luma_mean - luma_delta ||
1954 delta > luma_mean + luma_delta) {
1955 switch (sd->sensor) {
1956 case SENSOR_HV7131R:
1957 expotimes = sd->exposure >> 8;
1958 expotimes += (luma_mean - delta) >> 4;
1959 if (expotimes < 0)
1960 expotimes = 0;
1961 sd->exposure = setexposure(gspca_dev,
1962 (unsigned int) (expotimes << 8));
1963 break;
1964 case SENSOR_OM6802:
1965 expotimes = sd->exposure;
1966 expotimes += (luma_mean - delta) >> 2;
1967 if (expotimes < 0)
1968 expotimes = 0;
1969 sd->exposure = setexposure(gspca_dev,
1970 (unsigned int) expotimes);
1971 setredblue(gspca_dev);
1972 break;
1973 default:
1974 /* case SENSOR_MO4000: */
1975 /* case SENSOR_MI0360: */
1976 /* case SENSOR_MT9V111: */
1977 expotimes = sd->exposure;
1978 expotimes += (luma_mean - delta) >> 6;
1979 if (expotimes < 0)
1980 expotimes = 0;
1981 sd->exposure = setexposure(gspca_dev,
1982 (unsigned int) expotimes);
1983 setredblue(gspca_dev);
1984 break;
1985 }
1986 }
1987 }
1988
1989 /* scan the URB packets */
1990 /* This function is run at interrupt level. */
1991 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1992 struct gspca_frame *frame, /* target */
1993 u8 *data, /* isoc packet */
1994 int len) /* iso packet length */
1995 {
1996 struct sd *sd = (struct sd *) gspca_dev;
1997 int sof, avg_lum;
1998
1999 sof = len - 64;
2000 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
2001
2002 /* end of frame */
2003 gspca_frame_add(gspca_dev, LAST_PACKET,
2004 frame, data, sof + 2);
2005 if (sd->ag_cnt < 0)
2006 return;
2007 /* w1 w2 w3 */
2008 /* w4 w5 w6 */
2009 /* w7 w8 */
2010 /* w4 */
2011 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2012 /* w6 */
2013 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2014 /* w2 */
2015 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2016 /* w8 */
2017 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2018 /* w5 */
2019 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2020 avg_lum >>= 4;
2021 atomic_set(&sd->avg_lum, avg_lum);
2022 return;
2023 }
2024 if (gspca_dev->last_packet_type == LAST_PACKET) {
2025
2026 /* put the JPEG 422 header */
2027 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
2028 sd->jpeg_hdr, JPEG_HDR_SZ);
2029 }
2030 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
2031 }
2032
2033 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2034 {
2035 struct sd *sd = (struct sd *) gspca_dev;
2036
2037 sd->brightness = val;
2038 if (gspca_dev->streaming)
2039 setbrightness(gspca_dev);
2040 return 0;
2041 }
2042
2043 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2044 {
2045 struct sd *sd = (struct sd *) gspca_dev;
2046
2047 *val = sd->brightness;
2048 return 0;
2049 }
2050
2051 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2052 {
2053 struct sd *sd = (struct sd *) gspca_dev;
2054
2055 sd->contrast = val;
2056 if (gspca_dev->streaming)
2057 setcontrast(gspca_dev);
2058 return 0;
2059 }
2060
2061 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2062 {
2063 struct sd *sd = (struct sd *) gspca_dev;
2064
2065 *val = sd->contrast;
2066 return 0;
2067 }
2068
2069 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2070 {
2071 struct sd *sd = (struct sd *) gspca_dev;
2072
2073 sd->colors = val;
2074 if (gspca_dev->streaming)
2075 setcolors(gspca_dev);
2076 return 0;
2077 }
2078
2079 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2080 {
2081 struct sd *sd = (struct sd *) gspca_dev;
2082
2083 *val = sd->colors;
2084 return 0;
2085 }
2086
2087 static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2088 {
2089 struct sd *sd = (struct sd *) gspca_dev;
2090
2091 sd->blue = val;
2092 if (gspca_dev->streaming)
2093 setredblue(gspca_dev);
2094 return 0;
2095 }
2096
2097 static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2098 {
2099 struct sd *sd = (struct sd *) gspca_dev;
2100
2101 *val = sd->blue;
2102 return 0;
2103 }
2104
2105 static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2106 {
2107 struct sd *sd = (struct sd *) gspca_dev;
2108
2109 sd->red = val;
2110 if (gspca_dev->streaming)
2111 setredblue(gspca_dev);
2112 return 0;
2113 }
2114
2115 static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2116 {
2117 struct sd *sd = (struct sd *) gspca_dev;
2118
2119 *val = sd->red;
2120 return 0;
2121 }
2122
2123 static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2124 {
2125 struct sd *sd = (struct sd *) gspca_dev;
2126
2127 sd->gamma = val;
2128 if (gspca_dev->streaming)
2129 setgamma(gspca_dev);
2130 return 0;
2131 }
2132
2133 static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2134 {
2135 struct sd *sd = (struct sd *) gspca_dev;
2136
2137 *val = sd->gamma;
2138 return 0;
2139 }
2140
2141 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2142 {
2143 struct sd *sd = (struct sd *) gspca_dev;
2144
2145 sd->autogain = val;
2146 if (gspca_dev->streaming)
2147 setautogain(gspca_dev);
2148 return 0;
2149 }
2150
2151 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2152 {
2153 struct sd *sd = (struct sd *) gspca_dev;
2154
2155 *val = sd->autogain;
2156 return 0;
2157 }
2158
2159 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2160 {
2161 struct sd *sd = (struct sd *) gspca_dev;
2162
2163 sd->vflip = val;
2164 if (gspca_dev->streaming)
2165 setvflip(sd);
2166 return 0;
2167 }
2168
2169 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2170 {
2171 struct sd *sd = (struct sd *) gspca_dev;
2172
2173 *val = sd->vflip;
2174 return 0;
2175 }
2176
2177 static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2178 {
2179 struct sd *sd = (struct sd *) gspca_dev;
2180
2181 sd->infrared = val;
2182 if (gspca_dev->streaming)
2183 setinfrared(sd);
2184 return 0;
2185 }
2186
2187 static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2188 {
2189 struct sd *sd = (struct sd *) gspca_dev;
2190
2191 *val = sd->infrared;
2192 return 0;
2193 }
2194
2195 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2196 {
2197 struct sd *sd = (struct sd *) gspca_dev;
2198
2199 sd->freq = val;
2200 if (gspca_dev->streaming)
2201 setfreq(gspca_dev);
2202 return 0;
2203 }
2204
2205 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2206 {
2207 struct sd *sd = (struct sd *) gspca_dev;
2208
2209 *val = sd->freq;
2210 return 0;
2211 }
2212
2213 static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2214 struct v4l2_jpegcompression *jcomp)
2215 {
2216 struct sd *sd = (struct sd *) gspca_dev;
2217
2218 if (jcomp->quality < QUALITY_MIN)
2219 sd->quality = QUALITY_MIN;
2220 else if (jcomp->quality > QUALITY_MAX)
2221 sd->quality = QUALITY_MAX;
2222 else
2223 sd->quality = jcomp->quality;
2224 if (gspca_dev->streaming)
2225 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2226 return 0;
2227 }
2228
2229 static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2230 struct v4l2_jpegcompression *jcomp)
2231 {
2232 struct sd *sd = (struct sd *) gspca_dev;
2233
2234 memset(jcomp, 0, sizeof *jcomp);
2235 jcomp->quality = sd->quality;
2236 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2237 | V4L2_JPEG_MARKER_DQT;
2238 return 0;
2239 }
2240
2241 static int sd_querymenu(struct gspca_dev *gspca_dev,
2242 struct v4l2_querymenu *menu)
2243 {
2244 switch (menu->id) {
2245 case V4L2_CID_POWER_LINE_FREQUENCY:
2246 switch (menu->index) {
2247 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2248 strcpy((char *) menu->name, "NoFliker");
2249 return 0;
2250 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2251 strcpy((char *) menu->name, "50 Hz");
2252 return 0;
2253 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2254 strcpy((char *) menu->name, "60 Hz");
2255 return 0;
2256 }
2257 break;
2258 }
2259 return -EINVAL;
2260 }
2261
2262 /* sub-driver description */
2263 static const struct sd_desc sd_desc = {
2264 .name = MODULE_NAME,
2265 .ctrls = sd_ctrls,
2266 .nctrls = ARRAY_SIZE(sd_ctrls),
2267 .config = sd_config,
2268 .init = sd_init,
2269 .start = sd_start,
2270 .stopN = sd_stopN,
2271 .stop0 = sd_stop0,
2272 .pkt_scan = sd_pkt_scan,
2273 .dq_callback = do_autogain,
2274 .get_jcomp = sd_get_jcomp,
2275 .set_jcomp = sd_set_jcomp,
2276 .querymenu = sd_querymenu,
2277 };
2278
2279 /* -- module initialisation -- */
2280 #define BSI(bridge, sensor, i2c_addr) \
2281 .driver_info = (BRIDGE_ ## bridge << 16) \
2282 | (SENSOR_ ## sensor << 8) \
2283 | (i2c_addr)
2284 static const __devinitdata struct usb_device_id device_table[] = {
2285 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2286 {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)},
2287 {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120, OV7660, 0x21)},
2288 #endif
2289 {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)},
2290 {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)},
2291 {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)},
2292 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)},
2293 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)},
2294 {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)},
2295 {USB_DEVICE(0x06f8, 0x3008), BSI(SN9C105, OV7660, 0x21)},
2296 /* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x21)}, */
2297 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, HV7131R, 0x11)},
2298 /* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x21)}, */
2299 /* {USB_DEVICE(0x0c45, 0x607b), BSI(SN9C102P, OV7660, 0x21)}, */
2300 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)},
2301 /* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x21)}, */
2302 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)},
2303 /* {USB_DEVICE(0x0c45, 0x60c2), BSI(SN9C105, P1030xC, 0x??)}, */
2304 /* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6802, 0x34)}, */
2305 /* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
2306 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)},
2307 /* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
2308 /* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x21)}, */
2309 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)},
2310 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2311 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)},
2312 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)},
2313 #endif
2314 {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120, MI0360, 0x5d)}, /*sn9c128*/
2315 /* {USB_DEVICE(0x0c45, 0x6102), BSI(SN9C120, P1030xC, ??)}, */
2316 /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6802, 0x34)}, */
2317 {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c128*/
2318 {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120, OV7660, 0x21)}, /*sn9c128*/
2319 {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120, HV7131R, 0x11)}, /*sn9c128*/
2320 {USB_DEVICE(0x0c45, 0x610e), BSI(SN9C120, OV7630, 0x21)}, /*sn9c128*/
2321 /* {USB_DEVICE(0x0c45, 0x610f), BSI(SN9C120, S5K53BEB, 0x??)}, */
2322 /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
2323 /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
2324 {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C120, OM6802, 0x34)}, /*sn9c325?*/
2325 /*bw600.inf:*/
2326 {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c110?*/
2327 {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)},
2328 {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x21)},
2329 /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */
2330 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2331 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)},
2332 #endif
2333 /* {USB_DEVICE(0x0c45, 0x6132), BSI(SN9C120, OV7670, 0x21)}, */
2334 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)},
2335 {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)},
2336 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2337 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)},
2338 #endif
2339 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
2340 {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x21)},
2341 /* {USB_DEVICE(0x0c45, 0x6142), BSI(SN9C120, PO2030N, ??)}, *sn9c120b*/
2342 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)}, /*sn9c120b*/
2343 {USB_DEVICE(0x0c45, 0x6148), BSI(SN9C120, OM6802, 0x34)}, /*sn9c120b*/
2344 {}
2345 };
2346 MODULE_DEVICE_TABLE(usb, device_table);
2347
2348 /* -- device connect -- */
2349 static int sd_probe(struct usb_interface *intf,
2350 const struct usb_device_id *id)
2351 {
2352 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2353 THIS_MODULE);
2354 }
2355
2356 static struct usb_driver sd_driver = {
2357 .name = MODULE_NAME,
2358 .id_table = device_table,
2359 .probe = sd_probe,
2360 .disconnect = gspca_disconnect,
2361 #ifdef CONFIG_PM
2362 .suspend = gspca_suspend,
2363 .resume = gspca_resume,
2364 #endif
2365 };
2366
2367 /* -- module insert / remove -- */
2368 static int __init sd_mod_init(void)
2369 {
2370 int ret;
2371 ret = usb_register(&sd_driver);
2372 if (ret < 0)
2373 return ret;
2374 info("registered");
2375 return 0;
2376 }
2377 static void __exit sd_mod_exit(void)
2378 {
2379 usb_deregister(&sd_driver);
2380 info("deregistered");
2381 }
2382
2383 module_init(sd_mod_init);
2384 module_exit(sd_mod_exit);
This page took 0.167618 seconds and 5 git commands to generate.