22 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
50 static s32 AC50Hz = 0xff;
54 static char sensor[7];
57 " Driver sensor ('MI1320'/'MI2020'/'OV9655'/'OV2640')");
62 #define SD_SETGET(thename) \
63 static int sd_set_##thename(struct gspca_dev *gspca_dev, s32 val)\
65 struct sd *sd = (struct sd *) gspca_dev;\
67 sd->vcur.thename = val;\
68 if (gspca_dev->streaming)\
72 static int sd_get_##thename(struct gspca_dev *gspca_dev, s32 *val)\
74 struct sd *sd = (struct sd *) gspca_dev;\
76 *val = sd->vcur.thename;\
92 #define GL860_NCTRLS 11
100 #define SET_MY_CTRL(theid, \
101 thetype, thelabel, thename) \
102 if (sd->vmax.thename != 0) {\
103 sd_ctrls[nCtrls].qctrl.id = theid;\
104 sd_ctrls[nCtrls].qctrl.type = thetype;\
105 strcpy(sd_ctrls[nCtrls].qctrl.name, thelabel);\
106 sd_ctrls[nCtrls].qctrl.minimum = 0;\
107 sd_ctrls[nCtrls].qctrl.maximum = sd->vmax.thename;\
108 sd_ctrls[nCtrls].qctrl.default_value = sd->vcur.thename;\
109 sd_ctrls[nCtrls].qctrl.step = \
110 (sd->vmax.thename < 16) ? 1 : sd->vmax.thename/16;\
111 sd_ctrls[nCtrls].set = sd_set_##thename;\
112 sd_ctrls[nCtrls].get = sd_get_##thename;\
118 struct sd *
sd = (
struct sd *) gspca_dev;
119 struct ctrl *sd_ctrls;
123 sd_ctrls = sd_ctrls_mi1320;
125 sd_ctrls = sd_ctrls_mi2020;
127 sd_ctrls = sd_ctrls_ov2640;
129 sd_ctrls = sd_ctrls_ov9655;
164 static const struct sd_desc sd_desc_mi1320 = {
166 .ctrls = sd_ctrls_mi1320,
170 .isoc_init = sd_isoc_init,
173 .pkt_scan = sd_pkt_scan,
174 .dq_callback = sd_callback,
177 static const struct sd_desc sd_desc_mi2020 = {
179 .ctrls = sd_ctrls_mi2020,
183 .isoc_init = sd_isoc_init,
186 .pkt_scan = sd_pkt_scan,
187 .dq_callback = sd_callback,
190 static const struct sd_desc sd_desc_ov2640 = {
192 .ctrls = sd_ctrls_ov2640,
196 .isoc_init = sd_isoc_init,
199 .pkt_scan = sd_pkt_scan,
200 .dq_callback = sd_callback,
203 static const struct sd_desc sd_desc_ov9655 = {
205 .ctrls = sd_ctrls_ov9655,
209 .isoc_init = sd_isoc_init,
212 .pkt_scan = sd_pkt_scan,
213 .dq_callback = sd_callback,
221 .sizeimage = 640 * 480,
227 .sizeimage = 800 * 598,
232 .bytesperline = 1280,
233 .sizeimage = 1280 * 1024,
238 .bytesperline = 1600,
239 .sizeimage = 1600 * 1198,
248 .sizeimage = 640 * 480,
254 .sizeimage = 800 * 600,
259 .bytesperline = 1280,
260 .sizeimage = 1280 * 960,
265 .bytesperline = 1600,
266 .sizeimage = 1600 * 1200,
275 .sizeimage = 640 * 480,
281 .sizeimage = 800 * 600,
286 .bytesperline = 1280,
287 .sizeimage = 1280 * 960,
296 .sizeimage = 640 * 480,
301 .bytesperline = 1280,
302 .sizeimage = 1280 * 960,
314 struct sd *
sd = (
struct sd *) gspca_dev;
319 vendor_id =
id->idVendor;
320 product_id =
id->idProduct;
326 if (
strcmp(sensor,
"MI1320") == 0)
328 else if (
strcmp(sensor,
"OV2640") == 0)
330 else if (
strcmp(sensor,
"OV9655") == 0)
332 else if (
strcmp(sensor,
"MI2020") == 0)
336 if (gl860_guess_sensor(gspca_dev, vendor_id, product_id) == -1)
339 cam = &gspca_dev->
cam;
343 gspca_dev->
sd_desc = &sd_desc_mi1320;
350 gspca_dev->
sd_desc = &sd_desc_mi2020;
357 gspca_dev->
sd_desc = &sd_desc_ov2640;
364 gspca_dev->
sd_desc = &sd_desc_ov9655;
371 dev_init_settings(gspca_dev);
373 ((
struct sd *) gspca_dev)->vcur.AC50Hz = AC50Hz;
374 gl860_build_control_table(gspca_dev);
380 static int sd_init(
struct gspca_dev *gspca_dev)
382 struct sd *sd = (
struct sd *) gspca_dev;
388 static int sd_isoc_init(
struct gspca_dev *gspca_dev)
390 struct sd *sd = (
struct sd *) gspca_dev;
396 static int sd_start(
struct gspca_dev *gspca_dev)
398 struct sd *sd = (
struct sd *) gspca_dev;
404 static void sd_stop0(
struct gspca_dev *gspca_dev)
406 struct sd *sd = (
struct sd *) gspca_dev;
415 static void sd_pkt_scan(
struct gspca_dev *gspca_dev,
418 struct sd *sd = (
struct sd *) gspca_dev;
423 sd->
swapRB * (gspca_dev->
cam.cam_mode[mode].bytesperline + 1);
438 if (nSkipped + len <= nToSkip)
441 if (nSkipped < nToSkip && nSkipped + len > nToSkip) {
442 data += nToSkip - nSkipped;
443 len -= nToSkip - nSkipped;
444 nSkipped = nToSkip + 1;
455 static void sd_callback(
struct gspca_dev *gspca_dev)
457 struct sd *sd = (
struct sd *) gspca_dev;
464 ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, (
void *)&state);
468 upsideDown = (state == 0xc8 || state == 0x40);
497 {USB_DEVICE(0x05e3, 0x0503)},
498 {USB_DEVICE(0x05e3, 0xf191)},
516 static struct usb_driver sd_driver = {
518 .id_table = device_table,
520 .disconnect = sd_disconnect,
522 .suspend = gspca_suspend,
523 .resume = gspca_resume,
524 .reset_resume = gspca_resume,
538 struct usb_device *
udev = gspca_dev->
dev;
545 req, pref, val, index,
547 len, 400 + 200 * (len > 1));
550 req, pref, val, index,
NULL, len, 400);
555 req, pref, val, index,
557 len, 400 + 200 * (len > 1));
561 req, pref, val, index,
NULL, len, 400);
566 pr_err(
"ctrl transfer failed %4d [p%02x r%d v%04x i%04x len%d]\n",
567 r, pref, req, val, index, len);
568 else if (len > 1 && r < len)
569 PDEBUG(
D_ERR,
"short ctrl transfer %d/%d", r, len);
580 for (n = 0; n < len; n++) {
581 if (tbl[n].
idx != 0xffff)
584 else if (tbl[n].val == 0xffff)
596 if (tbl[n].
idx != 0xffff)
599 else if (tbl[n].val == 0xffff)
611 for (n = 0; n < len; n++) {
612 if (
memcmp(tbl[n].data,
"\xff\xff\xff", 3) != 0)
620 static int gl860_guess_sensor(
struct gspca_dev *gspca_dev,
621 u16 vendor_id,
u16 product_id)
623 struct sd *sd = (
struct sd *) gspca_dev;
624 u8 probe, nb26, nb96, nOV, ntry;
626 if (product_id == 0xf191)
630 ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &probe);
631 ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &probe);
648 PDEBUG(D_PROBE,
"probing for sensor MI2020 or OVXXXX");
650 for (ntry = 0; ntry < 4; ntry++) {
657 ctrl_in(gspca_dev, 0xc0, 2, 0x7a00, 0x8030, 1, &probe);
658 PDEBUG(D_PROBE,
"probe=0x%02x", probe);
664 PDEBUG(D_PROBE,
"0xff -> OVXXXX");
665 PDEBUG(D_PROBE,
"probing for sensor OV2640 or OV9655");
668 for (ntry = 0; ntry < 4; ntry++) {
669 ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000,
672 ctrl_out(gspca_dev, 0x40, 1, 0x6000, 0x800a,
677 ctrl_in(gspca_dev, 0xc0, 2, 0x6000, 0x800a,
680 if (probe == 0x26 || probe == 0x40) {
682 "probe=0x%02x -> OV2640",
688 if (probe == 0x96 || probe == 0x55) {
690 "probe=0x%02x -> OV9655",
696 PDEBUG(D_PROBE,
"probe=0x%02x", probe);
703 if (nb26 < 4 && nb96 < 4)
706 PDEBUG(D_PROBE,
"Not any 0xff -> MI2020");
712 PDEBUG(D_PROBE,
"05e3:f191 sensor MI1320 (1.3M)");
714 PDEBUG(D_PROBE,
"05e3:0503 sensor MI2020 (2.0M)");
716 PDEBUG(D_PROBE,
"05e3:0503 sensor OV9655 (1.3M)");
718 PDEBUG(D_PROBE,
"05e3:0503 sensor OV2640 (2.0M)");
720 PDEBUG(D_PROBE,
"***** Unknown sensor *****");