diff --git a/4.18/wacom_sys.c b/4.18/wacom_sys.c index 0c26dc15..b41e6c4c 100644 --- a/4.18/wacom_sys.c +++ b/4.18/wacom_sys.c @@ -1392,17 +1392,6 @@ static int wacom_led_register_one(struct device *dev, struct wacom *wacom, if (!name) return -ENOMEM; - if (!read_only) { - led->trigger.name = name; - error = devm_led_trigger_register(dev, &led->trigger); - if (error) { - hid_err(wacom->hdev, - "failed to register LED trigger %s: %d\n", - led->cdev.name, error); - return error; - } - } - led->group = group; led->id = id; led->wacom = wacom; @@ -1419,6 +1408,21 @@ static int wacom_led_register_one(struct device *dev, struct wacom *wacom, led->cdev.brightness_set = wacom_led_readonly_brightness_set; } + if (!read_only) { + led->trigger.name = name; +#ifdef WACOM_TRIGGER_BRIGHTNESS + if (id == wacom->led.groups[group].select) + led->trigger.brightness = wacom_leds_brightness_get(led); +#endif + error = devm_led_trigger_register(dev, &led->trigger); + if (error) { + hid_err(wacom->hdev, + "failed to register LED trigger %s: %d\n", + led->cdev.name, error); + return error; + } + } + error = devm_led_classdev_register(dev, &led->cdev); if (error) { hid_err(wacom->hdev, diff --git a/configure.ac b/configure.ac index e4c74ba3..5aacf265 100644 --- a/configure.ac +++ b/configure.ac @@ -256,6 +256,22 @@ int test(struct hid_usage *usage) { return usage->resolution_multiplier; } AC_MSG_RESULT([no]) ]) +dnl Check if LED triggers define brightness. This should be in Linux +dnl 6.10 and later. +AC_MSG_CHECKING(trigger brightness) +WACOM_LINUX_TRY_COMPILE([ +#include +int test(struct led_trigger *trigger) { return trigger->brightness; } +],[ +],[ + HAVE_TRIGGER_BRIGHTNESS=yes + AC_MSG_RESULT([yes]) + AC_DEFINE([WACOM_TRIGGER_BRIGHTNESS], [], [kernel defines trigger brightness from v6.10+]) +],[ + HAVE_TRIGGER_BRIGHTNESS=no + AC_MSG_RESULT([no]) +]) + dnl Check which version of the driver we should compile