mirror of
https://github.com/outbackdingo/OpCore-Simplify.git
synced 2026-01-27 10:19:49 +00:00
Add SSDT spoof GPU ID for some GPU IDs not available in macOS
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
from Scripts.datasets import chipset_data
|
||||
from Scripts.datasets import cpu_data
|
||||
from Scripts.datasets import pci_data
|
||||
from Scripts import smbios
|
||||
from Scripts import dsdt
|
||||
from Scripts import utils
|
||||
@@ -898,12 +899,11 @@ DefinitionBlock ("", "SSDT", 2, "ZPSS", "[[DeviceType]]", 0)
|
||||
}""".replace("[[DeviceType]]", "DWiFi" if "WiFi" in device else "DSDC")
|
||||
|
||||
if ssdt_name:
|
||||
if self.write_ssdt(ssdt_name, ssdt_content, compile="Discrete GPU" in device):
|
||||
self.result["Add"].append({
|
||||
"Comment": comment,
|
||||
"Enabled": True,
|
||||
"Path": f"{ssdt_name}.aml"
|
||||
})
|
||||
self.result["Add"].append({
|
||||
"Comment": comment,
|
||||
"Enabled": self.write_ssdt(ssdt_name, ssdt_content, compile=False),
|
||||
"Path": f"{ssdt_name}.aml"
|
||||
})
|
||||
|
||||
def enable_backlight_controls(self, platform, cpu_codename, integrated_gpu):
|
||||
if "Laptop" not in platform or not integrated_gpu:
|
||||
@@ -2808,7 +2808,106 @@ DefinitionBlock ("", "SSDT", 2, "ZPSS", "Surface", 0x00001000)
|
||||
continue
|
||||
return self.read_dsdt(path)
|
||||
|
||||
def initialize_patches(self, motherboard_name, motherboard_chipset, platform, cpu_manufacturer, cpu_codename, integrated_gpu, ethernet_pci, touchpad_communication, smbios, intel_mei, unsupported_devices, macos_version, acpi_directory):
|
||||
def add_dtgp_method(self):
|
||||
comment = "Enables macOS to read and merge device properties from ACPI and determine if a specific device should temporarily receive power"
|
||||
ssdt_name = "SSDT-DTGP"
|
||||
ssdt_content = """
|
||||
// Resource: https://github.com/5T33Z0/OC-Little-Translated/blob/main/01_Adding_missing_Devices_and_enabling_Features/Method_DTGP/SSDT-DTGP.dsl
|
||||
|
||||
DefinitionBlock ("", "SSDT", 2, "ZPSS", "DTGP", 0x00001000)
|
||||
{
|
||||
Method (DTGP, 5, NotSerialized)
|
||||
{
|
||||
If ((Arg0 == ToUUID ("a0b5b7c6-1318-441c-b0c9-fe695eaf949b") /* Unknown UUID */))
|
||||
{
|
||||
If ((Arg1 == One))
|
||||
{
|
||||
If ((Arg2 == Zero))
|
||||
{
|
||||
Arg4 = Buffer (One)
|
||||
{
|
||||
0x03 // .
|
||||
}
|
||||
Return (One)
|
||||
}
|
||||
|
||||
If ((Arg2 == One))
|
||||
{
|
||||
Return (One)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Arg4 = Buffer (One)
|
||||
{
|
||||
0x00 // .
|
||||
}
|
||||
Return (Zero)
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
self.result["Add"].append({
|
||||
"Comment": comment,
|
||||
"Enabled": self.write_ssdt(ssdt_name, ssdt_content),
|
||||
"Path": f"{ssdt_name}.aml"
|
||||
})
|
||||
|
||||
def spoof_discrete_gpu(self, discrete_gpu):
|
||||
device_id = discrete_gpu.get("Device ID")
|
||||
|
||||
if not device_id in pci_data.SpoofGPUIDs:
|
||||
return
|
||||
|
||||
self.add_dtgp_method()
|
||||
new_device_id_le = self.utils.to_little_endian_hex(pci_data.SpoofGPUIDs.get(device_id).split("-")[-1])
|
||||
device_id_byte = ", ".join([f'0x{new_device_id_le[i:i+2]}' for i in range(0, len(new_device_id_le), 2)])
|
||||
comment = "Spoof GPU ID to enable graphics acceleration in macOS"
|
||||
ssdt_name = "SSDT-GPU-SPOOF"
|
||||
ssdt_content = """
|
||||
// Resource: https://github.com/dortania/Getting-Started-With-ACPI/blob/master/extra-files/decompiled/SSDT-GPU-SPOOF.dsl
|
||||
|
||||
// Replace all "_SB.PCI0.PEG0.PEGP" with the ACPI path of your discrete GPU
|
||||
|
||||
DefinitionBlock ("", "SSDT", 2, "ZPSS", "GPUSPOOF", 0x00001000)
|
||||
{
|
||||
External (_SB.PCI0.PEG0.PEGP, DeviceObj)
|
||||
External (DTGP, MethodObj)
|
||||
|
||||
Scope (_SB.PCI0.PEG0.PEGP)
|
||||
{
|
||||
if (_OSI ("Darwin"))
|
||||
{
|
||||
Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method
|
||||
{
|
||||
Local0 = Package (0x04)
|
||||
{
|
||||
"device-id",
|
||||
Buffer (0x04)
|
||||
{
|
||||
[[DeviceID]]
|
||||
},
|
||||
|
||||
"model",
|
||||
Buffer ()
|
||||
{
|
||||
"[[model]]"
|
||||
}
|
||||
}
|
||||
DTGP (Arg0, Arg1, Arg2, Arg3, RefOf (Local0))
|
||||
Return (Local0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}""".replace("[[DeviceID]]", device_id_byte).replace("[[model]]", discrete_gpu.get("GPU Name"))
|
||||
|
||||
self.result["Add"].append({
|
||||
"Comment": comment,
|
||||
"Enabled": self.write_ssdt(ssdt_name, ssdt_content, compile=False),
|
||||
"Path": f"{ssdt_name}.aml"
|
||||
})
|
||||
|
||||
def initialize_patches(self, motherboard_name, motherboard_chipset, platform, cpu_manufacturer, cpu_codename, integrated_gpu, discrete_gpu, ethernet_pci, touchpad_communication, smbios, intel_mei, unsupported_devices, macos_version, acpi_directory):
|
||||
self.acpi_directory = self.check_acpi_directory(acpi_directory)
|
||||
|
||||
if self.select_dsdt():
|
||||
@@ -2835,6 +2934,7 @@ DefinitionBlock ("", "SSDT", 2, "ZPSS", "Surface", 0x00001000)
|
||||
self.fix_uncore_bridge(motherboard_chipset, macos_version)
|
||||
self.instant_wake_fix()
|
||||
self.operating_system_patch(platform)
|
||||
self.spoof_discrete_gpu(discrete_gpu)
|
||||
self.surface_laptop_special_patch(motherboard_name, platform)
|
||||
|
||||
self.result["Add"] = sorted(self.result["Add"], key=lambda x: x["Path"])
|
||||
|
||||
@@ -294,7 +294,7 @@ class ConfigProdigy:
|
||||
hardware.get("CPU Manufacturer"),
|
||||
hardware.get("CPU Codename"),
|
||||
hardware["CPU Cores"],
|
||||
hardware["Discrete GPU Manufacturer"] or hardware["Integrated GPU Manufacturer"],
|
||||
hardware["Discrete GPU"].get("Manufacturer", "") or hardware["Integrated GPU"].get("Manufacturer", ""),
|
||||
efi_option.get("Synchronize the TSC"),
|
||||
efi_option.get("macOS Version"),
|
||||
)
|
||||
@@ -333,7 +333,7 @@ class ConfigProdigy:
|
||||
hardware.get("Platform"),
|
||||
hardware.get("CPU Manufacturer"),
|
||||
hardware.get("CPU Codename"),
|
||||
hardware.get("Discrete GPU Codename"),
|
||||
hardware.get("Discrete GPU").get("GPU Codename", ""),
|
||||
hardware.get("Integrated GPU Name"),
|
||||
hardware.get("Ethernet (PCI)"),
|
||||
hardware.get("Codec ID"),
|
||||
|
||||
@@ -1137,4 +1137,8 @@ UnsupportedNVMeSSDIDs = {
|
||||
"1C5C-1327": "SK hynix BC501",
|
||||
"8086-390B": "Intel 760p",
|
||||
"2646-2263": "Kingston A2000"
|
||||
}
|
||||
|
||||
SpoofGPUIDs = {
|
||||
"1002-699F": "1002-67FF" # AMD RX 550 (Lexa core)
|
||||
}
|
||||
@@ -393,12 +393,10 @@ class builder:
|
||||
hardware_shorc["CPU Cores"] = hardware["CPU"].get("CPU Cores")
|
||||
hardware_shorc["CPU Codename"] = hardware["CPU"].get("CPU Codename")
|
||||
hardware_shorc["Integrated GPU"] = list(hardware.get("GPU").items())[-1][1] if "Integrated GPU" in list(hardware.get("GPU").items())[-1][1]["Device Type"] else {}
|
||||
hardware_shorc["Integrated GPU Manufacturer"] = hardware_shorc["Integrated GPU"]["Manufacturer"] if hardware_shorc["Integrated GPU"] else ""
|
||||
hardware_shorc["Integrated GPU Name"] = list(hardware.get("GPU").keys())[-1] if hardware_shorc["Integrated GPU"] else ""
|
||||
hardware_shorc["Integrated GPU Codename"] = hardware_shorc["Integrated GPU"]["GPU Codename"] if hardware_shorc["Integrated GPU"] else ""
|
||||
hardware_shorc["Discrete GPU"] = list(hardware.get("GPU").items())[0][1] if "Discrete GPU" in list(hardware.get("GPU").items())[0][1]["Device Type"] else {}
|
||||
hardware_shorc["Discrete GPU Manufacturer"] = hardware_shorc["Discrete GPU"]["Manufacturer"] if hardware_shorc["Discrete GPU"] else ""
|
||||
hardware_shorc["Discrete GPU Codename"] = hardware_shorc["Discrete GPU"]["GPU Codename"] if hardware_shorc["Discrete GPU"] else ""
|
||||
if hardware_shorc["Discrete GPU"]:
|
||||
hardware_shorc["Discrete GPU"]["GPU Name"] = list(hardware.get("GPU").keys())[0]
|
||||
hardware_shorc["Ethernet (PCI)"] = []
|
||||
for network_name, network_props in hardware["Network"].items():
|
||||
connection_name = network_props["Connection Name"]
|
||||
@@ -424,13 +422,13 @@ class builder:
|
||||
efi_option = {}
|
||||
efi_option["macOS Version"] = macos_version
|
||||
efi_option["Custom CPU Name"] = not (" Core" in hardware_shorc.get("Processor Name") and self.utils.contains_any(cpu_data.IntelCPUGenerations, hardware_shorc.get("CPU Codename"), end=12))
|
||||
efi_option["Synchronize the TSC"] = "Laptop" in hardware_shorc["Platform"] and "ASUS" in hardware_shorc["Motherboard Name"] or "AMD" in hardware_shorc["Integrated GPU Manufacturer"]
|
||||
efi_option["Synchronize the TSC"] = "Laptop" in hardware_shorc["Platform"] and "ASUS" in hardware_shorc["Motherboard Name"] or "AMD" in hardware_shorc["Integrated GPU"].get("Manufacturer", "")
|
||||
efi_option["iGPU Properties"] = self.igpu_properties(
|
||||
hardware_shorc["Platform"],
|
||||
hardware_shorc.get("Processor Name"),
|
||||
hardware_shorc.get("Integrated GPU Codename"),
|
||||
hardware_shorc["Integrated GPU"].get("GPU Codename", ""),
|
||||
hardware_shorc["Discrete GPU"],
|
||||
hardware_shorc["Integrated GPU Manufacturer"],
|
||||
hardware_shorc["Integrated GPU"].get("Manufacturer", ""),
|
||||
hardware_shorc["Integrated GPU Name"],
|
||||
efi_option.get("macOS Version"))
|
||||
efi_option["SMBIOS"] = self.system_product_info(
|
||||
@@ -452,6 +450,7 @@ class builder:
|
||||
hardware_shorc["CPU Manufacturer"],
|
||||
hardware_shorc["CPU Codename"],
|
||||
hardware_shorc["Integrated GPU"],
|
||||
hardware_shorc["Discrete GPU"],
|
||||
hardware_shorc["Ethernet (PCI)"],
|
||||
hardware_shorc["Touchpad Communication"],
|
||||
efi_option.get("SMBIOS"),
|
||||
@@ -467,7 +466,7 @@ class builder:
|
||||
hardware_shorc["CPU Configuration"],
|
||||
hardware_shorc["CPU Manufacturer"],
|
||||
hardware_shorc["CPU Codename"],
|
||||
hardware_shorc["Discrete GPU Codename"],
|
||||
hardware_shorc["Discrete GPU"].get("GPU Codename", ""),
|
||||
hardware_shorc["Integrated GPU"],
|
||||
hardware_shorc.get("Wi-Fi (PCI)"),
|
||||
hardware_shorc["Ethernet (PCI)"],
|
||||
@@ -491,7 +490,7 @@ class builder:
|
||||
hardware_shorc["Motherboard Name"],
|
||||
hardware_shorc["Platform"],
|
||||
hardware_shorc["CPU Manufacturer"],
|
||||
hardware_shorc["Discrete GPU Codename"],
|
||||
hardware_shorc["Discrete GPU"].get("GPU Codename", ""),
|
||||
efi_option["macOS Version"]
|
||||
)
|
||||
|
||||
|
||||
@@ -120,6 +120,15 @@ class Utils:
|
||||
|
||||
def hex_to_int(self, hex_string):
|
||||
return int(hex_string, 16)
|
||||
|
||||
def to_little_endian_hex(self, hex_str):
|
||||
hex_str = hex_str.lower().lstrip("0x")
|
||||
|
||||
hex_str = hex_str.zfill(8)
|
||||
|
||||
little_endian_hex = ''.join(reversed([hex_str[i:i+2] for i in range(0, len(hex_str), 2)]))
|
||||
|
||||
return little_endian_hex.upper()
|
||||
|
||||
def contains_any(self, data, search_item, start=0, end=None):
|
||||
return next((item for item in data[start:end] if item.lower() in search_item.lower()), None)
|
||||
|
||||
Reference in New Issue
Block a user