aboutsummaryrefslogtreecommitdiff
path: root/SOURCES/asus-linux.patch
diff options
context:
space:
mode:
Diffstat (limited to 'SOURCES/asus-linux.patch')
-rw-r--r--SOURCES/asus-linux.patch337
1 files changed, 51 insertions, 286 deletions
diff --git a/SOURCES/asus-linux.patch b/SOURCES/asus-linux.patch
index cc36d1b..947accc 100644
--- a/SOURCES/asus-linux.patch
+++ b/SOURCES/asus-linux.patch
@@ -1925,28 +1925,28 @@ index 3d861477cb20..7dd580fdc61c 100644
--
2.37.2
-From e6529e0ad6942bb0eadc5f5ad0590124153e0a8c Mon Sep 17 00:00:00 2001
+From 802dfc514194e5459397f513b202031228b3315a Mon Sep 17 00:00:00 2001
From: "Luke D. Jones" <luke@ljones.dev>
-Date: Wed, 3 Aug 2022 11:02:05 +1200
-Subject: [PATCH 1/1] HID: amd_sfh: Add keyguard for ASUS ROG X13 tablet
+Date: Fri, 26 Aug 2022 12:25:12 +1200
+Subject: [PATCH 19/19] HID: amd_sfh: Add keyguard for ASUS ROG X13 tablet
Add support for ROG X13 Flow 2-in-1 to disable the keyboard when
the lid is flipped.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 7 ++++-
+ drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 +++
drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 +
.../hid_descriptor/amd_sfh_hid_desc.c | 27 +++++++++++++++++++
- .../hid_descriptor/amd_sfh_hid_desc.h | 9 +++++++
+ .../hid_descriptor/amd_sfh_hid_desc.h | 8 ++++++
.../hid_descriptor/amd_sfh_hid_report_desc.h | 19 +++++++++++++
- 5 files changed, 62 insertions(+), 1 deletion(-)
+ 5 files changed, 59 insertions(+)
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
-index dadc491bbf6b..243541d426d8 100644
+index 4b90c86ee5f8..0f4db2ce076e 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
-@@ -26,6 +26,7 @@
+@@ -27,6 +27,7 @@
#define ACEL_EN BIT(0)
#define GYRO_EN BIT(1)
#define MAGNO_EN BIT(2)
@@ -1954,7 +1954,7 @@ index dadc491bbf6b..243541d426d8 100644
#define HPD_EN BIT(16)
#define ALS_EN BIT(19)
-@@ -232,6 +233,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
+@@ -233,6 +234,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
if (HPD_EN & activestatus)
sensor_id[num_of_sensors++] = HPD_IDX;
@@ -1964,33 +1964,23 @@ index dadc491bbf6b..243541d426d8 100644
return num_of_sensors;
}
-@@ -373,7 +377,8 @@ static int __maybe_unused amd_mp2_pci_suspend(struct device *dev)
-
- for (i = 0; i < cl_data->num_hid_devices; i++) {
- if (cl_data->sensor_idx[i] != HPD_IDX &&
-- cl_data->sensor_sts[i] == SENSOR_ENABLED) {
-+ cl_data->sensor_idx[i] != KBGUARD_IDX &&
-+ cl_data->sensor_sts[i] == SENSOR_ENABLED) {
- mp2->mp2_ops->stop(mp2, cl_data->sensor_idx[i]);
- status = amd_sfh_wait_for_response
- (mp2, cl_data->sensor_idx[i], SENSOR_DISABLED);
diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
-index 8c760526132a..4a86bc6038a2 100644
+index dfb7cabd82ef..5fa15eed43f3 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
-@@ -36,6 +36,7 @@
- #define SENSOR_DISABLED 5
+@@ -23,6 +23,7 @@
+ #define V2_STATUS 0x2
#define HPD_IDX 16
+#define KBGUARD_IDX 15
- #define AMD_SFH_IDLE_LOOP 200
-
+ #define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3)
+ #define SENSOR_DISCOVERY_STATUS_SHIFT 3
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
-index 76095bd53c65..f41d28ea7b93 100644
+index f9a8c02d5a7b..06487eb75dc8 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
-@@ -57,6 +57,11 @@ int get_report_descriptor(int sensor_idx, u8 *rep_desc)
+@@ -57,6 +57,11 @@ static int get_report_descriptor(int sensor_idx, u8 *rep_desc)
memcpy(rep_desc, hpd_report_descriptor,
sizeof(hpd_report_descriptor));
break;
@@ -2002,7 +1992,7 @@ index 76095bd53c65..f41d28ea7b93 100644
default:
break;
}
-@@ -116,6 +121,16 @@ u32 get_descr_sz(int sensor_idx, int descriptor_name)
+@@ -116,6 +121,16 @@ static u32 get_descr_sz(int sensor_idx, int descriptor_name)
return sizeof(struct hpd_feature_report);
}
break;
@@ -2019,7 +2009,7 @@ index 76095bd53c65..f41d28ea7b93 100644
default:
break;
-@@ -139,6 +154,7 @@ u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
+@@ -139,6 +154,7 @@ static u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
struct gyro_feature_report gyro_feature;
struct magno_feature_report magno_feature;
struct hpd_feature_report hpd_feature;
@@ -2027,7 +2017,7 @@ index 76095bd53c65..f41d28ea7b93 100644
struct als_feature_report als_feature;
u8 report_size = 0;
-@@ -186,6 +202,11 @@ u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
+@@ -186,6 +202,11 @@ static u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
memcpy(feature_report, &hpd_feature, sizeof(hpd_feature));
report_size = sizeof(hpd_feature);
break;
@@ -2039,7 +2029,7 @@ index 76095bd53c65..f41d28ea7b93 100644
default:
break;
-@@ -210,6 +231,7 @@ u8 get_input_report(u8 current_index, int sensor_idx, int report_id, struct amd_
+@@ -211,6 +232,7 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
struct accel3_input_report acc_input;
struct gyro_input_report gyro_input;
struct hpd_input_report hpd_input;
@@ -2047,7 +2037,7 @@ index 76095bd53c65..f41d28ea7b93 100644
struct als_input_report als_input;
struct hpd_status hpdstatus;
u8 report_size = 0;
-@@ -262,6 +284,11 @@ u8 get_input_report(u8 current_index, int sensor_idx, int report_id, struct amd_
+@@ -263,6 +285,11 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
report_size = sizeof(hpd_input);
memcpy(input_report, &hpd_input, sizeof(hpd_input));
break;
@@ -2060,31 +2050,22 @@ index 76095bd53c65..f41d28ea7b93 100644
break;
}
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
-index 70b1b7abe2c6..98571a8597b3 100644
+index ebd55675eb62..2f2ba9a0cfbc 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
-@@ -105,12 +105,21 @@ struct hpd_feature_report {
- struct common_feature_property common_property;
+@@ -111,4 +111,12 @@ struct hpd_input_report {
+ u8 human_presence;
} __packed;
+struct kbguard_feature_report {
+ struct common_feature_property common_property;
+} __packed;
+
- struct hpd_input_report {
- struct common_input_property common_property;
- /* values specific to human presence sensor */
- u8 human_presence;
- } __packed;
-
+struct kbguard_input_report {
+ struct common_input_property common_property;
+} __packed;
+
-+
- int get_report_descriptor(int sensor_idx, u8 rep_desc[]);
- u32 get_descr_sz(int sensor_idx, int descriptor_name);
- u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report);
+ #endif
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
index 697f2791ea9c..7a62fcec2c73 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
@@ -2116,7 +2097,7 @@ index 697f2791ea9c..7a62fcec2c73 100644
static const u8 hpd_report_descriptor[] = {
0x05, 0x20, /* Usage page */
--
-2.37.1
+2.37.2
From 3f73788b14ada783657e5e6303c4e5de5e096be5 Mon Sep 17 00:00:00 2001
From: "Luke D. Jones" <luke@ljones.dev>
@@ -2179,17 +2160,27 @@ index f608a4467d99..ea45e10302f7 100644
--
2.37.2
+From fe443cc4ff4e12652af1cdae63cff354a2467b67 Mon Sep 17 00:00:00 2001
+From: "Luke D. Jones" <luke@ljones.dev>
+Date: Fri, 26 Aug 2022 12:34:02 +1200
+Subject: [PATCH 21/21] asus-wmi: Support the GPU fan on TUF laptops
+
+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 ac06fec0565c..2a74e468591a 100644
+index ea45e10302f7..d05684194f2d 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
-@@ -221,7 +221,9 @@ struct asus_wmi {
- struct asus_rfkill uwb;
+@@ -226,7 +226,9 @@ struct asus_wmi {
+ u32 tablet_switch_dev_id;
enum fan_type fan_type;
+ enum fan_type gpu_fan_type;
@@ -2198,12 +2189,12 @@ index ac06fec0565c..2a74e468591a 100644
int agfn_pwm;
bool fan_boost_mode_available;
-@@ -1757,6 +1759,18 @@ static int asus_fan_set_auto(struct asus_wmi *asus)
+@@ -1861,6 +1863,18 @@ static int asus_fan_set_auto(struct asus_wmi *asus)
return -ENXIO;
}
+ /*
-+ * Modern models like G713 also have GPU fan control. This is not AGFN.
++ * 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,
@@ -2217,7 +2208,7 @@ index ac06fec0565c..2a74e468591a 100644
return 0;
}
-@@ -1959,9 +1973,57 @@ static ssize_t asus_hwmon_temp1(struct device *dev,
+@@ -2063,9 +2077,57 @@ static ssize_t asus_hwmon_temp1(struct device *dev,
deci_kelvin_to_millicelsius(value & 0xFFFF));
}
@@ -2228,7 +2219,7 @@ index ac06fec0565c..2a74e468591a 100644
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
-+ return sprintf(buf, "%d\n", asus->gpu_fan_pwm_mode);
++ return sysfs_emit(buf, "%d\n", asus->gpu_fan_pwm_mode);
+}
+
+static ssize_t pwm2_enable_store(struct device *dev,
@@ -2275,7 +2266,7 @@ index ac06fec0565c..2a74e468591a 100644
static DEVICE_ATTR_RO(fan1_input);
static DEVICE_ATTR_RO(fan1_label);
-@@ -1971,6 +2033,7 @@ static DEVICE_ATTR(temp1_input, S_IRUGO, asus_hwmon_temp1, NULL);
+@@ -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,
@@ -2283,7 +2274,7 @@ index ac06fec0565c..2a74e468591a 100644
&dev_attr_fan1_input.attr,
&dev_attr_fan1_label.attr,
-@@ -1993,6 +2056,9 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,
+@@ -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;
@@ -2293,7 +2284,7 @@ index ac06fec0565c..2a74e468591a 100644
} else if (attr == &dev_attr_temp1_input.attr) {
int err = asus_wmi_get_devstate(asus,
ASUS_WMI_DEVID_THERMAL_CTRL,
-@@ -2035,6 +2101,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus)
+@@ -2139,6 +2205,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus)
static int asus_wmi_fan_init(struct asus_wmi *asus)
{
@@ -2301,7 +2292,7 @@ index ac06fec0565c..2a74e468591a 100644
asus->fan_type = FAN_TYPE_NONE;
asus->agfn_pwm = -1;
-@@ -2043,6 +2110,10 @@ static int asus_wmi_fan_init(struct asus_wmi *asus)
+@@ -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;
@@ -2313,10 +2304,10 @@ index ac06fec0565c..2a74e468591a 100644
return -ENODEV;
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
-index a571b47ff362..bcffb77371be 100644
+index 7dd580fdc61c..28234dc9fa6a 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
-@@ -77,6 +77,7 @@
+@@ -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
@@ -2325,9 +2316,9 @@ index a571b47ff362..bcffb77371be 100644
#define ASUS_WMI_DEVID_GPU_FAN_CURVE 0x00110025
--
-2.37.1
+2.37.2
- From ded47e7197a4ce9d6c34c0c96c6551ecaca0b6bd Mon Sep 17 00:00:00 2001
+From ded47e7197a4ce9d6c34c0c96c6551ecaca0b6bd Mon Sep 17 00:00:00 2001
From: "Luke D. Jones" <luke@ljones.dev>
Date: Fri, 16 Sep 2022 11:17:16 +1200
Subject: [PATCH] asus-wmi: Expand support of GPU fan to read RPM and label
@@ -2423,229 +2414,3 @@ index ae46af731de9..7fe6ce25da0a 100644
--
2.37.3
-From c104c26a25de7faf6c1fce3d05806d1766721798 Mon Sep 17 00:00:00 2001
-From: "Luke D. Jones" <luke@ljones.dev>
-Date: Mon, 10 Oct 2022 20:00:26 +1300
-Subject: [PATCH] ALSA: hda/realtek: Add quirk for ASUS GV601R laptop
-
-The ASUS ROG X16 (GV601R) series laptop has the same node-to-DAC pairs
-as early models and the G14, this includes bass speakers which are by
-default mapped incorrectly to the 0x06 node.
-
-Add a quirk to use the same DAC pairs as the G14.
-
-Signed-off-by: Luke D. Jones <luke@ljones.dev>
----
- sound/pci/hda/patch_realtek.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
-index bce82b834cec..1ffea762ba57 100644
---- a/sound/pci/hda/patch_realtek.c
-+++ b/sound/pci/hda/patch_realtek.c
-@@ -9422,6 +9422,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
- SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
- SND_PCI_QUIRK(0x1043, 0x1c52, "ASUS Zephyrus G15 2022", ALC289_FIXUP_ASUS_GA401),
- SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
-+ SND_PCI_QUIRK(0x1043, 0x1f92, "ASUS ROG Flow X16", ALC289_FIXUP_ASUS_GA401),
- SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
- SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
- SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
---
-2.37.3
-
-From 4e55d420b8f311a5d93367e8598c7d1590eff4cf Mon Sep 17 00:00:00 2001
-From: "Luke D. Jones" <luke@ljones.dev>
-Date: Mon, 10 Oct 2022 19:51:57 +1300
-Subject: [PATCH] Fixes bc2c23549ccd ("ALSA: hda/realtek: Add pincfg for ASUS
- G533Z HP jack")
-
-The initial fix for ASUS G533Z was based on faulty information. This
-fixes the pincfg to values that have been verified with no existing
-module options or other hacks enabled.
-
-Enables headphone jack, and 5.1 surround.
-
-Signed-off-by: Luke D. Jones <luke@ljones.dev>
----
- sound/pci/hda/patch_realtek.c | 10 ++++++----
- 1 file changed, 6 insertions(+), 4 deletions(-)
-
-diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
-index bce82b834cec..24406f81da27 100644
---- a/sound/pci/hda/patch_realtek.c
-+++ b/sound/pci/hda/patch_realtek.c
-@@ -8449,11 +8449,13 @@ static const struct hda_fixup alc269_fixups[] = {
- [ALC285_FIXUP_ASUS_G533Z_PINS] = {
- .type = HDA_FIXUP_PINS,
- .v.pins = (const struct hda_pintbl[]) {
-- { 0x14, 0x90170120 },
-- { }
-+ { 0x14, 0x90170152 }, /* Speaker Surround Playback Switch */
-+ { 0x19, 0x03a19020 }, /* Mic Boost Volume */
-+ { 0x1a, 0x03a11c30 }, /* Mic Boost Volume */
-+ { 0x1e, 0x90170151 }, /* Rear jack, IN OUT EAPD Detect */
-+ { 0x21, 0x03211420 },
-+ { }
- },
-- .chained = true,
-- .chain_id = ALC294_FIXUP_ASUS_G513_PINS,
- },
- [ALC294_FIXUP_ASUS_COEF_1B] = {
- .type = HDA_FIXUP_VERBS,
---
-2.37.3
-
-From ef5a27e01610251d6b91e3bdcf297246414b40ce Mon Sep 17 00:00:00 2001
-From: "Luke D. Jones" <luke@ljones.dev>
-Date: Mon, 10 Oct 2022 19:27:51 +1300
-Subject: [PATCH] platform/x86: asus-wmi: Add support for ROG X16 tablet mode
-
-Add quirk for ASUS ROG X16 Flow 2-in-1 to enable tablet mode with
-lid flip (all screen rotations).
-
-Signed-off-by: Luke D. Jones <luke@ljones.dev>
----
- drivers/platform/x86/asus-nb-wmi.c | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
-index 613c45c9fbe3..c685a705b73d 100644
---- a/drivers/platform/x86/asus-nb-wmi.c
-+++ b/drivers/platform/x86/asus-nb-wmi.c
-@@ -464,6 +464,15 @@ static const struct dmi_system_id asus_quirks[] = {
- },
- .driver_data = &quirk_asus_tablet_mode,
- },
-+ {
-+ .callback = dmi_matched,
-+ .ident = "ASUS ROG FLOW X16",
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "GV601R"),
-+ },
-+ .driver_data = &quirk_asus_tablet_mode,
-+ },
- {},
- };
-
---
-2.37.3
-
-From 9eccb147466f00a13c593ac078d8639e1eafe3a2 Mon Sep 17 00:00:00 2001
-From: "Luke D. Jones" <luke@ljones.dev>
-Date: Fri, 14 Oct 2022 10:43:09 +1300
-Subject: [PATCH] platform/x86: asus-wmi: Add safety checks to dgpu/egpu/mux
- methods
-
-The WMI methods for dgpu_disable, egpu_enable, and gpu_mux_mode have
-no internal safety checks. This means it is possible for a user to
-set the gpu mux to discreet mode and then disable the dgpu, resulting
-in the user having no screen and very little chance of recovery.
-
-This commit adds checks to dgpu_disable and egpu_enable to ensure that
-the dgpu can not be disabled if the MUX is in discreet mode, and a
-check to gpu_mux_mode to prevent switching to discreet mode if
-dgpu_disable is set.
-
-Signed-off-by: Luke D. Jones <luke@ljones.dev>
----
- drivers/platform/x86/asus-wmi.c | 38 +++++++++++++++++++++++++++++++++
- 1 file changed, 38 insertions(+)
-
-diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
-index 6e8e093f96b3..1afc4d40fa1a 100644
---- a/drivers/platform/x86/asus-wmi.c
-+++ b/drivers/platform/x86/asus-wmi.c
-@@ -615,6 +615,18 @@ static ssize_t dgpu_disable_store(struct device *dev,
- if (disable > 1)
- return -EINVAL;
-
-+ /*
-+ * The GPU MUX must be checked first, if it is in discreet mode the
-+ * dgpu_disable cannot be set to on or users can end up with no screen.
-+ */
-+ result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX);
-+ if (result < 0)
-+ return result;
-+ if (!result && disable) {
-+ pr_warn("ASUS MUX is in discreet mode, can not set dgpu_disable on\n");
-+ return -EINVAL;
-+ }
-+
- err = asus_wmi_set_devstate(ASUS_WMI_DEVID_DGPU, disable, &result);
- if (err) {
- pr_warn("Failed to set dgpu disable: %d\n", err);
-@@ -663,6 +675,19 @@ static ssize_t egpu_enable_store(struct device *dev,
- if (enable > 1)
- return -EINVAL;
-
-+ /*
-+ * The GPU MUX must be checked first, if it is in discreet mode the
-+ * egpu_enable cannot be set to on or users can end up with no screen.
-+ * Note: egpu_enable method in WMI also sets dgpu_disable to on.
-+ */
-+ result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX);
-+ if (result < 0)
-+ return result;
-+ if (!result && enable) {
-+ pr_warn("ASUS MUX is in discreet mode, can not set egpu_enable on\n");
-+ return -EINVAL;
-+ }
-+
- err = asus_wmi_set_devstate(ASUS_WMI_DEVID_EGPU, enable, &result);
- if (err) {
- pr_warn("Failed to set egpu disable: %d\n", err);
-@@ -709,6 +734,19 @@ static ssize_t gpu_mux_mode_store(struct device *dev,
- if (optimus > 1)
- return -EINVAL;
-
-+ /*
-+ * The dgpu_disable must be checked first, if it is enabled the
-+ * gpu MUX can not be set to 0 or users can end up with no screen.
-+ * Note: egpu_enable also switches dgpu_disable to 1 if enabled.
-+ */
-+ result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_DGPU);
-+ if (result < 0)
-+ return result;
-+ if (result && !optimus) {
-+ pr_warn("ASUS dgpu_disable is set, can not switch MUX to discreet mode\n");
-+ return -EINVAL;
-+ }
-+
- err = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_MUX, optimus, &result);
- if (err) {
- dev_err(dev, "Failed to set GPU MUX mode: %d\n", err);
---
-2.37.3
-
-From f1c38428ff75d0f3956615bea69a43b8b6812414 Mon Sep 17 00:00:00 2001
-From: "Luke D. Jones" <luke@ljones.dev>
-Date: Fri, 14 Oct 2022 13:03:36 +1300
-Subject: [PATCH] platform/x86: asus-wmi: Check for reboot required in
- dgpu_disable methods
-
-Signed-off-by: Luke D. Jones <luke@ljones.dev>
----
- drivers/platform/x86/asus-wmi.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
-index 1afc4d40fa1a..5d5c473541bd 100644
---- a/drivers/platform/x86/asus-wmi.c
-+++ b/drivers/platform/x86/asus-wmi.c
-@@ -633,6 +633,11 @@ static ssize_t dgpu_disable_store(struct device *dev,
- return err;
- }
-
-+ if (result == 2) {
-+ pr_warn("Failed to set dgpu disable, reboot is required\n");
-+ return -2;
-+ }
-+
- if (result > 1) {
- pr_warn("Failed to set dgpu disable (result): 0x%x\n", result);
- return -EIO;
---
-2.37.3
-