[PATCH 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling

Denis Benato posted 2 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling
Posted by Denis Benato 1 month, 2 weeks ago
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.

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 0775fadedd10..4130dae37e15 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -4254,32 +4254,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;
+	int err = 0;
+	u32 ctrl_param = bd->props.brightness;
 
-	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
Re: [PATCH 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling
Posted by Ilpo Järvinen 1 month, 1 week ago
On Thu, 12 Feb 2026, Denis Benato wrote:

> 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.

Should this have a Fixes tag?

> 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 0775fadedd10..4130dae37e15 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -4254,32 +4254,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;
> +	int err = 0;
> +	u32 ctrl_param = bd->props.brightness;

Please retain reverse xmas-tree order.

>  
> -	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;
>  }
> 

-- 
 i.
Re: [PATCH 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling
Posted by Denis Benato 1 month, 1 week ago
On 2/23/26 15:38, Ilpo Järvinen wrote:
> On Thu, 12 Feb 2026, Denis Benato wrote:
>
>> 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.
> Should this have a Fixes tag?
>
Same for the other patch: I am not sure.

What I know for certain is that Luke had an asus DUO to test this patch with
and most certainly it was because someone contacted him about these bugs.

I split up commits found int the previous version of this patch:
https://lore.kernel.org/all/20250525204214.104030-1-luke@ljones.dev/

I changed nothing else beside removing a redundant variable assignment.
>> 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 0775fadedd10..4130dae37e15 100644
>> --- a/drivers/platform/x86/asus-wmi.c
>> +++ b/drivers/platform/x86/asus-wmi.c
>> @@ -4254,32 +4254,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;
>> +	int err = 0;
>> +	u32 ctrl_param = bd->props.brightness;
> Please retain reverse xmas-tree order.
>
>>  
>> -	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;
>>  }
>>
Re: [PATCH 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling
Posted by luke@ljones.dev 1 month, 1 week ago
> On 24 Feb 2026, at 07:15, Denis Benato <denis.benato@linux.dev> wrote:
> 
> 
> On 2/23/26 15:38, Ilpo Järvinen wrote:
>> On Thu, 12 Feb 2026, Denis Benato wrote:
>> 
>>> 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.
>> Should this have a Fixes tag?
>> 
> Same for the other patch: I am not sure.

It probably should be a fixes tag. Though there is no reference bug report or
other relating to it - only my discovery that the previously written code was in 
fact not right.

I had written the initial version that is in the kernel based on some limited testing
feedback from a user who was not able to clearly articulate what the issues
were and was happy with the final result.

I was able to get my hands on a Zenbook Duo and fully test this, which is how
I discovered the issues.

> What I know for certain is that Luke had an asus DUO to test this patch with
> and most certainly it was because someone contacted him about these bugs.
> 
> I split up commits found int the previous version of this patch:
> https://lore.kernel.org/all/20250525204214.104030-1-luke@ljones.dev/

Thanks for doing this. I just have not had any time to do it myself, very low on
the priority list but I would wager getting this all fixed correctly will enable both
Older and newer models to function how they should.

> I changed nothing else beside removing a redundant variable assignment.
>>> 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 0775fadedd10..4130dae37e15 100644
>>> --- a/drivers/platform/x86/asus-wmi.c
>>> +++ b/drivers/platform/x86/asus-wmi.c
>>> @@ -4254,32 +4254,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;
>>> + int err = 0;
>>> + u32 ctrl_param = bd->props.brightness;
>> Please retain reverse xmas-tree order.
>> 
>>> 
>>> - 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;
>>> }
>>> 
Re: [PATCH 1/2] platform/x86: asus-wmi: adjust screenpad power/brightness handling
Posted by Denis Benato 1 month ago
On 2/24/26 05:15, luke@ljones.dev wrote:
>> On 24 Feb 2026, at 07:15, Denis Benato <denis.benato@linux.dev> wrote:
>>
>>
>> On 2/23/26 15:38, Ilpo Järvinen wrote:
>>> On Thu, 12 Feb 2026, Denis Benato wrote:
>>>
>>>> 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.
>>> Should this have a Fixes tag?
>>>
>> Same for the other patch: I am not sure.
> It probably should be a fixes tag. Though there is no reference bug report or
> other relating to it - only my discovery that the previously written code was in 
> fact not right.
>
> I had written the initial version that is in the kernel based on some limited testing
> feedback from a user who was not able to clearly articulate what the issues
> were and was happy with the final result.
>
> I was able to get my hands on a Zenbook Duo and fully test this, which is how
> I discovered the issues.
Actually... my bad. I confused "Closes" with "Fixes". Ilpo meant to reference the original commit.

Sorry for the noise. I will dig those two tags.
>> What I know for certain is that Luke had an asus DUO to test this patch with
>> and most certainly it was because someone contacted him about these bugs.
>>
>> I split up commits found int the previous version of this patch:
>> https://lore.kernel.org/all/20250525204214.104030-1-luke@ljones.dev/
> Thanks for doing this. I just have not had any time to do it myself, very low on
> the priority list but I would wager getting this all fixed correctly will enable both
> Older and newer models to function how they should.
>
>> I changed nothing else beside removing a redundant variable assignment.
>>>> 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 0775fadedd10..4130dae37e15 100644
>>>> --- a/drivers/platform/x86/asus-wmi.c
>>>> +++ b/drivers/platform/x86/asus-wmi.c
>>>> @@ -4254,32 +4254,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;
>>>> + int err = 0;
>>>> + u32 ctrl_param = bd->props.brightness;
>>> Please retain reverse xmas-tree order.
>>>
>>>> - 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;
>>>> }
>>>>