Hi,
I am using the HID USB gadget on a system that can be plugged in to
different machines with different USB speeds (high or full).
Since the HID polling interval unit depends on the USB speed:
- Full speed: bInterval is linear, in milliseconds (1 to 255)
- High/Super speed: bInterval is logarithmic, encoding the interval
as 2^(bInterval-1) * 125us (microframes)
Exposing directly the bInterval means that the user needs to know
which speed is currently in use and has to convert it accordingly.
I propose a solution to to expose the interval for each speed:
- interval_fs: bInterval for full-speed
- interval_hs: bInterval for high-speed
- interval_ss: bInterval for super-speed
- interval: legacy bInterval that overwrites the per-speed bInterval
to keep backward compatibility
When the user sets the legacy interval attribute, all the other
per-speed interval attributes are set to this value. That way backward
compatibility is ensured.
Thank you for your reviews!
Arthur Crepin Leblond
Signed-off-by: Arthur Crepin Leblond <arthur@marmottus.net>
---
v4 -> v5:
- Got rid of the f_hid_opt_interval and user_set
- Put the new attributes in the same documentation block
- Reword the bInterval differences between speeds
- Link to v4: https://patch.msgid.link/20260831-usb_hid_interval-v4-0-609394103dcb@marmottus.net
v3 -> v4:
- Update documentation against 7.4
- Removed unused struct f_hidg::interval
- Edit cover letter
- Link to v3: https://patch.msgid.link/20260804-usb_hid_interval-v3-1-975a9fec2d7b@marmottus.net
v2 -> v3:
- Use sysfs_emit
- Link to v2: https://patch.msgid.link/20260727152705.79384-1-arthur@marmottus.net
v1 -> v2:
- Expose a specific interval attribute per USB speed
- Use a define for the default values
- Update ABI documentation
- Link to v1: https://patch.msgid.link/20260716144921.1120265-1-arthur@marmottus.net
---
Arthur Crepin Leblond (2):
usb: gadget: f_hid: allow setting different interval for each speed
docs: ABI: testing: document hid interval attributes
Documentation/ABI/testing/configfs-usb-gadget-hid | 8 ++
drivers/usb/gadget/function/f_hid.c | 140 ++++++++++------------
drivers/usb/gadget/function/u_hid.h | 4 +-
3 files changed, 74 insertions(+), 78 deletions(-)
---
base-commit: d58dffe9ee2c8883193959ff4ef995ec07932874
change-id: 20260804-usb_hid_interval-0d8928874826