Skip to content

leds: dynamic: Add Dynamic Lighting class interface and Aura (hid-asus) support - #17

Open
scardracs wants to merge 1253 commits into
OpenGamingCollective:masterfrom
scardracs:leds/dynamic-lighting
Open

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

Conversation

@scardracs

@scardracs scardracs commented Sep 4, 2026 •

Copy link
Copy Markdown

Summary

This pull request introduces the Dynamic Lighting LED class to the kernel and adds driver support in hid-asus for ASUS ROG Aura keyboards and chassis lightbars.
It provides a standard sysfs ABI for devices that expose multi-zone effects, palette programming, direct RGB frame streaming, and lighting power-state persistence, without requiring individual drivers to invent ad-hoc sysfs layouts.

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


Commits Overview

  1. leds: Add LED_DYNAMIC_LIGHTING flag to LED core
    • Defines LED_DYNAMIC_LIGHTING in struct led_classdev to enable runtime identification of Dynamic Lighting class devices, following the pattern of LED_MULTI_COLOR.
  2. leds: dynamic: Add Dynamic Lighting core class interface
    • Implements the new class (drivers/leds/led-class-dynamic.c, include/linux/led-dynamic-lighting.h) extending led_classdev.
    • Exposes common effect, speed, direction, and power-state controls, plus binary direct-buffer and frame write interfaces.
    • Serializes writes using led_access and the class mutex to ensure thread safety alongside LED triggers.
  3. docs: leds: Document the Dynamic Lighting class ABI
    • Documents the user-facing sysfs interface in Documentation/ABI/testing/sysfs-class-leds-dynamic and Documentation/leds/leds-class-dynamic.rst.
    • Updates Documentation/leds/index.rst and registers the subsystem files in MAINTAINERS.
  4. HID: asus: Add Dynamic Lighting support for Aura devices
    • Integrates Dynamic Lighting support into hid-asus.
    • Discovers keyboard layout and chassis lightbar zones via the Aura probe report.
    • Implements zone power unmasking (0xbd), zone activation (0xc0), and hardware effect engine programming (0xb3) with the firmware latch commit sequence (0xb5 SET -> 0xb4 COMMIT -> 0xb5 SET).
    • Supports direct per-key/lightbar packed RGB frame writes through the class direct-buffer streaming interface.
    • Fully preserves backward compatibility with the existing asus::kbd_backlight brightness control.

Summary by CodeRabbit

  • New Features
    • Added Dynamic Lighting controls for supported devices, including RGB streaming, hardware effects, color palettes, animation speed and direction, power-state persistence, and matrix or zone information.
    • Added ASUS Aura lighting support for keyboard, lightbar, and global zones, with selectable automatic, unified, and split modes.
    • Added lighting controls for supported ASUS ROG Slash devices.
  • Documentation
    • Added guides and reference information covering Dynamic Lighting controls, supported values, and usage constraints.

@scardracs
scardracs force-pushed the leds/dynamic-lighting branch 4 times, most recently from 005fb1f to c6ee973 Compare September 5, 2026 12:09
Comment thread drivers/leds/led-class-dynamic.c Outdated
@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

Comment thread Documentation/ABI/testing/sysfs-class-leds-dynamic Outdated
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch 2 times, most recently from 45f6a76 to 1a38a2e Compare September 8, 2026 14:19
@scardracs scardracs changed the title Leds/dynamic lighting leds: dynamic: Add Dynamic Lighting class interface and Aura (hid-asus) support Sep 8, 2026
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch from 1a38a2e to 4e550e9 Compare September 8, 2026 18:30
@scardracs

Copy link
Copy Markdown
Author

Added an aura:global that controls both keyboard and lightbar for those devices that don't have the ability to control them separately

@scardracs
scardracs force-pushed the leds/dynamic-lighting branch 4 times, most recently from 3a706b9 to a4d18f6 Compare September 9, 2026 07:42
Grippy98 pushed a commit to Grippy98/linux-unstable that referenced this pull request Sep 10, 2026
cifs.idmap key descriptions carry authority-bearing fields (owner and
group SIDs and uid/gid values in "os:"/"gs:"/"oi:"/"gi:" form) that the
cifs.idmap upcall helper treats as kernel-originating inputs.  Unlike
its sibling cifs.spnego, the cifs.idmap key type has no vet_description
hook, so userspace can create keys of this type through
request_key(2)/add_key(2) and supply those fields without CIFS origin.
A request_key(2) call with a non-NULL callout then drives a root
usermodehelper upcall (/sbin/request-key -> cifs.idmap) that consumes
the unvetted description in root context.

