2022-01-18 02:56:24

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v3 0/3] Add Meta: to Metadata devices

Metadata devices usually companion "real" devices. In order to
distinguish them properly, add the Meta: prefix to their names.

Also, add a unique suffix to all the uvc devices, to multisensor cameras
do not show the same names for all their devices (IR, RBG....).

v3:

- Add the meta logic to the core


v2: uvc: Restore old vdev name

Ricardo Ribalda (3):
media: v4l2-dev.c: Add Meta: to the name of metadata devices
media: Documentation/driver-api: Document device name
media: uvcvideo: Add a unique suffix to camera names

Documentation/driver-api/media/v4l2-dev.rst | 4 +++-
drivers/media/usb/uvc/uvc_driver.c | 3 ++-
drivers/media/v4l2-core/v4l2-dev.c | 9 +++++++++
3 files changed, 14 insertions(+), 2 deletions(-)

--
2.34.1.703.g22d0c6ccf7-goog


2022-01-18 02:56:27

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v3 1/3] media: v4l2-dev.c: Add Meta: to the name of metadata devices

Devices with Metadata output (like uvc), create two video devices, one
for the data itself and another one for the metadata.

Add a "Meta: " to the beginning of the device name, as suggested by Mauro,
to avoid having multiple devices with the same name.

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

Suggested-by: Mauro Carvalho Chehab <[email protected]>
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/v4l2-core/v4l2-dev.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index d03ace324db0..98be80010702 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -901,6 +901,15 @@ int __video_register_device(struct video_device *vdev,
if (WARN_ON(type != VFL_TYPE_SUBDEV && !vdev->device_caps))
return -EINVAL;

+ /* Add Meta: to metadata device names */
+ if (vdev->device_caps &
+ (V4L2_CAP_META_CAPTURE | V4L2_CAP_META_OUTPUT)) {
+ char aux[sizeof(vdev->name)];
+
+ snprintf(aux, sizeof(aux), "Meta: %s", vdev->name);
+ strscpy(vdev->name, aux, sizeof(aux));
+ }
+
/* v4l2_fh support */
spin_lock_init(&vdev->fh_lock);
INIT_LIST_HEAD(&vdev->fh_list);
--
2.34.1.703.g22d0c6ccf7-goog

2022-01-18 02:56:34

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v3 3/3] 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.

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 <[email protected]>
---
drivers/media/usb/uvc/uvc_driver.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 5f394d4efc21..b17569fc4264 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2232,7 +2232,8 @@ int uvc_register_video_device(struct uvc_device *dev,
break;
}

- strscpy(vdev->name, dev->name, sizeof(vdev->name));
+ snprintf(vdev->name, sizeof(vdev->name), "%s %u", dev->name,
+ stream->header.bTerminalLink);

/*
* Set the driver data before calling video_register_device, otherwise
--
2.34.1.703.g22d0c6ccf7-goog

2022-01-18 02:56:43

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v3 2/3] media: Documentation/driver-api: Document device name

Document how the name of the metadata devices is modified.

Signed-off-by: Ricardo Ribalda <[email protected]>
---
Documentation/driver-api/media/v4l2-dev.rst | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/driver-api/media/v4l2-dev.rst b/Documentation/driver-api/media/v4l2-dev.rst
index 99e3b5fa7444..935a46e29c5e 100644
--- a/Documentation/driver-api/media/v4l2-dev.rst
+++ b/Documentation/driver-api/media/v4l2-dev.rst
@@ -42,7 +42,9 @@ You should also set these fields of :c:type:`video_device`:
- :c:type:`video_device`->v4l2_dev: must be set to the :c:type:`v4l2_device`
parent device.

-- :c:type:`video_device`->name: set to something descriptive and unique.
+- :c:type:`video_device`->name: set to something descriptive and unique. If the
+ device has the `V4L2_CAP_META_CAPTURE` or `V4L2_CAP_META_OUTPUT` capabilities,
+ the string `Meta:` will be inserted before the original name.

- :c:type:`video_device`->vfl_dir: set this to ``VFL_DIR_RX`` for capture
devices (``VFL_DIR_RX`` has value 0, so this is normally already the
--
2.34.1.703.g22d0c6ccf7-goog