diff --git a/src/tuxedo_io/tuxedo_io.c b/src/tuxedo_io/tuxedo_io.c index 1121ebd..879efd7 100644 --- a/src/tuxedo_io/tuxedo_io.c +++ b/src/tuxedo_io/tuxedo_io.c @@ -34,7 +34,7 @@ MODULE_DESCRIPTION("Hardware interface for TUXEDO laptops"); MODULE_AUTHOR("TUXEDO Computers GmbH "); -MODULE_VERSION("0.3.3"); +MODULE_VERSION("0.3.4"); MODULE_LICENSE("GPL"); MODULE_ALIAS_CLEVO_INTERFACES(); @@ -262,24 +262,6 @@ static long clevo_ioctl_interface(struct file *file, unsigned int cmd, unsigned return 0; } -static int has_universal_ec_fan_control(void) { - int ret; - u8 data; - - if (uw_feats->model == UW_MODEL_PH4TRX) { - // For some reason, on this particular device, the 2nd fan is not controlled via the - // "GPU" fan curve when the bit to separate both fancurves is set, but the old fan - // control works just fine. - return 0; - } - - ret = uniwill_read_ec_ram(0x078e, &data); - if (ret < 0) { - return ret; - } - return (data >> 6) & 1; -} - static int set_full_fan_mode(bool enable) { u8 mode_data; @@ -315,7 +297,7 @@ static int uw_init_fan(void) { u16 addr_gpu_custom_fan_table_start_temp = 0x0f40; u16 addr_gpu_custom_fan_table_fan_speed = 0x0f50; - if (!fans_initialized && (has_universal_ec_fan_control() == 1)) { + if (!fans_initialized && uw_feats->uniwill_has_universal_ec_fan_control) { set_full_fan_mode(false); uniwill_read_ec_ram(addr_use_custom_fan_table_0, &value_use_custom_fan_table_0); @@ -360,7 +342,7 @@ static u32 uw_set_fan(u32 fan_index, u8 fan_speed) u16 addr_cpu_custom_fan_table_fan_speed = 0x0f20; u16 addr_gpu_custom_fan_table_fan_speed = 0x0f50; - if (has_universal_ec_fan_control() == 1) { + if (uw_feats->uniwill_has_universal_ec_fan_control) { uw_init_fan(); if (fan_index == 0) @@ -416,7 +398,7 @@ static u32 uw_set_fan_auto(void) { u8 mode_data; - if (has_universal_ec_fan_control() == 1) { + if (uw_feats->uniwill_has_universal_ec_fan_control) { u16 addr_use_custom_fan_table_0 = 0x07c5; // use different tables for both fans (0x0f00-0x0f2f and 0x0f30-0x0f5f respectivly) u16 addr_use_custom_fan_table_1 = 0x07c6; // enable 0x0fxx fantables u8 offset_use_custom_fan_table_0 = 7; @@ -611,7 +593,7 @@ static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigne copy_result = copy_to_user((void *) arg, &result, sizeof(result)); break; case R_UW_FANS_OFF_AVAILABLE: - /*result = has_universal_ec_fan_control(); + /*result = uw_feats->uniwill_has_universal_ec_fan_control ? 1 : 0; if (result == 1) { result = 0; } @@ -622,7 +604,7 @@ static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigne copy_result = copy_to_user((void *) arg, &result, sizeof(result)); break; case R_UW_FANS_MIN_SPEED: - /*result = has_universal_ec_fan_control(); + /*result = uw_feats->uniwill_has_universal_ec_fan_control? 1 : 0; if (result == 1) { result = 20; } diff --git a/src/uniwill_interfaces.h b/src/uniwill_interfaces.h index 705ccda..ceba580 100644 --- a/src/uniwill_interfaces.h +++ b/src/uniwill_interfaces.h @@ -106,6 +106,7 @@ struct uniwill_device_features_t { bool uniwill_profile_v1_three_profs_leds_only; bool uniwill_has_charging_prio; bool uniwill_has_charging_profile; + bool uniwill_has_universal_ec_fan_control; }; struct uniwill_device_features_t *uniwill_get_device_features(void); diff --git a/src/uniwill_keyboard.h b/src/uniwill_keyboard.h index e72d4ee..332acd6 100644 --- a/src/uniwill_keyboard.h +++ b/src/uniwill_keyboard.h @@ -950,10 +950,31 @@ static ssize_t uw_charging_prio_store(struct device *child, return -EINVAL; } +static int has_universal_ec_fan_control(void) { + int ret; + u8 data; + + struct uniwill_device_features_t *uw_feats = &uniwill_device_features; + + if (uw_feats->model == UW_MODEL_PH4TRX) { + // For some reason, on this particular device, the 2nd fan is not controlled via the + // "GPU" fan curve when the bit to separate both fancurves is set, but the old fan + // control works just fine. + return 0; + } + + ret = uniwill_read_ec_ram(0x078e, &data); + if (ret < 0) { + return ret; + } + return (data >> 6) & 1; +} + struct uniwill_device_features_t *uniwill_get_device_features(void) { struct uniwill_device_features_t *uw_feats = &uniwill_device_features; u32 status; + int result; bool feats_loaded; if (uw_feats_loaded) @@ -1013,6 +1034,14 @@ struct uniwill_device_features_t *uniwill_get_device_features(void) if (uw_has_charging_profile(&uw_feats->uniwill_has_charging_profile) != 0) feats_loaded = false; + result = has_universal_ec_fan_control(); + if (result < 0) { + feats_loaded = false; + } else { + uw_feats->uniwill_has_universal_ec_fan_control = (result == 1); + } + + if (feats_loaded) pr_debug("feats loaded\n"); else diff --git a/src/uniwill_wmi.c b/src/uniwill_wmi.c index e75b7cd..009e199 100644 --- a/src/uniwill_wmi.c +++ b/src/uniwill_wmi.c @@ -124,7 +124,8 @@ static int uw_ec_write_addr_wmi(u8 addr_low, u8 addr_high, u8 data_low, u8 data_ static int uw_ec_read_addr_direct(u8 addr_low, u8 addr_high, union uw_ec_read_return *output) { int result; - u8 tmp, count, flags; + int count; + u8 tmp, flags; bool ready; bool bflag = false; @@ -164,6 +165,7 @@ static int uw_ec_read_addr_direct(u8 addr_low, u8 addr_high, union uw_ec_read_re output->bytes.data_high = tmp; result = 0; } else { + pr_err("uw ec read timeout, addr: 0x%02x%02x\n", addr_high, addr_low); output->dword = 0xfefefefe; result = -EIO; } @@ -175,6 +177,9 @@ static int uw_ec_read_addr_direct(u8 addr_low, u8 addr_high, union uw_ec_read_re if (bflag) pr_debug("addr: 0x%02x%02x value: %0#4x result: %d\n", addr_high, addr_low, output->bytes.data_low, result); + if ((UW_EC_BUSY_WAIT_CYCLES - count) > 1) + pr_debug("read wait count: %i", (UW_EC_BUSY_WAIT_CYCLES - count)); + // pr_debug("addr: 0x%02x%02x value: %0#4x result: %d\n", addr_high, addr_low, output->bytes.data_low, result); return result; @@ -183,7 +188,8 @@ static int uw_ec_read_addr_direct(u8 addr_low, u8 addr_high, union uw_ec_read_re static int uw_ec_write_addr_direct(u8 addr_low, u8 addr_high, u8 data_low, u8 data_high, union uw_ec_write_return *output) { int result = 0; - u8 tmp, count, flags; + int count; + u8 tmp, flags; bool ready; bool bflag = false; @@ -225,6 +231,7 @@ static int uw_ec_write_addr_direct(u8 addr_low, u8 addr_high, u8 data_low, u8 da output->bytes.data_high = data_high; result = 0; } else { + pr_err("uw ec write timeout, addr: 0x%02x%02x, value: %0#4x\n", addr_high, addr_low, data_low); output->dword = 0xfefefefe; result = -EIO; } @@ -234,6 +241,9 @@ static int uw_ec_write_addr_direct(u8 addr_low, u8 addr_high, u8 data_low, u8 da if (bflag) pr_debug("addr: 0x%02x%02x value: %0#4x result: %d\n", addr_high, addr_low, data_low, result); + if ((UW_EC_BUSY_WAIT_CYCLES - count) > 1) + pr_debug("write wait count: %i", (UW_EC_BUSY_WAIT_CYCLES - count)); + mutex_unlock(&uniwill_ec_lock); return result; @@ -371,7 +381,7 @@ module_wmi_driver(uniwill_wmi_driver); MODULE_AUTHOR("TUXEDO Computers GmbH "); MODULE_DESCRIPTION("Driver for Uniwill WMI interface"); -MODULE_VERSION("0.0.3"); +MODULE_VERSION("0.0.4"); MODULE_LICENSE("GPL"); /*