2022-09-20 14:13:46

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v1 0/3] [RESEND] 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

To: Mauro Carvalho Chehab <[email protected]>
To: Laurent Pinchart <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Mauro Carvalho Chehab <[email protected]>
Signed-off-by: Ricardo Ribalda <[email protected]>

---
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(-)
---
base-commit: 521a547ced6477c54b4b0cc206000406c221b4d6
change-id: 20220920-resend-meta-435c30209235

Best regards,
--
Ricardo Ribalda <[email protected]>


2022-09-20 14:45:01

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v1 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]>

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

--
b4 0.11.0-dev-d93f8

2022-09-20 14:47:36

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v1 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]>

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index d00237ee4cae..da97572953af 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);

--
b4 0.11.0-dev-d93f8

2022-09-20 15:09:57

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v1 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]>

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 9c05776f11d1..0f0e200a345e 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2251,7 +2251,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

--
b4 0.11.0-dev-d93f8