Fix DRM support on Nvidia-only configurations

This commit is contained in:
Mykola Grymalyuk
2021-04-20 15:00:53 -06:00
parent d08807e301
commit 797b56b9f9
6 changed files with 54 additions and 15 deletions

View File

@@ -3,6 +3,9 @@
## 0.1.1
- Fix iMac11,3 GFX0 pathing
- Add MouSSE support to iMac10,1 with Metal AMD GPU
- Fix iMac11,1 boot issues after PRAM reset
- Fix DRM support on Nvidia-only configurations
- Support optional setting between DRM and QuickSync support on iMacs13,x and iMac14,x
## 0.1.0
- Fix crash on iMacs with Metal GPUs

View File

@@ -90,6 +90,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
[f"Set Vault Mode:\t\t\tCurrently {self.constants.vault}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_vault],
[f"Set SIP and SecureBootModel:\tSIP: {self.constants.sip_status} SBM: {self.constants.secure_status}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_sip],
[f"Set SMBIOS Mode:\t\t\tCurrently {self.constants.serial_settings}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).change_serial],
[f"DRM Preferences:\t\t\tCurrently {self.constants.drm_support}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).drm_setting],
[f"Set Generic Bootstrap:\t\t{self.constants.boot_efi}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).bootstrap_setting],
["Set Custom Patch Repo", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).custom_repo],
]

View File

@@ -259,7 +259,11 @@ class BuildOpenCore:
# AGPM Patch
if self.model in ModelArray.DualGPUPatch:
print("- Adding dual GPU patch")
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"] = {"agdpmod": "pikera"}
if self.model in ModelArray.IntelNvidiaDRM and self.constants.drm_support is True:
print("- Prioritizing DRM support over Intel QuickSync")
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"] = {"agdpmod": "pikera", "shikigva": 256}
else:
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"] = {"agdpmod": "pikera"}
# HiDPI OpenCanopy and FileVault
if self.model in ModelArray.HiDPIpicker:
@@ -279,15 +283,20 @@ class BuildOpenCore:
def nvidia_patch(self):
self.constants.custom_mxm_gpu = True
print("- Adding Nvidia Brightness Control patches")
if self.model in ["iMac11,1", "iMac11,3"]:
print("- Adding Nvidia Brightness Control and DRM patches")
if self.model == "iMac11,1":
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")}
self.config["DeviceProperties"]["Add"][backlight_path] = {"@0,backlight-control": binascii.unhexlify("01000000"), "@0,built-in": binascii.unhexlify("01000000"), "shikigva": 256, "agdpmod": "vit9696"}
shutil.copy(self.constants.backlight_path, self.constants.kexts_path)
self.get_kext_by_bundle_path("AppleBacklightFixup.kext")["Enabled"] = True
elif self.model == "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"), "shikigva": 256}
shutil.copy(self.constants.backlight_path, self.constants.kexts_path)
self.get_kext_by_bundle_path("AppleBacklightFixup.kext")["Enabled"] = True
elif self.model in ["iMac11,2", "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")}
self.config["DeviceProperties"]["Add"][backlight_path] = {"@0,backlight-control": binascii.unhexlify("01000000"), "@0,built-in": binascii.unhexlify("01000000"), "shikigva": 256}
print("- Disabling unsupported iGPU")
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"name": binascii.unhexlify("23646973706C6179"), "IOName": "#display", "class-code": binascii.unhexlify("FFFFFFFF")}
shutil.copy(self.constants.backlight_path, self.constants.kexts_path)
@@ -298,7 +307,9 @@ class BuildOpenCore:
def amd_patch(self):
self.constants.custom_mxm_gpu = True
print("- Adding AMD DRM patches")
if self.model in ["iMac11,1", "iMac11,3"]:
if self.model == "iMac11,1":
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"] = {"shikigva": 80, "unfairgva": 1, "agdpmod": "vit9696"}
elif self.model == "iMac11,3":
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"] = {"shikigva": 80, "unfairgva": 1}
elif self.model in ["iMac11,2", "iMac12,1", "iMac12,2"]:
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"] = {"shikigva": 80, "unfairgva": 1}
@@ -408,15 +419,7 @@ class BuildOpenCore:
spoofed_board = "Mac-7BA5B2D9E42DDD94"
elif self.model in ModelArray.iMac151:
# Check for upgraded GPUs on iMacs
if self.constants.metal_build is True:
print("- Spoofing to iMacPro1,1")
spoofed_model = "iMacPro1,1"
spoofed_board = "Mac-7BA5B2D9E42DDD94"
elif self.constants.dgpu_vendor == self.constants.pci_amd_ati and self.constants.dgpu_device in ModelArray.AMDMXMGPUs and not self.constants.custom_model:
print("- Spoofing to iMacPro1,1")
spoofed_model = "iMacPro1,1"
spoofed_board = "Mac-7BA5B2D9E42DDD94"
elif self.constants.dgpu_vendor == self.constants.pci_nvidia and self.constants.dgpu_device in ModelArray.NVIDIAMXMGPUs and not self.constants.custom_model:
if self.constants.metal_build is True or (self.constants.dgpu_vendor == self.constants.pci_amd_ati and self.constants.dgpu_device in ModelArray.AMDMXMGPUs and not self.constants.custom_model) or (self.constants.dgpu_vendor == self.constants.pci_nvidia and self.constants.dgpu_device in ModelArray.NVIDIAMXMGPUs and not self.constants.custom_model) or (self.model in ModelArray.IntelNvidiaDRM and self.constants.drm_support is True):
print("- Spoofing to iMacPro1,1")
spoofed_model = "iMacPro1,1"
spoofed_board = "Mac-7BA5B2D9E42DDD94"

View File

@@ -270,3 +270,26 @@ see the EFI Boot entry in the boot picker.
self.constants.boot_efi = True
else:
print("Invalid option")
def drm_setting(self):
Utilities.cls()
Utilities.header(["Set DRM preferences"])
print("""Sets OpenCore's DRM preferences for iMac13,x and iMac14,x.
In Big Sur, some DRM based content may be broken by
default in AppleTV, Photobooth, etc.
To resolve, you can opt to disable Intel QuickSync support in
favor of Nvidia's Software rendering. This can aid in DRM however
greatly hampers Video rendering performance in Final Cut Pro and
other programs relying on such features.
Recommend only disabling if absolutely required.
""")
change_menu = input("Enable Nvidia's Software DRM rendering(y/n): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.drm_support = True
elif change_menu in {"n", "N", "no", "No"}:
self.constants.drm_support = False
else:
print("Invalid option")

View File

@@ -68,6 +68,7 @@ class Constants:
self.secure_status = True
self.detected_os = 0
self.boot_efi = False
self.drm_support = False
# OS Versions
self.tiger = 8

View File

@@ -471,6 +471,7 @@ DualGPUPatch = [
"Macmini5,2",
"iMac12,1",
"iMac12,2",
"iMac13,1",
"iMac13,2",
"iMac14,2",
"iMac14,3",
@@ -481,6 +482,13 @@ DualGPUPatchRetina = [
"MacBookPro10,1",
]
IntelNvidiaDRM = [
"iMac13,1",
"iMac13,2",
"iMac14,2",
"iMac14,3",
]
HiDPIpicker = [
"MacBookPro10,1",
"MacBookPro10,2",