Commit d7af78b9 authored by Kieran Bingham's avatar Kieran Bingham Committed by Felipe Balbi

usb: gadget: uvc: Expose configuration name through video node

When utilising multiple instantiations of a UVC gadget on a composite
device, there is no clear method to link a particular configuration to
its respective video node.

Provide a means for identifying the correct video node by exposing the
name of the function configuration through sysfs.
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent c728effd
...@@ -263,3 +263,8 @@ Description: Specific streaming header descriptors ...@@ -263,3 +263,8 @@ Description: Specific streaming header descriptors
is connected is connected
bmInfo - capabilities of this video streaming bmInfo - capabilities of this video streaming
interface interface
What: /sys/class/udc/udc.name/device/gadget/video4linux/video.name/function_name
Date: May 2018
KernelVersion: 4.19
Description: UVC configfs function instance name
...@@ -413,10 +413,21 @@ uvc_function_disconnect(struct uvc_device *uvc) ...@@ -413,10 +413,21 @@ uvc_function_disconnect(struct uvc_device *uvc)
* USB probe and disconnect * USB probe and disconnect
*/ */
static ssize_t function_name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct uvc_device *uvc = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name);
}
static DEVICE_ATTR_RO(function_name);
static int static int
uvc_register_video(struct uvc_device *uvc) uvc_register_video(struct uvc_device *uvc)
{ {
struct usb_composite_dev *cdev = uvc->func.config->cdev; struct usb_composite_dev *cdev = uvc->func.config->cdev;
int ret;
/* TODO reference counting. */ /* TODO reference counting. */
uvc->vdev.v4l2_dev = &uvc->v4l2_dev; uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
...@@ -429,7 +440,17 @@ uvc_register_video(struct uvc_device *uvc) ...@@ -429,7 +440,17 @@ uvc_register_video(struct uvc_device *uvc)
video_set_drvdata(&uvc->vdev, uvc); video_set_drvdata(&uvc->vdev, uvc);
return video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1); ret = video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1);
if (ret < 0)
return ret;
ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name);
if (ret < 0) {
video_unregister_device(&uvc->vdev);
return ret;
}
return 0;
} }
#define UVC_COPY_DESCRIPTOR(mem, dst, desc) \ #define UVC_COPY_DESCRIPTOR(mem, dst, desc) \
...@@ -867,6 +888,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f) ...@@ -867,6 +888,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f)
INFO(cdev, "%s\n", __func__); INFO(cdev, "%s\n", __func__);
device_remove_file(&uvc->vdev.dev, &dev_attr_function_name);
video_unregister_device(&uvc->vdev); video_unregister_device(&uvc->vdev);
v4l2_device_unregister(&uvc->v4l2_dev); v4l2_device_unregister(&uvc->v4l2_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment