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,27 +267,29 @@ static void uniwill_wmi_handle_event(u32 value, void *context, u32 guid_nr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keyboard backlight brightness toggle
|
// Keyboard backlight brightness toggle
|
||||||
switch (code) {
|
if (uniwill_kbd_bl_type_rgb_single_color) {
|
||||||
case 0x3b:
|
switch (code) {
|
||||||
kbd_led_state_uw.brightness = 0x00;
|
case 0x3b:
|
||||||
uniwill_write_kbd_bl_state();
|
kbd_led_state_uw.brightness = 0x00;
|
||||||
break;
|
uniwill_write_kbd_bl_state();
|
||||||
case 0x3c:
|
break;
|
||||||
kbd_led_state_uw.brightness = 0x20;
|
case 0x3c:
|
||||||
uniwill_write_kbd_bl_state();
|
kbd_led_state_uw.brightness = 0x20;
|
||||||
break;
|
uniwill_write_kbd_bl_state();
|
||||||
case 0x3d:
|
break;
|
||||||
kbd_led_state_uw.brightness = 0x50;
|
case 0x3d:
|
||||||
uniwill_write_kbd_bl_state();
|
kbd_led_state_uw.brightness = 0x50;
|
||||||
break;
|
uniwill_write_kbd_bl_state();
|
||||||
case 0x3e:
|
break;
|
||||||
kbd_led_state_uw.brightness = 0x80;
|
case 0x3e:
|
||||||
uniwill_write_kbd_bl_state();
|
kbd_led_state_uw.brightness = 0x80;
|
||||||
break;
|
uniwill_write_kbd_bl_state();
|
||||||
case 0x3f:
|
break;
|
||||||
kbd_led_state_uw.brightness = 0xc8;
|
case 0x3f:
|
||||||
uniwill_write_kbd_bl_state();
|
kbd_led_state_uw.brightness = 0xc8;
|
||||||
break;
|
uniwill_write_kbd_bl_state();
|
||||||
|
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,20 +353,24 @@ 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();
|
||||||
|
|
||||||
// Disable backlight while initializing
|
if (uniwill_kbd_bl_type_rgb_single_color) {
|
||||||
uniwill_write_kbd_bl_enable(0);
|
// Disable backlight while initializing
|
||||||
|
uniwill_write_kbd_bl_enable(0);
|
||||||
|
|
||||||
// Initialize keyboard backlight driver state according to parameters
|
// Initialize keyboard backlight driver state according to parameters
|
||||||
if (param_brightness > UNIWILL_BRIGHTNESS_MAX) param_brightness = UNIWILL_BRIGHTNESS_DEFAULT;
|
if (param_brightness > UNIWILL_BRIGHTNESS_MAX) param_brightness = UNIWILL_BRIGHTNESS_DEFAULT;
|
||||||
kbd_led_state_uw.brightness = param_brightness;
|
kbd_led_state_uw.brightness = param_brightness;
|
||||||
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)
|
||||||
{
|
{
|
||||||
uniwill_write_kbd_bl_state();
|
if (uniwill_kbd_bl_type_rgb_single_color) {
|
||||||
|
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