Re: [RFC PATCH] uvc_v4l2: reset connection on uvc open

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

 



Hi Michael,

On Thursday 24 January 2013 11:22:02 Michael Grzeschik wrote:
> 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.

This shouldn't happen, as the UVC gadget driver should start disconnected (it 
calls usb_function_deactive() in uvc_function_bind()). If the host can 
enumerate the gadget before the application starts it would then likely be a 
device controller driver bug, not a UVC gadget driver bug.

> 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;
-- 
Regards,

Laurent Pinchart

--
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