Add device check to uw kbd bl driver

This commit is contained in:
Christoffer Sandberg 2020-08-19 13:27:06 +02:00
parent d976cddc81
commit 9fc2f16482
No known key found for this signature in database
GPG key ID: BF563F71B6C7A96D

View file

@ -75,6 +75,9 @@ struct kbd_led_state_uw_t {
.color_string = UNIWILL_COLOR_STRING_DEFAULT
};
static u8 uniwill_kbd_bl_enable_state_on_start;
static bool uniwill_kbd_bl_type_rgb_single_color = true;
static struct key_entry uniwill_wmi_keymap[] = {
// { KE_KEY, UNIWILL_OSD_RADIOON, { KEY_RFKILL } },
// { KE_KEY, UNIWILL_OSD_RADIOOFF, { KEY_RFKILL } },
@ -87,8 +90,6 @@ static struct key_entry uniwill_wmi_keymap[] = {
{ KE_END, 0 }
};
static u8 uniwill_kbd_bl_enable_state_on_start;
static void key_event_work(struct work_struct *work)
{
sparse_keymap_report_known_event(
@ -266,6 +267,7 @@ static void uniwill_wmi_handle_event(u32 value, void *context, u32 guid_nr)
}
// Keyboard backlight brightness toggle
if (uniwill_kbd_bl_type_rgb_single_color) {
switch (code) {
case 0x3b:
kbd_led_state_uw.brightness = 0x00;
@ -288,6 +290,7 @@ static void uniwill_wmi_handle_event(u32 value, void *context, u32 guid_nr)
uniwill_write_kbd_bl_state();
break;
}
}
} else {
TUXEDO_DEBUG("[Ev %d] Unknown event type - %d (%0#6x)\n", guid_nr, obj->type, obj->type);
}
@ -350,9 +353,12 @@ static int uniwill_keyboard_probe(struct platform_device *dev)
status = register_keyboard_notifier(&keyboard_notifier_block);
uniwill_kbd_bl_type_rgb_single_color = dmi_match(DMI_BOARD_NAME, "Polaris15I01");
// Save previous enable state
uniwill_kbd_bl_enable_state_on_start = uniwill_read_kbd_bl_enabled();
if (uniwill_kbd_bl_type_rgb_single_color) {
// Disable backlight while initializing
uniwill_write_kbd_bl_enable(0);
@ -362,8 +368,9 @@ static int uniwill_keyboard_probe(struct platform_device *dev)
if (color_lookup(&color_list, param_color) <= (u32) 0xffffff) kbd_led_state_uw.color = color_lookup(&color_list, param_color);
else kbd_led_state_uw.color = UNIWILL_COLOR_DEFAULT;
// Update keyboard according to the current state
// Update keyboard backlight according to the current state
uniwill_write_kbd_bl_state();
}
// Enable keyboard backlight
uniwill_write_kbd_bl_enable(1);
@ -401,7 +408,9 @@ static int uniwill_keyboard_suspend(struct platform_device *dev, pm_message_t st
static int uniwill_keyboard_resume(struct platform_device *dev)
{
if (uniwill_kbd_bl_type_rgb_single_color) {
uniwill_write_kbd_bl_state();
}
uniwill_write_kbd_bl_enable(1);
return 0;
}