1

I'm developing an application based on g_webcam kind of template code available at git://git.ideasonboard.org/uvc-gadget.git. I've noticed the FPS setting supplied in the USB device config structures is not respected. In fact, gadget attempts the fastest possible frame rate. Moreover, the host tends to loose the pipe to UVC device due to probable low-level USB interface flooding due to opportunistic FPS selection.

So, how can we set a hard-limit on FPS for a UVC gadget?

Thanks!

Kernel module source:

/* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
static const struct UVC_FRAME_UNCOMPRESSED(1) 
uvc_frame_uncompressed_360p = {
    .bLength        = UVC_DT_FRAME_UNCOMPRESSED_SIZE(1),
    .bDescriptorType    = USB_DT_CS_INTERFACE,
    .bDescriptorSubType = UVC_VS_FRAME_UNCOMPRESSED,
    .bFrameIndex        = 1,
    .bmCapabilities     = 0,
    .wWidth         = cpu_to_le16(FRAME_WIDTH),
    .wHeight        = cpu_to_le16(FRAME_HEIGHT),
    .dwMinBitRate       = cpu_to_le32(FRAME_WIDTH * FRAME_HEIGHT * 8 * FRAME_RATE),
    .dwMaxBitRate       = cpu_to_le32(FRAME_WIDTH * FRAME_HEIGHT * 8 * FRAME_RATE),
    .dwMaxVideoFrameBufferSize  = cpu_to_le32(FRAME_WIDTH * FRAME_HEIGHT),
    .dwDefaultFrameInterval = cpu_to_le32(FRAME_RATE_USEC),
    .bFrameIntervalType = 1,
    .dwFrameInterval[0] = cpu_to_le32(FRAME_RATE_USEC),
};

UVC gadget source:

static const struct uvc_frame_info uvc_frames_grey[] = {
    {  FRAME_WIDTH, FRAME_HEIGHT, FRAME_RATE_USEC, },
    { 0, 0, 0, },
};

Common header:

#define STREAMING_MAXPACKET 1024
#define FRAME_WIDTH 160
#define FRAME_HEIGHT 90
#define FRAME_RATE 330 /* 330 FPS */
#define FRAME_RATE_USEC 30303 /* 330 FPS */
Dmitry Mikushin
  • 1,478
  • 15
  • 16

1 Answers1

0

I believe Paul added support for setting a limit on the FPS in usb-gadget, which got upstreamed recently.

Please consider looking at the latest version of the repository.

Let us know if you hit any further issues on this.

Kieran
  • 829
  • 6
  • 6