Skip to content

Leds/dynamic lighting - #17

Draft
scardracs wants to merge 4 commits into
OpenGamingCollective:masterfrom
scardracs:leds/dynamic-lighting
Draft

Leds/dynamic lighting#17
scardracs wants to merge 4 commits into
OpenGamingCollective:masterfrom
scardracs:leds/dynamic-lighting

Conversation

@scardracs

@scardracs scardracs commented Sep 4, 2026

Copy link
Copy Markdown

Draft for progress. I'll make a proper PR title/message when it is ready for review.

@scardracs
scardracs force-pushed the leds/dynamic-lighting branch 2 times, most recently from b472da2 to 02c6e54 Compare September 4, 2026 19:51
Define LED_DYNAMIC_LIGHTING flag in struct led_classdev to enable
runtime type identification for Dynamic Lighting class devices,
matching the established pattern used by LED_MULTI_COLOR.

Signed-off-by: Marco Scardovi <[email protected]>
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch 2 times, most recently from 005fb1f to c6ee973 Compare September 5, 2026 12:09
#include <linux/string.h>
#include <linux/sysfs.h>

static const char * const dl_zone_type_names[] = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have to be managed by the specific driver (like hid-asus).

the dynamic lighting will need to be fully agnostic about what It's supported. Something like drm core that is made of helpers

Add the Dynamic Lighting LED class subsystem to provide a standardized,
sysfs-native interface for complex illumination devices such as per-key
RGB keyboard matrices, 2D LED displays, addressable segment strips, and
chassis lightbars.

Introduce struct led_classdev_dynamic which wraps struct led_classdev
and provides:
- Static sysfs attribute groups with dynamic visibility helpers to
  prevent race conditions during device registration.
- Sysfs metadata attributes ('led_count', 'matrix_dimensions') enabling
  dynamic userspace frame buffer sizing without hardcoded quirk tables.
- Hardware animation effect management ('effect', 'effects_supported',
  'effect_speed', 'effect_direction') and multi-color stacked palettes
  ('effects_palette') using bounds-checked hex2bin parsing.
- Platform power state persistence ('power_states_supported',
  'power_states') for hardware states (boot, awake, sleep, shutdown).
- High-throughput binary frame sinks ('direct_buffer', 'frame') for
  60 FPS RGB matrix streaming and monochrome chunk transfers.
- Strict lock hierarchy (cdev->led_access > trigger removal >
  ldev->lock) preventing deadlocks between sysfs handlers and LED
  triggers.
- Scope-based guard(mutex) resource acquisition across all sysfs handlers.
- Runtime class identification via is_dynamic_lighting_led() helper.

Signed-off-by: Marco Scardovi <[email protected]>
Add documentation for the Dynamic Lighting LED class interface:
- Documentation/ABI/testing/sysfs-class-leds-dynamic: version-agnostic
  sysfs and binary attribute interface specification.
- Documentation/leds/leds-class-dynamic.rst: overview of topology
  types, sysfs directory layout, attribute details, locking order,
  and interaction examples.
- Register leds-class-dynamic in Documentation/leds/index.rst.
- Track documentation files under LED DYNAMIC LIGHTING CLASS in
  MAINTAINERS.

Signed-off-by: Marco Scardovi <[email protected]>
…ming

Add native Dynamic Lighting class support to hid-asus for ASUS ROG
keyboards and chassis lightbars using the Aura USB HID wire protocol:
- Discover Aura lighting capabilities and zone layout (4-Zone vs Per-Key)
  via Report 0x5D opcode 0x05 (0x05 0x20 0x31) querying hardware layout
  and feature flags (lightbar presence).
- Wake all physical hardware zones (zones 0..3 for keyboard, zone 4
  for chassis lightbar) via asus_aura_wake_all_zones() with power
  gating unmute (report 0x5d 0xbd) and error propagation.
- Implement hardware animation effect configuration (report 0x5d 0xb3)
  for keyboard zones (zones 1..4, or zone 0 All) and chassis lightbar
  zones (zone 6 BarLeft and zone 7 BarRight).
- Sequence commit operations using the staging SET command (0x5d 0xb5)
  followed by the APPLY command (0x5d 0xb4) for keyboard zones to
  reliably activate and persist hardware register state in alignment
  with Armoury Crate and asusctl captures, while omitting commit on
  the lightbar path where updates apply immediately.
- Maintain independent per-channel direct streaming state (kbd_direct_mode
  and lightbar_direct_mode) and provide independent effect, speed,
  direction, brightness, and color control across 'aura:keyboard' and
  'aura:lightbar' dynamic lighting devices.
- Route lightbar animated effects strictly through opcode 0xb3 without
  trailing direct streaming packets, reserving direct packets on channel
  0x04 for static/off modes and direct buffer writes.
- Implement direct RGB streaming for ASUS ROG Strix series laptops
  sharing USB PID 0b05:19b6 (e.g. G614, G834 models) via
  asus_aura_strix_set_direct() and asus_aura_lightbar_set_direct()
  using 64-byte HID Feature Reports with opcode 0xbc on channels 0x01
  and 0x04.
- Correct 4-zone chassis lightbar direct buffer bounds (18 bytes at
  offset 27) and enforce exact led_count * 3 buffer size validation
  across direct write callbacks.
- Bound direct per-key keyboard frame transmissions strictly to 11
  packets carrying 168 LEDs total (504 bytes), preventing the internal
  firmware defect where a 12th packet shuts off the rear lightbar and
  front glow strip.
- Serialize Aura feature and raw requests with
  guard(mutex)(&drvdata->aura_lock) and manage lock and DMA buffer
  lifetime with devm_mutex_init and devm_kzalloc.
- Register 'aura:keyboard' and 'aura:lightbar' dynamic lighting devices
  during probe prior to the QUIRK_ROG_NKEY_KEYBOARD early return, leaving
  legacy 'asus::kbd_backlight' 4-step brightness fully functional without
  regressions.

Signed-off-by: Marco Scardovi <[email protected]>
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch from c6ee973 to 2ce82cc Compare September 5, 2026 14:23
@scardracs

Copy link
Copy Markdown
Author

I've moved the patch to 7.2 in order to have some stability (7.3 is way too bugged as for now). When the situation will be better I'll move it back to 7.3. I leave that draft open for now

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.

2 participants