diff --git a/patches/asus2.patch b/patches/asus2.patch index 9574344..65dc6af 100644 --- a/patches/asus2.patch +++ b/patches/asus2.patch @@ -1,7 +1,7 @@ -From fbeb8e1f27193acf368a6f67ecd8cfa203630fd8 Mon Sep 17 00:00:00 2001 +From edf9057aca96335e527e9854e474c85e97697788 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Tue, 17 Dec 2024 09:31:08 +1300 -Subject: [PATCH 01/30] Tmp: add GA605W & H7606W to AMD-PMF quirks. +Subject: [PATCH 01/28] Tmp: add GA605W & H7606W to AMD-PMF quirks. This will not be submitted upstream as the entire quirk system is being removed in 6.14 kernel. @@ -42,10 +42,10 @@ index 7cde5733b9ca..02b9d0b49092 100644 2.48.1 -From 47f9536d4c5c60dca429fdbdbb17acec050776c9 Mon Sep 17 00:00:00 2001 +From f2bcf1ee4c0bedfdc7e7611887372b62edd8a172 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 21 Jan 2025 16:03:52 -0600 -Subject: [PATCH 02/30] drm/amd/display: Avoid divide by zero by initializing +Subject: [PATCH 02/28] drm/amd/display: Avoid divide by zero by initializing dummy pitch to 1 If the dummy values in `populate_dummy_dml_surface_cfg()` aren't updated @@ -74,18 +74,24 @@ index bde4250853b1..f07afe451006 100644 2.48.1 -From 5647afafd922de05d1d3c7e9da03cd5dabac0706 Mon Sep 17 00:00:00 2001 +From 69c51952964f756a95d980944a446e42c7ca3b95 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Tue, 28 Jan 2025 19:29:27 +1300 -Subject: [PATCH 05/30] hid-asus: check ROG Ally MCU version and warn +Subject: [PATCH 04/28] hid-asus: check ROG Ally MCU version and warn + +ASUS have fixed suspend issues arising from a flag not being cleared in +the MCU FW in both the ROG Ally 1 and the ROG Ally X. + +Implement a check and a warning to encourage users to update the FW to +a minimum supported version. Signed-off-by: Luke D. Jones --- - drivers/hid/hid-asus.c | 97 +++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 95 insertions(+), 2 deletions(-) + drivers/hid/hid-asus.c | 107 ++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 105 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c -index 46e3e42f9eb5..040eeb25f706 100644 +index 46e3e42f9eb5..599c836507ff 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -52,6 +52,10 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); @@ -107,85 +113,95 @@ index 46e3e42f9eb5..040eeb25f706 100644 #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ QUIRK_NO_INIT_REPORTS | \ -@@ -534,9 +539,89 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev) +@@ -534,9 +539,99 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev) return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT); } +/* + * We don't care about any other part of the string except the version section. + * Example strings: FGA80100.RC72LA.312_T01, FGA80100.RC71LS.318_T01 ++ * The bytes "5a 05 03 31 00 1a 13" and possibly more come before the version ++ * string, and there may be additional bytes after the version string such as ++ * "75 00 74 00 65 00" or a postfix such as "_T01" + */ +static int mcu_parse_version_string(const u8 *response, size_t response_size) +{ -+ int dot_count = 0; -+ size_t i; ++ const u8 *end = response + response_size; ++ const u8 *p = response; ++ int dots, err, version; ++ char buf[4]; + -+ // Look for the second '.' to identify the start of the version -+ for (i = 0; i < response_size; i++) { -+ if (response[i] == '.') { -+ dot_count++; -+ if (dot_count == 2) { -+ int version = -+ simple_strtol((const char *)&response[i + 1], NULL, 10); -+ return (version >= 0) ? version : -EINVAL; -+ } -+ } ++ dots = 0; ++ while (p < end && dots < 2) { ++ if (*p++ == '.') ++ dots++; + } + -+ return -EINVAL; ++ if (dots != 2 || p >= end || (p + 3) >= end) ++ return -EINVAL; ++ ++ memcpy(buf, p, 3); ++ buf[3] = '\0'; ++ ++ err = kstrtoint(buf, 10, &version); ++ if (err || version < 0) ++ return -EINVAL; ++ ++ return version; +} + +static int mcu_request_version(struct hid_device *hdev) +{ ++ u8 *response __free(kfree) = kzalloc(ROG_ALLY_REPORT_SIZE, GFP_KERNEL); + const u8 request[] = { 0x5a, 0x05, 0x03, 0x31, 0x00, 0x20 }; -+ u8 *response; + int ret; + -+ response = kzalloc(ROG_ALLY_REPORT_SIZE, GFP_KERNEL); + if (!response) + return -ENOMEM; + + ret = asus_kbd_set_report(hdev, request, sizeof(request)); + if (ret < 0) -+ goto out; ++ return ret; + + ret = hid_hw_raw_request(hdev, FEATURE_REPORT_ID, response, + ROG_ALLY_REPORT_SIZE, HID_FEATURE_REPORT, + HID_REQ_GET_REPORT); + if (ret < 0) -+ goto out; ++ return ret; + + ret = mcu_parse_version_string(response, ROG_ALLY_REPORT_SIZE); -+out: -+ if (ret < 0) -+ hid_err(hdev, "Failed to get MCU version: %d\n", ret); -+ kfree(response); ++ if (ret < 0) { ++ pr_err("Failed to parse MCU version: %d\n", ret); ++ print_hex_dump(KERN_ERR, "MCU: ", DUMP_PREFIX_NONE, ++ 16, 1, response, ROG_ALLY_REPORT_SIZE, false); ++ } ++ + return ret; +} + -+static void mcu_maybe_warn_version(struct hid_device *hdev, int idProduct) ++static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct) +{ + int min_version, version; + -+ min_version = ROG_ALLY_X_MIN_MCU; + version = mcu_request_version(hdev); -+ if (version) { -+ switch (idProduct) { -+ case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY: -+ min_version = ROG_ALLY_MIN_MCU; -+ break; -+ case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X: -+ min_version = ROG_ALLY_X_MIN_MCU; -+ break; -+ } ++ if (version < 0) ++ return; ++ ++ switch (idProduct) { ++ case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY: ++ min_version = ROG_ALLY_MIN_MCU; ++ break; ++ case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X: ++ min_version = ROG_ALLY_X_MIN_MCU; ++ break; ++ default: ++ min_version = 0; + } + -+ hid_info(hdev, "Ally device MCU version: %d\n", version); + if (version < min_version) { + hid_warn(hdev, -+ "The MCU version must be %d or greater\n" -+ "Please update your MCU with official ASUS firmware release\n", -+ min_version); ++ "The MCU firmware version must be %d or greater to avoid issues with suspend.\n", ++ min_version); + } +} + @@ -197,7 +213,7 @@ index 46e3e42f9eb5..040eeb25f706 100644 unsigned char kbd_func; int ret; -@@ -560,6 +645,14 @@ static int asus_kbd_register_leds(struct hid_device *hdev) +@@ -560,6 +655,14 @@ static int asus_kbd_register_leds(struct hid_device *hdev) if (ret < 0) return ret; } @@ -205,14 +221,14 @@ index 46e3e42f9eb5..040eeb25f706 100644 + if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) { + intf = to_usb_interface(hdev->dev.parent); + udev = interface_to_usbdev(intf); -+ mcu_maybe_warn_version(hdev, ++ validate_mcu_fw_version(hdev, + le16_to_cpu(udev->descriptor.idProduct)); + } + } else { /* Initialize keyboard */ ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID); -@@ -1280,10 +1373,10 @@ static const struct hid_device_id asus_devices[] = { +@@ -1280,10 +1383,10 @@ static const struct hid_device_id asus_devices[] = { QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD }, { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY), @@ -229,32 +245,57 @@ index 46e3e42f9eb5..040eeb25f706 100644 2.48.1 -From 68734910f718009aec4ce2e60d97430f4acc7b64 Mon Sep 17 00:00:00 2001 +From be09c4e5184f8c73fcaf4e396cda23d097fa4693 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 1 Sep 2024 14:30:37 +1200 -Subject: [PATCH 06/30] platform/x86: asus-wmi: Refactor Ally suspend/resume +Subject: [PATCH 05/28] platform/x86: asus-wmi: Refactor Ally suspend/resume -The CSEE method from ACPI is now called only on module load. This fixes -an issues with USB device loss on Ally 1 after reboot. +Adjust how the CSEE direct call hack is used. -Both Ally 1 and Ally X now rely only of the _DSM screen off/on calls -exposed in AMD s2idle to call the CSEE (which is done in the _DSM), plus -a small additional delay to allow the MCU time to do USB unplug/plug. +The results of months of testing combined with help from ASUS to +determine the actual cause of suspend issues has resulted in this +refactoring which immensely improves the reliability for devices which +do not have the following minimum MCU FW version: +- ROG Ally X: 313 +- ROG Ally 1: 319 -Note: a new MCU FW is being released on 2024/10/16 which will completely -fix the issue this quirk series has been trying to fix, and it will be -able to be removed in full some time in the future. This quirk series -has also been tested with a test version of this FW fix with no ill -effects - users will notice only that powersave becomes reliable 100% of -the time. +For MCU FW versions that match the minimum or above the CSEE hack is +disabled and mcu_powersave set to on by default as there are no +negatives beyond a slightly slower device reinitialization due to the +MCU being powered off. + +As this is set only at module load time, it is still possible for +mcu_powersave sysfs attributes to change it at runtime if so desired. Signed-off-by: Luke D. Jones --- - drivers/platform/x86/asus-wmi.c | 86 ++++++++++++++++++--------------- - 1 file changed, 48 insertions(+), 38 deletions(-) + drivers/hid/hid-asus.c | 4 + + drivers/platform/x86/asus-wmi.c | 130 ++++++++++++++------- + include/linux/platform_data/x86/asus-wmi.h | 15 +++ + 3 files changed, 110 insertions(+), 39 deletions(-) +diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c +index 599c836507ff..66bae5cea4f9 100644 +--- a/drivers/hid/hid-asus.c ++++ b/drivers/hid/hid-asus.c +@@ -624,6 +624,9 @@ static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct) + hid_warn(hdev, + "The MCU firmware version must be %d or greater to avoid issues with suspend.\n", + min_version); ++ } else { ++ set_ally_mcu_hack(false); ++ set_ally_mcu_powersave(true); + } + } + +@@ -1430,4 +1433,5 @@ static struct hid_driver asus_driver = { + }; + module_hid_driver(asus_driver); + ++MODULE_IMPORT_NS("ASUS_WMI"); + MODULE_LICENSE("GPL"); diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index 8bd187e8b47f..5033dd45103c 100644 +index 8bd187e8b47f..671c726f85b8 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -142,16 +142,20 @@ module_param(fnlock_default, bool, 0444); @@ -292,34 +333,90 @@ index 8bd187e8b47f..5033dd45103c 100644 enum fan_type fan_type; enum fan_type gpu_fan_type; enum fan_type mid_fan_type; -@@ -335,6 +336,8 @@ struct asus_wmi { +@@ -335,6 +336,9 @@ struct asus_wmi { struct asus_wmi_driver *driver; }; -+static bool ally_mcu_usb_plug; ++/* Global to allow setting externally without requiring driver data */ ++static bool use_ally_mcu_hack; + /* WMI ************************************************************************/ static int asus_wmi_evaluate_method3(u32 method_id, -@@ -4707,6 +4710,17 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -549,7 +553,7 @@ static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval) + return 0; + } + +-static int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, ++int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, + u32 *retval) + { + return asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS, dev_id, +@@ -1343,6 +1347,44 @@ static ssize_t nv_temp_target_show(struct device *dev, + static DEVICE_ATTR_RW(nv_temp_target); + + /* Ally MCU Powersave ********************************************************/ ++ ++/* ++ * The HID driver needs to check MCU version and set this to false if the MCU FW ++ * version is >= the minimum requirements. New FW do not need the hacks. ++ */ ++void set_ally_mcu_hack(bool enabled) ++{ ++ use_ally_mcu_hack = enabled; ++ pr_debug("%s Ally MCU suspend quirk\n", ++ enabled ? "Enabled" : "Disabled"); ++} ++EXPORT_SYMBOL_NS_GPL(set_ally_mcu_hack, "ASUS_WMI"); ++ ++/* ++ * mcu_powersave should be enabled always, as it is fixed in MCU FW versions: ++ * - v313 for Ally X ++ * - v319 for Ally 1 ++ * The HID driver checks MCU versions and so should set this if requirements match ++ */ ++void set_ally_mcu_powersave(bool enabled) ++{ ++ int result, err; ++ ++ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MCU_POWERSAVE, enabled, &result); ++ if (err) { ++ pr_warn("Failed to set MCU powersave: %d\n", err); ++ return; ++ } ++ if (result > 1) { ++ pr_warn("Failed to set MCU powersave (result): 0x%x\n", result); ++ return; ++ } ++ ++ pr_debug("%s MCU Powersave\n", ++ enabled ? "Enabled" : "Disabled"); ++} ++EXPORT_SYMBOL_NS_GPL(set_ally_mcu_powersave, "ASUS_WMI"); ++ + static ssize_t mcu_powersave_show(struct device *dev, + struct device_attribute *attr, char *buf) + { +@@ -4707,6 +4749,18 @@ static int asus_wmi_add(struct platform_device *pdev) if (err) goto fail_platform; -+ ally_mcu_usb_plug = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) ++ use_ally_mcu_hack = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) + && dmi_check_system(asus_rog_ally_device); -+ if (ally_mcu_usb_plug) { ++ if (use_ally_mcu_hack && dmi_match(DMI_BOARD_NAME, "RC71")) { + /* + * These steps ensure the device is in a valid good state, this is + * especially important for the Ally 1 after a reboot. + */ -+ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ASUS_USB0_PWR_EC0_CSEE_ON); ++ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ++ ASUS_USB0_PWR_EC0_CSEE_ON); + msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT); + } + /* ensure defaults for tunables */ asus->ppt_pl2_sppt = 5; asus->ppt_pl1_spl = 5; -@@ -4719,8 +4733,6 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -4719,8 +4773,6 @@ static int asus_wmi_add(struct platform_device *pdev) asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); @@ -328,7 +425,7 @@ index 8bd187e8b47f..5033dd45103c 100644 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE)) asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE; -@@ -4911,34 +4923,6 @@ static int asus_hotk_resume(struct device *device) +@@ -4911,34 +4963,6 @@ static int asus_hotk_resume(struct device *device) return 0; } @@ -363,22 +460,24 @@ index 8bd187e8b47f..5033dd45103c 100644 static int asus_hotk_restore(struct device *device) { struct asus_wmi *asus = dev_get_drvdata(device); -@@ -4979,11 +4963,32 @@ static int asus_hotk_restore(struct device *device) +@@ -4979,11 +5003,34 @@ static int asus_hotk_restore(struct device *device) return 0; } +static void asus_ally_s2idle_restore(void) +{ -+ if (ally_mcu_usb_plug) { -+ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ASUS_USB0_PWR_EC0_CSEE_ON); ++ if (use_ally_mcu_hack) { ++ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ++ ASUS_USB0_PWR_EC0_CSEE_ON); + msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT); + } +} + +static int asus_hotk_prepare(struct device *device) +{ -+ if (ally_mcu_usb_plug) { -+ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ASUS_USB0_PWR_EC0_CSEE_OFF); ++ if (use_ally_mcu_hack) { ++ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ++ ASUS_USB0_PWR_EC0_CSEE_OFF); + msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT); + } + return 0; @@ -397,7 +496,7 @@ index 8bd187e8b47f..5033dd45103c 100644 .prepare = asus_hotk_prepare, }; -@@ -5011,6 +5016,10 @@ static int asus_wmi_probe(struct platform_device *pdev) +@@ -5011,6 +5058,10 @@ static int asus_wmi_probe(struct platform_device *pdev) return ret; } @@ -408,7 +507,7 @@ index 8bd187e8b47f..5033dd45103c 100644 return asus_wmi_add(pdev); } -@@ -5043,6 +5052,7 @@ EXPORT_SYMBOL_GPL(asus_wmi_register_driver); +@@ -5043,6 +5094,7 @@ EXPORT_SYMBOL_GPL(asus_wmi_register_driver); void asus_wmi_unregister_driver(struct asus_wmi_driver *driver) { @@ -416,83 +515,29 @@ index 8bd187e8b47f..5033dd45103c 100644 platform_device_unregister(driver->platform_device); platform_driver_unregister(&driver->platform_driver); used = false; --- -2.48.1 - - -From cf54f159d77c17b2524c1686673e081f225ed4ce Mon Sep 17 00:00:00 2001 -From: Luke Jones -Date: Tue, 11 Feb 2025 00:05:08 +1300 -Subject: [PATCH 07/30] hid-asus: set mcu hack to off if required MCU version - -Signed-off-by: Luke Jones ---- - drivers/hid/hid-asus.c | 3 +++ - drivers/platform/x86/asus-wmi.c | 12 +++++++++++- - include/linux/platform_data/x86/asus-wmi.h | 4 ++++ - 3 files changed, 18 insertions(+), 1 deletion(-) - -diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c -index 040eeb25f706..93217442b4b6 100644 ---- a/drivers/hid/hid-asus.c -+++ b/drivers/hid/hid-asus.c -@@ -614,6 +614,8 @@ static void mcu_maybe_warn_version(struct hid_device *hdev, int idProduct) - "The MCU version must be %d or greater\n" - "Please update your MCU with official ASUS firmware release\n", - min_version); -+ } else { -+ set_ally_mcu_hack_available(false); - } - } - -@@ -1420,4 +1422,5 @@ static struct hid_driver asus_driver = { - }; - module_hid_driver(asus_driver); - -+MODULE_IMPORT_NS("ASUS_WMI"); - MODULE_LICENSE("GPL"); -diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index 5033dd45103c..2afb949ac397 100644 ---- a/drivers/platform/x86/asus-wmi.c -+++ b/drivers/platform/x86/asus-wmi.c -@@ -338,6 +338,16 @@ struct asus_wmi { - - static bool ally_mcu_usb_plug; - -+/* -+ * The HID driver needs to check MCU version and set this to false if the MCU FW -+ * version is >= the minimum requirements. New FW do not need the hacks. -+ */ -+void set_ally_mcu_hack_available(bool enabled) -+{ -+ ally_mcu_usb_plug = enabled; -+} -+EXPORT_SYMBOL_NS_GPL(set_ally_mcu_hack_available, "ASUS_WMI"); -+ - /* WMI ************************************************************************/ - - static int asus_wmi_evaluate_method3(u32 method_id, -@@ -4712,7 +4722,7 @@ static int asus_wmi_add(struct platform_device *pdev) - - ally_mcu_usb_plug = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) - && dmi_check_system(asus_rog_ally_device); -- if (ally_mcu_usb_plug) { -+ if (ally_mcu_usb_plug && dmi_match(DMI_BOARD_NAME, "RC71")) { - /* - * These steps ensure the device is in a valid good state, this is - * especially important for the Ally 1 after a reboot. diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index 783e2a336861..f1b96f90e8e2 100644 +index 783e2a336861..a32cb8865b2f 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h -@@ -158,8 +158,12 @@ +@@ -158,8 +158,23 @@ #define ASUS_WMI_DSTS_LIGHTBAR_MASK 0x0000000F #if IS_REACHABLE(CONFIG_ASUS_WMI) -+void set_ally_mcu_hack_available(bool enabled); ++void set_ally_mcu_hack(bool enabled); ++void set_ally_mcu_powersave(bool enabled); ++int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval); int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval); #else -+static inline void set_ally_mcu_hack_available(bool enabled) { ++static inline void set_ally_mcu_hack(bool enabled) ++{ ++ return -ENODEV; ++} ++static inline void set_ally_mcu_powersave(bool enabled) ++{ ++ return -ENODEV; ++} ++static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) ++{ + return -ENODEV; +} static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, @@ -502,25 +547,25 @@ index 783e2a336861..f1b96f90e8e2 100644 2.48.1 -From b6469d0b7d78a725f03f36da3432e915f8a53d86 Mon Sep 17 00:00:00 2001 +From cb18b84648fd740bba4d5bd5146b1fe617a6942c Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Mon, 26 Aug 2024 12:49:35 +1200 -Subject: [PATCH 08/30] hid-asus-ally: Add joystick LED ring support +Subject: [PATCH 06/28] hid-asus-ally: Add joystick LED ring support Adds basic support for the joystick RGB LED rings as a multicolour LED -device with 4 LEDs. - -Move the MCU check in to new driver as it must be done after init, and -hid-asus-ally takes over from hid-asus. +device with 4 LEDs. As this uses the software-mode for setting the LED +colours it also sets the MCU-mode for LED's to static + the first RGB +colour on suspend/reboot/shutdown. This is done to prevent user confusion +if the LED's were to not match what was set, and to maintain consistency. Signed-off-by: Luke D. Jones --- drivers/hid/Kconfig | 9 + drivers/hid/Makefile | 1 + - drivers/hid/hid-asus-ally.c | 619 ++++++++++++++++++++++++++++++++++++ - drivers/hid/hid-asus-ally.h | 38 +++ - drivers/hid/hid-asus.c | 107 +------ - 5 files changed, 681 insertions(+), 93 deletions(-) + drivers/hid/hid-asus-ally.c | 517 ++++++++++++++++++++++++++++++++++++ + drivers/hid/hid-asus-ally.h | 42 +++ + drivers/hid/hid-asus.c | 12 + + 5 files changed, 581 insertions(+) create mode 100644 drivers/hid/hid-asus-ally.c create mode 100644 drivers/hid/hid-asus-ally.h @@ -558,10 +603,10 @@ index 24de45f3677d..f338c9eb4600 100644 obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c new file mode 100644 -index 000000000000..86b0c7deb719 +index 000000000000..d4172a829ced --- /dev/null +++ b/drivers/hid/hid-asus-ally.c -@@ -0,0 +1,619 @@ +@@ -0,0 +1,517 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * HID driver for Asus ROG laptops and Ally @@ -596,10 +641,6 @@ index 000000000000..86b0c7deb719 +#define ROG_ALLY_X_MIN_MCU 313 +#define ROG_ALLY_MIN_MCU 319 + -+#define ROG_ALLY_CFG_INTF_IN 0x83 -+#define ROG_ALLY_CFG_INTF_OUT 0x04 -+#define ROG_ALLY_X_INTF_IN 0x87 -+ +#define FEATURE_KBD_LED_REPORT_ID1 0x5d +#define FEATURE_KBD_LED_REPORT_ID2 0x5e + @@ -669,12 +710,6 @@ index 000000000000..86b0c7deb719 + return ret; +} + -+static int asus_dev_get_report(struct hid_device *hdev, u8 *out_buf, size_t out_buf_size) -+{ -+ return hid_hw_raw_request(hdev, FEATURE_REPORT_ID, out_buf, out_buf_size, -+ HID_FEATURE_REPORT, HID_REQ_GET_REPORT); -+} -+ +static u8 get_endpoint_address(struct hid_device *hdev) +{ + struct usb_interface *intf; @@ -942,85 +977,6 @@ index 000000000000..86b0c7deb719 +/* ROG Ally driver init */ +/**************************************************************************************************/ + -+/* -+ * We don't care about any other part of the string except the version section. -+ * Example strings: FGA80100.RC72LA.312_T01, FGA80100.RC71LS.318_T01 -+ */ -+static int mcu_parse_version_string(const u8 *response, size_t response_size) -+{ -+ int dot_count = 0; -+ size_t i; -+ -+ // Look for the second '.' to identify the start of the version -+ for (i = 0; i < response_size; i++) { -+ if (response[i] == '.') { -+ dot_count++; -+ if (dot_count == 2) { -+ int version = -+ simple_strtol((const char *)&response[i + 1], NULL, 10); -+ return (version >= 0) ? version : -EINVAL; -+ } -+ } -+ } -+ -+ return -EINVAL; -+} -+ -+static int mcu_request_version(struct hid_device *hdev) -+{ -+ const u8 request[] = { 0x5a, 0x05, 0x03, 0x31, 0x00, 0x20 }; -+ u8 *response; -+ int ret; -+ -+ response = kzalloc(FEATURE_ROG_ALLY_REPORT_SIZE, GFP_KERNEL); -+ if (!response) -+ return -ENOMEM; -+ -+ ret = asus_dev_set_report(hdev, request, sizeof(request)); -+ if (ret < 0) -+ goto out; -+ -+ ret = asus_dev_get_report(hdev, response, FEATURE_ROG_ALLY_REPORT_SIZE); -+ if (ret < 0) -+ goto out; -+ -+ ret = mcu_parse_version_string(response, FEATURE_ROG_ALLY_REPORT_SIZE); -+out: -+ if (ret < 0) -+ hid_err(hdev, "Failed to get MCU version: %d\n", ret); -+ kfree(response); -+ return ret; -+} -+ -+static void mcu_maybe_warn_version(struct hid_device *hdev, int idProduct) -+{ -+ int min_version, version; -+ struct asus_wmi *asus; -+ struct device *dev; -+ -+ min_version = ROG_ALLY_X_MIN_MCU; -+ version = mcu_request_version(hdev); -+ if (version) { -+ switch (idProduct) { -+ case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY: -+ min_version = ROG_ALLY_MIN_MCU; -+ break; -+ case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X: -+ min_version = ROG_ALLY_X_MIN_MCU; -+ break; -+ } -+ } -+ -+ hid_info(hdev, "Ally device MCU version: %d\n", version); -+ if (version < min_version) { -+ set_ally_mcu_hack_available(false); -+ hid_warn(hdev, -+ "The MCU version must be %d or greater\n" -+ "Please update your MCU with official ASUS firmware release\n", -+ min_version); -+ } -+} -+ +static int ally_hid_init(struct hid_device *hdev) +{ + int ret; @@ -1040,9 +996,6 @@ index 000000000000..86b0c7deb719 + +static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_id) +{ -+ struct usb_interface *intf = to_usb_interface(hdev->dev.parent); -+ struct usb_device *udev = interface_to_usbdev(intf); -+ u16 idProduct = le16_to_cpu(udev->descriptor.idProduct); + int ret, ep; + + ep = get_endpoint_address(hdev); @@ -1080,8 +1033,6 @@ index 000000000000..86b0c7deb719 + + /* This should almost always exist */ + if (ep == ROG_ALLY_CFG_INTF_IN) { -+ validate_mcu_fw_version(hdev, idProduct); -+ + drvdata.led_rgb_dev = ally_rgb_create(hdev); + if (IS_ERR(drvdata.led_rgb_dev)) + hid_err(hdev, "Failed to create Ally gamepad LEDs.\n"); @@ -1110,13 +1061,6 @@ index 000000000000..86b0c7deb719 + hid_hw_stop(hdev); +} + -+static int ally_hid_resume(struct hid_device *hdev) -+{ -+ ally_rgb_resume(); -+ -+ return 0; -+} -+ +static int ally_hid_reset_resume(struct hid_device *hdev) +{ + int ep = get_endpoint_address(hdev); @@ -1153,17 +1097,16 @@ index 000000000000..86b0c7deb719 + +MODULE_DEVICE_TABLE(hid, rog_ally_devices); + -+static struct hid_driver -+ rog_ally_cfg = { .name = "asus_rog_ally", -+ .id_table = rog_ally_devices, -+ .probe = ally_hid_probe, -+ .remove = ally_hid_remove, -+ /* HID is the better place for resume functions, not pm_ops */ -+ .resume = ally_hid_resume, -+ .reset_resume = ally_hid_reset_resume, -+ .driver = { -+ .pm = &ally_pm_ops, -+ } }; ++static struct hid_driver rog_ally_cfg = { .name = "asus_rog_ally", ++ .id_table = rog_ally_devices, ++ .probe = ally_hid_probe, ++ .remove = ally_hid_remove, ++ /* ALLy 1 requires this to reset device state correctly */ ++ .reset_resume = ally_hid_reset_resume, ++ .driver = { ++ .pm = &ally_pm_ops, ++ } ++}; + +static int __init rog_ally_init(void) +{ @@ -1183,10 +1126,10 @@ index 000000000000..86b0c7deb719 +MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h new file mode 100644 -index 000000000000..eb8617c80c2a +index 000000000000..2f621e16a9d8 --- /dev/null +++ b/drivers/hid/hid-asus-ally.h -@@ -0,0 +1,38 @@ +@@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * HID driver for Asus ROG laptops and Ally @@ -1197,6 +1140,10 @@ index 000000000000..eb8617c80c2a +#include +#include + ++#define ROG_ALLY_CFG_INTF_IN 0x83 ++#define ROG_ALLY_CFG_INTF_OUT 0x04 ++#define ROG_ALLY_X_INTF_IN 0x87 ++ +/* the xpad_cmd determines which feature is set or queried */ +enum xpad_cmd { + xpad_cmd_set_mode = 0x01, @@ -1226,130 +1173,18 @@ index 000000000000..eb8617c80c2a + xpad_cmd_len_adz = 0x02, +}; diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c -index 93217442b4b6..fb29486478f7 100644 +index 66bae5cea4f9..9ebee77638a0 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c -@@ -52,9 +52,9 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); - #define FEATURE_KBD_LED_REPORT_ID1 0x5d - #define FEATURE_KBD_LED_REPORT_ID2 0x5e +@@ -33,6 +33,7 @@ + #include --#define ROG_ALLY_REPORT_SIZE 64 --#define ROG_ALLY_X_MIN_MCU 313 --#define ROG_ALLY_MIN_MCU 319 -+#define ROG_ALLY_CFG_INTF_IN 0x83 -+#define ROG_ALLY_CFG_INTF_OUT 0x04 -+#define ROG_ALLY_X_INTF_IN 0x87 + #include "hid-ids.h" ++#include "hid-asus-ally.h" - #define SUPPORT_KBD_BACKLIGHT BIT(0) - -@@ -539,91 +539,9 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev) - return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT); - } - --/* -- * We don't care about any other part of the string except the version section. -- * Example strings: FGA80100.RC72LA.312_T01, FGA80100.RC71LS.318_T01 -- */ --static int mcu_parse_version_string(const u8 *response, size_t response_size) --{ -- int dot_count = 0; -- size_t i; -- -- // Look for the second '.' to identify the start of the version -- for (i = 0; i < response_size; i++) { -- if (response[i] == '.') { -- dot_count++; -- if (dot_count == 2) { -- int version = -- simple_strtol((const char *)&response[i + 1], NULL, 10); -- return (version >= 0) ? version : -EINVAL; -- } -- } -- } -- -- return -EINVAL; --} -- --static int mcu_request_version(struct hid_device *hdev) --{ -- const u8 request[] = { 0x5a, 0x05, 0x03, 0x31, 0x00, 0x20 }; -- u8 *response; -- int ret; -- -- response = kzalloc(ROG_ALLY_REPORT_SIZE, GFP_KERNEL); -- if (!response) -- return -ENOMEM; -- -- ret = asus_kbd_set_report(hdev, request, sizeof(request)); -- if (ret < 0) -- goto out; -- -- ret = hid_hw_raw_request(hdev, FEATURE_REPORT_ID, response, -- ROG_ALLY_REPORT_SIZE, HID_FEATURE_REPORT, -- HID_REQ_GET_REPORT); -- if (ret < 0) -- goto out; -- -- ret = mcu_parse_version_string(response, ROG_ALLY_REPORT_SIZE); --out: -- if (ret < 0) -- hid_err(hdev, "Failed to get MCU version: %d\n", ret); -- kfree(response); -- return ret; --} -- --static void mcu_maybe_warn_version(struct hid_device *hdev, int idProduct) --{ -- int min_version, version; -- -- min_version = ROG_ALLY_X_MIN_MCU; -- version = mcu_request_version(hdev); -- if (version) { -- switch (idProduct) { -- case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY: -- min_version = ROG_ALLY_MIN_MCU; -- break; -- case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X: -- min_version = ROG_ALLY_X_MIN_MCU; -- break; -- } -- } -- -- hid_info(hdev, "Ally device MCU version: %d\n", version); -- if (version < min_version) { -- hid_warn(hdev, -- "The MCU version must be %d or greater\n" -- "Please update your MCU with official ASUS firmware release\n", -- min_version); -- } else { -- set_ally_mcu_hack_available(false); -- } --} -- - static int asus_kbd_register_leds(struct hid_device *hdev) - { - struct asus_drvdata *drvdata = hid_get_drvdata(hdev); -- struct usb_interface *intf; -- struct usb_device *udev; - unsigned char kbd_func; - int ret; - -@@ -647,14 +565,6 @@ static int asus_kbd_register_leds(struct hid_device *hdev) - if (ret < 0) - return ret; - } -- -- if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) { -- intf = to_usb_interface(hdev->dev.parent); -- udev = interface_to_usbdev(intf); -- mcu_maybe_warn_version(hdev, -- le16_to_cpu(udev->descriptor.idProduct)); -- } -- - } else { - /* Initialize keyboard */ - ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID); -@@ -1124,6 +1034,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) + MODULE_AUTHOR("Yusuke Fujimaki "); + MODULE_AUTHOR("Brendan McGrath "); +@@ -1135,6 +1136,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) drvdata->quirks = id->driver_data; @@ -1371,10 +1206,282 @@ index 93217442b4b6..fb29486478f7 100644 2.48.1 -From 81aec29f33af181e3004829f89673855ce6e9d13 Mon Sep 17 00:00:00 2001 +From 75c2fe6293821b19f940abfc98e04ccaf0187640 Mon Sep 17 00:00:00 2001 +From: Luke Jones +Date: Mon, 24 Feb 2025 19:40:04 +1300 +Subject: [PATCH 07/28] hid-asus-ally: move MCU FW validation to module + +Signed-off-by: Luke Jones +--- + drivers/hid/hid-asus-ally.c | 97 ++++++++++++++++++++++++++++++++++ + drivers/hid/hid-asus.c | 101 ------------------------------------ + 2 files changed, 97 insertions(+), 101 deletions(-) + +diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c +index d4172a829ced..cf0bbaa88a69 100644 +--- a/drivers/hid/hid-asus-ally.c ++++ b/drivers/hid/hid-asus-ally.c +@@ -368,6 +368,97 @@ static void ally_rgb_remove(struct hid_device *hdev) + /* ROG Ally driver init */ + /**************************************************************************************************/ + ++/* ++ * We don't care about any other part of the string except the version section. ++ * Example strings: FGA80100.RC72LA.312_T01, FGA80100.RC71LS.318_T01 ++ * The bytes "5a 05 03 31 00 1a 13" and possibly more come before the version ++ * string, and there may be additional bytes after the version string such as ++ * "75 00 74 00 65 00" or a postfix such as "_T01" ++ */ ++static int mcu_parse_version_string(const u8 *response, size_t response_size) ++{ ++ const u8 *end = response + response_size; ++ const u8 *p = response; ++ int dots, err, version; ++ char buf[4]; ++ ++ dots = 0; ++ while (p < end && dots < 2) { ++ if (*p++ == '.') ++ dots++; ++ } ++ ++ if (dots != 2 || p >= end || (p + 3) >= end) ++ return -EINVAL; ++ ++ memcpy(buf, p, 3); ++ buf[3] = '\0'; ++ ++ err = kstrtoint(buf, 10, &version); ++ if (err || version < 0) ++ return -EINVAL; ++ ++ return version; ++} ++ ++static int mcu_request_version(struct hid_device *hdev) ++{ ++ u8 *response __free(kfree) = kzalloc(ROG_ALLY_REPORT_SIZE, GFP_KERNEL); ++ const u8 request[] = { 0x5a, 0x05, 0x03, 0x31, 0x00, 0x20 }; ++ int ret; ++ ++ if (!response) ++ return -ENOMEM; ++ ++ ret = asus_dev_set_report(hdev, request, sizeof(request)); ++ if (ret < 0) ++ return ret; ++ ++ ret = hid_hw_raw_request(hdev, FEATURE_REPORT_ID, response, ++ ROG_ALLY_REPORT_SIZE, HID_FEATURE_REPORT, ++ HID_REQ_GET_REPORT); ++ if (ret < 0) ++ return ret; ++ ++ ret = mcu_parse_version_string(response, ROG_ALLY_REPORT_SIZE); ++ if (ret < 0) { ++ pr_err("Failed to parse MCU version: %d\n", ret); ++ print_hex_dump(KERN_ERR, "MCU: ", DUMP_PREFIX_NONE, ++ 16, 1, response, ROG_ALLY_REPORT_SIZE, false); ++ } ++ ++ return ret; ++} ++ ++static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct) ++{ ++ int min_version, version; ++ ++ version = mcu_request_version(hdev); ++ if (version < 0) ++ return; ++ ++ switch (idProduct) { ++ case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY: ++ min_version = ROG_ALLY_MIN_MCU; ++ break; ++ case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X: ++ min_version = ROG_ALLY_X_MIN_MCU; ++ break; ++ default: ++ min_version = 0; ++ } ++ ++ if (version < min_version) { ++ hid_warn(hdev, ++ "The MCU firmware version must be %d or greater to avoid issues with suspend.\n", ++ min_version); ++ } else { ++ set_ally_mcu_hack(false); ++ set_ally_mcu_powersave(true); ++ } ++} ++ + static int ally_hid_init(struct hid_device *hdev) + { + int ret; +@@ -387,6 +478,9 @@ static int ally_hid_init(struct hid_device *hdev) + + static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_id) + { ++ struct usb_interface *intf = to_usb_interface(hdev->dev.parent); ++ struct usb_device *udev = interface_to_usbdev(intf); ++ u16 idProduct = le16_to_cpu(udev->descriptor.idProduct); + int ret, ep; + + ep = get_endpoint_address(hdev); +@@ -424,6 +518,8 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ + + /* This should almost always exist */ + if (ep == ROG_ALLY_CFG_INTF_IN) { ++ validate_mcu_fw_version(hdev, idProduct); ++ + drvdata.led_rgb_dev = ally_rgb_create(hdev); + if (IS_ERR(drvdata.led_rgb_dev)) + hid_err(hdev, "Failed to create Ally gamepad LEDs.\n"); +@@ -512,6 +608,7 @@ static void __exit rog_ally_exit(void) + module_init(rog_ally_init); + module_exit(rog_ally_exit); + ++MODULE_IMPORT_NS("ASUS_WMI"); + MODULE_AUTHOR("Luke D. Jones"); + MODULE_DESCRIPTION("HID Driver for ASUS ROG Ally gamepad configuration."); + MODULE_LICENSE("GPL"); +diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c +index 9ebee77638a0..83883f58202b 100644 +--- a/drivers/hid/hid-asus.c ++++ b/drivers/hid/hid-asus.c +@@ -540,102 +540,9 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev) + return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT); + } + +-/* +- * We don't care about any other part of the string except the version section. +- * Example strings: FGA80100.RC72LA.312_T01, FGA80100.RC71LS.318_T01 +- * The bytes "5a 05 03 31 00 1a 13" and possibly more come before the version +- * string, and there may be additional bytes after the version string such as +- * "75 00 74 00 65 00" or a postfix such as "_T01" +- */ +-static int mcu_parse_version_string(const u8 *response, size_t response_size) +-{ +- const u8 *end = response + response_size; +- const u8 *p = response; +- int dots, err, version; +- char buf[4]; +- +- dots = 0; +- while (p < end && dots < 2) { +- if (*p++ == '.') +- dots++; +- } +- +- if (dots != 2 || p >= end || (p + 3) >= end) +- return -EINVAL; +- +- memcpy(buf, p, 3); +- buf[3] = '\0'; +- +- err = kstrtoint(buf, 10, &version); +- if (err || version < 0) +- return -EINVAL; +- +- return version; +-} +- +-static int mcu_request_version(struct hid_device *hdev) +-{ +- u8 *response __free(kfree) = kzalloc(ROG_ALLY_REPORT_SIZE, GFP_KERNEL); +- const u8 request[] = { 0x5a, 0x05, 0x03, 0x31, 0x00, 0x20 }; +- int ret; +- +- if (!response) +- return -ENOMEM; +- +- ret = asus_kbd_set_report(hdev, request, sizeof(request)); +- if (ret < 0) +- return ret; +- +- ret = hid_hw_raw_request(hdev, FEATURE_REPORT_ID, response, +- ROG_ALLY_REPORT_SIZE, HID_FEATURE_REPORT, +- HID_REQ_GET_REPORT); +- if (ret < 0) +- return ret; +- +- ret = mcu_parse_version_string(response, ROG_ALLY_REPORT_SIZE); +- if (ret < 0) { +- pr_err("Failed to parse MCU version: %d\n", ret); +- print_hex_dump(KERN_ERR, "MCU: ", DUMP_PREFIX_NONE, +- 16, 1, response, ROG_ALLY_REPORT_SIZE, false); +- } +- +- return ret; +-} +- +-static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct) +-{ +- int min_version, version; +- +- version = mcu_request_version(hdev); +- if (version < 0) +- return; +- +- switch (idProduct) { +- case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY: +- min_version = ROG_ALLY_MIN_MCU; +- break; +- case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X: +- min_version = ROG_ALLY_X_MIN_MCU; +- break; +- default: +- min_version = 0; +- } +- +- if (version < min_version) { +- hid_warn(hdev, +- "The MCU firmware version must be %d or greater to avoid issues with suspend.\n", +- min_version); +- } else { +- set_ally_mcu_hack(false); +- set_ally_mcu_powersave(true); +- } +-} +- + static int asus_kbd_register_leds(struct hid_device *hdev) + { + struct asus_drvdata *drvdata = hid_get_drvdata(hdev); +- struct usb_interface *intf; +- struct usb_device *udev; + unsigned char kbd_func; + int ret; + +@@ -659,14 +566,6 @@ static int asus_kbd_register_leds(struct hid_device *hdev) + if (ret < 0) + return ret; + } +- +- if (drvdata->quirks & QUIRK_ROG_ALLY_XPAD) { +- intf = to_usb_interface(hdev->dev.parent); +- udev = interface_to_usbdev(intf); +- validate_mcu_fw_version(hdev, +- le16_to_cpu(udev->descriptor.idProduct)); +- } +- + } else { + /* Initialize keyboard */ + ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID); +-- +2.48.1 + + +From 942eaebc0ed29e681e19917b20b47fc5639b3584 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 2 Oct 2024 23:32:46 +1300 -Subject: [PATCH 09/30] hid-asus-ally: initial Ally-X gamepad +Subject: [PATCH 08/28] hid-asus-ally: initial Ally-X gamepad bringup + +Enable use of the new gamepad device created by the MCU. +- Triggers +- Buttons +- Sticks +- Vibration Signed-off-by: Luke D. Jones --- @@ -1383,10 +1490,10 @@ Signed-off-by: Luke D. Jones 2 files changed, 389 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 86b0c7deb719..b7d22c1747b0 100644 +index cf0bbaa88a69..2de79d5fe361 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -50,6 +50,51 @@ static const struct hid_device_id rog_ally_devices[] = { +@@ -46,6 +46,51 @@ static const struct hid_device_id rog_ally_devices[] = { {} }; @@ -1438,7 +1545,7 @@ index 86b0c7deb719..b7d22c1747b0 100644 struct ally_rgb_dev { struct hid_device *hdev; struct led_classdev_mc led_rgb_dev; -@@ -74,6 +119,7 @@ struct ally_rgb_data { +@@ -70,6 +115,7 @@ struct ally_rgb_data { static struct ally_drvdata { struct hid_device *hdev; @@ -1446,7 +1553,7 @@ index 86b0c7deb719..b7d22c1747b0 100644 struct ally_rgb_dev *led_rgb_dev; struct ally_rgb_data led_rgb_data; } drvdata; -@@ -128,6 +174,309 @@ static u8 get_endpoint_address(struct hid_device *hdev) +@@ -118,6 +164,309 @@ static u8 get_endpoint_address(struct hid_device *hdev) return -ENODEV; } @@ -1756,7 +1863,7 @@ index 86b0c7deb719..b7d22c1747b0 100644 /**************************************************************************************************/ /* ROG Ally LED control */ /**************************************************************************************************/ -@@ -378,6 +727,24 @@ static void ally_rgb_remove(struct hid_device *hdev) +@@ -368,6 +717,24 @@ static void ally_rgb_remove(struct hid_device *hdev) /* ROG Ally driver init */ /**************************************************************************************************/ @@ -1781,7 +1888,7 @@ index 86b0c7deb719..b7d22c1747b0 100644 /* * We don't care about any other part of the string except the version section. * Example strings: FGA80100.RC72LA.312_T01, FGA80100.RC71LS.318_T01 -@@ -485,7 +852,8 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ +@@ -487,7 +854,8 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ if (ep < 0) return ep; @@ -1791,7 +1898,7 @@ index 86b0c7deb719..b7d22c1747b0 100644 return -ENODEV; ret = hid_parse(hdev); -@@ -528,6 +896,17 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ +@@ -530,6 +898,17 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ goto err_close; } @@ -1809,7 +1916,7 @@ index 86b0c7deb719..b7d22c1747b0 100644 return 0; err_close: -@@ -542,6 +921,9 @@ static void ally_hid_remove(struct hid_device *hdev) +@@ -544,6 +923,9 @@ static void ally_hid_remove(struct hid_device *hdev) if (drvdata.led_rgb_dev) ally_rgb_remove(hdev); @@ -1819,19 +1926,19 @@ index 86b0c7deb719..b7d22c1747b0 100644 hid_hw_close(hdev); hid_hw_stop(hdev); } -@@ -594,6 +976,7 @@ static struct hid_driver - .id_table = rog_ally_devices, - .probe = ally_hid_probe, - .remove = ally_hid_remove, -+ .raw_event = ally_raw_event, - /* HID is the better place for resume functions, not pm_ops */ - .resume = ally_hid_resume, - .reset_resume = ally_hid_reset_resume, +@@ -588,6 +970,7 @@ static struct hid_driver rog_ally_cfg = { .name = "asus_rog_ally", + .id_table = rog_ally_devices, + .probe = ally_hid_probe, + .remove = ally_hid_remove, ++ .raw_event = ally_raw_event, + /* ALLy 1 requires this to reset device state correctly */ + .reset_resume = ally_hid_reset_resume, + .driver = { diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index eb8617c80c2a..458d02996bca 100644 +index 2f621e16a9d8..7d172d64b814 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -36,3 +36,8 @@ enum xpad_cmd_len { +@@ -40,3 +40,8 @@ enum xpad_cmd_len { xpad_cmd_len_response_curve = 0x09, xpad_cmd_len_adz = 0x02, }; @@ -1844,19 +1951,22 @@ index eb8617c80c2a..458d02996bca 100644 2.48.1 -From 2716866a4a92fe3a71ce72888599a5344c4ec0f7 Mon Sep 17 00:00:00 2001 +From 254900ffe626b9a6392387aa1bb1828b950617f5 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 2 Oct 2024 23:51:36 +1300 -Subject: [PATCH 10/30] hid-asus-ally: initial gamepad configuration +Subject: [PATCH 09/28] hid-asus-ally: initial gamepad configuration + +Add the basics of the gamepad configuration options. Makes the gamepad +usable. Signed-off-by: Luke D. Jones --- - drivers/hid/hid-asus-ally.c | 246 +++++++++++++++++++++++++++++++++++- - drivers/hid/hid-asus-ally.h | 38 +++--- - 2 files changed, 266 insertions(+), 18 deletions(-) + drivers/hid/hid-asus-ally.c | 282 +++++++++++++++++++++++++++++++++++- + drivers/hid/hid-asus-ally.h | 38 +++-- + 2 files changed, 301 insertions(+), 19 deletions(-) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index b7d22c1747b0..4935ab36aa35 100644 +index 2de79d5fe361..9b76d41f160e 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c @@ -10,7 +10,6 @@ @@ -1867,7 +1977,7 @@ index b7d22c1747b0..4935ab36aa35 100644 #include #include #include -@@ -39,6 +38,9 @@ +@@ -35,6 +34,9 @@ #define FEATURE_KBD_LED_REPORT_ID1 0x5d #define FEATURE_KBD_LED_REPORT_ID2 0x5e @@ -1877,7 +1987,7 @@ index b7d22c1747b0..4935ab36aa35 100644 static const u8 EC_INIT_STRING[] = { 0x5A, 'A', 'S', 'U', 'S', ' ', 'T', 'e','c', 'h', '.', 'I', 'n', 'c', '.', '\0' }; static const u8 EC_MODE_LED_APPLY[] = { 0x5A, 0xB4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const u8 EC_MODE_LED_SET[] = { 0x5A, 0xB5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -@@ -50,6 +52,58 @@ static const struct hid_device_id rog_ally_devices[] = { +@@ -46,6 +48,58 @@ static const struct hid_device_id rog_ally_devices[] = { {} }; @@ -1936,7 +2046,7 @@ index b7d22c1747b0..4935ab36aa35 100644 /* The hatswitch outputs integers, we use them to index this X|Y pair */ static const int hat_values[][2] = { { 0, 0 }, { 0, -1 }, { 1, -1 }, { 1, 0 }, { 1, 1 }, -@@ -120,6 +174,7 @@ struct ally_rgb_data { +@@ -116,6 +170,7 @@ struct ally_rgb_data { static struct ally_drvdata { struct hid_device *hdev; struct ally_x_device *ally_x; @@ -1944,7 +2054,31 @@ index b7d22c1747b0..4935ab36aa35 100644 struct ally_rgb_dev *led_rgb_dev; struct ally_rgb_data led_rgb_data; } drvdata; -@@ -174,6 +229,172 @@ static u8 get_endpoint_address(struct hid_device *hdev) +@@ -147,6 +202,23 @@ static int asus_dev_set_report(struct hid_device *hdev, const u8 *buf, size_t le + return ret; + } + ++/** ++ * asus_dev_get_report - send get report request to device. ++ * ++ * @hdev: hid device ++ * @out: buffer to write output data in to ++ * @len: length the output buffer provided ++ * ++ * Return: count of data transferred, negative if error ++ * ++ * Same behavior as hid_hw_raw_request. ++ */ ++static int asus_dev_get_report(struct hid_device *hdev, u8 *out, size_t len) ++{ ++ return hid_hw_raw_request(hdev, FEATURE_REPORT_ID, out, len, ++ HID_FEATURE_REPORT, HID_REQ_GET_REPORT); ++} ++ + static u8 get_endpoint_address(struct hid_device *hdev) + { + struct usb_interface *intf; +@@ -164,6 +236,172 @@ static u8 get_endpoint_address(struct hid_device *hdev) return -ENODEV; } @@ -2117,7 +2251,7 @@ index b7d22c1747b0..4935ab36aa35 100644 /**************************************************************************************************/ /* ROG Ally gamepad i/o and force-feedback */ /**************************************************************************************************/ -@@ -730,6 +951,7 @@ static void ally_rgb_remove(struct hid_device *hdev) +@@ -720,6 +958,7 @@ static void ally_rgb_remove(struct hid_device *hdev) static int ally_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size) { @@ -2125,7 +2259,7 @@ index b7d22c1747b0..4935ab36aa35 100644 struct ally_x_device *ally_x = drvdata.ally_x; if (ally_x) { -@@ -742,6 +964,14 @@ static int ally_raw_event(struct hid_device *hdev, struct hid_report *report, u8 +@@ -732,6 +971,14 @@ static int ally_raw_event(struct hid_device *hdev, struct hid_report *report, u8 } } @@ -2140,7 +2274,7 @@ index b7d22c1747b0..4935ab36aa35 100644 return 0; } -@@ -892,7 +1122,13 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ +@@ -894,7 +1141,13 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ else hid_info(hdev, "Created Ally RGB LED controls.\n"); @@ -2155,7 +2289,7 @@ index b7d22c1747b0..4935ab36aa35 100644 goto err_close; } -@@ -905,6 +1141,12 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ +@@ -907,6 +1160,12 @@ static int ally_hid_probe(struct hid_device *hdev, const struct hid_device_id *_ goto err_close; } hid_info(hdev, "Created Ally X controller.\n"); @@ -2168,13 +2302,53 @@ index b7d22c1747b0..4935ab36aa35 100644 } return 0; +@@ -930,6 +1189,21 @@ static void ally_hid_remove(struct hid_device *hdev) + hid_hw_stop(hdev); + } + ++static int ally_hid_resume(struct hid_device *hdev) ++{ ++ struct ally_gamepad_cfg *ally_cfg = drvdata.gamepad_cfg; ++ int err; ++ ++ if (!ally_cfg) ++ return 0; ++ ++ err = _gamepad_apply_btn_pair(hdev, ally_cfg, btn_pair_m1_m2); ++ if (err) ++ return err; ++ ++ return 0; ++} ++ + static int ally_hid_reset_resume(struct hid_device *hdev) + { + int ep = get_endpoint_address(hdev); +@@ -939,7 +1213,7 @@ static int ally_hid_reset_resume(struct hid_device *hdev) + ally_hid_init(hdev); + ally_rgb_resume(); + +- return 0; ++ return ally_hid_resume(hdev); + } + + static int ally_pm_thaw(struct device *dev) +@@ -971,6 +1245,8 @@ static struct hid_driver rog_ally_cfg = { .name = "asus_rog_ally", + .probe = ally_hid_probe, + .remove = ally_hid_remove, + .raw_event = ally_raw_event, ++ /* HID is the better place for resume functions, not pm_ops */ ++ .resume = ally_hid_resume, + /* ALLy 1 requires this to reset device state correctly */ + .reset_resume = ally_hid_reset_resume, + .driver = { diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index 458d02996bca..2b298ad4da0e 100644 +index 7d172d64b814..66376e6cbd71 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -8,35 +8,41 @@ - #include - #include +@@ -12,35 +12,41 @@ + #define ROG_ALLY_CFG_INTF_OUT 0x04 + #define ROG_ALLY_X_INTF_IN 0x87 +/* + * the xpad_mode is used inside the mode setting packet and is used @@ -2234,22 +2408,25 @@ index 458d02996bca..2b298ad4da0e 100644 2.48.1 -From 2e9a04a44b0b8ad6ae4b82aced1b78d0daf00af3 Mon Sep 17 00:00:00 2001 +From 8b4cf837e80c35b20fc1208456f471a16c2ff319 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 5 Oct 2024 14:58:33 +1300 -Subject: [PATCH 11/30] hid-asus-ally: add button remap attributes +Subject: [PATCH 10/28] hid-asus-ally: add button remap attributes + +Add the full set of button remapping abilities for plain remap and macro +remap (hold one button, press another for macro mapped action). Signed-off-by: Luke D. Jones --- - drivers/hid/hid-asus-ally.c | 393 ++++++++++++++++++++++++++++++++++-- + drivers/hid/hid-asus-ally.c | 395 ++++++++++++++++++++++++++++++++++-- drivers/hid/hid-asus-ally.h | 211 +++++++++++++++++++ - 2 files changed, 586 insertions(+), 18 deletions(-) + 2 files changed, 587 insertions(+), 19 deletions(-) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 4935ab36aa35..f5a50eaa7e75 100644 +index 9b76d41f160e..4755f5f6ad9e 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -57,6 +57,152 @@ struct btn_code_map { +@@ -53,6 +53,152 @@ struct btn_code_map { const char *name; }; @@ -2402,7 +2579,7 @@ index 4935ab36aa35..f5a50eaa7e75 100644 /* byte_array must be >= 8 in length */ static void btn_code_to_byte_array(u64 keycode, u8 *byte_array) { -@@ -66,6 +212,27 @@ static void btn_code_to_byte_array(u64 keycode, u8 *byte_array) +@@ -62,6 +208,27 @@ static void btn_code_to_byte_array(u64 keycode, u8 *byte_array) } } @@ -2430,7 +2607,7 @@ index 4935ab36aa35..f5a50eaa7e75 100644 struct btn_data { u64 button; u64 macro; -@@ -101,7 +268,7 @@ struct ally_gamepad_cfg { +@@ -97,7 +264,7 @@ struct ally_gamepad_cfg { /* * index: [mode] */ @@ -2439,7 +2616,7 @@ index 4935ab36aa35..f5a50eaa7e75 100644 }; /* The hatswitch outputs integers, we use them to index this X|Y pair */ -@@ -315,9 +482,41 @@ static int _gamepad_apply_btn_pair(struct hid_device *hdev, struct ally_gamepad_ +@@ -322,9 +489,41 @@ static int _gamepad_apply_btn_pair(struct hid_device *hdev, struct ally_gamepad_ return -ENOMEM; switch (btn_pair) { @@ -2483,7 +2660,7 @@ index 4935ab36aa35..f5a50eaa7e75 100644 break; default: break; -@@ -331,6 +530,157 @@ static int _gamepad_apply_btn_pair(struct hid_device *hdev, struct ally_gamepad_ +@@ -338,6 +537,157 @@ static int _gamepad_apply_btn_pair(struct hid_device *hdev, struct ally_gamepad_ return ret; } @@ -2641,7 +2818,7 @@ index 4935ab36aa35..f5a50eaa7e75 100644 static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) { struct ally_gamepad_cfg *ally_cfg; -@@ -343,13 +693,6 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) +@@ -350,13 +700,6 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) ally_cfg->hdev = hdev; // Allocate memory for each mode's `btn_mapping` ally_cfg->mode = xpad_mode_game; @@ -2655,7 +2832,7 @@ index 4935ab36aa35..f5a50eaa7e75 100644 input_dev = devm_input_allocate_device(&hdev->dev); if (!input_dev) { -@@ -375,26 +718,37 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) +@@ -382,26 +725,37 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) ally_cfg->input = input_dev; /* ignore all errors for this as they are related to USB HID I/O */ @@ -2701,7 +2878,7 @@ index 4935ab36aa35..f5a50eaa7e75 100644 /**************************************************************************************************/ /* ROG Ally gamepad i/o and force-feedback */ /**************************************************************************************************/ -@@ -1166,6 +1520,9 @@ static void ally_hid_remove(struct hid_device *hdev) +@@ -1185,6 +1539,9 @@ static void ally_hid_remove(struct hid_device *hdev) if (drvdata.ally_x) ally_x_remove(hdev); @@ -2711,11 +2888,20 @@ index 4935ab36aa35..f5a50eaa7e75 100644 hid_hw_close(hdev); hid_hw_stop(hdev); } +@@ -1197,7 +1554,7 @@ static int ally_hid_resume(struct hid_device *hdev) + if (!ally_cfg) + return 0; + +- err = _gamepad_apply_btn_pair(hdev, ally_cfg, btn_pair_m1_m2); ++ err = _gamepad_apply_all(hdev, ally_cfg); + if (err) + return err; + diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index 2b298ad4da0e..f985cbd698c3 100644 +index 66376e6cbd71..c5c6ff8d6f1c 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -33,11 +33,155 @@ enum xpad_cmd_len { +@@ -37,11 +37,155 @@ enum xpad_cmd_len { /* Values correspond to the actual HID byte value required */ enum btn_pair_index { @@ -2871,7 +3057,7 @@ index 2b298ad4da0e..f985cbd698c3 100644 #define ALLY_DEVICE_ATTR_WO(_name, _sysfs_name) \ struct device_attribute dev_attr_##_name = \ -@@ -47,3 +191,70 @@ enum btn_pair_index { +@@ -51,3 +195,70 @@ enum btn_pair_index { #define ALLY_DEVICE_ATTR_RW(_name, _sysfs_name) \ struct device_attribute dev_attr_##_name = \ __ATTR(_sysfs_name, 0644, _name##_show, _name##_store) @@ -2946,10 +3132,10 @@ index 2b298ad4da0e..f985cbd698c3 100644 2.48.1 -From d714ade992b6ac4e2684bbb3f2c65b8a0c766afc Mon Sep 17 00:00:00 2001 +From 624095227105a255f3bde3bdd5fab8508700a1b1 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Fri, 25 Oct 2024 08:56:54 +0200 -Subject: [PATCH 12/30] hid-asus-ally: add gamepad mode selection +Subject: [PATCH 11/28] hid-asus-ally: add gamepad mode selection --- drivers/hid/hid-asus-ally.c | 73 +++++++++++++++++++++++++++++++++++++ @@ -2957,10 +3143,10 @@ Subject: [PATCH 12/30] hid-asus-ally: add gamepad mode selection 2 files changed, 75 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index f5a50eaa7e75..8a49d37c20e7 100644 +index 4755f5f6ad9e..d4d7877b3065 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -647,9 +647,82 @@ static ssize_t btn_mapping_reset_store(struct device *dev, struct device_attribu +@@ -654,9 +654,82 @@ static ssize_t btn_mapping_reset_store(struct device *dev, struct device_attribu } ALLY_DEVICE_ATTR_WO(btn_mapping_reset, reset_btn_mapping); @@ -3044,10 +3230,10 @@ index f5a50eaa7e75..8a49d37c20e7 100644 NULL }; diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index f985cbd698c3..f7e21be50d8e 100644 +index c5c6ff8d6f1c..a0b0acd65bfd 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -20,6 +20,7 @@ enum xpad_mode { +@@ -24,6 +24,7 @@ enum xpad_mode { /* the xpad_cmd determines which feature is set or queried */ enum xpad_cmd { @@ -3055,7 +3241,7 @@ index f985cbd698c3..f7e21be50d8e 100644 xpad_cmd_set_mapping = 0x02, xpad_cmd_set_leds = 0x08, xpad_cmd_check_ready = 0x0A, -@@ -27,6 +28,7 @@ enum xpad_cmd { +@@ -31,6 +32,7 @@ enum xpad_cmd { /* the xpad_cmd determines which feature is set or queried */ enum xpad_cmd_len { @@ -3067,10 +3253,10 @@ index f985cbd698c3..f7e21be50d8e 100644 2.48.1 -From aa0e8815323970879f5c92ae9f28242cd8d9ef54 Mon Sep 17 00:00:00 2001 +From df00d60cc95dbe0383ee08beed2a47c365a8f1df Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 5 Oct 2024 15:40:09 +1300 -Subject: [PATCH 13/30] hid-asus-ally: Turbo settings for buttons +Subject: [PATCH 12/28] hid-asus-ally: Turbo settings for buttons Signed-off-by: Luke D. Jones --- @@ -3079,10 +3265,10 @@ Signed-off-by: Luke D. Jones 2 files changed, 108 insertions(+), 14 deletions(-) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 8a49d37c20e7..4812c060afa2 100644 +index d4d7877b3065..afaeba3dfde7 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -236,6 +236,7 @@ static const char* btn_to_name(u64 key) +@@ -232,6 +232,7 @@ static const char* btn_to_name(u64 key) struct btn_data { u64 button; u64 macro; @@ -3090,7 +3276,7 @@ index 8a49d37c20e7..4812c060afa2 100644 }; struct btn_mapping { -@@ -530,6 +531,46 @@ static int _gamepad_apply_btn_pair(struct hid_device *hdev, struct ally_gamepad_ +@@ -537,6 +538,46 @@ static int _gamepad_apply_btn_pair(struct hid_device *hdev, struct ally_gamepad_ return ret; } @@ -3137,7 +3323,7 @@ index 8a49d37c20e7..4812c060afa2 100644 static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_cfg *ally_cfg) { int ret; -@@ -559,6 +600,9 @@ static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_c +@@ -566,6 +607,9 @@ static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_c if (ret < 0) return ret; ret = _gamepad_apply_btn_pair(hdev, ally_cfg, btn_pair_lt_rt); @@ -3147,7 +3333,7 @@ index 8a49d37c20e7..4812c060afa2 100644 if (ret < 0) return ret; -@@ -586,22 +630,22 @@ ALLY_DEVICE_ATTR_WO(gamepad_apply_all, apply_all); +@@ -593,22 +637,22 @@ ALLY_DEVICE_ATTR_WO(gamepad_apply_all, apply_all); /* button map attributes, regular and macro*/ ALLY_BTN_MAPPING(m1, btn_m1); ALLY_BTN_MAPPING(m2, btn_m2); @@ -3185,10 +3371,10 @@ index 8a49d37c20e7..4812c060afa2 100644 static void _gamepad_set_xpad_default(struct ally_gamepad_cfg *ally_cfg) { diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index f7e21be50d8e..63a3b5caa71c 100644 +index a0b0acd65bfd..4e1eccbd99ad 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -24,6 +24,7 @@ enum xpad_cmd { +@@ -28,6 +28,7 @@ enum xpad_cmd { xpad_cmd_set_mapping = 0x02, xpad_cmd_set_leds = 0x08, xpad_cmd_check_ready = 0x0A, @@ -3196,7 +3382,7 @@ index f7e21be50d8e..63a3b5caa71c 100644 }; /* the xpad_cmd determines which feature is set or queried */ -@@ -31,6 +32,7 @@ enum xpad_cmd_len { +@@ -35,6 +36,7 @@ enum xpad_cmd_len { xpad_cmd_len_mode = 0x01, xpad_cmd_len_mapping = 0x2c, xpad_cmd_len_leds = 0x0C, @@ -3204,7 +3390,7 @@ index f7e21be50d8e..63a3b5caa71c 100644 }; /* Values correspond to the actual HID byte value required */ -@@ -228,6 +230,37 @@ enum btn_pair_index { +@@ -232,6 +234,37 @@ enum btn_pair_index { return count; \ } @@ -3242,7 +3428,7 @@ index f7e21be50d8e..63a3b5caa71c 100644 #define ALLY_BTN_ATTRS_GROUP(_name, _fname) \ static struct attribute *_fname##_attrs[] = { \ &dev_attr_##_fname.attr, \ -@@ -260,3 +293,20 @@ enum btn_pair_index { +@@ -264,3 +297,20 @@ enum btn_pair_index { .name = __stringify(btn_##_fname), \ .attrs = _fname##_attrs, \ } @@ -3267,10 +3453,10 @@ index f7e21be50d8e..63a3b5caa71c 100644 2.48.1 -From b221aa86e9c3d0459e07aa8d1878b427d6137ec0 Mon Sep 17 00:00:00 2001 +From a280d7183af50f5ac2888812bafaf8a60ad5b896 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 5 Oct 2024 20:46:00 +1300 -Subject: [PATCH 14/30] hid-asus-ally: add vibration intensity settings +Subject: [PATCH 13/28] hid-asus-ally: add vibration intensity settings Signed-off-by: Luke D. Jones --- @@ -3279,10 +3465,10 @@ Signed-off-by: Luke D. Jones 2 files changed, 99 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 4812c060afa2..01d0ff6169fd 100644 +index afaeba3dfde7..2eae8a226f18 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -270,6 +270,11 @@ struct ally_gamepad_cfg { +@@ -266,6 +266,11 @@ struct ally_gamepad_cfg { * index: [mode] */ struct btn_mapping key_mapping[xpad_mode_mouse]; @@ -3294,7 +3480,7 @@ index 4812c060afa2..01d0ff6169fd 100644 }; /* The hatswitch outputs integers, we use them to index this X|Y pair */ -@@ -441,6 +446,89 @@ static int ally_gamepad_check_ready(struct hid_device *hdev) +@@ -448,6 +453,89 @@ static int ally_gamepad_check_ready(struct hid_device *hdev) return ret; } @@ -3384,7 +3570,7 @@ index 4812c060afa2..01d0ff6169fd 100644 /* A HID packet conatins mappings for two buttons: btn1, btn1_macro, btn2, btn2_macro */ static void _btn_pair_to_hid_pkt(struct ally_gamepad_cfg *ally_cfg, enum btn_pair_index pair, -@@ -768,6 +856,8 @@ static struct attribute *gamepad_device_attrs[] = { +@@ -775,6 +863,8 @@ static struct attribute *gamepad_device_attrs[] = { &dev_attr_btn_mapping_reset.attr, &dev_attr_gamepad_mode.attr, &dev_attr_gamepad_apply_all.attr, @@ -3393,7 +3579,7 @@ index 4812c060afa2..01d0ff6169fd 100644 NULL }; -@@ -840,6 +930,9 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) +@@ -847,6 +937,9 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) ally_cfg->key_mapping[ally_cfg->mode - 1].btn_m2.button = BTN_KB_M2; _gamepad_apply_btn_pair(hdev, ally_cfg, btn_pair_m1_m2); @@ -3404,10 +3590,10 @@ index 4812c060afa2..01d0ff6169fd 100644 if (sysfs_create_groups(&hdev->dev.kobj, gamepad_device_attr_groups)) { err = -ENODEV; diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index 63a3b5caa71c..6ac79ad3c5f2 100644 +index 4e1eccbd99ad..160d00690d41 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -22,6 +22,7 @@ enum xpad_mode { +@@ -26,6 +26,7 @@ enum xpad_mode { enum xpad_cmd { xpad_cmd_set_mode = 0x01, xpad_cmd_set_mapping = 0x02, @@ -3415,7 +3601,7 @@ index 63a3b5caa71c..6ac79ad3c5f2 100644 xpad_cmd_set_leds = 0x08, xpad_cmd_check_ready = 0x0A, xpad_cmd_set_turbo = 0x0F, -@@ -31,6 +32,7 @@ enum xpad_cmd { +@@ -35,6 +36,7 @@ enum xpad_cmd { enum xpad_cmd_len { xpad_cmd_len_mode = 0x01, xpad_cmd_len_mapping = 0x2c, @@ -3423,7 +3609,7 @@ index 63a3b5caa71c..6ac79ad3c5f2 100644 xpad_cmd_len_leds = 0x0C, xpad_cmd_len_turbo = 0x20, }; -@@ -196,6 +198,10 @@ enum btn_pair_index { +@@ -200,6 +202,10 @@ enum btn_pair_index { struct device_attribute dev_attr_##_name = \ __ATTR(_sysfs_name, 0644, _name##_show, _name##_store) @@ -3438,10 +3624,10 @@ index 63a3b5caa71c..6ac79ad3c5f2 100644 2.48.1 -From d8b6f0e5e7bd8ae186455667c671cd0b5f1dd99f Mon Sep 17 00:00:00 2001 +From 746a094ea4e211db4c5992fa6ff33e3222a56211 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 5 Oct 2024 21:32:41 +1300 -Subject: [PATCH 15/30] hid-asus-ally: add JS deadzones +Subject: [PATCH 14/28] hid-asus-ally: add JS deadzones Signed-off-by: Luke D. Jones --- @@ -3450,10 +3636,10 @@ Signed-off-by: Luke D. Jones 2 files changed, 123 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 01d0ff6169fd..08d66a179523 100644 +index 2eae8a226f18..57f3ded74a66 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -260,6 +260,11 @@ struct btn_mapping { +@@ -256,6 +256,11 @@ struct btn_mapping { struct btn_data btn_m2; }; @@ -3465,7 +3651,7 @@ index 01d0ff6169fd..08d66a179523 100644 /* ROG Ally has many settings related to the gamepad, all using the same n-key endpoint */ struct ally_gamepad_cfg { struct hid_device *hdev; -@@ -275,6 +280,10 @@ struct ally_gamepad_cfg { +@@ -271,6 +276,10 @@ struct ally_gamepad_cfg { * max: 64 */ u8 vibration_intensity[2]; @@ -3476,7 +3662,7 @@ index 01d0ff6169fd..08d66a179523 100644 }; /* The hatswitch outputs integers, we use them to index this X|Y pair */ -@@ -529,6 +538,75 @@ static ssize_t gamepad_vibration_intensity_store(struct device *dev, +@@ -536,6 +545,75 @@ static ssize_t gamepad_vibration_intensity_store(struct device *dev, ALLY_DEVICE_ATTR_RW(gamepad_vibration_intensity, vibration_intensity); @@ -3552,7 +3738,7 @@ index 01d0ff6169fd..08d66a179523 100644 /* A HID packet conatins mappings for two buttons: btn1, btn1_macro, btn2, btn2_macro */ static void _btn_pair_to_hid_pkt(struct ally_gamepad_cfg *ally_cfg, enum btn_pair_index pair, -@@ -691,6 +769,9 @@ static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_c +@@ -698,6 +776,9 @@ static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_c if (ret < 0) return ret; ret = _gamepad_apply_turbo(hdev, ally_cfg); @@ -3562,7 +3748,7 @@ index 01d0ff6169fd..08d66a179523 100644 if (ret < 0) return ret; -@@ -867,6 +948,8 @@ static const struct attribute_group ally_controller_attr_group = { +@@ -874,6 +955,8 @@ static const struct attribute_group ally_controller_attr_group = { static const struct attribute_group *gamepad_device_attr_groups[] = { &ally_controller_attr_group, @@ -3571,7 +3757,7 @@ index 01d0ff6169fd..08d66a179523 100644 &btn_mapping_m1_attr_group, &btn_mapping_m2_attr_group, &btn_mapping_a_attr_group, -@@ -932,6 +1015,7 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) +@@ -939,6 +1022,7 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) ally_cfg->vibration_intensity[0] = 0x64; ally_cfg->vibration_intensity[1] = 0x64; @@ -3580,10 +3766,10 @@ index 01d0ff6169fd..08d66a179523 100644 drvdata.gamepad_cfg = ally_cfg; // Must asign before attr group setup if (sysfs_create_groups(&hdev->dev.kobj, gamepad_device_attr_groups)) { diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index 6ac79ad3c5f2..3dc14a5226f3 100644 +index 160d00690d41..b773130c2cf9 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -22,6 +22,7 @@ enum xpad_mode { +@@ -26,6 +26,7 @@ enum xpad_mode { enum xpad_cmd { xpad_cmd_set_mode = 0x01, xpad_cmd_set_mapping = 0x02, @@ -3591,7 +3777,7 @@ index 6ac79ad3c5f2..3dc14a5226f3 100644 xpad_cmd_set_vibe_intensity = 0x06, xpad_cmd_set_leds = 0x08, xpad_cmd_check_ready = 0x0A, -@@ -32,6 +33,7 @@ enum xpad_cmd { +@@ -36,6 +37,7 @@ enum xpad_cmd { enum xpad_cmd_len { xpad_cmd_len_mode = 0x01, xpad_cmd_len_mapping = 0x2c, @@ -3599,7 +3785,7 @@ index 6ac79ad3c5f2..3dc14a5226f3 100644 xpad_cmd_len_vibe_intensity = 0x02, xpad_cmd_len_leds = 0x0C, xpad_cmd_len_turbo = 0x20, -@@ -267,6 +269,43 @@ enum btn_pair_index { +@@ -271,6 +273,43 @@ enum btn_pair_index { return count; \ } @@ -3647,10 +3833,10 @@ index 6ac79ad3c5f2..3dc14a5226f3 100644 2.48.1 -From 43ddec5698ccbdba43359e14c9837b05c9568df3 Mon Sep 17 00:00:00 2001 +From 301445819d3892b148027092ce88ae8a10568362 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 5 Oct 2024 21:37:27 +1300 -Subject: [PATCH 16/30] hid-asus-ally: add trigger deadzones +Subject: [PATCH 15/28] hid-asus-ally: add trigger deadzones Signed-off-by: Luke D. Jones --- @@ -3659,10 +3845,10 @@ Signed-off-by: Luke D. Jones 2 files changed, 44 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 08d66a179523..066956922e17 100644 +index 57f3ded74a66..4a0bab7fb609 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -284,6 +284,8 @@ struct ally_gamepad_cfg { +@@ -280,6 +280,8 @@ struct ally_gamepad_cfg { /* deadzones */ struct deadzone ls_dz; // left stick struct deadzone rs_dz; // right stick @@ -3671,7 +3857,7 @@ index 08d66a179523..066956922e17 100644 }; /* The hatswitch outputs integers, we use them to index this X|Y pair */ -@@ -563,7 +565,20 @@ static ssize_t _gamepad_apply_deadzones(struct hid_device *hdev, +@@ -570,7 +572,20 @@ static ssize_t _gamepad_apply_deadzones(struct hid_device *hdev, hidbuf[7] = ally_cfg->rs_dz.outer; ret = asus_dev_set_report(hdev, hidbuf, FEATURE_ROG_ALLY_REPORT_SIZE); @@ -3692,7 +3878,7 @@ index 08d66a179523..066956922e17 100644 kfree(hidbuf); return ret; } -@@ -574,6 +589,10 @@ static void _gamepad_set_deadzones_default(struct ally_gamepad_cfg *ally_cfg) +@@ -581,6 +596,10 @@ static void _gamepad_set_deadzones_default(struct ally_gamepad_cfg *ally_cfg) ally_cfg->ls_dz.outer = 0x64; ally_cfg->rs_dz.inner = 0x00; ally_cfg->rs_dz.outer = 0x64; @@ -3703,7 +3889,7 @@ index 08d66a179523..066956922e17 100644 } static ssize_t axis_xyz_deadzone_index_show(struct device *dev, struct device_attribute *attr, -@@ -586,6 +605,8 @@ ALLY_DEVICE_ATTR_RO(axis_xyz_deadzone_index, deadzone_index); +@@ -593,6 +612,8 @@ ALLY_DEVICE_ATTR_RO(axis_xyz_deadzone_index, deadzone_index); ALLY_DEADZONES(axis_xy_left, ls_dz); ALLY_DEADZONES(axis_xy_right, rs_dz); @@ -3712,7 +3898,7 @@ index 08d66a179523..066956922e17 100644 static struct attribute *axis_xy_left_attrs[] = { &dev_attr_axis_xy_left_deadzone.attr, -@@ -607,6 +628,26 @@ static const struct attribute_group axis_xy_right_attr_group = { +@@ -614,6 +635,26 @@ static const struct attribute_group axis_xy_right_attr_group = { .attrs = axis_xy_right_attrs, }; @@ -3739,7 +3925,7 @@ index 08d66a179523..066956922e17 100644 /* A HID packet conatins mappings for two buttons: btn1, btn1_macro, btn2, btn2_macro */ static void _btn_pair_to_hid_pkt(struct ally_gamepad_cfg *ally_cfg, enum btn_pair_index pair, -@@ -950,6 +991,8 @@ static const struct attribute_group *gamepad_device_attr_groups[] = { +@@ -957,6 +998,8 @@ static const struct attribute_group *gamepad_device_attr_groups[] = { &ally_controller_attr_group, &axis_xy_left_attr_group, &axis_xy_right_attr_group, @@ -3749,10 +3935,10 @@ index 08d66a179523..066956922e17 100644 &btn_mapping_m2_attr_group, &btn_mapping_a_attr_group, diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index 3dc14a5226f3..32ed5caa3759 100644 +index b773130c2cf9..e0be54b4debb 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -23,6 +23,7 @@ enum xpad_cmd { +@@ -27,6 +27,7 @@ enum xpad_cmd { xpad_cmd_set_mode = 0x01, xpad_cmd_set_mapping = 0x02, xpad_cmd_set_js_dz = 0x04, /* deadzones */ @@ -3764,10 +3950,10 @@ index 3dc14a5226f3..32ed5caa3759 100644 2.48.1 -From 59bbde0bea81e630bc43d920c1ca06e204c6178a Mon Sep 17 00:00:00 2001 +From de93678e3d8aff108cfd0b97af82b6bc5996a484 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 6 Oct 2024 19:49:24 +1300 -Subject: [PATCH 17/30] hid-asus-ally: add anti-deadzones +Subject: [PATCH 16/28] hid-asus-ally: add anti-deadzones Signed-off-by: Luke D. Jones --- @@ -3776,10 +3962,10 @@ Signed-off-by: Luke D. Jones 2 files changed, 112 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 066956922e17..8d2165b52b3b 100644 +index 4a0bab7fb609..0d27799e1947 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -286,6 +286,9 @@ struct ally_gamepad_cfg { +@@ -282,6 +282,9 @@ struct ally_gamepad_cfg { struct deadzone rs_dz; // right stick struct deadzone lt_dz; // left trigger struct deadzone rt_dz; // right trigger @@ -3789,7 +3975,7 @@ index 066956922e17..8d2165b52b3b 100644 }; /* The hatswitch outputs integers, we use them to index this X|Y pair */ -@@ -608,7 +611,109 @@ ALLY_DEADZONES(axis_xy_right, rs_dz); +@@ -615,7 +618,109 @@ ALLY_DEADZONES(axis_xy_right, rs_dz); ALLY_DEADZONES(axis_z_left, lt_dz); ALLY_DEADZONES(axis_z_right, rt_dz); @@ -3899,7 +4085,7 @@ index 066956922e17..8d2165b52b3b 100644 &dev_attr_axis_xy_left_deadzone.attr, &dev_attr_axis_xyz_deadzone_index.attr, NULL -@@ -619,6 +724,7 @@ static const struct attribute_group axis_xy_left_attr_group = { +@@ -626,6 +731,7 @@ static const struct attribute_group axis_xy_left_attr_group = { }; static struct attribute *axis_xy_right_attrs[] = { @@ -3907,7 +4093,7 @@ index 066956922e17..8d2165b52b3b 100644 &dev_attr_axis_xy_right_deadzone.attr, &dev_attr_axis_xyz_deadzone_index.attr, NULL -@@ -813,6 +919,9 @@ static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_c +@@ -820,6 +926,9 @@ static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_c if (ret < 0) return ret; ret = _gamepad_apply_deadzones(hdev, ally_cfg); @@ -3917,7 +4103,7 @@ index 066956922e17..8d2165b52b3b 100644 if (ret < 0) return ret; -@@ -1059,6 +1168,7 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) +@@ -1066,6 +1175,7 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) ally_cfg->vibration_intensity[0] = 0x64; ally_cfg->vibration_intensity[1] = 0x64; _gamepad_set_deadzones_default(ally_cfg); @@ -3926,10 +4112,10 @@ index 066956922e17..8d2165b52b3b 100644 drvdata.gamepad_cfg = ally_cfg; // Must asign before attr group setup if (sysfs_create_groups(&hdev->dev.kobj, gamepad_device_attr_groups)) { diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index 32ed5caa3759..69f59592dd50 100644 +index e0be54b4debb..70ef69ac476b 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -28,6 +28,7 @@ enum xpad_cmd { +@@ -32,6 +32,7 @@ enum xpad_cmd { xpad_cmd_set_leds = 0x08, xpad_cmd_check_ready = 0x0A, xpad_cmd_set_turbo = 0x0F, @@ -3937,7 +4123,7 @@ index 32ed5caa3759..69f59592dd50 100644 }; /* the xpad_cmd determines which feature is set or queried */ -@@ -38,6 +39,7 @@ enum xpad_cmd_len { +@@ -42,6 +43,7 @@ enum xpad_cmd_len { xpad_cmd_len_vibe_intensity = 0x02, xpad_cmd_len_leds = 0x0C, xpad_cmd_len_turbo = 0x20, @@ -3949,10 +4135,10 @@ index 32ed5caa3759..69f59592dd50 100644 2.48.1 -From 7147a33b33d9370abf36025a92edf7a481795423 Mon Sep 17 00:00:00 2001 +From f71d28fca54a57d017494c29e32ce7c8eb8328ae Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 6 Oct 2024 21:22:40 +1300 -Subject: [PATCH 18/30] hid-asus-ally: add JS response curves +Subject: [PATCH 17/28] hid-asus-ally: add JS response curves Signed-off-by: Luke D. Jones --- @@ -3961,7 +4147,7 @@ Signed-off-by: Luke D. Jones 2 files changed, 141 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 8d2165b52b3b..705e6ab62d85 100644 +index 0d27799e1947..d41e78c196a0 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c @@ -5,10 +5,12 @@ @@ -3977,7 +4163,7 @@ index 8d2165b52b3b..705e6ab62d85 100644 #include "linux/slab.h" #include #include -@@ -265,6 +267,17 @@ struct deadzone { +@@ -261,6 +263,17 @@ struct deadzone { u8 outer; }; @@ -3995,7 +4181,7 @@ index 8d2165b52b3b..705e6ab62d85 100644 /* ROG Ally has many settings related to the gamepad, all using the same n-key endpoint */ struct ally_gamepad_cfg { struct hid_device *hdev; -@@ -289,6 +302,9 @@ struct ally_gamepad_cfg { +@@ -285,6 +298,9 @@ struct ally_gamepad_cfg { /* anti-deadzones */ u8 ls_adz; // left stick u8 rs_adz; // right stick @@ -4005,7 +4191,7 @@ index 8d2165b52b3b..705e6ab62d85 100644 }; /* The hatswitch outputs integers, we use them to index this X|Y pair */ -@@ -712,10 +728,85 @@ static ssize_t axis_xy_right_anti_deadzone_store(struct device *dev, +@@ -719,10 +735,85 @@ static ssize_t axis_xy_right_anti_deadzone_store(struct device *dev, } ALLY_DEVICE_ATTR_RW(axis_xy_right_anti_deadzone, anti_deadzone); @@ -4091,7 +4277,7 @@ index 8d2165b52b3b..705e6ab62d85 100644 NULL }; static const struct attribute_group axis_xy_left_attr_group = { -@@ -727,6 +818,14 @@ static struct attribute *axis_xy_right_attrs[] = { +@@ -734,6 +825,14 @@ static struct attribute *axis_xy_right_attrs[] = { &dev_attr_axis_xy_right_anti_deadzone.attr, &dev_attr_axis_xy_right_deadzone.attr, &dev_attr_axis_xyz_deadzone_index.attr, @@ -4106,7 +4292,7 @@ index 8d2165b52b3b..705e6ab62d85 100644 NULL }; static const struct attribute_group axis_xy_right_attr_group = { -@@ -922,6 +1021,9 @@ static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_c +@@ -929,6 +1028,9 @@ static ssize_t _gamepad_apply_all(struct hid_device *hdev, struct ally_gamepad_c if (ret < 0) return ret; ret = _gamepad_apply_js_ADZ(hdev, ally_cfg); @@ -4116,7 +4302,7 @@ index 8d2165b52b3b..705e6ab62d85 100644 if (ret < 0) return ret; -@@ -1169,6 +1271,7 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) +@@ -1176,6 +1278,7 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) ally_cfg->vibration_intensity[1] = 0x64; _gamepad_set_deadzones_default(ally_cfg); _gamepad_set_anti_deadzones_default(ally_cfg); @@ -4125,10 +4311,10 @@ index 8d2165b52b3b..705e6ab62d85 100644 drvdata.gamepad_cfg = ally_cfg; // Must asign before attr group setup if (sysfs_create_groups(&hdev->dev.kobj, gamepad_device_attr_groups)) { diff --git a/drivers/hid/hid-asus-ally.h b/drivers/hid/hid-asus-ally.h -index 69f59592dd50..c83817589082 100644 +index 70ef69ac476b..512e51d2761f 100644 --- a/drivers/hid/hid-asus-ally.h +++ b/drivers/hid/hid-asus-ally.h -@@ -28,6 +28,7 @@ enum xpad_cmd { +@@ -32,6 +32,7 @@ enum xpad_cmd { xpad_cmd_set_leds = 0x08, xpad_cmd_check_ready = 0x0A, xpad_cmd_set_turbo = 0x0F, @@ -4136,7 +4322,7 @@ index 69f59592dd50..c83817589082 100644 xpad_cmd_set_adz = 0x18, }; -@@ -39,6 +40,7 @@ enum xpad_cmd_len { +@@ -43,6 +44,7 @@ enum xpad_cmd_len { xpad_cmd_len_vibe_intensity = 0x02, xpad_cmd_len_leds = 0x0C, xpad_cmd_len_turbo = 0x20, @@ -4144,7 +4330,7 @@ index 69f59592dd50..c83817589082 100644 xpad_cmd_len_adz = 0x02, }; -@@ -309,6 +311,42 @@ enum btn_pair_index { +@@ -313,6 +315,42 @@ enum btn_pair_index { ALLY_DEADZONE_STORE(_fname##_deadzone, _mname); \ ALLY_DEVICE_ATTR_RW(_fname##_deadzone, deadzone) @@ -4191,21 +4377,24 @@ index 69f59592dd50..c83817589082 100644 2.48.1 -From 7687ce770f492f7c4ce0d3528e4a6dc994a6836e Mon Sep 17 00:00:00 2001 +From 6c6deac3f1bd9bbdd3dc2c363c66073f4a9e998f Mon Sep 17 00:00:00 2001 From: Luke Jones Date: Mon, 10 Feb 2025 17:15:01 +1300 -Subject: [PATCH 19/30] hid-asus-ally: mcu_version attribute +Subject: [PATCH 18/28] hid-asus-ally: mcu_version attribute + +Add the mcu_version sysfs attribute so that userspace has a way to check +the MCU FW version. Signed-off-by: Luke Jones --- - drivers/hid/hid-asus-ally.c | 18 ++++++++++++++---- - 1 file changed, 14 insertions(+), 4 deletions(-) + drivers/hid/hid-asus-ally.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 705e6ab62d85..2783cc054acd 100644 +index d41e78c196a0..3e6250a7bd48 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -380,6 +380,7 @@ static struct ally_drvdata { +@@ -376,6 +376,7 @@ static struct ally_drvdata { struct ally_gamepad_cfg *gamepad_cfg; struct ally_rgb_dev *led_rgb_dev; struct ally_rgb_data led_rgb_data; @@ -4213,7 +4402,7 @@ index 705e6ab62d85..2783cc054acd 100644 } drvdata; /** -@@ -1184,6 +1185,13 @@ static ssize_t gamepad_mode_store(struct device *dev, struct device_attribute *a +@@ -1191,6 +1192,13 @@ static ssize_t gamepad_mode_store(struct device *dev, struct device_attribute *a DEVICE_ATTR_RW(gamepad_mode); @@ -4227,7 +4416,7 @@ index 705e6ab62d85..2783cc054acd 100644 /* ROOT LEVEL ATTRS *******************************************************************************/ static struct attribute *gamepad_device_attrs[] = { &dev_attr_btn_mapping_reset.attr, -@@ -1191,6 +1199,7 @@ static struct attribute *gamepad_device_attrs[] = { +@@ -1198,6 +1206,7 @@ static struct attribute *gamepad_device_attrs[] = { &dev_attr_gamepad_apply_all.attr, &dev_attr_gamepad_vibration_intensity.attr, &dev_attr_gamepad_vibration_intensity_index.attr, @@ -4235,53 +4424,22 @@ index 705e6ab62d85..2783cc054acd 100644 NULL }; -@@ -1929,14 +1938,13 @@ static int mcu_request_version(struct hid_device *hdev) - return ret; - } - --static void mcu_maybe_warn_version(struct hid_device *hdev, int idProduct) -+static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct) - { - int min_version, version; -- struct asus_wmi *asus; -- struct device *dev; - - min_version = ROG_ALLY_X_MIN_MCU; - version = mcu_request_version(hdev); -+ drvdata.mcu_version = version; - if (version) { - switch (idProduct) { - case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY: -@@ -1950,11 +1958,12 @@ static void mcu_maybe_warn_version(struct hid_device *hdev, int idProduct) - - hid_info(hdev, "Ally device MCU version: %d\n", version); - if (version < min_version) { -- set_ally_mcu_hack_available(false); - hid_warn(hdev, - "The MCU version must be %d or greater\n" - "Please update your MCU with official ASUS firmware release\n", - min_version); -+ } else { -+ set_ally_mcu_hack_available(false); +@@ -1967,6 +1976,7 @@ static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct) + min_version = 0; } - } -@@ -2146,6 +2155,7 @@ static void __exit rog_ally_exit(void) - module_init(rog_ally_init); - module_exit(rog_ally_exit); - -+MODULE_IMPORT_NS("ASUS_WMI"); - MODULE_AUTHOR("Luke D. Jones"); - MODULE_DESCRIPTION("HID Driver for ASUS ROG Ally gamepad configuration."); - MODULE_LICENSE("GPL"); ++ drvdata.mcu_version = version; + if (version < min_version) { + hid_warn(hdev, + "The MCU firmware version must be %d or greater to avoid issues with suspend.\n", -- 2.48.1 -From 062c28dce932ffe640c95165a9cfe6b2e1e54aaa Mon Sep 17 00:00:00 2001 +From d379f0d42f0bd1ed7c1e78435e9b09f6e5156fa3 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Thu, 10 Oct 2024 11:15:36 +1300 -Subject: [PATCH 20/30] hid-asus-ally: add calibrations (wip) +Subject: [PATCH 19/28] hid-asus-ally: add calibrations (wip) Signed-off-by: Luke D. Jones --- @@ -4289,10 +4447,10 @@ Signed-off-by: Luke D. Jones 1 file changed, 95 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 2783cc054acd..79a3cfffc01d 100644 +index 3e6250a7bd48..5c12d8fd1c8e 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c -@@ -278,6 +278,28 @@ struct response_curve { +@@ -274,6 +274,28 @@ struct response_curve { uint8_t response_pct_4; } __packed; @@ -4321,7 +4479,7 @@ index 2783cc054acd..79a3cfffc01d 100644 /* ROG Ally has many settings related to the gamepad, all using the same n-key endpoint */ struct ally_gamepad_cfg { struct hid_device *hdev; -@@ -305,6 +327,9 @@ struct ally_gamepad_cfg { +@@ -301,6 +323,9 @@ struct ally_gamepad_cfg { /* joystick response curves */ struct response_curve ls_rc; struct response_curve rs_rc; @@ -4331,7 +4489,7 @@ index 2783cc054acd..79a3cfffc01d 100644 }; /* The hatswitch outputs integers, we use them to index this X|Y pair */ -@@ -383,6 +408,18 @@ static struct ally_drvdata { +@@ -379,6 +404,18 @@ static struct ally_drvdata { uint mcu_version; } drvdata; @@ -4350,7 +4508,7 @@ index 2783cc054acd..79a3cfffc01d 100644 /** * asus_dev_set_report - send set report request to device. * -@@ -796,6 +833,63 @@ ALLY_JS_RC_POINT(axis_xy_right, response, 2); +@@ -803,6 +840,63 @@ ALLY_JS_RC_POINT(axis_xy_right, response, 2); ALLY_JS_RC_POINT(axis_xy_right, response, 3); ALLY_JS_RC_POINT(axis_xy_right, response, 4); @@ -4414,7 +4572,7 @@ index 2783cc054acd..79a3cfffc01d 100644 static struct attribute *axis_xy_left_attrs[] = { &dev_attr_axis_xy_left_anti_deadzone.attr, &dev_attr_axis_xy_left_deadzone.attr, -@@ -1275,6 +1369,7 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) +@@ -1282,6 +1376,7 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) ally_cfg->key_mapping[ally_cfg->mode - 1].btn_m1.button = BTN_KB_M1; ally_cfg->key_mapping[ally_cfg->mode - 1].btn_m2.button = BTN_KB_M2; _gamepad_apply_btn_pair(hdev, ally_cfg, btn_pair_m1_m2); @@ -4426,64 +4584,17 @@ index 2783cc054acd..79a3cfffc01d 100644 2.48.1 -From 747ff0ec3802785d28b703ab9f369fee6fd53376 Mon Sep 17 00:00:00 2001 -From: Luke Jones -Date: Tue, 11 Feb 2025 13:24:02 +1300 -Subject: [PATCH 21/30] hid-asus-ally: set default backface btns to F14/15 - -Signed-off-by: Luke Jones ---- - drivers/hid/hid-asus-ally.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index 79a3cfffc01d..f4d852c0481d 100644 ---- a/drivers/hid/hid-asus-ally.c -+++ b/drivers/hid/hid-asus-ally.c -@@ -1354,6 +1354,8 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) - input_dev->uniq = hdev->uniq; - input_dev->name = "ASUS ROG Ally Config"; - input_set_capability(input_dev, EV_KEY, KEY_PROG1); -+ input_set_capability(input_dev, EV_KEY, KEY_F14); -+ input_set_capability(input_dev, EV_KEY, KEY_F15); - input_set_capability(input_dev, EV_KEY, KEY_F16); - input_set_capability(input_dev, EV_KEY, KEY_F17); - input_set_capability(input_dev, EV_KEY, KEY_F18); -@@ -1366,8 +1368,8 @@ static struct ally_gamepad_cfg *ally_gamepad_cfg_create(struct hid_device *hdev) - - /* ignore all errors for this as they are related to USB HID I/O */ - _gamepad_set_xpad_default(ally_cfg); -- ally_cfg->key_mapping[ally_cfg->mode - 1].btn_m1.button = BTN_KB_M1; -- ally_cfg->key_mapping[ally_cfg->mode - 1].btn_m2.button = BTN_KB_M2; -+ ally_cfg->key_mapping[ally_cfg->mode - 1].btn_m1.button = BTN_KB_F15; -+ ally_cfg->key_mapping[ally_cfg->mode - 1].btn_m2.button = BTN_KB_F14; - _gamepad_apply_btn_pair(hdev, ally_cfg, btn_pair_m1_m2); - gamepad_get_calibration(hdev); - -@@ -1594,6 +1596,8 @@ static struct input_dev *ally_x_setup_input(struct hid_device *hdev) - input_set_capability(input, EV_KEY, BTN_THUMBR); - - input_set_capability(input, EV_KEY, KEY_PROG1); -+ input_set_capability(input, EV_KEY, KEY_F14); -+ input_set_capability(input, EV_KEY, KEY_F15); - input_set_capability(input, EV_KEY, KEY_F16); - input_set_capability(input, EV_KEY, KEY_F17); - input_set_capability(input, EV_KEY, KEY_F18); --- -2.48.1 - - -From a6761693908de1334694a354f4ad93a0a25e9f72 Mon Sep 17 00:00:00 2001 +From de46ea402c48e6b14589afc60079ac8f65fee848 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 6 Nov 2024 00:27:03 +0300 -Subject: [PATCH 22/30] debug by default +Subject: [PATCH 20/28] debug by default --- drivers/hid/hid-asus-ally.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c -index f4d852c0481d..b5688f1401a5 100644 +index 5c12d8fd1c8e..72925d034fa4 100644 --- a/drivers/hid/hid-asus-ally.c +++ b/drivers/hid/hid-asus-ally.c @@ -21,6 +21,8 @@ @@ -4499,10 +4610,10 @@ index f4d852c0481d..b5688f1401a5 100644 2.48.1 -From 18cc2e984ebf1b7f7abf7d28e78c56b23840d64f Mon Sep 17 00:00:00 2001 +From df8ecffce91ab38d83cd844409ba697f672da767 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 22 Sep 2024 21:40:46 +1200 -Subject: [PATCH 23/30] platform/x86: asus-wmi: export symbols used for +Subject: [PATCH 21/28] platform/x86: asus-wmi: export symbols used for read/write WMI Export some rather helpful read/write WMI symbols using a namespace. @@ -4513,15 +4624,15 @@ Also does a slight refactor of internals of these functions. Signed-off-by: Luke D. Jones Reviewed-by: Mario Limonciello --- - drivers/platform/x86/asus-wmi.c | 44 ++++++++++++++++++++-- - include/linux/platform_data/x86/asus-wmi.h | 10 +++++ + drivers/platform/x86/asus-wmi.c | 45 ++++++++++++++++++++-- + include/linux/platform_data/x86/asus-wmi.h | 9 +++++ 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index 2afb949ac397..c39b79571ec2 100644 +index 671c726f85b8..27085df2b47a 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c -@@ -398,7 +398,7 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) +@@ -389,7 +389,7 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) { return asus_wmi_evaluate_method3(method_id, arg0, arg1, 0, retval); } @@ -4530,12 +4641,13 @@ index 2afb949ac397..c39b79571ec2 100644 static int asus_wmi_evaluate_method5(u32 method_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *retval) -@@ -562,12 +562,50 @@ static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval) +@@ -553,12 +553,51 @@ static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval) return 0; } --static int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, +-int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, - u32 *retval) ++ +/** + * asus_wmi_get_devstate_dsts() - Get the WMI function state. + * @dev_id: The WMI method ID to call. @@ -4584,18 +4696,19 @@ index 2afb949ac397..c39b79571ec2 100644 /* Helper for special devices with magic return codes */ static int asus_wmi_get_devstate_bits(struct asus_wmi *asus, diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index f1b96f90e8e2..7c886a93d554 100644 +index a32cb8865b2f..96ff25b2b51b 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h -@@ -159,11 +159,21 @@ - +@@ -160,6 +160,7 @@ #if IS_REACHABLE(CONFIG_ASUS_WMI) - void set_ally_mcu_hack_available(bool enabled); + void set_ally_mcu_hack(bool enabled); + void set_ally_mcu_powersave(bool enabled); +int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval); -+int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval); + int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval); int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval); #else - static inline void set_ally_mcu_hack_available(bool enabled) { +@@ -175,6 +176,14 @@ static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) + { return -ENODEV; } +static inline int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval) @@ -4613,10 +4726,10 @@ index f1b96f90e8e2..7c886a93d554 100644 2.48.1 -From 61ce3d6b7e6dbcfbdaff51bd2cb707c79a3a071f Mon Sep 17 00:00:00 2001 +From 903e02728fde7a62dc38686ead6bdcd362317d13 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 22 Sep 2024 21:39:43 +1200 -Subject: [PATCH 24/30] platform/x86: asus-armoury: move existing tunings to +Subject: [PATCH 22/28] platform/x86: asus-armoury: move existing tunings to asus-armoury module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -5407,7 +5520,7 @@ index 000000000000..440f41c5df3b + +#endif /* _ASUS_ARMOURY_H_ */ diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index c39b79571ec2..9f0153ee8601 100644 +index 27085df2b47a..1377682461d7 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -55,8 +55,6 @@ module_param(fnlock_default, bool, 0444); @@ -5429,7 +5542,7 @@ index c39b79571ec2..9f0153ee8601 100644 #define FAN_CURVE_POINTS 8 diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index 7c886a93d554..3fd11c782ee2 100644 +index 96ff25b2b51b..4574e30c53fc 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -6,6 +6,9 @@ @@ -5446,10 +5559,10 @@ index 7c886a93d554..3fd11c782ee2 100644 2.48.1 -From 28377eeea2e83f8c7335d8d1a2c91b52a6b06165 Mon Sep 17 00:00:00 2001 +From 972ac717967430e3ed2093030f2b83b1e50d8de0 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Thu, 19 Sep 2024 17:23:35 +1200 -Subject: [PATCH 25/30] platform/x86: asus-armoury: add panel_hd_mode attribute +Subject: [PATCH 23/28] platform/x86: asus-armoury: add panel_hd_mode attribute Add panel_hd_mode to toggle the panel mode between single and high definition modes. @@ -5493,7 +5606,7 @@ index d2e8c21d62dc..716bf96b6b58 100644 static int asus_fw_attr_add(void) diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index 3fd11c782ee2..e1ae2c1e229c 100644 +index 4574e30c53fc..62a9adb1af2f 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -76,6 +76,7 @@ @@ -5508,10 +5621,10 @@ index 3fd11c782ee2..e1ae2c1e229c 100644 2.48.1 -From 43a9bdf26bb75ad00ba05559e05956a6ac525369 Mon Sep 17 00:00:00 2001 +From b826fbc727b8dec8d437a6abfd099354870114b1 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 2 Jun 2024 14:44:31 +1200 -Subject: [PATCH 26/30] platform/x86: asus-armoury: add apu-mem control support +Subject: [PATCH 24/28] platform/x86: asus-armoury: add apu-mem control support Implement the APU memory size control under the asus-armoury module using the fw_attributes class. @@ -5659,7 +5772,7 @@ index 716bf96b6b58..298f7b203d7c 100644 { &charge_mode_attr_group, ASUS_WMI_DEVID_CHARGE_MODE }, { &boot_sound_attr_group, ASUS_WMI_DEVID_BOOT_SOUND }, diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index e1ae2c1e229c..b7e2582763a8 100644 +index 62a9adb1af2f..f3494a9efea7 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -137,6 +137,8 @@ @@ -5675,10 +5788,10 @@ index e1ae2c1e229c..b7e2582763a8 100644 2.48.1 -From d1452cbaa217541e9b5ebcb7c9c963241df75731 Mon Sep 17 00:00:00 2001 +From 111ca7b501b6ba2271ea581fc2f8e6281fdb4603 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Wed, 18 Sep 2024 21:19:12 +1200 -Subject: [PATCH 27/30] platform/x86: asus-armoury: add core count control +Subject: [PATCH 25/28] platform/x86: asus-armoury: add core count control Implement Intel core enablement under the asus-armoury module using the fw_attributes class. @@ -6024,7 +6137,7 @@ index 440f41c5df3b..5d6bef6d2b12 100644 + #endif /* _ASUS_ARMOURY_H_ */ diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index b7e2582763a8..0f45d5549e10 100644 +index f3494a9efea7..e735f35b423c 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -137,6 +137,11 @@ @@ -6043,10 +6156,10 @@ index b7e2582763a8..0f45d5549e10 100644 2.48.1 -From 7946d6a16668295187f687ad0d3992cce3273641 Mon Sep 17 00:00:00 2001 +From d5134659069c909c57715433a56aa804b9404318 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Mon, 3 Jun 2024 12:04:41 +1200 -Subject: [PATCH 28/30] platform/x86: asus-wmi: deprecate bios features +Subject: [PATCH 26/28] platform/x86: asus-wmi: deprecate bios features With the existence of the asus-armoury module the attributes no-longer need to live under the /sys/devices/platform/asus-nb-wmi/ path. @@ -6223,12 +6336,12 @@ index 294364cc7478..b160173a530e 100644 tristate "Asus Notebook WMI Driver" depends on ASUS_WMI diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index 9f0153ee8601..bcf0cab8f9ae 100644 +index 1377682461d7..519ab1899d85 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c -@@ -344,6 +344,15 @@ void set_ally_mcu_hack_available(bool enabled) - } - EXPORT_SYMBOL_NS_GPL(set_ally_mcu_hack_available, "ASUS_WMI"); +@@ -335,6 +335,15 @@ struct asus_wmi { + /* Global to allow setting externally without requiring driver data */ + static bool use_ally_mcu_hack; +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) +static void asus_wmi_show_deprecated(void) @@ -6242,7 +6355,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 /* WMI ************************************************************************/ static int asus_wmi_evaluate_method3(u32 method_id, -@@ -734,6 +743,7 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus) +@@ -726,6 +735,7 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus) } /* Charging mode, 1=Barrel, 2=USB ******************************************/ @@ -6250,7 +6363,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t charge_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -744,12 +754,16 @@ static ssize_t charge_mode_show(struct device *dev, +@@ -736,12 +746,16 @@ static ssize_t charge_mode_show(struct device *dev, if (result < 0) return result; @@ -6267,7 +6380,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t dgpu_disable_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -760,6 +774,8 @@ static ssize_t dgpu_disable_show(struct device *dev, +@@ -752,6 +766,8 @@ static ssize_t dgpu_disable_show(struct device *dev, if (result < 0) return result; @@ -6276,7 +6389,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -813,8 +829,10 @@ static ssize_t dgpu_disable_store(struct device *dev, +@@ -805,8 +821,10 @@ static ssize_t dgpu_disable_store(struct device *dev, return count; } static DEVICE_ATTR_RW(dgpu_disable); @@ -6287,7 +6400,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t egpu_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -825,6 +843,8 @@ static ssize_t egpu_enable_show(struct device *dev, +@@ -817,6 +835,8 @@ static ssize_t egpu_enable_show(struct device *dev, if (result < 0) return result; @@ -6296,7 +6409,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -881,8 +901,10 @@ static ssize_t egpu_enable_store(struct device *dev, +@@ -873,8 +893,10 @@ static ssize_t egpu_enable_store(struct device *dev, return count; } static DEVICE_ATTR_RW(egpu_enable); @@ -6307,7 +6420,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t egpu_connected_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -893,12 +915,16 @@ static ssize_t egpu_connected_show(struct device *dev, +@@ -885,12 +907,16 @@ static ssize_t egpu_connected_show(struct device *dev, if (result < 0) return result; @@ -6324,7 +6437,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t gpu_mux_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -909,6 +935,8 @@ static ssize_t gpu_mux_mode_show(struct device *dev, +@@ -901,6 +927,8 @@ static ssize_t gpu_mux_mode_show(struct device *dev, if (result < 0) return result; @@ -6333,7 +6446,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -967,6 +995,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev, +@@ -959,6 +987,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev, return count; } static DEVICE_ATTR_RW(gpu_mux_mode); @@ -6341,7 +6454,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 /* TUF Laptop Keyboard RGB Modes **********************************************/ static ssize_t kbd_rgb_mode_store(struct device *dev, -@@ -1090,6 +1119,7 @@ static const struct attribute_group *kbd_rgb_mode_groups[] = { +@@ -1082,6 +1111,7 @@ static const struct attribute_group *kbd_rgb_mode_groups[] = { }; /* Tunable: PPT: Intel=PL1, AMD=SPPT *****************************************/ @@ -6349,7 +6462,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t ppt_pl2_sppt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) -@@ -1128,6 +1158,8 @@ static ssize_t ppt_pl2_sppt_show(struct device *dev, +@@ -1120,6 +1150,8 @@ static ssize_t ppt_pl2_sppt_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -6358,7 +6471,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%u\n", asus->ppt_pl2_sppt); } static DEVICE_ATTR_RW(ppt_pl2_sppt); -@@ -1170,6 +1202,8 @@ static ssize_t ppt_pl1_spl_show(struct device *dev, +@@ -1162,6 +1194,8 @@ static ssize_t ppt_pl1_spl_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -6367,7 +6480,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%u\n", asus->ppt_pl1_spl); } static DEVICE_ATTR_RW(ppt_pl1_spl); -@@ -1213,6 +1247,8 @@ static ssize_t ppt_fppt_show(struct device *dev, +@@ -1205,6 +1239,8 @@ static ssize_t ppt_fppt_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -6376,7 +6489,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%u\n", asus->ppt_fppt); } static DEVICE_ATTR_RW(ppt_fppt); -@@ -1256,6 +1292,8 @@ static ssize_t ppt_apu_sppt_show(struct device *dev, +@@ -1248,6 +1284,8 @@ static ssize_t ppt_apu_sppt_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -6385,7 +6498,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%u\n", asus->ppt_apu_sppt); } static DEVICE_ATTR_RW(ppt_apu_sppt); -@@ -1299,6 +1337,8 @@ static ssize_t ppt_platform_sppt_show(struct device *dev, +@@ -1291,6 +1329,8 @@ static ssize_t ppt_platform_sppt_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -6394,7 +6507,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%u\n", asus->ppt_platform_sppt); } static DEVICE_ATTR_RW(ppt_platform_sppt); -@@ -1342,6 +1382,8 @@ static ssize_t nv_dynamic_boost_show(struct device *dev, +@@ -1334,6 +1374,8 @@ static ssize_t nv_dynamic_boost_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -6403,7 +6516,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%u\n", asus->nv_dynamic_boost); } static DEVICE_ATTR_RW(nv_dynamic_boost); -@@ -1385,11 +1427,15 @@ static ssize_t nv_temp_target_show(struct device *dev, +@@ -1377,9 +1419,12 @@ static ssize_t nv_temp_target_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -6415,11 +6528,16 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ /* Ally MCU Powersave ********************************************************/ + +@@ -1420,6 +1465,7 @@ void set_ally_mcu_powersave(bool enabled) + } + EXPORT_SYMBOL_NS_GPL(set_ally_mcu_powersave, "ASUS_WMI"); + +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t mcu_powersave_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -1400,6 +1446,8 @@ static ssize_t mcu_powersave_show(struct device *dev, +@@ -1430,6 +1476,8 @@ static ssize_t mcu_powersave_show(struct device *dev, if (result < 0) return result; @@ -6428,7 +6546,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -1435,6 +1483,7 @@ static ssize_t mcu_powersave_store(struct device *dev, +@@ -1465,6 +1513,7 @@ static ssize_t mcu_powersave_store(struct device *dev, return count; } static DEVICE_ATTR_RW(mcu_powersave); @@ -6436,7 +6554,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 /* Battery ********************************************************************/ -@@ -2308,6 +2357,7 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) +@@ -2338,6 +2387,7 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) } /* Panel Overdrive ************************************************************/ @@ -6444,7 +6562,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t panel_od_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -2318,6 +2368,8 @@ static ssize_t panel_od_show(struct device *dev, +@@ -2348,6 +2398,8 @@ static ssize_t panel_od_show(struct device *dev, if (result < 0) return result; @@ -6453,7 +6571,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -2354,9 +2406,10 @@ static ssize_t panel_od_store(struct device *dev, +@@ -2384,9 +2436,10 @@ static ssize_t panel_od_store(struct device *dev, return count; } static DEVICE_ATTR_RW(panel_od); @@ -6465,7 +6583,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t boot_sound_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -2367,6 +2420,8 @@ static ssize_t boot_sound_show(struct device *dev, +@@ -2397,6 +2450,8 @@ static ssize_t boot_sound_show(struct device *dev, if (result < 0) return result; @@ -6474,7 +6592,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -2402,8 +2457,10 @@ static ssize_t boot_sound_store(struct device *dev, +@@ -2432,8 +2487,10 @@ static ssize_t boot_sound_store(struct device *dev, return count; } static DEVICE_ATTR_RW(boot_sound); @@ -6485,7 +6603,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t mini_led_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -2434,6 +2491,8 @@ static ssize_t mini_led_mode_show(struct device *dev, +@@ -2464,6 +2521,8 @@ static ssize_t mini_led_mode_show(struct device *dev, } } @@ -6494,7 +6612,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 return sysfs_emit(buf, "%d\n", value); } -@@ -2504,10 +2563,13 @@ static ssize_t available_mini_led_mode_show(struct device *dev, +@@ -2534,10 +2593,13 @@ static ssize_t available_mini_led_mode_show(struct device *dev, return sysfs_emit(buf, "0 1 2\n"); } @@ -6508,7 +6626,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 /* Quirks *********************************************************************/ -@@ -3795,6 +3857,7 @@ static int throttle_thermal_policy_set_default(struct asus_wmi *asus) +@@ -3825,6 +3887,7 @@ static int throttle_thermal_policy_set_default(struct asus_wmi *asus) return throttle_thermal_policy_write(asus); } @@ -6516,7 +6634,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 static ssize_t throttle_thermal_policy_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -3838,6 +3901,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, +@@ -3868,6 +3931,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, * Throttle thermal policy: 0 - default, 1 - overboost, 2 - silent */ static DEVICE_ATTR_RW(throttle_thermal_policy); @@ -6524,7 +6642,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 /* Platform profile ***********************************************************/ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof, -@@ -4435,27 +4499,29 @@ static struct attribute *platform_attributes[] = { +@@ -4465,27 +4529,29 @@ static struct attribute *platform_attributes[] = { &dev_attr_camera.attr, &dev_attr_cardr.attr, &dev_attr_touchpad.attr, @@ -6572,7 +6690,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 NULL }; -@@ -4477,7 +4543,11 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, +@@ -4507,7 +4573,11 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, devid = ASUS_WMI_DEVID_LID_RESUME; else if (attr == &dev_attr_als_enable.attr) devid = ASUS_WMI_DEVID_ALS_ENABLE; @@ -6585,7 +6703,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 devid = ASUS_WMI_DEVID_CHARGE_MODE; else if (attr == &dev_attr_egpu_enable.attr) ok = asus->egpu_enable_available; -@@ -4515,6 +4585,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, +@@ -4545,6 +4615,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, ok = asus->mini_led_dev_id != 0; else if (attr == &dev_attr_available_mini_led_mode.attr) ok = asus->mini_led_dev_id != 0; @@ -6593,7 +6711,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 if (devid != -1) { ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0); -@@ -4766,6 +4837,7 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -4797,6 +4868,7 @@ static int asus_wmi_add(struct platform_device *pdev) } /* ensure defaults for tunables */ @@ -6601,7 +6719,7 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 asus->ppt_pl2_sppt = 5; asus->ppt_pl1_spl = 5; asus->ppt_apu_sppt = 5; -@@ -4787,17 +4859,18 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -4818,17 +4890,18 @@ static int asus_wmi_add(struct platform_device *pdev) asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX; else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX_VIVO)) asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX_VIVO; @@ -6629,10 +6747,10 @@ index 9f0153ee8601..bcf0cab8f9ae 100644 2.48.1 -From 81635e56f75e745444df8dd5dd182ba114c38e1f Mon Sep 17 00:00:00 2001 +From 55c383056b5db6f4b123aa72df47350be4a898d8 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Thu, 19 Sep 2024 17:19:37 +1200 -Subject: [PATCH 29/30] platform/x86: asus-armoury: add the ppt_* and nv_* +Subject: [PATCH 27/28] platform/x86: asus-armoury: add the ppt_* and nv_* tuning knobs Adds the ppt_* and nv_* tuning knobs that are available via WMI methods @@ -6640,13 +6758,13 @@ and adds proper min/max levels plus defaults. Signed-off-by: Luke D. Jones --- - drivers/platform/x86/asus-armoury.c | 182 +++- - drivers/platform/x86/asus-armoury.h | 1028 +++++++++++++++++++- + drivers/platform/x86/asus-armoury.c | 191 +++- + drivers/platform/x86/asus-armoury.h | 1100 +++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 3 + - 3 files changed, 1200 insertions(+), 13 deletions(-) + 3 files changed, 1281 insertions(+), 13 deletions(-) diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asus-armoury.c -index 49e1788d8bba..5768997ea2d3 100644 +index 49e1788d8bba..6248c5e16e52 100644 --- a/drivers/platform/x86/asus-armoury.c +++ b/drivers/platform/x86/asus-armoury.c @@ -21,6 +21,7 @@ @@ -6800,7 +6918,7 @@ index 49e1788d8bba..5768997ea2d3 100644 return 0; -@@ -849,6 +935,78 @@ static int asus_fw_attr_add(void) +@@ -849,6 +935,87 @@ static int asus_fw_attr_add(void) /* Init / exit ****************************************************************/ @@ -6838,9 +6956,18 @@ index 49e1788d8bba..5768997ea2d3 100644 + } + } else { + limits = power_data->dc_data; -+ if (!limits && !power_data->ac_data) { -+ pr_err("No power limits available\n"); -+ return false; ++ if (!limits) { ++ rog->ppt_pl1_spl = 0; ++ rog->ppt_pl2_sppt = 0; ++ rog->ppt_pl3_fppt = 0; ++ rog->ppt_apu_sppt = 0; ++ rog->ppt_platform_sppt = 0; ++ rog->nv_dynamic_boost = 0; ++ rog->nv_temp_target = 0; ++ rog->nv_tgp = 0; ++ ++ pr_warn("No DC power limits available, initializing to 0\n"); ++ return true; + } + } + @@ -6879,7 +7006,7 @@ index 49e1788d8bba..5768997ea2d3 100644 static int __init asus_fw_init(void) { char *wmi_uid; -@@ -879,6 +1037,16 @@ static int __init asus_fw_init(void) +@@ -879,6 +1046,16 @@ static int __init asus_fw_init(void) } } @@ -6897,7 +7024,7 @@ index 49e1788d8bba..5768997ea2d3 100644 if (err) return err; diff --git a/drivers/platform/x86/asus-armoury.h b/drivers/platform/x86/asus-armoury.h -index 5d6bef6d2b12..60c36529c11e 100644 +index 5d6bef6d2b12..5a10da2a26eb 100644 --- a/drivers/platform/x86/asus-armoury.h +++ b/drivers/platform/x86/asus-armoury.h @@ -8,6 +8,7 @@ @@ -6965,7 +7092,7 @@ index 5d6bef6d2b12..60c36529c11e 100644 #define ATTR_GROUP_BOOL_RO(_attrname, _fsname, _wmi, _dispname) \ __ATTR_CURRENT_INT_RO(_attrname, _wmi); \ __ATTR_GROUP_ENUM(_attrname, _fsname, "0;1", _dispname) -@@ -178,4 +197,1001 @@ static ssize_t int_type_show(struct kobject *kobj, struct kobj_attribute *attr, +@@ -178,4 +197,1073 @@ static ssize_t int_type_show(struct kobject *kobj, struct kobj_attribute *attr, .name = _fsname, .attrs = _attrname##_attrs \ } @@ -7130,6 +7257,37 @@ index 5d6bef6d2b12..60c36529c11e 100644 + }, + { + .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "FA507N"), ++ }, ++ .driver_data = &(struct power_data) { ++ .ac_data = &(struct power_limits) { ++ .ppt_pl1_spl_min = 15, ++ .ppt_pl1_spl_max = 80, ++ .ppt_pl2_sppt_min = 35, ++ .ppt_pl2_sppt_max = 80, ++ .ppt_pl3_fppt_min = 35, ++ .ppt_pl3_fppt_max = 80, ++ .nv_dynamic_boost_min = 5, ++ .nv_dynamic_boost_max = 25, ++ .nv_temp_target_min = 75, ++ .nv_temp_target_max = 87, ++ }, ++ .dc_data = &(struct power_limits) { ++ .ppt_pl1_spl_min = 15, ++ .ppt_pl1_spl_def = 45, ++ .ppt_pl1_spl_max = 65, ++ .ppt_pl2_sppt_min = 35, ++ .ppt_pl2_sppt_def = 54, ++ .ppt_pl2_sppt_max = 65, ++ .ppt_pl3_fppt_min = 35, ++ .ppt_pl3_fppt_max = 65, ++ .nv_temp_target_min = 75, ++ .nv_temp_target_max = 87, ++ } ++ }, ++ }, ++ { ++ .matches = { + DMI_MATCH(DMI_BOARD_NAME, "FA507R"), + }, + .driver_data = &(struct power_data) { @@ -7398,7 +7556,13 @@ index 5d6bef6d2b12..60c36529c11e 100644 + .ppt_pl2_sppt_min = 25, + .ppt_pl2_sppt_max = 80, + .ppt_pl3_fppt_min = 35, -+ .ppt_pl3_fppt_max = 80 ++ .ppt_pl3_fppt_max = 80, ++ .nv_dynamic_boost_min = 5, ++ .nv_dynamic_boost_max = 25, ++ .nv_temp_target_min = 75, ++ .nv_temp_target_max = 87, ++ .nv_tgp_min = 55, ++ .nv_tgp_max = 65, + }, + .dc_data = &(struct power_limits) { + .ppt_pl1_spl_min = 15, @@ -7406,7 +7570,9 @@ index 5d6bef6d2b12..60c36529c11e 100644 + .ppt_pl2_sppt_min = 25, + .ppt_pl2_sppt_max = 35, + .ppt_pl3_fppt_min = 35, -+ .ppt_pl3_fppt_max = 65 ++ .ppt_pl3_fppt_max = 65, ++ .nv_temp_target_min = 75, ++ .nv_temp_target_max = 87, + }, + .requires_fan_curve = true, + }, @@ -7834,6 +8000,39 @@ index 5d6bef6d2b12..60c36529c11e 100644 + }, + { + .matches = { ++ DMI_MATCH(DMI_BOARD_NAME, "G733P"), ++ }, ++ .driver_data = &(struct power_data) { ++ .ac_data = &(struct power_limits) { ++ .ppt_pl1_spl_min = 30, ++ .ppt_pl1_spl_def = 100, ++ .ppt_pl1_spl_max = 130, ++ .ppt_pl2_sppt_min = 65, ++ .ppt_pl2_sppt_def = 125, ++ .ppt_pl2_sppt_max = 130, ++ .ppt_pl3_fppt_min = 65, ++ .ppt_pl3_fppt_def = 125, ++ .ppt_pl3_fppt_max = 130, ++ .nv_temp_target_min = 75, ++ .nv_temp_target_max = 87, ++ .nv_dynamic_boost_min = 5, ++ .nv_dynamic_boost_max = 25, ++ }, ++ .dc_data = &(struct power_limits) { ++ .ppt_pl1_spl_min = 25, ++ .ppt_pl1_spl_max = 65, ++ .ppt_pl2_sppt_min = 25, ++ .ppt_pl2_sppt_max = 65, ++ .ppt_pl3_fppt_min = 35, ++ .ppt_pl3_fppt_max = 75, ++ .nv_temp_target_min = 75, ++ .nv_temp_target_max = 87, ++ }, ++ .requires_fan_curve = true, ++ }, ++ }, ++ { ++ .matches = { + DMI_MATCH(DMI_BOARD_NAME, "G814J"), + }, + .driver_data = &(struct power_data) { @@ -7968,7 +8167,7 @@ index 5d6bef6d2b12..60c36529c11e 100644 + #endif /* _ASUS_ARMOURY_H_ */ diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index 0f45d5549e10..8e90d2221706 100644 +index e735f35b423c..e99cd9a06e2f 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -144,6 +144,9 @@ @@ -7985,10 +8184,10 @@ index 0f45d5549e10..8e90d2221706 100644 2.48.1 -From c6e3fde2aacadd7b5a3a8ab70b8877c445af132b Mon Sep 17 00:00:00 2001 +From c60c015c1d7c497a60a8ab8b075e747a04df33c7 Mon Sep 17 00:00:00 2001 From: Luke Jones Date: Wed, 5 Feb 2025 12:37:47 +1300 -Subject: [PATCH 30/30] backport: fix fw_attr use +Subject: [PATCH 28/28] backport: fix fw_attr use Signed-off-by: Luke Jones --- @@ -7996,7 +8195,7 @@ Signed-off-by: Luke Jones 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asus-armoury.c -index 5768997ea2d3..a9c18a0caffb 100644 +index 6248c5e16e52..b49513947c52 100644 --- a/drivers/platform/x86/asus-armoury.c +++ b/drivers/platform/x86/asus-armoury.c @@ -94,6 +94,8 @@ struct asus_armoury_priv { @@ -8032,7 +8231,7 @@ index 5768997ea2d3..a9c18a0caffb 100644 return err; } -@@ -1060,7 +1067,8 @@ static void __exit asus_fw_exit(void) +@@ -1069,7 +1076,8 @@ static void __exit asus_fw_exit(void) sysfs_remove_file(&asus_armoury.fw_attr_kset->kobj, &pending_reboot.attr); kset_unregister(asus_armoury.fw_attr_kset);