From 9d3475065167197742b0882aff21cf8e78393277 Mon Sep 17 00:00:00 2001 From: Bartu Alev Date: Sat, 10 Oct 2026 13:15:59 +0300 Subject: [PATCH] platform/x86: asus-wmi: name the TUF keyboard RGB state and speed codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TUF keyboard RGB attributes encode four power-state flags and three animation speeds as bare BIT() and hex literals inside their store handlers. The speed codes in particular read as arbitrary hex until one knows they are EC firmware conventions: 0xe1, 0xeb and 0xf5 select animation step thresholds of 30, 20 and 10 ticks per phase, which the EC derives from the stored byte through a lookup table. Give the seven values names and use them in kbd_rgb_mode_store() and kbd_rgb_state_store(), so the handlers state what they mean without a decoding comment. No behavior change. Suggested-by: Ilpo Järvinen Signed-off-by: Bartu Alev Link: https://patch.msgid.link/20261010101601.888709-4-bartualev@gmail.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen --- drivers/platform/x86/asus-wmi.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 3348ce162ad3..b33ebdb21aa2 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1058,6 +1058,10 @@ static DEVICE_ATTR_RW(gpu_mux_mode); #endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ /* TUF Laptop Keyboard RGB Modes **********************************************/ + +#define TUF_KBD_RGB_SPEED_SLOW 0xe1 +#define TUF_KBD_RGB_SPEED_NORMAL 0xeb +#define TUF_KBD_RGB_SPEED_FAST 0xf5 static ssize_t kbd_rgb_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1091,16 +1095,16 @@ static ssize_t kbd_rgb_mode_store(struct device *dev, switch (speed) { case 0: - speed = 0xe1; + speed = TUF_KBD_RGB_SPEED_SLOW; break; case 1: - speed = 0xeb; + speed = TUF_KBD_RGB_SPEED_NORMAL; break; case 2: - speed = 0xf5; + speed = TUF_KBD_RGB_SPEED_FAST; break; default: - speed = 0xeb; + speed = TUF_KBD_RGB_SPEED_NORMAL; } err = asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS, asus->kbd_rgb_dev, @@ -1126,6 +1130,11 @@ static const struct attribute_group kbd_rgb_mode_group = { }; /* TUF Laptop Keyboard RGB State **********************************************/ + +#define TUF_KBD_RGB_STATE_BOOT BIT(1) +#define TUF_KBD_RGB_STATE_AWAKE BIT(3) +#define TUF_KBD_RGB_STATE_SLEEP BIT(5) +#define TUF_KBD_RGB_STATE_SHUTDOWN BIT(7) static ssize_t kbd_rgb_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1141,13 +1150,13 @@ static ssize_t kbd_rgb_state_store(struct device *dev, flags = 0; if (boot) - flags |= BIT(1); + flags |= TUF_KBD_RGB_STATE_BOOT; if (awake) - flags |= BIT(3); + flags |= TUF_KBD_RGB_STATE_AWAKE; if (sleep) - flags |= BIT(5); + flags |= TUF_KBD_RGB_STATE_SLEEP; if (shutdown) - flags |= BIT(7); + flags |= TUF_KBD_RGB_STATE_SHUTDOWN; /* 0xbd is the required default arg0 for the method. Nothing happens otherwise */ err = asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS,