4 * Genesys Logic webcam with gl860 subdrivers
6 * Driver by Olivier Lorin <o.lorin@laposte.net>
7 * GSPCA by Jean-Francois Moine <http://moinejf.free.fr>
8 * Thanks BUGabundo and Malmostoso for your amazing help!
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 MODULE_AUTHOR("Olivier Lorin <lorin@laposte.net>");
27 MODULE_DESCRIPTION("GSPCA/Genesys Logic GL860 USB Camera Driver");
28 MODULE_LICENSE("GPL");
30 /*======================== static function declarations ====================*/
32 static void (*dev_init_settings
)(struct gspca_dev
*gspca_dev
);
34 static int sd_config(struct gspca_dev
*gspca_dev
,
35 const struct usb_device_id
*id
);
36 static int sd_init(struct gspca_dev
*gspca_dev
);
37 static int sd_isoc_init(struct gspca_dev
*gspca_dev
);
38 static int sd_start(struct gspca_dev
*gspca_dev
);
39 static void sd_stop0(struct gspca_dev
*gspca_dev
);
40 static void sd_pkt_scan(struct gspca_dev
*gspca_dev
,
41 struct gspca_frame
*frame
, u8
*data
, s32 len
);
42 static void sd_callback(struct gspca_dev
*gspca_dev
);
44 static int gl860_guess_sensor(struct gspca_dev
*gspca_dev
,
45 s32 vendor_id
, s32 product_id
);
47 /*============================ driver options ==============================*/
49 static s32 AC50Hz
= 0xff;
50 module_param(AC50Hz
, int, 0644);
51 MODULE_PARM_DESC(AC50Hz
, " Does AC power frequency is 50Hz? (0/1)");
53 static char sensor
[7];
54 module_param_string(sensor
, sensor
, sizeof(sensor
), 0644);
55 MODULE_PARM_DESC(sensor
,
56 " Driver sensor ('MI1320'/'MI2020'/'OV9655'/'OV2640'/'')");
58 /*============================ webcam controls =============================*/
60 /* Functions to get and set a control value */
61 #define SD_SETGET(thename) \
62 static int sd_set_##thename(struct gspca_dev *gspca_dev, s32 val)\
64 struct sd *sd = (struct sd *) gspca_dev;\
66 sd->vcur.thename = val;\
67 if (gspca_dev->streaming)\
68 sd->dev_camera_settings(gspca_dev);\
71 static int sd_get_##thename(struct gspca_dev *gspca_dev, s32 *val)\
73 struct sd *sd = (struct sd *) gspca_dev;\
75 *val = sd->vcur.thename;\
91 #define GL860_NCTRLS 11
94 static struct ctrl sd_ctrls_mi1320
[GL860_NCTRLS
];
95 static struct ctrl sd_ctrls_mi2020
[GL860_NCTRLS
];
96 static struct ctrl sd_ctrls_mi2020b
[GL860_NCTRLS
];
97 static struct ctrl sd_ctrls_ov2640
[GL860_NCTRLS
];
98 static struct ctrl sd_ctrls_ov9655
[GL860_NCTRLS
];
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;\
116 static int gl860_build_control_table(struct gspca_dev
*gspca_dev
)
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_mi2020b
;
129 sd_ctrls
= sd_ctrls_ov2640
;
131 sd_ctrls
= sd_ctrls_ov9655
;
135 memset(sd_ctrls
, 0, GL860_NCTRLS
* sizeof(struct ctrl
));
137 SET_MY_CTRL(V4L2_CID_BRIGHTNESS
,
138 V4L2_CTRL_TYPE_INTEGER
, "Brightness", brightness
)
139 SET_MY_CTRL(V4L2_CID_SHARPNESS
,
140 V4L2_CTRL_TYPE_INTEGER
, "Sharpness", sharpness
)
141 SET_MY_CTRL(V4L2_CID_CONTRAST
,
142 V4L2_CTRL_TYPE_INTEGER
, "Contrast", contrast
)
143 SET_MY_CTRL(V4L2_CID_GAMMA
,
144 V4L2_CTRL_TYPE_INTEGER
, "Gamma", gamma
)
145 SET_MY_CTRL(V4L2_CID_HUE
,
146 V4L2_CTRL_TYPE_INTEGER
, "Palette", hue
)
147 SET_MY_CTRL(V4L2_CID_SATURATION
,
148 V4L2_CTRL_TYPE_INTEGER
, "Saturation", saturation
)
149 SET_MY_CTRL(V4L2_CID_WHITE_BALANCE_TEMPERATURE
,
150 V4L2_CTRL_TYPE_INTEGER
, "White Bal.", whitebal
)
151 SET_MY_CTRL(V4L2_CID_BACKLIGHT_COMPENSATION
,
152 V4L2_CTRL_TYPE_INTEGER
, "Backlight" , backlight
)
154 SET_MY_CTRL(V4L2_CID_HFLIP
,
155 V4L2_CTRL_TYPE_BOOLEAN
, "Mirror", mirror
)
156 SET_MY_CTRL(V4L2_CID_VFLIP
,
157 V4L2_CTRL_TYPE_BOOLEAN
, "Flip", flip
)
158 SET_MY_CTRL(V4L2_CID_POWER_LINE_FREQUENCY
,
159 V4L2_CTRL_TYPE_BOOLEAN
, "50Hz", AC50Hz
)
164 /*==================== sud-driver structure initialisation =================*/
166 static struct sd_desc sd_desc_mi1320
= {
168 .ctrls
= sd_ctrls_mi1320
,
169 .nctrls
= GL860_NCTRLS
,
172 .isoc_init
= sd_isoc_init
,
175 .pkt_scan
= sd_pkt_scan
,
176 .dq_callback
= sd_callback
,
179 static struct sd_desc sd_desc_mi2020
= {
181 .ctrls
= sd_ctrls_mi2020
,
182 .nctrls
= GL860_NCTRLS
,
185 .isoc_init
= sd_isoc_init
,
188 .pkt_scan
= sd_pkt_scan
,
189 .dq_callback
= sd_callback
,
192 static struct sd_desc sd_desc_mi2020b
= {
194 .ctrls
= sd_ctrls_mi2020b
,
195 .nctrls
= GL860_NCTRLS
,
198 .isoc_init
= sd_isoc_init
,
201 .pkt_scan
= sd_pkt_scan
,
202 .dq_callback
= sd_callback
,
205 static struct sd_desc sd_desc_ov2640
= {
207 .ctrls
= sd_ctrls_ov2640
,
208 .nctrls
= GL860_NCTRLS
,
211 .isoc_init
= sd_isoc_init
,
214 .pkt_scan
= sd_pkt_scan
,
215 .dq_callback
= sd_callback
,
218 static struct sd_desc sd_desc_ov9655
= {
220 .ctrls
= sd_ctrls_ov9655
,
221 .nctrls
= GL860_NCTRLS
,
224 .isoc_init
= sd_isoc_init
,
227 .pkt_scan
= sd_pkt_scan
,
228 .dq_callback
= sd_callback
,
231 /*=========================== sub-driver image sizes =======================*/
233 static struct v4l2_pix_format mi2020_mode
[] = {
234 { 640, 480, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
236 .sizeimage
= 640 * 480,
237 .colorspace
= V4L2_COLORSPACE_SRGB
,
240 { 800, 600, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
242 .sizeimage
= 800 * 600,
243 .colorspace
= V4L2_COLORSPACE_SRGB
,
246 {1280, 1024, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
247 .bytesperline
= 1280,
248 .sizeimage
= 1280 * 1024,
249 .colorspace
= V4L2_COLORSPACE_SRGB
,
252 {1600, 1200, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
253 .bytesperline
= 1600,
254 .sizeimage
= 1600 * 1200,
255 .colorspace
= V4L2_COLORSPACE_SRGB
,
260 static struct v4l2_pix_format ov2640_mode
[] = {
261 { 640, 480, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
263 .sizeimage
= 640 * 480,
264 .colorspace
= V4L2_COLORSPACE_SRGB
,
267 { 800, 600, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
269 .sizeimage
= 800 * 600,
270 .colorspace
= V4L2_COLORSPACE_SRGB
,
273 {1280, 960, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
274 .bytesperline
= 1280,
275 .sizeimage
= 1280 * 960,
276 .colorspace
= V4L2_COLORSPACE_SRGB
,
279 {1600, 1200, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
280 .bytesperline
= 1600,
281 .sizeimage
= 1600 * 1200,
282 .colorspace
= V4L2_COLORSPACE_SRGB
,
287 static struct v4l2_pix_format mi1320_mode
[] = {
288 { 640, 480, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
290 .sizeimage
= 640 * 480,
291 .colorspace
= V4L2_COLORSPACE_SRGB
,
294 { 800, 600, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
296 .sizeimage
= 800 * 600,
297 .colorspace
= V4L2_COLORSPACE_SRGB
,
300 {1280, 960, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
301 .bytesperline
= 1280,
302 .sizeimage
= 1280 * 960,
303 .colorspace
= V4L2_COLORSPACE_SRGB
,
308 static struct v4l2_pix_format ov9655_mode
[] = {
309 { 640, 480, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
311 .sizeimage
= 640 * 480,
312 .colorspace
= V4L2_COLORSPACE_SRGB
,
315 {1280, 960, V4L2_PIX_FMT_SGBRG8
, V4L2_FIELD_NONE
,
316 .bytesperline
= 1280,
317 .sizeimage
= 1280 * 960,
318 .colorspace
= V4L2_COLORSPACE_SRGB
,
323 /*========================= sud-driver functions ===========================*/
325 /* This function is called at probe time */
326 static int sd_config(struct gspca_dev
*gspca_dev
,
327 const struct usb_device_id
*id
)
329 struct sd
*sd
= (struct sd
*) gspca_dev
;
331 s32 vendor_id
, product_id
;
333 /* Get USB VendorID and ProductID */
334 vendor_id
= le16_to_cpu(id
->idVendor
);
335 product_id
= le16_to_cpu(id
->idProduct
);
341 if (strcmp(sensor
, "MI1320") == 0)
342 sd
->sensor
= ID_MI1320
;
343 else if (strcmp(sensor
, "OV2640") == 0)
344 sd
->sensor
= ID_OV2640
;
345 else if (strcmp(sensor
, "OV9655") == 0)
346 sd
->sensor
= ID_OV9655
;
347 else if (strcmp(sensor
, "MI2020") == 0)
348 sd
->sensor
= ID_MI2020
;
349 else if (strcmp(sensor
, "MI2020b") == 0)
350 sd
->sensor
= ID_MI2020b
;
352 /* Get sensor and set the suitable init/start/../stop functions */
353 if (gl860_guess_sensor(gspca_dev
, vendor_id
, product_id
) == -1)
356 cam
= &gspca_dev
->cam
;
357 gspca_dev
->nbalt
= 4;
359 switch (sd
->sensor
) {
361 gspca_dev
->sd_desc
= &sd_desc_mi1320
;
362 cam
->cam_mode
= mi1320_mode
;
363 cam
->nmodes
= ARRAY_SIZE(mi1320_mode
);
364 dev_init_settings
= mi1320_init_settings
;
368 gspca_dev
->sd_desc
= &sd_desc_mi2020
;
369 cam
->cam_mode
= mi2020_mode
;
370 cam
->nmodes
= ARRAY_SIZE(mi2020_mode
);
371 dev_init_settings
= mi2020_init_settings
;
375 gspca_dev
->sd_desc
= &sd_desc_mi2020b
;
376 cam
->cam_mode
= mi2020_mode
;
377 cam
->nmodes
= ARRAY_SIZE(mi2020_mode
);
378 dev_init_settings
= mi2020_init_settings
;
382 gspca_dev
->sd_desc
= &sd_desc_ov2640
;
383 cam
->cam_mode
= ov2640_mode
;
384 cam
->nmodes
= ARRAY_SIZE(ov2640_mode
);
385 dev_init_settings
= ov2640_init_settings
;
389 gspca_dev
->sd_desc
= &sd_desc_ov9655
;
390 cam
->cam_mode
= ov9655_mode
;
391 cam
->nmodes
= ARRAY_SIZE(ov9655_mode
);
392 dev_init_settings
= ov9655_init_settings
;
396 dev_init_settings(gspca_dev
);
398 ((struct sd
*) gspca_dev
)->vcur
.AC50Hz
= AC50Hz
;
399 gl860_build_control_table(gspca_dev
);
404 /* This function is called at probe time after sd_config */
405 static int sd_init(struct gspca_dev
*gspca_dev
)
407 struct sd
*sd
= (struct sd
*) gspca_dev
;
409 return sd
->dev_init_at_startup(gspca_dev
);
412 /* This function is called before to choose the alt setting */
413 static int sd_isoc_init(struct gspca_dev
*gspca_dev
)
415 struct sd
*sd
= (struct sd
*) gspca_dev
;
417 return sd
->dev_configure_alt(gspca_dev
);
420 /* This function is called to start the webcam */
421 static int sd_start(struct gspca_dev
*gspca_dev
)
423 struct sd
*sd
= (struct sd
*) gspca_dev
;
425 return sd
->dev_init_pre_alt(gspca_dev
);
428 /* This function is called to stop the webcam */
429 static void sd_stop0(struct gspca_dev
*gspca_dev
)
431 struct sd
*sd
= (struct sd
*) gspca_dev
;
433 return sd
->dev_post_unset_alt(gspca_dev
);
436 /* This function is called when an image is being received */
437 static void sd_pkt_scan(struct gspca_dev
*gspca_dev
,
438 struct gspca_frame
*frame
, u8
*data
, s32 len
)
440 struct sd
*sd
= (struct sd
*) gspca_dev
;
443 s32 mode
= (s32
) gspca_dev
->curr_mode
;
445 sd
->swapRB
* (gspca_dev
->cam
.cam_mode
[mode
].bytesperline
+ 1);
447 /* Test only against 0202h, so endianess does not matter */
448 switch (*(s16
*) data
) {
449 case 0x0202: /* End of frame, start a new one */
450 frame
= gspca_frame_add(gspca_dev
, LAST_PACKET
, frame
, data
, 0);
452 if (sd
->nbIm
>= 0 && sd
->nbIm
< 10)
454 gspca_frame_add(gspca_dev
, FIRST_PACKET
, frame
, data
, 0);
460 if (nSkipped
+ len
<= nToSkip
)
463 if (nSkipped
< nToSkip
&& nSkipped
+ len
> nToSkip
) {
464 data
+= nToSkip
- nSkipped
;
465 len
-= nToSkip
- nSkipped
;
466 nSkipped
= nToSkip
+ 1;
468 gspca_frame_add(gspca_dev
,
469 INTER_PACKET
, frame
, data
, len
);
475 /* This function is called when an image has been read */
476 /* This function is used to monitor webcam orientation */
477 static void sd_callback(struct gspca_dev
*gspca_dev
)
479 struct sd
*sd
= (struct sd
*) gspca_dev
;
485 /* Probe sensor orientation */
486 ctrl_in(gspca_dev
, 0xc0, 2, 0x0000, 0x0000, 1, (void *)&state
);
488 /* C8/40 means upside-down (looking backwards) */
489 /* D8/50 means right-up (looking onwards) */
490 upsideDown
= (state
== 0xc8 || state
== 0x40);
492 if (upsideDown
&& sd
->nbRightUp
> -4) {
493 if (sd
->nbRightUp
> 0)
495 if (sd
->nbRightUp
== -3) {
501 if (!upsideDown
&& sd
->nbRightUp
< 4) {
502 if (sd
->nbRightUp
< 0)
504 if (sd
->nbRightUp
== 3) {
513 sd
->dev_camera_settings(gspca_dev
);
516 /*=================== USB driver structure initialisation ==================*/
518 static const __devinitdata
struct usb_device_id device_table
[] = {
519 {USB_DEVICE(0x05e3, 0x0503)},
520 {USB_DEVICE(0x05e3, 0xf191)},
524 MODULE_DEVICE_TABLE(usb
, device_table
);
526 static int sd_probe(struct usb_interface
*intf
,
527 const struct usb_device_id
*id
)
529 struct gspca_dev
*gspca_dev
;
532 ret
= gspca_dev_probe(intf
, id
,
533 &sd_desc_mi1320
, sizeof(struct sd
), THIS_MODULE
);
536 gspca_dev
= usb_get_intfdata(intf
);
539 "Camera is now controlling video device /dev/video%d",
540 gspca_dev
->vdev
.minor
);
546 static void sd_disconnect(struct usb_interface
*intf
)
548 gspca_disconnect(intf
);
551 static struct usb_driver sd_driver
= {
553 .id_table
= device_table
,
555 .disconnect
= sd_disconnect
,
557 .suspend
= gspca_suspend
,
558 .resume
= gspca_resume
,
562 /*====================== Init and Exit module functions ====================*/
564 static int __init
sd_mod_init(void)
566 PDEBUG(D_PROBE
, "driver startup - version %s", DRIVER_VERSION
);
568 if (usb_register(&sd_driver
) < 0)
570 PDEBUG(D_PROBE
, "driver registered");
575 static void __exit
sd_mod_exit(void)
577 usb_deregister(&sd_driver
);
578 PDEBUG(D_PROBE
, "driver deregistered");
581 module_init(sd_mod_init
);
582 module_exit(sd_mod_exit
);
584 /*==========================================================================*/
586 int gl860_RTx(struct gspca_dev
*gspca_dev
,
587 unsigned char pref
, u32 req
, u16 val
, u16 index
,
588 s32 len
, void *pdata
)
590 struct usb_device
*udev
= gspca_dev
->dev
;
593 if (pref
== 0x40) { /* Send */
595 memcpy(gspca_dev
->usb_buf
, pdata
, len
);
596 r
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
597 req
, pref
, val
, index
,
599 len
, 400 + 200 * (len
> 1));
601 r
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
602 req
, pref
, val
, index
, NULL
, len
, 400);
604 } else { /* Receive */
606 r
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
607 req
, pref
, val
, index
,
609 len
, 400 + 200 * (len
> 1));
610 memcpy(pdata
, gspca_dev
->usb_buf
, len
);
612 r
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
613 req
, pref
, val
, index
, NULL
, len
, 400);
619 "ctrl transfer failed %4d "
620 "[p%02x r%d v%04x i%04x len%d]",
621 r
, pref
, req
, val
, index
, len
);
622 else if (len
> 1 && r
< len
)
623 PDEBUG(D_ERR
, "short ctrl transfer %d/%d", r
, len
);
625 if ((_MI2020_
|| _MI2020b_
|| _MI2020c_
) && (val
|| index
))
633 int fetch_validx(struct gspca_dev
*gspca_dev
, struct validx
*tbl
, int len
)
637 for (n
= 0; n
< len
; n
++) {
638 if (tbl
[n
].idx
!= 0xffff)
639 ctrl_out(gspca_dev
, 0x40, 1, tbl
[n
].val
,
640 tbl
[n
].idx
, 0, NULL
);
641 else if (tbl
[n
].val
== 0xffff)
649 int keep_on_fetching_validx(struct gspca_dev
*gspca_dev
, struct validx
*tbl
,
653 if (tbl
[n
].idx
!= 0xffff)
654 ctrl_out(gspca_dev
, 0x40, 1, tbl
[n
].val
, tbl
[n
].idx
,
656 else if (tbl
[n
].val
== 0xffff)
664 void fetch_idxdata(struct gspca_dev
*gspca_dev
, struct idxdata
*tbl
, int len
)
668 for (n
= 0; n
< len
; n
++) {
669 if (memcmp(tbl
[n
].data
, "\xff\xff\xff", 3) != 0)
670 ctrl_out(gspca_dev
, 0x40, 3, 0x7a00, tbl
[n
].idx
,
677 static int gl860_guess_sensor(struct gspca_dev
*gspca_dev
,
678 s32 vendor_id
, s32 product_id
)
680 struct sd
*sd
= (struct sd
*) gspca_dev
;
681 u8 probe
, nb26
, nb96
, nOV
, ntry
;
683 if (product_id
== 0xf191)
684 sd
->sensor
= ID_MI1320
;
686 if (sd
->sensor
== 0xff) {
687 ctrl_in(gspca_dev
, 0xc0, 2, 0x0000, 0x0004, 1, &probe
);
688 ctrl_in(gspca_dev
, 0xc0, 2, 0x0000, 0x0004, 1, &probe
);
690 ctrl_out(gspca_dev
, 0x40, 1, 0x0000, 0x0000, 0, NULL
);
692 ctrl_out(gspca_dev
, 0x40, 1, 0x0010, 0x0010, 0, NULL
);
694 ctrl_out(gspca_dev
, 0x40, 1, 0x0008, 0x00c0, 0, NULL
);
696 ctrl_out(gspca_dev
, 0x40, 1, 0x0001, 0x00c1, 0, NULL
);
698 ctrl_out(gspca_dev
, 0x40, 1, 0x0001, 0x00c2, 0, NULL
);
700 ctrl_out(gspca_dev
, 0x40, 1, 0x0020, 0x0006, 0, NULL
);
702 ctrl_out(gspca_dev
, 0x40, 1, 0x006a, 0x000d, 0, NULL
);
706 for (ntry
= 0; ntry
< 4; ntry
++) {
707 ctrl_out(gspca_dev
, 0x40, 1, 0x0040, 0x0000, 0, NULL
);
709 ctrl_out(gspca_dev
, 0x40, 1, 0x0063, 0x0006, 0, NULL
);
711 ctrl_out(gspca_dev
, 0x40, 1, 0x7a00, 0x8030, 0, NULL
);
713 ctrl_in(gspca_dev
, 0xc0, 2, 0x7a00, 0x8030, 1, &probe
);
714 PDEBUG(D_PROBE
, "1st probe=%02x", probe
);
720 PDEBUG(D_PROBE
, "0xff -> sensor OVXXXX");
721 PDEBUG(D_PROBE
, "Probing for sensor OV2640 or OV9655");
724 for (ntry
= 0; ntry
< 4; ntry
++) {
725 ctrl_out(gspca_dev
, 0x40, 1, 0x0040, 0x0000,
728 ctrl_out(gspca_dev
, 0x40, 1, 0x6000, 0x800a,
731 /* Wait for 26(OV2640) or 96(OV9655) */
732 ctrl_in(gspca_dev
, 0xc0, 2, 0x6000, 0x800a,
735 PDEBUG(D_PROBE
, "2nd probe=%02x", probe
);
738 if (probe
== 0x26 || probe
== 0x40) {
739 sd
->sensor
= ID_OV2640
;
743 if (probe
== 0x96 || probe
== 0x55) {
744 sd
->sensor
= ID_OV9655
;
752 if (nb26
< 4 && nb96
< 4) {
753 PDEBUG(D_PROBE
, "No relevant answer ");
754 PDEBUG(D_PROBE
, "* 1.3Mpixels -> use OV9655");
755 PDEBUG(D_PROBE
, "* 2.0Mpixels -> use OV2640");
757 "To force a sensor, add that line to "
758 "/etc/modprobe.d/options.conf:");
759 PDEBUG(D_PROBE
, "options gspca_gl860 "
760 "sensor=\"OV2640\" or \"OV9655\"");
763 } else { /* probe = 0 */
764 PDEBUG(D_PROBE
, "No 0xff -> sensor MI2020");
765 sd
->sensor
= ID_MI2020
;
770 PDEBUG(D_PROBE
, "05e3:f191 sensor MI1320 (1.3M)");
771 } else if (_MI2020_
) {
772 PDEBUG(D_PROBE
, "05e3:0503 sensor MI2020 (2.0M)");
773 } else if (_MI2020b_
) {
774 PDEBUG(D_PROBE
, "05e3:0503 sensor MI2020 alt. driver (2.0M)");
775 } else if (_OV9655_
) {
776 PDEBUG(D_PROBE
, "05e3:0503 sensor OV9655 (1.3M)");
777 } else if (_OV2640_
) {
778 PDEBUG(D_PROBE
, "05e3:0503 sensor OV2640 (2.0M)");
780 PDEBUG(D_PROBE
, "***** Unknown sensor *****");