Skip to content

fix(rog-aura): honour shutdown state for TUF keyboard power states - #381

Open
voidvore wants to merge 2 commits into
OpenGamingCollective:mainfrom
voidvore:fix/tuf-kbd-rgb-shutdown-state
Open

voidvore wants to merge 2 commits into
OpenGamingCollective:mainfrom
voidvore:fix/tuf-kbd-rgb-shutdown-state

Conversation

@voidvore

@voidvore voidvore commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Description

AuraPowerState.shutdown is silently dropped for TUF laptops: tuf_to_bytes() hardcodes the fifth kbd_rgb_state byte to 1, so asusd always writes the shutdown LED state as enabled and whatever the user configured is ignored. Since that write carries the save bit, the forced value is stored in non-volatile EC state on every daemon start and the configuration can never win.

The fifth byte of the TUF interface gates the keyboard LED during the S5 / power-off sequence. Measured on a TUF Gaming A15 FA507NV (BIOS 318, writing to /sys/class/leds/asus::kbd_backlight/kbd_rgb_state):

  • 1 0 1 0 1 -> arg0 0x008804BD for DEVS(0x00100057): the EC lights the keyboard with its power-on default colour (white) while power drops.
  • 1 0 1 0 0 -> arg0 0x000804BD: the LED stays dark through the power-off sequence.

Only bit 7 of the state flags differs between the two writes. The same bit position is named shutdown in AuraPowerState::new_to_byte() for the 2021+ keyboards, rog-control-center already exposes the matching toggle, and asusctl aura power-tuf already sends shutdown: false on the D-Bus call - only the TUF byte packing threw the value away. Pass the configured value through instead of forcing it on.

Machines that never touched the setting keep the previous behaviour: AuraPowerState::default() has shutdown enabled.

Tested Hardware & Environment

  • ASUS Laptop Model: ASUS TUF Gaming A15 FA507NV
  • Linux Distribution: CachyOS
  • Kernel Version: 7.2.4-3-cachyos

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)

Additional hardware checks performed on the FA507NV:

  • Unit test check_tuf_control_bytes covers both shutdown: false -> [1, 0, 1, 0, 0] and shutdown: true -> [1, 0, 1, 0, 1] for LaptopKeyboardTuf.
  • A/B on the live EC via the sysfs attribute: with the shutdown bit clear the keyboard stays dark through poweroff; with it set the EC runs its white power-off animation. AuraPowerState::default() keeps the bit set, so the new code path is byte-identical for anyone who did not change the setting.

The TUF `kbd_rgb_state` interface takes five values: cmd, boot, awake,
sleep and the shutdown state occupying the fifth slot. That fifth byte
was hardcoded to 1 and the configured value was dropped, so every write
re-enabled the shutdown LED state on the EC - and because the write
carries the save bit, the user's configuration was overridden in
non-volatile EC state on every boot.

Measured on a TUF Gaming A15 FA507NV (BIOS 318): writing `1 0 1 0 0`
vs `1 0 1 0 1` differs only in bit 7 of the state flags (arg0
0x000804BD vs 0x008804BD for DEVS(0x00100057)). With the bit set, the
EC lights the keyboard with its power-on default colour (white) while
the S5 power-off sequence runs; with it clear the LED stays dark. The
same bit position is named `shutdown` by `new_to_byte()` for the 2021+
keyboards, and rog-control-center already exposes the matching toggle
for TUF laptops, so pass the configured value through instead of
forcing it on.

Machines that never touched the setting are unaffected:
`AuraPowerState::default()` keeps `shutdown` enabled.
`AuraPowerState.shutdown` is honoured by the TUF interface now, and the
TUF state set consists of four states, not three.
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 55c9d916-69a4-4e88-aebd-79f88910271e

📥 Commits

Reviewing files that changed from the base of the PR and between 05d8370 and deaf853.

📒 Files selected for processing (1)
  • rog-aura/src/keyboard/power.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: cargo audit (Debian 13 / rustc 1.93)
  • GitHub Check: cargo build --workspace (Ubuntu / rustc 1.93)
🔇 Additional comments (1)
rog-aura/src/keyboard/power.rs (1)

17-17: LGTM!

Also applies to: 25-25, 54-56, 693-735


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • TUF keyboard power controls now correctly honor the configured shutdown setting.
    • Power control behavior is validated for both shutdown-enabled and shutdown-disabled states.

Walkthrough

The TUF power encoding now sends the configured shutdown bit instead of always sending 1. Documentation describes four TUF states, and tests cover shutdown enabled and disabled.

Changes

TUF shutdown encoding

Layer / File(s) Summary
Encode and validate TUF shutdown state
rog-aura/src/keyboard/power.rs
The TUF encoder uses self.shutdown. Documentation describes four TUF states. Tests verify both shutdown byte values.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested labels: rog-aura, fix

Suggested reviewers: luytan

Merge Risk: ⚪ Minimal · up to deaf8

The PR correctly makes TUF shutdown behavior configurable without changing the existing default, so no current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: honoring the TUF keyboard shutdown state.
Description check ✅ Passed The description explains the problem, implementation, expected behavior, tested hardware, environment, verification steps, and unit-test coverage. The issue reference remains a placeholder, but the de…

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.

@coderabbitai coderabbitai Bot added fix Fix a bug or an issue rog-aura Keyboard / Aura RGB labels Sep 15, 2026
@Ghoul4500

Copy link
Copy Markdown
Member

This may need some changes to the asusctl cli as well? Can you pls check that. In the meantime I'll see if I can get a friend with an older TUF to test this patch. You can write here any specific paths you want anyone seeing this to test

@voidvore

voidvore commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

This may need some changes to the asusctl cli as well? Can you pls check that. In the meantime I'll see if I can get a friend with an older TUF to test this patch. You can write here any specific paths you want anyone seeing this to test

echo "1 0 1 0 0" | sudo tee /sys/class/leds/asus::kbd_backlight/kbd_rgb_state

Before entering this laptop, when you shut down the computer: if the LED is off, it turns on and a white LED lights up. If the LED is on but in a color other than white (e.g. red), it slowly fades out and then turns on (this doesn't happen on Windows). When you turn the laptop on, it's as if the keyboard backlight calibrates itself, lighting up all colors in 3 different intensity ranges. After the calibration finishes, it switches to the settings you previously configured. Although I couldn't figure out the exact cause of the issue, setting this to 0 (the 5th flag) fixes the problem. The same parameter exists for ROG devices (a bit below the part I changed) but Luke didn't add it for TUFs (he had said by guessing that it should be keyboard in a commit message, so I THINK it was added based on a guess)

sorry for the PR description, I was in a hurry, it was entirely written by an llm

@voidvore

Copy link
Copy Markdown
Contributor Author

To test this, you'll need to rebuild asusd and use the patched one instead of the original asusd. So far I've only tested it with simple commands. Since it's hardcoded as 1, even if you toggle the shutdown parameter from the cli or rogcc, it doesn't take effect.

@Rashnan

Rashnan commented Sep 16, 2026

Copy link
Copy Markdown

TLDR: works

Machine info:
ASUS Laptop Model: ASUS TUF Gaming A15 FA506QM
Linux Distribution: CachyOS
Kernel Version: 7.2.4-3-cachyos

Asusctl 6.4:
Used static pattern red.
Shutdown -> replicated the issue. On power off, at end of sequence getting white keyboard light. On power on, getting white -> rainbow -> red

Asusctl 6.5 master:
Same as 6.4. Used rog-control-center to toggle keyboard additional settings boot and shutdown. specifically turned it on and then off. Left it at off, but still got same as 6.4

Asus 6.5 with pr:
Same procedure as 6.5. keyboard turns off properly during shutdown and boot and no white / rainbow light.

Other issue but likely unrelated:
On login screen powers doesn't power on and needs keyboard spam. Unrelated to this though likely related to cachyos update

@voidvore

voidvore commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Other issue but likely unrelated: On login screen powers doesn't power on and needs keyboard spam. Unrelated to this though likely related to cachyos update

@Rashnan I think I'm having the same issue. Did this happen when you first turn on the laptop, or after waking from sleep (opening the laptop lid)? To avoid cluttering the PR, could I ask you to write in the Discord server or open an issue on GitHub for this?

@Rashnan

Rashnan commented Sep 16, 2026

Copy link
Copy Markdown

I think I'm having the same issue. Did this happen when you first turn on the laptop, or after waking from sleep (opening the laptop lid)? To avoid cluttering the PR, could I ask you to write in the Discord server or open an issue on GitHub for this?

When first turn on (after opening after every shutdown) and not on wake from sleep.
Alright I have written in the discord server here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fix a bug or an issue rog-aura Keyboard / Aura RGB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants