Skip to content

Commit 38a9aa1

Browse files
NeroReflexgregkh
authored andcommitted
platform/x86: asus-wmi: adjust screenpad power/brightness handling
[ Upstream commit 130d29c ] 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: 2c97d3e ("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> Link: https://patch.msgid.link/20260302174431.349816-2-denis.benato@linux.dev Link: https://patch.msgid.link/20260326231154.856729-2-ethantidmore06@gmail.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4584229 commit 38a9aa1

1 file changed

Lines changed: 13 additions & 21 deletions

File tree

drivers/platform/x86/asus-wmi.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4154,32 +4154,24 @@ static int read_screenpad_brightness(struct backlight_device *bd)
41544154

41554155
static int update_screenpad_bl_status(struct backlight_device *bd)
41564156
{
4157-
struct asus_wmi *asus = bl_get_data(bd);
4158-
int power, err = 0;
4159-
u32 ctrl_param;
4157+
u32 ctrl_param = bd->props.brightness;
4158+
int err = 0;
41604159

4161-
power = read_screenpad_backlight_power(asus);
4162-
if (power < 0)
4163-
return power;
4160+
if (bd->props.power) {
4161+
err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL);
4162+
if (err < 0)
4163+
return err;
41644164

4165-
if (bd->props.power != power) {
4166-
if (power != BACKLIGHT_POWER_ON) {
4167-
/* Only brightness > 0 can power it back on */
4168-
ctrl_param = asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN;
4169-
err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT,
4170-
ctrl_param, NULL);
4171-
} else {
4172-
err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
4173-
}
4174-
} else if (power == BACKLIGHT_POWER_ON) {
4175-
/* Only set brightness if powered on or we get invalid/unsync state */
4176-
ctrl_param = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN;
41774165
err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
4166+
if (err < 0)
4167+
return err;
41784168
}
41794169

4180-
/* Ensure brightness is stored to turn back on with */
4181-
if (err == 0)
4182-
asus->driver->screenpad_brightness = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN;
4170+
if (!bd->props.power) {
4171+
err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
4172+
if (err < 0)
4173+
return err;
4174+
}
41834175

41844176
return err;
41854177
}

0 commit comments

Comments
 (0)