]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: gadget: uvc: set nbuffers to minimum STREAMING_MIN_BUFFERS in uvc_queue_setup
authorMichael Grzeschik <m.grzeschik@pengutronix.de>
Wed, 16 Oct 2024 13:58:12 +0000 (15:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 06:42:23 +0000 (08:42 +0200)
We set the minimum amount of v4l2 buffers that is possibly be pending
to UVCG_STREAMING_MIN_BUFFERS which is two. This way the driver will
always have at least one frame pending to be encoded while the other
is being enqueued in the hardware.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v7-7-e224bb1035f0@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/uvc.h
drivers/usb/gadget/function/uvc_queue.c

index bedb4ef42864f15952fdecf5ca7df619dd03b202..6f44dd732315074e215f75e5df99c289f9cebe35 100644 (file)
@@ -74,6 +74,8 @@ extern unsigned int uvc_gadget_trace_param;
 #define UVCG_REQ_MAX_INT_COUNT                 16
 #define UVCG_REQ_MAX_ZERO_COUNT                        (2 * UVCG_REQ_MAX_INT_COUNT)
 
+#define UVCG_STREAMING_MIN_BUFFERS             2
+
 /* ------------------------------------------------------------------------
  * Structures
  */
index 6757a4e25a74348725eac0ccd3aa50217babe3ab..5eaeae3e2441c54dff5075c3efc1427cccd27b94 100644 (file)
@@ -21,6 +21,7 @@
 #include <media/videobuf2-vmalloc.h>
 
 #include "uvc.h"
+#include "uvc_video.h"
 
 /* ------------------------------------------------------------------------
  * Video buffers queue management.
@@ -47,6 +48,8 @@ static int uvc_queue_setup(struct vb2_queue *vq,
 
        if (*nbuffers > UVC_MAX_VIDEO_BUFFERS)
                *nbuffers = UVC_MAX_VIDEO_BUFFERS;
+       if (*nbuffers < UVCG_STREAMING_MIN_BUFFERS)
+               *nbuffers = UVCG_STREAMING_MIN_BUFFERS;
 
        *nplanes = 1;