[RFC PATCH] uvc_v4l2: reset connection on uvc open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The current implementation of the composite framework connects the
gadget function to the device-controller at kernel boottime.

It's possible that the userspace application, which handles the
enumeration requests of the gadget, starts with high latency when the
host did already gave up to detect the gadget. In that case the
gadget-application will not work in the first case.

To ensure that the device acts properly with application start, we reset
the connection on device open, so the host restarts its enumeration
requests for the gadget.

Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx>
---

Another approach could be, to connect the composite to the
device-controller only at open of the v4l2 device. As the composite
framework is generic, this could probably not be true for every
function.

 drivers/usb/gadget/uvc_v4l2.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/uvc_v4l2.c b/drivers/usb/gadget/uvc_v4l2.c
index 2ca9386..068d6a7 100644
--- a/drivers/usb/gadget/uvc_v4l2.c
+++ b/drivers/usb/gadget/uvc_v4l2.c
@@ -16,6 +16,7 @@
 #include <linux/list.h>
 #include <linux/mutex.h>
 #include <linux/videodev2.h>
+#include <linux/usb/gadget.h>
 #include <linux/vmalloc.h>
 #include <linux/wait.h>
 
@@ -122,6 +123,7 @@ uvc_v4l2_open(struct file *file)
 	struct video_device *vdev = video_devdata(file);
 	struct uvc_device *uvc = video_get_drvdata(vdev);
 	struct uvc_file_handle *handle;
+	struct usb_composite_dev *cdev = uvc->func.config->cdev;
 
 	handle = kzalloc(sizeof(*handle), GFP_KERNEL);
 	if (handle == NULL)
@@ -130,6 +132,9 @@ uvc_v4l2_open(struct file *file)
 	v4l2_fh_init(&handle->vfh, vdev);
 	v4l2_fh_add(&handle->vfh);
 
+	usb_gadget_disconnect(cdev->gadget);
+	usb_gadget_connect(cdev->gadget);
+
 	handle->device = &uvc->video;
 	file->private_data = &handle->vfh;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux