mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 13:06:59 +02:00
platform/x86: asus-wmi: adjust screenpad power/brightness handling
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: 2c97d3e55b ("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>
This commit is contained in:
parent
186bf90316
commit
130d29c562
|
|
@ -4422,32 +4422,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 (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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user