@@ -334,6 +334,8 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
uvc->state = UVC_STATE_STOPPING;
+ usb_composite_setup_delay(cdev);
+
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_STREAMOFF;
v4l2_event_queue(&uvc->vdev, &v4l2_event);
@@ -358,10 +360,19 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
uvc->state = UVC_STATE_STARTING;
+ usb_composite_setup_delay(cdev);
+
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_STREAMON;
v4l2_event_queue(&uvc->vdev, &v4l2_event);
- return USB_GADGET_DELAYED_STATUS;
+
+ /*
+ * Normally we would return USB_GADGET_DELAYED_STATUS
+ * but status phase might try to continue in between
+ * this function returning and the delayed status
+ * actually being set
+ */
+ return 0;
default:
return -EINVAL;
@@ -235,6 +235,8 @@ uvc_v4l2_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
uvc->state = UVC_STATE_CONNECTED;
+ uvc_function_setup_continue(uvc);
+
return 0;
}
This patch depends on the previous patch in this series: [PATCH 2/4] usb: gadget: composite: add function to increment delayed_status The completion of the usb status phase from uvc_function_set_alt needs to be delayed until uvc_v4l2_streamon/off. This is currently done by uvc_function_set_alt returning USB_GADGET_DELAYED_STATUS and composite_setup detecting this to increment cdev->delayed_status. However, if uvc_v4l2_streamon/off is called in between this return and increment, uvc_function_setup_continue within uvc_v4l2_streamon/off will WARN that cdev->delayed_status is zero. To fix this, use usb_composite_setup_delay to increment cdev->delayed_status, and then return 0 so that composite_setup doesn't increment cdev->delayed_status again. Signed-off-by: Paul Elder <paul.elder@pitt.edu> --- drivers/usb/gadget/function/f_uvc.c | 13 ++++++++++++- drivers/usb/gadget/function/uvc_v4l2.c | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-)