From f444c4816c9a4f9ebc6a101af33cbda5b9904ce7 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Tue, 10 Dec 2024 13:00:59 -0800 Subject: [PATCH] HID: wacom: Status luminance properties should set brightness of all LEDs The wacom driver has (deprecated) sysfs properties `status0_luminance` and `status1_luminance` that are used to control the low- and high- level brightness values (llv and hlv) of the status LEDs. These two properties had an effect on /all/ of the status LEDs. After our driver switched to exposing each status LED individually through the LED class, this behavior changed. These controls started having only a temporary effect on the currently-lit LED. If a trigger changed the current LED, the driver would switch the brightness back to the llv/hlv values stored per-LED. (The code's current behavior of updating the "global" e.g. `wacom->led.llv` values has essentially no effect because those values are only used at initialization time). This commit restores the original behavior by ensuring these properties update the per-LED brightness for all LEDs. Signed-off-by: Jason Gerecke Signed-off-by: Jiri Kosina [jason.gerecke@wacom.com: Imported into input-wacom (d2c342334141)] Signed-off-by: Jason Gerecke --- 4.18/wacom_sys.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/4.18/wacom_sys.c b/4.18/wacom_sys.c index 4880c1b0..9bb66214 100644 --- a/4.18/wacom_sys.c +++ b/4.18/wacom_sys.c @@ -1097,6 +1097,7 @@ static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, const char *buf, size_t count) { unsigned int value; + unsigned int i; int err; err = kstrtouint(buf, 10, &value); @@ -1106,6 +1107,18 @@ static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, mutex_lock(&wacom->lock); *dest = value & 0x7f; + for (i = 0; i < wacom->led.count; i++) { + struct wacom_group_leds *group = &wacom->led.groups[i]; + unsigned int j; + + for (j = 0; j < group->count; j++) { + if (dest == &wacom->led.llv) + group->leds[j].llv = *dest; + else if (dest == &wacom->led.hlv) + group->leds[j].hlv = *dest; + } + } + err = wacom_led_control(wacom); mutex_unlock(&wacom->lock);