public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: Daniel Scally <dan.scally@ideasonboard.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Avichal Rakesh <arakesh@google.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 10/10] usb: gadget: uvc: add min g_ctrl vidioc and set min buffs to 4
Date: Tue, 13 Aug 2024 12:35:25 +0300	[thread overview]
Message-ID: <20240813093525.GD19716@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20240403-uvc_request_length_by_interval-v4-10-ca22f334226e@pengutronix.de>

On Tue, Aug 13, 2024 at 11:09:34AM +0200, Michael Grzeschik wrote:
> We increase the minimum amount of v4l2 buffers that will be possibly
> enqueued into the hardware and allocate at least
> UVCG_STREAMING_MIN_BUFFERS amount of requests. This way the driver has
> also more requests available to prefill the isoc hardware with.
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> 
> ---
> v3 -> v4: -
> v1 -> v3: new patch
> ---
>  drivers/usb/gadget/function/uvc.h       |  2 ++
>  drivers/usb/gadget/function/uvc_queue.c |  3 ++-
>  drivers/usb/gadget/function/uvc_v4l2.c  | 13 +++++++++++++
>  3 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h
> index f6bc58fb02b84..e0b1f78fdbc65 100644
> --- a/drivers/usb/gadget/function/uvc.h
> +++ b/drivers/usb/gadget/function/uvc.h
> @@ -71,6 +71,8 @@ extern unsigned int uvc_gadget_trace_param;
>  
>  #define UVCG_REQUEST_HEADER_LEN			12
>  
> +#define UVCG_STREAMING_MIN_BUFFERS		4
> +

4 is a large number that drastically increases latency.

>  /* ------------------------------------------------------------------------
>   * Structures
>   */
> diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
> index e33ce72325031..157e7f7d49c7a 100644
> --- a/drivers/usb/gadget/function/uvc_queue.c
> +++ b/drivers/usb/gadget/function/uvc_queue.c
> @@ -21,6 +21,7 @@
>  #include <media/videobuf2-vmalloc.h>
>  
>  #include "uvc.h"
> +#include "uvc_video.h"
>  
>  /* ------------------------------------------------------------------------
>   * Video buffers queue management.
> @@ -86,7 +87,7 @@ static int uvc_queue_setup(struct vb2_queue *vq,
>  	}
>  
>  	video->req_size = req_size;
> -	video->uvc_num_requests = nreq;
> +	video->uvc_num_requests = nreq * UVCG_STREAMING_MIN_BUFFERS;
>  
>  	return 0;
>  }
> diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
> index 392fb400aad14..f96074f2c2824 100644
> --- a/drivers/usb/gadget/function/uvc_v4l2.c
> +++ b/drivers/usb/gadget/function/uvc_v4l2.c
> @@ -357,6 +357,18 @@ static int uvc_v4l2_s_parm(struct file *file, void *fh,
>  	return 0;
>  }
>  
> +static int uvc_g_ctrl(struct file *file, void *priv, struct v4l2_control *vc)
> +{
> +	int ret = -EINVAL;
> +
> +	if (vc->id == V4L2_CID_MIN_BUFFERS_FOR_OUTPUT) {
> +		vc->value = UVCG_STREAMING_MIN_BUFFERS;
> +		ret = 0;
> +	}
> +
> +	return ret;
> +}
> +
>  static int
>  uvc_v4l2_enum_frameintervals(struct file *file, void *fh,
>  		struct v4l2_frmivalenum *fival)
> @@ -629,6 +641,7 @@ const struct v4l2_ioctl_ops uvc_v4l2_ioctl_ops = {
>  	.vidioc_streamoff = uvc_v4l2_streamoff,
>  	.vidioc_s_parm = uvc_v4l2_s_parm,
>  	.vidioc_g_parm = uvc_v4l2_g_parm,
> +	.vidioc_g_ctrl = uvc_g_ctrl,
>  	.vidioc_subscribe_event = uvc_v4l2_subscribe_event,
>  	.vidioc_unsubscribe_event = uvc_v4l2_unsubscribe_event,
>  	.vidioc_default = uvc_v4l2_ioctl_default,

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2024-08-13  9:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13  9:09 [PATCH v4 00/10] usb: gadget: uvc: effectively fill the udc isoc pipeline with available video buffers Michael Grzeschik
2024-08-13  9:09 ` [PATCH v4 01/10] usb: gadget: uvc: always set interrupt on zero length requests Michael Grzeschik
2024-08-13  9:17   ` Laurent Pinchart
2024-08-13  9:09 ` [PATCH v4 02/10] usb: gadget: uvc: only enqueue zero length requests in potential underrun Michael Grzeschik
2024-08-13  9:09 ` [PATCH v4 03/10] usb: gadget: uvc: remove pump worker and enqueue all buffers per frame in qbuf Michael Grzeschik
2024-08-13  9:09 ` [PATCH v4 04/10] usb: gadget: uvc: rework to enqueue in pump worker from encoded queue Michael Grzeschik
2024-08-13  9:09 ` [PATCH v4 05/10] usb: gadget: uvc: remove uvc_video_ep_queue_initial_requests Michael Grzeschik
2024-08-13  9:09 ` [PATCH v4 06/10] usb: gadget: uvc: set req_size once when the vb2 queue is calculated Michael Grzeschik
2024-08-13  9:41   ` Laurent Pinchart
2024-08-27 21:58     ` Michael Grzeschik
2024-08-13  9:09 ` [PATCH v4 07/10] usb: gadget: uvc: add g_parm and s_parm for frame interval Michael Grzeschik
2024-08-13  9:22   ` Laurent Pinchart
2024-08-13  9:28     ` Laurent Pinchart
2024-08-13 10:27       ` Michael Grzeschik
2024-08-13 10:34         ` Laurent Pinchart
2024-08-13  9:09 ` [PATCH v4 08/10] usb: gadget: uvc: set req_size and n_requests based on the " Michael Grzeschik
2024-08-13  9:09 ` [PATCH v4 09/10] usb: gadget: uvc: set req_length based on payload by nreqs instead of req_size Michael Grzeschik
2024-08-13  9:09 ` [PATCH v4 10/10] usb: gadget: uvc: add min g_ctrl vidioc and set min buffs to 4 Michael Grzeschik
2024-08-13  9:35   ` Laurent Pinchart [this message]
2024-08-13  9:56 ` [PATCH v4 00/10] usb: gadget: uvc: effectively fill the udc isoc pipeline with available video buffers Greg Kroah-Hartman
2024-08-13 10:01   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240813093525.GD19716@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=arakesh@google.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.grzeschik@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox