2 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) library
3 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
5 * V4L2 by Jean-Francois Moine <http://moinejf.free.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"
27 #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
29 MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
30 MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
31 MODULE_LICENSE("GPL");
33 /* specific webcam descriptor */
35 struct gspca_dev gspca_dev
; /* !! must be the first item */
47 u8 vflip
; /* ov7630/ov7648 only */
48 u8 infrared
; /* mt9v111 only */
49 u8 freq
; /* ov76xx only */
50 u8 quality
; /* image quality */
51 #define QUALITY_MIN 60
52 #define QUALITY_MAX 95
53 #define QUALITY_DEF 80
54 u8 jpegqual
; /* webcam quality */
59 #define AG_CNT_START 13
62 #define BRIDGE_SN9C102P 0
63 #define BRIDGE_SN9C105 1
64 #define BRIDGE_SN9C110 2
65 #define BRIDGE_SN9C120 3
66 u8 sensor
; /* Type of image sensor chip */
67 #define SENSOR_HV7131R 0
68 #define SENSOR_MI0360 1
69 #define SENSOR_MO4000 2
70 #define SENSOR_MT9V111 3
71 #define SENSOR_OM6802 4
72 #define SENSOR_OV7630 5
73 #define SENSOR_OV7648 6
74 #define SENSOR_OV7660 7
75 #define SENSOR_SP80708 8
81 /* V4L2 controls supported by the driver */
82 static int sd_setbrightness(struct gspca_dev
*gspca_dev
, __s32 val
);
83 static int sd_getbrightness(struct gspca_dev
*gspca_dev
, __s32
*val
);
84 static int sd_setcontrast(struct gspca_dev
*gspca_dev
, __s32 val
);
85 static int sd_getcontrast(struct gspca_dev
*gspca_dev
, __s32
*val
);
86 static int sd_setcolors(struct gspca_dev
*gspca_dev
, __s32 val
);
87 static int sd_getcolors(struct gspca_dev
*gspca_dev
, __s32
*val
);
88 static int sd_setblue_balance(struct gspca_dev
*gspca_dev
, __s32 val
);
89 static int sd_getblue_balance(struct gspca_dev
*gspca_dev
, __s32
*val
);
90 static int sd_setred_balance(struct gspca_dev
*gspca_dev
, __s32 val
);
91 static int sd_getred_balance(struct gspca_dev
*gspca_dev
, __s32
*val
);
92 static int sd_setgamma(struct gspca_dev
*gspca_dev
, __s32 val
);
93 static int sd_getgamma(struct gspca_dev
*gspca_dev
, __s32
*val
);
94 static int sd_setautogain(struct gspca_dev
*gspca_dev
, __s32 val
);
95 static int sd_getautogain(struct gspca_dev
*gspca_dev
, __s32
*val
);
96 static int sd_setvflip(struct gspca_dev
*gspca_dev
, __s32 val
);
97 static int sd_getvflip(struct gspca_dev
*gspca_dev
, __s32
*val
);
98 static int sd_setinfrared(struct gspca_dev
*gspca_dev
, __s32 val
);
99 static int sd_getinfrared(struct gspca_dev
*gspca_dev
, __s32
*val
);
100 static int sd_setfreq(struct gspca_dev
*gspca_dev
, __s32 val
);
101 static int sd_getfreq(struct gspca_dev
*gspca_dev
, __s32
*val
);
103 static struct ctrl sd_ctrls
[] = {
104 #define BRIGHTNESS_IDX 0
107 .id
= V4L2_CID_BRIGHTNESS
,
108 .type
= V4L2_CTRL_TYPE_INTEGER
,
109 .name
= "Brightness",
111 #define BRIGHTNESS_MAX 0xffff
112 .maximum
= BRIGHTNESS_MAX
,
114 #define BRIGHTNESS_DEF 0x8000
115 .default_value
= BRIGHTNESS_DEF
,
117 .set
= sd_setbrightness
,
118 .get
= sd_getbrightness
,
120 #define CONTRAST_IDX 1
123 .id
= V4L2_CID_CONTRAST
,
124 .type
= V4L2_CTRL_TYPE_INTEGER
,
127 #define CONTRAST_MAX 127
128 .maximum
= CONTRAST_MAX
,
130 #define CONTRAST_DEF 63
131 .default_value
= CONTRAST_DEF
,
133 .set
= sd_setcontrast
,
134 .get
= sd_getcontrast
,
139 .id
= V4L2_CID_SATURATION
,
140 .type
= V4L2_CTRL_TYPE_INTEGER
,
141 .name
= "Saturation",
146 .default_value
= COLOR_DEF
,
151 #define BLUE_BALANCE_IDX 3
154 .id
= V4L2_CID_BLUE_BALANCE
,
155 .type
= V4L2_CTRL_TYPE_INTEGER
,
156 .name
= "Blue Balance",
160 #define BLUE_BALANCE_DEF 32
161 .default_value
= BLUE_BALANCE_DEF
,
163 .set
= sd_setblue_balance
,
164 .get
= sd_getblue_balance
,
166 #define RED_BALANCE_IDX 4
169 .id
= V4L2_CID_RED_BALANCE
,
170 .type
= V4L2_CTRL_TYPE_INTEGER
,
171 .name
= "Red Balance",
175 #define RED_BALANCE_DEF 32
176 .default_value
= RED_BALANCE_DEF
,
178 .set
= sd_setred_balance
,
179 .get
= sd_getred_balance
,
184 .id
= V4L2_CID_GAMMA
,
185 .type
= V4L2_CTRL_TYPE_INTEGER
,
191 .default_value
= GAMMA_DEF
,
196 #define AUTOGAIN_IDX 6
199 .id
= V4L2_CID_AUTOGAIN
,
200 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
205 #define AUTOGAIN_DEF 1
206 .default_value
= AUTOGAIN_DEF
,
208 .set
= sd_setautogain
,
209 .get
= sd_getautogain
,
211 /* ov7630/ov7648 only */
215 .id
= V4L2_CID_VFLIP
,
216 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
222 .default_value
= VFLIP_DEF
,
228 #define INFRARED_IDX 8
231 .id
= V4L2_CID_INFRARED
,
232 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
237 #define INFRARED_DEF 0
238 .default_value
= INFRARED_DEF
,
240 .set
= sd_setinfrared
,
241 .get
= sd_getinfrared
,
243 /* ov7630/ov7648/ov7660 only */
247 .id
= V4L2_CID_POWER_LINE_FREQUENCY
,
248 .type
= V4L2_CTRL_TYPE_MENU
,
249 .name
= "Light frequency filter",
251 .maximum
= 2, /* 0: 0, 1: 50Hz, 2:60Hz */
254 .default_value
= FREQ_DEF
,
261 /* table of the disabled controls */
262 static __u32 ctrl_dis
[] = {
263 (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
264 /* SENSOR_HV7131R 0 */
265 (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
266 /* SENSOR_MI0360 1 */
267 (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
268 /* SENSOR_MO4000 2 */
269 (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
270 /* SENSOR_MT9V111 3 */
271 (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
272 /* SENSOR_OM6802 4 */
274 /* SENSOR_OV7630 5 */
276 /* SENSOR_OV7648 6 */
277 (1 << AUTOGAIN_IDX
) | (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
),
278 /* SENSOR_OV7660 7 */
279 (1 << AUTOGAIN_IDX
) | (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) |
280 (1 << FREQ_IDX
), /* SENSOR_SP80708 8 */
283 static const struct v4l2_pix_format vga_mode
[] = {
284 {160, 120, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
286 .sizeimage
= 160 * 120 * 4 / 8 + 590,
287 .colorspace
= V4L2_COLORSPACE_JPEG
,
289 {320, 240, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
291 .sizeimage
= 320 * 240 * 3 / 8 + 590,
292 .colorspace
= V4L2_COLORSPACE_JPEG
,
294 {640, 480, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
296 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
297 .sizeimage
= 640 * 480 * 3 / 4 + 590,
298 .colorspace
= V4L2_COLORSPACE_JPEG
,
302 /*Data from sn9c102p+hv7131r */
303 static const u8 sn_hv7131
[0x1c] = {
304 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
305 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
306 /* reg8 reg9 rega regb regc regd rege regf */
307 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10,
308 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
309 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
310 /* reg18 reg19 reg1a reg1b */
311 0x0a, 0x00, 0x00, 0x00
314 static const u8 sn_mi0360
[0x1c] = {
315 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
316 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
317 /* reg8 reg9 rega regb regc regd rege regf */
318 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10,
319 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
320 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
321 /* reg18 reg19 reg1a reg1b */
322 0x06, 0x00, 0x00, 0x00
325 static const u8 sn_mo4000
[0x1c] = {
326 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
327 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
328 /* reg8 reg9 rega regb regc regd rege regf */
329 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
330 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
331 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
332 /* reg18 reg19 reg1a reg1b */
333 0x08, 0x00, 0x00, 0x00
336 static const u8 sn_mt9v111
[0x1c] = {
337 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
338 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
339 /* reg8 reg9 rega regb regc regd rege regf */
340 0x81, 0x5c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
341 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
342 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
343 /* reg18 reg19 reg1a reg1b */
344 0x06, 0x00, 0x00, 0x00
347 static const u8 sn_om6802
[0x1c] = {
348 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
349 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20,
350 /* reg8 reg9 rega regb regc regd rege regf */
351 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
352 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
353 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
354 /* reg18 reg19 reg1a reg1b */
355 0x05, 0x00, 0x00, 0x00
358 static const u8 sn_ov7630
[0x1c] = {
359 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
360 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
361 /* reg8 reg9 rega regb regc regd rege regf */
362 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10,
363 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
364 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
365 /* reg18 reg19 reg1a reg1b */
366 0x0b, 0x00, 0x00, 0x00
369 static const u8 sn_ov7648
[0x1c] = {
370 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
371 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
372 /* reg8 reg9 rega regb regc regd rege regf */
373 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
374 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
375 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
376 /* reg18 reg19 reg1a reg1b */
377 0x0b, 0x00, 0x00, 0x00
380 static const u8 sn_ov7660
[0x1c] = {
381 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
382 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
383 /* reg8 reg9 rega regb regc regd rege regf */
384 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
385 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
386 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
387 /* reg18 reg19 reg1a reg1b */
388 0x07, 0x00, 0x00, 0x00
391 static const u8 sn_sp80708
[0x1c] = {
392 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
393 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
394 /* reg8 reg9 rega regb regc regd rege regf */
395 0x81, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
396 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
397 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
398 /* reg18 reg19 reg1a reg1b */
399 0x07, 0x00, 0x00, 0x00
402 /* sequence specific to the sensors - !! index = SENSOR_xxx */
403 static const u8
*sn_tb
[] = {
415 /* default gamma table */
416 static const u8 gamma_def
[17] = {
417 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
418 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
420 /* gamma for sensors HV7131R and MT9V111 */
421 static const u8 gamma_spec_1
[17] = {
422 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
423 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
425 /* gamma for sensor SP80708 */
426 static const u8 gamma_spec_2
[17] = {
427 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
428 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
431 /* color matrix and offsets */
432 static const u8 reg84
[] = {
433 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
434 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
435 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
436 0x00, 0x00, 0x00 /* YUV offsets */
438 static const u8 hv7131r_sensor_init
[][8] = {
439 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
440 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
441 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
442 /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
443 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
444 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
445 /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
447 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
448 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
449 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
450 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
451 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
452 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
453 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
454 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
456 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
457 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
458 {0xa1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10},
459 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
460 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
462 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
463 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
464 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
465 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
466 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
469 static const u8 mi0360_sensor_init
[][8] = {
470 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
471 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
472 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
473 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
474 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
475 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
476 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
477 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
478 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
479 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
480 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
481 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
482 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
483 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
484 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
485 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
486 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
487 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
488 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
489 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
490 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
491 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
492 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
493 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
494 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
495 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
496 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
497 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
498 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
499 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
500 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
501 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
502 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
504 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
505 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
506 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
507 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
508 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
510 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
511 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
512 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
513 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
515 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
516 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
517 /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
518 /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
519 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
520 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
523 static const u8 mo4000_sensor_init
[][8] = {
524 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
525 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
526 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
527 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
528 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
529 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
530 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
531 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
532 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
533 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
534 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
535 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
536 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
537 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
538 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
539 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
540 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
541 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
542 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
543 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
546 static const u8 mt9v111_sensor_init
[][8] = {
547 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
549 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
550 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
551 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
552 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
553 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
554 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
555 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
556 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
557 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
558 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
559 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
560 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
561 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
562 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
563 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
564 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
565 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
566 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
567 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
568 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
569 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
570 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
571 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
572 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
573 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
574 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
576 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
577 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
578 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
579 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
580 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
582 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
583 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
584 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
585 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
588 static const u8 om6802_sensor_init
[][8] = {
589 {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10},
590 {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10},
591 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
592 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
593 /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
594 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
595 /* white balance & auto-exposure */
596 /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
598 /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
599 * max AGC value in AE */
600 /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
602 /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
603 * preset brightness */
604 /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
606 /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
608 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
609 /* luminance mode (0x4f = AE) */
610 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
612 /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
614 /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
616 /* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */
617 /* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */
618 /* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */
619 /* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */
622 static const u8 ov7630_sensor_init
[][8] = {
623 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
624 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
625 /* win: delay 20ms */
626 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
627 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
628 /* win: delay 20ms */
629 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
630 /* win: i2c_r from 00 to 80 */
631 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
632 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
633 /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
634 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
635 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
636 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
637 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
638 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
639 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
640 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
641 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
642 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
643 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
644 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
645 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
646 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
647 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
648 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
649 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
650 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
651 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
652 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
653 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
654 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
655 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
656 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
657 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
658 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
660 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
661 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
662 /*fixme: + 0x12, 0x04*/
663 /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
665 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
666 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
667 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
669 /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
670 /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
672 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
673 /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
677 static const u8 ov7648_sensor_init
[][8] = {
678 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
679 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
680 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
681 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
682 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
683 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
684 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
685 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
686 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
687 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
688 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
689 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
690 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
691 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
692 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
693 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
694 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
695 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
696 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
697 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
698 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
700 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
701 /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
702 /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
703 /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
705 /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
706 /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
708 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
709 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
710 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
711 /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
712 /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
714 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
715 /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
716 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
717 /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
718 /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
719 /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
724 static const u8 ov7660_sensor_init
[][8] = {
725 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
727 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
728 /* Outformat = rawRGB */
729 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
730 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
731 /* GAIN BLUE RED VREF */
732 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
733 /* COM 1 BAVE GEAVE AECHH */
734 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
735 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
736 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xf8, 0x10},
737 /* AECH CLKRC COM7 COM8 */
738 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
739 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
740 /* HSTART HSTOP VSTRT VSTOP */
741 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
742 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
743 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
744 /* BOS GBOS GROS ROS (BGGR offset) */
745 /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
746 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
747 /* AEW AEB VPT BBIAS */
748 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
749 /* GbBIAS RSVD EXHCH EXHCL */
750 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
751 /* RBIAS ADVFL ASDVFH YAVE */
752 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
753 /* HSYST HSYEN HREF */
754 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
755 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
756 /* ADC ACOM OFON TSLB */
757 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
758 /* COM11 COM12 COM13 COM14 */
759 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
760 /* EDGE COM15 COM16 COM17 */
761 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
762 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
763 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
764 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
765 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
766 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
767 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
768 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
769 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
770 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
771 /* LCC1 LCC2 LCC3 LCC4 */
772 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
773 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
774 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
775 /* band gap reference [0:3] DBLV */
776 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
777 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
778 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
779 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
780 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
781 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
782 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
783 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
784 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
785 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
786 {0xb1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
787 /****** (some exchanges in the win trace) ******/
788 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
789 /* bits[3..0]reserved */
790 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
791 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
792 /* VREF vertical frame ctrl */
793 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
794 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
795 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
796 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
797 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
798 /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
799 /****** (some exchanges in the win trace) ******/
800 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
801 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
802 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
803 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
804 /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
805 /****** (some exchanges in the win trace) ******/
806 /******!! startsensor KO if changed !!****/
807 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
808 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
809 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
810 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
814 static const u8 sp80708_sensor_init
[][8] = {
815 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
816 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
817 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
818 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
819 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
820 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
821 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
822 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
823 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
824 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
825 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
826 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
830 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
831 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
832 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
833 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
834 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
850 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
851 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
852 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
853 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
854 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
855 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
856 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
857 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
858 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
859 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
860 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
861 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
863 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
864 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
866 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
867 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
868 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
869 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
870 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
871 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
872 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
873 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
874 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
875 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
876 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
877 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
878 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
879 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
880 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
881 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
882 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
883 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
884 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
885 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
887 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
888 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
889 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
890 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
891 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
892 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
893 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
897 /* read <len> bytes to gspca_dev->usb_buf */
898 static void reg_r(struct gspca_dev
*gspca_dev
,
902 if (len
> USB_BUF_SZ
) {
903 err("reg_r: buffer overflow");
907 usb_control_msg(gspca_dev
->dev
,
908 usb_rcvctrlpipe(gspca_dev
->dev
, 0),
910 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
912 gspca_dev
->usb_buf
, len
,
914 PDEBUG(D_USBI
, "reg_r [%02x] -> %02x", value
, gspca_dev
->usb_buf
[0]);
917 static void reg_w1(struct gspca_dev
*gspca_dev
,
921 PDEBUG(D_USBO
, "reg_w1 [%04x] = %02x", value
, data
);
922 gspca_dev
->usb_buf
[0] = data
;
923 usb_control_msg(gspca_dev
->dev
,
924 usb_sndctrlpipe(gspca_dev
->dev
, 0),
926 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
929 gspca_dev
->usb_buf
, 1,
932 static void reg_w(struct gspca_dev
*gspca_dev
,
937 PDEBUG(D_USBO
, "reg_w [%04x] = %02x %02x ..",
938 value
, buffer
[0], buffer
[1]);
940 if (len
> USB_BUF_SZ
) {
941 err("reg_w: buffer overflow");
945 memcpy(gspca_dev
->usb_buf
, buffer
, len
);
946 usb_control_msg(gspca_dev
->dev
,
947 usb_sndctrlpipe(gspca_dev
->dev
, 0),
949 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
951 gspca_dev
->usb_buf
, len
,
955 /* I2C write 1 byte */
956 static void i2c_w1(struct gspca_dev
*gspca_dev
, u8 reg
, u8 val
)
958 struct sd
*sd
= (struct sd
*) gspca_dev
;
960 PDEBUG(D_USBO
, "i2c_w2 [%02x] = %02x", reg
, val
);
961 gspca_dev
->usb_buf
[0] = 0x81 | (2 << 4); /* = a1 */
962 gspca_dev
->usb_buf
[1] = sd
->i2c_base
;
963 gspca_dev
->usb_buf
[2] = reg
;
964 gspca_dev
->usb_buf
[3] = val
;
965 gspca_dev
->usb_buf
[4] = 0;
966 gspca_dev
->usb_buf
[5] = 0;
967 gspca_dev
->usb_buf
[6] = 0;
968 gspca_dev
->usb_buf
[7] = 0x10;
969 usb_control_msg(gspca_dev
->dev
,
970 usb_sndctrlpipe(gspca_dev
->dev
, 0),
972 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
973 0x08, /* value = i2c */
975 gspca_dev
->usb_buf
, 8,
979 /* I2C write 8 bytes */
980 static void i2c_w8(struct gspca_dev
*gspca_dev
,
983 memcpy(gspca_dev
->usb_buf
, buffer
, 8);
984 usb_control_msg(gspca_dev
->dev
,
985 usb_sndctrlpipe(gspca_dev
->dev
, 0),
987 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
988 0x08, 0, /* value, index */
989 gspca_dev
->usb_buf
, 8,
994 /* read 5 bytes in gspca_dev->usb_buf */
995 static void i2c_r5(struct gspca_dev
*gspca_dev
, u8 reg
)
997 struct sd
*sd
= (struct sd
*) gspca_dev
;
1000 mode
[0] = 0x81 | 0x10;
1001 mode
[1] = sd
->i2c_base
;
1008 i2c_w8(gspca_dev
, mode
);
1010 mode
[0] = 0x81 | (5 << 4) | 0x02;
1012 i2c_w8(gspca_dev
, mode
);
1014 reg_r(gspca_dev
, 0x0a, 5);
1017 static int hv7131r_probe(struct gspca_dev
*gspca_dev
)
1019 i2c_w1(gspca_dev
, 0x02, 0); /* sensor wakeup */
1021 reg_w1(gspca_dev
, 0x02, 0x66); /* Gpio on */
1023 i2c_r5(gspca_dev
, 0); /* read sensor id */
1024 if (gspca_dev
->usb_buf
[0] == 0x02
1025 && gspca_dev
->usb_buf
[1] == 0x09
1026 && gspca_dev
->usb_buf
[2] == 0x01
1027 && gspca_dev
->usb_buf
[3] == 0x00
1028 && gspca_dev
->usb_buf
[4] == 0x00) {
1029 PDEBUG(D_PROBE
, "Find Sensor sn9c102P HV7131R");
1032 PDEBUG(D_PROBE
, "Find Sensor 0x%02x 0x%02x 0x%02x",
1033 gspca_dev
->usb_buf
[0], gspca_dev
->usb_buf
[1],
1034 gspca_dev
->usb_buf
[2]);
1035 PDEBUG(D_PROBE
, "Sensor sn9c102P Not found");
1039 static void mi0360_probe(struct gspca_dev
*gspca_dev
)
1041 struct sd
*sd
= (struct sd
*) gspca_dev
;
1044 static const u8 probe_tb
[][4][8] = {
1046 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1047 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1048 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1049 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1052 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1053 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1054 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1059 for (i
= 0; i
< ARRAY_SIZE(probe_tb
); i
++) {
1060 reg_w1(gspca_dev
, 0x17, 0x62);
1061 reg_w1(gspca_dev
, 0x01, 0x08);
1062 for (j
= 0; j
< 3; j
++)
1063 i2c_w8(gspca_dev
, probe_tb
[i
][j
]);
1065 reg_r(gspca_dev
, 0x0a, 5);
1066 val
= (gspca_dev
->usb_buf
[3] << 8) | gspca_dev
->usb_buf
[4];
1067 if (probe_tb
[i
][3][0] != 0)
1068 i2c_w8(gspca_dev
, probe_tb
[i
][3]);
1069 reg_w1(gspca_dev
, 0x01, 0x29);
1070 reg_w1(gspca_dev
, 0x17, 0x42);
1076 PDEBUG(D_PROBE
, "Sensor mt9v111");
1077 sd
->sensor
= SENSOR_MT9V111
;
1078 sd
->i2c_base
= 0x5c;
1081 PDEBUG(D_PROBE
, "Sensor mi0360");
1084 PDEBUG(D_PROBE
, "Unknown sensor %04x - forced to mi0360", val
);
1089 static int configure_gpio(struct gspca_dev
*gspca_dev
,
1092 struct sd
*sd
= (struct sd
*) gspca_dev
;
1094 static const u8 reg9a_def
[] =
1095 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1096 static const u8 reg9a_spec
[] =
1097 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1098 static const u8 regd4
[] = {0x60, 0x00, 0x00};
1100 reg_w1(gspca_dev
, 0xf1, 0x00);
1101 reg_w1(gspca_dev
, 0x01, sn9c1xx
[1]);
1103 /* configure gpio */
1104 reg_w(gspca_dev
, 0x01, &sn9c1xx
[1], 2);
1105 reg_w(gspca_dev
, 0x08, &sn9c1xx
[8], 2);
1106 reg_w(gspca_dev
, 0x17, &sn9c1xx
[0x17], 5); /* jfm len was 3 */
1107 switch (sd
->sensor
) {
1109 case SENSOR_SP80708
:
1116 reg_w(gspca_dev
, 0x9a, reg9a
, 6);
1118 reg_w(gspca_dev
, 0xd4, regd4
, sizeof regd4
); /*fixme:jfm was 60 only*/
1120 reg_w(gspca_dev
, 0x03, &sn9c1xx
[3], 0x0f);
1122 switch (sd
->sensor
) {
1123 case SENSOR_MT9V111
:
1124 reg_w1(gspca_dev
, 0x01, 0x61);
1125 reg_w1(gspca_dev
, 0x17, 0x61);
1126 reg_w1(gspca_dev
, 0x01, 0x60);
1127 reg_w1(gspca_dev
, 0x01, 0x40);
1130 reg_w1(gspca_dev
, 0x02, 0x71);
1131 reg_w1(gspca_dev
, 0x01, 0x42);
1132 reg_w1(gspca_dev
, 0x17, 0x64);
1133 reg_w1(gspca_dev
, 0x01, 0x42);
1136 reg_w1(gspca_dev
, 0x01, 0x61);
1137 reg_w1(gspca_dev
, 0x17, 0xe2);
1138 reg_w1(gspca_dev
, 0x01, 0x60);
1139 reg_w1(gspca_dev
, 0x01, 0x40);
1142 reg_w1(gspca_dev
, 0x01, 0x63);
1143 reg_w1(gspca_dev
, 0x17, 0x20);
1144 reg_w1(gspca_dev
, 0x01, 0x62);
1145 reg_w1(gspca_dev
, 0x01, 0x42);
1148 reg_w1(gspca_dev
, 0x01, 0x61);
1149 reg_w1(gspca_dev
, 0x17, 0x20);
1150 reg_w1(gspca_dev
, 0x01, 0x60);
1151 reg_w1(gspca_dev
, 0x01, 0x40);
1153 case SENSOR_SP80708
:
1154 reg_w1(gspca_dev
, 0x01, 0x63);
1155 reg_w1(gspca_dev
, 0x17, 0x20);
1156 reg_w1(gspca_dev
, 0x01, 0x62);
1157 reg_w1(gspca_dev
, 0x01, 0x42);
1159 reg_w1(gspca_dev
, 0x02, 0x62);
1161 /* case SENSOR_HV7131R: */
1162 /* case SENSOR_MI0360: */
1163 /* case SENSOR_MO4000: */
1165 reg_w1(gspca_dev
, 0x01, 0x43);
1166 reg_w1(gspca_dev
, 0x17, 0x61);
1167 reg_w1(gspca_dev
, 0x01, 0x42);
1168 if (sd
->sensor
== SENSOR_HV7131R
) {
1169 if (hv7131r_probe(gspca_dev
) < 0)
1177 static void hv7131R_InitSensor(struct gspca_dev
*gspca_dev
)
1180 static const u8 SetSensorClk
[] = /* 0x08 Mclk */
1181 { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 };
1183 while (hv7131r_sensor_init
[i
][0]) {
1184 i2c_w8(gspca_dev
, hv7131r_sensor_init
[i
]);
1187 i2c_w8(gspca_dev
, SetSensorClk
);
1190 static void mi0360_InitSensor(struct gspca_dev
*gspca_dev
)
1194 while (mi0360_sensor_init
[i
][0]) {
1195 i2c_w8(gspca_dev
, mi0360_sensor_init
[i
]);
1200 static void mo4000_InitSensor(struct gspca_dev
*gspca_dev
)
1204 while (mo4000_sensor_init
[i
][0]) {
1205 i2c_w8(gspca_dev
, mo4000_sensor_init
[i
]);
1210 static void mt9v111_InitSensor(struct gspca_dev
*gspca_dev
)
1214 i2c_w8(gspca_dev
, mt9v111_sensor_init
[i
]);
1217 while (mt9v111_sensor_init
[i
][0]) {
1218 i2c_w8(gspca_dev
, mt9v111_sensor_init
[i
]);
1223 static void om6802_InitSensor(struct gspca_dev
*gspca_dev
)
1227 while (om6802_sensor_init
[i
][0]) {
1228 i2c_w8(gspca_dev
, om6802_sensor_init
[i
]);
1233 static void ov7630_InitSensor(struct gspca_dev
*gspca_dev
)
1237 i2c_w8(gspca_dev
, ov7630_sensor_init
[i
]); /* 76 01 */
1239 i2c_w8(gspca_dev
, ov7630_sensor_init
[i
]); /* 12 c8 (RGB+SRST) */
1242 i2c_w8(gspca_dev
, ov7630_sensor_init
[i
]); /* 12 48 */
1244 i2c_w8(gspca_dev
, ov7630_sensor_init
[i
]); /* 12 c8 */
1247 i2c_w8(gspca_dev
, ov7630_sensor_init
[i
]); /* 12 48 */
1249 /*jfm:win i2c_r from 00 to 80*/
1251 while (ov7630_sensor_init
[i
][0]) {
1252 i2c_w8(gspca_dev
, ov7630_sensor_init
[i
]);
1257 static void ov7648_InitSensor(struct gspca_dev
*gspca_dev
)
1261 i2c_w8(gspca_dev
, ov7648_sensor_init
[i
]);
1263 /* win: dble reset */
1264 i2c_w8(gspca_dev
, ov7648_sensor_init
[i
]); /* reset */
1267 /* win: i2c reg read 00..7f */
1268 while (ov7648_sensor_init
[i
][0]) {
1269 i2c_w8(gspca_dev
, ov7648_sensor_init
[i
]);
1274 static void ov7660_InitSensor(struct gspca_dev
*gspca_dev
)
1278 i2c_w8(gspca_dev
, ov7660_sensor_init
[i
]); /* reset SCCB */
1281 while (ov7660_sensor_init
[i
][0]) {
1282 i2c_w8(gspca_dev
, ov7660_sensor_init
[i
]);
1287 static void sp80708_InitSensor(struct gspca_dev
*gspca_dev
)
1291 i2c_w8(gspca_dev
, sp80708_sensor_init
[i
]); /* reset SCCB */
1294 while (sp80708_sensor_init
[i
][0]) {
1295 i2c_w8(gspca_dev
, sp80708_sensor_init
[i
]);
1300 /* this function is called at probe time */
1301 static int sd_config(struct gspca_dev
*gspca_dev
,
1302 const struct usb_device_id
*id
)
1304 struct sd
*sd
= (struct sd
*) gspca_dev
;
1307 cam
= &gspca_dev
->cam
;
1308 cam
->cam_mode
= vga_mode
;
1309 cam
->nmodes
= ARRAY_SIZE(vga_mode
);
1310 cam
->npkt
= 24; /* 24 packets per ISOC message */
1312 sd
->bridge
= id
->driver_info
>> 16;
1313 sd
->sensor
= id
->driver_info
>> 8;
1314 sd
->i2c_base
= id
->driver_info
;
1316 sd
->brightness
= BRIGHTNESS_DEF
;
1317 sd
->contrast
= CONTRAST_DEF
;
1318 sd
->colors
= COLOR_DEF
;
1319 sd
->blue
= BLUE_BALANCE_DEF
;
1320 sd
->red
= RED_BALANCE_DEF
;
1321 sd
->gamma
= GAMMA_DEF
;
1322 sd
->autogain
= AUTOGAIN_DEF
;
1324 sd
->vflip
= VFLIP_DEF
;
1325 sd
->infrared
= INFRARED_DEF
;
1326 sd
->freq
= FREQ_DEF
;
1327 sd
->quality
= QUALITY_DEF
;
1330 gspca_dev
->ctrl_dis
= ctrl_dis
[sd
->sensor
];
1334 /* this function is called at probe and resume time */
1335 static int sd_init(struct gspca_dev
*gspca_dev
)
1337 struct sd
*sd
= (struct sd
*) gspca_dev
;
1338 u8 regGpio
[] = { 0x29, 0x74 };
1341 /* setup a selector by bridge */
1342 reg_w1(gspca_dev
, 0xf1, 0x01);
1343 reg_r(gspca_dev
, 0x00, 1);
1344 reg_w1(gspca_dev
, 0xf1, gspca_dev
->usb_buf
[0]);
1345 reg_r(gspca_dev
, 0x00, 1); /* get sonix chip id */
1346 regF1
= gspca_dev
->usb_buf
[0];
1347 PDEBUG(D_PROBE
, "Sonix chip id: %02x", regF1
);
1348 switch (sd
->bridge
) {
1349 case BRIDGE_SN9C102P
:
1352 reg_w1(gspca_dev
, 0x02, regGpio
[1]);
1354 case BRIDGE_SN9C105
:
1357 if (sd
->sensor
== SENSOR_MI0360
)
1358 mi0360_probe(gspca_dev
);
1359 reg_w(gspca_dev
, 0x01, regGpio
, 2);
1361 case BRIDGE_SN9C120
:
1364 if (sd
->sensor
== SENSOR_MI0360
)
1365 mi0360_probe(gspca_dev
);
1367 reg_w(gspca_dev
, 0x01, regGpio
, 2);
1370 /* case BRIDGE_SN9C110: */
1371 /* case BRIDGE_SN9C325: */
1374 reg_w1(gspca_dev
, 0x02, 0x62);
1378 reg_w1(gspca_dev
, 0xf1, 0x01);
1383 static u32
setexposure(struct gspca_dev
*gspca_dev
,
1386 struct sd
*sd
= (struct sd
*) gspca_dev
;
1388 switch (sd
->sensor
) {
1389 case SENSOR_HV7131R
: {
1391 { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
1393 Expodoit
[3] = expo
>> 16;
1394 Expodoit
[4] = expo
>> 8;
1396 i2c_w8(gspca_dev
, Expodoit
);
1399 case SENSOR_MI0360
: {
1400 u8 expoMi
[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
1401 { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
1402 static const u8 doit
[] = /* update sensor */
1403 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1404 static const u8 sensorgo
[] = /* sensor on */
1405 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
1409 else if (expo
< 0x0001)
1411 expoMi
[3] = expo
>> 8;
1413 i2c_w8(gspca_dev
, expoMi
);
1414 i2c_w8(gspca_dev
, doit
);
1415 i2c_w8(gspca_dev
, sensorgo
);
1418 case SENSOR_MO4000
: {
1420 { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
1422 { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
1423 static const u8 gainMo
[] =
1424 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
1428 else if (expo
< 0x0001)
1430 expoMof
[3] = (expo
& 0x03fc) >> 2;
1431 i2c_w8(gspca_dev
, expoMof
);
1432 expoMo10
[3] = ((expo
& 0x1c00) >> 10)
1433 | ((expo
& 0x0003) << 4);
1434 i2c_w8(gspca_dev
, expoMo10
);
1435 i2c_w8(gspca_dev
, gainMo
);
1436 PDEBUG(D_FRAM
, "set exposure %d",
1437 ((expoMo10
[3] & 0x07) << 10)
1439 | ((expoMo10
[3] & 0x30) >> 4));
1442 case SENSOR_MT9V111
: {
1444 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1448 else if (expo
< 0x0040)
1450 expo_c1
[3] = expo
>> 8;
1452 i2c_w8(gspca_dev
, expo_c1
);
1455 case SENSOR_OM6802
: {
1457 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
1463 gainOm
[3] = expo
>> 2;
1464 i2c_w8(gspca_dev
, gainOm
);
1465 reg_w1(gspca_dev
, 0x96, (expo
>> 5) & 0x1f);
1466 PDEBUG(D_FRAM
, "set exposure %d", gainOm
[3]);
1473 static void setbrightness(struct gspca_dev
*gspca_dev
)
1475 struct sd
*sd
= (struct sd
*) gspca_dev
;
1479 k2
= ((int) sd
->brightness
- 0x8000) >> 10;
1480 switch (sd
->sensor
) {
1481 case SENSOR_HV7131R
:
1482 expo
= sd
->brightness
<< 4;
1483 if (expo
> 0x002dc6c0)
1485 else if (expo
< 0x02a0)
1487 sd
->exposure
= setexposure(gspca_dev
, expo
);
1491 expo
= sd
->brightness
>> 4;
1492 sd
->exposure
= setexposure(gspca_dev
, expo
);
1494 case SENSOR_MT9V111
:
1495 expo
= sd
->brightness
>> 8;
1496 sd
->exposure
= setexposure(gspca_dev
, expo
);
1499 expo
= sd
->brightness
>> 6;
1500 sd
->exposure
= setexposure(gspca_dev
, expo
);
1501 k2
= sd
->brightness
>> 11;
1505 if (sd
->sensor
!= SENSOR_MT9V111
)
1506 reg_w1(gspca_dev
, 0x96, k2
); /* color matrix Y offset */
1509 static void setcontrast(struct gspca_dev
*gspca_dev
)
1511 struct sd
*sd
= (struct sd
*) gspca_dev
;
1515 k2
= sd
->contrast
* 0x30 / (CONTRAST_MAX
+ 1) + 0x10; /* 10..40 */
1516 contrast
[0] = (k2
+ 1) / 2; /* red */
1518 contrast
[2] = k2
; /* green */
1520 contrast
[4] = (k2
+ 1) / 5; /* blue */
1522 reg_w(gspca_dev
, 0x84, contrast
, sizeof contrast
);
1525 static void setcolors(struct gspca_dev
*gspca_dev
)
1527 struct sd
*sd
= (struct sd
*) gspca_dev
;
1529 u8 reg8a
[12]; /* U & V gains */
1530 static s16 uv
[6] = { /* same as reg84 in signed decimal */
1531 -24, -38, 64, /* UR UG UB */
1532 62, -51, -9 /* VR VG VB */
1534 for (i
= 0; i
< 6; i
++) {
1535 v
= uv
[i
] * sd
->colors
/ COLOR_DEF
;
1537 reg8a
[i
* 2 + 1] = (v
>> 8) & 0x0f;
1539 reg_w(gspca_dev
, 0x8a, reg8a
, sizeof reg8a
);
1542 static void setredblue(struct gspca_dev
*gspca_dev
)
1544 struct sd
*sd
= (struct sd
*) gspca_dev
;
1546 reg_w1(gspca_dev
, 0x05, sd
->red
);
1547 /* reg_w1(gspca_dev, 0x07, 32); */
1548 reg_w1(gspca_dev
, 0x06, sd
->blue
);
1551 static void setgamma(struct gspca_dev
*gspca_dev
)
1553 struct sd
*sd
= (struct sd
*) gspca_dev
;
1556 const u8
*gamma_base
;
1557 static const u8 delta
[17] = {
1558 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1559 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1562 switch (sd
->sensor
) {
1563 case SENSOR_HV7131R
:
1564 case SENSOR_MT9V111
:
1565 gamma_base
= gamma_spec_1
;
1567 case SENSOR_SP80708
:
1568 gamma_base
= gamma_spec_2
;
1571 gamma_base
= gamma_def
;
1575 for (i
= 0; i
< sizeof gamma
; i
++)
1576 gamma
[i
] = gamma_base
[i
]
1577 + delta
[i
] * (sd
->gamma
- GAMMA_DEF
) / 32;
1578 reg_w(gspca_dev
, 0x20, gamma
, sizeof gamma
);
1581 static void setautogain(struct gspca_dev
*gspca_dev
)
1583 struct sd
*sd
= (struct sd
*) gspca_dev
;
1585 if (gspca_dev
->ctrl_dis
& (1 << AUTOGAIN_IDX
))
1587 switch (sd
->sensor
) {
1589 case SENSOR_OV7648
: {
1592 if (sd
->sensor
== SENSOR_OV7630
)
1598 i2c_w1(&sd
->gspca_dev
, 0x13, comb
);
1603 sd
->ag_cnt
= AG_CNT_START
;
1608 /* ov7630/ov7648 only */
1609 static void setvflip(struct sd
*sd
)
1613 if (sd
->sensor
== SENSOR_OV7630
) {
1622 i2c_w1(&sd
->gspca_dev
, 0x75, comn
);
1625 static void setinfrared(struct sd
*sd
)
1627 /*fixme: different sequence for StarCam Clip and StarCam 370i */
1629 i2c_w1(&sd
->gspca_dev
, 0x02, /* gpio */
1630 sd
->infrared
? 0x66 : 0x64);
1633 static void setfreq(struct gspca_dev
*gspca_dev
)
1635 struct sd
*sd
= (struct sd
*) gspca_dev
;
1637 if (gspca_dev
->ctrl_dis
& (1 << FREQ_IDX
))
1639 if (sd
->sensor
== SENSOR_OV7660
) {
1642 com8
= 0xf8; /* no auto gain/wb/expo */
1644 case 0: /* Banding filter disabled */
1645 i2c_w1(gspca_dev
, 0x13, com8
& 0xdf);
1648 i2c_w1(gspca_dev
, 0x13, com8
);
1649 i2c_w1(gspca_dev
, 0x3b, 0x0a);
1652 i2c_w1(gspca_dev
, 0x13, com8
);
1653 i2c_w1(gspca_dev
, 0x3b, 0x02);
1657 u8 reg2a
= 0, reg2b
= 0, reg2d
= 0;
1659 /* Get reg2a / reg2d base values */
1660 switch (sd
->sensor
) {
1672 case 0: /* Banding filter disabled */
1674 case 1: /* 50 hz (filter on and framerate adj) */
1679 case 2: /* 60 hz (filter on, no framerate adj) */
1684 i2c_w1(gspca_dev
, 0x2a, reg2a
);
1685 i2c_w1(gspca_dev
, 0x2b, reg2b
);
1686 i2c_w1(gspca_dev
, 0x2d, reg2d
);
1690 static void setjpegqual(struct gspca_dev
*gspca_dev
)
1692 struct sd
*sd
= (struct sd
*) gspca_dev
;
1695 if (sd
->jpegqual
< 50)
1696 sc
= 5000 / sd
->jpegqual
;
1698 sc
= 200 - sd
->jpegqual
* 2;
1700 #error "No room enough in usb_buf for quantization table"
1702 for (i
= 0; i
< 64; i
++)
1703 gspca_dev
->usb_buf
[i
] =
1704 (jpeg_head
[JPEG_QT0_OFFSET
+ i
] * sc
+ 50) / 100;
1705 usb_control_msg(gspca_dev
->dev
,
1706 usb_sndctrlpipe(gspca_dev
->dev
, 0),
1708 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
1710 gspca_dev
->usb_buf
, 64,
1712 for (i
= 0; i
< 64; i
++)
1713 gspca_dev
->usb_buf
[i
] =
1714 (jpeg_head
[JPEG_QT1_OFFSET
+ i
] * sc
+ 50) / 100;
1715 usb_control_msg(gspca_dev
->dev
,
1716 usb_sndctrlpipe(gspca_dev
->dev
, 0),
1718 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
1720 gspca_dev
->usb_buf
, 64,
1724 reg_w1(gspca_dev
, 0x18, sd
->reg18
);
1727 /* -- start the camera -- */
1728 static int sd_start(struct gspca_dev
*gspca_dev
)
1730 struct sd
*sd
= (struct sd
*) gspca_dev
;
1735 static const u8 C0
[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1736 static const u8 CA
[] = { 0x28, 0xd8, 0x14, 0xec };
1737 static const u8 CE
[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1738 static const u8 CE_ov76xx
[] =
1739 { 0x32, 0xdd, 0x32, 0xdd };
1741 /* create the JPEG header */
1742 sd
->jpeg_hdr
= kmalloc(JPEG_HDR_SZ
, GFP_KERNEL
);
1745 jpeg_define(sd
->jpeg_hdr
, gspca_dev
->height
, gspca_dev
->width
,
1746 0x21); /* JPEG 422 */
1747 jpeg_set_qual(sd
->jpeg_hdr
, sd
->quality
);
1749 sn9c1xx
= sn_tb
[(int) sd
->sensor
];
1750 configure_gpio(gspca_dev
, sn9c1xx
);
1752 reg_w1(gspca_dev
, 0x15, sn9c1xx
[0x15]);
1753 reg_w1(gspca_dev
, 0x16, sn9c1xx
[0x16]);
1754 reg_w1(gspca_dev
, 0x12, sn9c1xx
[0x12]);
1755 reg_w1(gspca_dev
, 0x13, sn9c1xx
[0x13]);
1756 reg_w1(gspca_dev
, 0x18, sn9c1xx
[0x18]);
1757 reg_w1(gspca_dev
, 0xd2, 0x6a); /* DC29 */
1758 reg_w1(gspca_dev
, 0xd3, 0x50);
1759 reg_w1(gspca_dev
, 0xc6, 0x00);
1760 reg_w1(gspca_dev
, 0xc7, 0x00);
1761 reg_w1(gspca_dev
, 0xc8, 0x50);
1762 reg_w1(gspca_dev
, 0xc9, 0x3c);
1763 reg_w1(gspca_dev
, 0x18, sn9c1xx
[0x18]);
1764 switch (sd
->sensor
) {
1765 case SENSOR_MT9V111
:
1781 reg_w1(gspca_dev
, 0x17, reg17
);
1782 /* set reg1 was here */
1783 reg_w1(gspca_dev
, 0x05, sn9c1xx
[5]); /* red */
1784 reg_w1(gspca_dev
, 0x07, sn9c1xx
[7]); /* green */
1785 reg_w1(gspca_dev
, 0x06, sn9c1xx
[6]); /* blue */
1786 reg_w1(gspca_dev
, 0x14, sn9c1xx
[0x14]);
1788 setgamma(gspca_dev
);
1790 for (i
= 0; i
< 8; i
++)
1791 reg_w(gspca_dev
, 0x84, reg84
, sizeof reg84
);
1792 switch (sd
->sensor
) {
1793 case SENSOR_MT9V111
:
1794 reg_w1(gspca_dev
, 0x9a, 0x07);
1795 reg_w1(gspca_dev
, 0x99, 0x59);
1798 reg_w1(gspca_dev
, 0x9a, 0x0a);
1799 reg_w1(gspca_dev
, 0x99, 0x60);
1802 reg_w1(gspca_dev
, 0x9a, 0x05);
1803 if (sd
->bridge
== BRIDGE_SN9C105
)
1804 reg_w1(gspca_dev
, 0x99, 0xff);
1806 reg_w1(gspca_dev
, 0x99, 0x5b);
1808 case SENSOR_SP80708
:
1809 reg_w1(gspca_dev
, 0x9a, 0x05);
1810 reg_w1(gspca_dev
, 0x99, 0x59);
1813 reg_w1(gspca_dev
, 0x9a, 0x08);
1814 reg_w1(gspca_dev
, 0x99, 0x59);
1818 mode
= gspca_dev
->cam
.cam_mode
[(int) gspca_dev
->curr_mode
].priv
;
1820 reg1
= 0x46; /* 320x240: clk 48Mhz, video trf enable */
1822 reg1
= 0x06; /* 640x480: clk 24Mhz, video trf enable */
1823 reg17
= 0x61; /* 0x:20: enable sensor clock */
1824 switch (sd
->sensor
) {
1825 case SENSOR_HV7131R
:
1826 hv7131R_InitSensor(gspca_dev
);
1829 mi0360_InitSensor(gspca_dev
);
1832 mo4000_InitSensor(gspca_dev
);
1834 /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
1835 reg1
= 0x06; /* clk 24Mz */
1837 reg17
= 0x22; /* 640 MCKSIZE */
1838 /* reg1 = 0x06; * 640 clk 24Mz (done) */
1841 case SENSOR_MT9V111
:
1842 mt9v111_InitSensor(gspca_dev
);
1844 reg1
= 0x04; /* 320 clk 48Mhz */
1846 /* reg1 = 0x06; * 640 clk 24Mz (done) */
1851 om6802_InitSensor(gspca_dev
);
1852 reg17
= 0x64; /* 640 MCKSIZE */
1855 ov7630_InitSensor(gspca_dev
);
1861 ov7648_InitSensor(gspca_dev
);
1863 /* reg1 = 0x42; * 42 - 46? */
1866 ov7660_InitSensor(gspca_dev
);
1867 if (sd
->bridge
== BRIDGE_SN9C120
) {
1868 if (mode
) { /* 320x240 - 160x120 */
1870 reg1
= 0x44; /* 48 Mhz, video trf eneble */
1874 reg1
= 0x06; /* 24 Mhz, video trf eneble
1875 * inverse power down */
1879 /* case SENSOR_SP80708: */
1880 sp80708_InitSensor(gspca_dev
);
1882 /*?? reg1 = 0x04; * 320 clk 48Mhz */
1884 reg1
= 0x46; /* 640 clk 48Mz */
1889 reg_w(gspca_dev
, 0xc0, C0
, 6);
1890 reg_w(gspca_dev
, 0xca, CA
, 4);
1891 switch (sd
->sensor
) {
1895 reg_w(gspca_dev
, 0xce, CE_ov76xx
, 4);
1898 reg_w(gspca_dev
, 0xce, CE
, 4);
1899 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
1903 /* here change size mode 0 -> VGA; 1 -> CIF */
1904 sd
->reg18
= sn9c1xx
[0x18] | (mode
<< 4) | 0x40;
1905 reg_w1(gspca_dev
, 0x18, sd
->reg18
);
1906 setjpegqual(gspca_dev
);
1908 reg_w1(gspca_dev
, 0x17, reg17
);
1909 reg_w1(gspca_dev
, 0x01, reg1
);
1910 switch (sd
->sensor
) {
1915 setbrightness(gspca_dev
);
1916 setcontrast(gspca_dev
);
1917 setautogain(gspca_dev
);
1922 static void sd_stopN(struct gspca_dev
*gspca_dev
)
1924 struct sd
*sd
= (struct sd
*) gspca_dev
;
1925 static const u8 stophv7131
[] =
1926 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
1927 static const u8 stopmi0360
[] =
1928 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
1929 static const u8 stopov7648
[] =
1930 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
1935 switch (sd
->sensor
) {
1936 case SENSOR_HV7131R
:
1937 i2c_w8(gspca_dev
, stophv7131
);
1941 i2c_w8(gspca_dev
, stopmi0360
);
1945 i2c_w8(gspca_dev
, stopov7648
);
1947 case SENSOR_MT9V111
:
1952 /* case SENSOR_MO4000: */
1953 /* case SENSOR_OV7660: */
1956 sn9c1xx
= sn_tb
[(int) sd
->sensor
];
1957 reg_w1(gspca_dev
, 0x01, sn9c1xx
[1]);
1958 reg_w1(gspca_dev
, 0x17, sn9c1xx
[0x17]);
1959 reg_w1(gspca_dev
, 0x01, sn9c1xx
[1]);
1960 reg_w1(gspca_dev
, 0x01, data
);
1961 reg_w1(gspca_dev
, 0xf1, 0x00);
1964 static void sd_stop0(struct gspca_dev
*gspca_dev
)
1966 struct sd
*sd
= (struct sd
*) gspca_dev
;
1968 kfree(sd
->jpeg_hdr
);
1971 static void do_autogain(struct gspca_dev
*gspca_dev
)
1973 struct sd
*sd
= (struct sd
*) gspca_dev
;
1979 /* Thanks S., without your advice, autobright should not work :) */
1982 if (--sd
->ag_cnt
>= 0)
1984 sd
->ag_cnt
= AG_CNT_START
;
1986 delta
= atomic_read(&sd
->avg_lum
);
1987 PDEBUG(D_FRAM
, "mean lum %d", delta
);
1988 if (delta
< luma_mean
- luma_delta
||
1989 delta
> luma_mean
+ luma_delta
) {
1990 switch (sd
->sensor
) {
1991 case SENSOR_HV7131R
:
1992 expotimes
= sd
->exposure
>> 8;
1993 expotimes
+= (luma_mean
- delta
) >> 4;
1996 sd
->exposure
= setexposure(gspca_dev
,
1997 (unsigned int) (expotimes
<< 8));
2000 /* case SENSOR_MO4000: */
2001 /* case SENSOR_MI0360: */
2002 /* case SENSOR_MT9V111: */
2003 /* case SENSOR_OM6802: */
2004 expotimes
= sd
->exposure
;
2005 expotimes
+= (luma_mean
- delta
) >> 6;
2008 sd
->exposure
= setexposure(gspca_dev
,
2009 (unsigned int) expotimes
);
2010 setredblue(gspca_dev
);
2016 /* scan the URB packets */
2017 /* This function is run at interrupt level. */
2018 static void sd_pkt_scan(struct gspca_dev
*gspca_dev
,
2019 struct gspca_frame
*frame
, /* target */
2020 u8
*data
, /* isoc packet */
2021 int len
) /* iso packet length */
2023 struct sd
*sd
= (struct sd
*) gspca_dev
;
2027 if (sof
>= 0 && data
[sof
] == 0xff && data
[sof
+ 1] == 0xd9) {
2030 gspca_frame_add(gspca_dev
, LAST_PACKET
,
2031 frame
, data
, sof
+ 2);
2038 avg_lum
= ((data
[sof
+ 29] << 8) | data
[sof
+ 30]) >> 6;
2040 avg_lum
+= ((data
[sof
+ 33] << 8) | data
[sof
+ 34]) >> 6;
2042 avg_lum
+= ((data
[sof
+ 25] << 8) | data
[sof
+ 26]) >> 6;
2044 avg_lum
+= ((data
[sof
+ 37] << 8) | data
[sof
+ 38]) >> 6;
2046 avg_lum
+= ((data
[sof
+ 31] << 8) | data
[sof
+ 32]) >> 4;
2048 atomic_set(&sd
->avg_lum
, avg_lum
);
2051 if (gspca_dev
->last_packet_type
== LAST_PACKET
) {
2053 /* put the JPEG 422 header */
2054 gspca_frame_add(gspca_dev
, FIRST_PACKET
, frame
,
2055 sd
->jpeg_hdr
, JPEG_HDR_SZ
);
2057 gspca_frame_add(gspca_dev
, INTER_PACKET
, frame
, data
, len
);
2060 static int sd_setbrightness(struct gspca_dev
*gspca_dev
, __s32 val
)
2062 struct sd
*sd
= (struct sd
*) gspca_dev
;
2064 sd
->brightness
= val
;
2065 if (gspca_dev
->streaming
)
2066 setbrightness(gspca_dev
);
2070 static int sd_getbrightness(struct gspca_dev
*gspca_dev
, __s32
*val
)
2072 struct sd
*sd
= (struct sd
*) gspca_dev
;
2074 *val
= sd
->brightness
;
2078 static int sd_setcontrast(struct gspca_dev
*gspca_dev
, __s32 val
)
2080 struct sd
*sd
= (struct sd
*) gspca_dev
;
2083 if (gspca_dev
->streaming
)
2084 setcontrast(gspca_dev
);
2088 static int sd_getcontrast(struct gspca_dev
*gspca_dev
, __s32
*val
)
2090 struct sd
*sd
= (struct sd
*) gspca_dev
;
2092 *val
= sd
->contrast
;
2096 static int sd_setcolors(struct gspca_dev
*gspca_dev
, __s32 val
)
2098 struct sd
*sd
= (struct sd
*) gspca_dev
;
2101 if (gspca_dev
->streaming
)
2102 setcolors(gspca_dev
);
2106 static int sd_getcolors(struct gspca_dev
*gspca_dev
, __s32
*val
)
2108 struct sd
*sd
= (struct sd
*) gspca_dev
;
2114 static int sd_setblue_balance(struct gspca_dev
*gspca_dev
, __s32 val
)
2116 struct sd
*sd
= (struct sd
*) gspca_dev
;
2119 if (gspca_dev
->streaming
)
2120 setredblue(gspca_dev
);
2124 static int sd_getblue_balance(struct gspca_dev
*gspca_dev
, __s32
*val
)
2126 struct sd
*sd
= (struct sd
*) gspca_dev
;
2132 static int sd_setred_balance(struct gspca_dev
*gspca_dev
, __s32 val
)
2134 struct sd
*sd
= (struct sd
*) gspca_dev
;
2137 if (gspca_dev
->streaming
)
2138 setredblue(gspca_dev
);
2142 static int sd_getred_balance(struct gspca_dev
*gspca_dev
, __s32
*val
)
2144 struct sd
*sd
= (struct sd
*) gspca_dev
;
2150 static int sd_setgamma(struct gspca_dev
*gspca_dev
, __s32 val
)
2152 struct sd
*sd
= (struct sd
*) gspca_dev
;
2155 if (gspca_dev
->streaming
)
2156 setgamma(gspca_dev
);
2160 static int sd_getgamma(struct gspca_dev
*gspca_dev
, __s32
*val
)
2162 struct sd
*sd
= (struct sd
*) gspca_dev
;
2168 static int sd_setautogain(struct gspca_dev
*gspca_dev
, __s32 val
)
2170 struct sd
*sd
= (struct sd
*) gspca_dev
;
2173 if (gspca_dev
->streaming
)
2174 setautogain(gspca_dev
);
2178 static int sd_getautogain(struct gspca_dev
*gspca_dev
, __s32
*val
)
2180 struct sd
*sd
= (struct sd
*) gspca_dev
;
2182 *val
= sd
->autogain
;
2186 static int sd_setvflip(struct gspca_dev
*gspca_dev
, __s32 val
)
2188 struct sd
*sd
= (struct sd
*) gspca_dev
;
2191 if (gspca_dev
->streaming
)
2196 static int sd_getvflip(struct gspca_dev
*gspca_dev
, __s32
*val
)
2198 struct sd
*sd
= (struct sd
*) gspca_dev
;
2204 static int sd_setinfrared(struct gspca_dev
*gspca_dev
, __s32 val
)
2206 struct sd
*sd
= (struct sd
*) gspca_dev
;
2209 if (gspca_dev
->streaming
)
2214 static int sd_getinfrared(struct gspca_dev
*gspca_dev
, __s32
*val
)
2216 struct sd
*sd
= (struct sd
*) gspca_dev
;
2218 *val
= sd
->infrared
;
2222 static int sd_setfreq(struct gspca_dev
*gspca_dev
, __s32 val
)
2224 struct sd
*sd
= (struct sd
*) gspca_dev
;
2227 if (gspca_dev
->streaming
)
2232 static int sd_getfreq(struct gspca_dev
*gspca_dev
, __s32
*val
)
2234 struct sd
*sd
= (struct sd
*) gspca_dev
;
2240 static int sd_set_jcomp(struct gspca_dev
*gspca_dev
,
2241 struct v4l2_jpegcompression
*jcomp
)
2243 struct sd
*sd
= (struct sd
*) gspca_dev
;
2245 if (jcomp
->quality
< QUALITY_MIN
)
2246 sd
->quality
= QUALITY_MIN
;
2247 else if (jcomp
->quality
> QUALITY_MAX
)
2248 sd
->quality
= QUALITY_MAX
;
2250 sd
->quality
= jcomp
->quality
;
2251 if (gspca_dev
->streaming
)
2252 jpeg_set_qual(sd
->jpeg_hdr
, sd
->quality
);
2256 static int sd_get_jcomp(struct gspca_dev
*gspca_dev
,
2257 struct v4l2_jpegcompression
*jcomp
)
2259 struct sd
*sd
= (struct sd
*) gspca_dev
;
2261 memset(jcomp
, 0, sizeof *jcomp
);
2262 jcomp
->quality
= sd
->quality
;
2263 jcomp
->jpeg_markers
= V4L2_JPEG_MARKER_DHT
2264 | V4L2_JPEG_MARKER_DQT
;
2268 static int sd_querymenu(struct gspca_dev
*gspca_dev
,
2269 struct v4l2_querymenu
*menu
)
2272 case V4L2_CID_POWER_LINE_FREQUENCY
:
2273 switch (menu
->index
) {
2274 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2275 strcpy((char *) menu
->name
, "NoFliker");
2277 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2278 strcpy((char *) menu
->name
, "50 Hz");
2280 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2281 strcpy((char *) menu
->name
, "60 Hz");
2289 /* sub-driver description */
2290 static const struct sd_desc sd_desc
= {
2291 .name
= MODULE_NAME
,
2293 .nctrls
= ARRAY_SIZE(sd_ctrls
),
2294 .config
= sd_config
,
2299 .pkt_scan
= sd_pkt_scan
,
2300 .dq_callback
= do_autogain
,
2301 .get_jcomp
= sd_get_jcomp
,
2302 .set_jcomp
= sd_set_jcomp
,
2303 .querymenu
= sd_querymenu
,
2306 /* -- module initialisation -- */
2307 #define BSI(bridge, sensor, i2c_addr) \
2308 .driver_info = (BRIDGE_ ## bridge << 16) \
2309 | (SENSOR_ ## sensor << 8) \
2311 static const __devinitdata
struct usb_device_id device_table
[] = {
2312 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2313 {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120
, MI0360
, 0x5d)},
2314 {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120
, OV7660
, 0x21)},
2316 {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105
, OV7660
, 0x21)},
2317 {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105
, OV7660
, 0x21)},
2318 {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105
, MI0360
, 0x5d)},
2319 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105
, MI0360
, 0x5d)},
2320 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105
, MI0360
, 0x5d)},
2321 {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105
, OV7660
, 0x21)},
2322 {USB_DEVICE(0x06f8, 0x3008), BSI(SN9C105
, OV7660
, 0x21)},
2323 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P
, HV7131R
, 0x11)},
2325 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P, MI0360, 0x5d)}, */
2326 /* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x??)}, */
2327 /* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x??)}, */
2328 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P
, HV7131R
, 0x11)},
2329 /* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x??)}, */
2330 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105
, MI0360
, 0x5d)},
2331 /* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6801, 0x??)}, */
2332 /* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
2333 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105
, MO4000
, 0x21)},
2334 /* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
2335 /* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x??)}, */
2336 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105
, OV7660
, 0x21)},
2337 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105
, HV7131R
, 0x11)},
2338 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2339 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105
, OV7630
, 0x21)},
2341 {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120
, MI0360
, 0x5d)}, /*sn9c128*/
2342 /* {USB_DEVICE(0x0c45, 0x6102), BSI(SN9C120, PO2030N, ??)}, */
2343 /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6802, 0x21)}, */
2344 {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120
, OV7648
, 0x21)}, /*sn9c128*/
2345 {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120
, OV7660
, 0x21)}, /*sn9c128*/
2346 {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120
, HV7131R
, 0x11)}, /*sn9c128*/
2347 {USB_DEVICE(0x0c45, 0x610e), BSI(SN9C120
, OV7630
, 0x21)}, /*sn9c128*/
2348 /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
2349 /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
2350 {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110
, OM6802
, 0x21)}, /*sn9c325?*/
2352 {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C120
, OV7648
, 0x21)}, /*sn9c110?*/
2353 {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110
, MO4000
, 0x21)},
2354 {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110
, OV7630
, 0x21)},
2355 /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */
2356 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2357 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120
, MI0360
, 0x5d)},
2359 /* {USB_DEVICE(0x0c45, 0x6132), BSI(SN9C120, OV7670, 0x21)}, */
2360 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120
, MO4000
, 0x21)},
2361 {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120
, OV7648
, 0x21)},
2362 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2363 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120
, OV7660
, 0x21)},
2365 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120
, HV7131R
, 0x11)},
2366 {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120
, OV7630
, 0x21)},
2367 /* {USB_DEVICE(0x0c45, 0x6142), BSI(SN9C120, PO2030N, ??)}, *sn9c120b*/
2368 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120
, SP80708
, 0x18)}, /*sn9c120b*/
2369 {USB_DEVICE(0x0c45, 0x6148), BSI(SN9C120
, OM6802
, 0x21)}, /*sn9c120b*/
2372 MODULE_DEVICE_TABLE(usb
, device_table
);
2374 /* -- device connect -- */
2375 static int sd_probe(struct usb_interface
*intf
,
2376 const struct usb_device_id
*id
)
2378 return gspca_dev_probe(intf
, id
, &sd_desc
, sizeof(struct sd
),
2382 static struct usb_driver sd_driver
= {
2383 .name
= MODULE_NAME
,
2384 .id_table
= device_table
,
2386 .disconnect
= gspca_disconnect
,
2388 .suspend
= gspca_suspend
,
2389 .resume
= gspca_resume
,
2393 /* -- module insert / remove -- */
2394 static int __init
sd_mod_init(void)
2397 ret
= usb_register(&sd_driver
);
2403 static void __exit
sd_mod_exit(void)
2405 usb_deregister(&sd_driver
);
2406 info("deregistered");
2409 module_init(sd_mod_init
);
2410 module_exit(sd_mod_exit
);