mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Move uw universal fan check, add to feats structure
This commit is contained in:
parent
77389fc262
commit
a0d14ebd03
|
@ -262,24 +262,6 @@ static long clevo_ioctl_interface(struct file *file, unsigned int cmd, unsigned
|
||||||
return 0;
|
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) {
|
static int set_full_fan_mode(bool enable) {
|
||||||
u8 mode_data;
|
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_start_temp = 0x0f40;
|
||||||
u16 addr_gpu_custom_fan_table_fan_speed = 0x0f50;
|
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);
|
set_full_fan_mode(false);
|
||||||
|
|
||||||
uniwill_read_ec_ram(addr_use_custom_fan_table_0, &value_use_custom_fan_table_0);
|
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_cpu_custom_fan_table_fan_speed = 0x0f20;
|
||||||
u16 addr_gpu_custom_fan_table_fan_speed = 0x0f50;
|
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();
|
uw_init_fan();
|
||||||
|
|
||||||
if (fan_index == 0)
|
if (fan_index == 0)
|
||||||
|
@ -416,7 +398,7 @@ static u32 uw_set_fan_auto(void)
|
||||||
{
|
{
|
||||||
u8 mode_data;
|
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_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
|
u16 addr_use_custom_fan_table_1 = 0x07c6; // enable 0x0fxx fantables
|
||||||
u8 offset_use_custom_fan_table_0 = 7;
|
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));
|
copy_result = copy_to_user((void *) arg, &result, sizeof(result));
|
||||||
break;
|
break;
|
||||||
case R_UW_FANS_OFF_AVAILABLE:
|
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) {
|
if (result == 1) {
|
||||||
result = 0;
|
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));
|
copy_result = copy_to_user((void *) arg, &result, sizeof(result));
|
||||||
break;
|
break;
|
||||||
case R_UW_FANS_MIN_SPEED:
|
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) {
|
if (result == 1) {
|
||||||
result = 20;
|
result = 20;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ struct uniwill_device_features_t {
|
||||||
bool uniwill_profile_v1_three_profs_leds_only;
|
bool uniwill_profile_v1_three_profs_leds_only;
|
||||||
bool uniwill_has_charging_prio;
|
bool uniwill_has_charging_prio;
|
||||||
bool uniwill_has_charging_profile;
|
bool uniwill_has_charging_profile;
|
||||||
|
bool uniwill_has_universal_ec_fan_control;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct uniwill_device_features_t *uniwill_get_device_features(void);
|
struct uniwill_device_features_t *uniwill_get_device_features(void);
|
||||||
|
|
|
@ -950,10 +950,31 @@ static ssize_t uw_charging_prio_store(struct device *child,
|
||||||
return -EINVAL;
|
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 *uniwill_get_device_features(void)
|
||||||
{
|
{
|
||||||
struct uniwill_device_features_t *uw_feats = &uniwill_device_features;
|
struct uniwill_device_features_t *uw_feats = &uniwill_device_features;
|
||||||
u32 status;
|
u32 status;
|
||||||
|
int result;
|
||||||
bool feats_loaded;
|
bool feats_loaded;
|
||||||
|
|
||||||
if (uw_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)
|
if (uw_has_charging_profile(&uw_feats->uniwill_has_charging_profile) != 0)
|
||||||
feats_loaded = false;
|
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)
|
if (feats_loaded)
|
||||||
pr_debug("feats loaded\n");
|
pr_debug("feats loaded\n");
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue