Since this series did not get any feedback and the mentioned code needs to be fixed I will just start the new year with a fresh v6 series. On Mon, Dec 13, 2021 at 12:27:19AM +0100, Michael Grzeschik wrote:
Ping On Thu, Dec 09, 2021 at 09:43:22AM +0100, Michael Grzeschik wrote:The Hostside format selection is currently only done in userspace, as the events for SET_CUR and GET_CUR are allways moved to the application layer. Since the v4l2 device parses the configfs data, the format negotiation can be done in the kernel. This patch adds the functions to set the current configuration while continuing to forward all unknown events to the userspace level. Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx> --- v1 -> v2: - fixed the commit message - changed pr_debug to pr_err in events_process_data - aligned many indentations - simplified uvc_events_process_data - fixed uvc_fill_streaming_control calls in uvcg_video_init - added setup_subcribed to decide if userspace takes over on EOPNOTSUPP - added data_subscribed to decide if userspace takes over on EOPNOTSUPP - removed duplicate send_response - wrting fmt and frm in full v2 -> v3: - added find_format_index to set the right probe v3 -> v4: - add function find_ival_index and use for cur_ival - fix swapped frame and format in uvc_events_process_data on uvc_fill_streaming_control - set proper resp.length on ep0 complete - dropped setting cur_probe on set_format since function was removed - added locking around getting correspondent cur_{frame,format,ival} v4 -> v5: - fixed sparse errors reported by kernel test robot drivers/usb/gadget/function/f_uvc.c | 234 +++++++++++++++++++++++- drivers/usb/gadget/function/uvc.h | 19 ++ drivers/usb/gadget/function/uvc_v4l2.c | 66 ++++++- drivers/usb/gadget/function/uvc_video.c | 12 +- 4 files changed, 324 insertions(+), 7 deletions(-)[snip]static void uvc_function_ep0_complete(struct usb_ep *ep, struct usb_request *req) { struct uvc_device *uvc = req->context; struct v4l2_event v4l2_event; struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; + struct uvc_request_data resp; + int ret; if (uvc->event_setup_out) { uvc->event_setup_out = 0; + memset(&resp, 0, sizeof(resp)); + resp.length = -EL2HLT; + + ret = uvc_events_process_data(uvc, req); + /* If we have no error on process */ + if (!ret) { + resp.length = req->length; + uvc_send_response(uvc, &resp); + return;I just found out, that depending on the host implementation, sending a response persisting probe or commit is no valid. I will just keep it aligned with the uvc-gadget implementation and fix it not to send any response in that both cases.+ } + + /* If we have a real error on process */ + if (ret != -EOPNOTSUPP) + return; + + /* If we have -EOPNOTSUPP */ + if (!uvc->data_subscribed) + return; + + /* If we have data subscribed */ memset(&v4l2_event, 0, sizeof(v4l2_event)); v4l2_event.type = UVC_EVENT_DATA; uvc_event->data.length = req->actual;Beside that, I hope somebody would help reviewing this, before I will send v6. Laurant? Do you have any thoughts on that whole stack? Thanks, Michael -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
-- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Attachment:
signature.asc
Description: PGP signature