2 * Sonix sn9c102p sn9c105 sn9c120 (jpeg) subdriver
3 * Copyright (C) 2009 Jean-Francois Moine <http://moinejf.free.fr>
4 * Copyright (C) 2005 Michel Xhaard mxhaard@magic.fr
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define MODULE_NAME "sonixj"
26 #define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
28 MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29 MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
30 MODULE_LICENSE("GPL");
32 /* specific webcam descriptor */
34 struct gspca_dev gspca_dev
; /* !! must be the first item */
46 u8 vflip
; /* ov7630/ov7648 only */
47 u8 infrared
; /* mt9v111 only */
48 u8 freq
; /* ov76xx only */
49 u8 quality
; /* image quality */
50 #define QUALITY_MIN 60
51 #define QUALITY_MAX 95
52 #define QUALITY_DEF 80
53 u8 jpegqual
; /* webcam quality */
58 #define AG_CNT_START 13
61 #define BRIDGE_SN9C102P 0
62 #define BRIDGE_SN9C105 1
63 #define BRIDGE_SN9C110 2
64 #define BRIDGE_SN9C120 3
65 u8 sensor
; /* Type of image sensor chip */
66 #define SENSOR_HV7131R 0
67 #define SENSOR_MI0360 1
68 #define SENSOR_MO4000 2
69 #define SENSOR_MT9V111 3
70 #define SENSOR_OM6802 4
71 #define SENSOR_OV7630 5
72 #define SENSOR_OV7648 6
73 #define SENSOR_OV7660 7
74 #define SENSOR_SP80708 8
80 /* V4L2 controls supported by the driver */
81 static int sd_setbrightness(struct gspca_dev
*gspca_dev
, __s32 val
);
82 static int sd_getbrightness(struct gspca_dev
*gspca_dev
, __s32
*val
);
83 static int sd_setcontrast(struct gspca_dev
*gspca_dev
, __s32 val
);
84 static int sd_getcontrast(struct gspca_dev
*gspca_dev
, __s32
*val
);
85 static int sd_setcolors(struct gspca_dev
*gspca_dev
, __s32 val
);
86 static int sd_getcolors(struct gspca_dev
*gspca_dev
, __s32
*val
);
87 static int sd_setblue_balance(struct gspca_dev
*gspca_dev
, __s32 val
);
88 static int sd_getblue_balance(struct gspca_dev
*gspca_dev
, __s32
*val
);
89 static int sd_setred_balance(struct gspca_dev
*gspca_dev
, __s32 val
);
90 static int sd_getred_balance(struct gspca_dev
*gspca_dev
, __s32
*val
);
91 static int sd_setgamma(struct gspca_dev
*gspca_dev
, __s32 val
);
92 static int sd_getgamma(struct gspca_dev
*gspca_dev
, __s32
*val
);
93 static int sd_setautogain(struct gspca_dev
*gspca_dev
, __s32 val
);
94 static int sd_getautogain(struct gspca_dev
*gspca_dev
, __s32
*val
);
95 static int sd_setvflip(struct gspca_dev
*gspca_dev
, __s32 val
);
96 static int sd_getvflip(struct gspca_dev
*gspca_dev
, __s32
*val
);
97 static int sd_setinfrared(struct gspca_dev
*gspca_dev
, __s32 val
);
98 static int sd_getinfrared(struct gspca_dev
*gspca_dev
, __s32
*val
);
99 static int sd_setfreq(struct gspca_dev
*gspca_dev
, __s32 val
);
100 static int sd_getfreq(struct gspca_dev
*gspca_dev
, __s32
*val
);
102 static struct ctrl sd_ctrls
[] = {
103 #define BRIGHTNESS_IDX 0
106 .id
= V4L2_CID_BRIGHTNESS
,
107 .type
= V4L2_CTRL_TYPE_INTEGER
,
108 .name
= "Brightness",
110 #define BRIGHTNESS_MAX 0xffff
111 .maximum
= BRIGHTNESS_MAX
,
113 #define BRIGHTNESS_DEF 0x8000
114 .default_value
= BRIGHTNESS_DEF
,
116 .set
= sd_setbrightness
,
117 .get
= sd_getbrightness
,
119 #define CONTRAST_IDX 1
122 .id
= V4L2_CID_CONTRAST
,
123 .type
= V4L2_CTRL_TYPE_INTEGER
,
126 #define CONTRAST_MAX 127
127 .maximum
= CONTRAST_MAX
,
129 #define CONTRAST_DEF 63
130 .default_value
= CONTRAST_DEF
,
132 .set
= sd_setcontrast
,
133 .get
= sd_getcontrast
,
138 .id
= V4L2_CID_SATURATION
,
139 .type
= V4L2_CTRL_TYPE_INTEGER
,
140 .name
= "Saturation",
145 .default_value
= COLOR_DEF
,
150 #define BLUE_BALANCE_IDX 3
153 .id
= V4L2_CID_BLUE_BALANCE
,
154 .type
= V4L2_CTRL_TYPE_INTEGER
,
155 .name
= "Blue Balance",
159 #define BLUE_BALANCE_DEF 32
160 .default_value
= BLUE_BALANCE_DEF
,
162 .set
= sd_setblue_balance
,
163 .get
= sd_getblue_balance
,
165 #define RED_BALANCE_IDX 4
168 .id
= V4L2_CID_RED_BALANCE
,
169 .type
= V4L2_CTRL_TYPE_INTEGER
,
170 .name
= "Red Balance",
174 #define RED_BALANCE_DEF 32
175 .default_value
= RED_BALANCE_DEF
,
177 .set
= sd_setred_balance
,
178 .get
= sd_getred_balance
,
183 .id
= V4L2_CID_GAMMA
,
184 .type
= V4L2_CTRL_TYPE_INTEGER
,
190 .default_value
= GAMMA_DEF
,
195 #define AUTOGAIN_IDX 6
198 .id
= V4L2_CID_AUTOGAIN
,
199 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
204 #define AUTOGAIN_DEF 1
205 .default_value
= AUTOGAIN_DEF
,
207 .set
= sd_setautogain
,
208 .get
= sd_getautogain
,
210 /* ov7630/ov7648 only */
214 .id
= V4L2_CID_VFLIP
,
215 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
221 .default_value
= VFLIP_DEF
,
227 #define INFRARED_IDX 8
230 .id
= V4L2_CID_INFRARED
,
231 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
236 #define INFRARED_DEF 0
237 .default_value
= INFRARED_DEF
,
239 .set
= sd_setinfrared
,
240 .get
= sd_getinfrared
,
242 /* ov7630/ov7648/ov7660 only */
246 .id
= V4L2_CID_POWER_LINE_FREQUENCY
,
247 .type
= V4L2_CTRL_TYPE_MENU
,
248 .name
= "Light frequency filter",
250 .maximum
= 2, /* 0: 0, 1: 50Hz, 2:60Hz */
253 .default_value
= FREQ_DEF
,
260 /* table of the disabled controls */
261 static __u32 ctrl_dis
[] = {
262 (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
263 /* SENSOR_HV7131R 0 */
264 (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
265 /* SENSOR_MI0360 1 */
266 (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
267 /* SENSOR_MO4000 2 */
268 (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
269 /* SENSOR_MT9V111 3 */
270 (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) | (1 << FREQ_IDX
),
271 /* SENSOR_OM6802 4 */
273 /* SENSOR_OV7630 5 */
275 /* SENSOR_OV7648 6 */
276 (1 << AUTOGAIN_IDX
) | (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
),
277 /* SENSOR_OV7660 7 */
278 (1 << AUTOGAIN_IDX
) | (1 << INFRARED_IDX
) | (1 << VFLIP_IDX
) |
279 (1 << FREQ_IDX
), /* SENSOR_SP80708 8 */
282 static const struct v4l2_pix_format vga_mode
[] = {
283 {160, 120, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
285 .sizeimage
= 160 * 120 * 4 / 8 + 590,
286 .colorspace
= V4L2_COLORSPACE_JPEG
,
288 {320, 240, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
290 .sizeimage
= 320 * 240 * 3 / 8 + 590,
291 .colorspace
= V4L2_COLORSPACE_JPEG
,
293 {640, 480, V4L2_PIX_FMT_JPEG
, V4L2_FIELD_NONE
,
295 /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */
296 .sizeimage
= 640 * 480 * 3 / 4 + 590,
297 .colorspace
= V4L2_COLORSPACE_JPEG
,
301 /*Data from sn9c102p+hv7131r */
302 static const u8 sn_hv7131
[0x1c] = {
303 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
304 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20,
305 /* reg8 reg9 rega regb regc regd rege regf */
306 0x81, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
308 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41,
309 /* reg18 reg19 reg1a reg1b */
310 0x0a, 0x00, 0x00, 0x00
313 static const u8 sn_mi0360
[0x1c] = {
314 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
315 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20,
316 /* reg8 reg9 rega regb regc regd rege regf */
317 0x81, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
318 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
319 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61,
320 /* reg18 reg19 reg1a reg1b */
321 0x06, 0x00, 0x00, 0x00
324 static const u8 sn_mo4000
[0x1c] = {
325 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
326 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18,
327 /* reg8 reg9 rega regb regc regd rege regf */
328 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
329 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
330 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40,
331 /* reg18 reg19 reg1a reg1b */
332 0x08, 0x00, 0x00, 0x00
335 static const u8 sn_mt9v111
[0x1c] = {
336 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
337 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
338 /* reg8 reg9 rega regb regc regd rege regf */
339 0x81, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
340 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
341 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40,
342 /* reg18 reg19 reg1a reg1b */
343 0x06, 0x00, 0x00, 0x00
346 static const u8 sn_om6802
[0x1c] = {
347 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
348 0x00, 0x23, 0x72, 0x00, 0x1a, 0x20, 0x20, 0x19,
349 /* reg8 reg9 rega regb regc regd rege regf */
350 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
351 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
352 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40,
353 /* reg18 reg19 reg1a reg1b */
354 0x05, 0x00, 0x00, 0x00
357 static const u8 sn_ov7630
[0x1c] = {
358 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
359 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20,
360 /* reg8 reg9 rega regb regc regd rege regf */
361 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
363 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2,
364 /* reg18 reg19 reg1a reg1b */
365 0x0b, 0x00, 0x00, 0x00
368 static const u8 sn_ov7648
[0x1c] = {
369 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
370 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20,
371 /* reg8 reg9 rega regb regc regd rege regf */
372 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
374 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00,
375 /* reg18 reg19 reg1a reg1b */
376 0x0b, 0x00, 0x00, 0x00
379 static const u8 sn_ov7660
[0x1c] = {
380 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
381 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00,
382 /* reg8 reg9 rega regb regc regd rege regf */
383 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
384 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
385 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20,
386 /* reg18 reg19 reg1a reg1b */
387 0x07, 0x00, 0x00, 0x00
390 static const u8 sn_sp80708
[0x1c] = {
391 /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */
392 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20,
393 /* reg8 reg9 rega regb regc regd rege regf */
394 0x81, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
395 /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */
396 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00,
397 /* reg18 reg19 reg1a reg1b */
398 0x07, 0x00, 0x00, 0x00
401 /* sequence specific to the sensors - !! index = SENSOR_xxx */
402 static const u8
*sn_tb
[] = {
414 /* default gamma table */
415 static const u8 gamma_def
[17] = {
416 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99,
417 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff
419 /* gamma for sensors HV7131R and MT9V111 */
420 static const u8 gamma_spec_1
[17] = {
421 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d,
422 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5
424 /* gamma for sensor SP80708 */
425 static const u8 gamma_spec_2
[17] = {
426 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab,
427 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6
430 /* color matrix and offsets */
431 static const u8 reg84
[] = {
432 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */
433 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */
434 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */
435 0x00, 0x00, 0x00 /* YUV offsets */
437 static const u8 hv7131r_sensor_init
[][8] = {
438 {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10},
439 {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10},
440 {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10},
441 /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */
442 {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
443 {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10},
444 /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */
446 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
447 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
448 {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10},
449 {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10},
450 {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10},
451 {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10},
452 {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */
453 {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */
455 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
456 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
457 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
458 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
459 {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10},
461 {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10},
462 {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
463 {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10},
464 {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
465 {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10},
466 {0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10},
467 /* set sensor clock */
470 static const u8 mi0360_sensor_init
[][8] = {
471 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
472 {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10},
473 {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
474 {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10},
475 {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10},
476 {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10},
477 {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10},
478 {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
479 {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10},
480 {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
481 {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
482 {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
483 {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10},
484 {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10},
485 {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10},
486 {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10},
487 {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10},
488 {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10},
489 {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
490 {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
491 {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10},
492 {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10},
493 {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10},
494 {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10},
495 {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10},
496 {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10},
497 {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10},
498 {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10},
499 {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10},
500 {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10},
501 {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10},
502 {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10},
503 {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10},
505 {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10},
506 {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10},
507 {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10},
508 {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10},
509 {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10},
511 {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */
512 {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10},
513 {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10},
514 {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */
516 {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10},
517 {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */
518 /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */
519 /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */
520 {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */
521 {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */
524 static const u8 mo4000_sensor_init
[][8] = {
525 {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10},
526 {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10},
527 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
528 {0xa1, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10},
529 {0xa1, 0x21, 0x05, 0x00, 0x00, 0x00, 0x00, 0x10},
530 {0xa1, 0x21, 0x05, 0x04, 0x00, 0x00, 0x00, 0x10},
531 {0xa1, 0x21, 0x06, 0x80, 0x00, 0x00, 0x00, 0x10},
532 {0xa1, 0x21, 0x06, 0x81, 0x00, 0x00, 0x00, 0x10},
533 {0xa1, 0x21, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10},
534 {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10},
535 {0xa1, 0x21, 0x11, 0x20, 0x00, 0x00, 0x00, 0x10},
536 {0xa1, 0x21, 0x11, 0x30, 0x00, 0x00, 0x00, 0x10},
537 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
538 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
539 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
540 {0xa1, 0x21, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10},
541 {0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10},
542 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10},
543 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
544 {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10},
547 static const u8 mt9v111_sensor_init
[][8] = {
548 {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */
549 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
550 {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10},
551 {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */
552 {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */
553 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */
554 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
555 {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10},
556 {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10},
557 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
558 {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */
559 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10},
560 {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10},
561 {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10},
562 {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10},
563 {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10},
564 {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */
565 {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10},
566 {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */
567 {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */
568 {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */
569 {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */
570 {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */
571 {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */
572 {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */
573 {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */
574 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */
575 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
578 static const u8 mt9v111_sensor_param1
[][8] = {
579 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
580 {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10},
581 {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10},
582 {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */
583 {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */
585 {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */
586 {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */
587 {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */
588 {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */
591 static const u8 om6802_init0
[2][8] = {
593 {0xa0, 0x34, 0x29, 0x0e, 0x00, 0x00, 0x00, 0x10},
594 {0xa0, 0x34, 0x23, 0xb0, 0x00, 0x00, 0x00, 0x10},
596 static const u8 om6802_sensor_init
[][8] = {
597 {0xa0, 0x34, 0xdf, 0x6d, 0x00, 0x00, 0x00, 0x10},
599 {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10},
600 {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10},
601 /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */
602 {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10},
603 /* white balance & auto-exposure */
604 /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10},
606 /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10},
607 * max AGC value in AE */
608 /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10},
610 /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10},
611 * preset brightness */
612 /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10},
614 /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10},
616 {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10},
617 /* luminance mode (0x4f = AE) */
618 {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10},
620 /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10},
622 /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */
623 {0xa0, 0x34, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
626 static const u8 om6802_sensor_param1
[][8] = {
627 {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10},
628 {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10},
629 {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10},
630 {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10},
633 static const u8 ov7630_sensor_init
[][8] = {
634 {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10},
635 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
636 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
637 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
638 {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10},
639 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
640 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
641 /* win: i2c_r from 00 to 80 */
642 {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10},
643 {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10},
644 /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30)
645 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */
646 {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10},
647 {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10},
648 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
649 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
650 {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10},
651 {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10},
652 {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10},
653 {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10},
654 {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10},
655 {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10},
656 {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10},
657 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10},
658 {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10},
659 {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10},
660 {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10},
661 {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10},
662 {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10},
663 {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10},
664 {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10},
665 {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10},
666 {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10},
667 {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10},
668 {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10},
669 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
671 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
672 {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10},
673 /*fixme: + 0x12, 0x04*/
674 /* {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, * COMN
676 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
677 {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
678 {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10},
680 /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
681 /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */
683 {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10},
684 /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */
688 static const u8 ov7648_sensor_init
[][8] = {
689 {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10},
690 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */
691 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
692 {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10},
693 {0xd1, 0x21, 0x03, 0xa4, 0x30, 0x88, 0x00, 0x10},
694 {0xb1, 0x21, 0x11, 0x80, 0x08, 0x00, 0x00, 0x10},
695 {0xc1, 0x21, 0x13, 0xa0, 0x04, 0x84, 0x00, 0x10},
696 {0xd1, 0x21, 0x17, 0x1a, 0x02, 0xba, 0xf4, 0x10},
697 {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10},
698 {0xd1, 0x21, 0x1f, 0x41, 0xc0, 0x80, 0x80, 0x10},
699 {0xd1, 0x21, 0x23, 0xde, 0xa0, 0x80, 0x32, 0x10},
700 {0xd1, 0x21, 0x27, 0xfe, 0xa0, 0x00, 0x91, 0x10},
701 {0xd1, 0x21, 0x2b, 0x00, 0x88, 0x85, 0x80, 0x10},
702 {0xc1, 0x21, 0x2f, 0x9c, 0x00, 0xc4, 0x00, 0x10},
703 {0xd1, 0x21, 0x60, 0xa6, 0x60, 0x88, 0x12, 0x10},
704 {0xd1, 0x21, 0x64, 0x88, 0x00, 0x00, 0x94, 0x10},
705 {0xd1, 0x21, 0x68, 0x7a, 0x0c, 0x00, 0x00, 0x10},
706 {0xd1, 0x21, 0x6c, 0x11, 0x33, 0x22, 0x00, 0x10},
707 {0xd1, 0x21, 0x70, 0x11, 0x00, 0x10, 0x50, 0x10},
708 {0xd1, 0x21, 0x74, 0x20, 0x06, 0x00, 0xb5, 0x10},
709 {0xd1, 0x21, 0x78, 0x8a, 0x00, 0x00, 0x00, 0x10},
710 {0xb1, 0x21, 0x7c, 0x00, 0x43, 0x00, 0x00, 0x10},
712 {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10},
713 /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */
714 /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */
715 /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */
718 static const u8 ov7648_sensor_param1
[][8] = {
719 /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */
720 /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN
722 {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10},
723 {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10},
724 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
725 /* {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, * GAIN - def */
726 /* {0xb1, 0x21, 0x01, 0x6c, 0x6c, 0x00, 0x00, 0x10}, * B R - def: 80 */
728 {0xa1, 0x21, 0x11, 0x81, 0x00, 0x00, 0x00, 0x10}, /* CLKRC */
729 /* {0xa1, 0x21, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
730 /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
731 /* {0xa1, 0x21, 0x2a, 0x91, 0x00, 0x00, 0x00, 0x10}, jfm done */
732 /* {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */
733 /* {0xb1, 0x21, 0x01, 0x64, 0x84, 0x00, 0x00, 0x10}, * B R - def: 80 */
738 static const u8 ov7660_sensor_init
[][8] = {
739 {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */
740 {0xdd, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* delay 20ms */
741 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
742 /* Outformat = rawRGB */
743 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
744 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
745 /* GAIN BLUE RED VREF */
746 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
747 /* COM 1 BAVE GEAVE AECHH */
748 {0xb1, 0x21, 0x08, 0x83, 0x01, 0x00, 0x00, 0x10}, /* RAVE COM2 */
749 {0xd1, 0x21, 0x0c, 0x00, 0x08, 0x04, 0x4f, 0x10}, /* COM 3 4 5 6 */
750 {0xd1, 0x21, 0x10, 0x7f, 0x40, 0x05, 0xff, 0x10},
751 /* AECH CLKRC COM7 COM8 */
752 {0xc1, 0x21, 0x14, 0x2c, 0x00, 0x02, 0x00, 0x10}, /* COM9 COM10 */
753 {0xd1, 0x21, 0x17, 0x10, 0x60, 0x02, 0x7b, 0x10},
754 /* HSTART HSTOP VSTRT VSTOP */
755 {0xa1, 0x21, 0x1b, 0x02, 0x00, 0x00, 0x00, 0x10}, /* PSHFT */
756 {0xb1, 0x21, 0x1e, 0x01, 0x0e, 0x00, 0x00, 0x10}, /* MVFP LAEC */
757 {0xd1, 0x21, 0x20, 0x07, 0x07, 0x07, 0x07, 0x10},
758 /* BOS GBOS GROS ROS (BGGR offset) */
759 /* {0xd1, 0x21, 0x24, 0x68, 0x58, 0xd4, 0x80, 0x10}, */
760 {0xd1, 0x21, 0x24, 0x78, 0x68, 0xd4, 0x80, 0x10},
761 /* AEW AEB VPT BBIAS */
762 {0xd1, 0x21, 0x28, 0x80, 0x30, 0x00, 0x00, 0x10},
763 /* GbBIAS RSVD EXHCH EXHCL */
764 {0xd1, 0x21, 0x2c, 0x80, 0x00, 0x00, 0x62, 0x10},
765 /* RBIAS ADVFL ASDVFH YAVE */
766 {0xc1, 0x21, 0x30, 0x08, 0x30, 0xb4, 0x00, 0x10},
767 /* HSYST HSYEN HREF */
768 {0xd1, 0x21, 0x33, 0x00, 0x07, 0x84, 0x00, 0x10}, /* reserved */
769 {0xd1, 0x21, 0x37, 0x0c, 0x02, 0x43, 0x00, 0x10},
770 /* ADC ACOM OFON TSLB */
771 {0xd1, 0x21, 0x3b, 0x02, 0x6c, 0x19, 0x0e, 0x10},
772 /* COM11 COM12 COM13 COM14 */
773 {0xd1, 0x21, 0x3f, 0x41, 0xc1, 0x22, 0x08, 0x10},
774 /* EDGE COM15 COM16 COM17 */
775 {0xd1, 0x21, 0x43, 0xf0, 0x10, 0x78, 0xa8, 0x10}, /* reserved */
776 {0xd1, 0x21, 0x47, 0x60, 0x80, 0x00, 0x00, 0x10}, /* reserved */
777 {0xd1, 0x21, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* reserved */
778 {0xd1, 0x21, 0x4f, 0x46, 0x36, 0x0f, 0x17, 0x10}, /* MTX 1 2 3 4 */
779 {0xd1, 0x21, 0x53, 0x7f, 0x96, 0x40, 0x40, 0x10}, /* MTX 5 6 7 8 */
780 {0xb1, 0x21, 0x57, 0x40, 0x0f, 0x00, 0x00, 0x10}, /* MTX9 MTXS */
781 {0xd1, 0x21, 0x59, 0xba, 0x9a, 0x22, 0xb9, 0x10}, /* reserved */
782 {0xd1, 0x21, 0x5d, 0x9b, 0x10, 0xf0, 0x05, 0x10}, /* reserved */
783 {0xa1, 0x21, 0x61, 0x60, 0x00, 0x00, 0x00, 0x10}, /* reserved */
784 {0xd1, 0x21, 0x62, 0x00, 0x00, 0x50, 0x30, 0x10},
785 /* LCC1 LCC2 LCC3 LCC4 */
786 {0xa1, 0x21, 0x66, 0x00, 0x00, 0x00, 0x00, 0x10}, /* LCC5 */
787 {0xd1, 0x21, 0x67, 0x80, 0x7a, 0x90, 0x80, 0x10}, /* MANU */
788 {0xa1, 0x21, 0x6b, 0x0a, 0x00, 0x00, 0x00, 0x10},
789 /* band gap reference [0:3] DBLV */
790 {0xd1, 0x21, 0x6c, 0x30, 0x48, 0x80, 0x74, 0x10}, /* gamma curve */
791 {0xd1, 0x21, 0x70, 0x64, 0x60, 0x5c, 0x58, 0x10}, /* gamma curve */
792 {0xd1, 0x21, 0x74, 0x54, 0x4c, 0x40, 0x38, 0x10}, /* gamma curve */
793 {0xd1, 0x21, 0x78, 0x34, 0x30, 0x2f, 0x2b, 0x10}, /* gamma curve */
794 {0xd1, 0x21, 0x7c, 0x03, 0x07, 0x17, 0x34, 0x10}, /* gamma curve */
795 {0xd1, 0x21, 0x80, 0x41, 0x4d, 0x58, 0x63, 0x10}, /* gamma curve */
796 {0xd1, 0x21, 0x84, 0x6e, 0x77, 0x87, 0x95, 0x10}, /* gamma curve */
797 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
798 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
799 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
800 /* not in all ms-win traces*/
801 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
804 static const u8 ov7660_sensor_param1
[][8] = {
805 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
806 /* bits[3..0]reserved */
807 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10},
808 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
809 /* VREF vertical frame ctrl */
810 {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10},
811 {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, /* AECH 0x20 */
812 {0xa1, 0x21, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFL */
813 {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* ADVFH */
814 {0xa1, 0x21, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10}, /* GAIN */
815 /* {0xb1, 0x21, 0x01, 0x78, 0x78, 0x00, 0x00, 0x10}, * BLUE */
816 /****** (some exchanges in the win trace) ******/
818 {0xa1, 0x21, 0x93, 0x00, 0x00, 0x00, 0x00, 0x10},/* dummy line hight */
819 {0xa1, 0x21, 0x92, 0x25, 0x00, 0x00, 0x00, 0x10}, /* dummy line low */
820 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCH */
821 {0xa1, 0x21, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x10}, /* EXHCL */
822 /* {0xa1, 0x21, 0x02, 0x90, 0x00, 0x00, 0x00, 0x10}, * RED */
823 /****** (some exchanges in the win trace) ******/
824 /******!! startsensor KO if changed !!****/
826 {0xa1, 0x21, 0x93, 0x01, 0x00, 0x00, 0x00, 0x10},
827 {0xa1, 0x21, 0x92, 0xff, 0x00, 0x00, 0x00, 0x10},
828 {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10},
829 {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10},
833 static const u8 sp80708_sensor_init
[][8] = {
834 {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10},
835 {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10},
836 {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10},
837 {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10},
838 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
839 {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10},
840 {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10},
841 {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10},
842 {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10},
843 {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10},
844 {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10},
845 {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10},
846 {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10},
847 {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10},
848 {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10},
849 {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10},
850 {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10},
851 {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10},
852 {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10},
853 {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10},
854 {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10},
855 {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10},
856 {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10},
857 {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10},
858 {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10},
859 {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10},
860 {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10},
861 {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10},
862 {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10},
863 {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10},
864 {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10},
865 {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10},
866 {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10},
867 {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10},
868 {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10},
869 {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10},
870 {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10},
871 {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10},
872 {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10},
873 {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10},
874 {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10},
875 {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10},
876 {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10},
877 {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10},
878 {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10},
879 {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10},
880 {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10},
881 {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10},
882 {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10},
883 {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10},
884 {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10},
885 {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10},
886 {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10},
887 {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10},
888 {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10},
889 {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10},
890 {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10},
891 {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10},
892 {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10},
893 {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10},
894 {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10},
895 {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10},
896 {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10},
897 {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10},
898 {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10},
899 {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10},
900 {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10},
901 {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10},
902 {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10},
903 {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10},
904 {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10},
907 static const u8 sp80708_sensor_param1
[][8] = {
908 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
909 {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10},
910 {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10},
911 {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10},
912 {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10},
913 {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10},
914 {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10},
918 static const u8 (*sensor_init
[9])[8] = {
919 hv7131r_sensor_init
, /* HV7131R 0 */
920 mi0360_sensor_init
, /* MI0360 1 */
921 mo4000_sensor_init
, /* MO4000 2 */
922 mt9v111_sensor_init
, /* MT9V111 3 */
923 om6802_sensor_init
, /* OM6802 4 */
924 ov7630_sensor_init
, /* OV7630 5 */
925 ov7648_sensor_init
, /* OV7648 6 */
926 ov7660_sensor_init
, /* OV7660 7 */
927 sp80708_sensor_init
, /* SP80708 8 */
930 /* read <len> bytes to gspca_dev->usb_buf */
931 static void reg_r(struct gspca_dev
*gspca_dev
,
935 if (len
> USB_BUF_SZ
) {
936 err("reg_r: buffer overflow");
940 usb_control_msg(gspca_dev
->dev
,
941 usb_rcvctrlpipe(gspca_dev
->dev
, 0),
943 USB_DIR_IN
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
945 gspca_dev
->usb_buf
, len
,
947 PDEBUG(D_USBI
, "reg_r [%02x] -> %02x", value
, gspca_dev
->usb_buf
[0]);
950 static void reg_w1(struct gspca_dev
*gspca_dev
,
954 PDEBUG(D_USBO
, "reg_w1 [%04x] = %02x", value
, data
);
955 gspca_dev
->usb_buf
[0] = data
;
956 usb_control_msg(gspca_dev
->dev
,
957 usb_sndctrlpipe(gspca_dev
->dev
, 0),
959 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
962 gspca_dev
->usb_buf
, 1,
965 static void reg_w(struct gspca_dev
*gspca_dev
,
970 PDEBUG(D_USBO
, "reg_w [%04x] = %02x %02x ..",
971 value
, buffer
[0], buffer
[1]);
973 if (len
> USB_BUF_SZ
) {
974 err("reg_w: buffer overflow");
978 memcpy(gspca_dev
->usb_buf
, buffer
, len
);
979 usb_control_msg(gspca_dev
->dev
,
980 usb_sndctrlpipe(gspca_dev
->dev
, 0),
982 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
984 gspca_dev
->usb_buf
, len
,
988 /* I2C write 1 byte */
989 static void i2c_w1(struct gspca_dev
*gspca_dev
, u8 reg
, u8 val
)
991 struct sd
*sd
= (struct sd
*) gspca_dev
;
993 PDEBUG(D_USBO
, "i2c_w2 [%02x] = %02x", reg
, val
);
994 switch (sd
->sensor
) {
995 case SENSOR_OM6802
: /* i2c command = a0 (100 kHz) */
996 gspca_dev
->usb_buf
[0] = 0x80 | (2 << 4);
998 default: /* i2c command = a1 (400 kHz) */
999 gspca_dev
->usb_buf
[0] = 0x81 | (2 << 4);
1002 gspca_dev
->usb_buf
[1] = sd
->i2c_base
;
1003 gspca_dev
->usb_buf
[2] = reg
;
1004 gspca_dev
->usb_buf
[3] = val
;
1005 gspca_dev
->usb_buf
[4] = 0;
1006 gspca_dev
->usb_buf
[5] = 0;
1007 gspca_dev
->usb_buf
[6] = 0;
1008 gspca_dev
->usb_buf
[7] = 0x10;
1009 usb_control_msg(gspca_dev
->dev
,
1010 usb_sndctrlpipe(gspca_dev
->dev
, 0),
1012 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
1013 0x08, /* value = i2c */
1015 gspca_dev
->usb_buf
, 8,
1019 /* I2C write 8 bytes */
1020 static void i2c_w8(struct gspca_dev
*gspca_dev
,
1023 memcpy(gspca_dev
->usb_buf
, buffer
, 8);
1024 usb_control_msg(gspca_dev
->dev
,
1025 usb_sndctrlpipe(gspca_dev
->dev
, 0),
1027 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
1028 0x08, 0, /* value, index */
1029 gspca_dev
->usb_buf
, 8,
1034 /* read 5 bytes in gspca_dev->usb_buf */
1035 static void i2c_r5(struct gspca_dev
*gspca_dev
, u8 reg
)
1037 struct sd
*sd
= (struct sd
*) gspca_dev
;
1040 switch (sd
->sensor
) {
1041 case SENSOR_OM6802
: /* i2c command = 90 (100 kHz) */
1042 mode
[0] = 0x80 | 0x10;
1044 default: /* i2c command = 91 (400 kHz) */
1045 mode
[0] = 0x81 | 0x10;
1048 mode
[1] = sd
->i2c_base
;
1055 i2c_w8(gspca_dev
, mode
);
1057 mode
[0] = (mode
[0] & 0x81) | (5 << 4) | 0x02;
1059 i2c_w8(gspca_dev
, mode
);
1061 reg_r(gspca_dev
, 0x0a, 5);
1064 static void i2c_w_seq(struct gspca_dev
*gspca_dev
,
1065 const u8 (*data
)[8])
1067 while ((*data
)[0] != 0) {
1068 if ((*data
)[0] != 0xdd)
1069 i2c_w8(gspca_dev
, *data
);
1076 static void hv7131r_probe(struct gspca_dev
*gspca_dev
)
1078 i2c_w1(gspca_dev
, 0x02, 0); /* sensor wakeup */
1080 reg_w1(gspca_dev
, 0x02, 0x66); /* Gpio on */
1082 i2c_r5(gspca_dev
, 0); /* read sensor id */
1083 if (gspca_dev
->usb_buf
[0] == 0x02
1084 && gspca_dev
->usb_buf
[1] == 0x09
1085 && gspca_dev
->usb_buf
[2] == 0x01
1086 && gspca_dev
->usb_buf
[3] == 0x00
1087 && gspca_dev
->usb_buf
[4] == 0x00) {
1088 PDEBUG(D_PROBE
, "Sensor sn9c102P HV7131R found");
1091 PDEBUG(D_PROBE
, "Sensor 0x%02x 0x%02x 0x%02x - sn9c102P not found",
1092 gspca_dev
->usb_buf
[0], gspca_dev
->usb_buf
[1],
1093 gspca_dev
->usb_buf
[2]);
1096 static void mi0360_probe(struct gspca_dev
*gspca_dev
)
1098 struct sd
*sd
= (struct sd
*) gspca_dev
;
1101 static const u8 probe_tb
[][4][8] = {
1103 {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10},
1104 {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1105 {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1106 {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10}
1109 {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10},
1110 {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10},
1111 {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10},
1116 for (i
= 0; i
< ARRAY_SIZE(probe_tb
); i
++) {
1117 reg_w1(gspca_dev
, 0x17, 0x62);
1118 reg_w1(gspca_dev
, 0x01, 0x08);
1119 for (j
= 0; j
< 3; j
++)
1120 i2c_w8(gspca_dev
, probe_tb
[i
][j
]);
1122 reg_r(gspca_dev
, 0x0a, 5);
1123 val
= (gspca_dev
->usb_buf
[3] << 8) | gspca_dev
->usb_buf
[4];
1124 if (probe_tb
[i
][3][0] != 0)
1125 i2c_w8(gspca_dev
, probe_tb
[i
][3]);
1126 reg_w1(gspca_dev
, 0x01, 0x29);
1127 reg_w1(gspca_dev
, 0x17, 0x42);
1133 PDEBUG(D_PROBE
, "Sensor mt9v111");
1134 sd
->sensor
= SENSOR_MT9V111
;
1135 sd
->i2c_base
= 0x5c;
1138 PDEBUG(D_PROBE
, "Sensor mi0360");
1141 PDEBUG(D_PROBE
, "Unknown sensor %04x - forced to mi0360", val
);
1146 static void bridge_init(struct gspca_dev
*gspca_dev
,
1149 struct sd
*sd
= (struct sd
*) gspca_dev
;
1151 static const u8 reg9a_def
[] =
1152 {0x00, 0x40, 0x20, 0x00, 0x00, 0x00};
1153 static const u8 reg9a_spec
[] =
1154 {0x00, 0x40, 0x38, 0x30, 0x00, 0x20};
1155 static const u8 regd4
[] = {0x60, 0x00, 0x00};
1157 reg_w1(gspca_dev
, 0xf1, 0x00);
1158 reg_w1(gspca_dev
, 0x01, sn9c1xx
[1]);
1160 /* configure gpio */
1161 reg_w(gspca_dev
, 0x01, &sn9c1xx
[1], 2);
1162 reg_w(gspca_dev
, 0x08, &sn9c1xx
[8], 2);
1163 reg_w(gspca_dev
, 0x17, &sn9c1xx
[0x17], 5); /* jfm len was 3 */
1164 switch (sd
->sensor
) {
1166 case SENSOR_SP80708
:
1173 reg_w(gspca_dev
, 0x9a, reg9a
, 6);
1175 reg_w(gspca_dev
, 0xd4, regd4
, sizeof regd4
); /*fixme:jfm was 60 only*/
1177 reg_w(gspca_dev
, 0x03, &sn9c1xx
[3], 0x0f);
1179 switch (sd
->sensor
) {
1180 case SENSOR_MT9V111
:
1181 reg_w1(gspca_dev
, 0x01, 0x61);
1182 reg_w1(gspca_dev
, 0x17, 0x61);
1183 reg_w1(gspca_dev
, 0x01, 0x60);
1184 reg_w1(gspca_dev
, 0x01, 0x40);
1188 reg_w1(gspca_dev
, 0x02, 0x73);
1189 reg_w1(gspca_dev
, 0x17, 0x60);
1190 reg_w1(gspca_dev
, 0x01, 0x22);
1192 reg_w1(gspca_dev
, 0x01, 0x62);
1193 reg_w1(gspca_dev
, 0x17, 0x64);
1194 reg_w1(gspca_dev
, 0x17, 0x64);
1195 reg_w1(gspca_dev
, 0x01, 0x42);
1197 reg_w1(gspca_dev
, 0x01, 0x42);
1198 i2c_w8(gspca_dev
, om6802_init0
[0]);
1199 i2c_w8(gspca_dev
, om6802_init0
[1]);
1201 reg_w1(gspca_dev
, 0x02, 0x71);
1205 reg_w1(gspca_dev
, 0x01, 0x61);
1206 reg_w1(gspca_dev
, 0x17, 0xe2);
1207 reg_w1(gspca_dev
, 0x01, 0x60);
1208 reg_w1(gspca_dev
, 0x01, 0x40);
1211 reg_w1(gspca_dev
, 0x01, 0x63);
1212 reg_w1(gspca_dev
, 0x17, 0x20);
1213 reg_w1(gspca_dev
, 0x01, 0x62);
1214 reg_w1(gspca_dev
, 0x01, 0x42);
1217 case SENSOR_SP80708
:
1218 reg_w1(gspca_dev
, 0x01, 0x63);
1219 reg_w1(gspca_dev
, 0x17, 0x20);
1220 reg_w1(gspca_dev
, 0x01, 0x62);
1221 reg_w1(gspca_dev
, 0x01, 0x42);
1223 reg_w1(gspca_dev
, 0x02, 0x62);
1225 /* case SENSOR_HV7131R: */
1226 /* case SENSOR_MI0360: */
1227 /* case SENSOR_MO4000: */
1229 reg_w1(gspca_dev
, 0x01, 0x43);
1230 reg_w1(gspca_dev
, 0x17, 0x61);
1231 reg_w1(gspca_dev
, 0x01, 0x42);
1232 if (sd
->sensor
== SENSOR_HV7131R
)
1233 hv7131r_probe(gspca_dev
);
1238 /* this function is called at probe time */
1239 static int sd_config(struct gspca_dev
*gspca_dev
,
1240 const struct usb_device_id
*id
)
1242 struct sd
*sd
= (struct sd
*) gspca_dev
;
1245 cam
= &gspca_dev
->cam
;
1246 cam
->cam_mode
= vga_mode
;
1247 cam
->nmodes
= ARRAY_SIZE(vga_mode
);
1248 cam
->npkt
= 24; /* 24 packets per ISOC message */
1250 sd
->bridge
= id
->driver_info
>> 16;
1251 sd
->sensor
= id
->driver_info
>> 8;
1252 sd
->i2c_base
= id
->driver_info
;
1254 sd
->brightness
= BRIGHTNESS_DEF
;
1255 sd
->contrast
= CONTRAST_DEF
;
1256 sd
->colors
= COLOR_DEF
;
1257 sd
->blue
= BLUE_BALANCE_DEF
;
1258 sd
->red
= RED_BALANCE_DEF
;
1259 sd
->gamma
= GAMMA_DEF
;
1260 sd
->autogain
= AUTOGAIN_DEF
;
1262 sd
->vflip
= VFLIP_DEF
;
1263 sd
->infrared
= INFRARED_DEF
;
1264 sd
->freq
= FREQ_DEF
;
1265 sd
->quality
= QUALITY_DEF
;
1268 gspca_dev
->ctrl_dis
= ctrl_dis
[sd
->sensor
];
1272 /* this function is called at probe and resume time */
1273 static int sd_init(struct gspca_dev
*gspca_dev
)
1275 struct sd
*sd
= (struct sd
*) gspca_dev
;
1276 u8 regGpio
[] = { 0x29, 0x74 };
1279 /* setup a selector by bridge */
1280 reg_w1(gspca_dev
, 0xf1, 0x01);
1281 reg_r(gspca_dev
, 0x00, 1);
1282 reg_w1(gspca_dev
, 0xf1, gspca_dev
->usb_buf
[0]);
1283 reg_r(gspca_dev
, 0x00, 1); /* get sonix chip id */
1284 regF1
= gspca_dev
->usb_buf
[0];
1285 PDEBUG(D_PROBE
, "Sonix chip id: %02x", regF1
);
1286 switch (sd
->bridge
) {
1287 case BRIDGE_SN9C102P
:
1290 reg_w1(gspca_dev
, 0x02, regGpio
[1]);
1292 case BRIDGE_SN9C105
:
1295 if (sd
->sensor
== SENSOR_MI0360
)
1296 mi0360_probe(gspca_dev
);
1297 reg_w(gspca_dev
, 0x01, regGpio
, 2);
1299 case BRIDGE_SN9C120
:
1302 if (sd
->sensor
== SENSOR_MI0360
)
1303 mi0360_probe(gspca_dev
);
1305 reg_w(gspca_dev
, 0x01, regGpio
, 2);
1308 /* case BRIDGE_SN9C110: */
1309 /* case BRIDGE_SN9C325: */
1312 reg_w1(gspca_dev
, 0x02, 0x62);
1316 reg_w1(gspca_dev
, 0xf1, 0x01);
1321 static u32
setexposure(struct gspca_dev
*gspca_dev
,
1324 struct sd
*sd
= (struct sd
*) gspca_dev
;
1326 switch (sd
->sensor
) {
1327 case SENSOR_HV7131R
: {
1329 { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 };
1331 Expodoit
[3] = expo
>> 16;
1332 Expodoit
[4] = expo
>> 8;
1334 i2c_w8(gspca_dev
, Expodoit
);
1337 case SENSOR_MI0360
: {
1338 u8 expoMi
[] = /* exposure 0x0635 -> 4 fp/s 0x10 */
1339 { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 };
1340 static const u8 doit
[] = /* update sensor */
1341 { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 };
1342 static const u8 sensorgo
[] = /* sensor on */
1343 { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 };
1347 else if (expo
< 0x0001)
1349 expoMi
[3] = expo
>> 8;
1351 i2c_w8(gspca_dev
, expoMi
);
1352 i2c_w8(gspca_dev
, doit
);
1353 i2c_w8(gspca_dev
, sensorgo
);
1356 case SENSOR_MO4000
: {
1358 { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 };
1360 { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 };
1361 static const u8 gainMo
[] =
1362 { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d };
1366 else if (expo
< 0x0001)
1368 expoMof
[3] = (expo
& 0x03fc) >> 2;
1369 i2c_w8(gspca_dev
, expoMof
);
1370 expoMo10
[3] = ((expo
& 0x1c00) >> 10)
1371 | ((expo
& 0x0003) << 4);
1372 i2c_w8(gspca_dev
, expoMo10
);
1373 i2c_w8(gspca_dev
, gainMo
);
1374 PDEBUG(D_FRAM
, "set exposure %d",
1375 ((expoMo10
[3] & 0x07) << 10)
1377 | ((expoMo10
[3] & 0x30) >> 4));
1380 case SENSOR_MT9V111
: {
1382 { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 };
1386 else if (expo
< 0x0040)
1388 expo_c1
[3] = expo
>> 8;
1390 i2c_w8(gspca_dev
, expo_c1
);
1393 case SENSOR_OM6802
: {
1395 { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 };
1401 gainOm
[3] = expo
>> 2;
1402 i2c_w8(gspca_dev
, gainOm
);
1403 reg_w1(gspca_dev
, 0x96, (expo
>> 5) & 0x1f);
1404 PDEBUG(D_FRAM
, "set exposure %d", gainOm
[3]);
1411 static void setbrightness(struct gspca_dev
*gspca_dev
)
1413 struct sd
*sd
= (struct sd
*) gspca_dev
;
1417 k2
= ((int) sd
->brightness
- 0x8000) >> 10;
1418 switch (sd
->sensor
) {
1419 case SENSOR_HV7131R
:
1420 expo
= sd
->brightness
<< 4;
1421 if (expo
> 0x002dc6c0)
1423 else if (expo
< 0x02a0)
1425 sd
->exposure
= setexposure(gspca_dev
, expo
);
1429 expo
= sd
->brightness
>> 4;
1430 sd
->exposure
= setexposure(gspca_dev
, expo
);
1432 case SENSOR_MT9V111
:
1433 expo
= sd
->brightness
>> 8;
1434 sd
->exposure
= setexposure(gspca_dev
, expo
);
1437 expo
= sd
->brightness
>> 6;
1438 sd
->exposure
= setexposure(gspca_dev
, expo
);
1439 k2
= sd
->brightness
>> 11;
1443 if (sd
->sensor
!= SENSOR_MT9V111
)
1444 reg_w1(gspca_dev
, 0x96, k2
); /* color matrix Y offset */
1447 static void setcontrast(struct gspca_dev
*gspca_dev
)
1449 struct sd
*sd
= (struct sd
*) gspca_dev
;
1453 k2
= sd
->contrast
* 0x30 / (CONTRAST_MAX
+ 1) + 0x10; /* 10..40 */
1454 contrast
[0] = (k2
+ 1) / 2; /* red */
1456 contrast
[2] = k2
; /* green */
1458 contrast
[4] = (k2
+ 1) / 5; /* blue */
1460 reg_w(gspca_dev
, 0x84, contrast
, sizeof contrast
);
1463 static void setcolors(struct gspca_dev
*gspca_dev
)
1465 struct sd
*sd
= (struct sd
*) gspca_dev
;
1467 u8 reg8a
[12]; /* U & V gains */
1468 static s16 uv
[6] = { /* same as reg84 in signed decimal */
1469 -24, -38, 64, /* UR UG UB */
1470 62, -51, -9 /* VR VG VB */
1472 for (i
= 0; i
< 6; i
++) {
1473 v
= uv
[i
] * sd
->colors
/ COLOR_DEF
;
1475 reg8a
[i
* 2 + 1] = (v
>> 8) & 0x0f;
1477 reg_w(gspca_dev
, 0x8a, reg8a
, sizeof reg8a
);
1480 static void setredblue(struct gspca_dev
*gspca_dev
)
1482 struct sd
*sd
= (struct sd
*) gspca_dev
;
1484 reg_w1(gspca_dev
, 0x05, sd
->red
);
1485 /* reg_w1(gspca_dev, 0x07, 32); */
1486 reg_w1(gspca_dev
, 0x06, sd
->blue
);
1489 static void setgamma(struct gspca_dev
*gspca_dev
)
1491 struct sd
*sd
= (struct sd
*) gspca_dev
;
1494 const u8
*gamma_base
;
1495 static const u8 delta
[17] = {
1496 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a,
1497 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00
1500 switch (sd
->sensor
) {
1501 case SENSOR_HV7131R
:
1502 case SENSOR_MT9V111
:
1503 gamma_base
= gamma_spec_1
;
1505 case SENSOR_SP80708
:
1506 gamma_base
= gamma_spec_2
;
1509 gamma_base
= gamma_def
;
1513 for (i
= 0; i
< sizeof gamma
; i
++)
1514 gamma
[i
] = gamma_base
[i
]
1515 + delta
[i
] * (sd
->gamma
- GAMMA_DEF
) / 32;
1516 reg_w(gspca_dev
, 0x20, gamma
, sizeof gamma
);
1519 static void setautogain(struct gspca_dev
*gspca_dev
)
1521 struct sd
*sd
= (struct sd
*) gspca_dev
;
1523 if (gspca_dev
->ctrl_dis
& (1 << AUTOGAIN_IDX
))
1525 switch (sd
->sensor
) {
1527 case SENSOR_OV7648
: {
1530 if (sd
->sensor
== SENSOR_OV7630
)
1536 i2c_w1(&sd
->gspca_dev
, 0x13, comb
);
1541 sd
->ag_cnt
= AG_CNT_START
;
1546 /* ov7630/ov7648 only */
1547 static void setvflip(struct sd
*sd
)
1551 if (sd
->gspca_dev
.ctrl_dis
& (1 << VFLIP_IDX
))
1553 if (sd
->sensor
== SENSOR_OV7630
) {
1562 i2c_w1(&sd
->gspca_dev
, 0x75, comn
);
1565 static void setinfrared(struct sd
*sd
)
1567 if (sd
->gspca_dev
.ctrl_dis
& (1 << INFRARED_IDX
))
1569 /*fixme: different sequence for StarCam Clip and StarCam 370i */
1571 i2c_w1(&sd
->gspca_dev
, 0x02, /* gpio */
1572 sd
->infrared
? 0x66 : 0x64);
1575 static void setfreq(struct gspca_dev
*gspca_dev
)
1577 struct sd
*sd
= (struct sd
*) gspca_dev
;
1579 if (gspca_dev
->ctrl_dis
& (1 << FREQ_IDX
))
1581 if (sd
->sensor
== SENSOR_OV7660
) {
1584 com8
= 0xdf; /* auto gain/wb/expo */
1586 case 0: /* Banding filter disabled */
1587 i2c_w1(gspca_dev
, 0x13, com8
| 0x20);
1590 i2c_w1(gspca_dev
, 0x13, com8
);
1591 i2c_w1(gspca_dev
, 0x3b, 0x0a);
1594 i2c_w1(gspca_dev
, 0x13, com8
);
1595 i2c_w1(gspca_dev
, 0x3b, 0x02);
1599 u8 reg2a
= 0, reg2b
= 0, reg2d
= 0;
1601 /* Get reg2a / reg2d base values */
1602 switch (sd
->sensor
) {
1614 case 0: /* Banding filter disabled */
1616 case 1: /* 50 hz (filter on and framerate adj) */
1621 case 2: /* 60 hz (filter on, no framerate adj) */
1626 i2c_w1(gspca_dev
, 0x2a, reg2a
);
1627 i2c_w1(gspca_dev
, 0x2b, reg2b
);
1628 i2c_w1(gspca_dev
, 0x2d, reg2d
);
1632 static void setjpegqual(struct gspca_dev
*gspca_dev
)
1634 struct sd
*sd
= (struct sd
*) gspca_dev
;
1637 if (sd
->jpegqual
< 50)
1638 sc
= 5000 / sd
->jpegqual
;
1640 sc
= 200 - sd
->jpegqual
* 2;
1642 #error "No room enough in usb_buf for quantization table"
1644 for (i
= 0; i
< 64; i
++)
1645 gspca_dev
->usb_buf
[i
] =
1646 (jpeg_head
[JPEG_QT0_OFFSET
+ i
] * sc
+ 50) / 100;
1647 usb_control_msg(gspca_dev
->dev
,
1648 usb_sndctrlpipe(gspca_dev
->dev
, 0),
1650 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
1652 gspca_dev
->usb_buf
, 64,
1654 for (i
= 0; i
< 64; i
++)
1655 gspca_dev
->usb_buf
[i
] =
1656 (jpeg_head
[JPEG_QT1_OFFSET
+ i
] * sc
+ 50) / 100;
1657 usb_control_msg(gspca_dev
->dev
,
1658 usb_sndctrlpipe(gspca_dev
->dev
, 0),
1660 USB_DIR_OUT
| USB_TYPE_VENDOR
| USB_RECIP_INTERFACE
,
1662 gspca_dev
->usb_buf
, 64,
1666 reg_w1(gspca_dev
, 0x18, sd
->reg18
);
1669 /* -- start the camera -- */
1670 static int sd_start(struct gspca_dev
*gspca_dev
)
1672 struct sd
*sd
= (struct sd
*) gspca_dev
;
1674 u8 reg1
, reg2
, reg17
;
1676 const u8 (*init
)[8];
1678 static const u8 C0
[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
1679 static const u8 CA
[] = { 0x28, 0xd8, 0x14, 0xec };
1680 static const u8 CE
[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1681 static const u8 CE_ov76xx
[] =
1682 { 0x32, 0xdd, 0x32, 0xdd };
1684 /* create the JPEG header */
1685 sd
->jpeg_hdr
= kmalloc(JPEG_HDR_SZ
, GFP_KERNEL
);
1688 jpeg_define(sd
->jpeg_hdr
, gspca_dev
->height
, gspca_dev
->width
,
1689 0x21); /* JPEG 422 */
1690 jpeg_set_qual(sd
->jpeg_hdr
, sd
->quality
);
1692 /* initialize the bridge */
1693 sn9c1xx
= sn_tb
[sd
->sensor
];
1694 bridge_init(gspca_dev
, sn9c1xx
);
1695 /* initialize the sensor */
1696 i2c_w_seq(gspca_dev
, sensor_init
[sd
->sensor
]);
1698 switch (sd
->sensor
) {
1702 case SENSOR_SP80708
:
1709 reg_w1(gspca_dev
, 0x02, reg2
);
1710 reg_w1(gspca_dev
, 0x02, reg2
);
1712 reg_w1(gspca_dev
, 0x15, sn9c1xx
[0x15]);
1713 reg_w1(gspca_dev
, 0x16, sn9c1xx
[0x16]);
1714 reg_w1(gspca_dev
, 0x12, sn9c1xx
[0x12]);
1715 reg_w1(gspca_dev
, 0x13, sn9c1xx
[0x13]);
1716 reg_w1(gspca_dev
, 0x18, sn9c1xx
[0x18]);
1717 reg_w1(gspca_dev
, 0xd2, 0x6a); /* DC29 */
1718 reg_w1(gspca_dev
, 0xd3, 0x50);
1719 reg_w1(gspca_dev
, 0xc6, 0x00);
1720 reg_w1(gspca_dev
, 0xc7, 0x00);
1721 reg_w1(gspca_dev
, 0xc8, 0x50);
1722 reg_w1(gspca_dev
, 0xc9, 0x3c);
1723 reg_w1(gspca_dev
, 0x18, sn9c1xx
[0x18]);
1724 switch (sd
->sensor
) {
1725 case SENSOR_MT9V111
:
1741 reg_w1(gspca_dev
, 0x17, reg17
);
1742 /* set reg1 was here */
1743 reg_w1(gspca_dev
, 0x05, sn9c1xx
[5]); /* red */
1744 reg_w1(gspca_dev
, 0x07, sn9c1xx
[7]); /* green */
1745 reg_w1(gspca_dev
, 0x06, sn9c1xx
[6]); /* blue */
1746 reg_w1(gspca_dev
, 0x14, sn9c1xx
[0x14]);
1748 setgamma(gspca_dev
);
1750 for (i
= 0; i
< 8; i
++)
1751 reg_w(gspca_dev
, 0x84, reg84
, sizeof reg84
);
1752 switch (sd
->sensor
) {
1753 case SENSOR_MT9V111
:
1754 reg_w1(gspca_dev
, 0x9a, 0x07);
1755 reg_w1(gspca_dev
, 0x99, 0x59);
1758 reg_w1(gspca_dev
, 0x9a, 0x08);
1759 reg_w1(gspca_dev
, 0x99, 0x10);
1762 reg_w1(gspca_dev
, 0x9a, 0x0a);
1763 reg_w1(gspca_dev
, 0x99, 0x60);
1766 case SENSOR_SP80708
:
1767 reg_w1(gspca_dev
, 0x9a, 0x05);
1768 reg_w1(gspca_dev
, 0x99, 0x59);
1771 reg_w1(gspca_dev
, 0x9a, 0x08);
1772 reg_w1(gspca_dev
, 0x99, 0x59);
1776 reg_w(gspca_dev
, 0x84, reg84
, sizeof reg84
);
1777 reg_w1(gspca_dev
, 0x05, sn9c1xx
[5]); /* red */
1778 reg_w1(gspca_dev
, 0x07, sn9c1xx
[7]); /* green */
1779 reg_w1(gspca_dev
, 0x06, sn9c1xx
[6]); /* blue */
1782 mode
= gspca_dev
->cam
.cam_mode
[(int) gspca_dev
->curr_mode
].priv
;
1784 reg1
= 0x46; /* 320x240: clk 48Mhz, video trf enable */
1786 reg1
= 0x06; /* 640x480: clk 24Mhz, video trf enable */
1787 reg17
= 0x61; /* 0x:20: enable sensor clock */
1788 switch (sd
->sensor
) {
1791 /* reg1 = 0x46; * 320 clk 48Mhz 60fp/s */
1792 reg1
= 0x06; /* clk 24Mz */
1794 reg17
= 0x22; /* 640 MCKSIZE */
1795 /* reg1 = 0x06; * 640 clk 24Mz (done) */
1798 case SENSOR_MT9V111
:
1799 init
= mt9v111_sensor_param1
;
1801 reg1
= 0x04; /* 320 clk 48Mhz */
1803 /* reg1 = 0x06; * 640 clk 24Mz (done) */
1808 init
= om6802_sensor_param1
;
1809 reg17
= 0x64; /* 640 MCKSIZE */
1817 init
= ov7648_sensor_param1
;
1819 /* reg1 = 0x42; * 42 - 46? */
1822 init
= ov7660_sensor_param1
;
1823 if (sd
->bridge
== BRIDGE_SN9C120
) {
1824 if (mode
) { /* 320x240 - 160x120 */
1826 reg1
= 0x44; /* 48 Mhz, video trf eneble */
1830 reg1
= 0x06; /* 24 Mhz, video trf eneble
1831 * inverse power down */
1835 /* case SENSOR_SP80708: */
1836 init
= sp80708_sensor_param1
;
1838 /*?? reg1 = 0x04; * 320 clk 48Mhz */
1840 reg1
= 0x46; /* 640 clk 48Mz */
1846 /* more sensor initialization - param1 */
1848 i2c_w_seq(gspca_dev
, init
);
1852 reg_w(gspca_dev
, 0xc0, C0
, 6);
1853 reg_w(gspca_dev
, 0xca, CA
, 4);
1854 switch (sd
->sensor
) {
1858 reg_w(gspca_dev
, 0xce, CE_ov76xx
, 4);
1861 reg_w(gspca_dev
, 0xce, CE
, 4);
1862 /* ?? {0x1e, 0xdd, 0x2d, 0xe7} */
1867 /* here change size mode 0 -> VGA; 1 -> CIF */
1868 sd
->reg18
= sn9c1xx
[0x18] | (mode
<< 4) | 0x40;
1869 reg_w1(gspca_dev
, 0x18, sd
->reg18
);
1870 setjpegqual(gspca_dev
);
1872 reg_w1(gspca_dev
, 0x17, reg17
);
1873 reg_w1(gspca_dev
, 0x01, reg1
);
1875 switch (sd
->sensor
) {
1880 setbrightness(gspca_dev
);
1881 setcontrast(gspca_dev
);
1882 setautogain(gspca_dev
);
1887 static void sd_stopN(struct gspca_dev
*gspca_dev
)
1889 struct sd
*sd
= (struct sd
*) gspca_dev
;
1890 static const u8 stophv7131
[] =
1891 { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 };
1892 static const u8 stopmi0360
[] =
1893 { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 };
1894 static const u8 stopov7648
[] =
1895 { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 };
1900 switch (sd
->sensor
) {
1901 case SENSOR_HV7131R
:
1902 i2c_w8(gspca_dev
, stophv7131
);
1906 i2c_w8(gspca_dev
, stopmi0360
);
1910 i2c_w8(gspca_dev
, stopov7648
);
1912 case SENSOR_MT9V111
:
1917 /* case SENSOR_MO4000: */
1918 /* case SENSOR_OV7660: */
1921 sn9c1xx
= sn_tb
[(int) sd
->sensor
];
1922 reg_w1(gspca_dev
, 0x01, sn9c1xx
[1]);
1923 reg_w1(gspca_dev
, 0x17, sn9c1xx
[0x17]);
1924 reg_w1(gspca_dev
, 0x01, sn9c1xx
[1]);
1925 reg_w1(gspca_dev
, 0x01, data
);
1926 reg_w1(gspca_dev
, 0xf1, 0x00);
1929 static void sd_stop0(struct gspca_dev
*gspca_dev
)
1931 struct sd
*sd
= (struct sd
*) gspca_dev
;
1933 kfree(sd
->jpeg_hdr
);
1936 static void do_autogain(struct gspca_dev
*gspca_dev
)
1938 struct sd
*sd
= (struct sd
*) gspca_dev
;
1944 /* Thanks S., without your advice, autobright should not work :) */
1947 if (--sd
->ag_cnt
>= 0)
1949 sd
->ag_cnt
= AG_CNT_START
;
1951 delta
= atomic_read(&sd
->avg_lum
);
1952 PDEBUG(D_FRAM
, "mean lum %d", delta
);
1953 if (delta
< luma_mean
- luma_delta
||
1954 delta
> luma_mean
+ luma_delta
) {
1955 switch (sd
->sensor
) {
1956 case SENSOR_HV7131R
:
1957 expotimes
= sd
->exposure
>> 8;
1958 expotimes
+= (luma_mean
- delta
) >> 4;
1961 sd
->exposure
= setexposure(gspca_dev
,
1962 (unsigned int) (expotimes
<< 8));
1965 expotimes
= sd
->exposure
;
1966 expotimes
+= (luma_mean
- delta
) >> 2;
1969 sd
->exposure
= setexposure(gspca_dev
,
1970 (unsigned int) expotimes
);
1971 setredblue(gspca_dev
);
1974 /* case SENSOR_MO4000: */
1975 /* case SENSOR_MI0360: */
1976 /* case SENSOR_MT9V111: */
1977 expotimes
= sd
->exposure
;
1978 expotimes
+= (luma_mean
- delta
) >> 6;
1981 sd
->exposure
= setexposure(gspca_dev
,
1982 (unsigned int) expotimes
);
1983 setredblue(gspca_dev
);
1989 /* scan the URB packets */
1990 /* This function is run at interrupt level. */
1991 static void sd_pkt_scan(struct gspca_dev
*gspca_dev
,
1992 struct gspca_frame
*frame
, /* target */
1993 u8
*data
, /* isoc packet */
1994 int len
) /* iso packet length */
1996 struct sd
*sd
= (struct sd
*) gspca_dev
;
2000 if (sof
>= 0 && data
[sof
] == 0xff && data
[sof
+ 1] == 0xd9) {
2003 gspca_frame_add(gspca_dev
, LAST_PACKET
,
2004 frame
, data
, sof
+ 2);
2011 avg_lum
= ((data
[sof
+ 29] << 8) | data
[sof
+ 30]) >> 6;
2013 avg_lum
+= ((data
[sof
+ 33] << 8) | data
[sof
+ 34]) >> 6;
2015 avg_lum
+= ((data
[sof
+ 25] << 8) | data
[sof
+ 26]) >> 6;
2017 avg_lum
+= ((data
[sof
+ 37] << 8) | data
[sof
+ 38]) >> 6;
2019 avg_lum
+= ((data
[sof
+ 31] << 8) | data
[sof
+ 32]) >> 4;
2021 atomic_set(&sd
->avg_lum
, avg_lum
);
2024 if (gspca_dev
->last_packet_type
== LAST_PACKET
) {
2026 /* put the JPEG 422 header */
2027 gspca_frame_add(gspca_dev
, FIRST_PACKET
, frame
,
2028 sd
->jpeg_hdr
, JPEG_HDR_SZ
);
2030 gspca_frame_add(gspca_dev
, INTER_PACKET
, frame
, data
, len
);
2033 static int sd_setbrightness(struct gspca_dev
*gspca_dev
, __s32 val
)
2035 struct sd
*sd
= (struct sd
*) gspca_dev
;
2037 sd
->brightness
= val
;
2038 if (gspca_dev
->streaming
)
2039 setbrightness(gspca_dev
);
2043 static int sd_getbrightness(struct gspca_dev
*gspca_dev
, __s32
*val
)
2045 struct sd
*sd
= (struct sd
*) gspca_dev
;
2047 *val
= sd
->brightness
;
2051 static int sd_setcontrast(struct gspca_dev
*gspca_dev
, __s32 val
)
2053 struct sd
*sd
= (struct sd
*) gspca_dev
;
2056 if (gspca_dev
->streaming
)
2057 setcontrast(gspca_dev
);
2061 static int sd_getcontrast(struct gspca_dev
*gspca_dev
, __s32
*val
)
2063 struct sd
*sd
= (struct sd
*) gspca_dev
;
2065 *val
= sd
->contrast
;
2069 static int sd_setcolors(struct gspca_dev
*gspca_dev
, __s32 val
)
2071 struct sd
*sd
= (struct sd
*) gspca_dev
;
2074 if (gspca_dev
->streaming
)
2075 setcolors(gspca_dev
);
2079 static int sd_getcolors(struct gspca_dev
*gspca_dev
, __s32
*val
)
2081 struct sd
*sd
= (struct sd
*) gspca_dev
;
2087 static int sd_setblue_balance(struct gspca_dev
*gspca_dev
, __s32 val
)
2089 struct sd
*sd
= (struct sd
*) gspca_dev
;
2092 if (gspca_dev
->streaming
)
2093 setredblue(gspca_dev
);
2097 static int sd_getblue_balance(struct gspca_dev
*gspca_dev
, __s32
*val
)
2099 struct sd
*sd
= (struct sd
*) gspca_dev
;
2105 static int sd_setred_balance(struct gspca_dev
*gspca_dev
, __s32 val
)
2107 struct sd
*sd
= (struct sd
*) gspca_dev
;
2110 if (gspca_dev
->streaming
)
2111 setredblue(gspca_dev
);
2115 static int sd_getred_balance(struct gspca_dev
*gspca_dev
, __s32
*val
)
2117 struct sd
*sd
= (struct sd
*) gspca_dev
;
2123 static int sd_setgamma(struct gspca_dev
*gspca_dev
, __s32 val
)
2125 struct sd
*sd
= (struct sd
*) gspca_dev
;
2128 if (gspca_dev
->streaming
)
2129 setgamma(gspca_dev
);
2133 static int sd_getgamma(struct gspca_dev
*gspca_dev
, __s32
*val
)
2135 struct sd
*sd
= (struct sd
*) gspca_dev
;
2141 static int sd_setautogain(struct gspca_dev
*gspca_dev
, __s32 val
)
2143 struct sd
*sd
= (struct sd
*) gspca_dev
;
2146 if (gspca_dev
->streaming
)
2147 setautogain(gspca_dev
);
2151 static int sd_getautogain(struct gspca_dev
*gspca_dev
, __s32
*val
)
2153 struct sd
*sd
= (struct sd
*) gspca_dev
;
2155 *val
= sd
->autogain
;
2159 static int sd_setvflip(struct gspca_dev
*gspca_dev
, __s32 val
)
2161 struct sd
*sd
= (struct sd
*) gspca_dev
;
2164 if (gspca_dev
->streaming
)
2169 static int sd_getvflip(struct gspca_dev
*gspca_dev
, __s32
*val
)
2171 struct sd
*sd
= (struct sd
*) gspca_dev
;
2177 static int sd_setinfrared(struct gspca_dev
*gspca_dev
, __s32 val
)
2179 struct sd
*sd
= (struct sd
*) gspca_dev
;
2182 if (gspca_dev
->streaming
)
2187 static int sd_getinfrared(struct gspca_dev
*gspca_dev
, __s32
*val
)
2189 struct sd
*sd
= (struct sd
*) gspca_dev
;
2191 *val
= sd
->infrared
;
2195 static int sd_setfreq(struct gspca_dev
*gspca_dev
, __s32 val
)
2197 struct sd
*sd
= (struct sd
*) gspca_dev
;
2200 if (gspca_dev
->streaming
)
2205 static int sd_getfreq(struct gspca_dev
*gspca_dev
, __s32
*val
)
2207 struct sd
*sd
= (struct sd
*) gspca_dev
;
2213 static int sd_set_jcomp(struct gspca_dev
*gspca_dev
,
2214 struct v4l2_jpegcompression
*jcomp
)
2216 struct sd
*sd
= (struct sd
*) gspca_dev
;
2218 if (jcomp
->quality
< QUALITY_MIN
)
2219 sd
->quality
= QUALITY_MIN
;
2220 else if (jcomp
->quality
> QUALITY_MAX
)
2221 sd
->quality
= QUALITY_MAX
;
2223 sd
->quality
= jcomp
->quality
;
2224 if (gspca_dev
->streaming
)
2225 jpeg_set_qual(sd
->jpeg_hdr
, sd
->quality
);
2229 static int sd_get_jcomp(struct gspca_dev
*gspca_dev
,
2230 struct v4l2_jpegcompression
*jcomp
)
2232 struct sd
*sd
= (struct sd
*) gspca_dev
;
2234 memset(jcomp
, 0, sizeof *jcomp
);
2235 jcomp
->quality
= sd
->quality
;
2236 jcomp
->jpeg_markers
= V4L2_JPEG_MARKER_DHT
2237 | V4L2_JPEG_MARKER_DQT
;
2241 static int sd_querymenu(struct gspca_dev
*gspca_dev
,
2242 struct v4l2_querymenu
*menu
)
2245 case V4L2_CID_POWER_LINE_FREQUENCY
:
2246 switch (menu
->index
) {
2247 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */
2248 strcpy((char *) menu
->name
, "NoFliker");
2250 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2251 strcpy((char *) menu
->name
, "50 Hz");
2253 case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2254 strcpy((char *) menu
->name
, "60 Hz");
2262 /* sub-driver description */
2263 static const struct sd_desc sd_desc
= {
2264 .name
= MODULE_NAME
,
2266 .nctrls
= ARRAY_SIZE(sd_ctrls
),
2267 .config
= sd_config
,
2272 .pkt_scan
= sd_pkt_scan
,
2273 .dq_callback
= do_autogain
,
2274 .get_jcomp
= sd_get_jcomp
,
2275 .set_jcomp
= sd_set_jcomp
,
2276 .querymenu
= sd_querymenu
,
2279 /* -- module initialisation -- */
2280 #define BSI(bridge, sensor, i2c_addr) \
2281 .driver_info = (BRIDGE_ ## bridge << 16) \
2282 | (SENSOR_ ## sensor << 8) \
2284 static const __devinitdata
struct usb_device_id device_table
[] = {
2285 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2286 {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120
, MI0360
, 0x5d)},
2287 {USB_DEVICE(0x0458, 0x702e), BSI(SN9C120
, OV7660
, 0x21)},
2289 {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105
, OV7660
, 0x21)},
2290 {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105
, OV7660
, 0x21)},
2291 {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105
, MI0360
, 0x5d)},
2292 {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105
, MI0360
, 0x5d)},
2293 {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105
, MI0360
, 0x5d)},
2294 {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105
, OV7660
, 0x21)},
2295 {USB_DEVICE(0x06f8, 0x3008), BSI(SN9C105
, OV7660
, 0x21)},
2296 /* {USB_DEVICE(0x0c45, 0x603a), BSI(SN9C102P, OV7648, 0x21)}, */
2297 {USB_DEVICE(0x0c45, 0x6040), BSI(SN9C102P
, HV7131R
, 0x11)},
2298 /* {USB_DEVICE(0x0c45, 0x607a), BSI(SN9C102P, OV7648, 0x21)}, */
2299 /* {USB_DEVICE(0x0c45, 0x607b), BSI(SN9C102P, OV7660, 0x21)}, */
2300 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P
, HV7131R
, 0x11)},
2301 /* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x21)}, */
2302 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105
, MI0360
, 0x5d)},
2303 /* {USB_DEVICE(0x0c45, 0x60c2), BSI(SN9C105, P1030xC, 0x??)}, */
2304 /* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6802, 0x34)}, */
2305 /* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
2306 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105
, MO4000
, 0x21)},
2307 /* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
2308 /* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x21)}, */
2309 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105
, OV7660
, 0x21)},
2310 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2311 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105
, HV7131R
, 0x11)},
2312 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105
, OV7630
, 0x21)},
2314 {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120
, MI0360
, 0x5d)}, /*sn9c128*/
2315 /* {USB_DEVICE(0x0c45, 0x6102), BSI(SN9C120, P1030xC, ??)}, */
2316 /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6802, 0x34)}, */
2317 {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120
, OV7648
, 0x21)}, /*sn9c128*/
2318 {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120
, OV7660
, 0x21)}, /*sn9c128*/
2319 {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120
, HV7131R
, 0x11)}, /*sn9c128*/
2320 {USB_DEVICE(0x0c45, 0x610e), BSI(SN9C120
, OV7630
, 0x21)}, /*sn9c128*/
2321 /* {USB_DEVICE(0x0c45, 0x610f), BSI(SN9C120, S5K53BEB, 0x??)}, */
2322 /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */
2323 /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */
2324 {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C120
, OM6802
, 0x34)}, /*sn9c325?*/
2326 {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C120
, OV7648
, 0x21)}, /*sn9c110?*/
2327 {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110
, MO4000
, 0x21)},
2328 {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110
, OV7630
, 0x21)},
2329 /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */
2330 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2331 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120
, MI0360
, 0x5d)},
2333 /* {USB_DEVICE(0x0c45, 0x6132), BSI(SN9C120, OV7670, 0x21)}, */
2334 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120
, MO4000
, 0x21)},
2335 {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120
, OV7648
, 0x21)},
2336 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2337 {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120
, OV7660
, 0x21)},
2339 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120
, HV7131R
, 0x11)},
2340 {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120
, OV7630
, 0x21)},
2341 /* {USB_DEVICE(0x0c45, 0x6142), BSI(SN9C120, PO2030N, ??)}, *sn9c120b*/
2342 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120
, SP80708
, 0x18)}, /*sn9c120b*/
2343 {USB_DEVICE(0x0c45, 0x6148), BSI(SN9C120
, OM6802
, 0x34)}, /*sn9c120b*/
2346 MODULE_DEVICE_TABLE(usb
, device_table
);
2348 /* -- device connect -- */
2349 static int sd_probe(struct usb_interface
*intf
,
2350 const struct usb_device_id
*id
)
2352 return gspca_dev_probe(intf
, id
, &sd_desc
, sizeof(struct sd
),
2356 static struct usb_driver sd_driver
= {
2357 .name
= MODULE_NAME
,
2358 .id_table
= device_table
,
2360 .disconnect
= gspca_disconnect
,
2362 .suspend
= gspca_suspend
,
2363 .resume
= gspca_resume
,
2367 /* -- module insert / remove -- */
2368 static int __init
sd_mod_init(void)
2371 ret
= usb_register(&sd_driver
);
2377 static void __exit
sd_mod_exit(void)
2379 usb_deregister(&sd_driver
);
2380 info("deregistered");
2383 module_init(sd_mod_init
);
2384 module_exit(sd_mod_exit
);