[lvc-project] [PATCH 1/2] media: em28xx: adjust queues handling in em28xx_vb2_setup()

Dmitry Antipov dmantipov at yandex.ru
Thu Sep 10 19:58:07 MSK 2026


In em28xx_vb2_setup(), setup lock pointers as expected by
vb2_core_queue_init(), initialize VBI queue only if supported by
device, and release video capture queue with vb2_queue_release()
if vb2_queue_init() has failed for VBI queue, respectively.

Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
---
 drivers/media/usb/em28xx/em28xx-video.c | 32 +++++++++++++++----------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index c418add65bb5..560e0b01f8cb 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1405,24 +1405,30 @@ static int em28xx_vb2_setup(struct em28xx *dev)
 	q->buf_struct_size = sizeof(struct em28xx_buffer);
 	q->ops = &em28xx_video_qops;
 	q->mem_ops = &vb2_vmalloc_memops;
+	q->lock = &v4l2->vb_queue_lock;
 
 	rc = vb2_queue_init(q);
 	if (rc < 0)
 		return rc;
 
-	/* Setup Videobuf2 for VBI capture */
-	q = &v4l2->vb_vbiq;
-	q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
-	q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR;
-	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
-	q->drv_priv = dev;
-	q->buf_struct_size = sizeof(struct em28xx_buffer);
-	q->ops = &em28xx_vbi_qops;
-	q->mem_ops = &vb2_vmalloc_memops;
-
-	rc = vb2_queue_init(q);
-	if (rc < 0)
-		return rc;
+	/* Setup Videobuf2 for VBI capture if supported */
+	if (em28xx_vbi_supported(dev)) {
+		q = &v4l2->vb_vbiq;
+		q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
+		q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR;
+		q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+		q->drv_priv = dev;
+		q->buf_struct_size = sizeof(struct em28xx_buffer);
+		q->ops = &em28xx_vbi_qops;
+		q->mem_ops = &vb2_vmalloc_memops;
+		q->lock = &v4l2->vb_vbi_queue_lock;
+
+		rc = vb2_queue_init(q);
+		if (rc < 0) {
+			vb2_queue_release(&v4l2->vb_vidq);
+			return rc;
+		}
+	}
 
 	return 0;
 }
-- 
2.55.0




More information about the lvc-project mailing list