mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 11:43:59 +01:00
Add device check to uw kbd bl driver
This commit is contained in:
parent
d976cddc81
commit
9fc2f16482
|
@ -75,6 +75,9 @@ struct kbd_led_state_uw_t {
|
||||||
.color_string = UNIWILL_COLOR_STRING_DEFAULT
|
.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[] = {
|
static struct key_entry uniwill_wmi_keymap[] = {
|
||||||
// { KE_KEY, UNIWILL_OSD_RADIOON, { KEY_RFKILL } },
|
// { KE_KEY, UNIWILL_OSD_RADIOON, { KEY_RFKILL } },
|
||||||
// { KE_KEY, UNIWILL_OSD_RADIOOFF, { KEY_RFKILL } },
|
// { KE_KEY, UNIWILL_OSD_RADIOOFF, { KEY_RFKILL } },
|
||||||
|
@ -87,8 +90,6 @@ static struct key_entry uniwill_wmi_keymap[] = {
|
||||||
{ KE_END, 0 }
|
{ KE_END, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static u8 uniwill_kbd_bl_enable_state_on_start;
|
|
||||||
|
|
||||||
static void key_event_work(struct work_struct *work)
|
static void key_event_work(struct work_struct *work)
|
||||||
{
|
{
|
||||||
sparse_keymap_report_known_event(
|
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
|
// Keyboard backlight brightness toggle
|
||||||
|
if (uniwill_kbd_bl_type_rgb_single_color) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 0x3b:
|
case 0x3b:
|
||||||
kbd_led_state_uw.brightness = 0x00;
|
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();
|
uniwill_write_kbd_bl_state();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
TUXEDO_DEBUG("[Ev %d] Unknown event type - %d (%0#6x)\n", guid_nr, obj->type, obj->type);
|
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);
|
status = register_keyboard_notifier(&keyboard_notifier_block);
|
||||||
|
|
||||||
|
uniwill_kbd_bl_type_rgb_single_color = dmi_match(DMI_BOARD_NAME, "Polaris15I01");
|
||||||
|
|
||||||
// Save previous enable state
|
// Save previous enable state
|
||||||
uniwill_kbd_bl_enable_state_on_start = uniwill_read_kbd_bl_enabled();
|
uniwill_kbd_bl_enable_state_on_start = uniwill_read_kbd_bl_enabled();
|
||||||
|
|
||||||
|
if (uniwill_kbd_bl_type_rgb_single_color) {
|
||||||
// Disable backlight while initializing
|
// Disable backlight while initializing
|
||||||
uniwill_write_kbd_bl_enable(0);
|
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);
|
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;
|
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();
|
uniwill_write_kbd_bl_state();
|
||||||
|
}
|
||||||
|
|
||||||
// Enable keyboard backlight
|
// Enable keyboard backlight
|
||||||
uniwill_write_kbd_bl_enable(1);
|
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)
|
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_state();
|
||||||
|
}
|
||||||
uniwill_write_kbd_bl_enable(1);
|
uniwill_write_kbd_bl_enable(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue