Hi Jan,

On Sunday 15 February 2009 17:19:42 Jan Ciger wrote:
> Hi Laurent,
>
> Laurent Pinchart wrote:
> > Hi Jan,
> >
> > Could you try different resolutions ? The driver should report the
> > bandwidth requested by the camera in the kernel log, that information
> > can help debugging the issue.
>
> OK, got it work now - I guess I have mixed some incompatible module
> versions.
>
> 320x240 15 and 30fps works, both cameras stream.
> Log shows: uvcvideo: device Vimicro USB2.0 PC Camera requested 595 bytes
> per payload.
>
> 352x288 15 and 30fps works, both cameras stream
> Log: uvcvideo: device Vimicro USB2.0 PC Camera requested 785 bytes per
> payload.
>
> 640x480 15 and 30fps doesn't work, opening second luvcview results in:
> uvcvideo: device Vimicro USB2.0 PC Camera requested 2380 bytes per payload.
> uvcvideo: Failed to submit URB 0 (-28).
>
> Strange thing is that the amount of data requested doesn't depend on the
> frame rate.
>
> I did a bit of experimentation and have managed to get both cameras
> stream at 640x480/15fps with the payload size of 2000 bytes. However,
> luvcview hangs if I try to use 30fps (there is no message in the log). I
> think you need to take the requested framerate in the account when doing
> the calculation.

You're right. I've attached an updated version of the patch to this e-mail. 
Could you please test it ?

> > Please note that you must use the videodev module (and its
> > dependencies) from the uvcvideo source tree. Mixing uvcvideo from the
> > mercurial tree with a mainline videodev module will probably crash.
>
> Yep - that was it :(

Best regards,

Laurent Pinchart

diff -r 62db428e724f linux/drivers/media/video/uvc/uvc_driver.c
--- a/linux/drivers/media/video/uvc/uvc_driver.c	Sat Feb 14 23:39:08 2009 +0100
+++ b/linux/drivers/media/video/uvc/uvc_driver.c	Sun Feb 15 19:54:47 2009 +0100
@@ -1863,6 +1863,15 @@
 	  .bInterfaceSubClass	= 1,
 	  .bInterfaceProtocol	= 0,
 	  .driver_info		= UVC_QUIRK_STREAM_NO_FID },
+	/* ViMicro */
+	{ .match_flags		= USB_DEVICE_ID_MATCH_VENDOR
+				| USB_DEVICE_ID_MATCH_INT_INFO,
+	  .idVendor		= 0x0ac8,
+	  .idProduct		= 0x0000,
+	  .bInterfaceClass	= USB_CLASS_VIDEO,
+	  .bInterfaceSubClass	= 1,
+	  .bInterfaceProtocol	= 0,
+	  .driver_info		= UVC_QUIRK_FIX_BANDWIDTH },
 	/* MT6227 */
 	{ .match_flags		= USB_DEVICE_ID_MATCH_DEVICE
 				| USB_DEVICE_ID_MATCH_INT_INFO,
diff -r 62db428e724f linux/drivers/media/video/uvc/uvc_video.c
--- a/linux/drivers/media/video/uvc/uvc_video.c	Sat Feb 14 23:39:08 2009 +0100
+++ b/linux/drivers/media/video/uvc/uvc_video.c	Sun Feb 15 19:54:48 2009 +0100
@@ -84,6 +84,24 @@
 	      video->dev->uvc_version < 0x0110))
 		ctrl->dwMaxVideoFrameSize =
 			frame->dwMaxVideoFrameBufferSize;
+
+	if (video->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH &&
+	    video->streaming->intf->num_altsetting > 1) {
+		u32 interval;
+		u32 bandwidth;
+
+		interval = (ctrl->dwFrameInterval > 100000)
+			 ? ctrl->dwFrameInterval
+			 : frame->dwFrameInterval[0];
+
+		bandwidth = frame->wWidth * frame->wHeight / 8 * format->bpp;
+		bandwidth *= 10000000 / interval + 1;
+		bandwidth /= 1000;
+		if (video->dev->udev->speed == USB_SPEED_HIGH)
+			bandwidth /= 8;
+
+		ctrl->dwMaxPayloadTransferSize = bandwidth;
+	}
 }
 
 static int uvc_get_video_ctrl(struct uvc_video_device *video,
@@ -900,6 +918,9 @@
 				"bandwidth, defaulting to lowest.\n",
 				video->vdev->name);
 			bandwidth = 1;
+		} else {
+			uvc_printk(KERN_INFO, "device %s requested %u bytes "
+				"per payload.\n", video->vdev->name, bandwidth);
 		}
 
 		for (i = 0; i < intf->num_altsetting; ++i) {
diff -r 62db428e724f linux/drivers/media/video/uvc/uvcvideo.h
--- a/linux/drivers/media/video/uvc/uvcvideo.h	Sat Feb 14 23:39:08 2009 +0100
+++ b/linux/drivers/media/video/uvc/uvcvideo.h	Sun Feb 15 19:54:48 2009 +0100
@@ -315,6 +315,7 @@
 #define UVC_QUIRK_STREAM_NO_FID		0x00000010
 #define UVC_QUIRK_IGNORE_SELECTOR_UNIT	0x00000020
 #define UVC_QUIRK_PRUNE_CONTROLS	0x00000040
+#define UVC_QUIRK_FIX_BANDWIDTH		0x00000080
 
 /* Format flags */
 #define UVC_FMT_FLAG_COMPRESSED		0x00000001
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to