diff mbox series

[2/2] HID: wacom: Status luminance properties should set brightness of all LEDs

Message ID 20241210210059.87780-2-jason.gerecke@wacom.com
State New
Headers show
Series [1/2] HID: wacom: Improve behavior of non-standard LED brightness values | expand

Commit Message

Gerecke, Jason Dec. 10, 2024, 9 p.m. UTC
From: Jason Gerecke <jason.gerecke@wacom.com>

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 <jason.gerecke@wacom.com>
---
 drivers/hid/wacom_sys.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 5689bb6fcb264..8125383932ec7 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1084,6 +1084,17 @@  static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
 	mutex_lock(&wacom->lock);
 
 	*dest = value & 0x7f;
+	for (unsigned int i = 0; i < wacom->led.count; i++) {
+		struct wacom_group_leds *group = &wacom->led.groups[i];
+
+		for (unsigned int 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);