Fix GFX0 parsing for iMac11,x/12,x

This commit is contained in:
Mykola Grymalyuk
2021-04-15 20:28:32 -06:00
parent 2a12e861ac
commit fa045e96e7
3 changed files with 149 additions and 132 deletions
+24 -6
View File
@@ -43,6 +43,27 @@ class BuildOpenCore:
hex_str = "".join(["".join(x) for x in hex_rev]) hex_str = "".join(["".join(x) for x in hex_rev])
return hex_str.upper() return hex_str.upper()
def check_pciid(self):
try:
self.igpu_devices = plistlib.loads(subprocess.run("ioreg -r -n IGPU -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
self.igpu_devices = [i for i in self.igpu_devices if i["class-code"] == binascii.unhexlify("00000300")]
self.igpu_vendor = self.hexswap(binascii.hexlify(self.igpu_devices[0]["vendor-id"]).decode()[:4])
self.igpu_device = self.hexswap(binascii.hexlify(self.igpu_devices[0]["device-id"]).decode()[:4])
print(f"- Detected iGPU: {self.igpu_vendor}:{self.igpu_device}")
except ValueError:
print("- No iGPU detected")
self.igpu_devices = ""
try:
self.dgpu_devices = plistlib.loads(subprocess.run("ioreg -r -n GFX0 -a".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
self.dgpu_devices = [i for i in self.dgpu_devices if i["class-code"] == binascii.unhexlify("00000300")]
self.dgpu_vendor = self.hexswap(binascii.hexlify(self.dgpu_devices[0]["vendor-id"]).decode()[:4])
self.dgpu_device = self.hexswap(binascii.hexlify(self.dgpu_devices[0]["device-id"]).decode()[:4])
print(f"- Detected dGPU: {self.dgpu_vendor}:{self.dgpu_device}")
except ValueError:
print("- No dGPU detected")
self.dgpu_devices = ""
def build_efi(self): def build_efi(self):
Utilities.cls() Utilities.cls()
if not Path(self.constants.build_path).exists(): if not Path(self.constants.build_path).exists():
@@ -292,13 +313,10 @@ class BuildOpenCore:
else: else:
print("- Failed to find vendor") print("- Failed to find vendor")
elif self.constants.custom_model == "None": elif self.constants.custom_model == "None":
current_gpu: str = subprocess.run("system_profiler SPDisplaysDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode() self.check_pciid()
self.constants.current_gpuv = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Vendor"))][0] if self.dgpu_devices and self.dgpu_vendor == self.constants.pci_amd_ati and self.dgpu_device in ModelArray.AMDMXMGPUs:
self.constants.current_gpud = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Device ID"))][0]
print(f"- Detected GPU: {self.constants.current_gpuv} {self.constants.current_gpud}")
if (self.constants.current_gpuv == "AMD (0x1002)") & (self.constants.current_gpud in ModelArray.AMDMXMGPUs):
amd_patch(self) amd_patch(self)
elif (self.constants.current_gpuv == "NVIDIA (0x10de)") & (self.constants.current_gpud in ModelArray.NVIDIAMXMGPUs): elif self.dgpu_devices and self.dgpu_vendor == self.constants.pci_nvidia and self.dgpu_device in ModelArray.NVIDIAMXMGPUs:
nvidia_patch(self) nvidia_patch(self)
elif self.model in ModelArray.MacPro71: elif self.model in ModelArray.MacPro71:
print("- Adding Mac Pro, Xserve DRM patches") print("- Adding Mac Pro, Xserve DRM patches")
+93 -93
View File
@@ -686,32 +686,32 @@ upgradableMXMGPUs = [
# Reference: https://forums.macrumors.com/threads/2011-imac-graphics-card-upgrade.1596614/ # Reference: https://forums.macrumors.com/threads/2011-imac-graphics-card-upgrade.1596614/
NVIDIAMXMGPUs = [ NVIDIAMXMGPUs = [
"0x12b9", # Quadro K610M "12B9", # Quadro K610M
"0x0ff6", # Quadro K1100M "0FF6", # Quadro K1100M
"0x11fc", # Quadro K2100M "11FC", # Quadro K2100M
"0x0ffc", # Quadro K1000M "0FFC", # Quadro K1000M
"0x0ffb", # Quadro K2000M "0FFB", # Quadro K2000M
"0x11b6", # Quadro K3100M "11B6", # Quadro K3100M
"0x11b7", # Quadro K4100M "11B7", # Quadro K4100M
"0x11bc", # Quadro K5000M "11BC", # Quadro K5000M
"0x11b8", # Quadro K5100M "11B8", # Quadro K5100M
"0x11e1", # GTX 765M "11E1", # GTX 765M
"0x11e2", # GTX 765M "11E2", # GTX 765M
"0x11e0", # GTX 770M "11E0", # GTX 770M
"0x119e", # GTX 780M Mac Edition "119E", # GTX 780M Mac Edition
"0x119e", # GTX 780M "119E", # GTX 780M
"0x119f", # GTX 880M "119F", # GTX 880M
"0x119a", # GTX 860M "119A", # GTX 860M
"0x1392", # GTX 860M "1392", # GTX 860M
"0x1199", # GTX 870M "1199", # GTX 870M
"0x11a9", # GTX 870M "11A9", # GTX 870M
] ]
AMDMXMGPUs = [ AMDMXMGPUs = [
"0x67EF", # AMD RX 460 "67EF", # AMD RX 460
"0x67e8", # AMD WX 4130/WX 4150 "67E8", # AMD WX 4130/WX 4150
"0x67e0", # AMD WX 4170 "67E0", # AMD WX 4170
"0x67c0", # AMD WX 7100 "67C0", # AMD WX 7100
] ]
BCM4360Wifi = [ BCM4360Wifi = [
@@ -1041,83 +1041,83 @@ AddBrightness = [
# List supported IDs # List supported IDs
TeraScale1pciid = [ TeraScale1pciid = [
"0x9400", "9400",
"0x9401", "9401",
"0x9402", "9402",
"0x9403", "9403",
"0x9581", "9581",
"0x9583", "9583",
"0x9588", "9588",
"0x94c8", "94c8",
"0x94c9", "94c9",
"0x9500", "9500",
"0x9501", "9501",
"0x9505", "9505",
"0x9507", "9507",
"0x9504", "9504",
"0x9506", "9506",
"0x9598", "9598",
"0x9488", "9488",
"0x9599", "9599",
"0x9591", "9591",
"0x9593", "9593",
"0x9440", "9440",
"0x9442", "9442",
"0x944A", "944A",
"0x945A", "945A",
"0x9490", "9490",
"0x949E", "949E",
"0x9480", "9480",
"0x9540", "9540",
"0x9541", "9541",
"0x954E", "954E",
"0x954F", "954F",
"0x9552", "9552",
"0x9553", "9553",
"0x94a0", "94a0",
] ]
TeraScale2pciid = [ TeraScale2pciid = [
"0x6738", "6738",
"0x6739", "6739",
"0x6720", "6720",
"0x6722", "6722",
"0x6768", "6768",
"0x6770", "6770",
"0x6779", "6779",
"0x6760", "6760",
"0x6761", "6761",
"0x68E0", "68E0",
"0x6898", "6898",
"0x6899", "6899",
"0x68B8", "68B8",
"0x68B0", "68B0",
"0x68B1", "68B1",
"0x68A0", "68A0",
"0x68A1", "68A1",
"0x6840", "6840",
"0x6841", "6841",
"0x68D8", "68D8",
"0x68C0", "68C0",
"0x68C1", "68C1",
"0x68D9", "68D9",
"0x6750", "6750",
"0x6758", "6758",
"0x6759", "6759",
"0x6740", "6740",
"0x6741", "6741",
"0x6745", "6745",
] ]
IronLakepciid = [ IronLakepciid = [
"0x0044", "0044",
"0x0046", "0046",
] ]
SandyBridgepiciid = [ SandyBridgepiciid = [
"0x0106", "0106",
"0x0601", "0601",
"0x0116", "0116",
"0x0102", "0102",
"0x0126", "0126",
] ]
+32 -33
View File
@@ -201,48 +201,47 @@ class PatchSysVolume:
# Ensures no .DS_Stores got in # Ensures no .DS_Stores got in
print("- Preparing Files") print("- Preparing Files")
subprocess.run(f"sudo find {self.constants.payload_apple_root_path} -name '.DS_Store' -delete".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() subprocess.run(f"sudo find {self.constants.payload_apple_root_path} -name '.DS_Store' -delete".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
# TODO: Unify GPU detection logic
current_gpu: str = subprocess.run("system_profiler SPDisplaysDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
self.constants.current_gpuv = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Vendor"))][0]
self.constants.current_gpud = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Device ID"))][0]
if self.model in ModelArray.LegacyGPU: if self.model in ModelArray.LegacyGPU:
if (self.constants.current_gpuv == "AMD (0x1002)") & (self.constants.current_gpud in ModelArray.AMDMXMGPUs): self.check_pciid()
if self.dgpu_devices and self.dgpu_vendor == self.constants.pci_amd_ati and self.dgpu_device in ModelArray.AMDMXMGPUs:
print("- Detected Metal-based AMD GPU, skipping legacy patches") print("- Detected Metal-based AMD GPU, skipping legacy patches")
elif (self.constants.current_gpuv == "NVIDIA (0x10de)") & (self.constants.current_gpud in ModelArray.NVIDIAMXMGPUs): elif self.dgpu_devices and self.dgpu_vendor == self.constants.pci_nvidia and self.dgpu_device in ModelArray.NVIDIAMXMGPUs:
print("- Detected Metal-based Nvidia GPU, skipping legacy patches") print("- Detected Metal-based Nvidia GPU, skipping legacy patches")
else: else:
self.check_pciid()
if Path(self.constants.hiddhack_path).exists(): if Path(self.constants.hiddhack_path).exists():
print("- Detected legacy GPU, attempting legacy acceleration patches") print("- Detected legacy GPU, attempting legacy acceleration patches")
self.gpu_accel_patches_11() self.gpu_accel_patches_11()
else: else:
if self.dgpu_devices and self.dgpu_vendor == self.constants.pci_nvidia: if self.dgpu_devices:
print("- Adding Nvidia Brightness Control patches") if self.dgpu_vendor == self.constants.pci_nvidia:
self.add_new_binaries(ModelArray.AddNvidiaBrightness11, self.constants.legacy_nvidia_path) print("- Adding Nvidia Brightness Control patches")
elif self.dgpu_devices and self.dgpu_vendor == "1002": self.add_new_binaries(ModelArray.AddNvidiaBrightness11, self.constants.legacy_nvidia_path)
if self.dgpu_device in ModelArray.TeraScale1pciid: elif self.dgpu_vendor == self.constants.pci_amd_ati:
print("- Adding AMD/ATI TeraScale 1 Brightness Control patches") if self.dgpu_device in ModelArray.TeraScale1pciid:
self.add_new_binaries(ModelArray.AddAMDTeraScale1Brightness11, self.constants.legacy_amd_path) print("- Adding AMD/ATI TeraScale 1 Brightness Control patches")
elif self.dgpu_device in ModelArray.TeraScale2pciid: self.add_new_binaries(ModelArray.AddAMDTeraScale1Brightness11, self.constants.legacy_amd_path)
print("- Adding AMD/ATI TeraScale 2 Brightness Control patches") elif self.dgpu_device in ModelArray.TeraScale2pciid:
self.add_new_binaries(ModelArray.AddAMDTeraScale2Brightness11, self.constants.legacy_amd_path) print("- Adding AMD/ATI TeraScale 2 Brightness Control patches")
else: self.add_new_binaries(ModelArray.AddAMDTeraScale2Brightness11, self.constants.legacy_amd_path)
print("- Could not find supported Legacy AMD/ATI GPU") else:
if self.igpu_devices and self.igpu_vendor == "8086" and self.igpu_device in ModelArray.IronLakepciid: print("- Could not find supported Legacy AMD/ATI GPU")
print("- Adding Intel Ironlake Brightness Control patches") if self.igpu_devices:
self.add_new_binaries(ModelArray.AddIntelGen1Brightness, self.constants.legacy_intel_gen1_path) if self.igpu_vendor == self.constants.pci_intel:
elif self.igpu_devices and self.igpu_vendor == "8086" and self.igpu_device in ModelArray.SandyBridgepiciid: if self.igpu_device in ModelArray.IronLakepciid:
print("- Adding Intel Sandy Bridge Brightness Control patches") print("- Adding Intel Ironlake Brightness Control patches")
self.add_new_binaries(ModelArray.AddIntelGen2Brightness, self.constants.legacy_intel_gen2_path) self.add_new_binaries(ModelArray.AddIntelGen1Brightness, self.constants.legacy_intel_gen1_path)
if self.model in ModelArray.LegacyGPUAMDIntelGen2: elif self.igpu_device in ModelArray.SandyBridgepiciid:
# Swap custom AppleIntelSNBGraphicsFB-AMD.kext, required to fix linking print("- Adding Intel Sandy Bridge Brightness Control patches")
subprocess.run(f"sudo rm -R {self.mount_extensions}/AppleIntelSNBGraphicsFB.kext".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() self.add_new_binaries(ModelArray.AddIntelGen2Brightness, self.constants.legacy_intel_gen2_path)
subprocess.run(f"sudo cp -R {self.constants.legacy_amd_path}/AMD-Link/AppleIntelSNBGraphicsFB.kext {self.mount_extensions}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() if self.dgpu_devices and self.dgpu_vendor == self.constants.pci_amd_ati and self.dgpu_device in ModelArray.TeraScale2pciid:
elif self.igpu_device and self.igpu_vendor == self.constants.pci_nvidia and not self.dgpu_devices: # Swap custom AppleIntelSNBGraphicsFB-AMD.kext, required to fix linking
# Avoid patching twice, as Nvidia iGPUs will only have Nvidia dGPUs subprocess.run(f"sudo rm -R {self.mount_extensions}/AppleIntelSNBGraphicsFB.kext".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
print("- Adding Nvidia Brightness Control patches") subprocess.run(f"sudo cp -R {self.constants.legacy_amd_path}/AMD-Link/AppleIntelSNBGraphicsFB.kext {self.mount_extensions}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
self.add_new_binaries(ModelArray.AddNvidiaBrightness11, self.constants.legacy_nvidia_path) elif self.igpu_vendor == self.constants.pci_nvidia and not self.dgpu_devices:
# Avoid patching twice, as Nvidia iGPUs will only have Nvidia dGPUs
print("- Adding Nvidia Brightness Control patches")
self.add_new_binaries(ModelArray.AddNvidiaBrightness11, self.constants.legacy_nvidia_path)
if self.model in ModelArray.LegacyBrightness: if self.model in ModelArray.LegacyBrightness:
self.add_brightness_patch() self.add_brightness_patch()
rebuild_required = True rebuild_required = True