Unverified Commit 8d95d1f4 authored by Denis Benato's avatar Denis Benato Committed by Ilpo Järvinen
Browse files

platform/x86: asus-wmi: fix screenpad brightness range



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: 2c97d3e5 ("platform/x86: asus-wmi: add support for ASUS screenpad")
Signed-off-by: default avatarDenis Benato <denis.benato@linux.dev>
Signed-off-by: default avatarLuke Jones <luke@ljones.dev>
Link: https://patch.msgid.link/20260302174431.349816-3-denis.benato@linux.dev


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 130d29c5
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -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

@@ -4411,13 +4410,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)
@@ -4457,22 +4456,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);
@@ -4483,7 +4479,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);