Skip to contentSkip to conversation

usb: gadget: uvc: Utilise instance name in video name

DISCUSSION Laurent Pinchart 1 participant 1 message May 22, 2018 USB

lore
Share & tools
lore
#0 lore raw

Hi Kieran,

Thank you for the patch.

Quoted 19 lines · On Tuesday, 22 May 2018 18:29:49 EEST Kieran Bingham wrote:

From: Kieran Bingham <[email protected]>

With multiple UVC gadgets on a composite device, the device names become indistinguishable from one another.

Extend the gadget video name to incorporate the function instance name, along side the existing UDC controller name.

---
 drivers/usb/gadget/function/f_uvc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/usb/gadget/function/f_uvc.c index 1affa8e3a974..65454a31ad68 100644

drivers/usb/gadget/function/f_uvc.c uvc_register_video(struct uvc_device *uvc) · line 438

Quoted 7 lines
drivers/usb/gadget/function/f_uvc.c +3 -1
@@ -433,7 +433,9 @@ uvc_register_video(struct uvc_device *uvc)
 	uvc->vdev.release = video_device_release_empty;
 	uvc->vdev.vfl_dir = VFL_DIR_TX;
 	uvc->vdev.lock = &uvc->video.mutex;
-	strlcpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name));
+
+	snprintf(uvc->vdev.name, sizeof(uvc->vdev.name), "%s:%s",
+		 cdev->gadget->name, uvc->func.fi->group.cg_item.ci_name);

If the function is instantiated from the legacy g_webcam, the whole group structure will be zero, so ci_name will be empty. I think you should omit the ":" in that case.

I also wonder whether the vdev.name field will always be long enough. If we can't guarantee that, would it make sense to instead expose the config item name through a custom sysfs property for the video device ?

Quoted 1 line
drivers/usb/gadget/function/f_uvc.c +0 -0
 	video_set_drvdata(&uvc->vdev, uvc);