From 3af08adf7900b06907a95227f8b3ca6b072d2722 Mon Sep 17 00:00:00 2001 From: Ash Hughes Date: Fri, 14 Feb 2020 19:01:24 +0000 Subject: [PATCH 1/2] Restore state on resume. --- src/tuxedo_keyboard.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index 2b3aec5..77b57b3 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -621,6 +621,16 @@ static int tuxedo_wmi_resume(struct platform_device *dev) { tuxedo_evaluate_wmi_method(WMI_SUBMETHOD_ID_GET_AP, 0, NULL); + set_color(REGION_LEFT, kbd_led_state.color.left); + set_color(REGION_CENTER, kbd_led_state.color.center); + set_color(REGION_RIGHT, kbd_led_state.color.right); + if (kbd_led_state.has_extra) + set_color(REGION_EXTRA, kbd_led_state.color.extra); + + set_blinking_pattern(kbd_led_state.blinking_pattern); + set_brightness(kbd_led_state.brightness); + set_enabled(kbd_led_state.enabled); + return 0; } From 25181b40d2e08123dd6601eaa6ff1614e447ad7d Mon Sep 17 00:00:00 2001 From: Ash Hughes Date: Fri, 14 Feb 2020 23:12:15 +0000 Subject: [PATCH 2/2] Turn keyboard off on suspend to prevent default colours showing on resume before driver has control again. --- src/tuxedo_keyboard.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index 77b57b3..0dcae60 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -325,7 +325,7 @@ static ssize_t set_brightness_fs(struct device *child, return size; } -static void set_enabled(u8 state) +static int set_enabled_cmd(u8 state) { u32 cmd = 0xE0000000; TUXEDO_INFO("Set keyboard enabled to: %d\n", state); @@ -336,7 +336,12 @@ static void set_enabled(u8 state) cmd |= 0x07F001; } - if (!tuxedo_evaluate_wmi_method(WMI_SUBMETHOD_ID_SET_KB_LEDS, cmd, NULL)) { + return tuxedo_evaluate_wmi_method(WMI_SUBMETHOD_ID_SET_KB_LEDS, cmd, NULL); +} + +static void set_enabled(u8 state) +{ + if (!set_enabled_cmd(state)) { kbd_led_state.enabled = state; } } @@ -617,6 +622,13 @@ static int tuxedo_wmi_remove(struct platform_device *dev) return 0; } +static int tuxedo_wmi_suspend(struct platform_device *dev, pm_message_t state) +{ + // turning the keyboard off prevents default colours showing on resume + set_enabled_cmd(0); + return 0; +} + static int tuxedo_wmi_resume(struct platform_device *dev) { tuxedo_evaluate_wmi_method(WMI_SUBMETHOD_ID_GET_AP, 0, NULL); @@ -636,6 +648,7 @@ static int tuxedo_wmi_resume(struct platform_device *dev) static struct platform_driver tuxedo_platform_driver = { .remove = tuxedo_wmi_remove, + .suspend = tuxedo_wmi_suspend, .resume = tuxedo_wmi_resume, .driver = { .name = DRIVER_NAME,