[linux-uvc-devel] g_webcam gadget camera on IMX6 board
Linux UVC driver and tools
Brought to you by:
pinchartl
|
From: Matthieu V. <mat...@fr...> - 2013-12-02 10:16:20
|
Hello, I posted already few days ago having problems to have my IMX6 (running the g_webcam gadget) being recognized as a webcam on my host. As I was on an old Linux version on my device (3.0), and so many patches missing, I moved to 3.10 kernel version, and it Is working much better. My IMX6 device is now correctly recognized as an UVC device by an Ubuntu Linux and Windows host, and I can stream a JPG using the uvc gadget test app (git://git.ideasonboard.org/uvc-gadget.git). Nevertheless, I have few questions. Wanted to at the end do 720p/1080p30 MJPG streaming, I modified the FRAME MJPG descriptor to add 15fps and 30fps for 720p profile as following: static const struct UVC_FRAME_MJPEG(3) uvc_frame_mjpg_720p = { .bLength = UVC_DT_FRAME_MJPEG_SIZE(3), .bDescriptorType = USB_DT_CS_INTERFACE, .bDescriptorSubType = UVC_VS_FRAME_MJPEG, .bFrameIndex = 2, .bmCapabilities = 2, // Fixed frame rate D1=1 .wWidth = cpu_to_le16(1280), // resolution .wHeight = cpu_to_le16(720), .dwMinBitRate = cpu_to_le32(5529600), .dwMaxBitRate = cpu_to_le32(165888000), .dwMaxVideoFrameBufferSize = cpu_to_le32(1843200), // For backward compatibility, deprecated, should be taken from probe/commit .dwDefaultFrameInterval = cpu_to_le32(333333), // Default frame rate at 30fps .bFrameIntervalType = 3, .dwFrameInterval[0] = cpu_to_le32(333333), // 30fps .dwFrameInterval[1] = cpu_to_le32(666666), // 15fps .dwFrameInterval[2] = cpu_to_le32(5000000), // 2fps }; It is working, and my host streaming app can see the different frame rates (30fps being correctly the default one as defined by the defaultframeinterval). But when I use the uvc-gadget test app from Laurent, using a fix 720p JPG file @ 82KB (to simulate MJPG streaming), I always have 46fps (for sure linked to my image size) whatever the chosen frame rate from the streaming application (vlc or guvcview). I checked that the correct frame rate is passed from the host to my device on the commit. I created a 1080p profile, and I can stream a 1080p JPG (620KB) but at only 6fps. The data endpoint is for now configured as ISOCHRONOUS with maxpacketsize@1024B (default from the driver module). So it seems that the data bandwith on my USB link is always the same independent from the frameinterval chosen, and far away from the max theorical ISOCHRONOUS bandwith (1024/0.125 = 8.1 MB/s) In 720p streaming whatever fps chosen => 82K*46fps = 3.7 MB/s In 1080p streaming => 620K*6fps = 3.7MB/s If my understanding is correct, I would expect to have the fps from the one chosen on the streaming app, any idea why I have such behavior (46fps vs 30fps)? How the frameinterval is managed in the UVC driver (It is still unclear from the code II am reading)? Concerning the bandwith, my linux PC is only connected to my IMX6 webcam. The data EP seems correctly configured, and can correctly see 1024 maxpacketsize on my host. So is it normal to have such difference between the measured 3.7MB/s bandwith and theorical one from 8.1MB/s.? Finally, for the ones interested there is a typo mistake in one of the descriptors vs the spec. If I take the UVC mjpeg format struct struct uvc_format_mjpeg { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubType; __u8 bFormatIndex; __u8 bNumFrameDescriptors; __u8 bmFlags; __u8 bDefaultFrameIndex; __u8 bAspectRatioX; __u8 bAspectRatioY; __u8 bmInterfaceFlags; __u8 bCopyProtect; } __attribute__((__packed__)); I have bmInterfaceFlags defined while the UVC spec defines it as bmIntelaceFlags (for interlacing) :) Regards Matthieu |