Yifan-Liu1 commented on code in PR #21443:
URL: https://github.com/apache/nuttx/pull/21443#discussion_r4477241224
##########
arch/sim/src/sim/posix/sim_libusb.c:
##########
@@ -394,32 +405,101 @@ static int host_libusb_ep0outhandle(struct
host_libusb_hostdev_s *dev,
return LIBUSB_ERROR_NO_DEVICE;
}
- if ((ctrlreq->bRequestType & USB_TYPE_MASK) !=
- USB_TYPE_STANDARD)
+ if ((ctrlreq->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD)
{
- return ret;
+ /* Class and vendor requests carry the payload of the class driver: a
+ * UVC camera is configured through SET_CUR requests on its video
+ * control interface, for instance.
+ */
+
+ ret = host_uninterruptible(libusb_control_transfer, dev->handle,
+ ctrlreq->bRequestType, ctrlreq->bRequest,
+ ctrlreq->wValue, ctrlreq->wIndex,
+ datareq->data, datareq->len, 0);
Review Comment:
Right, that call had no business being synchronous - thanks for pointing it
out.
Fixed in cb1743b, submitted asynchronously the way
`host_libusb_ep0inhandle()` does rather than with a synchronous timeout. The
common part moved into `host_libusb_ep0submit()`, which fills the control
setup, copies the payload of an OUT transfer into the transfer buffer, and
returns right after `libusb_submit_transfer()`. The completion callback hands
the request back to the host thread that is already waiting for it, so
`priv->lock` is no longer held while the device stays silent; the transfer
timeout stays bounded (`HOST_LIBUSB_CTRL_TIMEOUT_MS`, 5 s) so a silent device
fails the request instead of stopping anything.
Standard requests keep their previous synchronous handling, since they must
complete before enumeration continues.
Verified: the simulator builds with `CONFIG_USBHOST_CDCACM`,
`CONFIG_USBHOST_FT232R`, `CONFIG_USBHOST_COMPOSITE` and `CONFIG_USBHOST_UVC`
without new warnings, `tools/checkpatch.sh -c -u -m -g` is clean, and the
camera still enumerates, negotiates through its class-specific SET_CUR requests
(now on the asynchronous path) and streams - JPEG 640x480, 8 frames in 499 ms.
Please take another look when you get a chance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]