Skip to content

iio: aop: Fix lid angle report decoding and scale - #665

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
fix/aop-las-j616s
Oct 31, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
fix/aop-las-j616s

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

The existing AOP LAS driver reads byte 1 of every fake-HID report as an angle. That drops bit 8 (256 degrees becomes 0) and lets property reports overwrite the cached angle. It also exposes degree counts without the scale required by IIO's radian angle ABI.

Decode only complete report-1 samples as a 9-bit little-endian value in the 0 to 360 range, preserve the last valid sample on other reports, and expose in_angl_scale = 0.017453293. The shared IIO callback returns the fixed scale before the first sample; ALS retains its processed-lux interface. Host tests compile the production decoder and callback with mocks, and Documentation/iio/aop-sensors.rst documents the interface and hardware test plan.

J616s already has the las child (apple,t6041-aop-las, apple,aop-las) under its enabled AOP, and asahi.config enables IIO_AOP_SENSOR_LAS=m. The compiled DTB confirms that wiring, so no DT changes are needed. The existing las announcement handling and EPIC subtype 0xc4 dispatch remain the single transport shared with ALS. Erik's J713 AOP series concerns handoff and microphones; it does not supply another LAS decoder.

Validation:

  • Four host regression tests pass, including all 65,536 two-byte payloads, report IDs, truncation, scale-before-sample and processed-channel behaviour. The original code fails the three LAS-specific tests.
  • arm64 rust/kernel.o, AOP core, LAS and ALS objects, and apple/t6040-j616s.dtb build with KCFLAGS=-Werror KRUSTFLAGS=-Dwarnings using Clang 22.1.6 and Rust 1.97.1.
  • The default defconfig + asahi.config hits a bindgen 0.73.2 layout error for empty, aligned sched_statistics before driver compilation. Validation used CONFIG_SCHEDSTATS=y, the only configuration difference; no configuration workaround is included in this PR.
  • Rust formatting, whitespace checks and strict checkpatch pass with zero errors, warnings or checks. Both new files are registered in MAINTAINERS.

No hardware test was performed. J616s unsolicited report delivery, changing hinge readings, resume and an older AOP platform still need the documented checks. Reading a HID feature report does not establish that Linux receives unsolicited input reports. No feature polling or speculative firmware setup command is added.

The LAS service already uses the same EPIC fake-HID receive path as ALS,
but the decoder treats byte 1 of every report as an angle. Report 1 has
a 9-bit little-endian angle; for example, 256 degrees becomes zero with
the old decoder. Other report IDs can also overwrite the cached angle.

Accept only complete report-1 samples in the 0..360 range and ignore the
padding bits. Keep the raw count in degrees and expose pi/180 through
in_angl_scale so IIO consumers can convert it to radians. A fixed scale
does not need to wait for the first reading. Processed ALS channels keep
their existing interface through the default no-scale implementation.

Add host tests of the production decoder and IIO callback, document the
existing J616s DT/config wiring and a hardware test plan, and register
the new documentation and test under the existing AOP maintainer entry.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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