From: Hans de Goede <hansg@kernel.org>
To: Ricardo Ribalda <ribalda@chromium.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Yunke Cao <yunkec@google.com>
Subject: Re: [PATCH 3/3] media: uvcvideo: Allow userspace to increase the meta buffersize
Date: Mon, 16 Mar 2026 12:53:12 +0100 [thread overview]
Message-ID: <e82689ce-ebc7-4413-ae24-30328329749d@kernel.org> (raw)
In-Reply-To: <20260309-uvc-metadata-dmabuf-v1-3-fc8b87bd29c5@chromium.org>
Hi,
On 9-Mar-26 4:01 PM, Ricardo Ribalda wrote:
> Now we have the metadata size hardcoded to 10 KiB, this is a value that
> works fine for bulk cameras or frames with no extra metadata. But not
> for all usecases.
>
> We have seen some cameras that produce more metadata per frame. Eg:
> Frame 1 captured (Bytes: 11154)
> Frame 2 captured (Bytes: 11616)
> Frame 3 captured (Bytes: 11374)
> Frame 4 captured (Bytes: 11132)
> Frame 5 captured (Bytes: 11594)
> Frame 6 captured (Bytes: 11352)
> Frame 7 captured (Bytes: 11110)
> Frame 8 captured (Bytes: 11572)
> Frame 9 captured (Bytes: 11308)
>
> When this happens, the driver (correctly) marks the metadata as ERROR.
>
> This patch let userspace set bigger buffersize via S_FMT.
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Regards,
Hans
> ---
> drivers/media/usb/uvc/uvc_metadata.c | 9 +++++++--
> drivers/media/usb/uvc/uvc_queue.c | 2 +-
> drivers/media/usb/uvc/uvcvideo.h | 3 ++-
> 3 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_metadata.c b/drivers/media/usb/uvc/uvc_metadata.c
> index 0a906ae3f971..9de8aba1229e 100644
> --- a/drivers/media/usb/uvc/uvc_metadata.c
> +++ b/drivers/media/usb/uvc/uvc_metadata.c
> @@ -50,7 +50,7 @@ static int uvc_meta_v4l2_get_format(struct file *file, void *priv,
> return -EINVAL;
>
> fmt->dataformat = stream->meta.format;
> - fmt->buffersize = UVC_METADATA_BUF_SIZE;
> + fmt->buffersize = stream->meta.buffersize;
>
> return 0;
> }
> @@ -63,6 +63,7 @@ static int uvc_meta_v4l2_try_format(struct file *file, void *priv,
> struct uvc_device *dev = stream->dev;
> struct v4l2_meta_format *fmt = &format->fmt.meta;
> u32 fmeta = V4L2_META_FMT_UVC;
> + u32 buffersize;
>
> if (format->type != vfh->vdev->queue->type)
> return -EINVAL;
> @@ -74,10 +75,12 @@ static int uvc_meta_v4l2_try_format(struct file *file, void *priv,
> }
> }
>
> + buffersize = max(UVC_METADATA_BUF_MIN_SIZE, fmt->buffersize);
> +
> memset(fmt, 0, sizeof(*fmt));
>
> fmt->dataformat = fmeta;
> - fmt->buffersize = UVC_METADATA_BUF_SIZE;
> + fmt->buffersize = buffersize;
>
> return 0;
> }
> @@ -103,6 +106,7 @@ static int uvc_meta_v4l2_set_format(struct file *file, void *priv,
> return -EBUSY;
>
> stream->meta.format = fmt->dataformat;
> + stream->meta.buffersize = fmt->buffersize;
>
> return 0;
> }
> @@ -229,6 +233,7 @@ int uvc_meta_register(struct uvc_streaming *stream)
> struct uvc_video_queue *queue = &stream->meta.queue;
>
> stream->meta.format = V4L2_META_FMT_UVC;
> + stream->meta.buffersize = UVC_METADATA_BUF_MIN_SIZE;
>
> return uvc_register_video_device(dev, stream, queue,
> V4L2_BUF_TYPE_META_CAPTURE,
> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
> index 68ed2883edb2..89206f761006 100644
> --- a/drivers/media/usb/uvc/uvc_queue.c
> +++ b/drivers/media/usb/uvc/uvc_queue.c
> @@ -83,7 +83,7 @@ static int uvc_queue_setup(struct vb2_queue *vq,
>
> switch (vq->type) {
> case V4L2_BUF_TYPE_META_CAPTURE:
> - size = UVC_METADATA_BUF_SIZE;
> + size = stream->meta.buffersize;
> break;
>
> default:
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index 9b4849fda12f..5ba698d2a23d 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -409,7 +409,7 @@ struct uvc_stats_stream {
> unsigned int max_sof; /* Maximum STC.SOF value */
> };
>
> -#define UVC_METADATA_BUF_SIZE 10240
> +#define UVC_METADATA_BUF_MIN_SIZE 10240
>
> /**
> * struct uvc_copy_op: Context structure to schedule asynchronous memcpy
> @@ -482,6 +482,7 @@ struct uvc_streaming {
> struct {
> struct uvc_video_queue queue;
> u32 format;
> + u32 buffersize;
> } meta;
>
> /* Context data used by the bulk completion handler. */
>
next prev parent reply other threads:[~2026-03-16 11:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 15:01 [PATCH 0/3] media: uvcvideo: Improvements for UVC metadata Ricardo Ribalda
2026-03-09 15:01 ` [PATCH 1/3] media: uvcvideo: Enable VB2_DMABUF for metadata stream Ricardo Ribalda
2026-03-16 11:47 ` Hans de Goede
2026-03-18 19:15 ` Laurent Pinchart
2026-03-09 15:01 ` [PATCH 2/3] media: uvcvideo: uvc_queue_to_stream(): Support meta queues Ricardo Ribalda
2026-03-16 11:49 ` Hans de Goede
2026-03-18 19:18 ` Laurent Pinchart
2026-03-09 15:01 ` [PATCH 3/3] media: uvcvideo: Allow userspace to increase the meta buffersize Ricardo Ribalda
2026-03-16 11:53 ` Hans de Goede [this message]
2026-03-18 19:22 ` Laurent Pinchart
2026-03-18 19:29 ` Ricardo Ribalda
2026-03-18 19:36 ` Laurent Pinchart
2026-03-16 12:05 ` [PATCH 0/3] media: uvcvideo: Improvements for UVC metadata Hans de Goede
2026-03-18 19:23 ` Laurent Pinchart
2026-03-18 20:22 ` [PATCH] media: uvcvideo: Add a stream backpointer in uvc_video_queue Ricardo Ribalda
2026-03-23 22:34 ` Laurent Pinchart
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=e82689ce-ebc7-4413-ae24-30328329749d@kernel.org \
--to=hansg@kernel.org \
--cc=guennadi.liakhovetski@intel.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=yunkec@google.com \
/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