mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Add keyboard type detection based on EC
This commit is contained in:
parent
8d67160ea8
commit
099be56b62
|
@ -40,7 +40,13 @@ typedef int (uniwill_write_ec_ram_t)(u16, u8);
|
||||||
typedef int (uniwill_write_ec_ram_with_retry_t)(u16, u8, int);
|
typedef int (uniwill_write_ec_ram_with_retry_t)(u16, u8, int);
|
||||||
typedef void (uniwill_event_callb_t)(u32);
|
typedef void (uniwill_event_callb_t)(u32);
|
||||||
|
|
||||||
|
// UW_EC_REG_* known relevant EC address exposing some information or function
|
||||||
|
// UW_EC_REG_*_BIT_* single bit from byte holding information, should be handled with bit-wise operations
|
||||||
|
// UW_EC_REG_*_VALUE_* discrete value of the whole byte with special meaning
|
||||||
|
// UW_EC_REG_*_SUBCMD_* writing this discrete value triggers special behaviour
|
||||||
|
|
||||||
#define UW_EC_REG_KBD_BL_STATUS 0x078c
|
#define UW_EC_REG_KBD_BL_STATUS 0x078c
|
||||||
|
#define UW_EC_REG_KBD_BL_STATUS_BIT_WHITE_ONLY_KB 0x01
|
||||||
#define UW_EC_REG_KBD_BL_STATUS_SUBCMD_RESET 0x10
|
#define UW_EC_REG_KBD_BL_STATUS_SUBCMD_RESET 0x10
|
||||||
|
|
||||||
#define UW_EC_REG_KBD_BL_MAX_BRIGHTNESS 0x1801
|
#define UW_EC_REG_KBD_BL_MAX_BRIGHTNESS 0x1801
|
||||||
|
@ -49,6 +55,20 @@ typedef void (uniwill_event_callb_t)(u32);
|
||||||
#define UW_EC_REG_KBD_BL_RGB_GREEN_BRIGHTNESS 0x1805
|
#define UW_EC_REG_KBD_BL_RGB_GREEN_BRIGHTNESS 0x1805
|
||||||
#define UW_EC_REG_KBD_BL_RGB_BLUE_BRIGHTNESS 0x1808
|
#define UW_EC_REG_KBD_BL_RGB_BLUE_BRIGHTNESS 0x1808
|
||||||
|
|
||||||
|
#define UW_EC_REG_BAREBONE_ID 0x0740
|
||||||
|
#define UW_EC_REG_BAREBONE_ID_VALUE_PFxxxxx 0x09
|
||||||
|
#define UW_EC_REG_BAREBONE_ID_VALUE_PFxMxxx 0x0e
|
||||||
|
#define UW_EC_REG_BAREBONE_ID_VALUE_PH4TRX1 0x12
|
||||||
|
#define UW_EC_REG_BAREBONE_ID_VALUE_PH4TUX1 0x13
|
||||||
|
#define UW_EC_REG_BAREBONE_ID_VALUE_PH4TQx1 0x14
|
||||||
|
#define UW_EC_REG_BAREBONE_ID_VALUE_PH6TRX1 0x15
|
||||||
|
#define UW_EC_REG_BAREBONE_ID_VALUE_PH6TQxx 0x16
|
||||||
|
#define UW_EC_REG_BAREBONE_ID_VALUE_PH4Axxx 0x17
|
||||||
|
|
||||||
|
#define UW_EC_REG_FEATURES_0 0x0765
|
||||||
|
#define UW_EC_REG_FEATURES_1 0x0766
|
||||||
|
#define UW_EC_REG_FEATURES_1_BIT_1_ZONE_RGB_KB 0x04
|
||||||
|
|
||||||
struct uniwill_interface_t {
|
struct uniwill_interface_t {
|
||||||
char *string_id;
|
char *string_id;
|
||||||
uniwill_event_callb_t *event_callb;
|
uniwill_event_callb_t *event_callb;
|
||||||
|
|
|
@ -56,7 +56,7 @@ void uniwill_leds_set_color_extern(u32 color);
|
||||||
|
|
||||||
#include <linux/led-class-multicolor.h>
|
#include <linux/led-class-multicolor.h>
|
||||||
|
|
||||||
static enum uniwill_kb_backlight_types uniwill_kb_backlight_type = UNIWILL_KB_BACKLIGHT_TYPE_FIXED_COLOR;
|
static enum uniwill_kb_backlight_types uniwill_kb_backlight_type = UNIWILL_KB_BACKLIGHT_TYPE_NONE;
|
||||||
static bool uw_leds_initialized = false;
|
static bool uw_leds_initialized = false;
|
||||||
//static DECLARE_COMPLETION(init_done);
|
//static DECLARE_COMPLETION(init_done);
|
||||||
|
|
||||||
|
@ -157,24 +157,41 @@ int uniwill_leds_init_early(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
// FIXME Use mutexes
|
// FIXME Use mutexes
|
||||||
int ret;
|
int ret;
|
||||||
|
u8 data;
|
||||||
|
|
||||||
if ( dmi_match(DMI_BOARD_NAME, "POLARIS1501A1650TI")
|
ret = uniwill_read_ec_ram(UW_EC_REG_BAREBONE_ID, &data);
|
||||||
|| dmi_match(DMI_BOARD_NAME, "POLARIS1501A2060")
|
if (ret) {
|
||||||
|| dmi_match(DMI_BOARD_NAME, "POLARIS1501I1650TI")
|
pr_err("Reading barebone ID failed.\n");
|
||||||
|| dmi_match(DMI_BOARD_NAME, "POLARIS1501I2060")
|
return ret;
|
||||||
|| dmi_match(DMI_BOARD_NAME, "POLARIS1701A1650TI")
|
}
|
||||||
|| dmi_match(DMI_BOARD_NAME, "POLARIS1701A2060")
|
|
||||||
|| dmi_match(DMI_BOARD_NAME, "POLARIS1701I1650TI")
|
if (data == UW_EC_REG_BAREBONE_ID_VALUE_PFxxxxx ||
|
||||||
|| dmi_match(DMI_BOARD_NAME, "POLARIS1701I2060")
|
data == UW_EC_REG_BAREBONE_ID_VALUE_PFxMxxx ||
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
|
data == UW_EC_REG_BAREBONE_ID_VALUE_PH4TRX1 ||
|
||||||
|| dmi_match(DMI_PRODUCT_SKU, "POLARIS1XA02")
|
data == UW_EC_REG_BAREBONE_ID_VALUE_PH4TUX1 ||
|
||||||
|| dmi_match(DMI_PRODUCT_SKU, "POLARIS1XI02")
|
data == UW_EC_REG_BAREBONE_ID_VALUE_PH4TQx1 ||
|
||||||
|| dmi_match(DMI_PRODUCT_SKU, "POLARIS1XA03")
|
data == UW_EC_REG_BAREBONE_ID_VALUE_PH6TRX1 ||
|
||||||
|| dmi_match(DMI_PRODUCT_SKU, "POLARIS1XI03")
|
data == UW_EC_REG_BAREBONE_ID_VALUE_PH6TQxx ||
|
||||||
#endif
|
data == UW_EC_REG_BAREBONE_ID_VALUE_PH4Axxx) {
|
||||||
) {
|
ret = uniwill_read_ec_ram(UW_EC_REG_KBD_BL_STATUS, &data);
|
||||||
|
if (ret) {
|
||||||
|
pr_err("Reading keyboard backlight status failed.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (data & UW_EC_REG_KBD_BL_STATUS_BIT_WHITE_ONLY_KB) {
|
||||||
|
uniwill_kb_backlight_type = UNIWILL_KB_BACKLIGHT_TYPE_FIXED_COLOR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = uniwill_read_ec_ram(UW_EC_REG_FEATURES_1, &data);
|
||||||
|
if (ret) {
|
||||||
|
pr_err("Reading features 1 failed.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (data & UW_EC_REG_FEATURES_1_BIT_1_ZONE_RGB_KB) {
|
||||||
uniwill_kb_backlight_type = UNIWILL_KB_BACKLIGHT_TYPE_1_ZONE_RGB;
|
uniwill_kb_backlight_type = UNIWILL_KB_BACKLIGHT_TYPE_1_ZONE_RGB;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pr_debug("Keyboard backlight type: 0x%02x\n", uniwill_kb_backlight_type);
|
pr_debug("Keyboard backlight type: 0x%02x\n", uniwill_kb_backlight_type);
|
||||||
|
|
||||||
if (uniwill_kb_backlight_type == UNIWILL_KB_BACKLIGHT_TYPE_FIXED_COLOR) {
|
if (uniwill_kb_backlight_type == UNIWILL_KB_BACKLIGHT_TYPE_FIXED_COLOR) {
|
||||||
|
|
Loading…
Reference in a new issue