]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: uvcvideo: uvc_queue_to_stream(): Support meta queues
authorRicardo Ribalda <ribalda@chromium.org>
Mon, 9 Mar 2026 15:01:55 +0000 (15:01 +0000)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 25 Mar 2026 08:40:28 +0000 (09:40 +0100)
The stream data structure has two queues: the metadata and the data
queues, but uvc_queue_to_stream() only supports the data queue. If we
pass the metadata queue the function will return an invalid pointer.

This patch add a parameter to the function to explicitly tell the
function which queue are we using.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Link: https://patch.msgid.link/20260309-uvc-metadata-dmabuf-v1-2-fc8b87bd29c5@chromium.org
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/usb/uvc/uvc_isight.c
drivers/media/usb/uvc/uvc_queue.c
drivers/media/usb/uvc/uvcvideo.h

index 43cda5e760a345af56186603e2f0594b814cdbcb..ea9dc31dfbadceee0fc68123026b567de969cc75 100644 (file)
@@ -41,7 +41,8 @@ static int isight_decode(struct uvc_video_queue *queue, struct uvc_buffer *buf,
                0xde, 0xad, 0xfa, 0xce
        };
 
-       struct uvc_streaming *stream = uvc_queue_to_stream(queue);
+       struct uvc_streaming *stream = uvc_queue_to_stream(queue,
+                                               V4L2_BUF_TYPE_VIDEO_CAPTURE);
        unsigned int maxlen, nbytes;
        u8 *mem;
        int is_header = 0;
index 0eddd4f872ca763e2ec43542a6670407e703e362..68ed2883edb220fe2ce3694de06fe88f381dc209 100644 (file)
@@ -78,7 +78,7 @@ static int uvc_queue_setup(struct vb2_queue *vq,
                           unsigned int sizes[], struct device *alloc_devs[])
 {
        struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
-       struct uvc_streaming *stream;
+       struct uvc_streaming *stream = uvc_queue_to_stream(queue, vq->type);
        unsigned int size;
 
        switch (vq->type) {
@@ -87,7 +87,6 @@ static int uvc_queue_setup(struct vb2_queue *vq,
                break;
 
        default:
-               stream = uvc_queue_to_stream(queue);
                size = stream->ctrl.dwMaxVideoFrameSize;
                break;
        }
@@ -113,7 +112,7 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb)
 
        if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
            vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) {
-               uvc_dbg(uvc_queue_to_stream(queue)->dev, CAPTURE,
+               uvc_dbg(uvc_queue_to_stream(queue, vb->type)->dev, CAPTURE,
                        "[E] Bytes used out of bounds\n");
                return -EINVAL;
        }
@@ -160,7 +159,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
-       struct uvc_streaming *stream = uvc_queue_to_stream(queue);
+       struct uvc_streaming *stream = uvc_queue_to_stream(queue, vb->type);
        struct uvc_buffer *buf = uvc_vbuf_to_buffer(vbuf);
 
        if (vb->state == VB2_BUF_STATE_DONE)
@@ -170,7 +169,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb)
 static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count)
 {
        struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
-       struct uvc_streaming *stream = uvc_queue_to_stream(queue);
+       struct uvc_streaming *stream = uvc_queue_to_stream(queue, vq->type);
        int ret;
 
        lockdep_assert_irqs_enabled();
@@ -197,11 +196,11 @@ err_buffers:
 static void uvc_stop_streaming_video(struct vb2_queue *vq)
 {
        struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
-       struct uvc_streaming *stream = uvc_queue_to_stream(queue);
+       struct uvc_streaming *stream = uvc_queue_to_stream(queue, vq->type);
 
        lockdep_assert_irqs_enabled();
 
-       uvc_video_stop_streaming(uvc_queue_to_stream(queue));
+       uvc_video_stop_streaming(stream);
 
        uvc_pm_put(stream->dev);
 
index 8480d65ecb85ed5bb492c9aa019b3766ccd02897..9b4849fda12f515659b7e16f2884217de9fd90d8 100644 (file)
@@ -703,8 +703,10 @@ static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
 }
 
 static inline struct uvc_streaming *
-uvc_queue_to_stream(struct uvc_video_queue *queue)
+uvc_queue_to_stream(struct uvc_video_queue *queue, unsigned int type)
 {
+       if (type == V4L2_BUF_TYPE_META_CAPTURE)
+               return container_of(queue, struct uvc_streaming, meta.queue);
        return container_of(queue, struct uvc_streaming, queue);
 }