Add Backlight patches for modded Nvidia GPUs

This commit is contained in:
Mykola Grymalyuk
2021-03-02 07:30:59 -07:00
parent 6c74bfd862
commit 08731521ad
6 changed files with 38 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
# OpenCore Legacy Patcher changelog
## 0.0.12
- Convert OpenCore-Patcher binary to OpenCore-Patcher.app
- Add Backlight patches for modded Nvidia GPUs in iMac10,x-12,x
## 0.0.11
- Re-add OpenCore GUI

View File

@@ -6,8 +6,6 @@ import subprocess, sys, time
from Resources import build, ModelArray, Constants, utilities
PATCHER_VERSION = "0.0.11"
class OpenCoreLegacyPatcher():
def __init__(self):

View File

@@ -25,6 +25,7 @@ class Constants:
self.voodoohda_version = "296"
self.restrictevents_version = "1.0.0"
self.piixata_version = "1.0.0"
self.backlight_version = "1.0.0"
# Get resource path
self.current_path = Path(__file__).parent.parent.resolve()
@@ -32,6 +33,8 @@ class Constants:
self.custom_model: str = None
self.custom_mxm_gpu: str = None
self.current_gpuv: str = None
self.current_gpud: str = None
# Payload Location
# OpenCore
@property
@@ -78,6 +81,8 @@ class Constants:
def voodoohda_path(self): return self.payload_kexts_path / Path(f"Audio/VoodooHDA-v{self.voodoohda_version}.zip")
@property
def piixata_path(self): return self.payload_kexts_path / Path(f"Misc/AppleIntelPIIXATA-v{self.piixata_version}.zip")
@property
def backlight_path(self): return self.payload_kexts_path / Path(f"Misc/AppleBacklightFixup-v{self.backlight_version}.zip")
# Build Location
@property

View File

@@ -153,19 +153,21 @@ class BuildOpenCore:
# Check GPU Vendor
if self.constants.custom_model == "None":
current_gpu: str = subprocess.run("system_profiler SPDisplaysDataType".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
current_gpuv = [line.strip().split(": ", 1)[1] for line in current_gpu.split("\n") if line.strip().startswith(("Vendor"))][0]
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: {current_gpuv} {current_gpud}")
if (current_gpuv == "AMD (0x1002)") & (current_gpud in ModelArray.AMDMXMGPUs):
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]
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):
self.constants.custom_mxm_gpu = True
print("- Adding AMD DRM patches")
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " shikigva=80 unfairgva=1"
elif (current_gpuv == "NVIDIA (0x10de)") & (current_gpud in ModelArray.NVIDIAMXMGPUs):
elif (self.constants.current_gpuv == "NVIDIA (0x10de)") & (self.constants.current_gpud in ModelArray.NVIDIAMXMGPUs):
self.constants.custom_mxm_gpu = True
print("- Adding Brightness Control patches")
if self.model in ["iMac11,1", "iMac11,2", "iMac11,3"]:
backlight_path = "PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"
self.config["DeviceProperties"]["Add"][backlight_path] = {"@0,backlight-control": binascii.unhexlify("01000000"), "@0,built-in": binascii.unhexlify("01000000")}
shutil.copy(self.constants.backlight_path, self.constants.kexts_path)
self.get_kext_by_bundle_path("AppleBacklightFixup.kext")["Enabled"] = True
elif self.model in ["iMac12,1", "iMac12,2"]:
backlight_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"
self.config["DeviceProperties"]["Add"][backlight_path] = {"@0,backlight-control": binascii.unhexlify("01000000"), "@0,built-in": binascii.unhexlify("01000000")}
@@ -200,7 +202,12 @@ class BuildOpenCore:
spoofed_model = "Macmini7,1"
spoofed_board = "Mac-35C5E08120C7EEAF"
elif self.model in ModelArray.iMac151:
if self.constants.custom_mxm_gpu == True:
# Check for upgraded GPUs on iMacs
if (self.constants.current_gpuv == "AMD (0x1002)") & (self.constants.current_gpud in ModelArray.AMDMXMGPUs) & (self.constants.custom_model == "None"):
print("- Spoofing to iMacPro1,1")
spoofed_model = "iMacPro1,1"
spoofed_board = "Mac-7BA5B2D9E42DDD94"
elif (self.constants.current_gpuv == "NVIDIA (0x10de)") & (self.constants.current_gpud in ModelArray.NVIDIAMXMGPUs) & (self.constants.custom_model == "None"):
print("- Spoofing to iMacPro1,1")
spoofed_model = "iMacPro1,1"
spoofed_board = "Mac-7BA5B2D9E42DDD94"
@@ -244,7 +251,6 @@ class BuildOpenCore:
smbios_mod = True
# USB Map
usb_map_path = Path(self.constants.current_path) / Path(f"payloads/Kexts/Maps/Universal/Info.plist")
self.new_map_ls = Path(self.constants.map_contents_folder) / Path(f"Info.plist")
self.map_config = plistlib.load(Path(self.new_map_ls).open("rb"))

View File

@@ -494,6 +494,24 @@
<key>PlistPath</key>
<string>Contents/Info.plist</string>
</dict>
<dict>
<key>Arch</key>
<string>x86_64</string>
<key>Comment</key>
<string>AppleBacklightFixup - Modded Nvidia GPUs</string>
<key>Enabled</key>
<false/>
<key>MaxKernel</key>
<string></string>
<key>MinKernel</key>
<string></string>
<key>BundlePath</key>
<string>AppleBacklightFixup.kext</string>
<key>ExecutablePath</key>
<string>Contents/MacOS/AppleBacklightFixup</string>
<key>PlistPath</key>
<string>Contents/Info.plist</string>
</dict>
<dict>
<key>Arch</key>
<string>x86_64</string>

Binary file not shown.