Skip to content

hid-ayaneo: sync to the upstream v3 state - #11

Open
matmartinez wants to merge 6 commits into
OpenGamingCollective:masterfrom
matmartinez:hid-ayaneo-v3-sync
Open

hid-ayaneo: sync to the upstream v3 state#11
matmartinez wants to merge 6 commits into
OpenGamingCollective:masterfrom
matmartinez:hid-ayaneo-v3-sync

Conversation

@matmartinez

@matmartinez matmartinez commented Aug 28, 2026

Copy link
Copy Markdown

Follow-up to #3 and #5, as invited. This brings hid-ayaneo in the tree up to the current upstream submission state: the rest of the LKML v2 round (#5 already carried its teardown-UAF fix), plus everything adopted from @pastaq's review on #3.

Commits, in order:

  1. sync remaining changes from the upstream v2 submission: eject-loop bail on fatal errors, maxcollection guard before touching hdev->collection, drop the joystick-sensitivity bytes from the config command so the firmware setting is left alone (hardware-verified), breathing effect via the stock ledtrig-pattern hw_pattern ABI, and a comment on reply matching. Matches the v2 series on lore.
  2. name and justify firmware timing constants
  3. use generic ayaneo_ prefix for driver plumbing (wire constants stay AYA3_*)
  4. describe the wire format with packed structs, with static_asserts and the vibration levels as an enum
  5. take the command lock with scoped guards, scoped_cond_guard(mutex_intr, ...) at every lock site
  6. mark the LED classdev LED_COLOR_ID_RGB

Commits 3 through 6 are the items adopted from the #3 review. The remaining review points are deferred to the upstream v3 cover letter as proposed ABI growth (rumble_intensity plus index attrs, eject_index, and the hid to ayaneo-ec notification framework, which needs the pdx86 folks on Cc). The RGB debounce question was resolved in the #3 thread with hardware measurements: brightness_set_blocking gets core-level deferral and coalescing, 5.3 ms average command round trip, and 1000 back-to-back sysfs stores complete in 12 ms without blocking the writer.

Hardware validation (AYANEO 3, Bazzite 44, kernel 7.2.0-ogc6.1): this exact file builds clean and is what I'm running daily. Module IDs read correctly through the new struct offsets, solid/pulse/off all ACKed (pulse visually confirmed), malformed hw_pattern writes are rejected, module reload cycles and dmesg are clean, and the teardown fix previously survived repeated unbind-under-brightness-hammer rounds.

After this lands the tree matches what will go out as v3 to LKML. v3 additionally grows only the Cc list and cover letter; no further code delta is planned unless upstream review asks for one.

The teardown use-after-free fix from v2 is already in the tree; bring
over the rest of that round:

- bail out of the eject polling loop on fatal command errors instead
  of burning the full 8s budget; only -ETIMEDOUT keeps polling, since
  the device goes mute mid-eject
- guard the vendor-interface match with hdev->maxcollection so a
  descriptor with no collections cannot dereference hdev->collection
- stop writing the joystick-sensitivity bytes in the config command;
  leaving them zero preserves the firmware setting instead of
  clobbering it on every RGB update (verified on hardware)
- expose the firmware's fixed breathing effect through the
  ledtrig-pattern hw_pattern ABI as the two-step pattern
  "0 <t> <brightness> <t>"; the period is firmware-controlled
- document why matching replies by subcommand echo alone is safe

Matches the driver as submitted upstream in
lore.kernel.org/linux-input/20260824223103.93947-1-hello@matias.me;
re-validated on an AYANEO 3.

Signed-off-by: Matías Martínez <hello@matias.me>
Replace the bare msleep/loop-bound literals with named constants and
a comment recording where the timings come from (the Handheld Daemon
implementation of this protocol) and what was validated on hardware.

Signed-off-by: Matías Martínez <hello@matias.me>
Keep entry points and driver structure generic so a future device or
protocol revision slots in without churn. Wire-protocol constants
stay AYA3_* since they are specific to this firmware generation.

Suggested-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Matías Martínez <hello@matias.me>
Replace the byte-offset defines with packed aya3_config/aya3_resp
structs (hid-lenovo-go idiom), static_assert their sizes against the
report sizes, and name every firmware vibration level in an enum
instead of a lone default define.

Suggested-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Matías Martínez <hello@matias.me>
Use scoped_cond_guard(mutex_intr, ...) at every interruptible lock
site so the unlock cannot be dropped in a future edit. Probe already
used scoped_guard.

Suggested-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Matías Martínez <hello@matias.me>
Lets userspace detect the RGB interface generically, same as hid-msi,
hid-oxp and hid-lenovo-go.

Suggested-by: Derek J. Clark <derekjohn.clark@gmail.com>
Signed-off-by: Matías Martínez <hello@matias.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant