uvc: reply with max frame rate in response to UVC_GET_MAX
authorPaul Elder <paul.elder@ideasonboard.com>
Tue, 28 Aug 2018 06:45:46 +0000 (02:45 -0400)
committerPaul Elder <paul.elder@ideasonboard.com>
Wed, 6 Feb 2019 06:49:34 +0000 (01:49 -0500)
Previously, the interval rate that would be selected and replied to the
host in response to UVC_GET_MAX, UVC_GET_MIN, and UVC_GET_DEF were all
the same and were the first interval rate. Assuming the interval rates
are sorted in ascending order, this means that UVC_GET_MAX would always
yield the minimum interval rate.

Modify the call to uvc_fill_streaming_control such that UVC_GET_MAX will
yield the maximum interval rate.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
lib/uvc.c

index ab03f0e..975413a 100644 (file)
--- a/lib/uvc.c
+++ b/lib/uvc.c
@@ -8,6 +8,7 @@
  */
 
 #include <errno.h>
+#include <limits.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/g_uvc.h>
 #include <linux/usb/video.h>
@@ -176,8 +177,10 @@ uvc_events_process_streaming(struct uvc_device *dev, uint8_t req, uint8_t cs,
        case UVC_GET_MIN:
        case UVC_GET_MAX:
        case UVC_GET_DEF:
-               uvc_fill_streaming_control(dev, ctrl, req == UVC_GET_MAX ? -1 : 1,
-                                          req == UVC_GET_MAX ? -1 : 1, 0);
+               if (req == UVC_GET_MAX)
+                       uvc_fill_streaming_control(dev, ctrl, -1, -1, UINT_MAX);
+               else
+                       uvc_fill_streaming_control(dev, ctrl, 1, 1, 0);
                break;
 
        case UVC_GET_RES: