lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220920-resend-meta-v5-0-3385df697370@chromium.org>
Date:   Tue, 17 Jan 2023 17:04:24 +0100
From:   Ricardo Ribalda <ribalda@...omium.org>
To:     Laurent Pinchart <laurent.pinchart@...asonboard.com>,
        Sergey Senozhatsky <senozhatsky@...omium.org>,
        Yunke Cao <yunkec@...omium.org>,
        Mauro Carvalho Chehab <mchehab@...nel.org>
Cc:     Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
        linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
        Ricardo Ribalda <ribalda@...omium.org>
Subject: [PATCH v5] media: uvcvideo: Add a unique suffix to camera names

Some cameras have multiple data inputs (i.e. IR sensor and RGB sensor),
append a unique number to the device name.

Do it in a way where devices with only one input are not affected by the
change, to avoid any regression.

Fixes v4l2-compliance:
    Media Controller ioctls:
         fail: v4l2-test-media.cpp(205): v2_entity_names_set.find(key) != v2_entity_names_set.end()
       test MEDIA_IOC_G_TOPOLOGY: FAIL
         fail: v4l2-test-media.cpp(394): num_data_links != num_links
       test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAIL

Signed-off-by: Ricardo Ribalda <ribalda@...omium.org>
---
Add unique prefixes to uvc entities.

Some UVC devices have multiple subdevices (IR, RBG...), lets give
every entity an unique name.

While we do so, try to avoid as much regressions as possible, by
only adding prefix to multi subdevices.

To: Mauro Carvalho Chehab <mchehab@...nel.org>
To: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Yunke Cao <yunkec@...omium.org>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: linux-media@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Cc: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
---
Changes in v5:
- Remove all the changes to the core.
- Do not add suffix to the first video entity of each device.
- Link to v4: https://lore.kernel.org/r/20220920-resend-meta-v4-0-3ac355b66723@chromium.org

Changes in v4:
- Link to v3: https://lore.kernel.org/r/20220920-resend-meta-v1-0-dfcfba923204@chromium.org
---
 drivers/media/usb/uvc/uvc_driver.c   | 21 ++++++++++++++++-----
 drivers/media/usb/uvc/uvc_metadata.c |  4 ++--
 drivers/media/usb/uvc/uvcvideo.h     |  3 ++-
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 215fb483efb0..01d5ca3da6ce 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1920,6 +1920,7 @@ static void uvc_unregister_video(struct uvc_device *dev)
 
 int uvc_register_video_device(struct uvc_device *dev,
 			      struct uvc_streaming *stream,
+			      unsigned int index,
 			      struct video_device *vdev,
 			      struct uvc_video_queue *queue,
 			      enum v4l2_buf_type type,
@@ -1963,7 +1964,14 @@ int uvc_register_video_device(struct uvc_device *dev,
 		break;
 	}
 
-	strscpy(vdev->name, dev->name, sizeof(vdev->name));
+	if (index) {
+		snprintf(vdev->name, sizeof(vdev->name), "%s_%u%s", dev->name,
+			 index,
+			 type == V4L2_BUF_TYPE_META_CAPTURE ? "-Meta" : "");
+	} else {
+		snprintf(vdev->name, sizeof(vdev->name), "%s%s", dev->name,
+			 type == V4L2_BUF_TYPE_META_CAPTURE ? "-Meta" : "");
+	}
 
 	/*
 	 * Set the driver data before calling video_register_device, otherwise
@@ -1984,7 +1992,8 @@ int uvc_register_video_device(struct uvc_device *dev,
 }
 
 static int uvc_register_video(struct uvc_device *dev,
-		struct uvc_streaming *stream)
+			      struct uvc_streaming *stream,
+			      unsigned int index)
 {
 	int ret;
 
@@ -2005,7 +2014,7 @@ static int uvc_register_video(struct uvc_device *dev,
 	uvc_debugfs_init_stream(stream);
 
 	/* Register the device with V4L. */
-	return uvc_register_video_device(dev, stream, &stream->vdev,
+	return uvc_register_video_device(dev, stream, index, &stream->vdev,
 					 &stream->queue, stream->type,
 					 &uvc_fops, &uvc_ioctl_ops);
 }
@@ -2018,6 +2027,7 @@ static int uvc_register_terms(struct uvc_device *dev,
 {
 	struct uvc_streaming *stream;
 	struct uvc_entity *term;
+	unsigned int index = 0;
 	int ret;
 
 	list_for_each_entry(term, &chain->entities, chain) {
@@ -2033,7 +2043,7 @@ static int uvc_register_terms(struct uvc_device *dev,
 		}
 
 		stream->chain = chain;
-		ret = uvc_register_video(dev, stream);
+		ret = uvc_register_video(dev, stream, index);
 		if (ret < 0)
 			return ret;
 
@@ -2041,9 +2051,10 @@ static int uvc_register_terms(struct uvc_device *dev,
 		 * Register a metadata node, but ignore a possible failure,
 		 * complete registration of video nodes anyway.
 		 */
-		uvc_meta_register(stream);
+		uvc_meta_register(stream, index);
 
 		term->vdev = &stream->vdev;
+		index += 1;
 	}
 
 	return 0;
diff --git a/drivers/media/usb/uvc/uvc_metadata.c b/drivers/media/usb/uvc/uvc_metadata.c
index 82de7781f5b6..d28f2f147acd 100644
--- a/drivers/media/usb/uvc/uvc_metadata.c
+++ b/drivers/media/usb/uvc/uvc_metadata.c
@@ -156,7 +156,7 @@ static const struct v4l2_file_operations uvc_meta_fops = {
 	.mmap = vb2_fop_mmap,
 };
 
-int uvc_meta_register(struct uvc_streaming *stream)
+int uvc_meta_register(struct uvc_streaming *stream, unsigned int index)
 {
 	struct uvc_device *dev = stream->dev;
 	struct video_device *vdev = &stream->meta.vdev;
@@ -170,7 +170,7 @@ int uvc_meta_register(struct uvc_streaming *stream)
 	 */
 	vdev->queue = &queue->queue;
 
-	return uvc_register_video_device(dev, stream, vdev, queue,
+	return uvc_register_video_device(dev, stream, index, vdev, queue,
 					 V4L2_BUF_TYPE_META_CAPTURE,
 					 &uvc_meta_fops, &uvc_meta_ioctl_ops);
 }
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index df93db259312..e87894b966f2 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -710,10 +710,11 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
 void uvc_video_clock_update(struct uvc_streaming *stream,
 			    struct vb2_v4l2_buffer *vbuf,
 			    struct uvc_buffer *buf);
-int uvc_meta_register(struct uvc_streaming *stream);
+int uvc_meta_register(struct uvc_streaming *stream, unsigned int index);
 
 int uvc_register_video_device(struct uvc_device *dev,
 			      struct uvc_streaming *stream,
+			      unsigned int index,
 			      struct video_device *vdev,
 			      struct uvc_video_queue *queue,
 			      enum v4l2_buf_type type,

---
base-commit: a4412fdd49dc011bcc2c0d81ac4cab7457092650
change-id: 20220920-resend-meta-435c30209235

Best regards,
-- 
Ricardo Ribalda <ribalda@...omium.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