public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management
@ 2026-03-02 17:44 Denis Benato
  2026-03-02 17:44 ` [PATCH v3 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling Denis Benato
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Denis Benato @ 2026-03-02 17:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: platform-driver-x86, Hans de Goede, Ilpo Järvinen,
	Luke D . Jones, Mateusz Schyboll, Denis Benato, Denis Benato

Fix up some inconsistent behaviour involving the screenpad on some
ASUS laptops. This fixes:
- illogical screen off control (0/1 flipped depending on WMI state)
- bad brightness depending on the last screenpad power state
- incorrect brightness scaling

Changelog:
- v1
  - Initial submission
- v2
  - Split patch in two
  - Remove a redundant variable copy
- v3
  - Fix variable declaration (reverse x-mas tree)
  - Change commit message of 2/2 to reflect the actual change
  - Add "Fixes" tag to both patches 

Denis Benato (2):
  platform/x86: asus-wmi: adjust screenpad power/brightness handling
  platform/x86: asus-wmi: fix screenpad brightness range

 drivers/platform/x86/asus-wmi.c | 50 +++++++++++++--------------------
 1 file changed, 19 insertions(+), 31 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling
  2026-03-02 17:44 [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management Denis Benato
@ 2026-03-02 17:44 ` Denis Benato
  2026-03-02 17:44 ` [PATCH v3 2/2] platform/x86: asus-wmi: fix screenpad brightness range Denis Benato
  2026-03-24 17:31 ` [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Denis Benato @ 2026-03-02 17:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: platform-driver-x86, Hans de Goede, Ilpo Järvinen,
	Luke D . Jones, Mateusz Schyboll, Denis Benato, Denis Benato

Fix illogical screen off control by hardcoding 0 and 1 depending on the
requested brightness and also do not rely on the last screenpad
power state to issue screen brightness commands.

Fixes: 2c97d3e55b70 ("platform/x86: asus-wmi: add support for ASUS screenpad")
Signed-off-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Luke Jones <luke@ljones.dev>
---
 drivers/platform/x86/asus-wmi.c | 34 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 7c0915e097ba..8925a0ee26af 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -4419,32 +4419,24 @@ static int read_screenpad_brightness(struct backlight_device *bd)
 
 static int update_screenpad_bl_status(struct backlight_device *bd)
 {
-	struct asus_wmi *asus = bl_get_data(bd);
-	int power, err = 0;
-	u32 ctrl_param;
+	u32 ctrl_param = bd->props.brightness;
+	int err = 0;
 
-	power = read_screenpad_backlight_power(asus);
-	if (power < 0)
-		return power;
+	if (ctrl_param >= 0 && bd->props.power) {
+		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL);
+		if (err < 0)
+			return err;
 
-	if (bd->props.power != power) {
-		if (power != BACKLIGHT_POWER_ON) {
-			/* Only brightness > 0 can power it back on */
-			ctrl_param = asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN;
-			err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT,
-						    ctrl_param, NULL);
-		} else {
-			err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
-		}
-	} else if (power == BACKLIGHT_POWER_ON) {
-		/* Only set brightness if powered on or we get invalid/unsync state */
-		ctrl_param = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN;
 		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
+		if (err < 0)
+			return err;
 	}
 
-	/* Ensure brightness is stored to turn back on with */
-	if (err == 0)
-		asus->driver->screenpad_brightness = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN;
+	if (!bd->props.power) {
+		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
+		if (err < 0)
+			return err;
+	}
 
 	return err;
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] platform/x86: asus-wmi: fix screenpad brightness range
  2026-03-02 17:44 [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management Denis Benato
  2026-03-02 17:44 ` [PATCH v3 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling Denis Benato
@ 2026-03-02 17:44 ` Denis Benato
  2026-03-24 17:31 ` [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Denis Benato @ 2026-03-02 17:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: platform-driver-x86, Hans de Goede, Ilpo Järvinen,
	Luke D . Jones, Mateusz Schyboll, Denis Benato, Denis Benato

Fix screenpad brightness range being too limited without reason:
testing this patch on a Zenbook Duo showed the hardware minimum not being
too low, therefore allow the user to configure the entire range, and
expose to userspace the hardware brightness range and value.

Fixes: 2c97d3e55b70 ("platform/x86: asus-wmi: add support for ASUS screenpad")
Signed-off-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Luke Jones <luke@ljones.dev>
---
 drivers/platform/x86/asus-wmi.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 8925a0ee26af..17e2dcaf2b4c 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -125,7 +125,6 @@ module_param(fnlock_default, bool, 0444);
 #define NVIDIA_TEMP_MIN		75
 #define NVIDIA_TEMP_MAX		87
 
-#define ASUS_SCREENPAD_BRIGHT_MIN 20
 #define ASUS_SCREENPAD_BRIGHT_MAX 255
 #define ASUS_SCREENPAD_BRIGHT_DEFAULT 60
 
@@ -4408,13 +4407,13 @@ static int read_screenpad_brightness(struct backlight_device *bd)
 		return err;
 	/* The device brightness can only be read if powered, so return stored */
 	if (err == BACKLIGHT_POWER_OFF)
-		return asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN;
+		return bd->props.brightness;
 
 	err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &retval);
 	if (err < 0)
 		return err;
 
-	return (retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK) - ASUS_SCREENPAD_BRIGHT_MIN;
+	return (retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK);
 }
 
 static int update_screenpad_bl_status(struct backlight_device *bd)
@@ -4454,22 +4453,19 @@ static int asus_screenpad_init(struct asus_wmi *asus)
 	int err, power;
 	int brightness = 0;
 
-	power = read_screenpad_backlight_power(asus);
+	power = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_SCREENPAD_POWER);
 	if (power < 0)
 		return power;
 
-	if (power != BACKLIGHT_POWER_OFF) {
+	if (power) {
 		err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &brightness);
 		if (err < 0)
 			return err;
 	}
-	/* default to an acceptable min brightness on boot if too low */
-	if (brightness < ASUS_SCREENPAD_BRIGHT_MIN)
-		brightness = ASUS_SCREENPAD_BRIGHT_DEFAULT;
 
 	memset(&props, 0, sizeof(struct backlight_properties));
 	props.type = BACKLIGHT_RAW; /* ensure this bd is last to be picked */
-	props.max_brightness = ASUS_SCREENPAD_BRIGHT_MAX - ASUS_SCREENPAD_BRIGHT_MIN;
+	props.max_brightness = ASUS_SCREENPAD_BRIGHT_MAX;
 	bd = backlight_device_register("asus_screenpad",
 				       &asus->platform_device->dev, asus,
 				       &asus_screenpad_bl_ops, &props);
@@ -4480,7 +4476,7 @@ static int asus_screenpad_init(struct asus_wmi *asus)
 
 	asus->screenpad_backlight_device = bd;
 	asus->driver->screenpad_brightness = brightness;
-	bd->props.brightness = brightness - ASUS_SCREENPAD_BRIGHT_MIN;
+	bd->props.brightness = brightness;
 	bd->props.power = power;
 	backlight_update_status(bd);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management
  2026-03-02 17:44 [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management Denis Benato
  2026-03-02 17:44 ` [PATCH v3 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling Denis Benato
  2026-03-02 17:44 ` [PATCH v3 2/2] platform/x86: asus-wmi: fix screenpad brightness range Denis Benato
@ 2026-03-24 17:31 ` Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-03-24 17:31 UTC (permalink / raw)
  To: linux-kernel, Denis Benato
  Cc: platform-driver-x86, Hans de Goede, Luke D . Jones,
	Mateusz Schyboll, Denis Benato

On Mon, 02 Mar 2026 18:44:29 +0100, Denis Benato wrote:

> Fix up some inconsistent behaviour involving the screenpad on some
> ASUS laptops. This fixes:
> - illogical screen off control (0/1 flipped depending on WMI state)
> - bad brightness depending on the last screenpad power state
> - incorrect brightness scaling
> 
> Changelog:
> - v1
>   - Initial submission
> - v2
>   - Split patch in two
>   - Remove a redundant variable copy
> - v3
>   - Fix variable declaration (reverse x-mas tree)
>   - Change commit message of 2/2 to reflect the actual change
>   - Add "Fixes" tag to both patches
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling
      commit: 034f5efd362fb87a3970d61eaf982664f84e6c5a
[2/2] platform/x86: asus-wmi: fix screenpad brightness range
      commit: fab7c51693e95aa874d6d9db22bfae7bd0b23c66

--
 i.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-24 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02 17:44 [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management Denis Benato
2026-03-02 17:44 ` [PATCH v3 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling Denis Benato
2026-03-02 17:44 ` [PATCH v3 2/2] platform/x86: asus-wmi: fix screenpad brightness range Denis Benato
2026-03-24 17:31 ` [PATCH v3 0/2] platform/x86: asus-wmi: fix screenpad brightness/power management Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox