One webcam I have here exposes an invalid videostreaming interface format, with trace=0x2 this output is shown on kernel log:
USB Video Class driver (v0.1.0) usb 3-7: new high speed USB device using ehci_hcd and address 5 usb 3-7: configuration #1 chosen from 1 choice uvcvideo: Found format YUV 4:2:2 (YUYV). uvcvideo: - 640x480 (18.0 fps) uvcvideo: - 320x240 (30.0 fps) uvcvideo: - 160x120 (30.0 fps) uvcvideo: - 352x288 (30.0 fps) uvcvideo: - 176x144 (30.0 fps) uvcvideo: - 1280x1024 (8.0 fps) uvcvideo: device 5 videostreaminginterface 1 FORMAT error uvcvideo: Found a Status endpoint (addr 82). uvcvideo: Found UVC 1.00 device BisonCam, NB Pro (5986:0241) uvcvideo: No valid video chain found. There is an invalid videostreaming interface format exposed, which makes the webcam to fail to work as the error is treated as fatal, even if we have already found a valid format. Fix this by not failing entirely if we have found an invalid format, as we can still have a valid format. The initial problem and solution (patch) was debugged and done by Clevo (probably by Michael Wang), which uses the affected webcam in one of their laptops. I'm forwarding their fix plus additional code that I noticed to be needed for generic cases that decrements properly streaming->nformats and checks later if we really found at least one valid format, and if there were really no valid formats we make sure then to return with error. Signed-off-by: Herton Ronaldo Krzesinski <her...@mandriva.com.br> --- 3rdparty/uvc/uvc_driver.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff -p -up linux/drivers/media/video/uvc/uvc_driver.c.orig linux/drivers/media/video/uvc/uvc_driver.c --- linux/drivers/media/video/uvc/uvc_driver.c.orig 2009-06-03 12:49:50.000000000 -0300 +++ linux/drivers/media/video/uvc/uvc_driver.c 2009-06-03 13:04:44.000000000 -0300 @@ -718,8 +718,17 @@ static int uvc_parse_streaming(struct uv format->frame = frame; ret = uvc_parse_format(dev, streaming, format, &interval, buffer, buflen); - if (ret < 0) - goto error; + /* + * Some webcams can expose videostreaming interface + * with formats that contains errors (firmware bug). + * Ignore the error, as we may have already got some + * valid format or still can find one which is valid + * and can be used + */ + if (ret < 0) { + streaming->nformats--; + break; + } frame += format->nframes; format++; @@ -736,6 +745,14 @@ static int uvc_parse_streaming(struct uv buffer += buffer[0]; } + /* Check if we got at least one valid format in loop above */ + if (streaming->nformats == 0) { + uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming interface " + "%d has no valid formats defined.\n", + dev->udev->devnum, alts->desc.bInterfaceNumber); + goto error; + } + /* Parse the alternate settings to find the maximum bandwidth. */ for (i = 0; i < intf->num_altsetting; ++i) { struct usb_host_endpoint *ep; _______________________________________________ Linux-uvc-devel mailing list Linux-uvc-devel@lists.berlios.de https://lists.berlios.de/mailman/listinfo/linux-uvc-devel