On 2018 and newer models, setting reader mode does not change display Gamma, so treat reader mode as a LED, instead of a switch. Signed-off-by: Matan Ziv-Av <matan@xxxxxxxxxxx> --- drivers/platform/x86/lg-laptop.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c index ccdc93be2a9b..fd802e9f6556 100644 --- a/drivers/platform/x86/lg-laptop.c +++ b/drivers/platform/x86/lg-laptop.c @@ -73,6 +73,7 @@ static u32 inited; #define INIT_INPUT_ACPI 0x04 #define INIT_TPAD_LED 0x08 #define INIT_KBD_LED 0x10 +#define INIT_RDMODE_LED 0x20 #define INIT_SPARSE_KEYMAP 0x80 static int battery_limit_use_wmbb; @@ -529,9 +530,9 @@ static DEVICE_ATTR_RW(battery_care_limit); static struct attribute *dev_attributes[] = { &dev_attr_fan_mode.attr, &dev_attr_usb_charge.attr, - &dev_attr_reader_mode.attr, &dev_attr_fn_lock.attr, &dev_attr_battery_care_limit.attr, + &dev_attr_reader_mode.attr, // This is last, to be easily removed NULL }; @@ -555,6 +556,22 @@ static enum led_brightness tpad_led_get(struct led_classdev *cdev) static LED_DEVICE(tpad_led, 1); +static void reader_mode_led_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + reader_mode_store(NULL, NULL, brightness == LED_OFF ? "0" : "1", 1); +} + +static enum led_brightness reader_mode_led_get(struct led_classdev *cdev) +{ + char buf[BUFFER_SIZE]; + + reader_mode_show(NULL, NULL, buf); + return buf[0] != '0'; +} + +static LED_DEVICE(reader_mode_led, 1); + static void kbd_backlight_set(struct led_classdev *cdev, enum led_brightness brightness) { @@ -670,6 +687,9 @@ static int acpi_add(struct acpi_device *device) if (year >= 2019) battery_limit_use_wmbb = 1; + if (year >= 2018) + dev_attributes[4] = NULL; // Remove reader mode special file. + ret = sysfs_create_group(&pf_device->dev.kobj, &dev_attribute_group); if (ret) goto out_platform_device; @@ -680,6 +700,11 @@ static int acpi_add(struct acpi_device *device) if (!led_classdev_register(&pf_device->dev, &tpad_led)) inited |= INIT_TPAD_LED; + // For 2018 and 2019 models, reader mode only controls the LED + if (year >= 2018) + if (!led_classdev_register(&pf_device->dev, &reader_mode_led)) + inited |= INIT_RDMODE_LED; + wmi_input_setup(); return 0; @@ -700,6 +725,9 @@ static int acpi_remove(struct acpi_device *device) if (inited & INIT_TPAD_LED) led_classdev_unregister(&tpad_led); + if (inited & INIT_RDMODE_LED) + led_classdev_unregister(&reader_mode_led); + wmi_input_destroy(); platform_device_unregister(pf_device); pf_device = NULL; -- 2.21.0