Merge branch 'fix_clevo_changing_color_on_suspend' into 'master'

Fix Clevo devices changing keyboard backlight color on resume

See merge request tuxedocomputers/development/packages/tuxedo-keyboard!45
This commit is contained in:
Christoffer 2023-04-13 07:06:27 +00:00
commit 2f4364968a
2 changed files with 18 additions and 0 deletions

View file

@ -359,6 +359,8 @@ static int clevo_keyboard_suspend(struct platform_device *dev, pm_message_t stat
static int clevo_keyboard_resume(struct platform_device *dev) static int clevo_keyboard_resume(struct platform_device *dev)
{ {
clevo_evaluate_method(CLEVO_CMD_SET_EVENTS_ENABLED, 0, NULL); clevo_evaluate_method(CLEVO_CMD_SET_EVENTS_ENABLED, 0, NULL);
clevo_leds_restore_state_extern(); // Sometimes clevo devices forget their last state after
// suspend, so let the kernel ensure it.
set_enabled_cmd(1); set_enabled_cmd(1);
return 0; return 0;
} }

View file

@ -35,6 +35,7 @@ enum clevo_kb_backlight_types {
int clevo_leds_init(struct platform_device *dev); int clevo_leds_init(struct platform_device *dev);
int clevo_leds_remove(struct platform_device *dev); int clevo_leds_remove(struct platform_device *dev);
enum clevo_kb_backlight_types clevo_leds_get_backlight_type(void); enum clevo_kb_backlight_types clevo_leds_get_backlight_type(void);
void clevo_leds_restore_state_extern(void);
void clevo_leds_set_brightness_extern(enum led_brightness brightness); void clevo_leds_set_brightness_extern(enum led_brightness brightness);
void clevo_leds_set_color_extern(u32 color); void clevo_leds_set_color_extern(u32 color);
@ -380,6 +381,21 @@ enum clevo_kb_backlight_types clevo_leds_get_backlight_type() {
} }
EXPORT_SYMBOL(clevo_leds_get_backlight_type); EXPORT_SYMBOL(clevo_leds_get_backlight_type);
void clevo_leds_restore_state_extern(void) {
if (clevo_kb_backlight_type == CLEVO_KB_BACKLIGHT_TYPE_FIXED_COLOR) {
clevo_led_cdev.brightness_set(&clevo_led_cdev, clevo_led_cdev.brightness);
}
else if (clevo_kb_backlight_type == CLEVO_KB_BACKLIGHT_TYPE_1_ZONE_RGB) {
clevo_mcled_cdevs[0].led_cdev.brightness_set(&clevo_mcled_cdevs[0].led_cdev, clevo_mcled_cdevs[0].led_cdev.brightness);
}
else if (clevo_kb_backlight_type == CLEVO_KB_BACKLIGHT_TYPE_3_ZONE_RGB) {
clevo_mcled_cdevs[0].led_cdev.brightness_set(&clevo_mcled_cdevs[0].led_cdev, clevo_mcled_cdevs[0].led_cdev.brightness);
clevo_mcled_cdevs[1].led_cdev.brightness_set(&clevo_mcled_cdevs[1].led_cdev, clevo_mcled_cdevs[1].led_cdev.brightness);
clevo_mcled_cdevs[2].led_cdev.brightness_set(&clevo_mcled_cdevs[2].led_cdev, clevo_mcled_cdevs[2].led_cdev.brightness);
}
}
EXPORT_SYMBOL(clevo_leds_restore_state_extern);
void clevo_leds_set_brightness_extern(enum led_brightness brightness) { void clevo_leds_set_brightness_extern(enum led_brightness brightness) {
if (clevo_kb_backlight_type == CLEVO_KB_BACKLIGHT_TYPE_FIXED_COLOR) { if (clevo_kb_backlight_type == CLEVO_KB_BACKLIGHT_TYPE_FIXED_COLOR) {
clevo_led_cdev.brightness_set(&clevo_led_cdev, brightness); clevo_led_cdev.brightness_set(&clevo_led_cdev, brightness);