Only accept cifs.idmap descriptions while CIFS is using its private
root_cred to request the key.  id_to_sid()/sid_to_id() already run
under override_creds(root_cred), so the kernel-originated path is
unaffected.

This mirrors commit 3da1fdf ("smb: client: reject userspace
cifs.spnego descriptions"), which applied the same restriction to
cifs.spnego.

Fixes: 4d79dba ("cifs: Add idmap key and related data structures and functions (try OpenGamingCollective#17 repost)")
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Cc: stable@vger.kernel.org
Assisted-by: CodeBuddy:Kimi-K3
Signed-off-by: Aohan Mei <henrymei@tencent.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch 4 times, most recently from fb74985 to 907aeed Compare September 13, 2026 10:23
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch 4 times, most recently from 7d4bd15 to 3b75011 Compare September 18, 2026 14:12
@scardracs
scardracs marked this pull request as ready for review September 18, 2026 14:13
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch from 3b75011 to 5a77b23 Compare September 18, 2026 14:21

@pastaq pastaq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm concerned that this implementation is too restrictive. I was under the impression that the classdev would outline the shape of the ABI, and a generic implementation would also exist that would implement them. Currently I don't see how I can transition the existing hid-[lenovo-go*|oxp|msi] drivers to this which need more dynamic ability to describe built in effects. Ideally this could be a drop in replacement where I just need to define the index/range for each and assign function pointers like I do with brightness/multi_intensity.

Comment thread Documentation/ABI/testing/sysfs-class-leds-dynamic Outdated
Comment thread Documentation/ABI/testing/sysfs-class-leds-dynamic Outdated
Comment thread Documentation/leds/leds-class-dynamic.rst Outdated
Comment thread Documentation/leds/leds-class-dynamic.rst Outdated
Comment thread drivers/hid/hid-ids.h
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch 2 times, most recently from 1f19f64 to 7a78e0e Compare September 26, 2026 07:31
NeroReflex and others added 8 commits September 27, 2026 18:38
--
2.47.3

(cherry picked from commit 536526d)
(cherry picked from commit 0ebc551)
(cherry picked from commit 2e5980a)
--
2.47.3
--
2.47.3
(cherry picked from commit 82fa594)
--
2.47.3
[Why]
Chrontel CH7218 found in Ugreen DP -> HDMI 2.1 adapter (model 85564)
works perfectly with VRR after testing. VRR and FreeSync compatibility
is explicitly advertised as a feature so it's addition is a formality.

Support FreeSync info packet passthrough and "generic" HDMI VRR.

[How]
Add CH7218's ID to dm_helpers_is_vrr_pcon_allowed()

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4773

Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
(cherry picked from commit 7b2436287ed953496ad1c9eb5820f00b75db597f)
(cherry picked from commit a9c7548)
The detachable keyboard shipped with the ROG Zephyrus Duo GX651AR
(0b05:1ce6) is a ROG N-Key keyboard, but it is not listed in
asus_devices[], so its interfaces are left to hid-generic and its
vendor usages are never mapped by asus_input_mapping().

Add it with QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD, matching
the other ROG N-Key keyboards.

Tested-by: Cymirk <cymirk@icloud.com>
Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
(cherry picked from commit 8d70b5f)
… interfaces

On the ROG Zephyrus Duo GX651AR (0b05:1ce6) the hotkeys live on report
0x5a on an interface whose descriptor holds nothing but two ASUS vendor
collections. Neither satisfies IS_INPUT_APPLICATION(), so
hidinput_connect() creates no input device, asus_input_mapping() never
runs and every hotkey is dropped by asus_event() as unmapped.

Set HID_QUIRK_HIDINPUT_FORCE on ROG N-Key interfaces that carry an ASUS
vendor input report so those usages get mapped. Interfaces left with no
mapped usage are still discarded by hidinput_has_been_populated().

The vendor check reads report_enum[HID_INPUT_REPORT], so interfaces with
no input reports, such as the RGB control interface, are unaffected.

Tested-by: Cymirk <cymirk@icloud.com>
Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
(cherry picked from commit 69887e3)
…Bluetooth

The GX651AR keyboard enumerates as 0b05:1ce6 over USB but pairs as
0b05:1ce7 in Bluetooth mode, where the keyboard, consumer and both ASUS
vendor collections (reports 0x5a and 0x5d) sit on a single HID device.
Add it with the same quirks as the USB entry.

Bind to HID_GROUP_GENERIC so that hid-multitouch keeps the digitizer.

Tested-by: Cymirk <cymirk@icloud.com>
Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
(cherry picked from commit b0dbc09)
…X651AR

Fn+F12 on the GX651AR keyboard emits ASUS vendor code 0x9c, which
asus_input_mapping() does not know about, so asus_event() drops it as
unmapped.

Map it to KEY_F19. F13 to F18 are already used for ASUS toggles that
have no generic keycode.

Tested-by: Cymirk <cymirk@icloud.com>
Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
(cherry picked from commit 337a811)
…=7 and dump serial log head on banner failure

The smoke test greps the captured serial console log for the kernel
banner ("Linux version <KREL> "), but the banner is printed at
KERN_NOTICE while some distro configs default the console to a quieter
level: Arch ships CONFIG_CONSOLE_LOGLEVEL_DEFAULT=4, which suppresses
notice (and info) messages entirely. The result was a confusing failure
mode: the kernel booted to userspace just fine (BOOT_OK marker, printed
by init directly on /dev/ttyS0), yet the banner check failed because
the console log only carried a few high-priority lines.

Pin loglevel=7 on the test kernel command line so every distro kernel
logs verbosely enough for the banner to be captured, and replace the
useless "^Linux version" grep in the failure path (banner lines are
prefixed with a "[    0.000000] " timestamp, so that grep could never
match) with a dump of the first serial console lines.

Verified locally against a kernel built with the exact Arch config
pipeline: the run failed identically to CI before the change and passes
both the bios-pc and uefi-q35 legs after it.
NeroReflex pushed a commit that referenced this pull request Sep 27, 2026
cifs.idmap key descriptions carry authority-bearing fields (owner and
group SIDs and uid/gid values in "os:"/"gs:"/"oi:"/"gi:" form) that the
cifs.idmap upcall helper treats as kernel-originating inputs.  Unlike
its sibling cifs.spnego, the cifs.idmap key type has no vet_description
hook, so userspace can create keys of this type through
request_key(2)/add_key(2) and supply those fields without CIFS origin.
A request_key(2) call with a non-NULL callout then drives a root
usermodehelper upcall (/sbin/request-key -> cifs.idmap) that consumes
the unvetted description in root context.

Only accept cifs.idmap descriptions while CIFS is using its private
root_cred to request the key.  id_to_sid()/sid_to_id() already run
under override_creds(root_cred), so the kernel-originated path is
unaffected.

This mirrors commit 3da1fdf ("smb: client: reject userspace
cifs.spnego descriptions"), which applied the same restriction to
cifs.spnego.

Fixes: 4d79dba ("cifs: Add idmap key and related data structures and functions (try #17 repost)")
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Cc: stable@vger.kernel.org
Assisted-by: CodeBuddy:Kimi-K3
Signed-off-by: Aohan Mei <henrymei@tencent.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
NeroReflex pushed a commit that referenced this pull request Sep 27, 2026
…_v6_do_rcv().

tcp_v6_do_rcv() no longer calls skb_clone_and_charge_r() for
TCP_LISTEN since commit 073d898 ("net: fix data-races around
sk->sk_forward_alloc").

However, there is still a small race window between tcp_v6_rcv()
and tcp_v6_do_rcv(), where concurrent close() changes TCP_LISTEN
to TCP_CLOSE, causing skb_clone_and_charge_r() to be called
locklessly and resulting in the splat below. [0]

Let's avoid calling skb_clone_and_charge_r() for TCP_CLOSE as well.

This is fine for non-listeners because tcp_rcv_state_process()
drops skb for TCP_CLOSE and opt_skb was freed immediately anyway.

[0]:
sk->sk_forward_alloc
WARNING: net/ipv4/af_inet.c:162 at inet_sock_destruct+0x64d/0x810 net/ipv4/af_inet.c:162, CPU#1: ksoftirqd/1/28
Modules linked in:
CPU: 1 UID: 0 PID: 28 Comm: ksoftirqd/1 Not tainted 7.2.0 #17 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
RIP: 0010:inet_sock_destruct+0x64d/0x810 net/ipv4/af_inet.c:162
Code: 3d 49 ff e9 06 fd ff ff e8 d0 5b 83 f8 90 0f 0b 90 e9 35 fe ff ff e8 c2 5b 83 f8 90 0f 0b 90 e9 c5 fe ff ff e8 b4 5b 83 f8 90 <0f> 0b 90 e9 04 ff ff ff e8 a6 5b 83 f8 90 0f 0b 90 e9 65 fe ff ff
RSP: 0018:ffffc90000677bb8 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff8880117bde80 RCX: ffffffff8957eb41
RDX: ffff88801dad5d00 RSI: ffffffff8957ec3c RDI: 0000000000000005
RBP: 00000000fffff000 R08: ffffffff8957eb41 R09: 00000000fffff000
R10: 0000000000000005 R11: 0000000000000000 R12: dffffc0000000000
R13: ffff8880117bdf10 R14: ffffffff81c08eb7 R15: 0000000000000003
FS:  0000000000000000(0000) GS:ffff8880d7ae5000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f93a1021138 CR3: 00000000207a9000 CR4: 0000000000350ef0
Call Trace:
 <TASK>
 __sk_destruct+0x82/0xae0 net/core/sock.c:2356
 rcu_do_batch kernel/rcu/tree.c:2645 [inline]
 rcu_core+0x59c/0x1100 kernel/rcu/tree.c:2897
 handle_softirqs+0x1e4/0x9b0 kernel/softirq.c:622
 run_ksoftirqd kernel/softirq.c:1076 [inline]
 run_ksoftirqd+0x38/0x60 kernel/softirq.c:1068
 smpboot_thread_fn+0x458/0xc80 kernel/smpboot.c:160
 kthread+0x396/0x4a0 kernel/kthread.c:436
 ret_from_fork+0x8e0/0xe40 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Fixes: e994b2f ("tcp: do not lock listener to process SYN packets")
Reported-by: Taras Madan <tarasmadan@google.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260914011420.115556-1-kuniyu@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
NeroReflex pushed a commit that referenced this pull request Sep 27, 2026
init_mount_tree() mounts the mutable rootfs on top of nullfs via
LOCK_MOUNT_EXACT(). That declares a pinned mountpoint with a cleanup
attribute in the scope of the whole function so the nullfs root inode
lock and namespace_sem are only dropped when init_mount_tree() returns.

This became a problem when the private nullfs instance for kthreads was
added. kern_mount() allocates a new superblock and alloc_super() takes
the new s_umount with SINGLE_DEPTH_NESTING and then shrinker_mutex via
shrinker_alloc(). Doing that with namespace_sem held teaches lockdep the
dependency

    namespace_sem -> s_umount/1 -> shrinker_mutex

With CONFIG_SHRINKER_DEBUG shrinker_debugfs_rename() takes the debugfs
directory inode lock under shrinker_mutex every time a block device is
mounted and lock_mount_exact() takes namespace_sem under the inode lock
of the mountpoint for every mount. So mounting anything on debugfs,
e.g. the tracefs automount on /sys/kernel/debug/tracing, closes the
cycle:

    WARNING: possible circular locking dependency detected
    7.3.0-rc3+ #17 Not tainted
    ------------------------------------------------------
    rasdaemon/4449 is trying to acquire lock:
    (namespace_sem){++++}-{4:4}, at: lock_mount_exact+0x4c/0x308

    but task is already holding lock:
    (&sb->s_type->i_mutex_key#17){++++}-{4:4}, at: lock_mount_exact+0x3c/0x308

    which lock already depends on the new lock.
    ...
    Chain exists of:
      namespace_sem --> shrinker_mutex --> &sb->s_type->i_mutex_key#17

This can't actually deadlock. init_mount_tree() runs single-threaded
during early boot before any other task exists and nothing allocates a
superblock under namespace_sem after that. But lockdep can't know that
and disables itself for the rest of the boot.

Move mounting the rootfs on top of nullfs into a helper so the locks
are dropped when it returns.

Fixes: 32750c7 ("fs: start all kthreads in nullfs")
Reported-by: Zenghui Yu <yuzenghui@huawei.com>
Closes: https://lore.kernel.org/15174353-3f4a-a1ca-5bd1-ea2a4c77828e@huawei.com
Link: https://patch.msgid.link/20260917-atemtechnik-bleichen-befassen-9a57db01baf0@brauner
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
@scardracs
scardracs force-pushed the leds/dynamic-lighting branch from 7a78e0e to f0df561 Compare September 28, 2026 06:06
Add a dedicated Dynamic Lighting LED class for devices that expose
multi-LED effects, palette programming, direct frame streaming or
lighting state persistence through sysfs.

Define LED_DYNAMIC_LIGHTING on struct led_classdev and an optional
led_dynamic back-pointer so the class can wrap a new LED or attach to
an already registered one without replacing brightness or
multi_intensity.

Drivers supply their own effect name table and optional ops. Sysfs
exposes only implemented attributes: effect and effect_index, optional
enabled and enabled_index, speed and speed_range, direction, palette,
power states, and binary direct/frame sinks. Lighting off is
enabled=false, not a dedicated off effect.

Registration validates exported capabilities and serializes writes
under led_access and the class-private lock so drivers can coexist
with LED triggers.

This provides a common kernel ABI for complex lighting devices without
requiring each driver to invent its own sysfs layout or rewrite an
existing LED registration.

Signed-off-by: Marco Scardovi <scardracs@disroot.org>
Document the Dynamic Lighting LED class ABI and user-facing sysfs
interface.

Describe the common attributes, visibility rules for optional
controls, and how a vendor driver can attach the class to an existing
LED. Effect names are defined by the driver and discovered through
effect_index. enabled/enabled_index turn lighting off without changing
the selected effect. Writing power_states replaces the active bitmask
(an empty list clears all enabled states).

Also add the new document to the LED documentation index and register
it in MAINTAINERS.

Signed-off-by: Marco Scardovi <scardracs@disroot.org>
USB ID 0x193b is shared by standalone Slash MCUs and AniMe Matrix
panels. Bind it only when the interface exposes Aura/Slash LED reports
(0x5d/0x5e) or a sibling HID LampArray lighting interface.

Detect LampArray by report IDs on usage page 0x59 and start that
interface without hidraw so lighting is not exported to userspace.
Firmware animations stay on the Aura 0x5d interface; Aura 0xBC remains
the fallback when LampArray is absent.

Signed-off-by: Marco Scardovi <scardracs@disroot.org>
Add Dynamic Lighting class support to hid-asus for Aura-capable ROG
keyboards and chassis lightbars.

Discover Aura layout, lightbar, and per-key/direct RGB from HID feature
reports rather than DMI board lists. Register aura:global,
aura:keyboard and aura:lightbar with aura_mode (auto/unified/split).
auto resolves to split so keyboard and lightbar stay independently
writable.

Publish the firmware effect list from the 0x9e capability mask
(static, breathe, rainbow_cycle, rainbow_wave, star, rain, highlight,
laser, ripple, pulse, comet, flash) and advertise direct when the
keyboard path supports packed RGB. Lighting off uses enabled rather
than a dedicated off effect.

Drive firmware animations with Aura 0xb3/0xb4/0xb5 and solid/direct
frames with Aura 0xBC. Map boot/awake/sleep/shutdown via power_states
to AURA_CMD_POWER (0xbd). Keep asus::kbd_backlight brightness
behaviour unchanged.

Signed-off-by: Marco Scardovi <scardracs@disroot.org>
On N-KEY devices where Aura 0xBC cannot drive the chassis lightbar
independently, use the sibling HID LampArray interface as the in-kernel
direct-RGB backend and drop the owner reference on unbind.

Linux Dynamic Lighting sysfs remains the userspace ABI. Fall back to
Aura 0xBC when LampArray is absent. Firmware animations stay on Aura
0xb3.

Signed-off-by: Marco Scardovi <scardracs@disroot.org>
Register Slash when feature report 0x5e is present, or on USB 0x193b
when Aura LED report 0x5d exists. Identify Slash from HID reports, never
from DMI board lists.

Expose asus::slash with mode, interval and brightness controls using
the Aura feature-report path already used for keyboard lighting.

Signed-off-by: Marco Scardovi <scardracs@disroot.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.

6 participants