Skip to content

usb: gadget: f_hid: allow setting different interval for each speed

Arthur Crepin Leblond linux-usb lkml 4 versions – New

Get series with b4
b4 am [email protected] change-id 20260804-usb_hid_interval-0d8928874826

Versions newest first

  1. v5 Latest2 patches 0 repliesNew
  2. v42 patches 0 repliesSuperseded
  3. v31 patch 0 repliesSuperseded inferred link
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v21 patch1 replySuperseded

Changes in v5 from the cover letter

- 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/[email protected]

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2usb: gadget: f_hid: allow setting different interval for each speeddrivers/usb/gadget/function/f_hid.c drivers/usb/gadget/function/u_hid.h+66 -780 replies
2/2docs: ABI: testing: document hid interval attributesDocumentation/ABI/testing/configfs-usb-gadget-hid+8 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/2] usb: gadget: f_hid: allow setting different interval for each speed

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

---
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/[email protected]

v3 -> v4:
- Update documentation against 7.4
- Removed unused struct f_hidg::interval
- Edit cover letter
- Link to v3: https://patch.msgid.link/[email protected]

v2 -> v3:
- Use sysfs_emit
- Link to v2: https://patch.msgid.link/[email protected]

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/[email protected]

---
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