Add keyboard type check for old devices

This commit is contained in:
Werner Sembach 2022-10-24 14:20:16 +02:00
parent 39c1629f8f
commit dd22af9924
2 changed files with 19 additions and 1 deletions

View file

@ -41,6 +41,9 @@
#define CLEVO_CMD_GET_EVENT 0x01 #define CLEVO_CMD_GET_EVENT 0x01
#define CLEVO_CMD_GET_SPECS 0x0D // Returns buffer -> only works with clevo_evaluate_method2 #define CLEVO_CMD_GET_SPECS 0x0D // Returns buffer -> only works with clevo_evaluate_method2
#define CLEVO_CMD_GET_BIOS_FEATURES 0x52
#define CLEVO_CMD_GET_BIOS_FEATURES_SUB_WHITE_ONLY_KB 0x40000000
#define CLEVO_CMD_GET_BIOS_FEATURES_SUB_3_ZONE_RGB_KB 0x00400000
// The clevo set commands expect a parameter // The clevo set commands expect a parameter
#define CLEVO_CMD_SET_FANSPEED_VALUE 0x68 #define CLEVO_CMD_SET_FANSPEED_VALUE 0x68

View file

@ -257,6 +257,7 @@ int clevo_leds_init(struct platform_device *dev)
int ret; int ret;
u32 status; u32 status;
union acpi_object *result; union acpi_object *result;
u32 result_fallback;
status = clevo_evaluate_method2(CLEVO_CMD_GET_SPECS, 0, &result); status = clevo_evaluate_method2(CLEVO_CMD_GET_SPECS, 0, &result);
if (!status) { if (!status) {
@ -270,7 +271,21 @@ int clevo_leds_init(struct platform_device *dev)
ACPI_FREE(result); ACPI_FREE(result);
} }
else { else {
pr_err("CLEVO_CMD_GET_SPECS failed\n"); pr_notice("CLEVO_CMD_GET_SPECS does not exist on this device or failed, trying CLEVO_CMD_GET_BIOS_FEATURES\n");
// check for devices <= Intel 7th gen (only white only, 3 zone RGB, or no backlight on these devices)
status = clevo_evaluate_method(CLEVO_CMD_GET_BIOS_FEATURES, 0, &result_fallback);
if (!status) {
if (result_fallback & CLEVO_CMD_GET_BIOS_FEATURES_SUB_3_ZONE_RGB_KB) {
clevo_kb_backlight_type = CLEVO_KB_BACKLIGHT_TYPE_3_ZONE_RGB;
}
else if (result_fallback & CLEVO_CMD_GET_BIOS_FEATURES_SUB_WHITE_ONLY_KB) {
clevo_kb_backlight_type = CLEVO_KB_BACKLIGHT_TYPE_FIXED_COLOR;
}
}
else {
pr_notice("CLEVO_CMD_GET_BIOS_FEATURES failed\n");
}
} }
pr_debug("Keyboard backlight type: 0x%02x\n", clevo_kb_backlight_type); pr_debug("Keyboard backlight type: 0x%02x\n", clevo_kb_backlight_type);