Skip to content

Commit

Permalink
platform/x86: asus-wmi: Only notify kbd LED hw_change by fn-key pressed
Browse files Browse the repository at this point in the history
Since commit dbb3d78 ("platform/x86: asus-wmi: Call led hw_changed
API on kbd brightness change"), asus-wmi directly changes the keyboard
LED brightness when the keyboard brightness keys are pressed,
raising the appropriate notification.

However, this notification was unintentionally also being raised during
boot and resume from suspend. This was resulting in userspace showing
the keyboard LED OSD on resume for no good reason.

Move the keyboard LED brightness changed notification
from kbd_led_update to the new kbd_led_set_by_kbd function which is only
called from the keyboard brightness function keys codepath.

Signed-off-by: Jian-Hong Pan <jian-hong@endlessm.com>
Signed-off-by: Daniel Drake <drake@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  • Loading branch information
Jian-Hong Pan authored and Andy Shevchenko committed Oct 31, 2018
1 parent 69372c1 commit 29f6eb5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions drivers/platform/x86/asus-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ static void kbd_led_update(struct asus_wmi *asus)
ctrl_param = 0x80 | (asus->kbd_led_wk & 0x7F);

asus_wmi_set_devstate(ASUS_WMI_DEVID_KBD_BACKLIGHT, ctrl_param, NULL);
led_classdev_notify_brightness_hw_changed(&asus->kbd_led, asus->kbd_led_wk);
}

static int kbd_led_read(struct asus_wmi *asus, int *level, int *env)
Expand Down Expand Up @@ -521,6 +520,14 @@ static void kbd_led_set(struct led_classdev *led_cdev,
do_kbd_led_set(led_cdev, value);
}

static void kbd_led_set_by_kbd(struct asus_wmi *asus, enum led_brightness value)
{
struct led_classdev *led_cdev = &asus->kbd_led;

do_kbd_led_set(led_cdev, value);
led_classdev_notify_brightness_hw_changed(led_cdev, asus->kbd_led_wk);
}

static enum led_brightness kbd_led_get(struct led_classdev *led_cdev)
{
struct asus_wmi *asus;
Expand Down Expand Up @@ -1759,18 +1766,18 @@ static void asus_wmi_notify(u32 value, void *context)
}

if (code == NOTIFY_KBD_BRTUP) {
do_kbd_led_set(&asus->kbd_led, asus->kbd_led_wk + 1);
kbd_led_set_by_kbd(asus, asus->kbd_led_wk + 1);
goto exit;
}
if (code == NOTIFY_KBD_BRTDWN) {
do_kbd_led_set(&asus->kbd_led, asus->kbd_led_wk - 1);
kbd_led_set_by_kbd(asus, asus->kbd_led_wk - 1);
goto exit;
}
if (code == NOTIFY_KBD_BRTTOGGLE) {
if (asus->kbd_led_wk == asus->kbd_led.max_brightness)
do_kbd_led_set(&asus->kbd_led, 0);
kbd_led_set_by_kbd(asus, 0);
else
do_kbd_led_set(&asus->kbd_led, asus->kbd_led_wk + 1);
kbd_led_set_by_kbd(asus, asus->kbd_led_wk + 1);
goto exit;
}

Expand Down

0 comments on commit 29f6eb5

Please sign in to comment.