From: Bartu Alev <bartualev@gmail.com>
To: platform-driver-x86@vger.kernel.org
Cc: ilpo.jarvinen@linux.intel.com, hansg@kernel.org, luke@ljones.dev,
denis.benato@linux.dev, benato.denis96@gmail.com,
corentin.chary@gmail.com, linux-api@vger.kernel.org,
linux-kernel@vger.kernel.org, Bartu Alev <bartualev@gmail.com>
Subject: [PATCH v3 3/5] platform/x86: asus-wmi: name the TUF keyboard RGB state and speed codes
Date: Sat, 10 Oct 2026 13:15:59 +0300 [thread overview]
Message-ID: <20261010101601.888709-4-bartualev@gmail.com> (raw)
In-Reply-To: <20261010101601.888709-1-bartualev@gmail.com>
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 <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bartu Alev <bartualev@gmail.com>
---
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 5cc71bfac841..c5c0fe92cea0 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1047,6 +1047,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)
@@ -1080,16 +1084,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,
@@ -1115,6 +1119,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)
@@ -1130,13 +1139,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,
--
2.56.0
next prev parent reply other threads:[~2026-10-10 10:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 10:15 [PATCH v3 0/5] platform/x86: asus-wmi: TUF keyboard shutdown naming and RGB readback Bartu Alev
2026-10-10 10:15 ` [PATCH v3 1/5] platform/x86: asus-wmi: rename TUF RGB state DEVID to _CMD Bartu Alev
2026-10-10 10:15 ` [PATCH v3 2/5] platform/x86: asus-wmi: fix TUF keyboard power state shutdown naming Bartu Alev
2026-10-10 10:15 ` Bartu Alev [this message]
2026-10-10 10:16 ` [PATCH v3 4/5] platform/x86: asus-wmi: add TUF keyboard RGB readback support Bartu Alev
2026-10-10 10:16 ` [PATCH v3 5/5] Documentation/ABI: asus-wmi: document TUF keyboard RGB attributes Bartu Alev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261010101601.888709-4-bartualev@gmail.com \
--to=bartualev@gmail.com \
--cc=benato.denis96@gmail.com \
--cc=corentin.chary@gmail.com \
--cc=denis.benato@linux.dev \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luke@ljones.dev \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®