Hi all,

Attached is a rather ugly patch that has proven to make the Logitech UVC cameras work fine for some people. It works around the USB errors by retrying control requests up to three times.

We would like to get as much feedback as possible, so if you try it out, please let us know whether or not it works for you.

A few notes:

- The patch is against the split branch.

- This only applies for Logitech UVC cameras (QuickCam Fusion, Orbit/Sphere, Pro 5000, for Notebooks Pro, UltraVision), the Cisco VT Camera II, and for some built-in laptop cameras like the QuickCam for Dell Notebooks and the Acer OrbiCam.

- If the debug output bugs you, just uncomment the uvc_printk line. It does, however give you an indication of whether and how often the patch has "prevented" the problem.

- Feel free to increase the QUERY_CTRL_RETRIES if you find that it helps. If it does, please drop us a note.

Again, any feedback is welcome. :-)

Cheers,
Martin





Index: uvc_video.c
===================================================================
--- uvc_video.c (revision 65)
+++ uvc_video.c (working copy)
@@ -38,8 +38,24 @@
                              : usb_sndctrlpipe(dev->udev, 0);
        type |= (query & 0x80) ? USB_DIR_IN : USB_DIR_OUT;

+#ifndef QUERY_CTRL_RETRIES
        ret = usb_control_msg(dev->udev, pipe, query, type, cs << 8,
                        unit << 8 | intfnum, data, size, UVC_CTRL_TIMEOUT);
+#else
+       {
+       int tries = 1 + QUERY_CTRL_RETRIES;
+       ret = 0;
+       while (tries--) {
+               ret = usb_control_msg(dev->udev, pipe, query, type, cs << 8,
+                               unit << 8 | intfnum, data, size, 
UVC_CTRL_TIMEOUT);
+               if(ret >= 0 || ret != -EPIPE)
+                       break;
+               uvc_printk(KERN_ERR, "Failed to query (%u) UVC control %u "
+                       "(unit %u) : %d. Retrying %d more times ...\n",
+                       query, cs, unit, ret, tries);
+       }
+       }
+#endif /* QUERY_CTRL_RETRIES */

        if (ret != size) {
                uvc_printk(KERN_ERR, "Failed to query (%u) UVC control %u "
Index: uvcvideo.h
===================================================================
--- uvcvideo.h  (revision 65)
+++ uvcvideo.h  (working copy)
@@ -233,6 +233,8 @@
 #define UVC_MAX_VIDEO_BUFFERS  32

 #define UVC_CTRL_TIMEOUT       300
+/* Number of retries for stalled control requests */
+#define QUERY_CTRL_RETRIES     3

/* ------------------------------------------------------------------------
  * Structures.

Attachment: usb-retry.patch
Description: Binary data

_______________________________________________
Linux-uvc-devel mailing list
Linux-uvc-devel@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to