mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
platform/x86: asus-wmi: name the TUF keyboard RGB state and speed codes
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> Link: https://patch.msgid.link/20261010101601.888709-4-bartualev@gmail.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
3d9a175707
commit
9d34750651
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user