From: Farhan via B4 Relay <devnull+khan.10.0412.gmail.com@kernel.org>
To: "Armin Wolf" <W_Armin@gmx.de>, "Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, Farhan <khan.10.0412@gmail.com>
Subject: [PATCH 1/3] platform/x86: uniwill-laptop: Optionally apply keyboard backlight levels
Date: Sat, 05 Dec 2026 13:10:49 +0500 [thread overview]
Message-ID: <20261205-rp15-v1-1-ae8475100ed4@gmail.com> (raw)
In-Reply-To: <20261205-rp15-v1-0-ae8475100ed4@gmail.com>
From: Farhan <khan.10.0412@gmail.com>
Once the driver has enabled manual control, the EC on some devices keeps
reporting UNIWILL_OSD_KB_LED_LEVEL* events when the keyboard backlight
keys are pressed, but no longer changes the backlight itself. The driver
then only notifies userspace about a brightness change that never
happened, so the keys appear to do nothing: brightness_hw_changed shows
the new level while the brightness attribute keeps the old one.
Add a device descriptor flag for such devices which makes the driver
write the reported level to the EC before notifying userspace.
Assisted-by: LLM
Signed-off-by: Farhan <khan.10.0412@gmail.com>
---
drivers/platform/x86/uniwill/uniwill-acpi.c | 36 ++++++++++++++++++++---------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
index e2a6a704e..1f1d62c39 100644
--- a/drivers/platform/x86/uniwill/uniwill-acpi.c
+++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
@@ -408,6 +408,7 @@ struct uniwill_data {
struct mc_subled led_mc_subled_info[LED_CHANNELS];
bool kbd_led_single_color;
u8 kbd_led_max_brightness;
+ bool kbd_led_apply_level;
unsigned int last_kbd_status;
union {
struct {
@@ -434,6 +435,12 @@ struct uniwill_device_descriptor {
unsigned int features;
bool kbd_led_single_color;
u8 kbd_led_max_brightness;
+ /*
+ * Some ECs only report the new keyboard backlight level when the
+ * brightness keys are pressed while the driver controls the EC,
+ * but do not apply it themselves.
+ */
+ bool kbd_led_apply_level;
u8 lightbar_max_intensity;
/* Executed during driver probing */
int (*probe)(struct uniwill_data *data);
@@ -1670,6 +1677,17 @@ static int uniwill_led_init(struct uniwill_data *data)
&init_data);
}
+#define KBD_LED_MASK (KBD_BRIGHTNESS_MASK | KBD_APPLY | KBD_POWER_OFF)
+
+static int uniwill_kbd_led_write_brightness(struct uniwill_data *data, int brightness)
+{
+ /* KBD_POWER_OFF is always implicitly cleared */
+ unsigned int regval = FIELD_PREP(KBD_BRIGHTNESS_MASK, brightness) | KBD_APPLY;
+
+ /* We must ensure that the "apply" bit is always written */
+ return regmap_write_bits(data->regmap, EC_ADDR_KBD_STATUS, KBD_LED_MASK, regval);
+}
+
static int uniwill_notify_kbd_led(struct uniwill_data *data, int brightness)
{
struct led_classdev *led_cdev;
@@ -1708,6 +1726,12 @@ static int uniwill_notify_kbd_led(struct uniwill_data *data, int brightness)
guard(mutex)(&led_cdev->led_access);
+ if (data->kbd_led_apply_level) {
+ ret = uniwill_kbd_led_write_brightness(data, brightness);
+ if (ret < 0)
+ return ret;
+ }
+
/* Sync the LED brightness with the actual hardware state */
ret = led_update_brightness(led_cdev);
if (ret < 0)
@@ -1718,17 +1742,6 @@ static int uniwill_notify_kbd_led(struct uniwill_data *data, int brightness)
return 0;
}
-#define KBD_LED_MASK (KBD_BRIGHTNESS_MASK | KBD_APPLY | KBD_POWER_OFF)
-
-static int uniwill_kbd_led_write_brightness(struct uniwill_data *data, int brightness)
-{
- /* KBD_POWER_OFF is always implicitly cleared */
- unsigned int regval = FIELD_PREP(KBD_BRIGHTNESS_MASK, brightness) | KBD_APPLY;
-
- /* We must ensure that the "apply" bit is always written */
- return regmap_write_bits(data->regmap, EC_ADDR_KBD_STATUS, KBD_LED_MASK, regval);
-}
-
static int uniwill_kbd_led_read_brightness(struct uniwill_data *data)
{
unsigned int regval;
@@ -2442,6 +2455,7 @@ static int uniwill_probe(struct platform_device *pdev)
data->features = device_descriptor.features;
data->kbd_led_single_color = device_descriptor.kbd_led_single_color;
data->kbd_led_max_brightness = device_descriptor.kbd_led_max_brightness;
+ data->kbd_led_apply_level = device_descriptor.kbd_led_apply_level;
data->lightbar_max_intensity = device_descriptor.lightbar_max_intensity;
/*
--
2.53.0
next prev parent reply other threads:[~2026-12-05 8:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 8:10 [PATCH 0/3] platform/x86: uniwill-laptop: Support the Eluktronics RP-15 Farhan via B4 Relay
2026-12-05 8:10 ` Farhan via B4 Relay [this message]
2026-12-05 8:10 ` [PATCH 2/3] platform/x86: uniwill-laptop: Add support for " Farhan via B4 Relay
2026-12-05 8:10 ` [PATCH 3/3] platform/x86: uniwill-laptop: Notify userspace about Fn and super key lock changes Farhan via B4 Relay
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=20261205-rp15-v1-1-ae8475100ed4@gmail.com \
--to=devnull+khan.10.0412.gmail.com@kernel.org \
--cc=W_Armin@gmx.de \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=khan.10.0412@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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®