Skip to content

feat(aura): support Dynamic Lighting sysfs interface with hidraw fallback - #369

Draft
scardracs wants to merge 12 commits into
OpenGamingCollective:mainfrom
scardracs:leds/dynamic-lighting
Draft

feat(aura): support Dynamic Lighting sysfs interface with hidraw fallback#369
scardracs wants to merge 12 commits into
OpenGamingCollective:mainfrom
scardracs:leds/dynamic-lighting

Conversation

@scardracs

@scardracs scardracs commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description

This draft introduces support for the Linux kernel Dynamic Lighting LED class interface (/sys/class/leds/aura:*) across asusctl, prioritizing the standardized sysfs interface while maintaining seamless fallback to legacy USB hidraw for backward compatibility with older kernels. It is based on that draft and as such NOT suitable for daily usage.

NOTE: due to heavy work on both here and linux the text on that OP can or cannot be accurate

Key Changes:

  1. rog-platform (DynamicLed):
    • Implemented DynamicLed sysfs abstraction for interacting with /sys/class/leds/<device>/.
    • Added support for reading/writing effect, effect_index, speed, speed_range, direction, direction_index, effects_palette (#RRGGBB format), direct_buffer, brightness, and power_states.
    • Added unit tests validating palette string formatting and parsing.
  2. rog-aura:
    • Implemented bidirectional conversions between ROG Aura enums (AuraModeNum, Speed, Direction, AuraEffect) and Dynamic Lighting sysfs strings/palettes.
    • Added unit tests covering all effect, speed, direction, and RGB palette conversions.
  3. asusd (3-Device Multi-Zone Dynamic Lighting & Fallback):
    • Probes for aura:global, aura:keyboard, and aura:lightbar during Aura laptop initialization.
    • Independent Zone Routing:
      • Global requests (AuraZone::None) route to aura:global (firmware AURA_ZONE_ALL) for atomic aggregate updates across all zones.
      • Keyboard requests (AuraZone::Key1..4) route to aura:keyboard without interrupting lightbar animations.
      • Lightbar requests (AuraZone::BarLeft / BarRight) route to aura:lightbar without disturbing keyboard lighting.
    • Fallback: Preserves the legacy hidraw handle and transparently falls back to direct HID reports if Dynamic Lighting is unsupported on older kernels.
    • Cleanup: Removed legacy commented-out AniMe HIDRAW probe code in maybe_anime_hid.
  4. asusctl:
    • Fixed clippy::manual_slice_fill in examples/anime-diag.rs.

Tested Hardware & Environment

  • ASUS Laptop Model: ROG Strix G16 (G614PR)
  • Linux Distribution: Arch Linux / OpenGamingCollective
  • Kernel Version: 7.3.0-rc1+ (with Dynamic Lighting patch series)

Verification and testing:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My code follows the style guidelines of this project (cargo fmt --all -- --check)
  • My changes generate no new warnings (cargo clippy --all -- -D warnings/cargo check --all-targets)
  • New and existing unit tests pass locally with my changes (cargo test --all)
  • Cranky with 0 warning (cargo cranky)

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@scardracs
scardracs force-pushed the leds/dynamic-lighting branch from 75ed83b to f70b66d Compare September 8, 2026 22:01
Replace the manual element-wise loop with slice::fill to address
the clippy::manual_slice_fill lint when mutating matrix rows.
Introduce DynamicLed for communicating with the Linux kernel Dynamic
Lighting class interface under /sys/class/leds/<name>/.

This wrapper provides methods to inspect and control:
- effect and dynamically queried supported effects via effect_index
- direction and direction_index
- speed and speed_range
- effects_palette using space-separated #RRGGBB values
- write_direct for streaming raw binary frame data
- brightness, max_brightness, and power_states attributes
Add mapping functions between ROG Aura structures and Dynamic Lighting class values:
- AuraModeNum::{to_dynamic_effect_str, from_dynamic_effect_str}
- Speed::{to_dynamic_speed, from_dynamic_speed}
- Direction::{to_dynamic_direction_str, from_dynamic_direction_str}
- AuraEffect::to_dynamic_palette for extracting RGB palette tuples
Probe for /sys/class/leds/aura:global, aura:keyboard, and aura:lightbar
Dynamic Lighting LED devices during Aura laptop initialization.

When present:
- Query available hardware effect modes dynamically from the kernel via sysfs
  effect_index instead of hardcoding assumptions.
- Route global laptop requests (AuraZone::None) directly to aura:global
  for aggregate hardware execution on AURA_ZONE_ALL.
- Route individual zone requests to aura:keyboard or aura:lightbar for
  independent zone control.
- Prioritize the sysfs Dynamic Lighting interface for effect application,
  brightness control, and power states.
- Retain the legacy USB hidraw device handle and fallback to legacy packets
  if an effect is unsupported by Dynamic Lighting or on older kernels.
Remove legacy commented-out HIDRAW AniMe Matrix probe code in
DeviceHandle::maybe_anime_hid. AniMe Matrix over HIDRAW is currently
unsupported and immediately returns an explicit NotFound error, making
the commented lines dead code.
…om aura laptop

With the introduction of the Dynamic Lighting sysfs interface (/sys/class/leds/aura:*), direct USB HID report 0x5d writes via hidraw are no longer necessary for Aura laptop keyboard, lightbar, or unified chassis control.

- Remove the `hid` (HidRaw) handle from the `Aura` struct.
- Remove raw 64-byte padded packet writes (AURA_LAPTOP_LED_SET/APPLY) and fallback paths from `write_effect_and_apply`, `set_power_states`, `write_effect_block`, and `fix_ally_power`.
- Update `DeviceHandle::maybe_laptop_aura` to not require a HidRaw handle.
- In `aura_manager`, bypass opening `/dev/hidrawX` for Aura laptop keyboards to avoid unnecessary open file descriptors and kernel hidraw minor leaks.
…handles

Remove unused `hid` (HidRaw) handle from `AniMe` struct and methods, as AniMe Matrix devices are driven exclusively via USB raw packets.

- Remove `hid` field from `AniMe` and `AniMe::new`.
- Remove dead `DeviceHandle::maybe_anime_hid` stub and its invocation in `init_hid_devices`.
- Remove dead enum variants `Ally`, `OldAura`, and `TufLedClass` from `DeviceHandle`.
…t_buffer

Migrate per-key and zoned direct RGB addressing in write_effect_block
from raw USB HID writes to the Dynamic Lighting direct_buffer sysfs
interface exposed by the kernel driver (hid-asus).

When Dynamic Lighting is available on the keyboard or global chassis
node, convert the per-key chunked packets or 4-zone payloads into a
flat RGB stream sized to match the hardware led_count, and write it
directly to direct_buffer. The kernel driver handles packet chunking
(opcode 0xbc), concurrency locking, and direct frame streaming without
requiring userspace to open or manage /dev/hidraw.
Update DynamicLed device discovery to support non-aura-prefixed LED class
nodes that expose the Dynamic Lighting sysfs ABI (effect_index), such as
asus::kbd_backlight registered by asus-wmi on TUF laptops.

In DeviceHandle::maybe_laptop_aura, fall back to asus::kbd_backlight if
aura:keyboard is absent. This allows TUF RGB laptop keyboards to be driven
via the unified Dynamic Lighting sysfs path (effect, speed, palette) with
graceful fallback to legacy platform sysfs when Dynamic Lighting is not
supported by the kernel.
…idraw

Add SlashLed wrapper in rog-platform targeting /sys/class/leds/asus::slash
created by the kernel hid-asus driver.

Update asusd's Slash implementation to drive brightness, animation mode,
and interval via SlashLed sysfs attributes, retaining raw USB as a fallback
for older kernels.

Remove remaining HidRaw handles and device probing from aura_manager,
completing the full removal of hidraw dependencies from the asusd daemon.
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch from 3e07fa2 to e90e9ed Compare September 8, 2026 22:35
Add generic ScsiLed abstraction in rog-platform leveraging the kernel's
Dynamic Lighting interface (led_classdev_dynamic) exposed by the
leds-asus-aura-scsi driver.

Update ScsiAura in asusd to drive lighting exclusively through native
kernel Dynamic Lighting (ScsiLed), and remove legacy userspace SG_IO
ioctl mechanisms (sg.rs, scsi.rs, and libc dependency across the workspace).
In aura_manager, discover native ScsiLed sysfs nodes directly,
eliminating raw SCSI ioctls, retry loops, and the need for CAP_SYS_RAWIO.
Drive Slash lighting exclusively through the sysfs SlashLed interface
provided by the hid-asus kernel driver.

Remove the USBRaw fallback handle and write_bytes wrapper from the Slash
controller, and remove new_slash_usb from DeviceHandle. With hid-asus
handling Slash Lighting in the kernel, userspace raw USB transfers are no
longer required, simplifying the daemon architecture and eliminating
unneeded device descriptor handles.
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