From nobody Sat Apr 11 09:20:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2957FC19F2D for ; Sat, 13 Aug 2022 09:37:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238972AbiHMJhE (ORCPT ); Sat, 13 Aug 2022 05:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238925AbiHMJhA (ORCPT ); Sat, 13 Aug 2022 05:37:00 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8697C41D02; Sat, 13 Aug 2022 02:36:59 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 9F2693200904; Sat, 13 Aug 2022 05:36:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 13 Aug 2022 05:36:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1660383418; x=1660469818; bh=5s JrxwyxQvWKQb1bzW9egtWpG8+alHMEb9LZTo1uBPM=; b=lXvEN5Y/8LS7q/FLxs 5RNfGI5/dmIWehRPMH9uU17gibgK2ZFsQB6DYMHNBNjIyzQPniY/noYgBgjsMkJW pA8VMDgYp4igaA8PQy2EzwSiJql682Iq1W1e1Bl2bTeWLzqYMX4NNZ6tQXhsS2h6 Uvv52ABEowvZldqGS5wE1TMkK8ZTWgQRVlWUR4DzXx34YNPxIEK2YZOVAFO9vzaE R6QGJ40amdcjveJ/PhxndgZJspWDDw4k/Wd3HwPsK7GLqSi0fORLhPsta62gxu8Z jS9/0XwTigFAl27MOAv6YMSOghcQjkG7aahRqI6pu4SzJn6owe4clGjBzwrWW7+2 77iQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1660383418; x=1660469818; bh=5sJrxwyxQvWKQ b1bzW9egtWpG8+alHMEb9LZTo1uBPM=; b=Co0hk6ZWO47495/f1cRQrytV2lKbM Xi4SrCbNFPP/uqVyDXq2Yf3BaI9LwVyB79QVkmZ5Q+6t8V8CXH8Wc0mfc8uTBnhe ipOVSYAnVn5MmonUDguGoJsrFlNh7OG4T6kbce77yvUkYJPgrx/EL8ga1GdLiziO HCibZFwS3tzyZ80Kd0YBXYQUWFP9EvYCUHQi5inWD+L28r0JKsicUNJQLn03UWHC UV9J4hLsdZ6q+YnehutqxDVRNKenqZsTD6zUNDRSyaqA6odOlRw5LFMozxshNkBs UTY/yfLXFCtP/Tv44Hx4hW456GwoF/HayIxpsftHRObFr4B/6kSlh6WCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegkedgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 13 Aug 2022 05:36:55 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: markgross@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 1/2] asus-wmi: Modify behaviour of Fn+F5 fan key Date: Sat, 13 Aug 2022 21:36:41 +1200 Message-Id: <20220813093642.7440-2-luke@ljones.dev> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220813093642.7440-1-luke@ljones.dev> References: <20220813093642.7440-1-luke@ljones.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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[] =3D { { 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-wm= i.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, st= ruct asus_wmi *asus) break; } =20 - if (asus->fan_boost_mode_available && code =3D=3D NOTIFY_KBD_FBM) { - fan_boost_mode_switch_next(asus); + if (code =3D=3D NOTIFY_KBD_FBM || code =3D=3D 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; - } =20 - if (asus->throttle_thermal_policy_available && code =3D=3D NOTIFY_KBD_TTP= ) { - throttle_thermal_policy_switch_next(asus); - return; } =20 if (is_display_toggle(code) && asus->driver->quirks->no_display_toggle) --=20 2.37.1 From nobody Sat Apr 11 09:20:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42915C19F2D for ; Sat, 13 Aug 2022 09:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237447AbiHMJhN (ORCPT ); Sat, 13 Aug 2022 05:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239019AbiHMJhG (ORCPT ); Sat, 13 Aug 2022 05:37:06 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC05746DBE; Sat, 13 Aug 2022 02:37:04 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id BCE4532008FF; Sat, 13 Aug 2022 05:37:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 13 Aug 2022 05:37:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1660383423; x=1660469823; bh=U+ PjTgt180MNnROx+XicSml347QIeNEXU/vdPDGf6bY=; b=ZlWeDMts4orFH6hn7/ RQJ6QEW+Sq6+Hs4s0nam3myYbzZh5QF5CeYnQPxcuooun9K56mlna9e1hcxQIO/C 01BSqul1y2DcRBBy3yFeaAcEcn1gem5byH22z50JOERDYhOM/j0v/4zZ2g/QdH5e xvjtr9G/WgqIqzZTm1l2SofXgTag9SJdG8kkkC2I1XxMXfxy5eUOleKvPmdqkQPv sE9rhRLHNp6+6p4IwfQbiNuyP0yjJgFB17LZkab70Mtj9bPgnZ8bfVp6sHh0EmXw 0yPHIIYYiW5/xWt4ndOe4r6XhiSCx/qtdsgu8bZNCHxVSKtzasqt+A5w0YlImPdz zRMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1660383423; x=1660469823; bh=U+PjTgt180MNn ROx+XicSml347QIeNEXU/vdPDGf6bY=; b=az8bWzas4YMBu+6tdLtSRxoVbQK5t grBUiFjKcqs1B66rziYfXm/jHQsLJ7QIE7Tgpi8pLolTUuji1eZ5cimzaG53CdHR XRKU574NqbZNsbJjlbxGMDUFk2diJ2qfBvlGGGR6TP/P7FWngA1xGIED+5bViwpr eKXSTNCrVZ15ZR8uwRpp3zvi4AVxlw229dT3WHMqkRl/3ssOezoHkSloVVXEmxR0 HeiJkYXXmAvphVOCSHz7cht+2bH7zrGV5wihvaRxFuAKEgWv54MhJr1oxbKk4Kdn utS1FMCFsgBkZecZZ89Aet/LkJo01rUcBbiB8oc3QgFM7IgCW33oB6bQA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdegkedgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgepuden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 13 Aug 2022 05:36:59 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: markgross@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 2/2] asus-wmi: Support the GPU fan on TUF laptops Date: Sat, 13 Aug 2022 21:36:42 +1200 Message-Id: <20220813093642.7440-3-luke@ljones.dev> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220813093642.7440-1-luke@ljones.dev> References: <20220813093642.7440-1-luke@ljones.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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-wm= i.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; =20 enum fan_type fan_type; + enum fan_type gpu_fan_type; int fan_pwm_mode; + int gpu_fan_pwm_mode; int agfn_pwm; =20 bool fan_boost_mode_available; @@ -1750,6 +1752,18 @@ static int asus_fan_set_auto(struct asus_wmi *asus) return -ENXIO; } =20 + /* + * Modern models like the G713 also have GPU fan control (this is not AGF= N) + */ + if (asus->gpu_fan_type =3D=3D FAN_TYPE_SPEC83) { + status =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_FAN_CTRL, + 0, &retval); + if (status) + return status; + + if (retval !=3D 1) + return -EIO; + } =20 return 0; } @@ -1952,9 +1966,57 @@ static ssize_t asus_hwmon_temp1(struct device *dev, deci_kelvin_to_millicelsius(value & 0xFFFF)); } =20 +/* 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 =3D 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 =3D dev_get_drvdata(dev); + int state; + int value; + int ret; + u32 retval; + + ret =3D kstrtouint(buf, 10, &state); + if (ret) + return ret; + + switch (state) { /* standard documented hwmon values */ + case ASUS_FAN_CTRL_FULLSPEED: + value =3D 1; + break; + case ASUS_FAN_CTRL_AUTO: + value =3D 0; + break; + default: + return -EINVAL; + } + + ret =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_FAN_CTRL, + value, &retval); + if (ret) + return ret; + + if (retval !=3D 1) + return -EIO; + + asus->gpu_fan_pwm_mode =3D 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); =20 @@ -1964,6 +2026,7 @@ static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_t= emp1, NULL); static struct attribute *hwmon_attributes[] =3D { &dev_attr_pwm1.attr, &dev_attr_pwm1_enable.attr, + &dev_attr_pwm2_enable.attr, &dev_attr_fan1_input.attr, &dev_attr_fan1_label.attr, =20 @@ -1986,6 +2049,9 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kob= ject *kobj, || attr =3D=3D &dev_attr_pwm1_enable.attr) { if (asus->fan_type =3D=3D FAN_TYPE_NONE) return 0; + } else if (attr =3D=3D &dev_attr_pwm2_enable.attr) { + if (asus->gpu_fan_type =3D=3D FAN_TYPE_NONE) + return 0; } else if (attr =3D=3D &dev_attr_temp1_input.attr) { int err =3D asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_THERMAL_CTRL, @@ -2028,6 +2094,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus) =20 static int asus_wmi_fan_init(struct asus_wmi *asus) { + asus->gpu_fan_type =3D FAN_TYPE_NONE; asus->fan_type =3D FAN_TYPE_NONE; asus->agfn_pwm =3D -1; =20 @@ -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 =3D FAN_TYPE_AGFN; =20 + /* 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 =3D FAN_TYPE_SPEC83; + if (asus->fan_type =3D=3D FAN_TYPE_NONE) return -ENODEV; =20 diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_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 =20 --=20 2.37.1