xairy / raw-gadget

USB Raw Gadget — a low-level interface for the Linux USB Gadget subsystem
350 stars 37 forks source link

Expose more hardware information via ioctls #41

Open xairy opened 1 year ago

xairy commented 1 year ago

The Gadget subsystem provides information about the capabilities of the UDC hardware. It might be useful to expose this information via Raw Gadget ioctls.

xairy commented 11 months ago

One of the things we need to expose is usb_gadget->ep0->maxpacket: looks like some UDCs expect bMaxPacketSize0 in the device descriptor to be not lower than the maxpacket that they set.

xairy commented 11 months ago

Some UDCs also have a minimum device speed they support, e.g. DWC3.

This information is not exposed through usb_gadget though.

The comment for max_speed is also misleading.

xairy commented 11 months ago

So the speed provided to USB_RAW_IOCTL_INIT is rather just a hint, and the UDC might decide to use a different one. Perhaps, we should expose the actual speed of the device as well.

xairy commented 11 months ago

It also appears the UDC might set a particular maxpacket value for non-control endpoints, (see calls to dwc2_hsotg_set_ep_maxpacket in dwc2), and Raw Gadget should expose this via USB_RAW_IOCTL_EPS_INFO.

Or is that the dwc2 driver that needs to be fixed? Other UDCs don't seem to do this.

Nevermind, dwc2 takes those values from the USB descriptors.

xairy commented 3 months ago

Issue #73 is related to exposing whether the UDC supports remote wake up.