diff options
author | Scott B | 2021-10-27 16:42:00 -0700 |
---|---|---|
committer | Scott B | 2021-10-29 03:47:50 -0700 |
commit | e9db7394d91a87982be3725253d24ac2395d8b11 (patch) | |
tree | d0ac38aa678642cb89ec19aefba53ac14ea01af6 | |
parent | 07e328db43c0cb8c9e23ef228bb80d8dd2bd8473 (diff) | |
download | aur-e9db7394d91a87982be3725253d24ac2395d8b11.tar.gz |
patch: update ROG custom fan curve patch (v16)
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 4 | ||||
-rw-r--r-- | v16-asus-wmi-Add-support-for-custom-fan-curves.patch (renamed from v15-asus-wmi-Add-support-for-custom-fan-curves.patch) | 183 |
3 files changed, 68 insertions, 123 deletions
@@ -31,7 +31,7 @@ pkgbase = linux-xanmod-rog source = HID-asus-Prevent-Claymore-sending-suspend-event.patch source = HID-asus-Reduce-object-size-by-consolidating-calls.patch source = v5-asus-wmi-Add-support-for-platform_profile.patch - source = v15-asus-wmi-Add-support-for-custom-fan-curves.patch + source = v16-asus-wmi-Add-support-for-custom-fan-curves.patch source = mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch source = mt76-mt7921-Add-mt7922-support.patch source = 1-1-Bluetooth-btusb-Enable-MSFT-extension-for-Mediatek-Chip-MT7921.patch @@ -69,7 +69,7 @@ pkgbase = linux-xanmod-rog sha256sums = ec317cc2c2c8c1186c4f553fdd010adc013c37600a499802473653fd8e7564df sha256sums = 544464bf0807b324120767d55867f03014a9fda4e1804768ca341be902d7ade4 sha256sums = 4ef12029ea73ca924b6397e1de4911e84d9e77ddaccdab1ef579823d848524e8 - sha256sums = 1e547bddf80d201f77da1d876cd280e4d40b377bbd8ebc218f0ba57cd959ff76 + sha256sums = 0c422d8f420c1518aab1b980c6cdb6e029a4fa9cde1fd99a63670bb105a44f36 sha256sums = 2163cb2e394a013042a40cd3b00dae788603284b20d71e262995366c5534e480 sha256sums = a01cf700d79b983807e2285be1b30df6e02db6adfd9c9027fe2dfa8ca5a74bc9 sha256sums = 9f6b8c3ea6e1c285e0a7efda4d743dbae343bc6ee7ad599a4ab7d380c750bc83 @@ -134,7 +134,7 @@ source=("https://cdn.kernel.org/pub/linux/kernel/v${_branch}/linux-${_major}.tar "HID-asus-Prevent-Claymore-sending-suspend-event.patch" # " "HID-asus-Reduce-object-size-by-consolidating-calls.patch" # awaiting ack ... "v5-asus-wmi-Add-support-for-platform_profile.patch" # landing in 5.15 - "v15-asus-wmi-Add-support-for-custom-fan-curves.patch" # -next + "v16-asus-wmi-Add-support-for-custom-fan-curves.patch" # -next # mediatek mt7921 bt/wifi patches #"Bluetooth-btusb-Fixed-too-many-in-token-issue-for-Me.patch" @@ -183,7 +183,7 @@ sha256sums=('7e068b5e0d26a62b10e5320b25dce57588cbbc6f781c090442138c9c9c3271b2' 'ec317cc2c2c8c1186c4f553fdd010adc013c37600a499802473653fd8e7564df' '544464bf0807b324120767d55867f03014a9fda4e1804768ca341be902d7ade4' '4ef12029ea73ca924b6397e1de4911e84d9e77ddaccdab1ef579823d848524e8' - '1e547bddf80d201f77da1d876cd280e4d40b377bbd8ebc218f0ba57cd959ff76' + '0c422d8f420c1518aab1b980c6cdb6e029a4fa9cde1fd99a63670bb105a44f36' '2163cb2e394a013042a40cd3b00dae788603284b20d71e262995366c5534e480' 'a01cf700d79b983807e2285be1b30df6e02db6adfd9c9027fe2dfa8ca5a74bc9' '9f6b8c3ea6e1c285e0a7efda4d743dbae343bc6ee7ad599a4ab7d380c750bc83' diff --git a/v15-asus-wmi-Add-support-for-custom-fan-curves.patch b/v16-asus-wmi-Add-support-for-custom-fan-curves.patch index be11606fad13..f8e2fe883137 100644 --- a/v15-asus-wmi-Add-support-for-custom-fan-curves.patch +++ b/v16-asus-wmi-Add-support-for-custom-fan-curves.patch @@ -1,7 +1,10 @@ -From b9e2eae999333fc1ad9ddf4cf0e36a0eaee239e2 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" <luke@ljones.dev> -Date: Sun, 29 Aug 2021 13:21:23 +1200 -Subject: [PATCH v15] asus-wmi: Add support for custom fan curves +To: linux-kernel@vger.kernel.org +Cc: hdegoede@redhat.com, platform-driver-x86@vger.kernel.org, + hadess@hadess.net, pobrn@protonmail.com, linux@roeck-us.net, + "Luke D. Jones" <luke@ljones.dev> +Subject: [PATCH v16] asus-wmi: Add support for custom fan curves +Date: Sun, 24 Oct 2021 16:37:05 +1300 Add support for custom fan curves found on some ASUS ROG laptops. @@ -28,12 +31,12 @@ Notes: Signed-off-by: Luke D. Jones <luke@ljones.dev> --- - drivers/platform/x86/asus-wmi.c | 608 ++++++++++++++++++++- + drivers/platform/x86/asus-wmi.c | 567 ++++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 2 + - 2 files changed, 602 insertions(+), 8 deletions(-) + 2 files changed, 564 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index e14fb5fa7324..8b0ed1969d86 100644 +index e14fb5fa7324..680570b37c2f 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -106,8 +106,17 @@ module_param(fnlock_default, bool, 0444); @@ -64,12 +67,13 @@ index e14fb5fa7324..8b0ed1969d86 100644 u32 arg5; } __packed; -@@ -173,6 +183,12 @@ enum fan_type { +@@ -173,6 +183,13 @@ enum fan_type { FAN_TYPE_SPEC83, /* starting in Spec 8.3, use CPU_FAN_CTRL */ }; +struct fan_curve_data { + bool enabled; ++ u32 device_id; + u8 temps[FAN_CURVE_POINTS]; + u8 percents[FAN_CURVE_POINTS]; +}; @@ -77,7 +81,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 struct asus_wmi { int dsts_id; int spec; -@@ -220,6 +236,10 @@ struct asus_wmi { +@@ -220,6 +237,10 @@ struct asus_wmi { bool throttle_thermal_policy_available; u8 throttle_thermal_policy_mode; @@ -88,7 +92,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 struct platform_profile_handler platform_profile_handler; bool platform_profile_support; -@@ -285,6 +305,103 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) +@@ -285,6 +306,103 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) } EXPORT_SYMBOL_GPL(asus_wmi_evaluate_method); @@ -192,7 +196,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 static int asus_wmi_evaluate_method_agfn(const struct acpi_buffer args) { struct acpi_buffer input; -@@ -1806,6 +1923,13 @@ static ssize_t pwm1_enable_store(struct device *dev, +@@ -1806,6 +1924,13 @@ static ssize_t pwm1_enable_store(struct device *dev, } asus->fan_pwm_mode = state; @@ -206,7 +210,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 return count; } -@@ -1953,9 +2077,9 @@ static int fan_boost_mode_check_present(struct asus_wmi *asus) +@@ -1953,9 +2078,9 @@ static int fan_boost_mode_check_present(struct asus_wmi *asus) static int fan_boost_mode_write(struct asus_wmi *asus) { @@ -218,7 +222,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 value = asus->fan_boost_mode; -@@ -2013,10 +2137,10 @@ static ssize_t fan_boost_mode_store(struct device *dev, +@@ -2013,10 +2138,10 @@ static ssize_t fan_boost_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -231,11 +235,11 @@ index e14fb5fa7324..8b0ed1969d86 100644 result = kstrtou8(buf, 10, &new_mode); if (result < 0) { -@@ -2043,6 +2167,462 @@ static ssize_t fan_boost_mode_store(struct device *dev, +@@ -2043,6 +2168,426 @@ static ssize_t fan_boost_mode_store(struct device *dev, // Fan boost mode: 0 - normal, 1 - overboost, 2 - silent static DEVICE_ATTR_RW(fan_boost_mode); -+/* Custom fan curves *********************************************************/ ++/* Custom fan curves **********************************************************/ + +static void fan_curve_copy_from_buf(struct fan_curve_data *data, u8 *buf) +{ @@ -277,6 +281,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 + return err; + + fan_curve_copy_from_buf(curves, buf); ++ curves->device_id = fan_dev; + + return 0; +} @@ -342,14 +347,16 @@ index e14fb5fa7324..8b0ed1969d86 100644 + * "fan_dev" is the related WMI method such as ASUS_WMI_DEVID_CPU_FAN_CURVE. + */ +static int fan_curve_write(struct asus_wmi *asus, -+ struct device_attribute *attr, u32 fan_dev) ++ struct fan_curve_data *data) +{ -+ struct fan_curve_data *data = fan_curve_attr_2_select(asus, attr); + u32 arg1 = 0, arg2 = 0, arg3 = 0, arg4 = 0; + u8 *percents = data->percents; + u8 *temps = data->temps; + int ret, i, shift = 0; + ++ if (!data->enabled) ++ return 0; ++ + for (i = 0; i < FAN_CURVE_POINTS / 2; i++) { + arg1 += (temps[i]) << shift; + arg2 += (temps[i + 4]) << shift; @@ -359,32 +366,9 @@ index e14fb5fa7324..8b0ed1969d86 100644 + shift += 8; + } + -+ return asus_wmi_evaluate_method5(ASUS_WMI_METHODID_DEVS, fan_dev, arg1, -+ arg2, arg3, arg4, &ret); -+} -+ -+/* -+ * Called on curve enable/disable. This should be the only way to write out the -+ * fan curves. This avoids potential lockups on write to ACPI for every change. -+ */ -+static int fan_curve_write_data(struct asus_wmi *asus, -+ struct device_attribute *attr) -+{ -+ int err; -+ -+ if (asus->cpu_fan_curve_available) { -+ err = fan_curve_write(asus, attr, ASUS_WMI_DEVID_CPU_FAN_CURVE); -+ if (err) -+ return err; -+ } -+ -+ if (asus->gpu_fan_curve_available) { -+ err = fan_curve_write(asus, attr, ASUS_WMI_DEVID_GPU_FAN_CURVE); -+ if (err) -+ return err; -+ } -+ -+ return 0; ++ return asus_wmi_evaluate_method5(ASUS_WMI_METHODID_DEVS, ++ data->device_id, ++ arg1, arg2, arg3, arg4, &ret); +} + +static ssize_t fan_curve_store(struct device *dev, @@ -437,22 +421,6 @@ index e14fb5fa7324..8b0ed1969d86 100644 + return sysfs_emit(buf, "%d\n", out); +} + -+static int fan_curve_set_default(struct asus_wmi *asus) -+{ -+ int err; -+ -+ err = fan_curve_get_factory_default( -+ asus, ASUS_WMI_DEVID_CPU_FAN_CURVE); -+ if (err) -+ return err; -+ -+ err = fan_curve_get_factory_default( -+ asus, ASUS_WMI_DEVID_GPU_FAN_CURVE); -+ if (err) -+ return err; -+ return 0; -+} -+ +static ssize_t fan_curve_enable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) @@ -479,7 +447,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 + * option so that users don't accidentally overwrite a set fan curve. + */ + case 3: -+ err = fan_curve_set_default(asus); ++ err = fan_curve_get_factory_default(asus, data->device_id); + if (err) + return err; + data->enabled = false; @@ -488,41 +456,34 @@ index e14fb5fa7324..8b0ed1969d86 100644 + return -EINVAL; + }; + -+ /* -+ * For machines with throttle this is the only way to reset fans to -+ * default mode of operation (does not erase curve data). -+ */ -+ if (asus->throttle_thermal_policy_available && !data->enabled) { -+ err = throttle_thermal_policy_write(asus); -+ if (err) -+ return err; -+ } -+ /* Similar is true for laptops with this fan */ -+ if (asus->fan_type == FAN_TYPE_SPEC83) { -+ err = asus_fan_set_auto(asus); -+ if (err) -+ return err; -+ } -+ /* -+ * Machines without either need to write their defaults back always. -+ * This is more of a safeguard against ASUS faulty ACPI tables. -+ */ -+ if (!asus->throttle_thermal_policy_available -+ && asus->fan_type != FAN_TYPE_SPEC83 && !data->enabled) { -+ err = fan_curve_set_default(asus); -+ if (err) -+ return err; -+ err = fan_curve_write_data(asus, attr); -+ if (err) -+ return err; -+ } -+ + if (data->enabled) { -+ err = fan_curve_write_data(asus, attr); ++ err = fan_curve_write(asus, data); + if (err) + return err; ++ } else { ++ /* ++ * For machines with throttle this is the only way to reset fans ++ * to default mode of operation (does not erase curve data). ++ */ ++ if (asus->throttle_thermal_policy_available) { ++ err = throttle_thermal_policy_write(asus); ++ if (err) ++ return err; ++ /* Similar is true for laptops with this fan */ ++ } else if (asus->fan_type == FAN_TYPE_SPEC83) { ++ err = asus_fan_set_auto(asus); ++ if (err) ++ return err; ++ } else { ++ /* Safeguard against fautly ACPI tables */ ++ err = fan_curve_get_factory_default(asus, data->device_id); ++ if (err) ++ return err; ++ err = fan_curve_write(asus, data); ++ if (err) ++ return err; ++ } + } -+ + return count; +} + @@ -644,10 +605,14 @@ index e14fb5fa7324..8b0ed1969d86 100644 + struct device *dev = container_of(kobj, struct device, kobj); + struct asus_wmi *asus = dev_get_drvdata(dev->parent); + -+ if (asus->cpu_fan_curve_available) ++ /* ++ * Check the char instead of casting attr as there are two attr types ++ * involved here (attr1 and attr2) ++ */ ++ if (asus->cpu_fan_curve_available && attr->name[3] == '1') + return 0644; + -+ if (asus->gpu_fan_curve_available) ++ if (asus->gpu_fan_curve_available && attr->name[3] == '2') + return 0644; + + return 0; @@ -679,6 +644,9 @@ index e14fb5fa7324..8b0ed1969d86 100644 + if (err) + return err; + ++ if (!asus->cpu_fan_curve_available && !asus->gpu_fan_curve_available) ++ return 0; ++ + hwmon = devm_hwmon_device_register_with_groups( + dev, "asus_custom_fan_curve", asus, asus_fan_curve_attr_groups); + @@ -694,18 +662,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 /* Throttle thermal policy ****************************************************/ static int throttle_thermal_policy_check_present(struct asus_wmi *asus) -@@ -2053,8 +2633,8 @@ static int throttle_thermal_policy_check_present(struct asus_wmi *asus) - asus->throttle_thermal_policy_available = false; - - err = asus_wmi_get_devstate(asus, -- ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY, -- &result); -+ ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY, -+ &result); - if (err) { - if (err == -ENODEV) - return 0; -@@ -2092,6 +2672,12 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus) +@@ -2092,6 +2637,12 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus) return -EIO; } @@ -718,16 +675,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 return 0; } -@@ -2901,7 +3487,7 @@ static int show_call(struct seq_file *m, void *data) - if (ACPI_FAILURE(status)) - return -EIO; - -- obj = (union acpi_object *)output.pointer; -+ obj = output.pointer; - if (obj && obj->type == ACPI_TYPE_INTEGER) - seq_printf(m, "%#x(%#x, %#x) = %#x\n", asus->debug.method_id, - asus->debug.dev_id, asus->debug.ctrl_param, -@@ -3035,6 +3621,10 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -3035,6 +3586,10 @@ static int asus_wmi_add(struct platform_device *pdev) if (err) goto fail_hwmon; @@ -738,7 +686,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 err = asus_wmi_led_init(asus); if (err) goto fail_leds; -@@ -3106,6 +3696,7 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -3106,6 +3661,7 @@ static int asus_wmi_add(struct platform_device *pdev) asus_wmi_sysfs_exit(asus->platform_device); fail_sysfs: fail_throttle_thermal_policy: @@ -746,7 +694,7 @@ index e14fb5fa7324..8b0ed1969d86 100644 fail_platform_profile_setup: if (asus->platform_profile_support) platform_profile_remove(); -@@ -3131,6 +3722,7 @@ static int asus_wmi_remove(struct platform_device *device) +@@ -3131,6 +3687,7 @@ static int asus_wmi_remove(struct platform_device *device) asus_wmi_debugfs_exit(asus); asus_wmi_sysfs_exit(asus->platform_device); asus_fan_set_auto(asus); @@ -767,6 +715,3 @@ index 17dc5cb6f3f2..a571b47ff362 100644 /* Power */ #define ASUS_WMI_DEVID_PROCESSOR_STATE 0x00120012 --- -2.32.0 - |