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>
25 #include <linux/slab.h>
29 #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
31 MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
32 MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
33 MODULE_LICENSE("GPL");
35 /* specific webcam descriptor */
37 struct gspca_dev gspca_dev; /* !! must be the first item */
49 u8 vflip; /* ov7630/ov7648 only */
51 u8 infrared; /* mt9v111 only */
52 u8 freq; /* ov76xx only */
53 u8 quality; /* image quality */
54 #define QUALITY_MIN 60
55 #define QUALITY_MAX 95
56 #define QUALITY_DEF 80
57 u8 jpegqual; /* webcam quality */
62 #define AG_CNT_START 13
65 #define BRIDGE_SN9C102P 0
66 #define BRIDGE_SN9C105 1
67 #define BRIDGE_SN9C110 2
68 #define BRIDGE_SN9C120 3
69 u8 sensor; /* Type of image sensor chip */
87 u8 jpeg_hdr[JPEG_HDR_SZ];
90 /* V4L2 controls supported by the driver */
91 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
92 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
93 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
94 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
95 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
96 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
97 static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
98 static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
99 static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
100 static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
101 static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
102 static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
103 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
104 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
105 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
106 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
107 static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
108 static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
109 static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
110 static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
111 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
112 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
114 static const struct ctrl sd_ctrls[] = {
115 #define BRIGHTNESS_IDX 0
118 .id = V4L2_CID_BRIGHTNESS,
119 .type = V4L2_CTRL_TYPE_INTEGER,
120 .name = "Brightness",
122 #define BRIGHTNESS_MAX 0xffff
123 .maximum = BRIGHTNESS_MAX,
125 #define BRIGHTNESS_DEF 0x8000
126 .default_value = BRIGHTNESS_DEF,
128 .set = sd_setbrightness,
129 .get = sd_getbrightness,
131 #define CONTRAST_IDX 1
134 .id = V4L2_CID_CONTRAST,
135 .type = V4L2_CTRL_TYPE_INTEGER,
138 #define CONTRAST_MAX 127
139 .maximum = CONTRAST_MAX,
141 #define CONTRAST_DEF 63
142 .default_value = CONTRAST_DEF,
144 .set = sd_setcontrast,
145 .get = sd_getcontrast,
150 .id = V4L2_CID_SATURATION,
151 .type = V4L2_CTRL_TYPE_INTEGER,
152 .name = "Saturation",
157 .default_value = COLOR_DEF,
162 #define BLUE_BALANCE_IDX 3
165 .id = V4L2_CID_BLUE_BALANCE,
166 .type = V4L2_CTRL_TYPE_INTEGER,
167 .name = "Blue Balance",
171 #define BLUE_BALANCE_DEF 32
172 .default_value = BLUE_BALANCE_DEF,
174 .set = sd_setblue_balance,
175 .get = sd_getblue_balance,
177 #define RED_BALANCE_IDX 4
180 .id = V4L2_CID_RED_BALANCE,
181 .type = V4L2_CTRL_TYPE_INTEGER,
182 .name = "Red Balance",
186 #define RED_BALANCE_DEF 32
187 .default_value = RED_BALANCE_DEF,
189 .set = sd_setred_balance,
190 .get = sd_getred_balance,
195 .id = V4L2_CID_GAMMA,
196 .type = V4L2_CTRL_TYPE_INTEGER,
202 .default_value = GAMMA_DEF,
207 #define AUTOGAIN_IDX 6
210 .id = V4L2_CID_AUTOGAIN,
211 .type = V4L2_CTRL_TYPE_BOOLEAN,
216 #define AUTOGAIN_DEF 1
217 .default_value = AUTOGAIN_DEF,
219 .set = sd_setautogain,
220 .get = sd_getautogain,
222 /* ov7630/ov7648 only */
226 .id = V4L2_CID_VFLIP,
227 .type = V4L2_CTRL_TYPE_BOOLEAN,
233 .default_value = VFLIP_DEF,
238 #define SHARPNESS_IDX 8
241 .id = V4L2_CID_SHARPNESS,
242 .type = V4L2_CTRL_TYPE_INTEGER,
247 #define SHARPNESS_DEF 90
248 .default_value = SHARPNESS_DEF,
250 .set = sd_setsharpness,
251 .get = sd_getsharpness,
254 #define INFRARED_IDX 9
257 .id = V4L2_CID_INFRARED,
258 .type = V4L2_CTRL_TYPE_BOOLEAN,
263 #define INFRARED_DEF 0
264 .default_value = INFRARED_DEF,
266 .set = sd_setinfrared,
267 .get = sd_getinfrared,
269 /* ov7630/ov7648/ov7660 only */
273 .id = V4L2_CID_POWER_LINE_FREQUENCY,
274 .type = V4L2_CTRL_TYPE_MENU,
275 .name = "Light frequency filter",
277 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
280 .default_value = FREQ_DEF,
287 /* table of the disabled controls */
288 static const __u32 ctrl_dis[] = {
289 [SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) |
290 (1 << INFRARED_IDX) |
294 [SENSOR_GC0307] = (1 << INFRARED_IDX) |
298 [SENSOR_HV7131R] = (1 << INFRARED_IDX) |
301 [SENSOR_MI0360] = (1 << INFRARED_IDX) |
305 [SENSOR_MO4000] = (1 << INFRARED_IDX) |
309 [SENSOR_MT9V111] = (1 << VFLIP_IDX) |
312 [SENSOR_OM6802] = (1 << INFRARED_IDX) |
316 [SENSOR_OV7630] = (1 << INFRARED_IDX),
318 [SENSOR_OV7648] = (1 << INFRARED_IDX),
320 [SENSOR_OV7660] = (1 << AUTOGAIN_IDX) |
321 (1 << INFRARED_IDX) |
324 [SENSOR_PO1030] = (1 << AUTOGAIN_IDX) |
325 (1 << INFRARED_IDX) |
329 [SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) |
330 (1 << INFRARED_IDX) |
334 [SENSOR_SP80708] = (1 << AUTOGAIN_IDX) |
335 (1 << INFRARED_IDX) |
340 static const struct v4l2_pix_format cif_mode[] = {
341 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
343 .sizeimage = 352 * 288 * 4 / 8 + 590,
344 .colorspace = V4L2_COLORSPACE_JPEG,
347 static const struct v4l2_pix_format vga_mode[] = {
348 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
350 .sizeimage = 160 * 120 * 4 / 8 + 590,
351 .colorspace = V4L2_COLORSPACE_JPEG,
353 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
355 .sizeimage = 320 * 240 * 3 / 8 + 590,
356 .colorspace = V4L2_COLORSPACE_JPEG,
358 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
360 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
361 .sizeimage = 640 * 480 * 3 / 4 + 590,
362 .colorspace = V4L2_COLORSPACE_JPEG,
366 static const u8 sn_adcm1700[0x1c] = {
367 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
368 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
369 /* reg8 reg9 rega regb regc regd rege regf */
370 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
371 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
372 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
373 /* reg18 reg19 reg1a reg1b */
374 0x06, 0x00, 0x00, 0x00
377 static const u8 sn_gc0307[0x1c] = {
378 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
379 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
380 /* reg8 reg9 rega regb regc regd rege regf */
381 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
382 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
383 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
384 /* reg18 reg19 reg1a reg1b */
385 0x06, 0x00, 0x00, 0x00
388 static const u8 sn_hv7131[0x1c] = {
389 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
390 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
391 /* reg8 reg9 rega regb regc regd rege regf */
392 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
393 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
394 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
395 /* reg18 reg19 reg1a reg1b */
396 0x0a, 0x00, 0x00, 0x00
399 static const u8 sn_mi0360[0x1c] = {
400 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
401 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
402 /* reg8 reg9 rega regb regc regd rege regf */
403 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
404 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
405 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
406 /* reg18 reg19 reg1a reg1b */
407 0x06, 0x00, 0x00, 0x00
410 static const u8 sn_mo4000[0x1c] = {
411 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
412 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
413 /* reg8 reg9 rega regb regc regd rege regf */
414 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
415 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
416 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
417 /* reg18 reg19 reg1a reg1b */
418 0x08, 0x00, 0x00, 0x00
421 static const u8 sn_mt9v111[0x1c] = {
422 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
423 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
424 /* reg8 reg9 rega regb regc regd rege regf */
425 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
426 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
427 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
428 /* reg18 reg19 reg1a reg1b */
429 0x06, 0x00, 0x00, 0x00
432 static const u8 sn_om6802[0x1c] = {
433 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
434 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
435 /* reg8 reg9 rega regb regc regd rege regf */
436 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
437 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
438 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
439 /* reg18 reg19 reg1a reg1b */
440 0x05, 0x00, 0x00, 0x00
443 static const u8 sn_ov7630[0x1c] = {
444 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
445 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
446 /* reg8 reg9 rega regb regc regd rege regf */
447 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
448 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
449 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
450 /* reg18 reg19 reg1a reg1b */
451 0x0b, 0x00, 0x00, 0x00
454 static const u8 sn_ov7648[0x1c] = {
455 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
456 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
457 /* reg8 reg9 rega regb regc regd rege regf */
458 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
460 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
461 /* reg18 reg19 reg1a reg1b */
462 0x0b, 0x00, 0x00, 0x00
465 static const u8 sn_ov7660[0x1c] = {
466 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
467 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
468 /* reg8 reg9 rega regb regc regd rege regf */
469 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
470 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
471 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
472 /* reg18 reg19 reg1a reg1b */
473 0x07, 0x00, 0x00, 0x00
476 static const u8 sn_po1030[0x1c] = {
477 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
478 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
479 /* reg8 reg9 rega regb regc regd rege regf */
480 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
481 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
482 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
483 /* reg18 reg19 reg1a reg1b */
484 0x07, 0x00, 0x00, 0x00
487 static const u8 sn_po2030n[0x1c] = {
488 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
489 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
490 /* reg8 reg9 rega regb regc regd rege regf */
491 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
492 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
493 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
494 /* reg18 reg19 reg1a reg1b */
495 0x07, 0x00, 0x00, 0x00
498 static const u8 sn_sp80708[0x1c] = {
499 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
500 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
501 /* reg8 reg9 rega regb regc regd rege regf */
502 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
503 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
504 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
505 /* reg18 reg19 reg1a reg1b */
506 0x07, 0x00, 0x00, 0x00
509 /* sequence specific to the sensors - !! index = SENSOR_xxx */
510 static const u8 *sn_tb[] = {
511 [SENSOR_ADCM1700] = sn_adcm1700,
512 [SENSOR_GC0307] = sn_gc0307,
513 [SENSOR_HV7131R] = sn_hv7131,
514 [SENSOR_MI0360] = sn_mi0360,
515 [SENSOR_MO4000] = sn_mo4000,
516 [SENSOR_MT9V111] = sn_mt9v111,
517 [SENSOR_OM6802] = sn_om6802,
518 [SENSOR_OV7630] = sn_ov7630,
519 [SENSOR_OV7648] = sn_ov7648,
520 [SENSOR_OV7660] = sn_ov7660,
521 [SENSOR_PO1030] = sn_po1030,
522 [SENSOR_PO2030N] = sn_po2030n,
523 [SENSOR_SP80708] = sn_sp80708
526 /* default gamma table */
527 static const u8 gamma_def[17] = {
528 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
529 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
531 /* gamma for sensor ADCM1700 */
532 static const u8 gamma_spec_0[17] = {
533 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
534 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
536 /* gamma for sensors HV7131R and MT9V111 */
537 static const u8 gamma_spec_1[17] = {
538 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
539 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
541 /* gamma for sensor GC0307 */
542 static const u8 gamma_spec_2[17] = {
543 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
544 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
546 /* gamma for sensor SP80708 */
547 static const u8 gamma_spec_3[17] = {
548 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
549 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
552 /* color matrix and offsets */
553 static const u8 reg84[] = {
554 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
555 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
556 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
557 0x00, 0x00, 0x00 /* YUV offsets */
559 static const u8 adcm1700_sensor_init[][8] = {
560 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
561 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
562 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
563 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
564 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
565 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
566 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
567 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
568 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
569 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
570 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
571 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
572 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
573 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
574 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
575 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
576 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
579 static const u8 adcm1700_sensor_param1[][8] = {
580 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
581 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
583 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
584 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
585 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
586 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
587 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
589 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
590 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
591 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
592 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
595 static const u8 gc0307_sensor_init[][8] = {
596 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
597 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
598 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
599 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
600 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
601 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
602 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
603 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
604 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
605 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
606 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
607 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
608 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
609 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
610 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
611 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
612 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
613 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
614 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
615 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
616 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
617 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
618 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
619 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
620 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
621 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
622 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
623 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
625 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
626 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
627 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
632 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
633 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
636 static const u8 gc0307_sensor_param1[][8] = {
637 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
638 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
639 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
640 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
642 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
647 static const u8 hv7131r_sensor_init[][8] = {
648 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
649 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
650 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
651 /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
652 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
653 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
654 /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
656 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
657 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
658 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
659 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
660 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
661 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
662 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
663 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
665 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
666 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
667 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
668 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
669 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
671 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
672 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
673 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
674 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
675 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
676 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
677 /* set sensor clock */
680 static const u8 mi0360_sensor_init[][8] = {
681 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
682 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
683 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
684 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
685 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
686 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
687 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
688 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
689 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
690 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
691 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
692 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
693 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
694 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
695 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
696 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
697 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
698 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
699 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
700 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
701 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
702 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
703 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
704 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
705 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
706 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
707 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
708 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
709 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
710 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
711 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
712 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
713 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
715 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
716 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
717 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
718 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
719 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
721 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
722 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
723 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
724 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
726 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
727 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
728 /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
729 /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
730 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
731 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
734 static const u8 mo4000_sensor_init[][8] = {
735 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
736 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
737 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
738 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
739 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
740 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
741 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
742 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
743 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
745 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
746 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
747 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
748 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
749 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
750 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
751 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
752 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
753 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
754 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
757 static const u8 mt9v111_sensor_init[][8] = {
758 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
759 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
760 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
761 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
762 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
763 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
764 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
765 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
766 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
767 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
768 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
769 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
770 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
771 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
772 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
773 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
774 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
775 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
776 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
777 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
778 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
779 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
780 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
781 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
782 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
783 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
784 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
785 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
788 static const u8 mt9v111_sensor_param1[][8] = {
789 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
792 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
793 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
795 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
796 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
797 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
798 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
801 static const u8 om6802_init0[2][8] = {
803 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
804 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
806 static const u8 om6802_sensor_init[][8] = {
807 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
809 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
811 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
812 /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
813 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
814 /* auto-exposure speed (0) / white balance mode (auto RGB) */
815 /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
817 /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
818 * max AGC value in AE */
819 /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
821 /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
822 * preset brightness */
823 /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
825 /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
827 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
828 /* luminance mode (0x4f -> AutoExpo on) */
829 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
831 /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
833 /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
834 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
837 static const u8 om6802_sensor_param1[][8] = {
838 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
839 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
840 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
841 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
844 static const u8 ov7630_sensor_init[][8] = {
845 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
847 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
848 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
850 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
851 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
852 /* win: i2c_r from 00 to 80 */
853 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
854 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
855 /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
856 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
857 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
858 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
859 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
860 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
861 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
862 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
863 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
864 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
865 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
866 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
867 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
868 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
869 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
870 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
871 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
872 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
873 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
874 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
875 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
876 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
877 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
878 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
879 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
880 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
882 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
883 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
884 /*fixme: + 0x12, 0x04*/
885 /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
887 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
888 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
889 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
891 /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
892 /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
894 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
895 /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
899 static const u8 ov7648_sensor_init[][8] = {
900 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
901 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
902 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
903 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
904 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
905 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
906 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
907 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
908 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
909 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
910 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
911 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
912 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
913 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
914 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
915 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
916 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
917 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
918 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
919 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
920 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
921 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
923 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
924 /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
925 /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
926 /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
929 static const u8 ov7648_sensor_param1[][8] = {
930 /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
931 /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
933 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
934 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
935 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
936 /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
937 /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
939 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
940 /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
941 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
942 /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
943 /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
944 /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
949 static const u8 ov7660_sensor_init[][8] = {
950 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
951 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
952 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
953 /* Outformat = rawRGB */
954 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
955 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
956 /* GAIN BLUE RED VREF */
957 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
958 /* COM 1 BAVE GEAVE AECHH */
959 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
960 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
961 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
962 /* AECH CLKRC COM7 COM8 */
963 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
964 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
965 /* HSTART HSTOP VSTRT VSTOP */
966 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
967 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
968 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
969 /* BOS GBOS GROS ROS (BGGR offset) */
970 /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
971 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
972 /* AEW AEB VPT BBIAS */
973 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
974 /* GbBIAS RSVD EXHCH EXHCL */
975 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
976 /* RBIAS ADVFL ASDVFH YAVE */
977 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
978 /* HSYST HSYEN HREF */
979 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
980 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
981 /* ADC ACOM OFON TSLB */
982 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
983 /* COM11 COM12 COM13 COM14 */
984 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
985 /* EDGE COM15 COM16 COM17 */
986 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
987 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
988 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
989 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
990 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
991 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
992 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
993 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
994 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
995 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
996 /* LCC1 LCC2 LCC3 LCC4 */
997 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
998 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
999 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
1000 /* band gap reference [0:3] DBLV */
1001 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1002 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1003 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1004 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1005 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1006 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1007 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1008 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1009 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
1010 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
1011 /* not in all ms-win traces*/
1012 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
1015 static const u8 ov7660_sensor_param1[][8] = {
1016 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
1017 /* bits[3..0]reserved */
1018 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1019 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1020 /* VREF vertical frame ctrl */
1021 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1022 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1023 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1024 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1025 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1026 /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
1027 /****** (some exchanges in the win trace) ******/
1029 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
1030 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1031 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1032 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1033 /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
1034 /****** (some exchanges in the win trace) ******/
1035 /******!! startsensor KO if changed !!****/
1037 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1038 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1039 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1040 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
1044 static const u8 po1030_sensor_init[][8] = {
1045 /* the sensor registers are described in m5602/m5602_po1030.h */
1046 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1047 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1048 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1049 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1050 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1051 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1052 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1053 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1054 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1055 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1056 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1057 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1058 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1059 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1060 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1061 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1062 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1063 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1064 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1065 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1066 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1067 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1068 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1069 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1070 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1071 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1072 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1073 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1075 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1076 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1077 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1078 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1079 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1082 static const u8 po1030_sensor_param1[][8] = {
1083 /* from ms-win traces - these values change with auto gain/expo/wb.. */
1084 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1085 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1087 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1088 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1089 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1091 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1092 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1093 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1094 /* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1098 static const u8 po2030n_sensor_init[][8] = {
1099 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1100 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1101 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1102 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1103 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1104 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1105 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1106 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1107 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1108 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1109 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1110 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1111 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1112 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1113 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1114 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1115 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1116 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1117 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1118 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1119 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1120 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1121 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1122 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1123 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1124 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1125 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1126 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1127 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1128 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1129 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1130 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1131 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1132 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1133 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1134 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1135 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1136 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1137 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1138 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1139 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1140 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1141 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1142 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1143 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1144 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1145 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1146 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1147 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1148 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1151 static const u8 po2030n_sensor_param1[][8] = {
1152 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1153 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1154 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1155 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1156 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1158 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1159 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1160 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1161 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1162 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1163 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1164 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1166 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1167 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1168 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1169 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1170 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1174 static const u8 sp80708_sensor_init[][8] = {
1175 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1176 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1177 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1178 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1179 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1180 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1181 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1182 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1183 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1184 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1185 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1186 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1187 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1188 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1189 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1190 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1191 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1192 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1193 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1194 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1195 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1196 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1198 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1199 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1200 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1201 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1202 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1203 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1204 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1205 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1206 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1207 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1208 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1209 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1210 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1211 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1212 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1213 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1214 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1215 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1216 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1217 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1218 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1219 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1220 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1221 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1222 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1223 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1224 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1225 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1226 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1227 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1228 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1229 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1230 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1231 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1232 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1233 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1234 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1235 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1236 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1237 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1238 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1239 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1240 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1241 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1242 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1243 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1244 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1245 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
1248 static const u8 sp80708_sensor_param1[][8] = {
1249 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1250 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1251 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1252 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1253 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1254 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1255 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1259 static const u8 (*sensor_init[])[8] = {
1260 [SENSOR_ADCM1700] = adcm1700_sensor_init,
1261 [SENSOR_GC0307] = gc0307_sensor_init,
1262 [SENSOR_HV7131R] = hv7131r_sensor_init,
1263 [SENSOR_MI0360] = mi0360_sensor_init,
1264 [SENSOR_MO4000] = mo4000_sensor_init,
1265 [SENSOR_MT9V111] = mt9v111_sensor_init,
1266 [SENSOR_OM6802] = om6802_sensor_init,
1267 [SENSOR_OV7630] = ov7630_sensor_init,
1268 [SENSOR_OV7648] = ov7648_sensor_init,
1269 [SENSOR_OV7660] = ov7660_sensor_init,
1270 [SENSOR_PO1030] = po1030_sensor_init,
1271 [SENSOR_PO2030N] = po2030n_sensor_init,
1272 [SENSOR_SP80708] = sp80708_sensor_init,
1275 /* read <len> bytes to gspca_dev->usb_buf */
1276 static void reg_r(struct gspca_dev *gspca_dev,
1280 if (len > USB_BUF_SZ) {
1281 err("reg_r: buffer overflow");
1285 usb_control_msg(gspca_dev->dev,
1286 usb_rcvctrlpipe(gspca_dev->dev, 0),
1288 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1290 gspca_dev->usb_buf, len,
1292 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
1295 static void reg_w1(struct gspca_dev *gspca_dev,
1299 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
1300 gspca_dev->usb_buf[0] = data;
1301 usb_control_msg(gspca_dev->dev,
1302 usb_sndctrlpipe(gspca_dev->dev, 0),
1304 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1307 gspca_dev->usb_buf, 1,
1310 static void reg_w(struct gspca_dev *gspca_dev,
1315 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
1316 value, buffer[0], buffer[1]);
1318 if (len > USB_BUF_SZ) {
1319 err("reg_w: buffer overflow");
1323 memcpy(gspca_dev->usb_buf, buffer, len);
1324 usb_control_msg(gspca_dev->dev,
1325 usb_sndctrlpipe(gspca_dev->dev, 0),
1327 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1329 gspca_dev->usb_buf, len,
1333 /* I2C write 1 byte */
1334 static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1336 struct sd *sd = (struct sd *) gspca_dev;
1338 PDEBUG(D_USBO, "i2c_w2 [%02x] = %02x", reg, val);
1339 switch (sd->sensor) {
1340 case SENSOR_ADCM1700:
1342 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
1343 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1345 default: /* i2c command = a1 (400 kHz) */
1346 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1349 gspca_dev->usb_buf[1] = sd->i2c_addr;
1350 gspca_dev->usb_buf[2] = reg;
1351 gspca_dev->usb_buf[3] = val;
1352 gspca_dev->usb_buf[4] = 0;
1353 gspca_dev->usb_buf[5] = 0;
1354 gspca_dev->usb_buf[6] = 0;
1355 gspca_dev->usb_buf[7] = 0x10;
1356 usb_control_msg(gspca_dev->dev,
1357 usb_sndctrlpipe(gspca_dev->dev, 0),
1359 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1360 0x08, /* value = i2c */
1362 gspca_dev->usb_buf, 8,
1366 /* I2C write 8 bytes */
1367 static void i2c_w8(struct gspca_dev *gspca_dev,
1370 memcpy(gspca_dev->usb_buf, buffer, 8);
1371 usb_control_msg(gspca_dev->dev,
1372 usb_sndctrlpipe(gspca_dev->dev, 0),
1374 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1375 0x08, 0, /* value, index */
1376 gspca_dev->usb_buf, 8,
1381 /* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1382 static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
1384 struct sd *sd = (struct sd *) gspca_dev;
1387 switch (sd->sensor) {
1388 case SENSOR_ADCM1700:
1390 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
1391 mode[0] = 0x80 | 0x10;
1393 default: /* i2c command = 91 (400 kHz) */
1394 mode[0] = 0x81 | 0x10;
1397 mode[1] = sd->i2c_addr;
1404 i2c_w8(gspca_dev, mode);
1406 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
1408 i2c_w8(gspca_dev, mode);
1410 reg_r(gspca_dev, 0x0a, 5);
1413 static void i2c_w_seq(struct gspca_dev *gspca_dev,
1414 const u8 (*data)[8])
1416 while ((*data)[0] != 0) {
1417 if ((*data)[0] != 0xdd)
1418 i2c_w8(gspca_dev, *data);
1425 static void hv7131r_probe(struct gspca_dev *gspca_dev)
1427 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
1429 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
1431 i2c_r(gspca_dev, 0, 5); /* read sensor id */
1432 if (gspca_dev->usb_buf[0] == 0x02
1433 && gspca_dev->usb_buf[1] == 0x09
1434 && gspca_dev->usb_buf[2] == 0x01
1435 && gspca_dev->usb_buf[3] == 0x00
1436 && gspca_dev->usb_buf[4] == 0x00) {
1437 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1440 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
1441 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1442 gspca_dev->usb_buf[2]);
1445 static void mi0360_probe(struct gspca_dev *gspca_dev)
1447 struct sd *sd = (struct sd *) gspca_dev;
1450 static const u8 probe_tb[][4][8] = {
1452 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1453 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1454 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1455 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1458 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1459 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1460 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1465 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1466 reg_w1(gspca_dev, 0x17, 0x62);
1467 reg_w1(gspca_dev, 0x01, 0x08);
1468 for (j = 0; j < 3; j++)
1469 i2c_w8(gspca_dev, probe_tb[i][j]);
1471 reg_r(gspca_dev, 0x0a, 5);
1472 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1473 if (probe_tb[i][3][0] != 0)
1474 i2c_w8(gspca_dev, probe_tb[i][3]);
1475 reg_w1(gspca_dev, 0x01, 0x29);
1476 reg_w1(gspca_dev, 0x17, 0x42);
1482 PDEBUG(D_PROBE, "Sensor mt9v111");
1483 sd->sensor = SENSOR_MT9V111;
1486 PDEBUG(D_PROBE, "Sensor mi0360");
1489 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1494 static void ov7648_probe(struct gspca_dev *gspca_dev)
1496 struct sd *sd = (struct sd *) gspca_dev;
1499 reg_w1(gspca_dev, 0x17, 0x62);
1500 reg_w1(gspca_dev, 0x01, 0x08);
1501 sd->i2c_addr = 0x21;
1502 i2c_r(gspca_dev, 0x0a, 2);
1503 if (gspca_dev->usb_buf[3] == 0x76) { /* ov76xx */
1504 PDEBUG(D_PROBE, "Sensor ov%02x%02x",
1505 gspca_dev->usb_buf[3], gspca_dev->usb_buf[4]);
1510 reg_w1(gspca_dev, 0x01, 0x29);
1511 reg_w1(gspca_dev, 0x17, 0x42);
1514 reg_w1(gspca_dev, 0x17, 0x62);
1515 reg_w1(gspca_dev, 0x01, 0x08);
1516 sd->i2c_addr = 0x6e;
1517 i2c_r(gspca_dev, 0x00, 2);
1518 if (gspca_dev->usb_buf[3] == 0x10 /* po1030 */
1519 && gspca_dev->usb_buf[4] == 0x30) {
1520 PDEBUG(D_PROBE, "Sensor po1030");
1521 sd->sensor = SENSOR_PO1030;
1525 PDEBUG(D_PROBE, "Unknown sensor %02x%02x",
1526 gspca_dev->usb_buf[3], gspca_dev->usb_buf[4]);
1529 /* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1530 static void po2030n_probe(struct gspca_dev *gspca_dev)
1532 struct sd *sd = (struct sd *) gspca_dev;
1535 reg_w1(gspca_dev, 0x17, 0x62);
1536 reg_w1(gspca_dev, 0x01, 0x08);
1537 reg_w1(gspca_dev, 0x02, 0x22);
1538 sd->i2c_addr = 0x21;
1539 i2c_r(gspca_dev, 0x00, 1);
1541 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1542 reg_w1(gspca_dev, 0x17, 0x42);
1544 if (gspca_dev->usb_buf[4] == 0x99) { /* gc0307 (?) */
1545 PDEBUG(D_PROBE, "Sensor gc0307");
1546 sd->sensor = SENSOR_GC0307;
1551 reg_w1(gspca_dev, 0x17, 0x62);
1552 reg_w1(gspca_dev, 0x01, 0x0a);
1553 sd->i2c_addr = 0x6e;
1554 i2c_r(gspca_dev, 0x00, 2);
1556 reg_w1(gspca_dev, 0x01, 0x29);
1557 reg_w1(gspca_dev, 0x17, 0x42);
1559 if (gspca_dev->usb_buf[3] == 0x20
1560 && gspca_dev->usb_buf[4] == 0x30)
1561 PDEBUG(D_PROBE, "Sensor po2030n");
1562 /* sd->sensor = SENSOR_PO2030N; */
1564 PDEBUG(D_PROBE, "Unknown sensor ID %02x%02x",
1565 gspca_dev->usb_buf[3],
1566 gspca_dev->usb_buf[4]);
1569 static void bridge_init(struct gspca_dev *gspca_dev,
1572 struct sd *sd = (struct sd *) gspca_dev;
1574 static const u8 reg9a_def[] =
1575 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1576 static const u8 reg9a_spec[] =
1577 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1578 static const u8 regd4[] = {0x60, 0x00, 0x00};
1580 /* sensor clock already enabled in sd_init */
1581 /* reg_w1(gspca_dev, 0xf1, 0x00); */
1582 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1584 /* configure gpio */
1585 reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2);
1586 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
1587 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
1588 switch (sd->sensor) {
1592 case SENSOR_PO2030N:
1593 case SENSOR_SP80708:
1600 reg_w(gspca_dev, 0x9a, reg9a, 6);
1602 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
1604 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
1606 switch (sd->sensor) {
1607 case SENSOR_ADCM1700:
1608 reg_w1(gspca_dev, 0x01, 0x43);
1609 reg_w1(gspca_dev, 0x17, 0x62);
1610 reg_w1(gspca_dev, 0x01, 0x42);
1611 reg_w1(gspca_dev, 0x01, 0x42);
1615 reg_w1(gspca_dev, 0x01, 0x61);
1616 reg_w1(gspca_dev, 0x17, 0x22);
1617 reg_w1(gspca_dev, 0x01, 0x60);
1618 reg_w1(gspca_dev, 0x01, 0x40);
1621 case SENSOR_MT9V111:
1622 reg_w1(gspca_dev, 0x01, 0x61);
1623 reg_w1(gspca_dev, 0x17, 0x61);
1624 reg_w1(gspca_dev, 0x01, 0x60);
1625 reg_w1(gspca_dev, 0x01, 0x40);
1629 reg_w1(gspca_dev, 0x02, 0x73);
1630 reg_w1(gspca_dev, 0x17, 0x60);
1631 reg_w1(gspca_dev, 0x01, 0x22);
1633 reg_w1(gspca_dev, 0x01, 0x62);
1634 reg_w1(gspca_dev, 0x17, 0x64);
1635 reg_w1(gspca_dev, 0x17, 0x64);
1636 reg_w1(gspca_dev, 0x01, 0x42);
1638 reg_w1(gspca_dev, 0x01, 0x42);
1639 i2c_w8(gspca_dev, om6802_init0[0]);
1640 i2c_w8(gspca_dev, om6802_init0[1]);
1642 reg_w1(gspca_dev, 0x02, 0x71);
1646 reg_w1(gspca_dev, 0x01, 0x61);
1647 reg_w1(gspca_dev, 0x17, 0xe2);
1648 reg_w1(gspca_dev, 0x01, 0x60);
1649 reg_w1(gspca_dev, 0x01, 0x40);
1652 reg_w1(gspca_dev, 0x01, 0x63);
1653 reg_w1(gspca_dev, 0x17, 0x20);
1654 reg_w1(gspca_dev, 0x01, 0x62);
1655 reg_w1(gspca_dev, 0x01, 0x42);
1658 reg_w1(gspca_dev, 0x01, 0x61);
1659 reg_w1(gspca_dev, 0x17, 0x20);
1660 reg_w1(gspca_dev, 0x01, 0x60);
1661 reg_w1(gspca_dev, 0x01, 0x40);
1663 case SENSOR_PO2030N:
1664 reg_w1(gspca_dev, 0x01, 0x63);
1665 reg_w1(gspca_dev, 0x17, 0x20);
1666 reg_w1(gspca_dev, 0x01, 0x62);
1667 reg_w1(gspca_dev, 0x01, 0x42);
1671 case SENSOR_SP80708:
1672 reg_w1(gspca_dev, 0x01, 0x63);
1673 reg_w1(gspca_dev, 0x17, 0x20);
1674 reg_w1(gspca_dev, 0x01, 0x62);
1675 reg_w1(gspca_dev, 0x01, 0x42);
1677 reg_w1(gspca_dev, 0x02, 0x62);
1680 /* case SENSOR_HV7131R: */
1681 /* case SENSOR_MI0360: */
1682 /* case SENSOR_MO4000: */
1683 reg_w1(gspca_dev, 0x01, 0x43);
1684 reg_w1(gspca_dev, 0x17, 0x61);
1685 reg_w1(gspca_dev, 0x01, 0x42);
1686 if (sd->sensor == SENSOR_HV7131R
1687 && sd->bridge == BRIDGE_SN9C102P)
1688 hv7131r_probe(gspca_dev);
1693 /* this function is called at probe time */
1694 static int sd_config(struct gspca_dev *gspca_dev,
1695 const struct usb_device_id *id)
1697 struct sd *sd = (struct sd *) gspca_dev;
1700 sd->bridge = id->driver_info >> 16;
1701 sd->sensor = id->driver_info;
1703 cam = &gspca_dev->cam;
1704 if (sd->sensor == SENSOR_ADCM1700) {
1705 cam->cam_mode = cif_mode;
1706 cam->nmodes = ARRAY_SIZE(cif_mode);
1708 cam->cam_mode = vga_mode;
1709 cam->nmodes = ARRAY_SIZE(vga_mode);
1711 cam->npkt = 24; /* 24 packets per ISOC message */
1713 sd->brightness = BRIGHTNESS_DEF;
1714 sd->contrast = CONTRAST_DEF;
1715 sd->colors = COLOR_DEF;
1716 sd->blue = BLUE_BALANCE_DEF;
1717 sd->red = RED_BALANCE_DEF;
1718 sd->gamma = GAMMA_DEF;
1719 sd->autogain = AUTOGAIN_DEF;
1721 sd->vflip = VFLIP_DEF;
1722 switch (sd->sensor) {
1724 sd->sharpness = 0x10;
1727 sd->sharpness = SHARPNESS_DEF;
1730 sd->infrared = INFRARED_DEF;
1731 sd->freq = FREQ_DEF;
1732 sd->quality = QUALITY_DEF;
1738 /* this function is called at probe and resume time */
1739 static int sd_init(struct gspca_dev *gspca_dev)
1741 struct sd *sd = (struct sd *) gspca_dev;
1743 u8 regGpio[] = { 0x29, 0x74 };
1746 /* setup a selector by bridge */
1747 reg_w1(gspca_dev, 0xf1, 0x01);
1748 reg_r(gspca_dev, 0x00, 1);
1749 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1750 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
1751 regF1 = gspca_dev->usb_buf[0];
1752 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
1753 switch (sd->bridge) {
1754 case BRIDGE_SN9C102P:
1757 reg_w1(gspca_dev, 0x02, regGpio[1]);
1759 case BRIDGE_SN9C105:
1762 if (sd->sensor == SENSOR_MI0360)
1763 mi0360_probe(gspca_dev);
1764 reg_w(gspca_dev, 0x01, regGpio, 2);
1766 case BRIDGE_SN9C120:
1769 switch (sd->sensor) {
1771 mi0360_probe(gspca_dev);
1774 ov7648_probe(gspca_dev);
1776 case SENSOR_PO2030N:
1777 po2030n_probe(gspca_dev);
1781 reg_w(gspca_dev, 0x01, regGpio, 2);
1784 /* case BRIDGE_SN9C110: */
1785 /* case BRIDGE_SN9C325: */
1788 reg_w1(gspca_dev, 0x02, 0x62);
1792 /* Note we do not disable the sensor clock here (power saving mode),
1793 as that also disables the button on the cam. */
1794 reg_w1(gspca_dev, 0xf1, 0x00);
1796 /* set the i2c address */
1797 sn9c1xx = sn_tb[sd->sensor];
1798 sd->i2c_addr = sn9c1xx[9];
1800 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1805 static u32 setexposure(struct gspca_dev *gspca_dev,
1808 struct sd *sd = (struct sd *) gspca_dev;
1810 switch (sd->sensor) {
1811 case SENSOR_GC0307: {
1814 /* expo = 0..255 -> a = 19..43 */
1815 a = 19 + expo * 25 / 256;
1816 i2c_w1(gspca_dev, 0x68, a);
1818 b = a * a * 4; /* heuristic */
1819 i2c_w1(gspca_dev, 0x03, b >> 8);
1820 i2c_w1(gspca_dev, 0x04, b);
1823 case SENSOR_HV7131R: {
1825 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
1827 Expodoit[3] = expo >> 16;
1828 Expodoit[4] = expo >> 8;
1830 i2c_w8(gspca_dev, Expodoit);
1833 case SENSOR_MI0360: {
1834 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
1835 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
1836 static const u8 doit[] = /* update sensor */
1837 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1838 static const u8 sensorgo[] = /* sensor on */
1839 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
1843 else if (expo < 0x0001)
1845 expoMi[3] = expo >> 8;
1847 i2c_w8(gspca_dev, expoMi);
1848 i2c_w8(gspca_dev, doit);
1849 i2c_w8(gspca_dev, sensorgo);
1852 case SENSOR_MO4000: {
1854 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
1856 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
1857 static const u8 gainMo[] =
1858 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
1862 else if (expo < 0x0001)
1864 expoMof[3] = (expo & 0x03fc) >> 2;
1865 i2c_w8(gspca_dev, expoMof);
1866 expoMo10[3] = ((expo & 0x1c00) >> 10)
1867 | ((expo & 0x0003) << 4);
1868 i2c_w8(gspca_dev, expoMo10);
1869 i2c_w8(gspca_dev, gainMo);
1870 PDEBUG(D_FRAM, "set exposure %d",
1871 ((expoMo10[3] & 0x07) << 10)
1873 | ((expoMo10[3] & 0x30) >> 4));
1876 case SENSOR_MT9V111: {
1878 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1882 else if (expo < 0x0040)
1884 expo_c1[3] = expo >> 8;
1886 i2c_w8(gspca_dev, expo_c1);
1889 case SENSOR_OM6802: {
1891 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
1892 /* preset AGC - works when AutoExpo = off */
1898 gainOm[3] = expo >> 2;
1899 i2c_w8(gspca_dev, gainOm);
1900 reg_w1(gspca_dev, 0x96, expo >> 5);
1901 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
1908 static void setbrightness(struct gspca_dev *gspca_dev)
1910 struct sd *sd = (struct sd *) gspca_dev;
1914 k2 = ((int) sd->brightness - 0x8000) >> 10;
1915 switch (sd->sensor) {
1916 case SENSOR_ADCM1700:
1918 k2 = 0; /* only positive Y offset */
1920 case SENSOR_HV7131R:
1921 expo = sd->brightness << 4;
1922 if (expo > 0x002dc6c0)
1924 else if (expo < 0x02a0)
1926 sd->exposure = setexposure(gspca_dev, expo);
1930 expo = sd->brightness >> 4;
1931 sd->exposure = setexposure(gspca_dev, expo);
1934 case SENSOR_MT9V111:
1935 expo = sd->brightness >> 8;
1936 sd->exposure = setexposure(gspca_dev, expo);
1937 return; /* don't set the Y offset */
1939 expo = sd->brightness >> 6;
1940 sd->exposure = setexposure(gspca_dev, expo);
1941 k2 = sd->brightness >> 11;
1945 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
1948 static void setcontrast(struct gspca_dev *gspca_dev)
1950 struct sd *sd = (struct sd *) gspca_dev;
1954 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
1955 contrast[0] = (k2 + 1) / 2; /* red */
1957 contrast[2] = k2; /* green */
1959 contrast[4] = (k2 + 1) / 5; /* blue */
1961 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
1964 static void setcolors(struct gspca_dev *gspca_dev)
1966 struct sd *sd = (struct sd *) gspca_dev;
1968 u8 reg8a[12]; /* U & V gains */
1969 static const s16 uv[6] = { /* same as reg84 in signed decimal */
1970 -24, -38, 64, /* UR UG UB */
1971 62, -51, -9 /* VR VG VB */
1974 for (i = 0; i < 6; i++) {
1975 v = uv[i] * sd->colors / COLOR_DEF;
1977 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
1979 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
1982 static void setredblue(struct gspca_dev *gspca_dev)
1984 struct sd *sd = (struct sd *) gspca_dev;
1986 reg_w1(gspca_dev, 0x05, sd->red);
1987 /* reg_w1(gspca_dev, 0x07, 32); */
1988 reg_w1(gspca_dev, 0x06, sd->blue);
1991 static void setgamma(struct gspca_dev *gspca_dev)
1993 struct sd *sd = (struct sd *) gspca_dev;
1996 const u8 *gamma_base;
1997 static const u8 delta[17] = {
1998 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1999 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2002 switch (sd->sensor) {
2003 case SENSOR_ADCM1700:
2004 gamma_base = gamma_spec_0;
2006 case SENSOR_HV7131R:
2007 case SENSOR_MT9V111:
2008 gamma_base = gamma_spec_1;
2011 gamma_base = gamma_spec_2;
2013 case SENSOR_SP80708:
2014 gamma_base = gamma_spec_3;
2017 gamma_base = gamma_def;
2021 for (i = 0; i < sizeof gamma; i++)
2022 gamma[i] = gamma_base[i]
2023 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
2024 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2027 static void setautogain(struct gspca_dev *gspca_dev)
2029 struct sd *sd = (struct sd *) gspca_dev;
2031 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
2033 switch (sd->sensor) {
2035 case SENSOR_OV7648: {
2038 if (sd->sensor == SENSOR_OV7630)
2044 i2c_w1(&sd->gspca_dev, 0x13, comb);
2049 sd->ag_cnt = AG_CNT_START;
2054 /* hv7131r/ov7630/ov7648 only */
2055 static void setvflip(struct sd *sd)
2059 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
2061 switch (sd->sensor) {
2062 case SENSOR_HV7131R:
2063 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
2066 i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */
2072 i2c_w1(&sd->gspca_dev, 0x75, comn);
2075 /* case SENSOR_OV7648: */
2079 i2c_w1(&sd->gspca_dev, 0x75, comn);
2084 static void setsharpness(struct sd *sd)
2086 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness);
2089 static void setinfrared(struct sd *sd)
2091 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
2093 /*fixme: different sequence for StarCam Clip and StarCam 370i */
2095 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
2096 sd->infrared ? 0x66 : 0x64);
2099 static void setfreq(struct gspca_dev *gspca_dev)
2101 struct sd *sd = (struct sd *) gspca_dev;
2103 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
2105 if (sd->sensor == SENSOR_OV7660) {
2108 com8 = 0xdf; /* auto gain/wb/expo */
2110 case 0: /* Banding filter disabled */
2111 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
2114 i2c_w1(gspca_dev, 0x13, com8);
2115 i2c_w1(gspca_dev, 0x3b, 0x0a);
2118 i2c_w1(gspca_dev, 0x13, com8);
2119 i2c_w1(gspca_dev, 0x3b, 0x02);
2123 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2125 /* Get reg2a / reg2d base values */
2126 switch (sd->sensor) {
2138 case 0: /* Banding filter disabled */
2140 case 1: /* 50 hz (filter on and framerate adj) */
2145 case 2: /* 60 hz (filter on, no framerate adj) */
2150 i2c_w1(gspca_dev, 0x2a, reg2a);
2151 i2c_w1(gspca_dev, 0x2b, reg2b);
2152 i2c_w1(gspca_dev, 0x2d, reg2d);
2156 static void setjpegqual(struct gspca_dev *gspca_dev)
2158 struct sd *sd = (struct sd *) gspca_dev;
2161 if (sd->jpegqual < 50)
2162 sc = 5000 / sd->jpegqual;
2164 sc = 200 - sd->jpegqual * 2;
2166 #error "No room enough in usb_buf for quantization table"
2168 for (i = 0; i < 64; i++)
2169 gspca_dev->usb_buf[i] =
2170 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2171 usb_control_msg(gspca_dev->dev,
2172 usb_sndctrlpipe(gspca_dev->dev, 0),
2174 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2176 gspca_dev->usb_buf, 64,
2178 for (i = 0; i < 64; i++)
2179 gspca_dev->usb_buf[i] =
2180 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2181 usb_control_msg(gspca_dev->dev,
2182 usb_sndctrlpipe(gspca_dev->dev, 0),
2184 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2186 gspca_dev->usb_buf, 64,
2190 reg_w1(gspca_dev, 0x18, sd->reg18);
2193 /* -- start the camera -- */
2194 static int sd_start(struct gspca_dev *gspca_dev)
2196 struct sd *sd = (struct sd *) gspca_dev;
2198 u8 reg1, reg2, reg17;
2200 const u8 (*init)[8];
2202 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2203 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
2204 static const u8 CA_adcm1700[] =
2205 { 0x14, 0xec, 0x0a, 0xf6 };
2206 static const u8 CA_po2030n[] =
2207 { 0x1e, 0xe2, 0x14, 0xec };
2208 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
2209 static const u8 CE_gc0307[] =
2210 { 0x32, 0xce, 0x2d, 0xd3 };
2211 static const u8 CE_ov76xx[] =
2212 { 0x32, 0xdd, 0x32, 0xdd };
2213 static const u8 CE_po2030n[] =
2214 { 0x14, 0xe7, 0x1e, 0xdd };
2216 /* create the JPEG header */
2217 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2218 0x21); /* JPEG 422 */
2219 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2221 /* initialize the bridge */
2222 sn9c1xx = sn_tb[sd->sensor];
2223 bridge_init(gspca_dev, sn9c1xx);
2225 /* initialize the sensor */
2226 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2228 switch (sd->sensor) {
2229 case SENSOR_ADCM1700:
2235 case SENSOR_SP80708:
2242 reg_w1(gspca_dev, 0x02, reg2);
2243 reg_w1(gspca_dev, 0x02, reg2);
2245 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2246 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2247 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2248 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2249 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
2250 if (sd->sensor == SENSOR_ADCM1700) {
2251 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2252 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
2254 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2255 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
2257 reg_w1(gspca_dev, 0xc6, 0x00);
2258 reg_w1(gspca_dev, 0xc7, 0x00);
2259 if (sd->sensor == SENSOR_ADCM1700) {
2260 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2261 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
2263 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2264 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
2266 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
2267 switch (sd->sensor) {
2271 case SENSOR_MT9V111:
2274 case SENSOR_ADCM1700:
2285 case SENSOR_PO2030N:
2292 reg_w1(gspca_dev, 0x17, reg17);
2294 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2295 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2296 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
2297 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
2299 setgamma(gspca_dev);
2301 /*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
2302 for (i = 0; i < 8; i++)
2303 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2304 switch (sd->sensor) {
2305 case SENSOR_ADCM1700:
2307 case SENSOR_SP80708:
2308 reg_w1(gspca_dev, 0x9a, 0x05);
2311 case SENSOR_MT9V111:
2312 reg_w1(gspca_dev, 0x9a, 0x07);
2315 reg_w1(gspca_dev, 0x9a, 0x0a);
2317 case SENSOR_PO2030N:
2318 reg_w1(gspca_dev, 0x9a, 0x06);
2321 reg_w1(gspca_dev, 0x9a, 0x08);
2326 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2327 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2328 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2329 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
2332 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
2334 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
2336 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2337 reg17 = 0x61; /* 0x:20: enable sensor clock */
2338 switch (sd->sensor) {
2339 case SENSOR_ADCM1700:
2340 init = adcm1700_sensor_param1;
2345 init = gc0307_sensor_param1;
2351 /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2352 reg1 = 0x06; /* clk 24Mz */
2354 reg17 = 0x22; /* 640 MCKSIZE */
2355 /* reg1 = 0x06; * 640 clk 24Mz (done) */
2358 case SENSOR_MT9V111:
2359 init = mt9v111_sensor_param1;
2361 reg1 = 0x04; /* 320 clk 48Mhz */
2363 /* reg1 = 0x06; * 640 clk 24Mz (done) */
2368 init = om6802_sensor_param1;
2369 reg17 = 0x64; /* 640 MCKSIZE */
2376 init = ov7648_sensor_param1;
2378 /* reg1 = 0x42; * 42 - 46? */
2381 init = ov7660_sensor_param1;
2382 if (sd->bridge == BRIDGE_SN9C120) {
2383 if (mode) { /* 320x240 - 160x120 */
2385 reg1 = 0x44; /* 48 Mhz, video trf eneble */
2389 reg1 = 0x06; /* 24 Mhz, video trf eneble
2390 * inverse power down */
2394 init = po1030_sensor_param1;
2398 case SENSOR_PO2030N:
2399 init = po2030n_sensor_param1;
2404 /* case SENSOR_SP80708: */
2405 init = sp80708_sensor_param1;
2407 /*?? reg1 = 0x04; * 320 clk 48Mhz */
2409 reg1 = 0x46; /* 640 clk 48Mz */
2415 /* more sensor initialization - param1 */
2417 i2c_w_seq(gspca_dev, init);
2421 reg_w(gspca_dev, 0xc0, C0, 6);
2422 switch (sd->sensor) {
2423 case SENSOR_ADCM1700:
2425 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
2427 case SENSOR_PO2030N:
2428 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2431 reg_w(gspca_dev, 0xca, CA, 4);
2434 switch (sd->sensor) {
2435 case SENSOR_ADCM1700:
2439 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
2442 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2444 case SENSOR_PO2030N:
2445 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2448 reg_w(gspca_dev, 0xce, CE, 4);
2449 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2454 /* here change size mode 0 -> VGA; 1 -> CIF */
2455 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2456 reg_w1(gspca_dev, 0x18, sd->reg18);
2457 setjpegqual(gspca_dev);
2459 reg_w1(gspca_dev, 0x17, reg17);
2460 reg_w1(gspca_dev, 0x01, reg1);
2463 setbrightness(gspca_dev);
2464 setcontrast(gspca_dev);
2465 setautogain(gspca_dev);
2470 static void sd_stopN(struct gspca_dev *gspca_dev)
2472 struct sd *sd = (struct sd *) gspca_dev;
2473 static const u8 stophv7131[] =
2474 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
2475 static const u8 stopmi0360[] =
2476 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
2477 static const u8 stopov7648[] =
2478 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
2483 switch (sd->sensor) {
2487 case SENSOR_HV7131R:
2488 i2c_w8(gspca_dev, stophv7131);
2492 i2c_w8(gspca_dev, stopmi0360);
2496 i2c_w8(gspca_dev, stopov7648);
2498 case SENSOR_MT9V111:
2504 sn9c1xx = sn_tb[sd->sensor];
2505 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2506 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2507 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2508 reg_w1(gspca_dev, 0x01, data);
2509 /* Don't disable sensor clock as that disables the button on the cam */
2510 /* reg_w1(gspca_dev, 0xf1, 0x01); */
2513 static void do_autogain(struct gspca_dev *gspca_dev)
2515 struct sd *sd = (struct sd *) gspca_dev;
2521 /* Thanks S., without your advice, autobright should not work :) */
2524 if (--sd->ag_cnt >= 0)
2526 sd->ag_cnt = AG_CNT_START;
2528 delta = atomic_read(&sd->avg_lum);
2529 PDEBUG(D_FRAM, "mean lum %d", delta);
2530 if (delta < luma_mean - luma_delta ||
2531 delta > luma_mean + luma_delta) {
2532 switch (sd->sensor) {
2534 expotimes = sd->exposure;
2535 expotimes += (luma_mean - delta) >> 6;
2538 sd->exposure = setexposure(gspca_dev,
2539 (unsigned int) expotimes);
2541 case SENSOR_HV7131R:
2542 expotimes = sd->exposure >> 8;
2543 expotimes += (luma_mean - delta) >> 4;
2546 sd->exposure = setexposure(gspca_dev,
2547 (unsigned int) (expotimes << 8));
2550 expotimes = sd->exposure;
2551 expotimes += (luma_mean - delta) >> 2;
2554 sd->exposure = setexposure(gspca_dev,
2555 (unsigned int) expotimes);
2556 setredblue(gspca_dev);
2559 /* case SENSOR_MO4000: */
2560 /* case SENSOR_MI0360: */
2561 /* case SENSOR_MT9V111: */
2562 expotimes = sd->exposure;
2563 expotimes += (luma_mean - delta) >> 6;
2566 sd->exposure = setexposure(gspca_dev,
2567 (unsigned int) expotimes);
2568 setredblue(gspca_dev);
2574 /* scan the URB packets */
2575 /* This function is run at interrupt level. */
2576 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2577 u8 *data, /* isoc packet */
2578 int len) /* iso packet length */
2580 struct sd *sd = (struct sd *) gspca_dev;
2584 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9) {
2587 gspca_frame_add(gspca_dev, LAST_PACKET,
2595 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2597 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2599 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2601 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2603 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2605 atomic_set(&sd->avg_lum, avg_lum);
2608 if (gspca_dev->last_packet_type == LAST_PACKET) {
2610 /* put the JPEG 422 header */
2611 gspca_frame_add(gspca_dev, FIRST_PACKET,
2612 sd->jpeg_hdr, JPEG_HDR_SZ);
2614 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2617 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2619 struct sd *sd = (struct sd *) gspca_dev;
2621 sd->brightness = val;
2622 if (gspca_dev->streaming)
2623 setbrightness(gspca_dev);
2627 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2629 struct sd *sd = (struct sd *) gspca_dev;
2631 *val = sd->brightness;
2635 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2637 struct sd *sd = (struct sd *) gspca_dev;
2640 if (gspca_dev->streaming)
2641 setcontrast(gspca_dev);
2645 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2647 struct sd *sd = (struct sd *) gspca_dev;
2649 *val = sd->contrast;
2653 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2655 struct sd *sd = (struct sd *) gspca_dev;
2658 if (gspca_dev->streaming)
2659 setcolors(gspca_dev);
2663 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2665 struct sd *sd = (struct sd *) gspca_dev;
2671 static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2673 struct sd *sd = (struct sd *) gspca_dev;
2676 if (gspca_dev->streaming)
2677 setredblue(gspca_dev);
2681 static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2683 struct sd *sd = (struct sd *) gspca_dev;
2689 static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2691 struct sd *sd = (struct sd *) gspca_dev;
2694 if (gspca_dev->streaming)
2695 setredblue(gspca_dev);
2699 static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2701 struct sd *sd = (struct sd *) gspca_dev;
2707 static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2709 struct sd *sd = (struct sd *) gspca_dev;
2712 if (gspca_dev->streaming)
2713 setgamma(gspca_dev);
2717 static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2719 struct sd *sd = (struct sd *) gspca_dev;
2725 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2727 struct sd *sd = (struct sd *) gspca_dev;
2730 if (gspca_dev->streaming)
2731 setautogain(gspca_dev);
2735 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2737 struct sd *sd = (struct sd *) gspca_dev;
2739 *val = sd->autogain;
2743 static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2745 struct sd *sd = (struct sd *) gspca_dev;
2747 sd->sharpness = val;
2748 if (gspca_dev->streaming)
2753 static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2755 struct sd *sd = (struct sd *) gspca_dev;
2757 *val = sd->sharpness;
2761 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
2763 struct sd *sd = (struct sd *) gspca_dev;
2766 if (gspca_dev->streaming)
2771 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
2773 struct sd *sd = (struct sd *) gspca_dev;
2779 static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
2781 struct sd *sd = (struct sd *) gspca_dev;
2784 if (gspca_dev->streaming)
2789 static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
2791 struct sd *sd = (struct sd *) gspca_dev;
2793 *val = sd->infrared;
2797 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
2799 struct sd *sd = (struct sd *) gspca_dev;
2802 if (gspca_dev->streaming)
2807 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
2809 struct sd *sd = (struct sd *) gspca_dev;
2815 static int sd_set_jcomp(struct gspca_dev *gspca_dev,
2816 struct v4l2_jpegcompression *jcomp)
2818 struct sd *sd = (struct sd *) gspca_dev;
2820 if (jcomp->quality < QUALITY_MIN)
2821 sd->quality = QUALITY_MIN;
2822 else if (jcomp->quality > QUALITY_MAX)
2823 sd->quality = QUALITY_MAX;
2825 sd->quality = jcomp->quality;
2826 if (gspca_dev->streaming)
2827 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2831 static int sd_get_jcomp(struct gspca_dev *gspca_dev,
2832 struct v4l2_jpegcompression *jcomp)
2834 struct sd *sd = (struct sd *) gspca_dev;
2836 memset(jcomp, 0, sizeof *jcomp);
2837 jcomp->quality = sd->quality;
2838 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
2839 | V4L2_JPEG_MARKER_DQT;
2843 static int sd_querymenu(struct gspca_dev *gspca_dev,
2844 struct v4l2_querymenu *menu)
2847 case V4L2_CID_POWER_LINE_FREQUENCY:
2848 switch (menu->index) {
2849 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2850 strcpy((char *) menu->name, "NoFliker");
2852 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2853 strcpy((char *) menu->name, "50 Hz");
2855 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2856 strcpy((char *) menu->name, "60 Hz");
2865 static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
2866 u8 *data, /* interrupt packet data */
2867 int len) /* interrupt packet length */
2871 if (len == 1 && data[0] == 1) {
2872 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
2873 input_sync(gspca_dev->input_dev);
2874 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
2875 input_sync(gspca_dev->input_dev);
2883 /* sub-driver description */
2884 static const struct sd_desc sd_desc = {
2885 .name = MODULE_NAME,
2887 .nctrls = ARRAY_SIZE(sd_ctrls),
2888 .config = sd_config,
2892 .pkt_scan = sd_pkt_scan,
2893 .dq_callback = do_autogain,
2894 .get_jcomp = sd_get_jcomp,
2895 .set_jcomp = sd_set_jcomp,
2896 .querymenu = sd_querymenu,
2898 .int_pkt_scan = sd_int_pkt_scan,
2902 /* -- module initialisation -- */
2903 #define BS(bridge, sensor) \
2904 .driver_info = (BRIDGE_ ## bridge << 16) \
2906 static const __devinitdata struct usb_device_id device_table[] = {
2907 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2908 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2909 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
2911 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
2912 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
2913 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2914 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2915 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
2916 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
2917 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
2918 /* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
2919 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
2920 /* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
2921 /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2922 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2923 /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2924 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
2925 /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2926 /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
2927 /* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
2928 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
2929 /* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
2930 /* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
2931 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
2932 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2933 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2934 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
2936 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
2937 /* {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, P1030xC)}, */
2938 /* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
2939 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
2940 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
2941 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
2942 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
2943 /* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
2944 /* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
2945 /* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
2946 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
2948 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
2949 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
2950 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
2951 /* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
2952 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2953 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
2955 /* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
2956 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
2957 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
2958 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2959 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
2961 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
2962 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
2963 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
2964 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2965 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
2966 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
2969 MODULE_DEVICE_TABLE(usb, device_table);
2971 /* -- device connect -- */
2972 static int sd_probe(struct usb_interface *intf,
2973 const struct usb_device_id *id)
2975 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
2979 static struct usb_driver sd_driver = {
2980 .name = MODULE_NAME,
2981 .id_table = device_table,
2983 .disconnect = gspca_disconnect,
2985 .suspend = gspca_suspend,
2986 .resume = gspca_resume,
2990 /* -- module insert / remove -- */
2991 static int __init sd_mod_init(void)
2994 ret = usb_register(&sd_driver);
3000 static void __exit sd_mod_exit(void)
3002 usb_deregister(&sd_driver);
3003 info("deregistered");
3006 module_init(sd_mod_init);
3007 module_exit(sd_mod_exit);