usb: gadget: uvc: disable stream when disconnected
PATCH v2 3/3 usb: gadget: uvc: disable stream when disconnected
Hi Paul,
Thank you for the patch.
Quoted 22 lines · On Tuesday, 24 April 2018 23:59:36 EEST Paul Elder wrote:
Down the call stack from the ioctl handler for
VIDIOC_STREAMON,uvc_video_alloc_requestscontains aBUG_ON, which in the high level, triggers whenVIDIOC_STREAMONioctl is issued withoutVIDIOC_STREAMOFFbeing issued previously.This can also be triggered by starting the stream and then physically disconnecting usb. To fix this, do the streamoff procedures on usb disconnect.
Signed-off-by Paul Elder <[email protected]>---
Changes in v2: Nothingdrivers/usb/gadget/function/f_uvc.c | 3 +++ 1 file changed, 3 insertions(+)(quoted diff) +0
-0
b/drivers/usb/gadget/function/f_uvc.cindexfa34dcbe1197..5bb79888e3f7100644
drivers/usb/gadget/function/f_uvc.c uvc_function_disable(struct usb_function *f) · line 382
Quoted 9 lines
drivers/usb/gadget/function/f_uvc.c +3
-0@@ -374,9 +374,12 @@ uvc_function_disable(struct usb_function *f) {struct uvc_device *uvc =to_uvc (f);struct v4l2_event v4l2_event; +struct uvc_video *video = &uvc->video;INFO (f->config->cdev,"uvc_function_disable\n" ); +uvcg_video_enable (video,0 ); +
As commented in my reply to patch 2/3, you will need to protect this with proper locking. You now have at least four events dealing with states and buffers allocation (VIDIOC_STREAMON, VIDIOC_STREAMOFF, uvc_function_set_alt and uvc_function_disable).
Quoted 3 lines
drivers/usb/gadget/function/f_uvc.c +0
-0memset (&v4l2_event,0 ,sizeof (v4l2_event)); v4l2_event.type =UVC_EVENT_DISCONNECT ;v4l2_event_queue (&uvc->vdev, &v4l2_event);