diff options
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 539 |
1 files changed, 361 insertions, 178 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 245a30ec5fb1..d75b1d20b318 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -54,8 +54,10 @@ struct sd { | |||
54 | #define SENSOR_HV7131R 0 | 54 | #define SENSOR_HV7131R 0 |
55 | #define SENSOR_MI0360 1 | 55 | #define SENSOR_MI0360 1 |
56 | #define SENSOR_MO4000 2 | 56 | #define SENSOR_MO4000 2 |
57 | #define SENSOR_OV7648 3 | 57 | #define SENSOR_OM6802 3 |
58 | #define SENSOR_OV7660 4 | 58 | #define SENSOR_OV7630 4 |
59 | #define SENSOR_OV7648 5 | ||
60 | #define SENSOR_OV7660 6 | ||
59 | unsigned char i2c_base; | 61 | unsigned char i2c_base; |
60 | }; | 62 | }; |
61 | 63 | ||
@@ -76,7 +78,8 @@ static struct ctrl sd_ctrls[] = { | |||
76 | .type = V4L2_CTRL_TYPE_INTEGER, | 78 | .type = V4L2_CTRL_TYPE_INTEGER, |
77 | .name = "Brightness", | 79 | .name = "Brightness", |
78 | .minimum = 0, | 80 | .minimum = 0, |
79 | .maximum = 0xffff, | 81 | #define BRIGHTNESS_MAX 0xffff |
82 | .maximum = BRIGHTNESS_MAX, | ||
80 | .step = 1, | 83 | .step = 1, |
81 | #define BRIGHTNESS_DEF 0x7fff | 84 | #define BRIGHTNESS_DEF 0x7fff |
82 | .default_value = BRIGHTNESS_DEF, | 85 | .default_value = BRIGHTNESS_DEF, |
@@ -90,7 +93,8 @@ static struct ctrl sd_ctrls[] = { | |||
90 | .type = V4L2_CTRL_TYPE_INTEGER, | 93 | .type = V4L2_CTRL_TYPE_INTEGER, |
91 | .name = "Contrast", | 94 | .name = "Contrast", |
92 | .minimum = 0, | 95 | .minimum = 0, |
93 | .maximum = 127, | 96 | #define CONTRAST_MAX 127 |
97 | .maximum = CONTRAST_MAX, | ||
94 | .step = 1, | 98 | .step = 1, |
95 | #define CONTRAST_DEF 63 | 99 | #define CONTRAST_DEF 63 |
96 | .default_value = CONTRAST_DEF, | 100 | .default_value = CONTRAST_DEF, |
@@ -104,14 +108,15 @@ static struct ctrl sd_ctrls[] = { | |||
104 | .type = V4L2_CTRL_TYPE_INTEGER, | 108 | .type = V4L2_CTRL_TYPE_INTEGER, |
105 | .name = "Color", | 109 | .name = "Color", |
106 | .minimum = 0, | 110 | .minimum = 0, |
107 | .maximum = 255, | 111 | .maximum = 64, |
108 | .step = 1, | 112 | .step = 1, |
109 | #define COLOR_DEF 127 | 113 | #define COLOR_DEF 32 |
110 | .default_value = COLOR_DEF, | 114 | .default_value = COLOR_DEF, |
111 | }, | 115 | }, |
112 | .set = sd_setcolors, | 116 | .set = sd_setcolors, |
113 | .get = sd_getcolors, | 117 | .get = sd_getcolors, |
114 | }, | 118 | }, |
119 | #define AUTOGAIN_IDX 3 | ||
115 | { | 120 | { |
116 | { | 121 | { |
117 | .id = V4L2_CID_AUTOGAIN, | 122 | .id = V4L2_CID_AUTOGAIN, |
@@ -131,7 +136,7 @@ static struct ctrl sd_ctrls[] = { | |||
131 | static struct v4l2_pix_format vga_mode[] = { | 136 | static struct v4l2_pix_format vga_mode[] = { |
132 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 137 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
133 | .bytesperline = 160, | 138 | .bytesperline = 160, |
134 | .sizeimage = 160 * 120 * 3 / 8 + 590, | 139 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
135 | .colorspace = V4L2_COLORSPACE_JPEG, | 140 | .colorspace = V4L2_COLORSPACE_JPEG, |
136 | .priv = 2}, | 141 | .priv = 2}, |
137 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 142 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
@@ -180,6 +185,31 @@ static const __u8 sn_mo4000[] = { | |||
180 | 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 185 | 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
181 | }; | 186 | }; |
182 | 187 | ||
188 | static const __u8 sn_om6802[] = { | ||
189 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | ||
190 | 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20, | ||
191 | /* reg8 reg9 rega regb regc regd rege regf */ | ||
192 | 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
193 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | ||
194 | 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40, | ||
195 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | ||
196 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
197 | 0x08, 0x22, 0x44, 0x63, 0x7d, 0x92, 0xa3, 0xaf, | ||
198 | 0xbc, 0xc4, 0xcd, 0xd5, 0xdc, 0xe1, 0xe8, 0xef, | ||
199 | 0xf7 | ||
200 | }; | ||
201 | |||
202 | static const __u8 sn_ov7630[] = { | ||
203 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | ||
204 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20, | ||
205 | /* reg8 reg9 rega regb regc regd rege regf */ | ||
206 | 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10, | ||
207 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | ||
208 | 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2, | ||
209 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | ||
210 | 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
211 | }; | ||
212 | |||
183 | static const __u8 sn_ov7648[] = { | 213 | static const __u8 sn_ov7648[] = { |
184 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 214 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
185 | 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20, | 215 | 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20, |
@@ -207,31 +237,22 @@ static const __u8 *sn_tb[] = { | |||
207 | sn_hv7131, | 237 | sn_hv7131, |
208 | sn_mi0360, | 238 | sn_mi0360, |
209 | sn_mo4000, | 239 | sn_mo4000, |
240 | sn_om6802, | ||
241 | sn_ov7630, | ||
210 | sn_ov7648, | 242 | sn_ov7648, |
211 | sn_ov7660 | 243 | sn_ov7660 |
212 | }; | 244 | }; |
213 | 245 | ||
214 | static const __u8 regsn20[] = { | 246 | static const __u8 gamma_def[] = { |
215 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, | 247 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, |
216 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff | 248 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff |
217 | }; | 249 | }; |
218 | static const __u8 regsn20_sn9c325[] = { | ||
219 | 0x0a, 0x3a, 0x56, 0x6c, 0x7e, 0x8d, 0x9a, 0xa4, | ||
220 | 0xaf, 0xbb, 0xc5, 0xcd, 0xd5, 0xde, 0xe8, 0xed, 0xf5 | ||
221 | }; | ||
222 | 250 | ||
223 | static const __u8 reg84[] = { | 251 | static const __u8 reg84[] = { |
224 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe5, 0x0f, | 252 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe5, 0x0f, |
225 | 0xe4, 0x0f, 0x38, 0x00, 0x3e, 0x00, 0xc3, 0x0f, | 253 | 0xe4, 0x0f, 0x38, 0x00, 0x3e, 0x00, 0xc3, 0x0f, |
226 | /* 0x00, 0x00, 0x00, 0x00, 0x00 */ | 254 | 0xf7, 0x0f, 0x00, 0x00, 0x00 |
227 | 0xf7, 0x0f, 0x0a, 0x00, 0x00 | ||
228 | }; | ||
229 | static const __u8 reg84_sn9c325[] = { | ||
230 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe4, 0x0f, | ||
231 | 0xd3, 0x0f, 0x4b, 0x00, 0x48, 0x00, 0xc0, 0x0f, | ||
232 | 0xf8, 0x0f, 0x00, 0x00, 0x00 | ||
233 | }; | 255 | }; |
234 | |||
235 | static const __u8 hv7131r_sensor_init[][8] = { | 256 | static const __u8 hv7131r_sensor_init[][8] = { |
236 | {0xC1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, | 257 | {0xC1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, |
237 | {0xB1, 0x11, 0x34, 0x17, 0x7F, 0x00, 0x00, 0x10}, | 258 | {0xB1, 0x11, 0x34, 0x17, 0x7F, 0x00, 0x00, 0x10}, |
@@ -340,6 +361,92 @@ static const __u8 mo4000_sensor_init[][8] = { | |||
340 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, | 361 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
341 | {} | 362 | {} |
342 | }; | 363 | }; |
364 | static __u8 om6802_sensor_init[][8] = { | ||
365 | {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10}, | ||
366 | {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10}, | ||
367 | {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10}, | ||
368 | {0xa0, 0x34, 0xdd, 0x18, 0x00, 0x00, 0x00, 0x10}, | ||
369 | /* {0xa0, 0x34, 0xfb, 0x11, 0x00, 0x00, 0x00, 0x10}, */ | ||
370 | {0xa0, 0x34, 0xf0, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
371 | /* white balance & auto-exposure */ | ||
372 | /* {0xa0, 0x34, 0xf1, 0x02, 0x00, 0x00, 0x00, 0x10}, | ||
373 | * set color mode */ | ||
374 | /* {0xa0, 0x34, 0xfe, 0x5b, 0x00, 0x00, 0x00, 0x10}, | ||
375 | * max AGC value in AE */ | ||
376 | /* {0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
377 | * preset AGC */ | ||
378 | /* {0xa0, 0x34, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
379 | * preset brightness */ | ||
380 | /* {0xa0, 0x34, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
381 | * preset contrast */ | ||
382 | /* {0xa0, 0x34, 0xe8, 0x31, 0x00, 0x00, 0x00, 0x10}, | ||
383 | * preset gamma */ | ||
384 | {0xa0, 0x34, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x10}, | ||
385 | /* luminance mode (0x4f = AE) */ | ||
386 | {0xa0, 0x34, 0xe4, 0xff, 0x00, 0x00, 0x00, 0x10}, | ||
387 | /* preset shutter */ | ||
388 | /* {0xa0, 0x34, 0xef, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
389 | * auto frame rate */ | ||
390 | /* {0xa0, 0x34, 0xfb, 0xee, 0x00, 0x00, 0x00, 0x10}, */ | ||
391 | |||
392 | /* {0xa0, 0x34, 0x71, 0x84, 0x00, 0x00, 0x00, 0x10}, */ | ||
393 | /* {0xa0, 0x34, 0x72, 0x05, 0x00, 0x00, 0x00, 0x10}, */ | ||
394 | /* {0xa0, 0x34, 0x68, 0x80, 0x00, 0x00, 0x00, 0x10}, */ | ||
395 | /* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */ | ||
396 | {} | ||
397 | }; | ||
398 | static const __u8 ov7630_sensor_init[][8] = { | ||
399 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, | ||
400 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | ||
401 | /* win: delay 20ms */ | ||
402 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | ||
403 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | ||
404 | /* win: delay 20ms */ | ||
405 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | ||
406 | /* win: i2c_r from 00 to 80 */ | ||
407 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, | ||
408 | {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10}, | ||
409 | {0xd1, 0x21, 0x11, 0x00, 0x48, 0xc0, 0x00, 0x10}, | ||
410 | {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10}, | ||
411 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, | ||
412 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
413 | {0xd1, 0x21, 0x1f, 0x00, 0x80, 0x80, 0x80, 0x10}, | ||
414 | {0xd1, 0x21, 0x23, 0xde, 0x10, 0x8a, 0xa0, 0x10}, | ||
415 | {0xc1, 0x21, 0x27, 0xca, 0xa2, 0x74, 0x00, 0x10}, | ||
416 | {0xd1, 0x21, 0x2a, 0x88, 0x00, 0x88, 0x01, 0x10}, | ||
417 | {0xc1, 0x21, 0x2e, 0x80, 0x00, 0x18, 0x00, 0x10}, | ||
418 | {0xa1, 0x21, 0x21, 0x08, 0x00, 0x00, 0x00, 0x10}, | ||
419 | {0xa1, 0x21, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
420 | {0xa1, 0x21, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
421 | {0xb1, 0x21, 0x32, 0xc2, 0x08, 0x00, 0x00, 0x10}, | ||
422 | {0xb1, 0x21, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
423 | {0xd1, 0x21, 0x60, 0x05, 0x40, 0x12, 0x57, 0x10}, | ||
424 | {0xa1, 0x21, 0x64, 0x73, 0x00, 0x00, 0x00, 0x10}, | ||
425 | {0xd1, 0x21, 0x65, 0x00, 0x55, 0x01, 0xac, 0x10}, | ||
426 | {0xa1, 0x21, 0x69, 0x38, 0x00, 0x00, 0x00, 0x10}, | ||
427 | {0xd1, 0x21, 0x6f, 0x1f, 0x01, 0x00, 0x10, 0x10}, | ||
428 | {0xd1, 0x21, 0x73, 0x50, 0x20, 0x02, 0x01, 0x10}, | ||
429 | {0xd1, 0x21, 0x77, 0xf3, 0x90, 0x98, 0x98, 0x10}, | ||
430 | {0xc1, 0x21, 0x7b, 0x00, 0x4c, 0xf7, 0x00, 0x10}, | ||
431 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, | ||
432 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
433 | /* */ | ||
434 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | ||
435 | {0xa1, 0x21, 0x12, 0x48, 0x00, 0x00, 0x00, 0x10}, | ||
436 | /*fixme: + 0x12, 0x04*/ | ||
437 | {0xa1, 0x21, 0x75, 0x82, 0x00, 0x00, 0x00, 0x10}, | ||
438 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, | ||
439 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
440 | {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10}, | ||
441 | /* */ | ||
442 | {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
443 | {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, | ||
444 | {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, | ||
445 | /* */ | ||
446 | {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10}, | ||
447 | /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */ | ||
448 | {} | ||
449 | }; | ||
343 | static const __u8 ov7660_sensor_init[][8] = { | 450 | static const __u8 ov7660_sensor_init[][8] = { |
344 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ | 451 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ |
345 | /* (delay 20ms) */ | 452 | /* (delay 20ms) */ |
@@ -506,10 +613,16 @@ static const __u8 qtable4[] = { | |||
506 | 0x29, 0x29, 0x29, 0x29 | 613 | 0x29, 0x29, 0x29, 0x29 |
507 | }; | 614 | }; |
508 | 615 | ||
509 | /* read <len> bytes (len < sizeof gspca_dev->usb_buf) to gspca_dev->usb_buf */ | 616 | /* read <len> bytes to gspca_dev->usb_buf */ |
510 | static void reg_r(struct gspca_dev *gspca_dev, | 617 | static void reg_r(struct gspca_dev *gspca_dev, |
511 | __u16 value, int len) | 618 | __u16 value, int len) |
512 | { | 619 | { |
620 | #ifdef GSPCA_DEBUG | ||
621 | if (len > USB_BUF_SZ) { | ||
622 | err("reg_r: buffer overflow"); | ||
623 | return; | ||
624 | } | ||
625 | #endif | ||
513 | usb_control_msg(gspca_dev->dev, | 626 | usb_control_msg(gspca_dev->dev, |
514 | usb_rcvctrlpipe(gspca_dev->dev, 0), | 627 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
515 | 0, | 628 | 0, |
@@ -542,29 +655,20 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
542 | { | 655 | { |
543 | PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..", | 656 | PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..", |
544 | value, buffer[0], buffer[1]); | 657 | value, buffer[0], buffer[1]); |
545 | if (len <= sizeof gspca_dev->usb_buf) { | 658 | #ifdef GSPCA_DEBUG |
546 | memcpy(gspca_dev->usb_buf, buffer, len); | 659 | if (len > USB_BUF_SZ) { |
547 | usb_control_msg(gspca_dev->dev, | 660 | err("reg_w: buffer overflow"); |
548 | usb_sndctrlpipe(gspca_dev->dev, 0), | 661 | return; |
549 | 0x08, | ||
550 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
551 | value, 0, | ||
552 | gspca_dev->usb_buf, len, | ||
553 | 500); | ||
554 | } else { | ||
555 | __u8 *tmpbuf; | ||
556 | |||
557 | tmpbuf = kmalloc(len, GFP_KERNEL); | ||
558 | memcpy(tmpbuf, buffer, len); | ||
559 | usb_control_msg(gspca_dev->dev, | ||
560 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
561 | 0x08, | ||
562 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
563 | value, 0, | ||
564 | tmpbuf, len, | ||
565 | 500); | ||
566 | kfree(tmpbuf); | ||
567 | } | 662 | } |
663 | #endif | ||
664 | memcpy(gspca_dev->usb_buf, buffer, len); | ||
665 | usb_control_msg(gspca_dev->dev, | ||
666 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
667 | 0x08, | ||
668 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
669 | value, 0, | ||
670 | gspca_dev->usb_buf, len, | ||
671 | 500); | ||
568 | } | 672 | } |
569 | 673 | ||
570 | /* I2C write 1 byte */ | 674 | /* I2C write 1 byte */ |
@@ -665,7 +769,7 @@ static int configure_gpio(struct gspca_dev *gspca_dev, | |||
665 | static const __u8 regd4[] = {0x60, 0x00, 0x00}; | 769 | static const __u8 regd4[] = {0x60, 0x00, 0x00}; |
666 | 770 | ||
667 | reg_w1(gspca_dev, 0xf1, 0x00); | 771 | reg_w1(gspca_dev, 0xf1, 0x00); |
668 | reg_w1(gspca_dev, 0x01, 0x00); /*jfm was sn9c1xx[1] in v1*/ | 772 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
669 | 773 | ||
670 | /* configure gpio */ | 774 | /* configure gpio */ |
671 | reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); | 775 | reg_w(gspca_dev, 0x01, &sn9c1xx[1], 2); |
@@ -685,21 +789,41 @@ static int configure_gpio(struct gspca_dev *gspca_dev, | |||
685 | 789 | ||
686 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); | 790 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); |
687 | 791 | ||
688 | switch (sd->bridge) { | 792 | switch (sd->sensor) { |
689 | case BRIDGE_SN9C325: | 793 | case SENSOR_OM6802: |
794 | reg_w1(gspca_dev, 0x02, 0x71); | ||
795 | reg_w1(gspca_dev, 0x01, 0x42); | ||
796 | reg_w1(gspca_dev, 0x17, 0x64); | ||
797 | reg_w1(gspca_dev, 0x01, 0x42); | ||
798 | break; | ||
799 | /*jfm: from win trace */ | ||
800 | case SENSOR_OV7630: | ||
801 | reg_w1(gspca_dev, 0x01, 0x61); | ||
802 | reg_w1(gspca_dev, 0x17, 0xe2); | ||
803 | reg_w1(gspca_dev, 0x01, 0x60); | ||
804 | reg_w1(gspca_dev, 0x01, 0x40); | ||
805 | break; | ||
806 | case SENSOR_OV7648: | ||
690 | reg_w1(gspca_dev, 0x01, 0x43); | 807 | reg_w1(gspca_dev, 0x01, 0x43); |
691 | reg_w1(gspca_dev, 0x17, 0xae); | 808 | reg_w1(gspca_dev, 0x17, 0xae); |
692 | reg_w1(gspca_dev, 0x01, 0x42); | 809 | reg_w1(gspca_dev, 0x01, 0x42); |
693 | break; | 810 | break; |
811 | /*jfm: from win trace */ | ||
812 | case SENSOR_OV7660: | ||
813 | reg_w1(gspca_dev, 0x01, 0x61); | ||
814 | reg_w1(gspca_dev, 0x17, 0x20); | ||
815 | reg_w1(gspca_dev, 0x01, 0x60); | ||
816 | reg_w1(gspca_dev, 0x01, 0x40); | ||
817 | break; | ||
694 | default: | 818 | default: |
695 | reg_w1(gspca_dev, 0x01, 0x43); | 819 | reg_w1(gspca_dev, 0x01, 0x43); |
696 | reg_w1(gspca_dev, 0x17, 0x61); | 820 | reg_w1(gspca_dev, 0x17, 0x61); |
697 | reg_w1(gspca_dev, 0x01, 0x42); | 821 | reg_w1(gspca_dev, 0x01, 0x42); |
698 | } | 822 | if (sd->sensor == SENSOR_HV7131R) { |
699 | 823 | if (probesensor(gspca_dev) < 0) | |
700 | if (sd->sensor == SENSOR_HV7131R) { | 824 | return -ENODEV; |
701 | if (probesensor(gspca_dev) < 0) | 825 | } |
702 | return -ENODEV; | 826 | break; |
703 | } | 827 | } |
704 | return 0; | 828 | return 0; |
705 | } | 829 | } |
@@ -737,6 +861,40 @@ static void mo4000_InitSensor(struct gspca_dev *gspca_dev) | |||
737 | } | 861 | } |
738 | } | 862 | } |
739 | 863 | ||
864 | static void om6802_InitSensor(struct gspca_dev *gspca_dev) | ||
865 | { | ||
866 | int i = 0; | ||
867 | |||
868 | while (om6802_sensor_init[i][0]) { | ||
869 | i2c_w8(gspca_dev, om6802_sensor_init[i]); | ||
870 | i++; | ||
871 | } | ||
872 | } | ||
873 | |||
874 | static void ov7630_InitSensor(struct gspca_dev *gspca_dev) | ||
875 | { | ||
876 | int i = 0; | ||
877 | |||
878 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 76 01 */ | ||
879 | i++; | ||
880 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 (RGB+SRST) */ | ||
881 | i++; | ||
882 | msleep(20); | ||
883 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */ | ||
884 | i++; | ||
885 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 c8 */ | ||
886 | i++; | ||
887 | msleep(20); | ||
888 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); /* 12 48 */ | ||
889 | i++; | ||
890 | /*jfm:win i2c_r from 00 to 80*/ | ||
891 | |||
892 | while (ov7630_sensor_init[i][0]) { | ||
893 | i2c_w8(gspca_dev, ov7630_sensor_init[i]); | ||
894 | i++; | ||
895 | } | ||
896 | } | ||
897 | |||
740 | static void ov7648_InitSensor(struct gspca_dev *gspca_dev) | 898 | static void ov7648_InitSensor(struct gspca_dev *gspca_dev) |
741 | { | 899 | { |
742 | int i = 0; | 900 | int i = 0; |
@@ -783,11 +941,19 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
783 | sd->autogain = AUTOGAIN_DEF; | 941 | sd->autogain = AUTOGAIN_DEF; |
784 | sd->ag_cnt = -1; | 942 | sd->ag_cnt = -1; |
785 | 943 | ||
944 | switch (sd->sensor) { | ||
945 | case SENSOR_OV7630: | ||
946 | case SENSOR_OV7648: | ||
947 | case SENSOR_OV7660: | ||
948 | gspca_dev->ctrl_dis = (1 << AUTOGAIN_IDX); | ||
949 | break; | ||
950 | } | ||
951 | |||
786 | return 0; | 952 | return 0; |
787 | } | 953 | } |
788 | 954 | ||
789 | /* this function is called at open time */ | 955 | /* this function is called at probe and resume time */ |
790 | static int sd_open(struct gspca_dev *gspca_dev) | 956 | static int sd_init(struct gspca_dev *gspca_dev) |
791 | { | 957 | { |
792 | struct sd *sd = (struct sd *) gspca_dev; | 958 | struct sd *sd = (struct sd *) gspca_dev; |
793 | /* const __u8 *sn9c1xx; */ | 959 | /* const __u8 *sn9c1xx; */ |
@@ -891,16 +1057,53 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev, | |||
891 | | ((expoMo10[3] & 0x30) >> 4)); | 1057 | | ((expoMo10[3] & 0x30) >> 4)); |
892 | break; | 1058 | break; |
893 | } | 1059 | } |
1060 | case SENSOR_OM6802: { | ||
1061 | __u8 gainOm[] = | ||
1062 | { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 }; | ||
1063 | |||
1064 | if (expo > 0x03ff) | ||
1065 | expo = 0x03ff; | ||
1066 | if (expo < 0x0001) | ||
1067 | expo = 0x0001; | ||
1068 | gainOm[3] = expo >> 2; | ||
1069 | i2c_w8(gspca_dev, gainOm); | ||
1070 | reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f); | ||
1071 | PDEBUG(D_CONF, "set exposure %d", gainOm[3]); | ||
1072 | break; | ||
1073 | } | ||
894 | } | 1074 | } |
895 | return expo; | 1075 | return expo; |
896 | } | 1076 | } |
897 | 1077 | ||
1078 | /* this function is used for sensors o76xx only */ | ||
1079 | static void setbrightcont(struct gspca_dev *gspca_dev) | ||
1080 | { | ||
1081 | struct sd *sd = (struct sd *) gspca_dev; | ||
1082 | unsigned val; | ||
1083 | __u8 reg84_full[0x15]; | ||
1084 | |||
1085 | memset(reg84_full, 0, sizeof reg84_full); | ||
1086 | val = sd->contrast * 0x20 / CONTRAST_MAX + 0x10; /* 10..30 */ | ||
1087 | reg84_full[2] = val; | ||
1088 | reg84_full[0] = (val + 1) / 2; | ||
1089 | reg84_full[4] = (val + 1) / 5; | ||
1090 | if (val > BRIGHTNESS_DEF) | ||
1091 | val = (sd->brightness - BRIGHTNESS_DEF) * 0x20 | ||
1092 | / BRIGHTNESS_MAX; | ||
1093 | else | ||
1094 | val = 0; | ||
1095 | reg84_full[0x12] = val; /* 00..1f */ | ||
1096 | reg_w(gspca_dev, 0x84, reg84_full, sizeof reg84_full); | ||
1097 | } | ||
1098 | |||
1099 | /* sensor != ov76xx */ | ||
898 | static void setbrightness(struct gspca_dev *gspca_dev) | 1100 | static void setbrightness(struct gspca_dev *gspca_dev) |
899 | { | 1101 | { |
900 | struct sd *sd = (struct sd *) gspca_dev; | 1102 | struct sd *sd = (struct sd *) gspca_dev; |
901 | unsigned int expo; | 1103 | unsigned int expo; |
902 | __u8 k2; | 1104 | __u8 k2; |
903 | 1105 | ||
1106 | k2 = sd->brightness >> 10; | ||
904 | switch (sd->sensor) { | 1107 | switch (sd->sensor) { |
905 | case SENSOR_HV7131R: | 1108 | case SENSOR_HV7131R: |
906 | expo = sd->brightness << 4; | 1109 | expo = sd->brightness << 4; |
@@ -915,12 +1118,17 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
915 | expo = sd->brightness >> 4; | 1118 | expo = sd->brightness >> 4; |
916 | sd->exposure = setexposure(gspca_dev, expo); | 1119 | sd->exposure = setexposure(gspca_dev, expo); |
917 | break; | 1120 | break; |
1121 | case SENSOR_OM6802: | ||
1122 | expo = sd->brightness >> 6; | ||
1123 | sd->exposure = setexposure(gspca_dev, expo); | ||
1124 | k2 = sd->brightness >> 11; | ||
1125 | break; | ||
918 | } | 1126 | } |
919 | 1127 | ||
920 | k2 = sd->brightness >> 10; | ||
921 | reg_w1(gspca_dev, 0x96, k2); | 1128 | reg_w1(gspca_dev, 0x96, k2); |
922 | } | 1129 | } |
923 | 1130 | ||
1131 | /* sensor != ov76xx */ | ||
924 | static void setcontrast(struct gspca_dev *gspca_dev) | 1132 | static void setcontrast(struct gspca_dev *gspca_dev) |
925 | { | 1133 | { |
926 | struct sd *sd = (struct sd *) gspca_dev; | 1134 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -937,31 +1145,30 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
937 | static void setcolors(struct gspca_dev *gspca_dev) | 1145 | static void setcolors(struct gspca_dev *gspca_dev) |
938 | { | 1146 | { |
939 | struct sd *sd = (struct sd *) gspca_dev; | 1147 | struct sd *sd = (struct sd *) gspca_dev; |
940 | __u8 data; | 1148 | __u8 blue, red; |
941 | int colour; | ||
942 | 1149 | ||
943 | colour = sd->colors - 128; | 1150 | if (sd->colors >= 32) { |
944 | if (colour > 0) | 1151 | red = 32 + (sd->colors - 32) / 2; |
945 | data = (colour + 32) & 0x7f; /* blue */ | 1152 | blue = 64 - sd->colors; |
946 | else | 1153 | } else { |
947 | data = (-colour + 32) & 0x7f; /* red */ | 1154 | red = sd->colors; |
948 | reg_w1(gspca_dev, 0x05, data); | 1155 | blue = 32 + (32 - sd->colors) / 2; |
1156 | } | ||
1157 | reg_w1(gspca_dev, 0x05, red); | ||
1158 | /* reg_w1(gspca_dev, 0x07, 32); */ | ||
1159 | reg_w1(gspca_dev, 0x06, blue); | ||
949 | } | 1160 | } |
950 | 1161 | ||
951 | static void setautogain(struct gspca_dev *gspca_dev) | 1162 | static void setautogain(struct gspca_dev *gspca_dev) |
952 | { | 1163 | { |
953 | struct sd *sd = (struct sd *) gspca_dev; | 1164 | struct sd *sd = (struct sd *) gspca_dev; |
954 | 1165 | ||
955 | switch (sd->sensor) { | 1166 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) |
956 | case SENSOR_HV7131R: | 1167 | return; |
957 | case SENSOR_MO4000: | 1168 | if (sd->autogain) |
958 | case SENSOR_MI0360: | 1169 | sd->ag_cnt = AG_CNT_START; |
959 | if (sd->autogain) | 1170 | else |
960 | sd->ag_cnt = AG_CNT_START; | 1171 | sd->ag_cnt = -1; |
961 | else | ||
962 | sd->ag_cnt = -1; | ||
963 | break; | ||
964 | } | ||
965 | } | 1172 | } |
966 | 1173 | ||
967 | /* -- start the camera -- */ | 1174 | /* -- start the camera -- */ |
@@ -975,13 +1182,12 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
975 | static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; | 1182 | static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
976 | static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; | 1183 | static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
977 | static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ | 1184 | static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ |
978 | static const __u8 CE_sn9c325[] = | 1185 | static const __u8 CE_ov76xx[] = |
979 | { 0x32, 0xdd, 0x32, 0xdd }; /* OV7648 - SN9C325 */ | 1186 | { 0x32, 0xdd, 0x32, 0xdd }; /* OV7630/48 */ |
980 | 1187 | ||
981 | sn9c1xx = sn_tb[(int) sd->sensor]; | 1188 | sn9c1xx = sn_tb[(int) sd->sensor]; |
982 | configure_gpio(gspca_dev, sn9c1xx); | 1189 | configure_gpio(gspca_dev, sn9c1xx); |
983 | 1190 | ||
984 | /* reg_w1(gspca_dev, 0x01, 0x44); jfm from win trace*/ | ||
985 | reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]); | 1191 | reg_w1(gspca_dev, 0x15, sn9c1xx[0x15]); |
986 | reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]); | 1192 | reg_w1(gspca_dev, 0x16, sn9c1xx[0x16]); |
987 | reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]); | 1193 | reg_w1(gspca_dev, 0x12, sn9c1xx[0x12]); |
@@ -994,10 +1200,17 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
994 | reg_w1(gspca_dev, 0xc8, 0x50); | 1200 | reg_w1(gspca_dev, 0xc8, 0x50); |
995 | reg_w1(gspca_dev, 0xc9, 0x3c); | 1201 | reg_w1(gspca_dev, 0xc9, 0x3c); |
996 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); | 1202 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
997 | switch (sd->bridge) { | 1203 | switch (sd->sensor) { |
998 | case BRIDGE_SN9C325: | 1204 | case SENSOR_OV7630: |
1205 | reg17 = 0xe2; | ||
1206 | break; | ||
1207 | case SENSOR_OV7648: | ||
999 | reg17 = 0xae; | 1208 | reg17 = 0xae; |
1000 | break; | 1209 | break; |
1210 | /*jfm: from win trace */ | ||
1211 | case SENSOR_OV7660: | ||
1212 | reg17 = 0xa0; | ||
1213 | break; | ||
1001 | default: | 1214 | default: |
1002 | reg17 = 0x60; | 1215 | reg17 = 0x60; |
1003 | break; | 1216 | break; |
@@ -1007,24 +1220,11 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1007 | reg_w1(gspca_dev, 0x07, sn9c1xx[7]); | 1220 | reg_w1(gspca_dev, 0x07, sn9c1xx[7]); |
1008 | reg_w1(gspca_dev, 0x06, sn9c1xx[6]); | 1221 | reg_w1(gspca_dev, 0x06, sn9c1xx[6]); |
1009 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); | 1222 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); |
1010 | switch (sd->bridge) { | 1223 | reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def); |
1011 | case BRIDGE_SN9C325: | 1224 | for (i = 0; i < 8; i++) |
1012 | reg_w(gspca_dev, 0x20, regsn20_sn9c325, | 1225 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); |
1013 | sizeof regsn20_sn9c325); | ||
1014 | for (i = 0; i < 8; i++) | ||
1015 | reg_w(gspca_dev, 0x84, reg84_sn9c325, | ||
1016 | sizeof reg84_sn9c325); | ||
1017 | reg_w1(gspca_dev, 0x9a, 0x0a); | ||
1018 | reg_w1(gspca_dev, 0x99, 0x60); | ||
1019 | break; | ||
1020 | default: | ||
1021 | reg_w(gspca_dev, 0x20, regsn20, sizeof regsn20); | ||
1022 | for (i = 0; i < 8; i++) | ||
1023 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); | ||
1024 | reg_w1(gspca_dev, 0x9a, 0x08); | 1226 | reg_w1(gspca_dev, 0x9a, 0x08); |
1025 | reg_w1(gspca_dev, 0x99, 0x59); | 1227 | reg_w1(gspca_dev, 0x99, 0x59); |
1026 | break; | ||
1027 | } | ||
1028 | 1228 | ||
1029 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | 1229 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; |
1030 | if (mode) | 1230 | if (mode) |
@@ -1049,6 +1249,15 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1049 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | 1249 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ |
1050 | } | 1250 | } |
1051 | break; | 1251 | break; |
1252 | case SENSOR_OM6802: | ||
1253 | om6802_InitSensor(gspca_dev); | ||
1254 | reg17 = 0x64; /* 640 MCKSIZE */ | ||
1255 | break; | ||
1256 | case SENSOR_OV7630: | ||
1257 | ov7630_InitSensor(gspca_dev); | ||
1258 | reg17 = 0xe2; | ||
1259 | reg1 = 0x44; | ||
1260 | break; | ||
1052 | case SENSOR_OV7648: | 1261 | case SENSOR_OV7648: |
1053 | ov7648_InitSensor(gspca_dev); | 1262 | ov7648_InitSensor(gspca_dev); |
1054 | reg17 = 0xa2; | 1263 | reg17 = 0xa2; |
@@ -1073,9 +1282,10 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1073 | } | 1282 | } |
1074 | reg_w(gspca_dev, 0xc0, C0, 6); | 1283 | reg_w(gspca_dev, 0xc0, C0, 6); |
1075 | reg_w(gspca_dev, 0xca, CA, 4); | 1284 | reg_w(gspca_dev, 0xca, CA, 4); |
1076 | switch (sd->bridge) { | 1285 | switch (sd->sensor) { |
1077 | case BRIDGE_SN9C325: | 1286 | case SENSOR_OV7630: |
1078 | reg_w(gspca_dev, 0xce, CE_sn9c325, 4); | 1287 | case SENSOR_OV7648: |
1288 | reg_w(gspca_dev, 0xce, CE_ov76xx, 4); | ||
1079 | break; | 1289 | break; |
1080 | default: | 1290 | default: |
1081 | reg_w(gspca_dev, 0xce, CE, 4); | 1291 | reg_w(gspca_dev, 0xce, CE, 4); |
@@ -1093,10 +1303,20 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1093 | reg_w1(gspca_dev, 0x18, reg18); | 1303 | reg_w1(gspca_dev, 0x18, reg18); |
1094 | 1304 | ||
1095 | reg_w1(gspca_dev, 0x17, reg17); | 1305 | reg_w1(gspca_dev, 0x17, reg17); |
1096 | reg_w1(gspca_dev, 0x01, reg1); | 1306 | switch (sd->sensor) { |
1097 | setbrightness(gspca_dev); | 1307 | case SENSOR_HV7131R: |
1098 | setcontrast(gspca_dev); | 1308 | case SENSOR_MI0360: |
1309 | case SENSOR_MO4000: | ||
1310 | case SENSOR_OM6802: | ||
1311 | setbrightness(gspca_dev); | ||
1312 | setcontrast(gspca_dev); | ||
1313 | break; | ||
1314 | default: /* OV76xx */ | ||
1315 | setbrightcont(gspca_dev); | ||
1316 | break; | ||
1317 | } | ||
1099 | setautogain(gspca_dev); | 1318 | setautogain(gspca_dev); |
1319 | reg_w1(gspca_dev, 0x01, reg1); | ||
1100 | } | 1320 | } |
1101 | 1321 | ||
1102 | static void sd_stopN(struct gspca_dev *gspca_dev) | 1322 | static void sd_stopN(struct gspca_dev *gspca_dev) |
@@ -1119,6 +1339,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1119 | i2c_w8(gspca_dev, stopmi0360); | 1339 | i2c_w8(gspca_dev, stopmi0360); |
1120 | data = 0x29; | 1340 | data = 0x29; |
1121 | break; | 1341 | break; |
1342 | case SENSOR_OV7630: | ||
1122 | case SENSOR_OV7648: | 1343 | case SENSOR_OV7648: |
1123 | data = 0x29; | 1344 | data = 0x29; |
1124 | break; | 1345 | break; |
@@ -1132,15 +1353,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1132 | reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); | 1353 | reg_w1(gspca_dev, 0x17, sn9c1xx[0x17]); |
1133 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | 1354 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
1134 | reg_w1(gspca_dev, 0x01, data); | 1355 | reg_w1(gspca_dev, 0x01, data); |
1135 | reg_w1(gspca_dev, 0xf1, 0x01); | 1356 | reg_w1(gspca_dev, 0xf1, 0x00); |
1136 | } | ||
1137 | |||
1138 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
1139 | { | ||
1140 | } | ||
1141 | |||
1142 | static void sd_close(struct gspca_dev *gspca_dev) | ||
1143 | { | ||
1144 | } | 1357 | } |
1145 | 1358 | ||
1146 | static void do_autogain(struct gspca_dev *gspca_dev) | 1359 | static void do_autogain(struct gspca_dev *gspca_dev) |
@@ -1174,6 +1387,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
1174 | default: | 1387 | default: |
1175 | /* case SENSOR_MO4000: */ | 1388 | /* case SENSOR_MO4000: */ |
1176 | /* case SENSOR_MI0360: */ | 1389 | /* case SENSOR_MI0360: */ |
1390 | /* case SENSOR_OM6802: */ | ||
1177 | expotimes = sd->exposure; | 1391 | expotimes = sd->exposure; |
1178 | expotimes += (luma_mean - delta) >> 6; | 1392 | expotimes += (luma_mean - delta) >> 6; |
1179 | if (expotimes < 0) | 1393 | if (expotimes < 0) |
@@ -1229,69 +1443,24 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
1229 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | 1443 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); |
1230 | } | 1444 | } |
1231 | 1445 | ||
1232 | static unsigned int getexposure(struct gspca_dev *gspca_dev) | ||
1233 | { | ||
1234 | struct sd *sd = (struct sd *) gspca_dev; | ||
1235 | __u8 hexpo, mexpo, lexpo; | ||
1236 | |||
1237 | switch (sd->sensor) { | ||
1238 | case SENSOR_HV7131R: | ||
1239 | /* read sensor exposure */ | ||
1240 | i2c_r5(gspca_dev, 0x25); | ||
1241 | return (gspca_dev->usb_buf[0] << 16) | ||
1242 | | (gspca_dev->usb_buf[1] << 8) | ||
1243 | | gspca_dev->usb_buf[2]; | ||
1244 | case SENSOR_MI0360: | ||
1245 | /* read sensor exposure */ | ||
1246 | i2c_r5(gspca_dev, 0x09); | ||
1247 | return (gspca_dev->usb_buf[0] << 8) | ||
1248 | | gspca_dev->usb_buf[1]; | ||
1249 | case SENSOR_MO4000: | ||
1250 | i2c_r5(gspca_dev, 0x0e); | ||
1251 | hexpo = 0; /* gspca_dev->usb_buf[1] & 0x07; */ | ||
1252 | mexpo = 0x40; /* gspca_dev->usb_buf[2] & 0xff; */ | ||
1253 | lexpo = (gspca_dev->usb_buf[1] & 0x30) >> 4; | ||
1254 | PDEBUG(D_CONF, "exposure %d", | ||
1255 | (hexpo << 10) | (mexpo << 2) | lexpo); | ||
1256 | return (hexpo << 10) | (mexpo << 2) | lexpo; | ||
1257 | default: | ||
1258 | /* case SENSOR_OV7648: * jfm: is it ok for 7648? */ | ||
1259 | /* case SENSOR_OV7660: */ | ||
1260 | /* read sensor exposure */ | ||
1261 | i2c_r5(gspca_dev, 0x04); | ||
1262 | hexpo = gspca_dev->usb_buf[3] & 0x2f; | ||
1263 | lexpo = gspca_dev->usb_buf[0] & 0x02; | ||
1264 | i2c_r5(gspca_dev, 0x08); | ||
1265 | mexpo = gspca_dev->usb_buf[2]; | ||
1266 | return (hexpo << 10) | (mexpo << 2) | lexpo; | ||
1267 | } | ||
1268 | } | ||
1269 | |||
1270 | static void getbrightness(struct gspca_dev *gspca_dev) | ||
1271 | { | ||
1272 | struct sd *sd = (struct sd *) gspca_dev; | ||
1273 | |||
1274 | /* hardcoded registers seem not readable */ | ||
1275 | switch (sd->sensor) { | ||
1276 | case SENSOR_HV7131R: | ||
1277 | sd->brightness = getexposure(gspca_dev) >> 4; | ||
1278 | break; | ||
1279 | case SENSOR_MI0360: | ||
1280 | sd->brightness = getexposure(gspca_dev) << 4; | ||
1281 | break; | ||
1282 | case SENSOR_MO4000: | ||
1283 | sd->brightness = getexposure(gspca_dev) << 4; | ||
1284 | break; | ||
1285 | } | ||
1286 | } | ||
1287 | |||
1288 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 1446 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
1289 | { | 1447 | { |
1290 | struct sd *sd = (struct sd *) gspca_dev; | 1448 | struct sd *sd = (struct sd *) gspca_dev; |
1291 | 1449 | ||
1292 | sd->brightness = val; | 1450 | sd->brightness = val; |
1293 | if (gspca_dev->streaming) | 1451 | if (gspca_dev->streaming) { |
1294 | setbrightness(gspca_dev); | 1452 | switch (sd->sensor) { |
1453 | case SENSOR_HV7131R: | ||
1454 | case SENSOR_MI0360: | ||
1455 | case SENSOR_MO4000: | ||
1456 | case SENSOR_OM6802: | ||
1457 | setbrightness(gspca_dev); | ||
1458 | break; | ||
1459 | default: /* OV76xx */ | ||
1460 | setbrightcont(gspca_dev); | ||
1461 | break; | ||
1462 | } | ||
1463 | } | ||
1295 | return 0; | 1464 | return 0; |
1296 | } | 1465 | } |
1297 | 1466 | ||
@@ -1299,7 +1468,6 @@ static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | |||
1299 | { | 1468 | { |
1300 | struct sd *sd = (struct sd *) gspca_dev; | 1469 | struct sd *sd = (struct sd *) gspca_dev; |
1301 | 1470 | ||
1302 | getbrightness(gspca_dev); | ||
1303 | *val = sd->brightness; | 1471 | *val = sd->brightness; |
1304 | return 0; | 1472 | return 0; |
1305 | } | 1473 | } |
@@ -1309,8 +1477,19 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | |||
1309 | struct sd *sd = (struct sd *) gspca_dev; | 1477 | struct sd *sd = (struct sd *) gspca_dev; |
1310 | 1478 | ||
1311 | sd->contrast = val; | 1479 | sd->contrast = val; |
1312 | if (gspca_dev->streaming) | 1480 | if (gspca_dev->streaming) { |
1313 | setcontrast(gspca_dev); | 1481 | switch (sd->sensor) { |
1482 | case SENSOR_HV7131R: | ||
1483 | case SENSOR_MI0360: | ||
1484 | case SENSOR_MO4000: | ||
1485 | case SENSOR_OM6802: | ||
1486 | setcontrast(gspca_dev); | ||
1487 | break; | ||
1488 | default: /* OV76xx */ | ||
1489 | setbrightcont(gspca_dev); | ||
1490 | break; | ||
1491 | } | ||
1492 | } | ||
1314 | return 0; | 1493 | return 0; |
1315 | } | 1494 | } |
1316 | 1495 | ||
@@ -1364,11 +1543,9 @@ static const struct sd_desc sd_desc = { | |||
1364 | .ctrls = sd_ctrls, | 1543 | .ctrls = sd_ctrls, |
1365 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1544 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1366 | .config = sd_config, | 1545 | .config = sd_config, |
1367 | .open = sd_open, | 1546 | .init = sd_init, |
1368 | .start = sd_start, | 1547 | .start = sd_start, |
1369 | .stopN = sd_stopN, | 1548 | .stopN = sd_stopN, |
1370 | .stop0 = sd_stop0, | ||
1371 | .close = sd_close, | ||
1372 | .pkt_scan = sd_pkt_scan, | 1549 | .pkt_scan = sd_pkt_scan, |
1373 | .dq_callback = do_autogain, | 1550 | .dq_callback = do_autogain, |
1374 | }; | 1551 | }; |
@@ -1379,7 +1556,7 @@ static const struct sd_desc sd_desc = { | |||
1379 | | (SENSOR_ ## sensor << 8) \ | 1556 | | (SENSOR_ ## sensor << 8) \ |
1380 | | (i2c_addr) | 1557 | | (i2c_addr) |
1381 | static const __devinitdata struct usb_device_id device_table[] = { | 1558 | static const __devinitdata struct usb_device_id device_table[] = { |
1382 | #ifndef CONFIG_USB_SN9C102 | 1559 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
1383 | {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)}, | 1560 | {USB_DEVICE(0x0458, 0x7025), BSI(SN9C120, MI0360, 0x5d)}, |
1384 | {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)}, | 1561 | {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)}, |
1385 | {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)}, | 1562 | {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)}, |
@@ -1406,15 +1583,17 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
1406 | /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */ | 1583 | /* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */ |
1407 | /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */ | 1584 | /* {USB_DEVICE(0x0c45, 0x6122), BSI(SN9C110, ICM105C, 0x??)}, */ |
1408 | /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */ | 1585 | /* {USB_DEVICE(0x0c45, 0x6123), BSI(SN9C110, SanyoCCD, 0x??)}, */ |
1409 | {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C325, OV7648, 0x21)}, | 1586 | {USB_DEVICE(0x0c45, 0x6128), BSI(SN9C110, OM6802, 0x21)}, /*sn9c325?*/ |
1410 | /* bw600.inf: | 1587 | /*bw600.inf:*/ |
1411 | {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C110, OV7648, 0x21)}, */ | 1588 | {USB_DEVICE(0x0c45, 0x612a), BSI(SN9C110, OV7648, 0x21)}, /*sn9c325?*/ |
1412 | {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)}, | 1589 | {USB_DEVICE(0x0c45, 0x612c), BSI(SN9C110, MO4000, 0x21)}, |
1413 | /* {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x??)}, */ | 1590 | {USB_DEVICE(0x0c45, 0x612e), BSI(SN9C110, OV7630, 0x21)}, |
1414 | /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */ | 1591 | /* {USB_DEVICE(0x0c45, 0x612f), BSI(SN9C110, ICM105C, 0x??)}, */ |
1415 | #ifndef CONFIG_USB_SN9C102 | 1592 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
1416 | {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)}, | 1593 | {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)}, |
1594 | #endif | ||
1417 | {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)}, | 1595 | {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)}, |
1596 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
1418 | /* {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x??)}, */ | 1597 | /* {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x??)}, */ |
1419 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, | 1598 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, |
1420 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, | 1599 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, |
@@ -1438,6 +1617,10 @@ static struct usb_driver sd_driver = { | |||
1438 | .id_table = device_table, | 1617 | .id_table = device_table, |
1439 | .probe = sd_probe, | 1618 | .probe = sd_probe, |
1440 | .disconnect = gspca_disconnect, | 1619 | .disconnect = gspca_disconnect, |
1620 | #ifdef CONFIG_PM | ||
1621 | .suspend = gspca_suspend, | ||
1622 | .resume = gspca_resume, | ||
1623 | #endif | ||
1441 | }; | 1624 | }; |
1442 | 1625 | ||
1443 | /* -- module insert / remove -- */ | 1626 | /* -- module insert / remove -- */ |