diff options
author | Matan Ziv-Av <matan@svgalib.org> | 2021-08-18 15:47:31 +0300 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2021-08-20 12:09:42 +0200 |
commit | ae26278829a80ad0e60ff004de71e9276cee5dc0 (patch) | |
tree | 07b85545a529aa2a259e4ca59f8174b862008db4 /drivers/platform/x86/lg-laptop.c | |
parent | 85973bf4c1b19cc1c6e801d492645bd63275573e (diff) | |
download | linux-ae26278829a80ad0e60ff004de71e9276cee5dc0.tar.bz2 |
platform/x86: lg-laptop: Use correct event for keyboard backlight FN-key
Use led_classdev_notify_brightness_hw_changed() instead of F16 key.
Signed-off-by: Matan Ziv-Av <matan@svgalib.org>
Link: https://lore.kernel.org/r/2196990f167efe6a42d51fb85f4db4cdf4d9e80e.1629291912.git.matan@svgalib.org
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform/x86/lg-laptop.c')
-rw-r--r-- | drivers/platform/x86/lg-laptop.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c index 12b497a11c6f..3e520d5bca07 100644 --- a/drivers/platform/x86/lg-laptop.c +++ b/drivers/platform/x86/lg-laptop.c @@ -17,11 +17,12 @@ #include <linux/platform_device.h> #include <linux/types.h> -#define LED_DEVICE(_name, max) struct led_classdev _name = { \ +#define LED_DEVICE(_name, max, flag) struct led_classdev _name = { \ .name = __stringify(_name), \ .max_brightness = max, \ .brightness_set = _name##_set, \ .brightness_get = _name##_get, \ + .flags = flag, \ } MODULE_AUTHOR("Matan Ziv-Av"); @@ -71,6 +72,8 @@ static u32 inited; #define INIT_SPARSE_KEYMAP 0x80 static int battery_limit_use_wmbb; +static struct led_classdev kbd_backlight; +static enum led_brightness get_kbd_backlight_level(void); static const struct key_entry wmi_keymap[] = { {KE_KEY, 0x70, {KEY_F15} }, /* LG control panel (F1) */ @@ -217,10 +220,16 @@ static void wmi_notify(u32 value, void *context) int eventcode = obj->integer.value; struct key_entry *key; - key = - sparse_keymap_entry_from_scancode(wmi_input_dev, eventcode); - if (key && key->type == KE_KEY) - sparse_keymap_report_entry(wmi_input_dev, key, 1, true); + if (eventcode == 0x10000000) { + led_classdev_notify_brightness_hw_changed( + &kbd_backlight, get_kbd_backlight_level()); + } else { + key = sparse_keymap_entry_from_scancode( + wmi_input_dev, eventcode); + if (key && key->type == KE_KEY) + sparse_keymap_report_entry(wmi_input_dev, + key, 1, true); + } } pr_debug("Type: %i Eventcode: 0x%llx\n", obj->type, @@ -548,7 +557,7 @@ static enum led_brightness tpad_led_get(struct led_classdev *cdev) return ggov(GOV_TLED) > 0 ? LED_ON : LED_OFF; } -static LED_DEVICE(tpad_led, 1); +static LED_DEVICE(tpad_led, 1, 0); static void kbd_backlight_set(struct led_classdev *cdev, enum led_brightness brightness) @@ -565,7 +574,7 @@ static void kbd_backlight_set(struct led_classdev *cdev, kfree(r); } -static enum led_brightness kbd_backlight_get(struct led_classdev *cdev) +static enum led_brightness get_kbd_backlight_level(void) { union acpi_object *r; int val; @@ -596,7 +605,12 @@ static enum led_brightness kbd_backlight_get(struct led_classdev *cdev) return val; } -static LED_DEVICE(kbd_backlight, 255); +static enum led_brightness kbd_backlight_get(struct led_classdev *cdev) +{ + return get_kbd_backlight_level(); +} + +static LED_DEVICE(kbd_backlight, 255, LED_BRIGHT_HW_CHANGED); static void wmi_input_destroy(void) { |