From c4dcd8b864d0db35e56eeab98c449a239a8fa8a2 Mon Sep 17 00:00:00 2001 From: Hoang Hong Quan Date: Mon, 28 Apr 2025 21:33:07 +0700 Subject: [PATCH] Add WMIS patch to fix ThermalZone sensor return issue --- Scripts/acpi_guru.py | 66 +++++++++++++++++++++++++++++ Scripts/datasets/acpi_patch_data.py | 7 ++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Scripts/acpi_guru.py b/Scripts/acpi_guru.py index ff482e2..16880ce 100644 --- a/Scripts/acpi_guru.py +++ b/Scripts/acpi_guru.py @@ -3015,6 +3015,68 @@ DefinitionBlock ("", "SSDT", 2, "ZPSS", "UsbReset", 0x00001000) ], "Patch": patches } + + def return_thermal_zone(self): + ssdt_name = "SSDT-WMIS" + ssdt_content = """ +// Resource: https://github.com/zhen-zen/YogaSMC/blob/master/YogaSMC/SSDTSample/SSDT-WMIS.dsl + +/* + * Sample SSDT to fix sensor return + * + * Certain models forget to return result from ThermalZone: + * + * Method (WQBI, 1, NotSerialized) + * { + * \_TZ.WQBI (Arg0) + * } + * + * So we have to patch it for correct reporting. + * Rename Method (WQBI, 1, N) to XQBI + * (ThermalZone one usually has Serialized type) + * + * Find: 57514249 01 // WQBI + * Repl: 58514249 01 // XQBI + * + * MethodFlags := + * bit 0-2: ArgCount (0-7) + * bit 3: SerializeFlag + * 0 NotSerialized + * 1 Serialized + */ +DefinitionBlock ("", "SSDT", 2, "ZPSS", "WMIS", 0x00000000) +{ + External (_TZ.WQBI, MethodObj) // Method in ThermalZone + + Method (_SB.WMIS.WQBI, 1, NotSerialized) + { + Return (\_TZ.WQBI (Arg0)) + } +} +""" + for table_name in self.sorted_nicely(list(self.acpi.acpi_tables)): + table = self.acpi.acpi_tables[table_name] + wqbi_method = self.acpi.get_method_paths("WQBI", table=table) + + if not wqbi_method: + continue + + return { + "Add": [ + { + "Comment": ssdt_name + ".aml", + "Enabled": self.write_ssdt(ssdt_name, ssdt_content), + "Path": ssdt_name + ".aml" + } + ], + "Patch": [ + { + "Comment": "WQBI to XQBI Rename", + "Find": "5751424901", + "Replace": "5851424901" + } + ] + } def drop_cpu_tables(self): deletes = [] @@ -3126,6 +3188,10 @@ DefinitionBlock ("", "SSDT", 2, "ZPSS", "UsbReset", 0x00001000) selected_patches.append("BATP") selected_patches.append("XOSI") + for device_name, device_info in hardware_report.get("System Devices", {}).items(): + if device_info.get("Bus Type") == "ACPI" and device_info.get("Device") in pci_data.YogaHIDs: + selected_patches.append("WMIS") + for patch in self.patches: patch.checked = patch.name in selected_patches diff --git a/Scripts/datasets/acpi_patch_data.py b/Scripts/datasets/acpi_patch_data.py index 5448b4d..41277bd 100644 --- a/Scripts/datasets/acpi_patch_data.py +++ b/Scripts/datasets/acpi_patch_data.py @@ -126,9 +126,14 @@ patches = [ description = "Creates an USBX device to inject USB power properties", function_name = "add_usb_power_properties" ), + PatchInfo( + name = "WMIS", + description = "Certain models forget to return result from ThermalZone", + function_name = "return_thermal_zone" + ), PatchInfo( name = "XOSI", description = "Spoofs the operating system to Windows, enabling devices locked behind non-Windows systems on macOS", function_name = "operating_system_patch" - ), + ) ] \ No newline at end of file