mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Don't send key event for firmware controlled TF white only backlights, but only notify userspace of change
This commit is contained in:
parent
52cf510303
commit
319d7b14a1
|
@ -274,13 +274,10 @@ static void uniwill_write_kbd_bl_enable(u8 enable)
|
||||||
|
|
||||||
void uniwill_event_callb(u32 code)
|
void uniwill_event_callb(u32 code)
|
||||||
{
|
{
|
||||||
if (uniwill_keyboard_driver.input_device != NULL)
|
switch (code) {
|
||||||
if (!sparse_keymap_report_known_event(uniwill_keyboard_driver.input_device, code, 1, true)) {
|
case UNIWILL_OSD_MODE_CHANGE_KEY_EVENT:
|
||||||
TUXEDO_DEBUG("Unknown code - %d (%0#6x)\n", code, code);
|
// Special key combination when mode change key is pressed (the one next to
|
||||||
}
|
// the power key). Opens TCC by default when installed.
|
||||||
|
|
||||||
// Special key combination when mode change key is pressed
|
|
||||||
if (code == UNIWILL_OSD_MODE_CHANGE_KEY_EVENT) {
|
|
||||||
input_report_key(uniwill_keyboard_driver.input_device, KEY_LEFTMETA, 1);
|
input_report_key(uniwill_keyboard_driver.input_device, KEY_LEFTMETA, 1);
|
||||||
input_report_key(uniwill_keyboard_driver.input_device, KEY_LEFTALT, 1);
|
input_report_key(uniwill_keyboard_driver.input_device, KEY_LEFTALT, 1);
|
||||||
input_report_key(uniwill_keyboard_driver.input_device, KEY_F6, 1);
|
input_report_key(uniwill_keyboard_driver.input_device, KEY_F6, 1);
|
||||||
|
@ -289,14 +286,28 @@ void uniwill_event_callb(u32 code)
|
||||||
input_report_key(uniwill_keyboard_driver.input_device, KEY_LEFTALT, 0);
|
input_report_key(uniwill_keyboard_driver.input_device, KEY_LEFTALT, 0);
|
||||||
input_report_key(uniwill_keyboard_driver.input_device, KEY_LEFTMETA, 0);
|
input_report_key(uniwill_keyboard_driver.input_device, KEY_LEFTMETA, 0);
|
||||||
input_sync(uniwill_keyboard_driver.input_device);
|
input_sync(uniwill_keyboard_driver.input_device);
|
||||||
}
|
break;
|
||||||
|
case UNIWILL_OSD_DC_ADAPTER_CHANGE:
|
||||||
// Refresh keyboard state and charging prio on cable switch event
|
// Refresh keyboard state and charging prio on cable switch event
|
||||||
if (code == UNIWILL_OSD_DC_ADAPTER_CHANGE) {
|
|
||||||
uniwill_leds_restore_state_extern();
|
uniwill_leds_restore_state_extern();
|
||||||
|
|
||||||
msleep(50);
|
msleep(50);
|
||||||
uw_charging_priority_write_state();
|
uw_charging_priority_write_state();
|
||||||
|
break;
|
||||||
|
case UNIWILL_OSD_KB_LED_LEVEL0:
|
||||||
|
case UNIWILL_OSD_KB_LED_LEVEL1:
|
||||||
|
case UNIWILL_OSD_KB_LED_LEVEL2:
|
||||||
|
case UNIWILL_OSD_KB_LED_LEVEL3:
|
||||||
|
case UNIWILL_OSD_KB_LED_LEVEL4:
|
||||||
|
// Notify userspace/UPower that the firmware changed the keyboard backlight
|
||||||
|
// brightness on white only keyboards. Fallthrough on other keyboards to
|
||||||
|
// emit KEY_KBDILLUMTOGGLE.
|
||||||
|
if (uniwill_leds_notify_brightness_change_extern())
|
||||||
|
return;
|
||||||
|
fallthrough;
|
||||||
|
default:
|
||||||
|
if (uniwill_keyboard_driver.input_device != NULL)
|
||||||
|
if (!sparse_keymap_report_known_event(uniwill_keyboard_driver.input_device, code, 1, true))
|
||||||
|
TUXEDO_DEBUG("Unknown code - %d (%0#6x)\n", code, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ int uniwill_leds_init_early(struct platform_device *dev);
|
||||||
int uniwill_leds_init_late(struct platform_device *dev);
|
int uniwill_leds_init_late(struct platform_device *dev);
|
||||||
int uniwill_leds_remove(struct platform_device *dev);
|
int uniwill_leds_remove(struct platform_device *dev);
|
||||||
enum uniwill_kb_backlight_types uniwill_leds_get_backlight_type(void);
|
enum uniwill_kb_backlight_types uniwill_leds_get_backlight_type(void);
|
||||||
|
int uniwill_leds_notify_brightness_change_extern(void);
|
||||||
void uniwill_leds_restore_state_extern(void);
|
void uniwill_leds_restore_state_extern(void);
|
||||||
void uniwill_leds_set_brightness_extern(enum led_brightness brightness);
|
void uniwill_leds_set_brightness_extern(enum led_brightness brightness);
|
||||||
void uniwill_leds_set_color_extern(u32 color);
|
void uniwill_leds_set_color_extern(u32 color);
|
||||||
|
@ -135,7 +136,8 @@ static struct led_classdev uniwill_led_cdev = {
|
||||||
.name = "white:" LED_FUNCTION_KBD_BACKLIGHT,
|
.name = "white:" LED_FUNCTION_KBD_BACKLIGHT,
|
||||||
.max_brightness = UNIWILL_KBD_BRIGHTNESS_WHITE_MAX,
|
.max_brightness = UNIWILL_KBD_BRIGHTNESS_WHITE_MAX,
|
||||||
.brightness_set = &uniwill_leds_set_brightness,
|
.brightness_set = &uniwill_leds_set_brightness,
|
||||||
.brightness = UNIWILL_KBD_BRIGHTNESS_WHITE_DEFAULT
|
.brightness = UNIWILL_KBD_BRIGHTNESS_WHITE_DEFAULT,
|
||||||
|
.flags = LED_BRIGHT_HW_CHANGED
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct mc_subled uw_mcled_cdev_subleds[3] = {
|
static struct mc_subled uw_mcled_cdev_subleds[3] = {
|
||||||
|
@ -164,6 +166,7 @@ static struct led_classdev_mc uniwill_mcled_cdev = {
|
||||||
.led_cdev.max_brightness = UNIWILL_KBD_BRIGHTNESS_MAX,
|
.led_cdev.max_brightness = UNIWILL_KBD_BRIGHTNESS_MAX,
|
||||||
.led_cdev.brightness_set = &uniwill_leds_set_brightness_mc,
|
.led_cdev.brightness_set = &uniwill_leds_set_brightness_mc,
|
||||||
.led_cdev.brightness = UNIWILL_KBD_BRIGHTNESS_DEFAULT,
|
.led_cdev.brightness = UNIWILL_KBD_BRIGHTNESS_DEFAULT,
|
||||||
|
.led_cdev.flags = LED_BRIGHT_HW_CHANGED,
|
||||||
.num_colors = 3,
|
.num_colors = 3,
|
||||||
.subled_info = uw_mcled_cdev_subleds
|
.subled_info = uw_mcled_cdev_subleds
|
||||||
};
|
};
|
||||||
|
@ -282,6 +285,20 @@ enum uniwill_kb_backlight_types uniwill_leds_get_backlight_type(void) {
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(uniwill_leds_get_backlight_type);
|
EXPORT_SYMBOL(uniwill_leds_get_backlight_type);
|
||||||
|
|
||||||
|
int uniwill_leds_notify_brightness_change_extern(void) {
|
||||||
|
u8 data = 0;
|
||||||
|
|
||||||
|
if (uw_leds_initialized) {
|
||||||
|
if (uniwill_kb_backlight_type == UNIWILL_KB_BACKLIGHT_TYPE_FIXED_COLOR) {
|
||||||
|
uniwill_read_ec_ram(UW_EC_REG_KBD_BL_STATUS, &data);
|
||||||
|
data = (data >> 5) & 0x3;
|
||||||
|
led_classdev_notify_brightness_hw_changed(&uniwill_led_cdev, data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void uniwill_leds_restore_state_extern(void) {
|
void uniwill_leds_restore_state_extern(void) {
|
||||||
u8 data;
|
u8 data;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue