Skip to content

Commit 8d4335d

Browse files
NeroReflexgregkh
authored andcommitted
platform/x86: asus-wmi: fix screenpad brightness range
[ Upstream commit 8d95d1f ] 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: 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-3-denis.benato@linux.dev 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 6a773c5 commit 8d4335d

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

drivers/platform/x86/asus-wmi.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ module_param(fnlock_default, bool, 0444);
125125
#define NVIDIA_TEMP_MIN 75
126126
#define NVIDIA_TEMP_MAX 87
127127

128-
#define ASUS_SCREENPAD_BRIGHT_MIN 20
129128
#define ASUS_SCREENPAD_BRIGHT_MAX 255
130129
#define ASUS_SCREENPAD_BRIGHT_DEFAULT 60
131130

@@ -4408,13 +4407,13 @@ static int read_screenpad_brightness(struct backlight_device *bd)
44084407
return err;
44094408
/* The device brightness can only be read if powered, so return stored */
44104409
if (err == BACKLIGHT_POWER_OFF)
4411-
return asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN;
4410+
return bd->props.brightness;
44124411

44134412
err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &retval);
44144413
if (err < 0)
44154414
return err;
44164415

4417-
return (retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK) - ASUS_SCREENPAD_BRIGHT_MIN;
4416+
return retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK;
44184417
}
44194418

44204419
static int update_screenpad_bl_status(struct backlight_device *bd)
@@ -4454,22 +4453,19 @@ static int asus_screenpad_init(struct asus_wmi *asus)
44544453
int err, power;
44554454
int brightness = 0;
44564455

4457-
power = read_screenpad_backlight_power(asus);
4456+
power = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_SCREENPAD_POWER);
44584457
if (power < 0)
44594458
return power;
44604459

4461-
if (power != BACKLIGHT_POWER_OFF) {
4460+
if (power) {
44624461
err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &brightness);
44634462
if (err < 0)
44644463
return err;
44654464
}
4466-
/* default to an acceptable min brightness on boot if too low */
4467-
if (brightness < ASUS_SCREENPAD_BRIGHT_MIN)
4468-
brightness = ASUS_SCREENPAD_BRIGHT_DEFAULT;
44694465

44704466
memset(&props, 0, sizeof(struct backlight_properties));
44714467
props.type = BACKLIGHT_RAW; /* ensure this bd is last to be picked */
4472-
props.max_brightness = ASUS_SCREENPAD_BRIGHT_MAX - ASUS_SCREENPAD_BRIGHT_MIN;
4468+
props.max_brightness = ASUS_SCREENPAD_BRIGHT_MAX;
44734469
bd = backlight_device_register("asus_screenpad",
44744470
&asus->platform_device->dev, asus,
44754471
&asus_screenpad_bl_ops, &props);
@@ -4480,7 +4476,7 @@ static int asus_screenpad_init(struct asus_wmi *asus)
44804476

44814477
asus->screenpad_backlight_device = bd;
44824478
asus->driver->screenpad_brightness = brightness;
4483-
bd->props.brightness = brightness - ASUS_SCREENPAD_BRIGHT_MIN;
4479+
bd->props.brightness = brightness;
44844480
bd->props.power = power;
44854481
backlight_update_status(bd);
44864482

0 commit comments

Comments
 (0)