* [PATCH v2 0/2] asus-wmi: TUF Fan extra (GPU) @ 2022-08-13 9:36 Luke D. Jones 2022-08-13 9:36 ` [PATCH v2 1/2] asus-wmi: Modify behaviour of Fn+F5 fan key Luke D. Jones 2022-08-13 9:36 ` [PATCH v2 2/2] asus-wmi: Support the GPU fan on TUF laptops Luke D. Jones 0 siblings, 2 replies; 4+ messages in thread From: Luke D. Jones @ 2022-08-13 9:36 UTC (permalink / raw) To: hdegoede; +Cc: markgross, platform-driver-x86, linux-kernel, Luke D. Jones Adds support to "boost" the second fan, typically GPU. Also tries both fan boost and throttle policy on fn+f5 as some laptops have one, or both but with an ampty body plus valid return for one. Changelog: - Edit commit mesages - Edit comments - use sysfs_emit() Luke D. Jones (2): asus-wmi: Modify behaviour of Fn+F5 fan key asus-wmi: Support the GPU fan on TUF laptops drivers/platform/x86/asus-nb-wmi.c | 1 + drivers/platform/x86/asus-wmi.c | 82 ++++++++++++++++++++-- include/linux/platform_data/x86/asus-wmi.h | 1 + 3 files changed, 78 insertions(+), 6 deletions(-) -- 2.37.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] asus-wmi: Modify behaviour of Fn+F5 fan key 2022-08-13 9:36 [PATCH v2 0/2] asus-wmi: TUF Fan extra (GPU) Luke D. Jones @ 2022-08-13 9:36 ` Luke D. Jones 2022-08-13 9:36 ` [PATCH v2 2/2] asus-wmi: Support the GPU fan on TUF laptops Luke D. Jones 1 sibling, 0 replies; 4+ messages in thread From: Luke D. Jones @ 2022-08-13 9:36 UTC (permalink / raw) To: hdegoede; +Cc: markgross, platform-driver-x86, linux-kernel, Luke D. Jones Some more recent TUF laptops have both fan_boost and thermal_throttle. The key code for Fn+F5 is also different and unmapped. This patch adjusts the asus_wmi_handle_event_code() match to match for both 0x99 and 0xAE, and run both mode switch functions for fan_boost and/or thermal_throttle if either are available. It is required that both are tried, as in some instances the ACPI set-method for one may not have any code body within it even though it was returned as supported by the get method. Signed-off-by: Luke D. Jones <luke@ljones.dev> --- drivers/platform/x86/asus-nb-wmi.c | 1 + drivers/platform/x86/asus-wmi.c | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c index d4cc6afc1861..c0a0d3f1db3e 100644 --- a/drivers/platform/x86/asus-nb-wmi.c +++ b/drivers/platform/x86/asus-nb-wmi.c @@ -584,6 +584,7 @@ static const struct key_entry asus_nb_wmi_keymap[] = { { KE_KEY, 0xA5, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + TV + HDMI */ { KE_KEY, 0xA6, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + TV + HDMI */ { KE_KEY, 0xA7, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV + HDMI */ + { KE_KEY, 0xAE, { KEY_FN_F5 } }, /* Fn+F5 fan mode on 2020+ */ { KE_KEY, 0xB5, { KEY_CALC } }, { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index c62977cd07bf..04699dd72f1b 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3104,14 +3104,13 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) break; } - if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) { - fan_boost_mode_switch_next(asus); + if (code == NOTIFY_KBD_FBM || code == NOTIFY_KBD_TTP) { + if (asus->fan_boost_mode_available) + fan_boost_mode_switch_next(asus); + if (asus->throttle_thermal_policy_available) + throttle_thermal_policy_switch_next(asus); return; - } - if (asus->throttle_thermal_policy_available && code == NOTIFY_KBD_TTP) { - throttle_thermal_policy_switch_next(asus); - return; } if (is_display_toggle(code) && asus->driver->quirks->no_display_toggle) -- 2.37.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] asus-wmi: Support the GPU fan on TUF laptops 2022-08-13 9:36 [PATCH v2 0/2] asus-wmi: TUF Fan extra (GPU) Luke D. Jones 2022-08-13 9:36 ` [PATCH v2 1/2] asus-wmi: Modify behaviour of Fn+F5 fan key Luke D. Jones @ 2022-08-13 9:36 ` Luke D. Jones 1 sibling, 0 replies; 4+ messages in thread From: Luke D. Jones @ 2022-08-13 9:36 UTC (permalink / raw) To: hdegoede; +Cc: markgross, platform-driver-x86, linux-kernel, Luke D. Jones Add support for TUF laptops which have the ability to control the GPU fan. This will show as a second fan in hwmon, and has the ability to run as boost (fullspeed), or auto. Signed-off-by: Luke D. Jones <luke@ljones.dev> --- drivers/platform/x86/asus-wmi.c | 71 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 72 insertions(+) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 04699dd72f1b..d5d8bf07a3cd 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -222,7 +222,9 @@ struct asus_wmi { struct asus_rfkill uwb; enum fan_type fan_type; + enum fan_type gpu_fan_type; int fan_pwm_mode; + int gpu_fan_pwm_mode; int agfn_pwm; bool fan_boost_mode_available; @@ -1750,6 +1752,18 @@ static int asus_fan_set_auto(struct asus_wmi *asus) return -ENXIO; } + /* + * Modern models like the G713 also have GPU fan control (this is not AGFN) + */ + if (asus->gpu_fan_type == FAN_TYPE_SPEC83) { + status = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_FAN_CTRL, + 0, &retval); + if (status) + return status; + + if (retval != 1) + return -EIO; + } return 0; } @@ -1952,9 +1966,57 @@ static ssize_t asus_hwmon_temp1(struct device *dev, deci_kelvin_to_millicelsius(value & 0xFFFF)); } +/* GPU fan on modern ROG laptops */ +static ssize_t pwm2_enable_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->gpu_fan_pwm_mode); +} + +static ssize_t pwm2_enable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct asus_wmi *asus = dev_get_drvdata(dev); + int state; + int value; + int ret; + u32 retval; + + ret = kstrtouint(buf, 10, &state); + if (ret) + return ret; + + switch (state) { /* standard documented hwmon values */ + case ASUS_FAN_CTRL_FULLSPEED: + value = 1; + break; + case ASUS_FAN_CTRL_AUTO: + value = 0; + break; + default: + return -EINVAL; + } + + ret = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_FAN_CTRL, + value, &retval); + if (ret) + return ret; + + if (retval != 1) + return -EIO; + + asus->gpu_fan_pwm_mode = state; + return count; +} + /* Fan1 */ static DEVICE_ATTR_RW(pwm1); static DEVICE_ATTR_RW(pwm1_enable); +static DEVICE_ATTR_RW(pwm2_enable); static DEVICE_ATTR_RO(fan1_input); static DEVICE_ATTR_RO(fan1_label); @@ -1964,6 +2026,7 @@ static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL); static struct attribute *hwmon_attributes[] = { &dev_attr_pwm1.attr, &dev_attr_pwm1_enable.attr, + &dev_attr_pwm2_enable.attr, &dev_attr_fan1_input.attr, &dev_attr_fan1_label.attr, @@ -1986,6 +2049,9 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, || attr == &dev_attr_pwm1_enable.attr) { if (asus->fan_type == FAN_TYPE_NONE) return 0; + } else if (attr == &dev_attr_pwm2_enable.attr) { + if (asus->gpu_fan_type == FAN_TYPE_NONE) + return 0; } else if (attr == &dev_attr_temp1_input.attr) { int err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_THERMAL_CTRL, @@ -2028,6 +2094,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus) static int asus_wmi_fan_init(struct asus_wmi *asus) { + asus->gpu_fan_type = FAN_TYPE_NONE; asus->fan_type = FAN_TYPE_NONE; asus->agfn_pwm = -1; @@ -2036,6 +2103,10 @@ static int asus_wmi_fan_init(struct asus_wmi *asus) else if (asus_wmi_has_agfn_fan(asus)) asus->fan_type = FAN_TYPE_AGFN; + /* Modern models like G713 also have GPU fan control */ + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_FAN_CTRL)) + asus->gpu_fan_type = FAN_TYPE_SPEC83; + if (asus->fan_type == FAN_TYPE_NONE) return -ENODEV; diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h index 9132b43c2666..56ebe9f97e08 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -78,6 +78,7 @@ #define ASUS_WMI_DEVID_THERMAL_CTRL 0x00110011 #define ASUS_WMI_DEVID_FAN_CTRL 0x00110012 /* deprecated */ #define ASUS_WMI_DEVID_CPU_FAN_CTRL 0x00110013 +#define ASUS_WMI_DEVID_GPU_FAN_CTRL 0x00110014 #define ASUS_WMI_DEVID_CPU_FAN_CURVE 0x00110024 #define ASUS_WMI_DEVID_GPU_FAN_CURVE 0x00110025 -- 2.37.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 0/2] asus-wmi: Modify fn+f5 and support GPU fan @ 2022-08-26 0:42 Luke D. Jones 2022-08-26 0:42 ` [PATCH v2 2/2] asus-wmi: Support the GPU fan on TUF laptops Luke D. Jones 0 siblings, 1 reply; 4+ messages in thread From: Luke D. Jones @ 2022-08-26 0:42 UTC (permalink / raw) To: hdegoede; +Cc: markgross, platform-driver-x86, linux-kernel, Luke D. Jones Some TUF laptops have both fan_boost and thermal_throttle, and some in that group may not actually have an effect on one or the other - this patch series adjusts behaviour to try both. There doesn't appear to be any consistency to check for so far. Some laptops can also control the GPU fan between auto and boost. Changelog: - V2 + Rebase on review-hans Luke D. Jones (2): asus-wmi: Modify behaviour of Fn+F5 fan key asus-wmi: Support the GPU fan on TUF laptops drivers/platform/x86/asus-nb-wmi.c | 1 + drivers/platform/x86/asus-wmi.c | 82 ++++++++++++++++++++-- include/linux/platform_data/x86/asus-wmi.h | 1 + 3 files changed, 78 insertions(+), 6 deletions(-) -- 2.37.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] asus-wmi: Support the GPU fan on TUF laptops 2022-08-26 0:42 [PATCH v2 0/2] asus-wmi: Modify fn+f5 and support GPU fan Luke D. Jones @ 2022-08-26 0:42 ` Luke D. Jones 0 siblings, 0 replies; 4+ messages in thread From: Luke D. Jones @ 2022-08-26 0:42 UTC (permalink / raw) To: hdegoede; +Cc: markgross, platform-driver-x86, linux-kernel, Luke D. Jones Add support for TUF laptops which have the ability to control the GPU fan. This will show as a second fan in hwmon, and has the ability to run as boost (fullspeed), or auto. Signed-off-by: Luke D. Jones <luke@ljones.dev> --- drivers/platform/x86/asus-wmi.c | 71 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 72 insertions(+) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index ea45e10302f7..d05684194f2d 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -226,7 +226,9 @@ struct asus_wmi { u32 tablet_switch_dev_id; enum fan_type fan_type; + enum fan_type gpu_fan_type; int fan_pwm_mode; + int gpu_fan_pwm_mode; int agfn_pwm; bool fan_boost_mode_available; @@ -1861,6 +1863,18 @@ static int asus_fan_set_auto(struct asus_wmi *asus) return -ENXIO; } + /* + * Modern models like the G713 also have GPU fan control (this is not AGFN) + */ + if (asus->gpu_fan_type == FAN_TYPE_SPEC83) { + status = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_FAN_CTRL, + 0, &retval); + if (status) + return status; + + if (retval != 1) + return -EIO; + } return 0; } @@ -2063,9 +2077,57 @@ static ssize_t asus_hwmon_temp1(struct device *dev, deci_kelvin_to_millicelsius(value & 0xFFFF)); } +/* GPU fan on modern ROG laptops */ +static ssize_t pwm2_enable_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->gpu_fan_pwm_mode); +} + +static ssize_t pwm2_enable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct asus_wmi *asus = dev_get_drvdata(dev); + int state; + int value; + int ret; + u32 retval; + + ret = kstrtouint(buf, 10, &state); + if (ret) + return ret; + + switch (state) { /* standard documented hwmon values */ + case ASUS_FAN_CTRL_FULLSPEED: + value = 1; + break; + case ASUS_FAN_CTRL_AUTO: + value = 0; + break; + default: + return -EINVAL; + } + + ret = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_FAN_CTRL, + value, &retval); + if (ret) + return ret; + + if (retval != 1) + return -EIO; + + asus->gpu_fan_pwm_mode = state; + return count; +} + /* Fan1 */ static DEVICE_ATTR_RW(pwm1); static DEVICE_ATTR_RW(pwm1_enable); +static DEVICE_ATTR_RW(pwm2_enable); static DEVICE_ATTR_RO(fan1_input); static DEVICE_ATTR_RO(fan1_label); @@ -2075,6 +2137,7 @@ static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL); static struct attribute *hwmon_attributes[] = { &dev_attr_pwm1.attr, &dev_attr_pwm1_enable.attr, + &dev_attr_pwm2_enable.attr, &dev_attr_fan1_input.attr, &dev_attr_fan1_label.attr, @@ -2097,6 +2160,9 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, || attr == &dev_attr_pwm1_enable.attr) { if (asus->fan_type == FAN_TYPE_NONE) return 0; + } else if (attr == &dev_attr_pwm2_enable.attr) { + if (asus->gpu_fan_type == FAN_TYPE_NONE) + return 0; } else if (attr == &dev_attr_temp1_input.attr) { int err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_THERMAL_CTRL, @@ -2139,6 +2205,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus) static int asus_wmi_fan_init(struct asus_wmi *asus) { + asus->gpu_fan_type = FAN_TYPE_NONE; asus->fan_type = FAN_TYPE_NONE; asus->agfn_pwm = -1; @@ -2147,6 +2214,10 @@ static int asus_wmi_fan_init(struct asus_wmi *asus) else if (asus_wmi_has_agfn_fan(asus)) asus->fan_type = FAN_TYPE_AGFN; + /* Modern models like G713 also have GPU fan control */ + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_FAN_CTRL)) + asus->gpu_fan_type = FAN_TYPE_SPEC83; + if (asus->fan_type == FAN_TYPE_NONE) return -ENODEV; diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h index 7dd580fdc61c..28234dc9fa6a 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -79,6 +79,7 @@ #define ASUS_WMI_DEVID_THERMAL_CTRL 0x00110011 #define ASUS_WMI_DEVID_FAN_CTRL 0x00110012 /* deprecated */ #define ASUS_WMI_DEVID_CPU_FAN_CTRL 0x00110013 +#define ASUS_WMI_DEVID_GPU_FAN_CTRL 0x00110014 #define ASUS_WMI_DEVID_CPU_FAN_CURVE 0x00110024 #define ASUS_WMI_DEVID_GPU_FAN_CURVE 0x00110025 -- 2.37.2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-26 0:42 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-08-13 9:36 [PATCH v2 0/2] asus-wmi: TUF Fan extra (GPU) Luke D. Jones 2022-08-13 9:36 ` [PATCH v2 1/2] asus-wmi: Modify behaviour of Fn+F5 fan key Luke D. Jones 2022-08-13 9:36 ` [PATCH v2 2/2] asus-wmi: Support the GPU fan on TUF laptops Luke D. Jones 2022-08-26 0:42 [PATCH v2 0/2] asus-wmi: Modify fn+f5 and support GPU fan Luke D. Jones 2022-08-26 0:42 ` [PATCH v2 2/2] asus-wmi: Support the GPU fan on TUF laptops Luke D. Jones
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).