From a85ccf9a4e2939b7b5351af2dc02409013385b50 Mon Sep 17 00:00:00 2001 From: Christoffer Sandberg Date: Mon, 27 Jul 2020 16:31:38 +0200 Subject: [PATCH] Prepare uw state data structure and lookup for color strings --- src/tuxedo_keyboard_common.h | 18 ++++++++++++++++++ src/uniwill_keyboard.h | 13 ++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/tuxedo_keyboard_common.h b/src/tuxedo_keyboard_common.h index e77457a..8ba4c00 100644 --- a/src/tuxedo_keyboard_common.h +++ b/src/tuxedo_keyboard_common.h @@ -95,4 +95,22 @@ static struct color_list_t color_list = { } }; +/** + * Looks up a color in the color_list + * + * Returns found color, or -1 if string did not match + */ +static u32 color_lookup(const struct color_list_t *color_list, const char *color_name) +{ + u32 found_color = -1; + int i; + for (i = 0; i < color_list->size; ++i) { + if (strcmp(color_list->colors[i].name, color_name) == 0) { + found_color = color_list->colors[i].code; + } + } + + return found_color; +} + #endif \ No newline at end of file diff --git a/src/uniwill_keyboard.h b/src/uniwill_keyboard.h index 525ce42..b9dba34 100644 --- a/src/uniwill_keyboard.h +++ b/src/uniwill_keyboard.h @@ -34,7 +34,10 @@ #define UNIWILL_OSD_RADIOON 0x01A #define UNIWILL_OSD_RADIOOFF 0x01B -#define UNIWILL_OSD_TOUCHPADWORKAROUND 0xFFF +#define UNIWILL_OSD_TOUCHPADWORKAROUND 0xFFF + +#define UNIWILL_BRIGHTNESS_DEFAULT 0xc8 * 0.75 // Note: values 0x00 - 0xc8 +#define UNIWILL_COLOR_DEFAULT 0xffffff union uw_ec_read_return { u32 dword; @@ -59,6 +62,14 @@ extern u32 uniwill_wmi_ec_write(u8, u8, u8, u8, union uw_ec_write_return *); struct tuxedo_keyboard_driver uniwill_keyboard_driver; +struct kbd_led_state_uw_t { + u8 brightness; + u32 color; +} kbd_led_state_cl = { + .brightness = UNIWILL_BRIGHTNESS_DEFAULT, + .color = UNIWILL_COLOR_DEFAULT, +}; + static struct key_entry uniwill_wmi_keymap[] = { // { KE_KEY, UNIWILL_OSD_RADIOON, { KEY_RFKILL } }, // { KE_KEY, UNIWILL_OSD_RADIOOFF, { KEY_RFKILL } },