[PATCH v3 0/6] asus-wmi: Add support for RGB keyboards

From: Luke D. Jones
Date: Mon Aug 08 2022 - 22:51:16 EST


This is a patch series to add RGB support for ASUS laptops.
The laptops with this RGB tend to be the TUF series of gamer laptops.

The first step is initial bringup of support using the multicolor LED API.

These types of keyboards implement a slightly more complex interface than
just RGB control however - they also have modes with can be static LED,
blinking, rainbow, color cycles, and more. They also have some custom
animations that can play depending on device state, such as suspended
playing a fancy colour cycle, or playing a "wave" animation.

Two of the patches add support for these features.

One patch adds documentation in:
Documentation/ABI/testing/sysfs-platform-asus-wmi
for some features that were added previously.

The final patch adds support for a particular MUX switch found only
on a few ROG laptops. This patch is added to this series due to some
conflicts in merge caused by the RGB patch series.

Some notes:

- this patch series obsoletes the previous RGB patches by myself

- it is not possible to add attribute groups to multicolor LED as
they get overwritten by `led_multicolor_groups` in
`led_classdev_multicolor_register_ext`.

- the methods for RGB control do not provide a way to fetch exisiting
state, so these methods are WO.

- There is an existing `asus::kbd_backlight`, this provides a 4-step
brightness to the RGB (off,low,med,high) individually to multicolor.
I was unsure of the effect of adding a similar path so have used the
`asus::multicolour::kbd_backlight` name to be clear about purpose.
If the `asus::kbd_backlight` is off, then no RGB is shown at all.

Changelog:
- V3: patch 2: asus-wmi RGB mode control
+ Split save, speed, mode in to separate nodes
+ Remove the _index node as it is not required with the above nodes
+ Cleanup of a one-line ternary
+ rename asus->keyboard_rgb_mode to keyboard_rgb_led to be clearer about purpose
+ Attach documentation to this patch
- V3: patch 3:
+ Use BIT() in place of previous hex for flags
+ Comment on purpose of 0xbd in state write
+ Attach documentation to this patch
- V3: patch 6: asus-wmi: hardware GPU MUX:
+ Include the correct patch for this feature
- V2: patch 1: asus-wmi - RGB
+ shorten a few lines
+ move unused keyboard_rgb_mode_available to next patch
+ remove tuf_rgb_brightness_get() is it was only returning current
led_classdev brightness, not reading it from device
+ remove unnecessary setting of brightness on multicolor init
+ set brightness_get to null for TUF RGB
+ actually use the member subled_info in keyboard_rgb_led struct and
not the leftover dynamic allocation (now removed)
- V2: patch 2: asus-wmi RGB mode control
+ tuf_rgb_brightness_set() was still using hardcoded save/mode/speed
from testing. This is now using the pre-set default.
+ asus_wmi_led_init(), set speed value to a correct value
+ keyboard_rgb_mode_store() return count, not 0
+ correctly unregister the mulicolor led on module exit
+ use switch/case in keyboard_rgb_mode_store() for speed
+ remove a single line bracket block
- V2: patch 3: asus-wmi RGB power control
+ Try to fix the indent warning from buildbot
+ Use correct date on added API docs
+ Add missing panel_od doc
+ correctly label attribute for keyboard_rgb_state
- V2: patch 4: documentation
+ Add commit message
- V2: patch 5: attributes using sysfs_emit:
+ Add commit message
- V2: patch 6: new patch, dgpu_only mode
+ A previous patch I submitted "0006-asus-wmi-Add-support-for-dGPU-only-mode.patch"
is now part of this series due to merge conflicts caused by the
previous 5 patches

Previous patches obsoleted:
https://lkml.org/lkml/2022/8/3/885
https://lkml.org/lkml/2022/8/3/886
https://lkml.org/lkml/2022/8/3/44
I may not have listed all.

Luke D. Jones (6):
asus-wmi: Implement TUF laptop keyboard RGB control
asus-wmi: Implement TUF laptop keyboard LED modes
asus-wmi: Implement TUF laptop keyboard power states
asus-wmi: Document previously added attributes
asus-wmi: Convert all attr-show to use sysfs_emit
asus-wmi: Support the hardware GPU MUX on some laptops

.../ABI/testing/sysfs-platform-asus-wmi | 83 ++++
drivers/platform/x86/asus-wmi.c | 368 +++++++++++++++++-
include/linux/platform_data/x86/asus-wmi.h | 8 +
3 files changed, 452 insertions(+), 7 deletions(-)

--
2.37.1