uvc: Restore old vdev name
Subsystems (3)
cover uvc: Restore old vdev name
In order to have unique entity names, we decided to change the name of the video devices with their functionality.
This has resulted in some (all?) GUIs showing not useful names.
This patchset reverts the original patch and introduces a new one to allow having different entity and vdev names.
Since some distros have ported the reverted patch to their stable kernels, it would be great if we can get this sent asap, to avoid making more people angry ;).
Ricardo Ribalda (3):
Revert "media: uvcvideo: Set unique vdev name based in type"
media: v4l2-dev.c: Allow driver-defined entity names
media: uvcvideo: Set unique entity name based in type
drivers/media/usb/uvc/uvc_driver.c | 14 +++++++++++--- drivers/media/v4l2-core/v4l2-dev.c | 4 +++- 2 files changed, 14 insertions(+), 4 deletions(-)
Signature · 1 line
2.33.0
PATCH 1/3 Revert "media: uvcvideo: Set unique vdev name based in type"
A lot of userspace depends on a descriptive name for vdev. Without this patch, users have a hard time figuring out which camera shall they use for their video conferencing.
This reverts commit e3f60e7e1a2b451f538f9926763432249bcf39c4.
--- drivers/media/usb/uvc/uvc_driver.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +1 -6
@@ -2193,7 +2193,6 @@ int uvc_register_video_device(struct uvc_device *dev,const struct v4l2_file_operations *fops, const struct v4l2_ioctl_ops *ioctl_ops) { - const char *name; int ret;/* Initialize the video buffers queue. */
@@ -2222,20 +2221,16 @@ int uvc_register_video_device(struct uvc_device *dev,case V4L2_BUF_TYPE_VIDEO_CAPTURE :default : vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; - name ="Video Capture" ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT : vdev->device_caps =V4L2_CAP_VIDEO_OUTPUT |V4L2_CAP_STREAMING ; - name ="Video Output" ;break ;case V4L2_BUF_TYPE_META_CAPTURE : vdev->device_caps =V4L2_CAP_META_CAPTURE |V4L2_CAP_STREAMING ; - name ="Metadata" ;break ; } -snprintf (vdev->name,sizeof (vdev->name),"%s %u" , name, - stream->header.bTerminalLink); +strscpy (vdev->name, dev->name,sizeof (vdev->name));/* * Set the driver data before calling video_register_device, otherwise
Signature · 1 line
2.33.0
Re: [PATCH 1/3] Revert "media: uvcvideo: Set unique vdev name based in type"
Hi Ricardo,
Thank you for the patch.
Quoted 10 lines · Ricardo Ribalda
A lot of userspace depends on a descriptive name for vdev. Without this patch, users have a hard time figuring out which camera shall they use for their video conferencing.
This reverts commit
e3f60e7e1a2b451f538f9926763432249bcf39c4.Cc <[email protected]>Fixes e3f60e7e1a2b ("media: uvcvideo: Set unique vdev name based in type")Reported-by Nicolas Dufresne <[email protected]>Signed-off-by Ricardo Ribalda <[email protected]>
Quoted 38 lines
--- drivers/media/usb/uvc/uvc_driver.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/media/usb/uvc/uvc_driver.c +1
-6@@ -2193,7 +2193,6 @@ int uvc_register_video_device(struct uvc_device *dev,const struct v4l2_file_operations *fops, const struct v4l2_ioctl_ops *ioctl_ops) { - const char *name; int ret;/* Initialize the video buffers queue. */ @@ -2222,20 +2221,16 @@ int uvc_register_video_device(struct uvc_device *dev,case V4L2_BUF_TYPE_VIDEO_CAPTURE :default : vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; - name ="Video Capture" ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT : vdev->device_caps =V4L2_CAP_VIDEO_OUTPUT |V4L2_CAP_STREAMING ; - name ="Video Output" ;break ;case V4L2_BUF_TYPE_META_CAPTURE : vdev->device_caps =V4L2_CAP_META_CAPTURE |V4L2_CAP_STREAMING ; - name ="Metadata" ;break ; } -snprintf (vdev->name,sizeof (vdev->name),"%s %u" , name, - stream->header.bTerminalLink); +strscpy (vdev->name, dev->name,sizeof (vdev->name));/* * Set the driver data before calling video_register_device, otherwise
Signature · 3 lines
Regards, Laurent Pinchart
Laurent Pinchart
maintainerRe: [PATCH 1/3] Revert "media: uvcvideo: Set unique vdev name based in type"
Quoted 9 lines · Laurent Pinchart
Hi Ricardo,
Thank you for the patch.
Quoted 4 lines · Ricardo Ribalda
A lot of userspace depends on a descriptive name for vdev. Without this patch, users have a hard time figuring out which camera shall they use for their video conferencing.
Quoted 8 lines
Quoted 6 lines
This reverts commit
e3f60e7e1a2b451f538f9926763432249bcf39c4.Cc <[email protected]>Fixes e3f60e7e1a2b ("media: uvcvideo: Set unique vdev name based in type")Reported-by Nicolas Dufresne <[email protected]>Signed-off-by Ricardo Ribalda <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>
Mauro, is it possible to queue this as a fix for v5.16 ?
Quoted 38 lines
Quoted 38 lines
--- drivers/media/usb/uvc/uvc_driver.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/media/usb/uvc/uvc_driver.c +1
-6@@ -2193,7 +2193,6 @@ int uvc_register_video_device(struct uvc_device *dev,const struct v4l2_file_operations *fops, const struct v4l2_ioctl_ops *ioctl_ops) { - const char *name; int ret;/* Initialize the video buffers queue. */ @@ -2222,20 +2221,16 @@ int uvc_register_video_device(struct uvc_device *dev,case V4L2_BUF_TYPE_VIDEO_CAPTURE :default : vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; - name ="Video Capture" ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT : vdev->device_caps =V4L2_CAP_VIDEO_OUTPUT |V4L2_CAP_STREAMING ; - name ="Video Output" ;break ;case V4L2_BUF_TYPE_META_CAPTURE : vdev->device_caps =V4L2_CAP_META_CAPTURE |V4L2_CAP_STREAMING ; - name ="Metadata" ;break ; } -snprintf (vdev->name,sizeof (vdev->name),"%s %u" , name, - stream->header.bTerminalLink); +strscpy (vdev->name, dev->name,sizeof (vdev->name));/* * Set the driver data before calling video_register_device, otherwise
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 2/3 media: v4l2-dev.c: Allow driver-defined entity names
In reply to Ricardo RibaldaIf the driver provides an name for an entity, use it. This is particularly useful for drivers that export multiple video devices for the same hardware (i.e. metadata and data).
--- drivers/media/v4l2-core/v4l2-dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-dev.c +3 -1
@@ -832,7 +832,9 @@ static int video_register_media_controller(struct video_device *vdev) }if (vdev->entity.function !=MEDIA_ENT_F_UNKNOWN ) { - vdev->entity.name = vdev->name; +/* Use entity names provided by the driver, if available. */ +if (!vdev->entity.name) + vdev->entity.name = vdev->name;/* Needed just for backward compatibility with legacy MC API */ vdev->entity.info.dev.major =VIDEO_MAJOR ;
Signature · 1 line
2.33.0
Laurent Pinchart
maintainerRe: [PATCH 2/3] media: v4l2-dev.c: Allow driver-defined entity names
Hi Ricardo,
Thank you for the patch.
Quoted 3 lines · Ricardo Ribalda
If the driver provides an name for an entity, use it. This is particularly useful for drivers that export multiple video devices for the same hardware (i.e. metadata and data).
This seems reasonable (especially given that I've proposed it), but I may be missing unintented consequences. Other reviews would be useful.
Quoted 10 lines
Signed-off-by Ricardo Ribalda <[email protected]>--- drivers/media/v4l2-core/v4l2-dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-dev.c +0
-0
drivers/media/v4l2-core/v4l2-dev.c static int video_register_media_controller(struct video_device *vdev) · line 837
Quoted 7 lines
drivers/media/v4l2-core/v4l2-dev.c +3
-1@@ -832,7 +832,9 @@ static int video_register_media_controller(struct video_device *vdev) }if (vdev->entity.function !=MEDIA_ENT_F_UNKNOWN ) { - vdev->entity.name = vdev->name; +/* Use entity names provided by the driver, if available. */ +if (!vdev->entity.name) + vdev->entity.name = vdev->name;
We need to document this.
Quoted 3 lines
drivers/media/v4l2-core/v4l2-dev.c +0
-0/* Needed just for backward compatibility with legacy MC API */ vdev->entity.info.dev.major =VIDEO_MAJOR ;
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 3/3 media: uvcvideo: Set unique entity name based in type
In reply to Ricardo RibaldaAll the entities must have a unique name. We can have a descriptive and unique name by appending the function to their terminal link.
This is even resilient to multi chain devices.
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
--- drivers/media/usb/uvc/uvc_driver.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +13 -0
@@ -2194,6 +2194,7 @@ int uvc_register_video_device(struct uvc_device *dev, const struct v4l2_ioctl_ops *ioctl_ops) {int ret; +const char *name;/* Initialize the video buffers queue. */ ret =uvc_queue_init (queue, type, !uvc_no_drop_param);
@@ -2221,17 +2222,29 @@ int uvc_register_video_device(struct uvc_device *dev,case V4L2_BUF_TYPE_VIDEO_CAPTURE :default : vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; + name ="Video Capture" ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT : vdev->device_caps =V4L2_CAP_VIDEO_OUTPUT |V4L2_CAP_STREAMING ; + name ="Video Output" ;break ;case V4L2_BUF_TYPE_META_CAPTURE : vdev->device_caps =V4L2_CAP_META_CAPTURE |V4L2_CAP_STREAMING ; + name ="Metadata" ;break ; } +/* +* Many userspace apps identify the device with vdev->name, so we +* cannot change its name for its function. +*/ strscpy (vdev->name, dev->name,sizeof (vdev->name)); +#if defined(CONFIG_MEDIA_CONTROLLER ) + vdev->entity.name =devm_kasprintf (&stream->intf->dev,GFP_KERNEL , +"%s %u" , name, stream->header.bTerminalLink); +#endif +/* * Set the driver data before calling video_register_device, otherwise * the file open() handler might race us.
Signature · 1 line
2.33.0
Laurent Pinchart
maintainerRe: [PATCH 3/3] media: uvcvideo: Set unique entity name based in type
Hi Ricardo,
Thank you for the patch.
Quoted 22 lines · Ricardo Ribalda
All the entities must have a unique name. We can have a descriptive and unique name by appending the function to their terminal link.
This is even resilient to multi chain devices.
Fixes v4l2-compliance:
Media Controller ioctls:
fail: v4l2-test-media.cpp(205):v2_entity_names_set.find(key)!=v2_entity_names_set.end()
testMEDIA_IOC_G_TOPOLOGY: FAIL
fail: v4l2-test-media.cpp(394):num_data_links!=num_links
test MEDIA_IOC_ENUM_ENTITIES/LINKS: FAILSigned-off-by Ricardo Ribalda <[email protected]>--- drivers/media/usb/uvc/uvc_driver.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/media/usb/uvc/uvc_driver.c +0
-0
drivers/media/usb/uvc/uvc_driver.c int uvc_register_video_device(struct uvc_device *dev, · line 2197
Quoted 4 lines
drivers/media/usb/uvc/uvc_driver.c +1
-0@@ -2194,6 +2194,7 @@ int uvc_register_video_device(struct uvc_device *dev, const struct v4l2_ioctl_ops *ioctl_ops) {int ret; +const char *name;
Please swap those two lines.
Quoted 11 lines
drivers/media/usb/uvc/uvc_driver.c +1
-0/* Initialize the video buffers queue. */ ret =uvc_queue_init (queue, type, !uvc_no_drop_param);@@ -2221,17 +2222,29 @@ int uvc_register_video_device(struct uvc_device *dev,case V4L2_BUF_TYPE_VIDEO_CAPTURE :default : vdev->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; + name ="Video Capture" ;break ;case V4L2_BUF_TYPE_VIDEO_OUTPUT : vdev->device_caps =V4L2_CAP_VIDEO_OUTPUT |V4L2_CAP_STREAMING ;
drivers/media/usb/uvc/uvc_driver.c int uvc_register_video_device(struct uvc_device *dev, · line 2238
Quoted 10 lines
drivers/media/usb/uvc/uvc_driver.c +4
-0+ name ="Video Output" ;break ;case V4L2_BUF_TYPE_META_CAPTURE : vdev->device_caps =V4L2_CAP_META_CAPTURE |V4L2_CAP_STREAMING ; + name ="Metadata" ;break ; } +/* +* Many userspace apps identify the device with vdev->name, so we
s/apps/applications/
drivers/media/usb/uvc/uvc_driver.c int uvc_register_video_device(struct uvc_device *dev, · line 2245
Quoted 7 lines
drivers/media/usb/uvc/uvc_driver.c +5
-0+* cannot change its name for its function. +*/ strscpy (vdev->name, dev->name,sizeof (vdev->name)); +#if defined(CONFIG_MEDIA_CONTROLLER ) + vdev->entity.name =devm_kasprintf (&stream->intf->dev,GFP_KERNEL , +"%s %u" , name, stream->header.bTerminalLink);
Won't the compiler warn about a set but unused variable when !CONFIG_MEDIA_CONTROLLER ?
Quoted 5 lines
drivers/media/usb/uvc/uvc_driver.c +2
-0+#endif +/* * Set the driver data before calling video_register_device, otherwise * the file open() handler might race us.
Signature · 3 lines
Regards, Laurent Pinchart