Add gfxutil support

This commit is contained in:
Mykola Grymalyuk
2021-04-13 10:31:37 -06:00
parent 9787645542
commit b1f16fca1d
5 changed files with 65 additions and 40 deletions
+1
View File
@@ -16,6 +16,7 @@
- Add panel type F10T9cde - Add panel type F10T9cde
- Enhance HDMI audio support on Mac Pros and Xserves - Enhance HDMI audio support on Mac Pros and Xserves
- Strip unused kext entries during build - Strip unused kext entries during build
- Add gfxutil support for better DeviceProperty path detection
## 0.0.22 ## 0.0.22
- Add ExFat support for models missing driver - Add ExFat support for models missing driver
+51 -36
View File
@@ -9,6 +9,8 @@ import subprocess
import uuid import uuid
import zipfile import zipfile
import os import os
import sys
import platform
from pathlib import Path from pathlib import Path
from datetime import date from datetime import date
@@ -100,24 +102,36 @@ class BuildOpenCore:
self.enable_kext(name, version, path, check) self.enable_kext(name, version, path, check)
def wifi_fake_id(self): def wifi_fake_id(self):
default_path = True
self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path) self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
self.get_kext_by_bundle_path("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext")["Enabled"] = True self.get_kext_by_bundle_path("AirportBrcmFixup.kext/Contents/PlugIns/AirPortBrcmNIC_Injector.kext")["Enabled"] = True
if not self.constants.custom_model:
if self.model in ModelArray.nvidiaHDEF: # Try finding
# Nvidia chipsets all have the same path to ARPT arpt_path: str = subprocess.run([self.constants.gfxutil_path] + f"-v".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
property_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)" try:
elif self.model in ("iMac7,1", "iMac8,1", "MacPro3,1", "MacBookPro4,1"): arpt_path = [line.strip().split("= ", 1)[1] for line in arpt_path.split("\n") if f"{wifi_vendor}:{wifi_device}".lower() in line.strip()][0]
property_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)" print(f"- Found ARPT device at {arpt_path}")
elif self.model in ("iMac13,1", "iMac13,2"): default_path = False
property_path = "PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0)" except IndexError:
elif self.model in ("MacPro4,1", "MacPro5,1"): print("- Failed to find Device path")
property_path = "PciRoot(0x0)/Pci(0x1C,0x5)/Pci(0x0,0x0)" default_path = True
else: if default_path is True:
# Assumes we have a laptop with Intel chipset if self.model in ModelArray.nvidiaHDEF:
# iMac11,x-12,x also apply # Nvidia chipsets all have the same path to ARPT
property_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)" arpt_path = "PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)"
elif self.model in ("iMac7,1", "iMac8,1", "MacPro3,1", "MacBookPro4,1"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x0)"
elif self.model in ("iMac13,1", "iMac13,2"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x3)/Pci(0x0,0x0)"
elif self.model in ("MacPro4,1", "MacPro5,1"):
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x5)/Pci(0x0,0x0)"
else:
# Assumes we have a laptop with Intel chipset
# iMac11,x-12,x also apply
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
print(f"- Using known DevicePath {arpt_path}")
print("- Applying fake ID for WiFi") print("- Applying fake ID for WiFi")
self.config["DeviceProperties"]["Add"][property_path] = {"device-id": binascii.unhexlify("ba430000"), "compatible": "pci14e4,43ba"} self.config["DeviceProperties"]["Add"][arpt_path] = {"device-id": binascii.unhexlify("ba430000"), "compatible": "pci14e4,43ba"}
# WiFi patches # WiFi patches
# TODO: -a is not supported in Lion and older, need to add proper fix # TODO: -a is not supported in Lion and older, need to add proper fix
@@ -140,34 +154,35 @@ class BuildOpenCore:
print("- Can't run Wifi hardware detection on Snow Leopard and older") print("- Can't run Wifi hardware detection on Snow Leopard and older")
if self.constants.wifi_build is True: if self.constants.wifi_build is True:
print("- Skipping Wifi patches on request") print("- Skipping Wifi patches on request")
elif not self.constants.custom_model and wifi_devices and wifi_vendor == "14E4" and wifi_device in ModelArray.BCM4360Wifi: elif not self.constants.custom_model and wifi_devices:
print("- Found supported WiFi card, skipping wifi patches") if wifi_vendor == self.constants.pci_broadcom:
elif not self.constants.custom_model and wifi_devices and wifi_vendor == "14E4" and wifi_device in ModelArray.BCM94331Wifi: if wifi_device in ModelArray.BCM4360Wifi:
wifi_fake_id(self) print("- Found supported WiFi card, skipping wifi patches")
elif not self.constants.custom_model and wifi_devices and wifi_vendor == "14E4" and wifi_device in ModelArray.BCM94322Wifi: elif wifi_device in ModelArray.BCM94331Wifi:
self.enable_kext("IO80211Mojave.kext", self.constants.io80211mojave_version, self.constants.io80211mojave_path) wifi_fake_id(self)
self.get_kext_by_bundle_path("IO80211Mojave.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True elif wifi_device in ModelArray.BCM94322Wifi:
elif not self.constants.custom_model and wifi_devices and wifi_vendor == "14E4" and wifi_device in ModelArray.BCM94328Wifi: self.enable_kext("IO80211Mojave.kext", self.constants.io80211mojave_version, self.constants.io80211mojave_path)
self.enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path) self.get_kext_by_bundle_path("IO80211Mojave.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True
self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path) elif wifi_device in ModelArray.BCM94328Wifi:
self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True self.enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
elif not self.constants.custom_model and wifi_devices and wifi_vendor == "168C" and wifi_device in ModelArray.AtherosWifi: self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path) self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True
self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True elif wifi_vendor == self.constants.pci_atheros and wifi_device in ModelArray.AtherosWifi:
else:
if self.model in ModelArray.WifiAtheros:
self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path) self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path)
self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
else:
if self.model in ModelArray.WifiBCM94331: if self.model in ModelArray.WifiBCM94331:
wifi_fake_id(self) wifi_fake_id(self)
if self.model in ModelArray.WifiBCM94322: elif self.model in ModelArray.WifiBCM94322:
self.enable_kext("IO80211Mojave.kext", self.constants.io80211mojave_version, self.constants.io80211mojave_path) self.enable_kext("IO80211Mojave.kext", self.constants.io80211mojave_version, self.constants.io80211mojave_path)
self.get_kext_by_bundle_path("IO80211Mojave.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True self.get_kext_by_bundle_path("IO80211Mojave.kext/Contents/PlugIns/AirPortBrcm4331.kext")["Enabled"] = True
if self.model in ModelArray.WifiBCM94328: elif self.model in ModelArray.WifiBCM94328:
self.enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path) self.enable_kext("corecaptureElCap.kext", self.constants.corecaptureelcap_version, self.constants.corecaptureelcap_path)
self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path) self.enable_kext("IO80211ElCap.kext", self.constants.io80211elcap_version, self.constants.io80211elcap_path)
self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True self.get_kext_by_bundle_path("IO80211ElCap.kext/Contents/PlugIns/AppleAirPortBrcm43224.kext")["Enabled"] = True
elif self.model in ModelArray.WifiAtheros:
self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path)
self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
# CPUFriend # CPUFriend
pp_map_path = Path(self.constants.current_path) / Path(f"payloads/Kexts/Plists/PlatformPlugin/{self.model}/Info.plist") pp_map_path = Path(self.constants.current_path) / Path(f"payloads/Kexts/Plists/PlatformPlugin/{self.model}/Info.plist")
@@ -260,9 +275,9 @@ class BuildOpenCore:
self.constants.custom_mxm_gpu = True self.constants.custom_mxm_gpu = True
print("- Adding AMD DRM patches") print("- Adding AMD DRM patches")
if self.model == "iMac11,1": if self.model == "iMac11,1":
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"] = {"shikigva=80": 80, "unfairgva": 1} self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"] = {"shikigva": 80, "unfairgva": 1}
elif self.model in ["iMac11,2", "iMac11,3", "iMac12,1", "iMac12,2"]: elif self.model in ["iMac11,2", "iMac11,3", "iMac12,1", "iMac12,2"]:
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"] = {"shikigva=80": 80, "unfairgva": 1} self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"] = {"shikigva": 80, "unfairgva": 1}
print("- Disabling unsupported iGPU") print("- Disabling unsupported iGPU")
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"name": binascii.unhexlify("23646973706C6179"), "IOName": "#display", "class-code": binascii.unhexlify("FFFFFFFF")} self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"name": binascii.unhexlify("23646973706C6179"), "IOName": "#display", "class-code": binascii.unhexlify("FFFFFFFF")}
+9
View File
@@ -80,6 +80,13 @@ class Constants:
self.catalina = 19 self.catalina = 19
self.big_sur = 20 self.big_sur = 20
# Vendor IDs
self.pci_nvidia = "10DE"
self.pci_amd_ati = "1002"
self.pci_intel = "8086"
self.pci_broadcom = "14E4"
self.pci_atheros = "16C8"
# External Files # External Files
self.url_backup = "" self.url_backup = ""
self.url_apple_binaries = "https://github.com/dortania/Apple-Binaries-OCLP/archive/refs/heads/main.zip" self.url_apple_binaries = "https://github.com/dortania/Apple-Binaries-OCLP/archive/refs/heads/main.zip"
@@ -196,6 +203,8 @@ class Constants:
@property @property
def macserial_path(self): return self.payload_path / Path("Tools/macserial") def macserial_path(self): return self.payload_path / Path("Tools/macserial")
@property @property
def gfxutil_path(self): return self.payload_path / Path("Tools/gfxutil")
@property
def vault_path(self): return self.payload_path / Path("Tools/CreateVault/sign.command") def vault_path(self): return self.payload_path / Path("Tools/CreateVault/sign.command")
# Icons # Icons
+4 -4
View File
@@ -139,16 +139,16 @@ class PatchSysVolume:
def gpu_accel_patches_11(self): def gpu_accel_patches_11(self):
if self.dgpu_devices: if self.dgpu_devices:
if self.dgpu_vendor == "10DE": if self.dgpu_vendor == self.constants.pci_nvidia:
print("- Merging legacy Nvidia Kexts and Bundles") print("- Merging legacy Nvidia Kexts and Bundles")
self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11) self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11)
self.add_new_binaries(ModelArray.AddNvidiaAccel11, self.constants.legacy_nvidia_path) self.add_new_binaries(ModelArray.AddNvidiaAccel11, self.constants.legacy_nvidia_path)
elif self.dgpu_vendor == "1002": elif self.dgpu_vendor == self.constants.pci_amd_ati:
print("- Merging legacy AMD Kexts and Bundles") print("- Merging legacy AMD Kexts and Bundles")
self.delete_old_binaries(ModelArray.DeleteAMDAccel11) self.delete_old_binaries(ModelArray.DeleteAMDAccel11)
self.add_new_binaries(ModelArray.AddAMDAccel11, self.constants.legacy_amd_path) self.add_new_binaries(ModelArray.AddAMDAccel11, self.constants.legacy_amd_path)
if self.igpu_devices: if self.igpu_devices:
if self.igpu_vendor == "8086": if self.igpu_vendor == self.constants.pci_intel:
if self.igpu_device in ModelArray.IronLakepciid: if self.igpu_device in ModelArray.IronLakepciid:
print("- Merging legacy Intel 1st Gen Kexts and Bundles") print("- Merging legacy Intel 1st Gen Kexts and Bundles")
self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11) self.delete_old_binaries(ModelArray.DeleteNvidiaAccel11)
@@ -161,7 +161,7 @@ class PatchSysVolume:
# Swap custom AppleIntelSNBGraphicsFB-AMD.kext, required to fix linking # Swap custom AppleIntelSNBGraphicsFB-AMD.kext, required to fix linking
subprocess.run(f"sudo rm -R {self.mount_extensions}/AppleIntelSNBGraphicsFB.kext".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode() subprocess.run(f"sudo rm -R {self.mount_extensions}/AppleIntelSNBGraphicsFB.kext".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
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() 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()
elif self.igpu_vendor == "10DE": elif self.igpu_vendor == self.constants.pci_nvidia:
if not self.dgpu_devices: if not self.dgpu_devices:
# Avoid patching twice, as Nvidia iGPUs will only have Nvidia dGPUs # Avoid patching twice, as Nvidia iGPUs will only have Nvidia dGPUs
print("- Merging legacy Nvidia Kexts and Bundles") print("- Merging legacy Nvidia Kexts and Bundles")
BIN
View File
Binary file not shown.