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");
34 /* specific webcam descriptor */
36 struct gspca_dev gspca_dev; /* !! must be the first item */
48 u8 vflip; /* ov7630/ov7648 only */
50 u8 infrared; /* mt9v111 only */
51 u8 freq; /* ov76xx only */
52 u8 quality; /* image quality */
53 #define QUALITY_MIN 60
54 #define QUALITY_MAX 95
55 #define QUALITY_DEF 80
56 u8 jpegqual; /* webcam quality */
61 #define AG_CNT_START 13
64 #define BRIDGE_SN9C102P 0
65 #define BRIDGE_SN9C105 1
66 #define BRIDGE_SN9C110 2
67 #define BRIDGE_SN9C120 3
68 u8 sensor; /* Type of image sensor chip */
71 u8 jpeg_hdr[JPEG_HDR_SZ];
91 /* V4L2 controls supported by the driver */
92 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
93 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
94 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val);
95 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val);
96 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val);
97 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val);
98 static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val);
99 static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val);
100 static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val);
101 static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val);
102 static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val);
103 static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val);
104 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
105 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
106 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val);
107 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val);
108 static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
109 static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
110 static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val);
111 static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val);
112 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val);
113 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val);
115 static const struct ctrl sd_ctrls[] = {
116 #define BRIGHTNESS_IDX 0
119 .id = V4L2_CID_BRIGHTNESS,
120 .type = V4L2_CTRL_TYPE_INTEGER,
121 .name = "Brightness",
123 #define BRIGHTNESS_MAX 0xffff
124 .maximum = BRIGHTNESS_MAX,
126 #define BRIGHTNESS_DEF 0x8000
127 .default_value = BRIGHTNESS_DEF,
129 .set = sd_setbrightness,
130 .get = sd_getbrightness,
132 #define CONTRAST_IDX 1
135 .id = V4L2_CID_CONTRAST,
136 .type = V4L2_CTRL_TYPE_INTEGER,
139 #define CONTRAST_MAX 127
140 .maximum = CONTRAST_MAX,
142 #define CONTRAST_DEF 63
143 .default_value = CONTRAST_DEF,
145 .set = sd_setcontrast,
146 .get = sd_getcontrast,
151 .id = V4L2_CID_SATURATION,
152 .type = V4L2_CTRL_TYPE_INTEGER,
153 .name = "Saturation",
158 .default_value = COLOR_DEF,
163 #define BLUE_BALANCE_IDX 3
166 .id = V4L2_CID_BLUE_BALANCE,
167 .type = V4L2_CTRL_TYPE_INTEGER,
168 .name = "Blue Balance",
172 #define BLUE_BALANCE_DEF 32
173 .default_value = BLUE_BALANCE_DEF,
175 .set = sd_setblue_balance,
176 .get = sd_getblue_balance,
178 #define RED_BALANCE_IDX 4
181 .id = V4L2_CID_RED_BALANCE,
182 .type = V4L2_CTRL_TYPE_INTEGER,
183 .name = "Red Balance",
187 #define RED_BALANCE_DEF 32
188 .default_value = RED_BALANCE_DEF,
190 .set = sd_setred_balance,
191 .get = sd_getred_balance,
196 .id = V4L2_CID_GAMMA,
197 .type = V4L2_CTRL_TYPE_INTEGER,
203 .default_value = GAMMA_DEF,
208 #define AUTOGAIN_IDX 6
211 .id = V4L2_CID_AUTOGAIN,
212 .type = V4L2_CTRL_TYPE_BOOLEAN,
217 #define AUTOGAIN_DEF 1
218 .default_value = AUTOGAIN_DEF,
220 .set = sd_setautogain,
221 .get = sd_getautogain,
223 /* ov7630/ov7648 only */
227 .id = V4L2_CID_VFLIP,
228 .type = V4L2_CTRL_TYPE_BOOLEAN,
234 .default_value = VFLIP_DEF,
239 #define SHARPNESS_IDX 8
242 .id = V4L2_CID_SHARPNESS,
243 .type = V4L2_CTRL_TYPE_INTEGER,
248 #define SHARPNESS_DEF 90
249 .default_value = SHARPNESS_DEF,
251 .set = sd_setsharpness,
252 .get = sd_getsharpness,
255 #define INFRARED_IDX 9
258 .id = V4L2_CID_INFRARED,
259 .type = V4L2_CTRL_TYPE_BOOLEAN,
264 #define INFRARED_DEF 0
265 .default_value = INFRARED_DEF,
267 .set = sd_setinfrared,
268 .get = sd_getinfrared,
270 /* ov7630/ov7648/ov7660 only */
274 .id = V4L2_CID_POWER_LINE_FREQUENCY,
275 .type = V4L2_CTRL_TYPE_MENU,
276 .name = "Light frequency filter",
278 .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */
281 .default_value = FREQ_DEF,
288 /* table of the disabled controls */
289 static const __u32 ctrl_dis[] = {
290 [SENSOR_ADCM1700] = (1 << AUTOGAIN_IDX) |
291 (1 << INFRARED_IDX) |
295 [SENSOR_GC0307] = (1 << INFRARED_IDX) |
299 [SENSOR_HV7131R] = (1 << INFRARED_IDX) |
302 [SENSOR_MI0360] = (1 << INFRARED_IDX) |
306 [SENSOR_MI0360B] = (1 << INFRARED_IDX) |
310 [SENSOR_MO4000] = (1 << INFRARED_IDX) |
314 [SENSOR_MT9V111] = (1 << VFLIP_IDX) |
317 [SENSOR_OM6802] = (1 << INFRARED_IDX) |
321 [SENSOR_OV7630] = (1 << INFRARED_IDX),
323 [SENSOR_OV7648] = (1 << INFRARED_IDX),
325 [SENSOR_OV7660] = (1 << AUTOGAIN_IDX) |
326 (1 << INFRARED_IDX) |
329 [SENSOR_PO1030] = (1 << AUTOGAIN_IDX) |
330 (1 << INFRARED_IDX) |
334 [SENSOR_PO2030N] = (1 << AUTOGAIN_IDX) |
335 (1 << INFRARED_IDX) |
338 [SENSOR_SOI768] = (1 << AUTOGAIN_IDX) |
339 (1 << INFRARED_IDX) |
343 [SENSOR_SP80708] = (1 << AUTOGAIN_IDX) |
344 (1 << INFRARED_IDX) |
349 static const struct v4l2_pix_format cif_mode[] = {
350 {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
352 .sizeimage = 352 * 288 * 4 / 8 + 590,
353 .colorspace = V4L2_COLORSPACE_JPEG,
356 static const struct v4l2_pix_format vga_mode[] = {
357 {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
359 .sizeimage = 160 * 120 * 4 / 8 + 590,
360 .colorspace = V4L2_COLORSPACE_JPEG,
362 {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
364 .sizeimage = 320 * 240 * 3 / 8 + 590,
365 .colorspace = V4L2_COLORSPACE_JPEG,
367 {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
369 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
370 .sizeimage = 640 * 480 * 3 / 4 + 590,
371 .colorspace = V4L2_COLORSPACE_JPEG,
375 static const u8 sn_adcm1700[0x1c] = {
376 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
377 0x00, 0x43, 0x60, 0x00, 0x1a, 0x00, 0x00, 0x00,
378 /* reg8 reg9 rega regb regc regd rege regf */
379 0x80, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
380 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
381 0x03, 0x00, 0x05, 0x01, 0x05, 0x16, 0x12, 0x42,
382 /* reg18 reg19 reg1a reg1b */
383 0x06, 0x00, 0x00, 0x00
386 static const u8 sn_gc0307[0x1c] = {
387 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
388 0x00, 0x61, 0x62, 0x00, 0x1a, 0x00, 0x00, 0x00,
389 /* reg8 reg9 rega regb regc regd rege regf */
390 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
391 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
392 0x03, 0x00, 0x03, 0x01, 0x08, 0x28, 0x1e, 0x02,
393 /* reg18 reg19 reg1a reg1b */
394 0x06, 0x00, 0x00, 0x00
397 static const u8 sn_hv7131[0x1c] = {
398 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
399 0x00, 0x03, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
400 /* reg8 reg9 rega regb regc regd rege regf */
401 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
402 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
403 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
404 /* reg18 reg19 reg1a reg1b */
405 0x0a, 0x00, 0x00, 0x00
408 static const u8 sn_mi0360[0x1c] = {
409 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
410 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
411 /* reg8 reg9 rega regb regc regd rege regf */
412 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
413 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
414 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
415 /* reg18 reg19 reg1a reg1b */
416 0x06, 0x00, 0x00, 0x00
419 static const u8 sn_mi0360b[0x1c] = {
420 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
421 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
422 /* reg8 reg9 rega regb regc regd rege regf */
423 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
424 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
425 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x40,
426 /* reg18 reg19 reg1a reg1b */
427 0x06, 0x00, 0x00, 0x00
430 static const u8 sn_mo4000[0x1c] = {
431 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
432 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
433 /* reg8 reg9 rega regb regc regd rege regf */
434 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
435 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
436 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
437 /* reg18 reg19 reg1a reg1b */
438 0x08, 0x00, 0x00, 0x00
441 static const u8 sn_mt9v111[0x1c] = {
442 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
443 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
444 /* reg8 reg9 rega regb regc regd rege regf */
445 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
446 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
447 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
448 /* reg18 reg19 reg1a reg1b */
449 0x06, 0x00, 0x00, 0x00
452 static const u8 sn_om6802[0x1c] = {
453 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
454 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
455 /* reg8 reg9 rega regb regc regd rege regf */
456 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
457 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
458 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
459 /* reg18 reg19 reg1a reg1b */
460 0x05, 0x00, 0x00, 0x00
463 static const u8 sn_ov7630[0x1c] = {
464 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
465 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
466 /* reg8 reg9 rega regb regc regd rege regf */
467 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
468 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
469 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
470 /* reg18 reg19 reg1a reg1b */
471 0x0b, 0x00, 0x00, 0x00
474 static const u8 sn_ov7648[0x1c] = {
475 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
476 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
477 /* reg8 reg9 rega regb regc regd rege regf */
478 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
479 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
480 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
481 /* reg18 reg19 reg1a reg1b */
482 0x0b, 0x00, 0x00, 0x00
485 static const u8 sn_ov7660[0x1c] = {
486 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
487 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
488 /* reg8 reg9 rega regb regc regd rege regf */
489 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
490 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
491 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
492 /* reg18 reg19 reg1a reg1b */
493 0x07, 0x00, 0x00, 0x00
496 static const u8 sn_po1030[0x1c] = {
497 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
498 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20,
499 /* reg8 reg9 rega regb regc regd rege regf */
500 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
501 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
502 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1e, 0x00,
503 /* reg18 reg19 reg1a reg1b */
504 0x07, 0x00, 0x00, 0x00
507 static const u8 sn_po2030n[0x1c] = {
508 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
509 0x00, 0x63, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
510 /* reg8 reg9 rega regb regc regd rege regf */
511 0x81, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
512 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
513 0x03, 0x00, 0x00, 0x01, 0x14, 0x28, 0x1e, 0x00,
514 /* reg18 reg19 reg1a reg1b */
515 0x07, 0x00, 0x00, 0x00
518 static const u8 sn_soi768[0x1c] = {
519 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
520 0x00, 0x21, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
521 /* reg8 reg9 rega regb regc regd rege regf */
522 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
523 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
524 0x03, 0x00, 0x00, 0x01, 0x08, 0x28, 0x1e, 0x00,
525 /* reg18 reg19 reg1a reg1b */
526 0x07, 0x00, 0x00, 0x00
529 static const u8 sn_sp80708[0x1c] = {
530 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
531 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
532 /* reg8 reg9 rega regb regc regd rege regf */
533 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
534 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
535 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
536 /* reg18 reg19 reg1a reg1b */
537 0x07, 0x00, 0x00, 0x00
540 /* sequence specific to the sensors - !! index = SENSOR_xxx */
541 static const u8 *sn_tb[] = {
542 [SENSOR_ADCM1700] = sn_adcm1700,
543 [SENSOR_GC0307] = sn_gc0307,
544 [SENSOR_HV7131R] = sn_hv7131,
545 [SENSOR_MI0360] = sn_mi0360,
546 [SENSOR_MI0360B] = sn_mi0360b,
547 [SENSOR_MO4000] = sn_mo4000,
548 [SENSOR_MT9V111] = sn_mt9v111,
549 [SENSOR_OM6802] = sn_om6802,
550 [SENSOR_OV7630] = sn_ov7630,
551 [SENSOR_OV7648] = sn_ov7648,
552 [SENSOR_OV7660] = sn_ov7660,
553 [SENSOR_PO1030] = sn_po1030,
554 [SENSOR_PO2030N] = sn_po2030n,
555 [SENSOR_SOI768] = sn_soi768,
556 [SENSOR_SP80708] = sn_sp80708,
559 /* default gamma table */
560 static const u8 gamma_def[17] = {
561 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
562 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
564 /* gamma for sensor ADCM1700 */
565 static const u8 gamma_spec_0[17] = {
566 0x0f, 0x39, 0x5a, 0x74, 0x86, 0x95, 0xa6, 0xb4,
567 0xbd, 0xc4, 0xcc, 0xd4, 0xd5, 0xde, 0xe4, 0xed, 0xf5
569 /* gamma for sensors HV7131R and MT9V111 */
570 static const u8 gamma_spec_1[17] = {
571 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
572 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
574 /* gamma for sensor GC0307 */
575 static const u8 gamma_spec_2[17] = {
576 0x14, 0x37, 0x50, 0x6a, 0x7c, 0x8d, 0x9d, 0xab,
577 0xb5, 0xbf, 0xc2, 0xcb, 0xd1, 0xd6, 0xdb, 0xe1, 0xeb
579 /* gamma for sensor SP80708 */
580 static const u8 gamma_spec_3[17] = {
581 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
582 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
585 /* color matrix and offsets */
586 static const u8 reg84[] = {
587 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
588 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
589 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
590 0x00, 0x00, 0x00 /* YUV offsets */
592 static const u8 adcm1700_sensor_init[][8] = {
593 {0xa0, 0x51, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x10},
594 {0xb0, 0x51, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10}, /* reset */
595 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
596 {0xb0, 0x51, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
597 {0xdd, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
598 {0xb0, 0x51, 0x0c, 0xe0, 0x2e, 0x00, 0x00, 0x10},
599 {0xb0, 0x51, 0x10, 0x02, 0x02, 0x00, 0x00, 0x10},
600 {0xb0, 0x51, 0x14, 0x0e, 0x0e, 0x00, 0x00, 0x10},
601 {0xb0, 0x51, 0x1c, 0x00, 0x80, 0x00, 0x00, 0x10},
602 {0xb0, 0x51, 0x20, 0x01, 0x00, 0x00, 0x00, 0x10},
603 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
604 {0xb0, 0x51, 0x04, 0x04, 0x00, 0x00, 0x00, 0x10},
605 {0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
606 {0xb0, 0x51, 0x04, 0x01, 0x00, 0x00, 0x00, 0x10},
607 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
608 {0xb0, 0x51, 0x14, 0x01, 0x00, 0x00, 0x00, 0x10},
609 {0xb0, 0x51, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
612 static const u8 adcm1700_sensor_param1[][8] = {
613 {0xb0, 0x51, 0x26, 0xf9, 0x01, 0x00, 0x00, 0x10}, /* exposure? */
614 {0xd0, 0x51, 0x1e, 0x8e, 0x8e, 0x8e, 0x8e, 0x10},
616 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
617 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
618 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
619 {0xb0, 0x51, 0x32, 0x00, 0x72, 0x00, 0x00, 0x10},
620 {0xd0, 0x51, 0x1e, 0xbe, 0xd7, 0xe8, 0xbe, 0x10}, /* exposure? */
622 {0xa0, 0x51, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x10},
623 {0xb0, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10},
624 {0xa0, 0x51, 0xfe, 0x10, 0x00, 0x00, 0x00, 0x10},
625 {0xb0, 0x51, 0x32, 0x00, 0xa2, 0x00, 0x00, 0x10},
628 static const u8 gc0307_sensor_init[][8] = {
629 {0xa0, 0x21, 0x43, 0x00, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x21, 0x44, 0xa2, 0x00, 0x00, 0x00, 0x10},
631 {0xa0, 0x21, 0x01, 0x6a, 0x00, 0x00, 0x00, 0x10},
632 {0xa0, 0x21, 0x02, 0x70, 0x00, 0x00, 0x00, 0x10},
633 {0xa0, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
634 {0xa0, 0x21, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
635 {0xa0, 0x21, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
636 {0xa0, 0x21, 0x11, 0x05, 0x00, 0x00, 0x00, 0x10},
637 {0xa0, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
638 {0xa0, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
639 {0xa0, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10},
640 {0xa0, 0x21, 0x08, 0x02, 0x00, 0x00, 0x00, 0x10},
641 {0xa0, 0x21, 0x09, 0x01, 0x00, 0x00, 0x00, 0x10},
642 {0xa0, 0x21, 0x0a, 0xe8, 0x00, 0x00, 0x00, 0x10},
643 {0xa0, 0x21, 0x0b, 0x02, 0x00, 0x00, 0x00, 0x10},
644 {0xa0, 0x21, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x10},
645 {0xa0, 0x21, 0x0d, 0x22, 0x00, 0x00, 0x00, 0x10},
646 {0xa0, 0x21, 0x0e, 0x02, 0x00, 0x00, 0x00, 0x10},
647 {0xa0, 0x21, 0x0f, 0xb2, 0x00, 0x00, 0x00, 0x10},
648 {0xa0, 0x21, 0x12, 0x70, 0x00, 0x00, 0x00, 0x10},
649 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 10ms*/
650 {0xa0, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x10},
651 {0xa0, 0x21, 0x15, 0xb8, 0x00, 0x00, 0x00, 0x10},
652 {0xa0, 0x21, 0x16, 0x13, 0x00, 0x00, 0x00, 0x10},
653 {0xa0, 0x21, 0x17, 0x52, 0x00, 0x00, 0x00, 0x10},
654 {0xa0, 0x21, 0x18, 0x50, 0x00, 0x00, 0x00, 0x10},
655 {0xa0, 0x21, 0x1e, 0x0d, 0x00, 0x00, 0x00, 0x10},
656 {0xa0, 0x21, 0x1f, 0x32, 0x00, 0x00, 0x00, 0x10},
657 {0xa0, 0x21, 0x61, 0x90, 0x00, 0x00, 0x00, 0x10},
658 {0xa0, 0x21, 0x63, 0x70, 0x00, 0x00, 0x00, 0x10},
659 {0xa0, 0x21, 0x65, 0x98, 0x00, 0x00, 0x00, 0x10},
660 {0xa0, 0x21, 0x67, 0x90, 0x00, 0x00, 0x00, 0x10},
661 {0xa0, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
662 {0xa0, 0x21, 0x04, 0x96, 0x00, 0x00, 0x00, 0x10},
663 {0xa0, 0x21, 0x45, 0x27, 0x00, 0x00, 0x00, 0x10},
664 {0xa0, 0x21, 0x47, 0x2c, 0x00, 0x00, 0x00, 0x10},
665 {0xa0, 0x21, 0x43, 0x47, 0x00, 0x00, 0x00, 0x10},
666 {0xa0, 0x21, 0x44, 0xd8, 0x00, 0x00, 0x00, 0x10},
669 static const u8 gc0307_sensor_param1[][8] = {
670 {0xa0, 0x21, 0x68, 0x13, 0x00, 0x00, 0x00, 0x10},
671 {0xd0, 0x21, 0x61, 0x80, 0x00, 0x80, 0x00, 0x10},
672 {0xc0, 0x21, 0x65, 0x80, 0x00, 0x80, 0x00, 0x10},
673 {0xc0, 0x21, 0x63, 0xa0, 0x00, 0xa6, 0x00, 0x10},
675 {0xa0, 0x21, 0x01, 0x6e, 0x00, 0x00, 0x00, 0x10},
676 {0xa0, 0x21, 0x02, 0x88, 0x00, 0x00, 0x00, 0x10},
680 static const u8 hv7131r_sensor_init[][8] = {
681 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
682 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
683 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
684 /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
685 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
686 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
687 /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
689 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
690 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
691 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
692 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
693 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
694 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
695 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
696 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
698 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
699 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
700 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
701 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
702 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
704 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
705 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
706 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
707 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
708 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
709 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
710 /* set sensor clock */
713 static const u8 mi0360_sensor_init[][8] = {
714 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
715 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
716 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
717 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
718 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
719 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
720 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
721 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
722 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
723 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
724 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
725 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
726 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
727 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
728 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
729 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
730 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
731 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
732 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
733 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
734 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
735 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
736 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
737 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
738 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
739 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
740 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
741 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
742 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
743 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
744 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
745 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
746 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
748 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
749 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
750 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
751 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
752 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
754 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
755 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
756 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
757 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
759 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
760 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
761 /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
762 /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
763 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
764 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
767 static const u8 mi0360b_sensor_init[][8] = {
768 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
769 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
770 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
771 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
772 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*delay 20ms*/
773 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
774 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
775 {0xd1, 0x5d, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
776 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
777 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
778 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
779 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
780 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
781 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
782 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
783 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
784 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
785 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
786 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
787 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
788 {0xd1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
789 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
790 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
791 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
792 {0xd1, 0x5d, 0x2f, 0xf7, 0xb0, 0x00, 0x04, 0x10},
793 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
794 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
795 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
796 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
797 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
798 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
799 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
800 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
801 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
802 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
804 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
805 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
806 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
807 {0xd1, 0x5d, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10},
808 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10},
811 static const u8 mi0360b_sensor_param1[][8] = {
812 {0xb1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
813 {0xb1, 0x5d, 0x06, 0x00, 0x53, 0x00, 0x00, 0x10},
814 {0xb1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x00, 0x10},
815 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
817 {0xd1, 0x5d, 0x2b, 0x00, 0xd1, 0x01, 0xc9, 0x10},
818 {0xd1, 0x5d, 0x2d, 0x00, 0xed, 0x00, 0xd1, 0x10},
819 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
820 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
823 static const u8 mo4000_sensor_init[][8] = {
824 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
846 static const u8 mt9v111_sensor_init[][8] = {
847 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
848 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
849 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
850 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
851 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
852 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
853 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
854 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
855 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
856 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
857 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
858 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
859 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
860 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
861 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
862 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
863 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
864 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
865 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
866 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
867 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
868 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
869 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
870 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
871 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
872 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
873 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
874 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
877 static const u8 mt9v111_sensor_param1[][8] = {
878 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
879 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
880 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
881 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
882 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
884 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
885 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
886 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
887 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
890 static const u8 om6802_init0[2][8] = {
892 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
893 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
895 static const u8 om6802_sensor_init[][8] = {
896 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
898 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
900 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
901 /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
902 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
903 /* auto-exposure speed (0) / white balance mode (auto RGB) */
904 /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
906 /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
907 * max AGC value in AE */
908 /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
910 /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
911 * preset brightness */
912 /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
914 /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
916 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
917 /* luminance mode (0x4f -> AutoExpo on) */
918 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
920 /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
922 /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
923 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
926 static const u8 om6802_sensor_param1[][8] = {
927 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
928 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
929 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
930 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
933 static const u8 ov7630_sensor_init[][8] = {
934 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
935 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
936 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
937 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
938 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
939 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
940 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
941 /* win: i2c_r from 00 to 80 */
942 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
943 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
944 /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
945 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
946 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
947 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
948 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
949 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
950 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
951 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
952 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
953 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
954 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
955 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
956 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
957 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
958 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
959 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
960 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
961 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
962 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
963 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
964 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
965 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
966 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
967 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
968 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
969 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
972 static const u8 ov7630_sensor_param1[][8] = {
973 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
974 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
975 /*fixme: + 0x12, 0x04*/
976 /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
978 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
979 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
980 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
982 /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
983 /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
985 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
986 /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
990 static const u8 ov7648_sensor_init[][8] = {
991 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
992 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
993 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
994 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
995 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
996 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
997 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
998 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
999 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
1000 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
1001 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
1002 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
1003 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
1004 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
1005 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
1006 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
1007 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
1008 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
1009 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
1010 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
1011 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
1012 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
1014 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
1015 /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
1016 /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
1017 /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
1020 static const u8 ov7648_sensor_param1[][8] = {
1021 /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
1022 /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
1023 * set by setvflip */
1024 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
1025 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
1026 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1027 /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
1028 /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
1030 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
1031 /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1032 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1033 /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
1034 /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
1035 /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
1040 static const u8 ov7660_sensor_init[][8] = {
1041 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
1042 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1043 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
1044 /* Outformat = rawRGB */
1045 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
1046 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
1047 /* GAIN BLUE RED VREF */
1048 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
1049 /* COM 1 BAVE GEAVE AECHH */
1050 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
1051 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
1052 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
1053 /* AECH CLKRC COM7 COM8 */
1054 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
1055 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
1056 /* HSTART HSTOP VSTRT VSTOP */
1057 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
1058 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
1059 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
1060 /* BOS GBOS GROS ROS (BGGR offset) */
1061 /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
1062 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
1063 /* AEW AEB VPT BBIAS */
1064 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
1065 /* GbBIAS RSVD EXHCH EXHCL */
1066 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
1067 /* RBIAS ADVFL ASDVFH YAVE */
1068 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
1069 /* HSYST HSYEN HREF */
1070 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
1071 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
1072 /* ADC ACOM OFON TSLB */
1073 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
1074 /* COM11 COM12 COM13 COM14 */
1075 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
1076 /* EDGE COM15 COM16 COM17 */
1077 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
1078 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
1079 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1080 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
1081 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
1082 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
1083 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
1084 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
1085 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
1086 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
1087 /* LCC1 LCC2 LCC3 LCC4 */
1088 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
1089 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
1090 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
1091 /* band gap reference [0:3] DBLV */
1092 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
1093 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
1094 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
1095 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
1096 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
1097 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
1098 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
1099 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
1100 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
1101 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
1102 /* not in all ms-win traces*/
1103 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
1106 static const u8 ov7660_sensor_param1[][8] = {
1107 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
1108 /* bits[3..0]reserved */
1109 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
1110 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1111 /* VREF vertical frame ctrl */
1112 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
1113 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
1114 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
1115 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
1116 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
1117 /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
1118 /****** (some exchanges in the win trace) ******/
1120 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
1121 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
1122 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
1123 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
1124 /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
1125 /****** (some exchanges in the win trace) ******/
1126 /******!! startsensor KO if changed !!****/
1128 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
1129 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
1130 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
1131 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
1135 static const u8 po1030_sensor_init[][8] = {
1136 /* the sensor registers are described in m5602/m5602_po1030.h */
1137 {0xa1, 0x6e, 0x3f, 0x20, 0x00, 0x00, 0x00, 0x10}, /* sensor reset */
1138 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
1139 {0xa1, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x10},
1140 {0xa1, 0x6e, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x10},
1141 {0xd1, 0x6e, 0x04, 0x02, 0xb1, 0x02, 0x39, 0x10},
1142 {0xd1, 0x6e, 0x08, 0x00, 0x01, 0x00, 0x00, 0x10},
1143 {0xd1, 0x6e, 0x0c, 0x02, 0x7f, 0x01, 0xe0, 0x10},
1144 {0xd1, 0x6e, 0x12, 0x03, 0x02, 0x00, 0x03, 0x10},
1145 {0xd1, 0x6e, 0x16, 0x85, 0x40, 0x4a, 0x40, 0x10}, /* r/g1/b/g2 gains */
1146 {0xc1, 0x6e, 0x1a, 0x00, 0x80, 0x00, 0x00, 0x10},
1147 {0xd1, 0x6e, 0x1d, 0x08, 0x03, 0x00, 0x00, 0x10},
1148 {0xd1, 0x6e, 0x23, 0x00, 0xb0, 0x00, 0x94, 0x10},
1149 {0xd1, 0x6e, 0x27, 0x58, 0x00, 0x00, 0x00, 0x10},
1150 {0xb1, 0x6e, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1151 {0xd1, 0x6e, 0x2d, 0x14, 0x35, 0x61, 0x84, 0x10}, /* gamma corr */
1152 {0xd1, 0x6e, 0x31, 0xa2, 0xbd, 0xd8, 0xff, 0x10},
1153 {0xd1, 0x6e, 0x35, 0x06, 0x1e, 0x12, 0x02, 0x10}, /* color matrix */
1154 {0xd1, 0x6e, 0x39, 0xaa, 0x53, 0x37, 0xd5, 0x10},
1155 {0xa1, 0x6e, 0x3d, 0xf2, 0x00, 0x00, 0x00, 0x10},
1156 {0xd1, 0x6e, 0x3e, 0x00, 0x00, 0x80, 0x03, 0x10},
1157 {0xd1, 0x6e, 0x42, 0x03, 0x00, 0x00, 0x00, 0x10},
1158 {0xc1, 0x6e, 0x46, 0x00, 0x80, 0x80, 0x00, 0x10},
1159 {0xd1, 0x6e, 0x4b, 0x02, 0xef, 0x08, 0xcd, 0x10},
1160 {0xd1, 0x6e, 0x4f, 0x00, 0xd0, 0x00, 0xa0, 0x10},
1161 {0xd1, 0x6e, 0x53, 0x01, 0xaa, 0x01, 0x40, 0x10},
1162 {0xd1, 0x6e, 0x5a, 0x50, 0x04, 0x30, 0x03, 0x10}, /* raw rgb bayer */
1163 {0xa1, 0x6e, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x10},
1164 {0xd1, 0x6e, 0x5f, 0x10, 0x40, 0xff, 0x00, 0x10},
1166 {0xd1, 0x6e, 0x63, 0x40, 0x40, 0x00, 0x00, 0x10},
1167 {0xd1, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x10},
1168 {0xd1, 0x6e, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x10},
1169 {0xd1, 0x6e, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x10},
1170 {0xc1, 0x6e, 0x73, 0x10, 0x80, 0xeb, 0x00, 0x10},
1173 static const u8 po1030_sensor_param1[][8] = {
1174 /* from ms-win traces - these values change with auto gain/expo/wb.. */
1175 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1176 {0xa1, 0x6e, 0x1e, 0x03, 0x00, 0x00, 0x00, 0x10},
1178 {0xc1, 0x6e, 0x1a, 0x02, 0xd4, 0xa4, 0x00, 0x10}, /* integlines */
1179 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10}, /* global gain */
1180 {0xc1, 0x6e, 0x16, 0x40, 0x40, 0x40, 0x00, 0x10}, /* r/g1/b gains */
1182 {0xa1, 0x6e, 0x1d, 0x08, 0x00, 0x00, 0x00, 0x10}, /* control1 */
1183 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10}, /* frameheight */
1184 {0xa1, 0x6e, 0x07, 0xd5, 0x00, 0x00, 0x00, 0x10},
1185 /* {0xc1, 0x6e, 0x16, 0x49, 0x40, 0x45, 0x00, 0x10}, */
1189 static const u8 po2030n_sensor_init[][8] = {
1190 {0xa1, 0x6e, 0x1e, 0x1a, 0x00, 0x00, 0x00, 0x10},
1191 {0xa1, 0x6e, 0x1f, 0x99, 0x00, 0x00, 0x00, 0x10},
1192 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1193 {0xa1, 0x6e, 0x1e, 0x0a, 0x00, 0x00, 0x00, 0x10},
1194 {0xa1, 0x6e, 0x1f, 0x19, 0x00, 0x00, 0x00, 0x10},
1195 {0xdd, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 10ms */
1196 {0xa1, 0x6e, 0x20, 0x44, 0x00, 0x00, 0x00, 0x10},
1197 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1198 {0xa1, 0x6e, 0x05, 0x70, 0x00, 0x00, 0x00, 0x10},
1199 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1200 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1201 {0xd1, 0x6e, 0x08, 0x00, 0xd0, 0x00, 0x08, 0x10},
1202 {0xd1, 0x6e, 0x0c, 0x03, 0x50, 0x01, 0xe8, 0x10},
1203 {0xd1, 0x6e, 0x1d, 0x20, 0x0a, 0x19, 0x44, 0x10},
1204 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1205 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x00, 0x10},
1206 {0xd1, 0x6e, 0x29, 0x00, 0x00, 0x00, 0x00, 0x10},
1207 {0xd1, 0x6e, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1208 {0xd1, 0x6e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
1209 {0xd1, 0x6e, 0x35, 0x00, 0x00, 0x00, 0x00, 0x10},
1210 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10},
1211 {0xd1, 0x6e, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x10},
1212 {0xd1, 0x6e, 0x41, 0x00, 0x00, 0x00, 0x00, 0x10},
1213 {0xd1, 0x6e, 0x45, 0x00, 0x00, 0x00, 0x00, 0x10},
1214 {0xd1, 0x6e, 0x49, 0x00, 0x00, 0x00, 0x00, 0x10},
1215 {0xd1, 0x6e, 0x4d, 0x00, 0x00, 0x00, 0xed, 0x10},
1216 {0xd1, 0x6e, 0x51, 0x17, 0x4a, 0x2f, 0xc0, 0x10},
1217 {0xd1, 0x6e, 0x55, 0x00, 0x00, 0x00, 0x00, 0x10},
1218 {0xd1, 0x6e, 0x59, 0x00, 0x00, 0x00, 0x00, 0x10},
1219 {0xd1, 0x6e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x10},
1220 {0xd1, 0x6e, 0x61, 0x00, 0x00, 0x00, 0x00, 0x10},
1221 {0xd1, 0x6e, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10},
1222 {0xd1, 0x6e, 0x69, 0x00, 0x00, 0x00, 0x00, 0x10},
1223 {0xd1, 0x6e, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10},
1224 {0xd1, 0x6e, 0x71, 0x00, 0x00, 0x00, 0x00, 0x10},
1225 {0xd1, 0x6e, 0x75, 0x00, 0x00, 0x00, 0x00, 0x10},
1226 {0xd1, 0x6e, 0x79, 0x00, 0x00, 0x00, 0x00, 0x10},
1227 {0xd1, 0x6e, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x10},
1228 {0xd1, 0x6e, 0x81, 0x00, 0x00, 0x00, 0x00, 0x10},
1229 {0xd1, 0x6e, 0x85, 0x00, 0x00, 0x00, 0x08, 0x10},
1230 {0xd1, 0x6e, 0x89, 0x01, 0xe8, 0x00, 0x01, 0x10},
1231 {0xa1, 0x6e, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x10},
1232 {0xd1, 0x6e, 0x21, 0x00, 0x00, 0x00, 0x00, 0x10},
1233 {0xd1, 0x6e, 0x25, 0x00, 0x00, 0x00, 0x01, 0x10},
1234 {0xd1, 0x6e, 0x29, 0xe6, 0x00, 0xbd, 0x03, 0x10},
1235 {0xd1, 0x6e, 0x2d, 0x41, 0x38, 0x68, 0x40, 0x10},
1236 {0xd1, 0x6e, 0x31, 0x2b, 0x00, 0x36, 0x00, 0x10},
1237 {0xd1, 0x6e, 0x35, 0x30, 0x30, 0x08, 0x00, 0x10},
1238 {0xd1, 0x6e, 0x39, 0x00, 0x00, 0x33, 0x06, 0x10},
1239 {0xb1, 0x6e, 0x3d, 0x06, 0x02, 0x00, 0x00, 0x10},
1242 static const u8 po2030n_sensor_param1[][8] = {
1243 {0xa1, 0x6e, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x10},
1244 {0xdd, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 8ms */
1245 {0xa1, 0x6e, 0x1b, 0xf4, 0x00, 0x00, 0x00, 0x10},
1246 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1247 {0xd1, 0x6e, 0x16, 0x50, 0x40, 0x49, 0x40, 0x10},
1249 {0xa1, 0x6e, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x10},
1250 {0xa1, 0x6e, 0x04, 0x03, 0x00, 0x00, 0x00, 0x10},
1251 {0xa1, 0x6e, 0x05, 0x6f, 0x00, 0x00, 0x00, 0x10},
1252 {0xa1, 0x6e, 0x06, 0x02, 0x00, 0x00, 0x00, 0x10},
1253 {0xa1, 0x6e, 0x07, 0x25, 0x00, 0x00, 0x00, 0x10},
1254 {0xa1, 0x6e, 0x15, 0x04, 0x00, 0x00, 0x00, 0x10},
1255 {0xc1, 0x6e, 0x16, 0x52, 0x40, 0x48, 0x00, 0x10},
1257 {0xa1, 0x6e, 0x15, 0x0f, 0x00, 0x00, 0x00, 0x10},
1258 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1259 {0xa1, 0x6e, 0x1a, 0x05, 0x00, 0x00, 0x00, 0x10},
1260 {0xdd, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 5ms */
1261 {0xa1, 0x6e, 0x1b, 0x53, 0x00, 0x00, 0x00, 0x10},
1265 static const u8 soi768_sensor_init[][8] = {
1266 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
1267 {0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 96ms */
1268 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
1269 {0xa1, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
1270 {0xa1, 0x21, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x10},
1271 {0xa1, 0x21, 0x19, 0x00, 0x00, 0x00, 0x00, 0x10},
1274 static const u8 soi768_sensor_param1[][8] = {
1275 {0xa1, 0x21, 0x10, 0x10, 0x00, 0x00, 0x00, 0x10},
1276 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10},
1277 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
1278 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1279 {0xb1, 0x21, 0x01, 0x7f, 0x7f, 0x00, 0x00, 0x10},
1281 /* {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1282 /* {0xa1, 0x21, 0x2d, 0x25, 0x00, 0x00, 0x00, 0x10}, */
1283 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10},
1284 /* {0xb1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, */
1285 {0xa1, 0x21, 0x02, 0x8d, 0x00, 0x00, 0x00, 0x10},
1286 /* the next sequence should be used for auto gain */
1287 {0xa1, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10},
1288 /* global gain ? : 07 - change with 0x15 at the end */
1289 {0xa1, 0x21, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x10}, /* ???? : 063f */
1290 {0xa1, 0x21, 0x04, 0x06, 0x00, 0x00, 0x00, 0x10},
1291 {0xb1, 0x21, 0x2d, 0x00, 0x02, 0x00, 0x00, 0x10},
1292 /* exposure ? : 0200 - change with 0x1e at the end */
1296 static const u8 sp80708_sensor_init[][8] = {
1297 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
1298 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
1299 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
1300 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
1301 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1302 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
1303 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
1304 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
1305 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
1306 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
1307 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
1308 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
1309 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
1310 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
1311 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
1312 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
1313 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
1314 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
1315 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
1316 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
1317 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
1318 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
1319 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
1320 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
1321 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
1322 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
1323 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
1324 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
1325 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
1326 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
1327 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
1328 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
1329 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
1330 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
1331 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
1332 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
1333 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
1334 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
1335 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
1336 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
1337 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
1338 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
1339 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
1340 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
1341 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
1342 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
1343 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
1344 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
1345 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
1346 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
1347 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
1348 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
1349 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
1350 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
1351 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
1352 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
1353 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
1354 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
1355 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
1356 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
1357 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
1358 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
1359 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
1360 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
1361 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
1362 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
1363 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
1364 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
1365 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
1366 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
1367 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
1370 static const u8 sp80708_sensor_param1[][8] = {
1371 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1372 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
1373 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
1374 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
1375 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
1376 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
1377 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
1381 static const u8 (*sensor_init[])[8] = {
1382 [SENSOR_ADCM1700] = adcm1700_sensor_init,
1383 [SENSOR_GC0307] = gc0307_sensor_init,
1384 [SENSOR_HV7131R] = hv7131r_sensor_init,
1385 [SENSOR_MI0360] = mi0360_sensor_init,
1386 [SENSOR_MI0360B] = mi0360b_sensor_init,
1387 [SENSOR_MO4000] = mo4000_sensor_init,
1388 [SENSOR_MT9V111] = mt9v111_sensor_init,
1389 [SENSOR_OM6802] = om6802_sensor_init,
1390 [SENSOR_OV7630] = ov7630_sensor_init,
1391 [SENSOR_OV7648] = ov7648_sensor_init,
1392 [SENSOR_OV7660] = ov7660_sensor_init,
1393 [SENSOR_PO1030] = po1030_sensor_init,
1394 [SENSOR_PO2030N] = po2030n_sensor_init,
1395 [SENSOR_SOI768] = soi768_sensor_init,
1396 [SENSOR_SP80708] = sp80708_sensor_init,
1399 /* read <len> bytes to gspca_dev->usb_buf */
1400 static void reg_r(struct gspca_dev *gspca_dev,
1405 if (gspca_dev->usb_err < 0)
1408 if (len > USB_BUF_SZ) {
1409 err("reg_r: buffer overflow");
1413 ret = usb_control_msg(gspca_dev->dev,
1414 usb_rcvctrlpipe(gspca_dev->dev, 0),
1416 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1418 gspca_dev->usb_buf, len,
1420 PDEBUG(D_USBI, "reg_r [%02x] -> %02x", value, gspca_dev->usb_buf[0]);
1422 err("reg_r err %d", ret);
1423 gspca_dev->usb_err = ret;
1427 static void reg_w1(struct gspca_dev *gspca_dev,
1433 if (gspca_dev->usb_err < 0)
1435 PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data);
1436 gspca_dev->usb_buf[0] = data;
1437 ret = usb_control_msg(gspca_dev->dev,
1438 usb_sndctrlpipe(gspca_dev->dev, 0),
1440 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1443 gspca_dev->usb_buf, 1,
1446 err("reg_w1 err %d", ret);
1447 gspca_dev->usb_err = ret;
1450 static void reg_w(struct gspca_dev *gspca_dev,
1457 if (gspca_dev->usb_err < 0)
1459 PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..",
1460 value, buffer[0], buffer[1]);
1462 if (len > USB_BUF_SZ) {
1463 err("reg_w: buffer overflow");
1467 memcpy(gspca_dev->usb_buf, buffer, len);
1468 ret = usb_control_msg(gspca_dev->dev,
1469 usb_sndctrlpipe(gspca_dev->dev, 0),
1471 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1473 gspca_dev->usb_buf, len,
1476 err("reg_w err %d", ret);
1477 gspca_dev->usb_err = ret;
1481 /* I2C write 1 byte */
1482 static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1484 struct sd *sd = (struct sd *) gspca_dev;
1487 if (gspca_dev->usb_err < 0)
1489 PDEBUG(D_USBO, "i2c_w1 [%02x] = %02x", reg, val);
1490 switch (sd->sensor) {
1491 case SENSOR_ADCM1700:
1493 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
1494 gspca_dev->usb_buf[0] = 0x80 | (2 << 4);
1496 default: /* i2c command = a1 (400 kHz) */
1497 gspca_dev->usb_buf[0] = 0x81 | (2 << 4);
1500 gspca_dev->usb_buf[1] = sd->i2c_addr;
1501 gspca_dev->usb_buf[2] = reg;
1502 gspca_dev->usb_buf[3] = val;
1503 gspca_dev->usb_buf[4] = 0;
1504 gspca_dev->usb_buf[5] = 0;
1505 gspca_dev->usb_buf[6] = 0;
1506 gspca_dev->usb_buf[7] = 0x10;
1507 ret = usb_control_msg(gspca_dev->dev,
1508 usb_sndctrlpipe(gspca_dev->dev, 0),
1510 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1511 0x08, /* value = i2c */
1513 gspca_dev->usb_buf, 8,
1516 err("i2c_w1 err %d", ret);
1517 gspca_dev->usb_err = ret;
1521 /* I2C write 8 bytes */
1522 static void i2c_w8(struct gspca_dev *gspca_dev,
1527 if (gspca_dev->usb_err < 0)
1529 PDEBUG(D_USBO, "i2c_w8 [%02x] = %02x ..",
1530 buffer[2], buffer[3]);
1531 memcpy(gspca_dev->usb_buf, buffer, 8);
1532 ret = usb_control_msg(gspca_dev->dev,
1533 usb_sndctrlpipe(gspca_dev->dev, 0),
1535 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1536 0x08, 0, /* value, index */
1537 gspca_dev->usb_buf, 8,
1541 err("i2c_w8 err %d", ret);
1542 gspca_dev->usb_err = ret;
1546 /* sensor read 'len' (1..5) bytes in gspca_dev->usb_buf */
1547 static void i2c_r(struct gspca_dev *gspca_dev, u8 reg, int len)
1549 struct sd *sd = (struct sd *) gspca_dev;
1552 switch (sd->sensor) {
1553 case SENSOR_ADCM1700:
1555 case SENSOR_GC0307: /* i2c command = a0 (100 kHz) */
1556 mode[0] = 0x80 | 0x10;
1558 default: /* i2c command = 91 (400 kHz) */
1559 mode[0] = 0x81 | 0x10;
1562 mode[1] = sd->i2c_addr;
1569 i2c_w8(gspca_dev, mode);
1571 mode[0] = (mode[0] & 0x81) | (len << 4) | 0x02;
1573 i2c_w8(gspca_dev, mode);
1575 reg_r(gspca_dev, 0x0a, 5);
1578 static void i2c_w_seq(struct gspca_dev *gspca_dev,
1579 const u8 (*data)[8])
1581 while ((*data)[0] != 0) {
1582 if ((*data)[0] != 0xdd)
1583 i2c_w8(gspca_dev, *data);
1590 static void hv7131r_probe(struct gspca_dev *gspca_dev)
1592 i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */
1594 reg_w1(gspca_dev, 0x02, 0x66); /* Gpio on */
1596 i2c_r(gspca_dev, 0, 5); /* read sensor id */
1597 if (gspca_dev->usb_buf[0] == 0x02
1598 && gspca_dev->usb_buf[1] == 0x09
1599 && gspca_dev->usb_buf[2] == 0x01
1600 && gspca_dev->usb_buf[3] == 0x00
1601 && gspca_dev->usb_buf[4] == 0x00) {
1602 PDEBUG(D_PROBE, "Sensor sn9c102P HV7131R found");
1605 PDEBUG(D_PROBE, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
1606 gspca_dev->usb_buf[0], gspca_dev->usb_buf[1],
1607 gspca_dev->usb_buf[2]);
1610 static void mi0360_probe(struct gspca_dev *gspca_dev)
1612 struct sd *sd = (struct sd *) gspca_dev;
1615 static const u8 probe_tb[][4][8] = {
1617 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1618 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1619 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1620 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1623 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1624 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1625 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1630 for (i = 0; i < ARRAY_SIZE(probe_tb); i++) {
1631 reg_w1(gspca_dev, 0x17, 0x62);
1632 reg_w1(gspca_dev, 0x01, 0x08);
1633 for (j = 0; j < 3; j++)
1634 i2c_w8(gspca_dev, probe_tb[i][j]);
1636 reg_r(gspca_dev, 0x0a, 5);
1637 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1638 if (probe_tb[i][3][0] != 0)
1639 i2c_w8(gspca_dev, probe_tb[i][3]);
1640 reg_w1(gspca_dev, 0x01, 0x29);
1641 reg_w1(gspca_dev, 0x17, 0x42);
1645 if (gspca_dev->usb_err < 0)
1649 PDEBUG(D_PROBE, "Sensor mi0360b");
1650 sd->sensor = SENSOR_MI0360B;
1653 PDEBUG(D_PROBE, "Sensor mt9v111");
1654 sd->sensor = SENSOR_MT9V111;
1657 PDEBUG(D_PROBE, "Sensor mi0360");
1660 PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val);
1665 static void ov7630_probe(struct gspca_dev *gspca_dev)
1667 struct sd *sd = (struct sd *) gspca_dev;
1671 reg_w1(gspca_dev, 0x17, 0x62);
1672 reg_w1(gspca_dev, 0x01, 0x08);
1673 sd->i2c_addr = 0x21;
1674 i2c_r(gspca_dev, 0x0a, 2);
1675 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1676 reg_w1(gspca_dev, 0x01, 0x29);
1677 reg_w1(gspca_dev, 0x17, 0x42);
1678 if (gspca_dev->usb_err < 0)
1680 if (val == 0x7628) { /* soi768 */
1681 sd->sensor = SENSOR_SOI768;
1682 /*fixme: only valid for 0c45:613e?*/
1683 gspca_dev->cam.input_flags =
1684 V4L2_IN_ST_VFLIP | V4L2_IN_ST_HFLIP;
1685 PDEBUG(D_PROBE, "Sensor soi768");
1688 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1691 static void ov7648_probe(struct gspca_dev *gspca_dev)
1693 struct sd *sd = (struct sd *) gspca_dev;
1697 reg_w1(gspca_dev, 0x17, 0x62);
1698 reg_w1(gspca_dev, 0x01, 0x08);
1699 sd->i2c_addr = 0x21;
1700 i2c_r(gspca_dev, 0x0a, 2);
1701 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1702 reg_w1(gspca_dev, 0x01, 0x29);
1703 reg_w1(gspca_dev, 0x17, 0x42);
1704 if ((val & 0xff00) == 0x7600) { /* ov76xx */
1705 PDEBUG(D_PROBE, "Sensor ov%04x", val);
1710 reg_w1(gspca_dev, 0x17, 0x62);
1711 reg_w1(gspca_dev, 0x01, 0x08);
1712 sd->i2c_addr = 0x6e;
1713 i2c_r(gspca_dev, 0x00, 2);
1714 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1715 reg_w1(gspca_dev, 0x01, 0x29);
1716 reg_w1(gspca_dev, 0x17, 0x42);
1717 if (gspca_dev->usb_err < 0)
1719 if (val == 0x1030) { /* po1030 */
1720 PDEBUG(D_PROBE, "Sensor po1030");
1721 sd->sensor = SENSOR_PO1030;
1725 err("Unknown sensor %04x", val);
1728 /* 0c45:6142 sensor may be po2030n, gc0305 or gc0307 */
1729 static void po2030n_probe(struct gspca_dev *gspca_dev)
1731 struct sd *sd = (struct sd *) gspca_dev;
1735 reg_w1(gspca_dev, 0x17, 0x62);
1736 reg_w1(gspca_dev, 0x01, 0x08);
1737 reg_w1(gspca_dev, 0x02, 0x22);
1738 sd->i2c_addr = 0x21;
1739 i2c_r(gspca_dev, 0x00, 1);
1740 val = gspca_dev->usb_buf[4];
1741 reg_w1(gspca_dev, 0x01, 0x29); /* reset */
1742 reg_w1(gspca_dev, 0x17, 0x42);
1743 if (val == 0x99) { /* gc0307 (?) */
1744 PDEBUG(D_PROBE, "Sensor gc0307");
1745 sd->sensor = SENSOR_GC0307;
1750 reg_w1(gspca_dev, 0x17, 0x62);
1751 reg_w1(gspca_dev, 0x01, 0x0a);
1752 sd->i2c_addr = 0x6e;
1753 i2c_r(gspca_dev, 0x00, 2);
1754 val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1755 reg_w1(gspca_dev, 0x01, 0x29);
1756 reg_w1(gspca_dev, 0x17, 0x42);
1757 if (gspca_dev->usb_err < 0)
1759 if (val == 0x2030) {
1760 PDEBUG(D_PROBE, "Sensor po2030n");
1761 /* sd->sensor = SENSOR_PO2030N; */
1763 err("Unknown sensor ID %04x", val);
1767 static void bridge_init(struct gspca_dev *gspca_dev,
1770 struct sd *sd = (struct sd *) gspca_dev;
1773 static const u8 reg9a_def[] =
1774 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1775 static const u8 reg9a_spec[] =
1776 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1777 static const u8 regd4[] = {0x60, 0x00, 0x00};
1779 /* sensor clock already enabled in sd_init */
1780 /* reg_w1(gspca_dev, 0xf1, 0x00); */
1781 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
1783 /* configure gpio */
1784 reg0102[0] = sn9c1xx[1];
1785 reg0102[1] = sn9c1xx[2];
1786 if (gspca_dev->audio)
1787 reg0102[1] |= 0x04; /* keep the audio connection */
1788 reg_w(gspca_dev, 0x01, reg0102, 2);
1789 reg_w(gspca_dev, 0x08, &sn9c1xx[8], 2);
1790 reg_w(gspca_dev, 0x17, &sn9c1xx[0x17], 5);
1791 switch (sd->sensor) {
1795 case SENSOR_PO2030N:
1797 case SENSOR_SP80708:
1804 reg_w(gspca_dev, 0x9a, reg9a, 6);
1806 reg_w(gspca_dev, 0xd4, regd4, sizeof regd4);
1808 reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f);
1810 switch (sd->sensor) {
1811 case SENSOR_ADCM1700:
1812 reg_w1(gspca_dev, 0x01, 0x43);
1813 reg_w1(gspca_dev, 0x17, 0x62);
1814 reg_w1(gspca_dev, 0x01, 0x42);
1815 reg_w1(gspca_dev, 0x01, 0x42);
1819 reg_w1(gspca_dev, 0x01, 0x61);
1820 reg_w1(gspca_dev, 0x17, 0x22);
1821 reg_w1(gspca_dev, 0x01, 0x60);
1822 reg_w1(gspca_dev, 0x01, 0x40);
1825 case SENSOR_MI0360B:
1826 reg_w1(gspca_dev, 0x01, 0x61);
1827 reg_w1(gspca_dev, 0x17, 0x60);
1828 reg_w1(gspca_dev, 0x01, 0x60);
1829 reg_w1(gspca_dev, 0x01, 0x40);
1831 case SENSOR_MT9V111:
1832 reg_w1(gspca_dev, 0x01, 0x61);
1833 reg_w1(gspca_dev, 0x17, 0x61);
1834 reg_w1(gspca_dev, 0x01, 0x60);
1835 reg_w1(gspca_dev, 0x01, 0x40);
1839 reg_w1(gspca_dev, 0x02, 0x73);
1840 reg_w1(gspca_dev, 0x17, 0x60);
1841 reg_w1(gspca_dev, 0x01, 0x22);
1843 reg_w1(gspca_dev, 0x01, 0x62);
1844 reg_w1(gspca_dev, 0x17, 0x64);
1845 reg_w1(gspca_dev, 0x17, 0x64);
1846 reg_w1(gspca_dev, 0x01, 0x42);
1848 reg_w1(gspca_dev, 0x01, 0x42);
1849 i2c_w8(gspca_dev, om6802_init0[0]);
1850 i2c_w8(gspca_dev, om6802_init0[1]);
1852 reg_w1(gspca_dev, 0x02, 0x71);
1856 reg_w1(gspca_dev, 0x01, 0x61);
1857 reg_w1(gspca_dev, 0x17, 0xe2);
1858 reg_w1(gspca_dev, 0x01, 0x60);
1859 reg_w1(gspca_dev, 0x01, 0x40);
1862 reg_w1(gspca_dev, 0x01, 0x63);
1863 reg_w1(gspca_dev, 0x17, 0x20);
1864 reg_w1(gspca_dev, 0x01, 0x62);
1865 reg_w1(gspca_dev, 0x01, 0x42);
1869 reg_w1(gspca_dev, 0x01, 0x61);
1870 reg_w1(gspca_dev, 0x17, 0x20);
1871 reg_w1(gspca_dev, 0x01, 0x60);
1872 reg_w1(gspca_dev, 0x01, 0x40);
1874 case SENSOR_PO2030N:
1876 reg_w1(gspca_dev, 0x01, 0x63);
1877 reg_w1(gspca_dev, 0x17, 0x20);
1878 reg_w1(gspca_dev, 0x01, 0x62);
1879 reg_w1(gspca_dev, 0x01, 0x42);
1881 case SENSOR_SP80708:
1882 reg_w1(gspca_dev, 0x01, 0x63);
1883 reg_w1(gspca_dev, 0x17, 0x20);
1884 reg_w1(gspca_dev, 0x01, 0x62);
1885 reg_w1(gspca_dev, 0x01, 0x42);
1887 reg_w1(gspca_dev, 0x02, 0x62);
1890 /* case SENSOR_HV7131R: */
1891 /* case SENSOR_MI0360: */
1892 /* case SENSOR_MO4000: */
1893 reg_w1(gspca_dev, 0x01, 0x43);
1894 reg_w1(gspca_dev, 0x17, 0x61);
1895 reg_w1(gspca_dev, 0x01, 0x42);
1896 if (sd->sensor == SENSOR_HV7131R
1897 && sd->bridge == BRIDGE_SN9C102P)
1898 hv7131r_probe(gspca_dev);
1903 /* this function is called at probe time */
1904 static int sd_config(struct gspca_dev *gspca_dev,
1905 const struct usb_device_id *id)
1907 struct sd *sd = (struct sd *) gspca_dev;
1910 sd->bridge = id->driver_info >> 16;
1911 sd->sensor = id->driver_info;
1913 cam = &gspca_dev->cam;
1914 if (sd->sensor == SENSOR_ADCM1700) {
1915 cam->cam_mode = cif_mode;
1916 cam->nmodes = ARRAY_SIZE(cif_mode);
1918 cam->cam_mode = vga_mode;
1919 cam->nmodes = ARRAY_SIZE(vga_mode);
1921 cam->npkt = 24; /* 24 packets per ISOC message */
1923 sd->brightness = BRIGHTNESS_DEF;
1924 sd->contrast = CONTRAST_DEF;
1925 sd->colors = COLOR_DEF;
1926 sd->blue = BLUE_BALANCE_DEF;
1927 sd->red = RED_BALANCE_DEF;
1928 sd->gamma = GAMMA_DEF;
1929 sd->autogain = AUTOGAIN_DEF;
1931 sd->vflip = VFLIP_DEF;
1932 switch (sd->sensor) {
1934 sd->sharpness = 0x10;
1937 sd->sharpness = SHARPNESS_DEF;
1940 sd->infrared = INFRARED_DEF;
1941 sd->freq = FREQ_DEF;
1942 sd->quality = QUALITY_DEF;
1948 /* this function is called at probe and resume time */
1949 static int sd_init(struct gspca_dev *gspca_dev)
1951 struct sd *sd = (struct sd *) gspca_dev;
1953 u8 regGpio[] = { 0x29, 0x74 }; /* with audio */
1956 /* setup a selector by bridge */
1957 reg_w1(gspca_dev, 0xf1, 0x01);
1958 reg_r(gspca_dev, 0x00, 1);
1959 reg_w1(gspca_dev, 0xf1, gspca_dev->usb_buf[0]);
1960 reg_r(gspca_dev, 0x00, 1); /* get sonix chip id */
1961 regF1 = gspca_dev->usb_buf[0];
1962 if (gspca_dev->usb_err < 0)
1963 return gspca_dev->usb_err;
1964 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
1965 switch (sd->bridge) {
1966 case BRIDGE_SN9C102P:
1969 reg_w1(gspca_dev, 0x02, regGpio[1]);
1971 case BRIDGE_SN9C105:
1974 if (sd->sensor == SENSOR_MI0360)
1975 mi0360_probe(gspca_dev);
1976 reg_w(gspca_dev, 0x01, regGpio, 2);
1978 case BRIDGE_SN9C120:
1981 switch (sd->sensor) {
1983 mi0360_probe(gspca_dev);
1986 ov7630_probe(gspca_dev);
1989 ov7648_probe(gspca_dev);
1991 case SENSOR_PO2030N:
1992 po2030n_probe(gspca_dev);
1995 regGpio[1] = 0x70; /* no audio */
1996 reg_w(gspca_dev, 0x01, regGpio, 2);
1999 /* case BRIDGE_SN9C110: */
2000 /* case BRIDGE_SN9C325: */
2003 reg_w1(gspca_dev, 0x02, 0x62);
2007 /* Note we do not disable the sensor clock here (power saving mode),
2008 as that also disables the button on the cam. */
2009 reg_w1(gspca_dev, 0xf1, 0x00);
2011 /* set the i2c address */
2012 sn9c1xx = sn_tb[sd->sensor];
2013 sd->i2c_addr = sn9c1xx[9];
2015 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
2017 return gspca_dev->usb_err;
2020 static u32 setexposure(struct gspca_dev *gspca_dev,
2023 struct sd *sd = (struct sd *) gspca_dev;
2025 switch (sd->sensor) {
2026 case SENSOR_GC0307: {
2029 /* expo = 0..255 -> a = 19..43 */
2030 a = 19 + expo * 25 / 256;
2031 i2c_w1(gspca_dev, 0x68, a);
2033 b = a * a * 4; /* heuristic */
2034 i2c_w1(gspca_dev, 0x03, b >> 8);
2035 i2c_w1(gspca_dev, 0x04, b);
2038 case SENSOR_HV7131R: {
2040 { 0xc1, 0x11, 0x25, 0x00, 0x00, 0x00, 0x00, 0x16 };
2042 Expodoit[3] = expo >> 16;
2043 Expodoit[4] = expo >> 8;
2045 i2c_w8(gspca_dev, Expodoit);
2049 case SENSOR_MI0360B: {
2050 u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
2051 { 0xb1, 0x5d, 0x09, 0x00, 0x00, 0x00, 0x00, 0x16 };
2052 static const u8 doit[] = /* update sensor */
2053 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
2054 static const u8 sensorgo[] = /* sensor on */
2055 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
2059 else if (expo < 0x0001)
2061 expoMi[3] = expo >> 8;
2063 i2c_w8(gspca_dev, expoMi);
2064 i2c_w8(gspca_dev, doit);
2065 i2c_w8(gspca_dev, sensorgo);
2068 case SENSOR_MO4000: {
2070 { 0xa1, 0x21, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x10 };
2072 { 0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10 };
2073 static const u8 gainMo[] =
2074 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
2078 else if (expo < 0x0001)
2080 expoMof[3] = (expo & 0x03fc) >> 2;
2081 i2c_w8(gspca_dev, expoMof);
2082 expoMo10[3] = ((expo & 0x1c00) >> 10)
2083 | ((expo & 0x0003) << 4);
2084 i2c_w8(gspca_dev, expoMo10);
2085 i2c_w8(gspca_dev, gainMo);
2086 PDEBUG(D_FRAM, "set exposure %d",
2087 ((expoMo10[3] & 0x07) << 10)
2089 | ((expoMo10[3] & 0x30) >> 4));
2092 case SENSOR_MT9V111: {
2094 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
2098 else if (expo < 0x0040)
2100 expo_c1[3] = expo >> 8;
2102 i2c_w8(gspca_dev, expo_c1);
2105 case SENSOR_OM6802: {
2107 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
2108 /* preset AGC - works when AutoExpo = off */
2114 gainOm[3] = expo >> 2;
2115 i2c_w8(gspca_dev, gainOm);
2116 reg_w1(gspca_dev, 0x96, expo >> 5);
2117 PDEBUG(D_FRAM, "set exposure %d", gainOm[3]);
2124 static void setbrightness(struct gspca_dev *gspca_dev)
2126 struct sd *sd = (struct sd *) gspca_dev;
2130 k2 = ((int) sd->brightness - 0x8000) >> 10;
2131 switch (sd->sensor) {
2132 case SENSOR_ADCM1700:
2134 k2 = 0; /* only positive Y offset */
2136 case SENSOR_HV7131R:
2137 expo = sd->brightness << 4;
2138 if (expo > 0x002dc6c0)
2140 else if (expo < 0x02a0)
2142 sd->exposure = setexposure(gspca_dev, expo);
2146 expo = sd->brightness >> 4;
2147 sd->exposure = setexposure(gspca_dev, expo);
2149 case SENSOR_MI0360B:
2150 expo = sd->brightness >> 6;
2151 sd->exposure = setexposure(gspca_dev, expo);
2154 case SENSOR_MT9V111:
2155 expo = sd->brightness >> 8;
2156 sd->exposure = setexposure(gspca_dev, expo);
2157 return; /* don't set the Y offset */
2159 expo = sd->brightness >> 6;
2160 sd->exposure = setexposure(gspca_dev, expo);
2161 k2 = sd->brightness >> 11;
2165 reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */
2168 static void setcontrast(struct gspca_dev *gspca_dev)
2170 struct sd *sd = (struct sd *) gspca_dev;
2174 k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */
2175 contrast[0] = (k2 + 1) / 2; /* red */
2177 contrast[2] = k2; /* green */
2179 contrast[4] = (k2 + 1) / 5; /* blue */
2181 reg_w(gspca_dev, 0x84, contrast, sizeof contrast);
2184 static void setcolors(struct gspca_dev *gspca_dev)
2186 struct sd *sd = (struct sd *) gspca_dev;
2189 u8 reg8a[12]; /* U & V gains */
2190 static const s16 uv_com[6] = { /* same as reg84 in signed decimal */
2191 -24, -38, 64, /* UR UG UB */
2192 62, -51, -9 /* VR VG VB */
2194 static const s16 uv_mi0360b[6] = {
2195 -20, -38, 64, /* UR UG UB */
2196 60, -51, -9 /* VR VG VB */
2199 if (sd->sensor == SENSOR_MI0360B)
2203 for (i = 0; i < 6; i++) {
2204 v = uv[i] * sd->colors / COLOR_DEF;
2206 reg8a[i * 2 + 1] = (v >> 8) & 0x0f;
2208 reg_w(gspca_dev, 0x8a, reg8a, sizeof reg8a);
2211 static void setredblue(struct gspca_dev *gspca_dev)
2213 struct sd *sd = (struct sd *) gspca_dev;
2215 reg_w1(gspca_dev, 0x05, sd->red);
2216 /* reg_w1(gspca_dev, 0x07, 32); */
2217 reg_w1(gspca_dev, 0x06, sd->blue);
2220 static void setgamma(struct gspca_dev *gspca_dev)
2222 struct sd *sd = (struct sd *) gspca_dev;
2225 const u8 *gamma_base;
2226 static const u8 delta[17] = {
2227 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
2228 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
2231 switch (sd->sensor) {
2232 case SENSOR_ADCM1700:
2233 gamma_base = gamma_spec_0;
2235 case SENSOR_HV7131R:
2236 case SENSOR_MI0360B:
2237 case SENSOR_MT9V111:
2238 gamma_base = gamma_spec_1;
2241 gamma_base = gamma_spec_2;
2243 case SENSOR_SP80708:
2244 gamma_base = gamma_spec_3;
2247 gamma_base = gamma_def;
2251 for (i = 0; i < sizeof gamma; i++)
2252 gamma[i] = gamma_base[i]
2253 + delta[i] * (sd->gamma - GAMMA_DEF) / 32;
2254 reg_w(gspca_dev, 0x20, gamma, sizeof gamma);
2257 static void setautogain(struct gspca_dev *gspca_dev)
2259 struct sd *sd = (struct sd *) gspca_dev;
2261 if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX))
2263 switch (sd->sensor) {
2265 case SENSOR_OV7648: {
2268 if (sd->sensor == SENSOR_OV7630)
2274 i2c_w1(&sd->gspca_dev, 0x13, comb);
2279 sd->ag_cnt = AG_CNT_START;
2284 /* hv7131r/ov7630/ov7648 only */
2285 static void setvflip(struct sd *sd)
2289 if (sd->gspca_dev.ctrl_dis & (1 << VFLIP_IDX))
2291 switch (sd->sensor) {
2292 case SENSOR_HV7131R:
2293 comn = 0x18; /* clkdiv = 1, ablcen = 1 */
2296 i2c_w1(&sd->gspca_dev, 0x01, comn); /* sctra */
2302 i2c_w1(&sd->gspca_dev, 0x75, comn);
2305 /* case SENSOR_OV7648: */
2309 i2c_w1(&sd->gspca_dev, 0x75, comn);
2314 static void setsharpness(struct sd *sd)
2316 reg_w1(&sd->gspca_dev, 0x99, sd->sharpness);
2319 static void setinfrared(struct sd *sd)
2321 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
2323 /*fixme: different sequence for StarCam Clip and StarCam 370i */
2325 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
2326 sd->infrared ? 0x66 : 0x64);
2329 static void setfreq(struct gspca_dev *gspca_dev)
2331 struct sd *sd = (struct sd *) gspca_dev;
2333 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
2335 if (sd->sensor == SENSOR_OV7660) {
2338 com8 = 0xdf; /* auto gain/wb/expo */
2340 case 0: /* Banding filter disabled */
2341 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
2344 i2c_w1(gspca_dev, 0x13, com8);
2345 i2c_w1(gspca_dev, 0x3b, 0x0a);
2348 i2c_w1(gspca_dev, 0x13, com8);
2349 i2c_w1(gspca_dev, 0x3b, 0x02);
2353 u8 reg2a = 0, reg2b = 0, reg2d = 0;
2355 /* Get reg2a / reg2d base values */
2356 switch (sd->sensor) {
2368 case 0: /* Banding filter disabled */
2370 case 1: /* 50 hz (filter on and framerate adj) */
2375 case 2: /* 60 hz (filter on, no framerate adj) */
2380 i2c_w1(gspca_dev, 0x2a, reg2a);
2381 i2c_w1(gspca_dev, 0x2b, reg2b);
2382 i2c_w1(gspca_dev, 0x2d, reg2d);
2386 static void setjpegqual(struct gspca_dev *gspca_dev)
2388 struct sd *sd = (struct sd *) gspca_dev;
2391 if (sd->jpegqual < 50)
2392 sc = 5000 / sd->jpegqual;
2394 sc = 200 - sd->jpegqual * 2;
2396 #error "No room enough in usb_buf for quantization table"
2398 for (i = 0; i < 64; i++)
2399 gspca_dev->usb_buf[i] =
2400 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
2401 usb_control_msg(gspca_dev->dev,
2402 usb_sndctrlpipe(gspca_dev->dev, 0),
2404 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2406 gspca_dev->usb_buf, 64,
2408 for (i = 0; i < 64; i++)
2409 gspca_dev->usb_buf[i] =
2410 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
2411 usb_control_msg(gspca_dev->dev,
2412 usb_sndctrlpipe(gspca_dev->dev, 0),
2414 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
2416 gspca_dev->usb_buf, 64,
2420 reg_w1(gspca_dev, 0x18, sd->reg18);
2423 /* -- start the camera -- */
2424 static int sd_start(struct gspca_dev *gspca_dev)
2426 struct sd *sd = (struct sd *) gspca_dev;
2430 const u8 (*init)[8];
2432 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
2433 static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
2434 static const u8 CA_adcm1700[] =
2435 { 0x14, 0xec, 0x0a, 0xf6 };
2436 static const u8 CA_po2030n[] =
2437 { 0x1e, 0xe2, 0x14, 0xec };
2438 static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
2439 static const u8 CE_gc0307[] =
2440 { 0x32, 0xce, 0x2d, 0xd3 };
2441 static const u8 CE_ov76xx[] =
2442 { 0x32, 0xdd, 0x32, 0xdd };
2443 static const u8 CE_po2030n[] =
2444 { 0x14, 0xe7, 0x1e, 0xdd };
2446 /* create the JPEG header */
2447 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
2448 0x21); /* JPEG 422 */
2449 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
2451 /* initialize the bridge */
2452 sn9c1xx = sn_tb[sd->sensor];
2453 bridge_init(gspca_dev, sn9c1xx);
2455 /* initialize the sensor */
2456 i2c_w_seq(gspca_dev, sensor_init[sd->sensor]);
2458 reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]);
2459 reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]);
2460 reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]);
2461 reg_w1(gspca_dev, 0x13, sn9c1xx[0x13]);
2462 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
2463 if (sd->sensor == SENSOR_ADCM1700) {
2464 reg_w1(gspca_dev, 0xd2, 0x3a); /* AE_H_SIZE = 116 */
2465 reg_w1(gspca_dev, 0xd3, 0x30); /* AE_V_SIZE = 96 */
2467 reg_w1(gspca_dev, 0xd2, 0x6a); /* AE_H_SIZE = 212 */
2468 reg_w1(gspca_dev, 0xd3, 0x50); /* AE_V_SIZE = 160 */
2470 reg_w1(gspca_dev, 0xc6, 0x00);
2471 reg_w1(gspca_dev, 0xc7, 0x00);
2472 if (sd->sensor == SENSOR_ADCM1700) {
2473 reg_w1(gspca_dev, 0xc8, 0x2c); /* AW_H_STOP = 352 */
2474 reg_w1(gspca_dev, 0xc9, 0x24); /* AW_V_STOP = 288 */
2476 reg_w1(gspca_dev, 0xc8, 0x50); /* AW_H_STOP = 640 */
2477 reg_w1(gspca_dev, 0xc9, 0x3c); /* AW_V_STOP = 480 */
2479 reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]);
2480 switch (sd->sensor) {
2484 case SENSOR_MT9V111:
2485 case SENSOR_MI0360B:
2488 case SENSOR_ADCM1700:
2500 case SENSOR_PO2030N:
2507 reg_w1(gspca_dev, 0x17, reg17);
2509 reg_w1(gspca_dev, 0x05, 0x00); /* red */
2510 reg_w1(gspca_dev, 0x07, 0x00); /* green */
2511 reg_w1(gspca_dev, 0x06, 0x00); /* blue */
2512 reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]);
2514 setgamma(gspca_dev);
2516 /*fixme: 8 times with all zeroes and 1 or 2 times with normal values */
2517 for (i = 0; i < 8; i++)
2518 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2519 switch (sd->sensor) {
2520 case SENSOR_ADCM1700:
2522 case SENSOR_SP80708:
2523 reg_w1(gspca_dev, 0x9a, 0x05);
2526 case SENSOR_MT9V111:
2527 case SENSOR_MI0360B:
2528 reg_w1(gspca_dev, 0x9a, 0x07);
2532 reg_w1(gspca_dev, 0x9a, 0x0a);
2534 case SENSOR_PO2030N:
2536 reg_w1(gspca_dev, 0x9a, 0x06);
2539 reg_w1(gspca_dev, 0x9a, 0x08);
2544 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
2545 reg_w1(gspca_dev, 0x05, 0x20); /* red */
2546 reg_w1(gspca_dev, 0x07, 0x20); /* green */
2547 reg_w1(gspca_dev, 0x06, 0x20); /* blue */
2550 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
2552 reg1 = 0x46; /* 320x240: clk 48Mhz, video trf enable */
2554 reg1 = 0x06; /* 640x480: clk 24Mhz, video trf enable */
2555 reg17 = 0x61; /* 0x:20: enable sensor clock */
2556 switch (sd->sensor) {
2557 case SENSOR_ADCM1700:
2558 init = adcm1700_sensor_param1;
2563 init = gc0307_sensor_param1;
2567 case SENSOR_MI0360B:
2568 init = mi0360b_sensor_param1;
2569 reg1 &= ~0x02; /* don't inverse pin S_PWR_DN */
2574 /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
2575 reg1 = 0x06; /* clk 24Mz */
2577 reg17 = 0x22; /* 640 MCKSIZE */
2578 /* reg1 = 0x06; * 640 clk 24Mz (done) */
2581 case SENSOR_MT9V111:
2582 init = mt9v111_sensor_param1;
2584 reg1 = 0x04; /* 320 clk 48Mhz */
2586 /* reg1 = 0x06; * 640 clk 24Mz (done) */
2591 init = om6802_sensor_param1;
2592 reg17 = 0x64; /* 640 MCKSIZE */
2595 init = ov7630_sensor_param1;
2600 init = ov7648_sensor_param1;
2602 /* reg1 = 0x42; * 42 - 46? */
2605 init = ov7660_sensor_param1;
2606 if (sd->bridge == BRIDGE_SN9C120) {
2607 if (mode) { /* 320x240 - 160x120 */
2609 reg1 = 0x44; /* 48 Mhz, video trf eneble */
2613 reg1 = 0x06; /* 24 Mhz, video trf eneble
2614 * inverse power down */
2618 init = po1030_sensor_param1;
2622 case SENSOR_PO2030N:
2623 init = po2030n_sensor_param1;
2628 init = soi768_sensor_param1;
2633 /* case SENSOR_SP80708: */
2634 init = sp80708_sensor_param1;
2636 /*?? reg1 = 0x04; * 320 clk 48Mhz */
2638 reg1 = 0x46; /* 640 clk 48Mz */
2644 /* more sensor initialization - param1 */
2646 i2c_w_seq(gspca_dev, init);
2650 reg_w(gspca_dev, 0xc0, C0, 6);
2651 switch (sd->sensor) {
2652 case SENSOR_ADCM1700:
2655 reg_w(gspca_dev, 0xca, CA_adcm1700, 4);
2657 case SENSOR_PO2030N:
2658 reg_w(gspca_dev, 0xca, CA_po2030n, 4);
2661 reg_w(gspca_dev, 0xca, CA, 4);
2664 switch (sd->sensor) {
2665 case SENSOR_ADCM1700:
2670 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
2673 reg_w(gspca_dev, 0xce, CE_gc0307, 4);
2675 case SENSOR_PO2030N:
2676 reg_w(gspca_dev, 0xce, CE_po2030n, 4);
2679 reg_w(gspca_dev, 0xce, CE, 4);
2680 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
2685 /* here change size mode 0 -> VGA; 1 -> CIF */
2686 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
2687 reg_w1(gspca_dev, 0x18, sd->reg18);
2688 setjpegqual(gspca_dev);
2690 reg_w1(gspca_dev, 0x17, reg17);
2691 reg_w1(gspca_dev, 0x01, reg1);
2694 setbrightness(gspca_dev);
2695 setcontrast(gspca_dev);
2696 setcolors(gspca_dev);
2697 setautogain(gspca_dev);
2699 return gspca_dev->usb_err;
2702 static void sd_stopN(struct gspca_dev *gspca_dev)
2704 struct sd *sd = (struct sd *) gspca_dev;
2705 static const u8 stophv7131[] =
2706 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
2707 static const u8 stopmi0360[] =
2708 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
2709 static const u8 stopov7648[] =
2710 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
2711 static const u8 stopsoi768[] =
2712 { 0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10 };
2717 switch (sd->sensor) {
2721 case SENSOR_HV7131R:
2722 i2c_w8(gspca_dev, stophv7131);
2726 case SENSOR_MI0360B:
2727 i2c_w8(gspca_dev, stopmi0360);
2731 i2c_w8(gspca_dev, stopov7648);
2733 case SENSOR_MT9V111:
2739 i2c_w8(gspca_dev, stopsoi768);
2743 sn9c1xx = sn_tb[sd->sensor];
2744 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2745 reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]);
2746 reg_w1(gspca_dev, 0x01, sn9c1xx[1]);
2747 reg_w1(gspca_dev, 0x01, data);
2748 /* Don't disable sensor clock as that disables the button on the cam */
2749 /* reg_w1(gspca_dev, 0xf1, 0x01); */
2752 static void do_autogain(struct gspca_dev *gspca_dev)
2754 struct sd *sd = (struct sd *) gspca_dev;
2760 /* Thanks S., without your advice, autobright should not work :) */
2763 if (--sd->ag_cnt >= 0)
2765 sd->ag_cnt = AG_CNT_START;
2767 delta = atomic_read(&sd->avg_lum);
2768 PDEBUG(D_FRAM, "mean lum %d", delta);
2769 if (delta < luma_mean - luma_delta ||
2770 delta > luma_mean + luma_delta) {
2771 switch (sd->sensor) {
2773 expotimes = sd->exposure;
2774 expotimes += (luma_mean - delta) >> 6;
2777 sd->exposure = setexposure(gspca_dev,
2778 (unsigned int) expotimes);
2780 case SENSOR_HV7131R:
2781 expotimes = sd->exposure >> 8;
2782 expotimes += (luma_mean - delta) >> 4;
2785 sd->exposure = setexposure(gspca_dev,
2786 (unsigned int) (expotimes << 8));
2789 expotimes = sd->exposure;
2790 expotimes += (luma_mean - delta) >> 2;
2793 sd->exposure = setexposure(gspca_dev,
2794 (unsigned int) expotimes);
2795 setredblue(gspca_dev);
2798 /* case SENSOR_MO4000: */
2799 /* case SENSOR_MI0360: */
2800 /* case SENSOR_MI0360B: */
2801 /* case SENSOR_MT9V111: */
2802 expotimes = sd->exposure;
2803 expotimes += (luma_mean - delta) >> 6;
2806 sd->exposure = setexposure(gspca_dev,
2807 (unsigned int) expotimes);
2808 setredblue(gspca_dev);
2814 /* scan the URB packets */
2815 /* This function is run at interrupt level. */
2816 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2817 u8 *data, /* isoc packet */
2818 int len) /* iso packet length */
2820 struct sd *sd = (struct sd *) gspca_dev;
2823 /* the image ends on a 64 bytes block starting with
2824 * ff d9 ff ff 00 c4 c4 96
2825 * and followed by various information including luminosity */
2826 /* this block may be splitted between two packets */
2827 /* a new image always starts in a new packet */
2828 switch (gspca_dev->last_packet_type) {
2829 case DISCARD_PACKET: /* restart image building */
2831 if (sof >= 0 && data[sof] == 0xff && data[sof + 1] == 0xd9)
2832 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2834 case LAST_PACKET: /* put the JPEG 422 header */
2835 gspca_frame_add(gspca_dev, FIRST_PACKET,
2836 sd->jpeg_hdr, JPEG_HDR_SZ);
2839 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2841 data = gspca_dev->image;
2844 sof = gspca_dev->image_len - 64;
2845 if (data[sof] != 0xff
2846 || data[sof + 1] != 0xd9)
2849 /* end of image found - remove the trailing data */
2850 gspca_dev->image_len = sof + 2;
2851 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2858 avg_lum = ((data[sof + 29] << 8) | data[sof + 30]) >> 6;
2860 avg_lum += ((data[sof + 33] << 8) | data[sof + 34]) >> 6;
2862 avg_lum += ((data[sof + 25] << 8) | data[sof + 26]) >> 6;
2864 avg_lum += ((data[sof + 37] << 8) | data[sof + 38]) >> 6;
2866 avg_lum += ((data[sof + 31] << 8) | data[sof + 32]) >> 4;
2868 atomic_set(&sd->avg_lum, avg_lum);
2871 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2873 struct sd *sd = (struct sd *) gspca_dev;
2875 sd->brightness = val;
2876 if (gspca_dev->streaming)
2877 setbrightness(gspca_dev);
2878 return gspca_dev->usb_err;
2881 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
2883 struct sd *sd = (struct sd *) gspca_dev;
2885 *val = sd->brightness;
2889 static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
2891 struct sd *sd = (struct sd *) gspca_dev;
2894 if (gspca_dev->streaming)
2895 setcontrast(gspca_dev);
2896 return gspca_dev->usb_err;
2899 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
2901 struct sd *sd = (struct sd *) gspca_dev;
2903 *val = sd->contrast;
2907 static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
2909 struct sd *sd = (struct sd *) gspca_dev;
2912 if (gspca_dev->streaming)
2913 setcolors(gspca_dev);
2914 return gspca_dev->usb_err;
2917 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2919 struct sd *sd = (struct sd *) gspca_dev;
2925 static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val)
2927 struct sd *sd = (struct sd *) gspca_dev;
2930 if (gspca_dev->streaming)
2931 setredblue(gspca_dev);
2932 return gspca_dev->usb_err;
2935 static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val)
2937 struct sd *sd = (struct sd *) gspca_dev;
2943 static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val)
2945 struct sd *sd = (struct sd *) gspca_dev;
2948 if (gspca_dev->streaming)
2949 setredblue(gspca_dev);
2950 return gspca_dev->usb_err;
2953 static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val)
2955 struct sd *sd = (struct sd *) gspca_dev;
2961 static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val)
2963 struct sd *sd = (struct sd *) gspca_dev;
2966 if (gspca_dev->streaming)
2967 setgamma(gspca_dev);
2968 return gspca_dev->usb_err;
2971 static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val)
2973 struct sd *sd = (struct sd *) gspca_dev;
2979 static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val)
2981 struct sd *sd = (struct sd *) gspca_dev;
2984 if (gspca_dev->streaming)
2985 setautogain(gspca_dev);
2986 return gspca_dev->usb_err;
2989 static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
2991 struct sd *sd = (struct sd *) gspca_dev;
2993 *val = sd->autogain;
2997 static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val)
2999 struct sd *sd = (struct sd *) gspca_dev;
3001 sd->sharpness = val;
3002 if (gspca_dev->streaming)
3004 return gspca_dev->usb_err;
3007 static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
3009 struct sd *sd = (struct sd *) gspca_dev;
3011 *val = sd->sharpness;
3015 static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val)
3017 struct sd *sd = (struct sd *) gspca_dev;
3020 if (gspca_dev->streaming)
3022 return gspca_dev->usb_err;
3025 static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val)
3027 struct sd *sd = (struct sd *) gspca_dev;
3033 static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val)
3035 struct sd *sd = (struct sd *) gspca_dev;
3038 if (gspca_dev->streaming)
3040 return gspca_dev->usb_err;
3043 static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
3045 struct sd *sd = (struct sd *) gspca_dev;
3047 *val = sd->infrared;
3051 static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
3053 struct sd *sd = (struct sd *) gspca_dev;
3056 if (gspca_dev->streaming)
3058 return gspca_dev->usb_err;
3061 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
3063 struct sd *sd = (struct sd *) gspca_dev;
3069 static int sd_set_jcomp(struct gspca_dev *gspca_dev,
3070 struct v4l2_jpegcompression *jcomp)
3072 struct sd *sd = (struct sd *) gspca_dev;
3074 if (jcomp->quality < QUALITY_MIN)
3075 sd->quality = QUALITY_MIN;
3076 else if (jcomp->quality > QUALITY_MAX)
3077 sd->quality = QUALITY_MAX;
3079 sd->quality = jcomp->quality;
3080 if (gspca_dev->streaming)
3081 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
3085 static int sd_get_jcomp(struct gspca_dev *gspca_dev,
3086 struct v4l2_jpegcompression *jcomp)
3088 struct sd *sd = (struct sd *) gspca_dev;
3090 memset(jcomp, 0, sizeof *jcomp);
3091 jcomp->quality = sd->quality;
3092 jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
3093 | V4L2_JPEG_MARKER_DQT;
3097 static int sd_querymenu(struct gspca_dev *gspca_dev,
3098 struct v4l2_querymenu *menu)
3101 case V4L2_CID_POWER_LINE_FREQUENCY:
3102 switch (menu->index) {
3103 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
3104 strcpy((char *) menu->name, "NoFliker");
3106 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
3107 strcpy((char *) menu->name, "50 Hz");
3109 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
3110 strcpy((char *) menu->name, "60 Hz");
3118 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3119 static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
3120 u8 *data, /* interrupt packet data */
3121 int len) /* interrupt packet length */
3125 if (len == 1 && data[0] == 1) {
3126 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
3127 input_sync(gspca_dev->input_dev);
3128 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
3129 input_sync(gspca_dev->input_dev);
3137 /* sub-driver description */
3138 static const struct sd_desc sd_desc = {
3139 .name = MODULE_NAME,
3141 .nctrls = ARRAY_SIZE(sd_ctrls),
3142 .config = sd_config,
3146 .pkt_scan = sd_pkt_scan,
3147 .dq_callback = do_autogain,
3148 .get_jcomp = sd_get_jcomp,
3149 .set_jcomp = sd_set_jcomp,
3150 .querymenu = sd_querymenu,
3151 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3152 .int_pkt_scan = sd_int_pkt_scan,
3156 /* -- module initialisation -- */
3157 #define BS(bridge, sensor) \
3158 .driver_info = (BRIDGE_ ## bridge << 16) \
3160 static const __devinitdata struct usb_device_id device_table[] = {
3161 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
3162 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
3163 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
3165 {USB_DEVICE(0x045e, 0x00f5), BS(SN9C105, OV7660)},
3166 {USB_DEVICE(0x045e, 0x00f7), BS(SN9C105, OV7660)},
3167 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
3168 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
3169 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
3170 {USB_DEVICE(0x06f8, 0x3004), BS(SN9C105, OV7660)},
3171 {USB_DEVICE(0x06f8, 0x3008), BS(SN9C105, OV7660)},
3172 /* {USB_DEVICE(0x0c45, 0x603a), BS(SN9C102P, OV7648)}, */
3173 {USB_DEVICE(0x0c45, 0x6040), BS(SN9C102P, HV7131R)},
3174 /* {USB_DEVICE(0x0c45, 0x607a), BS(SN9C102P, OV7648)}, */
3175 /* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
3176 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
3177 /* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
3178 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)},
3180 /* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
3181 /* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
3182 /* {USB_DEVICE(0x0c45, 0x60cc), BS(SN9C105, HV7131GP)}, */
3183 {USB_DEVICE(0x0c45, 0x60ce), BS(SN9C105, SP80708)},
3184 {USB_DEVICE(0x0c45, 0x60ec), BS(SN9C105, MO4000)},
3185 /* {USB_DEVICE(0x0c45, 0x60ef), BS(SN9C105, ICM105C)}, */
3186 /* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
3187 /* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
3188 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
3189 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
3190 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
3191 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
3193 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
3194 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
3195 /* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
3196 {USB_DEVICE(0x0c45, 0x610a), BS(SN9C120, OV7648)}, /*sn9c128*/
3197 {USB_DEVICE(0x0c45, 0x610b), BS(SN9C120, OV7660)}, /*sn9c128*/
3198 {USB_DEVICE(0x0c45, 0x610c), BS(SN9C120, HV7131R)}, /*sn9c128*/
3199 {USB_DEVICE(0x0c45, 0x610e), BS(SN9C120, OV7630)}, /*sn9c128*/
3200 /* {USB_DEVICE(0x0c45, 0x610f), BS(SN9C120, S5K53BEB)}, */
3201 /* {USB_DEVICE(0x0c45, 0x6122), BS(SN9C110, ICM105C)}, */
3202 /* {USB_DEVICE(0x0c45, 0x6123), BS(SN9C110, SanyoCCD)}, */
3203 {USB_DEVICE(0x0c45, 0x6128), BS(SN9C120, OM6802)}, /*sn9c325?*/
3205 {USB_DEVICE(0x0c45, 0x612a), BS(SN9C120, OV7648)}, /*sn9c325?*/
3206 {USB_DEVICE(0x0c45, 0x612b), BS(SN9C110, ADCM1700)},
3207 {USB_DEVICE(0x0c45, 0x612c), BS(SN9C110, MO4000)},
3208 {USB_DEVICE(0x0c45, 0x612e), BS(SN9C110, OV7630)},
3209 /* {USB_DEVICE(0x0c45, 0x612f), BS(SN9C110, ICM105C)}, */
3210 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
3211 {USB_DEVICE(0x0c45, 0x6130), BS(SN9C120, MI0360)},
3212 /* or MT9V111 / MI0360B */
3214 /* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
3215 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
3216 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
3217 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
3218 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
3220 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
3221 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
3222 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
3223 /* or GC0305 / GC0307 */
3224 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
3225 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
3226 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/
3229 MODULE_DEVICE_TABLE(usb, device_table);
3231 /* -- device connect -- */
3232 static int sd_probe(struct usb_interface *intf,
3233 const struct usb_device_id *id)
3235 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
3239 static struct usb_driver sd_driver = {
3240 .name = MODULE_NAME,
3241 .id_table = device_table,
3243 .disconnect = gspca_disconnect,
3245 .suspend = gspca_suspend,
3246 .resume = gspca_resume,
3250 /* -- module insert / remove -- */
3251 static int __init sd_mod_init(void)
3253 return usb_register(&sd_driver);
3255 static void __exit sd_mod_exit(void)
3257 usb_deregister(&sd_driver);
3260 module_init(sd_mod_init);
3261 module_exit(sd_mod_exit);