2 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
4 * Copyright (C) 2009-2010 Jean-François Moine <http://moinejf.free.fr>
5 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
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
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 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define MODULE_NAME "sonixj"
24 #include <linux/input.h>
28 #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
30 MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
31 MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32 MODULE_LICENSE("GPL");
47 NCTRLS /* number of controls */
50 /* specific webcam descriptor */
52 struct gspca_dev gspca_dev; /* !! must be the first item */
54 struct gspca_ctrl ctrls[NCTRLS];
59 u8 quality; /* image quality */
60 #define QUALITY_MIN 60
61 #define QUALITY_MAX 95
62 #define QUALITY_DEF 80
63 u8 jpegqual; /* webcam quality */
68 #define AG_CNT_START 13
71 #define BRIDGE_SN9C102P 0
72 #define BRIDGE_SN9C105 1
73 #define BRIDGE_SN9C110 2
74 #define BRIDGE_SN9C120 3
75 u8 sensor; /* Type of image sensor chip */
78 u8 jpeg_hdr[JPEG_HDR_SZ];
98 /* V4L2 controls supported by the driver */
99 static void setbrightness(struct gspca_dev *gspca_dev);
100 static void setcontrast(struct gspca_dev *gspca_dev);
101 static void setcolors(struct gspca_dev *gspca_dev);
102 static void setredblue(struct gspca_dev *gspca_dev);
103 static void setgamma(struct gspca_dev *gspca_dev);
104 static void setautogain(struct gspca_dev *gspca_dev);
105 static void setvflip(struct gspca_dev *gspca_dev);
106 static void setsharpness(struct gspca_dev *gspca_dev);
107 static void setinfrared(struct gspca_dev *gspca_dev);
108 static void setfreq(struct gspca_dev *gspca_dev);
110 static const struct ctrl sd_ctrls[NCTRLS] = {
113 .id = V4L2_CID_BRIGHTNESS,
114 .type = V4L2_CTRL_TYPE_INTEGER,
115 .name = "Brightness",
119 .default_value = 0x80,
121 .set_control = setbrightness
125 .id = V4L2_CID_CONTRAST,
126 .type = V4L2_CTRL_TYPE_INTEGER,
129 #define CONTRAST_MAX 127
130 .maximum = CONTRAST_MAX,
134 .set_control = setcontrast
138 .id = V4L2_CID_SATURATION,
139 .type = V4L2_CTRL_TYPE_INTEGER,
140 .name = "Saturation",
144 #define COLORS_DEF 25
145 .default_value = COLORS_DEF,
147 .set_control = setcolors
151 .id = V4L2_CID_BLUE_BALANCE,
152 .type = V4L2_CTRL_TYPE_INTEGER,
153 .name = "Blue Balance",
159 .set_control = setredblue
163 .id = V4L2_CID_RED_BALANCE,
164 .type = V4L2_CTRL_TYPE_INTEGER,
165 .name = "Red Balance",
171 .set_control = setredblue
175 .id = V4L2_CID_GAMMA,
176 .type = V4L2_CTRL_TYPE_INTEGER,
182 .default_value = GAMMA_DEF,
184 .set_control = setgamma
188 .id = V4L2_CID_AUTOGAIN,
189 .type = V4L2_CTRL_TYPE_BOOLEAN,
196 .set_control = setautogain
198 /* ov7630/ov7648 only */
201 .id = V4L2_CID_VFLIP,
202 .type = V4L2_CTRL_TYPE_BOOLEAN,
209 .set_control = setvflip
213 .id = V4L2_CID_SHARPNESS,
214 .type = V4L2_CTRL_TYPE_INTEGER,
221 .set_control = setsharpness
226 .id = V4L2_CID_INFRARED,
227 .type = V4L2_CTRL_TYPE_BOOLEAN,
234 .set_control = setinfrared
236 /* ov7630/ov7648/ov7660 only */
239 .id = V4L2_CID_POWER_LINE_FREQUENCY,
240 .type = V4L2_CTRL_TYPE_MENU,
241 .name = "Light frequency filter",
243 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
247 .set_control = setfreq
251 /* table of the disabled controls */
252 static const __u32 ctrl_dis[] = {
253 [SENSOR_ADCM1700] = (1 << AUTOGAIN) |
258 [SENSOR_GC0307] = (1 << INFRARED) |
262 [SENSOR_HV7131R] = (1 << INFRARED) |
265 [SENSOR_MI0360] = (1 << INFRARED) |
269 [SENSOR_MI0360B] = (1 << INFRARED) |
273 [SENSOR_MO4000] = (1 << INFRARED) |
277 [SENSOR_MT9V111] = (1 << VFLIP) |
280 [SENSOR_OM6802] = (1 << INFRARED) |
284 [SENSOR_OV7630] = (1 << INFRARED),
286 [SENSOR_OV7648] = (1 << INFRARED),
288 [SENSOR_OV7660] = (1 << AUTOGAIN) |
292 [SENSOR_PO1030] = (1 << AUTOGAIN) |
297 [SENSOR_PO2030N] = (1 << AUTOGAIN) |
301 [SENSOR_SOI768] = (1 << AUTOGAIN) |
306 [SENSOR_SP80708] = (1 << AUTOGAIN) |
312 static const struct v4l2_pix_format cif_mode[] = {
313 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
315 .sizeimage = 352 * 288 * 4 / 8 + 590,
316 .colorspace = V4L2_COLORSPACE_JPEG,
319 static const struct v4l2_pix_format vga_mode[] = {
320 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
322 .sizeimage = 160 * 120 * 4 / 8 + 590,
323 .colorspace = V4L2_COLORSPACE_JPEG,
325 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
327 .sizeimage = 320 * 240 * 3 / 8 + 590,
328 .colorspace = V4L2_COLORSPACE_JPEG,
330 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
332 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
333 .sizeimage = 640 * 480 * 3 / 4 + 590,
334 .colorspace = V4L2_COLORSPACE_JPEG,
338 static const u8 sn_adcm1700[0x1c] = {
339 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
340 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
341 /* reg8 reg9 rega regb regc regd rege regf */
342 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
343 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
344 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
345 /* reg18 reg19 reg1a reg1b */
346 0x06, 0x00, 0x00, 0x00
349 static const u8 sn_gc0307[0x1c] = {
350 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
351 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
352 /* reg8 reg9 rega regb regc regd rege regf */
353 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
354 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
355 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
356 /* reg18 reg19 reg1a reg1b */
357 0x06, 0x00, 0x00, 0x00
360 static const u8 sn_hv7131[0x1c] = {
361 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
362 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
363 /* reg8 reg9 rega regb regc regd rege regf */
364 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
365 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
366 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
367 /* reg18 reg19 reg1a reg1b */
368 0x0a, 0x00, 0x00, 0x00
371 static const u8 sn_mi0360[0x1c] = {
372 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
373 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
374 /* reg8 reg9 rega regb regc regd rege regf */
375 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
376 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
377 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
378 /* reg18 reg19 reg1a reg1b */
379 0x06, 0x00, 0x00, 0x00
382 static const u8 sn_mi0360b[0x1c] = {
383 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
384 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
385 /* reg8 reg9 rega regb regc regd rege regf */
386 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
388 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
389 /* reg18 reg19 reg1a reg1b */
390 0x06, 0x00, 0x00, 0x00
393 static const u8 sn_mo4000[0x1c] = {
394 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
395 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
396 /* reg8 reg9 rega regb regc regd rege regf */
397 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
398 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
399 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
400 /* reg18 reg19 reg1a reg1b */
401 0x08, 0x00, 0x00, 0x00
404 static const u8 sn_mt9v111[0x1c] = {
405 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
406 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
407 /* reg8 reg9 rega regb regc regd rege regf */
408 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
409 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
410 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
411 /* reg18 reg19 reg1a reg1b */
412 0x06, 0x00, 0x00, 0x00
415 static const u8 sn_om6802[0x1c] = {
416 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
417 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
418 /* reg8 reg9 rega regb regc regd rege regf */
419 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
420 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
421 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
422 /* reg18 reg19 reg1a reg1b */
423 0x05, 0x00, 0x00, 0x00
426 static const u8 sn_ov7630[0x1c] = {
427 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
428 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
429 /* reg8 reg9 rega regb regc regd rege regf */
430 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
431 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
432 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
433 /* reg18 reg19 reg1a reg1b */
434 0x0b, 0x00, 0x00, 0x00
437 static const u8 sn_ov7648[0x1c] = {
438 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
439 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
440 /* reg8 reg9 rega regb regc regd rege regf */
441 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
442 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
443 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
444 /* reg18 reg19 reg1a reg1b */
445 0x0b, 0x00, 0x00, 0x00
448 static const u8 sn_ov7660[0x1c] = {
449 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
450 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
451 /* reg8 reg9 rega regb regc regd rege regf */
452 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
453 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
454 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
455 /* reg18 reg19 reg1a reg1b */
456 0x07, 0x00, 0x00, 0x00
459 static const u8 sn_po1030[0x1c] = {
460 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
461 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
462 /* reg8 reg9 rega regb regc regd rege regf */
463 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
464 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
465 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
466 /* reg18 reg19 reg1a reg1b */
467 0x07, 0x00, 0x00, 0x00
470 static const u8 sn_po2030n[0x1c] = {
471 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
472 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
473 /* reg8 reg9 rega regb regc regd rege regf */
474 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
475 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
476 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
477 /* reg18 reg19 reg1a reg1b */
478 0x07, 0x00, 0x00, 0x00
481 static const u8 sn_soi768[0x1c] = {
482 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
483 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
484 /* reg8 reg9 rega regb regc regd rege regf */
485 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
486 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
487 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
488 /* reg18 reg19 reg1a reg1b */
489 0x07, 0x00, 0x00, 0x00
492 static const u8 sn_sp80708[0x1c] = {
493 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
494 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
495 /* reg8 reg9 rega regb regc regd rege regf */
496 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
497 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
498 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
499 /* reg18 reg19 reg1a reg1b */
500 0x07, 0x00, 0x00, 0x00
503 /* sequence specific to the sensors - !! index = SENSOR_xxx */
504 static const u8 *sn_tb[] = {
505 [SENSOR_ADCM1700] = sn_adcm1700,
506 [SENSOR_GC0307] = sn_gc0307,
507 [SENSOR_HV7131R] = sn_hv7131,
508 [SENSOR_MI0360] = sn_mi0360,
509 [SENSOR_MI0360B] = sn_mi0360b,
510 [SENSOR_MO4000] = sn_mo4000,
511 [SENSOR_MT9V111] = sn_mt9v111,
512 [SENSOR_OM6802] = sn_om6802,
513 [SENSOR_OV7630] = sn_ov7630,
514 [SENSOR_OV7648] = sn_ov7648,
515 [SENSOR_OV7660] = sn_ov7660,
516 [SENSOR_PO1030] = sn_po1030,
517 [SENSOR_PO2030N] = sn_po2030n,
518 [SENSOR_SOI768] = sn_soi768,
519 [SENSOR_SP80708] = sn_sp80708,
522 /* default gamma table */
523 static const u8 gamma_def[17] = {
524 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
525 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
527 /* gamma for sensor ADCM1700 */
528 static const u8 gamma_spec_0[17] = {
529 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
530 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
532 /* gamma for sensors HV7131R and MT9V111 */
533 static const u8 gamma_spec_1[17] = {
534 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
535 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
537 /* gamma for sensor GC0307 */
538 static const u8 gamma_spec_2[17] = {
539 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
540 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
542 /* gamma for sensor SP80708 */
543 static const u8 gamma_spec_3[17] = {
544 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
545 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
548 /* color matrix and offsets */
549 static const u8 reg84[] = {
550 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
551 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
552 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
553 0x00, 0x00, 0x00 /* YUV offsets */
555 static const u8 adcm1700_sensor_init[][8] = {
556 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
557 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
558 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
559 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
560 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
561 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
562 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
563 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
564 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
565 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
566 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
567 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
568 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
569 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
570 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
571 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
572 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
575 static const u8 adcm1700_sensor_param1[][8] = {
576 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
577 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
579 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
580 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
581 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
582 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
583 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
585 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
586 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
587 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
588 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
591 static const u8 gc0307_sensor_init[][8] = {
592 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
593 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
594 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
595 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
596 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
597 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
598 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
599 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
600 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
601 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
602 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
603 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
604 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
605 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
606 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
607 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
608 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
609 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
610 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
611 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
612 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
613 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
614 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
615 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
616 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
617 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
618 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
619 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
620 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
621 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
622 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
623 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
625 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
626 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
627 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
632 static const u8 gc0307_sensor_param1[][8] = {
633 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
634 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
635 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
636 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
638 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
643 static const u8 hv7131r_sensor_init[][8] = {
644 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
645 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
646 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
647 /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
648 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
649 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
650 /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
652 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
653 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
654 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
655 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
656 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
657 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
658 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
659 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
661 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
662 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
663 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
664 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
665 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
667 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
668 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
669 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
670 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
671 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
672 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
673 /* set sensor clock */
676 static const u8 mi0360_sensor_init[][8] = {
677 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
678 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
679 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
680 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
681 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
682 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
683 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
684 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
685 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
686 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
687 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
688 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
689 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
690 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
691 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
692 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
693 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
694 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
695 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
696 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
697 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
698 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
699 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
700 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
701 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
702 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
703 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
704 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
705 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
706 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
707 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
708 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
709 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
711 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
712 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
713 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
714 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
715 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
717 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
718 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
719 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
720 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
722 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
723 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
724 /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
725 /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
726 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
727 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
730 static const u8 mi0360b_sensor_init[][8] = {
731 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
732 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
733 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
734 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
735 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
736 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
737 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
738 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
739 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
740 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
741 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
742 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
743 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
745 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
746 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
747 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
748 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
749 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
750 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
751 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
752 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
753 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
754 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
755 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
756 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
757 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
758 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
759 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
760 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
761 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
762 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
763 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
764 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
765 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
767 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
768 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
769 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
770 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
771 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
774 static const u8 mi0360b_sensor_param1[][8] = {
775 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
777 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
778 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
780 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
781 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
782 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
783 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
786 static const u8 mo4000_sensor_init[][8] = {
787 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
788 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
789 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
792 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
793 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
794 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
795 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
796 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
797 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
798 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
799 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
800 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
801 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
802 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
803 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
804 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
805 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
806 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
809 static const u8 mt9v111_sensor_init[][8] = {
810 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
811 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
812 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
813 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
814 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
815 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
816 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
817 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
818 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
819 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
820 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
821 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
822 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
823 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
824 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
825 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
826 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
827 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
828 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
829 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
830 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
831 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
832 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
833 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
834 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
835 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
836 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
837 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
840 static const u8 mt9v111_sensor_param1[][8] = {
841 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
842 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
843 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
844 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
845 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
847 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
848 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
849 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
850 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
853 static const u8 om6802_init0[2][8] = {
855 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
856 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
858 static const u8 om6802_sensor_init[][8] = {
859 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
861 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
863 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
864 /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
865 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
866 /* auto-exposure speed (0) / white balance mode (auto RGB) */
867 /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
869 /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
870 * max AGC value in AE */
871 /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
873 /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
874 * preset brightness */
875 /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
877 /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
879 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
880 /* luminance mode (0x4f -> AutoExpo on) */
881 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
883 /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
885 /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
886 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
889 static const u8 om6802_sensor_param1[][8] = {
890 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
891 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
892 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
893 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
896 static const u8 ov7630_sensor_init[][8] = {
897 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
898 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
899 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
900 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
901 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
902 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
903 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
904 /* win: i2c_r from 00 to 80 */
905 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
906 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
907 /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
908 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
909 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
910 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
911 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
912 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
913 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
914 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
915 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
916 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
917 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
918 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
919 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
920 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
921 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
922 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
923 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
924 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
925 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
926 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
927 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
928 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
929 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
930 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
931 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
932 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
935 static const u8 ov7630_sensor_param1[][8] = {
936 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
937 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
938 /*fixme: + 0x12, 0x04*/
939 /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
941 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
942 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
943 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
945 /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
946 /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
948 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
949 /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
953 static const u8 ov7648_sensor_init[][8] = {
954 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
955 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
956 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
957 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
958 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
959 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
960 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
961 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
962 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
963 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
964 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
965 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
966 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
967 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
968 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
969 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
970 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
971 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
972 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
973 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
974 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
975 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
977 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
978 /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
979 /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
980 /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
983 static const u8 ov7648_sensor_param1[][8] = {
984 /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
985 /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
987 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
988 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
989 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
990 /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
991 /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
993 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
994 /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
995 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
996 /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
997 /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
998 /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1003 static const u8 ov7660_sensor_init[][8] = {
1004 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
1005 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1006 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
1007 /* Outformat = rawRGB */
1008 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
1009 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
1010 /* GAIN BLUE RED VREF */
1011 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1012 /* COM 1 BAVE GEAVE AECHH */
1013 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1014 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
1015 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
1016 /* AECH CLKRC COM7 COM8 */
1017 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1018 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1019 /* HSTART HSTOP VSTRT VSTOP */
1020 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1021 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1022 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1023 /* BOS GBOS GROS ROS (BGGR offset) */
1024 /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1025 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
1026 /* AEW AEB VPT BBIAS */
1027 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1028 /* GbBIAS RSVD EXHCH EXHCL */
1029 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1030 /* RBIAS ADVFL ASDVFH YAVE */
1031 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1032 /* HSYST HSYEN HREF */
1033 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1034 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1035 /* ADC ACOM OFON TSLB */
1036 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1037 /* COM11 COM12 COM13 COM14 */
1038 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1039 /* EDGE COM15 COM16 COM17 */
1040 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1041 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1042 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1043 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1044 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1045 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1046 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1047 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1048 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1049 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1050 /* LCC1 LCC2 LCC3 LCC4 */
1051 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
1052 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
1053 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
1054 /* band gap reference [0:3] DBLV */
1055 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1056 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1057 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1058 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1059 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1060 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1061 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1062 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1063 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
1064 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
1065 /* not in all ms-win traces*/
1066 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
1069 static const u8 ov7660_sensor_param1[][8] = {
1070 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
1071 /* bits[3..0]reserved */
1072 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1073 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1074 /* VREF vertical frame ctrl */
1075 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1076 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1077 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1078 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1079 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1080 /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
1081 /****** (some exchanges in the win trace) ******/
1083 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
1084 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1085 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1086 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1087 /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
1088 /****** (some exchanges in the win trace) ******/
1089 /******!! startsensor KO if changed !!****/
1091 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1092 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1093 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1094 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
1098 static const u8 po1030_sensor_init[][8] = {
1099 /* the sensor registers are described in m5602/m5602_po1030.h */
1100 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1101 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1102 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1103 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1104 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1105 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1106 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1107 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1108 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1109 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1110 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1111 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1112 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1113 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1114 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1115 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1116 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1117 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1118 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1119 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1120 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1121 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1122 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1123 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1124 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1125 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1126 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1127 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1129 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1130 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1131 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1132 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1133 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1136 static const u8 po1030_sensor_param1[][8] = {
1137 /* from ms-win traces - these values change with auto gain/expo/wb.. */
1138 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1139 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1141 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1142 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1143 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1145 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1146 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1147 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1148 /* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1152 static const u8 po2030n_sensor_init[][8] = {
1153 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1154 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1155 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1156 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1157 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1158 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1159 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1160 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1161 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1162 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1163 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1164 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1165 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1166 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1167 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1168 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1169 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1170 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1171 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1172 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1173 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1174 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1175 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1176 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1177 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1178 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1179 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1180 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1181 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1182 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1183 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1184 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1185 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1186 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1187 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1188 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1189 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1190 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1191 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1192 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1193 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1194 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1195 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1196 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1197 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1198 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1199 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1200 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1201 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1202 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1205 static const u8 po2030n_sensor_param1[][8] = {
1206 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1207 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1208 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1209 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1210 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1212 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1213 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1214 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1215 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1216 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1217 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1218 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1220 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1221 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1222 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1223 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1224 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1228 static const u8 soi768_sensor_init[][8] = {
1229 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
1230 {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
1231 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1232 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1233 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1234 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1237 static const u8 soi768_sensor_param1[][8] = {
1238 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1239 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1240 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1241 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1242 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1244 /* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1245 /* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1246 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1247 /* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1248 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1249 /* the next sequence should be used for auto gain */
1250 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1251 /* global gain ? : 07 - change with 0x15 at the end */
1252 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1253 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1254 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1255 /* exposure ? : 0200 - change with 0x1e at the end */
1259 static const u8 sp80708_sensor_init[][8] = {
1260 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1261 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1262 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1263 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1264 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1265 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1266 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1267 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1268 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1269 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1270 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1271 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1272 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1273 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1274 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1275 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1276 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1277 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1278 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1279 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1280 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1281 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1282 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1283 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1284 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1285 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1286 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1287 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1288 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1289 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1290 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1291 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1292 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1293 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1294 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1295 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1296 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1297 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1298 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1299 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1300 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1301 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1302 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1303 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1304 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1305 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1306 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
1333 static const u8 sp80708_sensor_param1[][8] = {
1334 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1340 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1344 static const u8 (*sensor_init[])[8] = {
1345 [SENSOR_ADCM1700] = adcm1700_sensor_init,
1346 [SENSOR_GC0307] = gc0307_sensor_init,
1347 [SENSOR_HV7131R] = hv7131r_sensor_init,
1348 [SENSOR_MI0360] = mi0360_sensor_init,
1349 [SENSOR_MI0360B] = mi0360b_sensor_init,
1350 [SENSOR_MO4000] = mo4000_sensor_init,
1351 [SENSOR_MT9V111] = mt9v111_sensor_init,
1352 [SENSOR_OM6802] = om6802_sensor_init,
1353 [SENSOR_OV7630] = ov7630_sensor_init,
1354 [SENSOR_OV7648] = ov7648_sensor_init,
1355 [SENSOR_OV7660] = ov7660_sensor_init,
1356 [SENSOR_PO1030] = po1030_sensor_init,
1357 [SENSOR_PO2030N] = po2030n_sensor_init,
1358 [SENSOR_SOI768] = soi768_sensor_init,
1359 [SENSOR_SP80708] = sp80708_sensor_init,
1362 /* read <len> bytes to gspca_dev->usb_buf */
1363 static void reg_r(struct gspca_dev *gspca_dev,
1368 if (gspca_dev->usb_err < 0)
1371 if (len > USB_BUF_SZ) {
1372 err("reg_r: buffer overflow");
1376 ret = usb_control_msg(gspca_dev->dev,
1377 usb_rcvctrlpipe(gspca_dev->dev, 0),
1379 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1381 gspca_dev->usb_buf, len,
1383 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
1385 err("reg_r err %d", ret);
1386 gspca_dev->usb_err = ret;
1390 static void reg_w1(struct gspca_dev *gspca_dev,
1396 if (gspca_dev->usb_err < 0)
1398 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
1399 gspca_dev->usb_buf[0] = data;
1400 ret = usb_control_msg(gspca_dev->dev,
1401 usb_sndctrlpipe(gspca_dev->dev, 0),
1403 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1406 gspca_dev->usb_buf, 1,
1409 err("reg_w1 err %d", ret);
1410 gspca_dev->usb_err = ret;
1413 static void reg_w(struct gspca_dev *gspca_dev,
1420 if (gspca_dev->usb_err < 0)
1422 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
1423 value, buffer[0], buffer[1]);
1425 if (len > USB_BUF_SZ) {
1426 err("reg_w: buffer overflow");
1430 memcpy(gspca_dev->usb_buf, buffer, len);
1431 ret = usb_control_msg(gspca_dev->dev,
1432 usb_sndctrlpipe(gspca_dev->dev, 0),
1434 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1436 gspca_dev->usb_buf, len,
1439 err("reg_w err %d", ret);
1440 gspca_dev->usb_err = ret;
1444 /* I2C write 1 byte */
1445 static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1447 struct sd *sd = (struct sd *) gspca_dev;
1450 if (gspca_dev->usb_err < 0)
1452 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
1453 switch (sd->sensor) {
1454 case SENSOR_ADCM1700:
1456 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
1457 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1459 default: /* i2c command = a1 (400 kHz) */
1460 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1463 gspca_dev->usb_buf[1] = sd->i2c_addr;
1464 gspca_dev->usb_buf[2] = reg;
1465 gspca_dev->usb_buf[3] = val;
1466 gspca_dev->usb_buf[4] = 0;
1467 gspca_dev->usb_buf[5] = 0;
1468 gspca_dev->usb_buf[6] = 0;
1469 gspca_dev->usb_buf[7] = 0x10;
1470 ret = usb_control_msg(gspca_dev->dev,
1471 usb_sndctrlpipe(gspca_dev->dev, 0),
1473 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1474 0x08, /* value = i2c */
1476 gspca_dev->usb_buf, 8,
1479 err("i2c_w1 err %d", ret);
1480 gspca_dev->usb_err = ret;
1484 /* I2C write 8 bytes */
1485 static void i2c_w8(struct gspca_dev *gspca_dev,
1490 if (gspca_dev->usb_err < 0)
1492 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1493 buffer[2], buffer[3]);
1494 memcpy(gspca_dev->usb_buf, buffer, 8);
1495 ret = usb_control_msg(gspca_dev->dev,
1496 usb_sndctrlpipe(gspca_dev->dev, 0),
1498 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1499 0x08, 0, /* value, index */
1500 gspca_dev->usb_buf, 8,
1504 err("i2c_w8 err %d", ret);
1505 gspca_dev->usb_err = ret;
1509 /* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1510 static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
1512 struct sd *sd = (struct sd *) gspca_dev;
1515 switch (sd->sensor) {
1516 case SENSOR_ADCM1700:
1518 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
1519 mode[0] = 0x80 | 0x10;
1521 default: /* i2c command = 91 (400 kHz) */
1522 mode[0] = 0x81 | 0x10;
1525 mode[1] = sd->i2c_addr;
1532 i2c_w8(gspca_dev, mode);
1534 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
1536 i2c_w8(gspca_dev, mode);
1538 reg_r(gspca_dev, 0x0a, 5);
1541 static void i2c_w_seq(struct gspca_dev *gspca_dev,
1542 const u8 (*data)[8])
1544 while ((*data)[0] != 0) {
1545 if ((*data)[0] != 0xdd)
1546 i2c_w8(gspca_dev, *data);
1553 static void hv7131r_probe(struct gspca_dev *gspca_dev)
1555 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
1557 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
1559 i2c_r(gspca_dev, 0, 5); /* read sensor id */
1560 if (gspca_dev->usb_buf[0] == 0x02
1561 && gspca_dev->usb_buf[1] == 0x09
1562 && gspca_dev->usb_buf[2] == 0x01
1563 && gspca_dev->usb_buf[3] == 0x00
1564 && gspca_dev->usb_buf[4] == 0x00) {
1565 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1568 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
1569 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1570 gspca_dev->usb_buf[2]);
1573 static void mi0360_probe(struct gspca_dev *gspca_dev)
1575 struct sd *sd = (struct sd *) gspca_dev;
1578 static const u8 probe_tb[][4][8] = {
1580 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1581 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1582 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1583 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1586 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1587 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1588 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1593 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1594 reg_w1(gspca_dev, 0x17, 0x62);
1595 reg_w1(gspca_dev, 0x01, 0x08);
1596 for (j = 0; j < 3; j++)
1597 i2c_w8(gspca_dev, probe_tb[i][j]);
1599 reg_r(gspca_dev, 0x0a, 5);
1600 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1601 if (probe_tb[i][3][0] != 0)
1602 i2c_w8(gspca_dev, probe_tb[i][3]);
1603 reg_w1(gspca_dev, 0x01, 0x29);
1604 reg_w1(gspca_dev, 0x17, 0x42);
1608 if (gspca_dev->usb_err < 0)
1612 PDEBUG(D_PROBE, "Sensor mi0360b");
1613 sd->sensor = SENSOR_MI0360B;
1616 PDEBUG(D_PROBE, "Sensor mt9v111");
1617 sd->sensor = SENSOR_MT9V111;
1620 PDEBUG(D_PROBE, "Sensor mi0360");
1623 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1628 static void ov7630_probe(struct gspca_dev *gspca_dev)
1630 struct sd *sd = (struct sd *) gspca_dev;
1634 reg_w1(gspca_dev, 0x17, 0x62);
1635 reg_w1(gspca_dev, 0x01, 0x08);
1636 sd->i2c_addr = 0x21;
1637 i2c_r(gspca_dev, 0x0a, 2);
1638 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1639 reg_w1(gspca_dev, 0x01, 0x29);
1640 reg_w1(gspca_dev, 0x17, 0x42);
1641 if (gspca_dev->usb_err < 0)
1643 if (val == 0x7628) { /* soi768 */
1644 sd->sensor = SENSOR_SOI768;
1645 /*fixme: only valid for 0c45:613e?*/
1646 gspca_dev->cam.input_flags =
1647 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1648 PDEBUG(D_PROBE, "Sensor soi768");
1651 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1654 static void ov7648_probe(struct gspca_dev *gspca_dev)
1656 struct sd *sd = (struct sd *) gspca_dev;
1660 reg_w1(gspca_dev, 0x17, 0x62);
1661 reg_w1(gspca_dev, 0x01, 0x08);
1662 sd->i2c_addr = 0x21;
1663 i2c_r(gspca_dev, 0x0a, 2);
1664 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1665 reg_w1(gspca_dev, 0x01, 0x29);
1666 reg_w1(gspca_dev, 0x17, 0x42);
1667 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1668 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1673 reg_w1(gspca_dev, 0x17, 0x62);
1674 reg_w1(gspca_dev, 0x01, 0x08);
1675 sd->i2c_addr = 0x6e;
1676 i2c_r(gspca_dev, 0x00, 2);
1677 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1678 reg_w1(gspca_dev, 0x01, 0x29);
1679 reg_w1(gspca_dev, 0x17, 0x42);
1680 if (gspca_dev->usb_err < 0)
1682 if (val == 0x1030) { /* po1030 */
1683 PDEBUG(D_PROBE, "Sensor po1030");
1684 sd->sensor = SENSOR_PO1030;
1688 err("Unknown sensor %04x", val);
1691 /* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1692 static void po2030n_probe(struct gspca_dev *gspca_dev)
1694 struct sd *sd = (struct sd *) gspca_dev;
1698 reg_w1(gspca_dev, 0x17, 0x62);
1699 reg_w1(gspca_dev, 0x01, 0x08);
1700 reg_w1(gspca_dev, 0x02, 0x22);
1701 sd->i2c_addr = 0x21;
1702 i2c_r(gspca_dev, 0x00, 1);
1703 val = gspca_dev->usb_buf[4];
1704 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1705 reg_w1(gspca_dev, 0x17, 0x42);
1706 if (val == 0x99) { /* gc0307 (?) */
1707 PDEBUG(D_PROBE, "Sensor gc0307");
1708 sd->sensor = SENSOR_GC0307;
1713 reg_w1(gspca_dev, 0x17, 0x62);
1714 reg_w1(gspca_dev, 0x01, 0x0a);
1715 sd->i2c_addr = 0x6e;
1716 i2c_r(gspca_dev, 0x00, 2);
1717 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1718 reg_w1(gspca_dev, 0x01, 0x29);
1719 reg_w1(gspca_dev, 0x17, 0x42);
1720 if (gspca_dev->usb_err < 0)
1722 if (val == 0x2030) {
1723 PDEBUG(D_PROBE, "Sensor po2030n");
1724 /* sd->sensor = SENSOR_PO2030N; */
1726 err("Unknown sensor ID %04x", val);
1730 static void bridge_init(struct gspca_dev *gspca_dev,
1733 struct sd *sd = (struct sd *) gspca_dev;
1736 static const u8 reg9a_def[] =
1737 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1738 static const u8 reg9a_spec[] =
1739 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1740 static const u8 regd4[] = {0x60, 0x00, 0x00};
1742 /* sensor clock already enabled in sd_init */
1743 /* reg_w1(gspca_dev, 0xf1, 0x00); */
1744 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1746 /* configure gpio */
1747 reg0102[0] = sn9c1xx[1];
1748 reg0102[1] = sn9c1xx[2];
1749 if (gspca_dev->audio)
1750 reg0102[1] |= 0x04; /* keep the audio connection */
1751 reg_w(gspca_dev, 0x01, reg0102, 2);
1752 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
1753 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
1754 switch (sd->sensor) {
1758 case SENSOR_PO2030N:
1760 case SENSOR_SP80708:
1767 reg_w(gspca_dev, 0x9a, reg9a, 6);
1769 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
1771 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
1773 switch (sd->sensor) {
1774 case SENSOR_ADCM1700:
1775 reg_w1(gspca_dev, 0x01, 0x43);
1776 reg_w1(gspca_dev, 0x17, 0x62);
1777 reg_w1(gspca_dev, 0x01, 0x42);
1778 reg_w1(gspca_dev, 0x01, 0x42);
1782 reg_w1(gspca_dev, 0x01, 0x61);
1783 reg_w1(gspca_dev, 0x17, 0x22);
1784 reg_w1(gspca_dev, 0x01, 0x60);
1785 reg_w1(gspca_dev, 0x01, 0x40);
1788 case SENSOR_MI0360B:
1789 reg_w1(gspca_dev, 0x01, 0x61);
1790 reg_w1(gspca_dev, 0x17, 0x60);
1791 reg_w1(gspca_dev, 0x01, 0x60);
1792 reg_w1(gspca_dev, 0x01, 0x40);
1794 case SENSOR_MT9V111:
1795 reg_w1(gspca_dev, 0x01, 0x61);
1796 reg_w1(gspca_dev, 0x17, 0x61);
1797 reg_w1(gspca_dev, 0x01, 0x60);
1798 reg_w1(gspca_dev, 0x01, 0x40);
1802 reg_w1(gspca_dev, 0x02, 0x73);
1803 reg_w1(gspca_dev, 0x17, 0x60);
1804 reg_w1(gspca_dev, 0x01, 0x22);
1806 reg_w1(gspca_dev, 0x01, 0x62);
1807 reg_w1(gspca_dev, 0x17, 0x64);
1808 reg_w1(gspca_dev, 0x17, 0x64);
1809 reg_w1(gspca_dev, 0x01, 0x42);
1811 reg_w1(gspca_dev, 0x01, 0x42);
1812 i2c_w8(gspca_dev, om6802_init0[0]);
1813 i2c_w8(gspca_dev, om6802_init0[1]);
1815 reg_w1(gspca_dev, 0x02, 0x71);
1819 reg_w1(gspca_dev, 0x01, 0x61);
1820 reg_w1(gspca_dev, 0x17, 0xe2);
1821 reg_w1(gspca_dev, 0x01, 0x60);
1822 reg_w1(gspca_dev, 0x01, 0x40);
1825 reg_w1(gspca_dev, 0x01, 0x63);
1826 reg_w1(gspca_dev, 0x17, 0x20);
1827 reg_w1(gspca_dev, 0x01, 0x62);
1828 reg_w1(gspca_dev, 0x01, 0x42);
1832 reg_w1(gspca_dev, 0x01, 0x61);
1833 reg_w1(gspca_dev, 0x17, 0x20);
1834 reg_w1(gspca_dev, 0x01, 0x60);
1835 reg_w1(gspca_dev, 0x01, 0x40);
1837 case SENSOR_PO2030N:
1839 reg_w1(gspca_dev, 0x01, 0x63);
1840 reg_w1(gspca_dev, 0x17, 0x20);
1841 reg_w1(gspca_dev, 0x01, 0x62);
1842 reg_w1(gspca_dev, 0x01, 0x42);
1844 case SENSOR_SP80708:
1845 reg_w1(gspca_dev, 0x01, 0x63);
1846 reg_w1(gspca_dev, 0x17, 0x20);
1847 reg_w1(gspca_dev, 0x01, 0x62);
1848 reg_w1(gspca_dev, 0x01, 0x42);
1850 reg_w1(gspca_dev, 0x02, 0x62);
1853 /* case SENSOR_HV7131R: */
1854 /* case SENSOR_MI0360: */
1855 /* case SENSOR_MO4000: */
1856 reg_w1(gspca_dev, 0x01, 0x43);
1857 reg_w1(gspca_dev, 0x17, 0x61);
1858 reg_w1(gspca_dev, 0x01, 0x42);
1859 if (sd->sensor == SENSOR_HV7131R
1860 && sd->bridge == BRIDGE_SN9C102P)
1861 hv7131r_probe(gspca_dev);
1866 /* this function is called at probe time */
1867 static int sd_config(struct gspca_dev *gspca_dev,
1868 const struct usb_device_id *id)
1870 struct sd *sd = (struct sd *) gspca_dev;
1873 sd->bridge = id->driver_info >> 16;
1874 sd->sensor = id->driver_info;
1876 cam = &gspca_dev->cam;
1877 if (sd->sensor == SENSOR_ADCM1700) {
1878 cam->cam_mode = cif_mode;
1879 cam->nmodes = ARRAY_SIZE(cif_mode);
1881 cam->cam_mode = vga_mode;
1882 cam->nmodes = ARRAY_SIZE(vga_mode);
1884 cam->npkt = 24; /* 24 packets per ISOC message */
1885 cam->ctrls = sd->ctrls;
1888 sd->quality = QUALITY_DEF;
1894 /* this function is called at probe and resume time */
1895 static int sd_init(struct gspca_dev *gspca_dev)
1897 struct sd *sd = (struct sd *) gspca_dev;
1899 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
1902 /* setup a selector by bridge */
1903 reg_w1(gspca_dev, 0xf1, 0x01);
1904 reg_r(gspca_dev, 0x00, 1);
1905 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1906 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
1907 regF1 = gspca_dev->usb_buf[0];
1908 if (gspca_dev->usb_err < 0)
1909 return gspca_dev->usb_err;
1910 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
1911 switch (sd->bridge) {
1912 case BRIDGE_SN9C102P:
1915 reg_w1(gspca_dev, 0x02, regGpio[1]);
1917 case BRIDGE_SN9C105:
1920 if (sd->sensor == SENSOR_MI0360)
1921 mi0360_probe(gspca_dev);
1922 reg_w(gspca_dev, 0x01, regGpio, 2);
1924 case BRIDGE_SN9C120:
1927 switch (sd->sensor) {
1929 mi0360_probe(gspca_dev);
1932 ov7630_probe(gspca_dev);
1935 ov7648_probe(gspca_dev);
1937 case SENSOR_PO2030N:
1938 po2030n_probe(gspca_dev);
1941 regGpio[1] = 0x70; /* no audio */
1942 reg_w(gspca_dev, 0x01, regGpio, 2);
1945 /* case BRIDGE_SN9C110: */
1946 /* case BRIDGE_SN9C325: */
1949 reg_w1(gspca_dev, 0x02, 0x62);
1953 if (sd->sensor == SENSOR_OM6802)
1954 sd->ctrls[SHARPNESS].def = 0x10;
1956 /* Note we do not disable the sensor clock here (power saving mode),
1957 as that also disables the button on the cam. */
1958 reg_w1(gspca_dev, 0xf1, 0x00);
1960 /* set the i2c address */
1961 sn9c1xx = sn_tb[sd->sensor];
1962 sd->i2c_addr = sn9c1xx[9];
1964 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1966 return gspca_dev->usb_err;
1969 static u32 setexposure(struct gspca_dev *gspca_dev,
1972 struct sd *sd = (struct sd *) gspca_dev;
1974 switch (sd->sensor) {
1975 case SENSOR_GC0307: {
1978 /* expo = 0..255 -> a = 19..43 */
1979 a = 19 + expo * 25 / 256;
1980 i2c_w1(gspca_dev, 0x68, a);
1982 b = a * a * 4; /* heuristic */
1983 i2c_w1(gspca_dev, 0x03, b >> 8);
1984 i2c_w1(gspca_dev, 0x04, b);
1987 case SENSOR_HV7131R: {
1989 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
1991 Expodoit[3] = expo >> 16;
1992 Expodoit[4] = expo >> 8;
1994 i2c_w8(gspca_dev, Expodoit);
1998 case SENSOR_MI0360B: {
1999 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
2000 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
2001 static const u8 doit[] = /* update sensor */
2002 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
2003 static const u8 sensorgo[] = /* sensor on */
2004 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
2008 else if (expo < 0x0001)
2010 expoMi[3] = expo >> 8;
2012 i2c_w8(gspca_dev, expoMi);
2013 i2c_w8(gspca_dev, doit);
2014 i2c_w8(gspca_dev, sensorgo);
2017 case SENSOR_MO4000: {
2019 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
2021 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
2022 static const u8 gainMo[] =
2023 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
2027 else if (expo < 0x0001)
2029 expoMof[3] = (expo & 0x03fc) >> 2;
2030 i2c_w8(gspca_dev, expoMof);
2031 expoMo10[3] = ((expo & 0x1c00) >> 10)
2032 | ((expo & 0x0003) << 4);
2033 i2c_w8(gspca_dev, expoMo10);
2034 i2c_w8(gspca_dev, gainMo);
2035 PDEBUG(D_FRAM, "set exposure %d",
2036 ((expoMo10[3] & 0x07) << 10)
2038 | ((expoMo10[3] & 0x30) >> 4));
2041 case SENSOR_MT9V111: {
2043 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
2047 else if (expo < 0x0040)
2049 expo_c1[3] = expo >> 8;
2051 i2c_w8(gspca_dev, expo_c1);
2054 case SENSOR_OM6802: {
2056 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
2057 /* preset AGC - works when AutoExpo = off */
2063 gainOm[3] = expo >> 2;
2064 i2c_w8(gspca_dev, gainOm);
2065 reg_w1(gspca_dev, 0x96, expo >> 5);
2066 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
2073 static void setbrightness(struct gspca_dev *gspca_dev)
2075 struct sd *sd = (struct sd *) gspca_dev;
2080 brightness = sd->ctrls[BRIGHTNESS].val;
2081 k2 = (brightness - 0x80) >> 2;
2082 switch (sd->sensor) {
2083 case SENSOR_ADCM1700:
2085 k2 = 0; /* only positive Y offset */
2087 case SENSOR_HV7131R:
2088 expo = brightness << 12;
2089 if (expo > 0x002dc6c0)
2091 else if (expo < 0x02a0)
2093 sd->exposure = setexposure(gspca_dev, expo);
2097 expo = brightness << 4;
2098 sd->exposure = setexposure(gspca_dev, expo);
2100 case SENSOR_MI0360B:
2101 expo = brightness << 2;
2102 sd->exposure = setexposure(gspca_dev, expo);
2105 case SENSOR_MT9V111:
2107 sd->exposure = setexposure(gspca_dev, expo);
2108 return; /* don't set the Y offset */
2110 expo = brightness << 2;
2111 sd->exposure = setexposure(gspca_dev, expo);
2112 k2 = brightness >> 3;
2116 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
2119 static void setcontrast(struct gspca_dev *gspca_dev)
2121 struct sd *sd = (struct sd *) gspca_dev;
2125 k2 = sd->ctrls[CONTRAST].val * 0x30 / (CONTRAST_MAX + 1)
2126 + 0x10; /* 10..40 */
2127 contrast[0] = (k2 + 1) / 2; /* red */
2129 contrast[2] = k2; /* green */
2131 contrast[4] = (k2 + 1) / 5; /* blue */
2133 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
2136 static void setcolors(struct gspca_dev *gspca_dev)
2138 struct sd *sd = (struct sd *) gspca_dev;
2141 u8 reg8a[12]; /* U & V gains */
2142 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
2143 -24, -38, 64, /* UR UG UB */
2144 62, -51, -9 /* VR VG VB */
2146 static const s16 uv_mi0360b[6] = {
2147 -20, -38, 64, /* UR UG UB */
2148 60, -51, -9 /* VR VG VB */
2151 colors = sd->ctrls[COLORS].val;
2152 if (sd->sensor == SENSOR_MI0360B)
2156 for (i = 0; i < 6; i++) {
2157 v = uv[i] * colors / COLORS_DEF;
2159 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
2161 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
2164 static void setredblue(struct gspca_dev *gspca_dev)
2166 struct sd *sd = (struct sd *) gspca_dev;
2168 reg_w1(gspca_dev, 0x05, sd->ctrls[RED].val);
2169 /* reg_w1(gspca_dev, 0x07, 32); */
2170 reg_w1(gspca_dev, 0x06, sd->ctrls[BLUE].val);
2173 static void setgamma(struct gspca_dev *gspca_dev)
2175 struct sd *sd = (struct sd *) gspca_dev;
2178 const u8 *gamma_base;
2179 static const u8 delta[17] = {
2180 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2181 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2184 switch (sd->sensor) {
2185 case SENSOR_ADCM1700:
2186 gamma_base = gamma_spec_0;
2188 case SENSOR_HV7131R:
2189 case SENSOR_MI0360B:
2190 case SENSOR_MT9V111:
2191 gamma_base = gamma_spec_1;
2194 gamma_base = gamma_spec_2;
2196 case SENSOR_SP80708:
2197 gamma_base = gamma_spec_3;
2200 gamma_base = gamma_def;
2204 val = sd->ctrls[GAMMA].val;
2205 for (i = 0; i < sizeof gamma; i++)
2206 gamma[i] = gamma_base[i]
2207 + delta[i] * (val - GAMMA_DEF) / 32;
2208 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2211 static void setautogain(struct gspca_dev *gspca_dev)
2213 struct sd *sd = (struct sd *) gspca_dev;
2215 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN))
2217 switch (sd->sensor) {
2219 case SENSOR_OV7648: {
2222 if (sd->sensor == SENSOR_OV7630)
2226 if (sd->ctrls[AUTOGAIN].val)
2228 i2c_w1(&sd->gspca_dev, 0x13, comb);
2232 if (sd->ctrls[AUTOGAIN].val)
2233 sd->ag_cnt = AG_CNT_START;
2238 /* hv7131r/ov7630/ov7648 only */
2239 static void setvflip(struct gspca_dev *gspca_dev)
2241 struct sd *sd = (struct sd *) gspca_dev;
2244 if (gspca_dev->ctrl_dis & (1 << VFLIP))
2246 switch (sd->sensor) {
2247 case SENSOR_HV7131R:
2248 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
2249 if (sd->ctrls[VFLIP].val)
2251 i2c_w1(gspca_dev, 0x01, comn); /* sctra */
2255 if (!sd->ctrls[VFLIP].val)
2257 i2c_w1(gspca_dev, 0x75, comn);
2260 /* case SENSOR_OV7648: */
2262 if (sd->ctrls[VFLIP].val)
2264 i2c_w1(gspca_dev, 0x75, comn);
2269 static void setsharpness(struct gspca_dev *gspca_dev)
2271 struct sd *sd = (struct sd *) gspca_dev;
2273 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
2276 static void setinfrared(struct gspca_dev *gspca_dev)
2278 struct sd *sd = (struct sd *) gspca_dev;
2280 if (gspca_dev->ctrl_dis & (1 << INFRARED))
2282 /*fixme: different sequence for StarCam Clip and StarCam 370i */
2284 i2c_w1(gspca_dev, 0x02, /* gpio */
2285 sd->ctrls[INFRARED].val ? 0x66 : 0x64);
2288 static void setfreq(struct gspca_dev *gspca_dev)
2290 struct sd *sd = (struct sd *) gspca_dev;
2292 if (gspca_dev->ctrl_dis & (1 << FREQ))
2294 if (sd->sensor == SENSOR_OV7660) {
2297 com8 = 0xdf; /* auto gain/wb/expo */
2298 switch (sd->ctrls[FREQ].val) {
2299 case 0: /* Banding filter disabled */
2300 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
2303 i2c_w1(gspca_dev, 0x13, com8);
2304 i2c_w1(gspca_dev, 0x3b, 0x0a);
2307 i2c_w1(gspca_dev, 0x13, com8);
2308 i2c_w1(gspca_dev, 0x3b, 0x02);
2312 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2314 /* Get reg2a / reg2d base values */
2315 switch (sd->sensor) {
2326 switch (sd->ctrls[FREQ].val) {
2327 case 0: /* Banding filter disabled */
2329 case 1: /* 50 hz (filter on and framerate adj) */
2334 case 2: /* 60 hz (filter on, no framerate adj) */
2339 i2c_w1(gspca_dev, 0x2a, reg2a);
2340 i2c_w1(gspca_dev, 0x2b, reg2b);
2341 i2c_w1(gspca_dev, 0x2d, reg2d);
2345 static void setjpegqual(struct gspca_dev *gspca_dev)
2347 struct sd *sd = (struct sd *) gspca_dev;
2350 if (sd->jpegqual < 50)
2351 sc = 5000 / sd->jpegqual;
2353 sc = 200 - sd->jpegqual * 2;
2355 #error "No room enough in usb_buf for quantization table"
2357 for (i = 0; i < 64; i++)
2358 gspca_dev->usb_buf[i] =
2359 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2360 usb_control_msg(gspca_dev->dev,
2361 usb_sndctrlpipe(gspca_dev->dev, 0),
2363 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2365 gspca_dev->usb_buf, 64,
2367 for (i = 0; i < 64; i++)
2368 gspca_dev->usb_buf[i] =
2369 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2370 usb_control_msg(gspca_dev->dev,
2371 usb_sndctrlpipe(gspca_dev->dev, 0),
2373 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2375 gspca_dev->usb_buf, 64,
2379 reg_w1(gspca_dev, 0x18, sd->reg18);
2382 /* -- start the camera -- */
2383 static int sd_start(struct gspca_dev *gspca_dev)
2385 struct sd *sd = (struct sd *) gspca_dev;
2389 const u8 (*init)[8];
2391 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2392 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
2393 static const u8 CA_adcm1700[] =
2394 { 0x14, 0xec, 0x0a, 0xf6 };
2395 static const u8 CA_po2030n[] =
2396 { 0x1e, 0xe2, 0x14, 0xec };
2397 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
2398 static const u8 CE_gc0307[] =
2399 { 0x32, 0xce, 0x2d, 0xd3 };
2400 static const u8 CE_ov76xx[] =
2401 { 0x32, 0xdd, 0x32, 0xdd };
2402 static const u8 CE_po2030n[] =
2403 { 0x14, 0xe7, 0x1e, 0xdd };
2405 /* create the JPEG header */
2406 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2407 0x21); /* JPEG 422 */
2408 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2410 /* initialize the bridge */
2411 sn9c1xx = sn_tb[sd->sensor];
2412 bridge_init(gspca_dev, sn9c1xx);
2414 /* initialize the sensor */
2415 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2417 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2418 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2419 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2420 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2421 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
2422 if (sd->sensor == SENSOR_ADCM1700) {
2423 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2424 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
2426 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2427 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
2429 reg_w1(gspca_dev, 0xc6, 0x00);
2430 reg_w1(gspca_dev, 0xc7, 0x00);
2431 if (sd->sensor == SENSOR_ADCM1700) {
2432 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2433 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
2435 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2436 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
2438 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
2439 switch (sd->sensor) {
2443 case SENSOR_MT9V111:
2444 case SENSOR_MI0360B:
2447 case SENSOR_ADCM1700:
2459 case SENSOR_PO2030N:
2466 reg_w1(gspca_dev, 0x17, reg17);
2468 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2469 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2470 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
2471 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
2473 setgamma(gspca_dev);
2475 /*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
2476 for (i = 0; i < 8; i++)
2477 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2478 switch (sd->sensor) {
2479 case SENSOR_ADCM1700:
2481 case SENSOR_SP80708:
2482 reg_w1(gspca_dev, 0x9a, 0x05);
2485 case SENSOR_MT9V111:
2486 case SENSOR_MI0360B:
2487 reg_w1(gspca_dev, 0x9a, 0x07);
2491 reg_w1(gspca_dev, 0x9a, 0x0a);
2493 case SENSOR_PO2030N:
2495 reg_w1(gspca_dev, 0x9a, 0x06);
2498 reg_w1(gspca_dev, 0x9a, 0x08);
2501 setsharpness(gspca_dev);
2503 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2504 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2505 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2506 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
2509 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
2511 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
2513 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2514 reg17 = 0x61; /* 0x:20: enable sensor clock */
2515 switch (sd->sensor) {
2516 case SENSOR_ADCM1700:
2517 init = adcm1700_sensor_param1;
2522 init = gc0307_sensor_param1;
2526 case SENSOR_MI0360B:
2527 init = mi0360b_sensor_param1;
2528 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2533 /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2534 reg1 = 0x06; /* clk 24Mz */
2536 reg17 = 0x22; /* 640 MCKSIZE */
2537 /* reg1 = 0x06; * 640 clk 24Mz (done) */
2540 case SENSOR_MT9V111:
2541 init = mt9v111_sensor_param1;
2543 reg1 = 0x04; /* 320 clk 48Mhz */
2545 /* reg1 = 0x06; * 640 clk 24Mz (done) */
2550 init = om6802_sensor_param1;
2551 reg17 = 0x64; /* 640 MCKSIZE */
2554 init = ov7630_sensor_param1;
2559 init = ov7648_sensor_param1;
2561 /* reg1 = 0x42; * 42 - 46? */
2564 init = ov7660_sensor_param1;
2565 if (sd->bridge == BRIDGE_SN9C120) {
2566 if (mode) { /* 320x240 - 160x120 */
2568 reg1 = 0x44; /* 48 Mhz, video trf eneble */
2572 reg1 = 0x06; /* 24 Mhz, video trf eneble
2573 * inverse power down */
2577 init = po1030_sensor_param1;
2581 case SENSOR_PO2030N:
2582 init = po2030n_sensor_param1;
2587 init = soi768_sensor_param1;
2591 case SENSOR_SP80708:
2592 init = sp80708_sensor_param1;
2594 /*?? reg1 = 0x04; * 320 clk 48Mhz */
2596 reg1 = 0x46; /* 640 clk 48Mz */
2602 /* more sensor initialization - param1 */
2604 i2c_w_seq(gspca_dev, init);
2608 reg_w(gspca_dev, 0xc0, C0, 6);
2609 switch (sd->sensor) {
2610 case SENSOR_ADCM1700:
2613 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
2615 case SENSOR_PO2030N:
2616 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2619 reg_w(gspca_dev, 0xca, CA, 4);
2622 switch (sd->sensor) {
2623 case SENSOR_ADCM1700:
2628 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
2631 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2633 case SENSOR_PO2030N:
2634 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2637 reg_w(gspca_dev, 0xce, CE, 4);
2638 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2643 /* here change size mode 0 -> VGA; 1 -> CIF */
2644 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2645 reg_w1(gspca_dev, 0x18, sd->reg18);
2646 setjpegqual(gspca_dev);
2648 reg_w1(gspca_dev, 0x17, reg17);
2649 reg_w1(gspca_dev, 0x01, reg1);
2651 setvflip(gspca_dev);
2652 setbrightness(gspca_dev);
2653 setcontrast(gspca_dev);
2654 setcolors(gspca_dev);
2655 setautogain(gspca_dev);
2657 return gspca_dev->usb_err;
2660 static void sd_stopN(struct gspca_dev *gspca_dev)
2662 struct sd *sd = (struct sd *) gspca_dev;
2663 static const u8 stophv7131[] =
2664 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
2665 static const u8 stopmi0360[] =
2666 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
2667 static const u8 stopov7648[] =
2668 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
2669 static const u8 stopsoi768[] =
2670 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
2675 switch (sd->sensor) {
2679 case SENSOR_HV7131R:
2680 i2c_w8(gspca_dev, stophv7131);
2684 case SENSOR_MI0360B:
2685 i2c_w8(gspca_dev, stopmi0360);
2689 i2c_w8(gspca_dev, stopov7648);
2691 case SENSOR_MT9V111:
2697 i2c_w8(gspca_dev, stopsoi768);
2701 sn9c1xx = sn_tb[sd->sensor];
2702 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2703 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2704 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2705 reg_w1(gspca_dev, 0x01, data);
2706 /* Don't disable sensor clock as that disables the button on the cam */
2707 /* reg_w1(gspca_dev, 0xf1, 0x01); */
2710 static void do_autogain(struct gspca_dev *gspca_dev)
2712 struct sd *sd = (struct sd *) gspca_dev;
2718 /* Thanks S., without your advice, autobright should not work :) */
2721 if (--sd->ag_cnt >= 0)
2723 sd->ag_cnt = AG_CNT_START;
2725 delta = atomic_read(&sd->avg_lum);
2726 PDEBUG(D_FRAM, "mean lum %d", delta);
2727 if (delta < luma_mean - luma_delta ||
2728 delta > luma_mean + luma_delta) {
2729 switch (sd->sensor) {
2731 expotimes = sd->exposure;
2732 expotimes += (luma_mean - delta) >> 6;
2735 sd->exposure = setexposure(gspca_dev,
2736 (unsigned int) expotimes);
2738 case SENSOR_HV7131R:
2739 expotimes = sd->exposure >> 8;
2740 expotimes += (luma_mean - delta) >> 4;
2743 sd->exposure = setexposure(gspca_dev,
2744 (unsigned int) (expotimes << 8));
2747 expotimes = sd->exposure;
2748 expotimes += (luma_mean - delta) >> 2;
2751 sd->exposure = setexposure(gspca_dev,
2752 (unsigned int) expotimes);
2753 setredblue(gspca_dev);
2756 /* case SENSOR_MO4000: */
2757 /* case SENSOR_MI0360: */
2758 /* case SENSOR_MI0360B: */
2759 /* case SENSOR_MT9V111: */
2760 expotimes = sd->exposure;
2761 expotimes += (luma_mean - delta) >> 6;
2764 sd->exposure = setexposure(gspca_dev,
2765 (unsigned int) expotimes);
2766 setredblue(gspca_dev);
2772 /* scan the URB packets */
2773 /* This function is run at interrupt level. */
2774 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2775 u8 *data, /* isoc packet */
2776 int len) /* iso packet length */
2778 struct sd *sd = (struct sd *) gspca_dev;
2781 /* the image ends on a 64 bytes block starting with
2782 * ff d9 ff ff 00 c4 c4 96
2783 * and followed by various information including luminosity */
2784 /* this block may be splitted between two packets */
2785 /* a new image always starts in a new packet */
2786 switch (gspca_dev->last_packet_type) {
2787 case DISCARD_PACKET: /* restart image building */
2789 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2790 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2792 case LAST_PACKET: /* put the JPEG 422 header */
2793 gspca_frame_add(gspca_dev, FIRST_PACKET,
2794 sd->jpeg_hdr, JPEG_HDR_SZ);
2797 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2799 data = gspca_dev->image;
2802 sof = gspca_dev->image_len - 64;
2803 if (data[sof] != 0xff
2804 || data[sof + 1] != 0xd9)
2807 /* end of image found - remove the trailing data */
2808 gspca_dev->image_len = sof + 2;
2809 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2816 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2818 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2820 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2822 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2824 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2826 atomic_set(&sd->avg_lum, avg_lum);
2829 static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2830 struct v4l2_jpegcompression *jcomp)
2832 struct sd *sd = (struct sd *) gspca_dev;
2834 if (jcomp->quality < QUALITY_MIN)
2835 sd->quality = QUALITY_MIN;
2836 else if (jcomp->quality > QUALITY_MAX)
2837 sd->quality = QUALITY_MAX;
2839 sd->quality = jcomp->quality;
2840 if (gspca_dev->streaming)
2841 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2845 static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2846 struct v4l2_jpegcompression *jcomp)
2848 struct sd *sd = (struct sd *) gspca_dev;
2850 memset(jcomp, 0, sizeof *jcomp);
2851 jcomp->quality = sd->quality;
2852 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2853 | V4L2_JPEG_MARKER_DQT;
2857 static int sd_querymenu(struct gspca_dev *gspca_dev,
2858 struct v4l2_querymenu *menu)
2861 case V4L2_CID_POWER_LINE_FREQUENCY:
2862 switch (menu->index) {
2863 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2864 strcpy((char *) menu->name, "NoFliker");
2866 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2867 strcpy((char *) menu->name, "50 Hz");
2869 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2870 strcpy((char *) menu->name, "60 Hz");
2878 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2879 static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2880 u8 *data, /* interrupt packet data */
2881 int len) /* interrupt packet length */
2885 if (len == 1 && data[0] == 1) {
2886 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2887 input_sync(gspca_dev->input_dev);
2888 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2889 input_sync(gspca_dev->input_dev);
2897 /* sub-driver description */
2898 static const struct sd_desc sd_desc = {
2899 .name = MODULE_NAME,
2902 .config = sd_config,
2906 .pkt_scan = sd_pkt_scan,
2907 .dq_callback = do_autogain,
2908 .get_jcomp = sd_get_jcomp,
2909 .set_jcomp = sd_set_jcomp,
2910 .querymenu = sd_querymenu,
2911 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2912 .int_pkt_scan = sd_int_pkt_scan,
2916 /* -- module initialisation -- */
2917 #define BS(bridge, sensor) \
2918 .driver_info = (BRIDGE_ ## bridge << 16) \
2920 static const __devinitdata struct usb_device_id device_table[] = {
2921 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2922 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2923 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
2925 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
2926 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
2927 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2928 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2929 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2930 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2931 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2932 /* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2933 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2934 /* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2935 /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2936 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2937 /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2938 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
2940 /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2941 /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2942 /* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
2943 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
2944 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2945 /* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2946 /* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
2947 /* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
2948 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
2949 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2950 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2951 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
2953 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
2954 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
2955 /* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2956 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2957 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2958 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2959 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
2960 /* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
2961 /* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
2962 /* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
2963 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
2965 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
2966 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
2967 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
2968 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
2969 /* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
2970 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
2971 /* or MT9V111 / MI0360B */
2972 /* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
2973 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
2974 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
2975 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2976 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
2978 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
2979 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
2980 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
2981 /* or GC0305 / GC0307 */
2982 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2983 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
2984 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
2987 MODULE_DEVICE_TABLE(usb, device_table);
2989 /* -- device connect -- */
2990 static int sd_probe(struct usb_interface *intf,
2991 const struct usb_device_id *id)
2993 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2997 static struct usb_driver sd_driver = {
2998 .name = MODULE_NAME,
2999 .id_table = device_table,
3001 .disconnect = gspca_disconnect,
3003 .suspend = gspca_suspend,
3004 .resume = gspca_resume,
3008 /* -- module insert / remove -- */
3009 static int __init sd_mod_init(void)
3011 return usb_register(&sd_driver);
3013 static void __exit sd_mod_exit(void)
3015 usb_deregister(&sd_driver);
3018 module_init(sd_mod_init);
3019 module_exit(sd_mod_exit);