From 797b56b9f957c182dc2ba2c0e45101e12f6500b2 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Tue, 20 Apr 2021 15:00:53 -0600 Subject: [PATCH] Fix DRM support on Nvidia-only configurations --- CHANGELOG.md | 3 +++ OpenCore-Patcher.command | 1 + Resources/Build.py | 33 ++++++++++++++++++--------------- Resources/CliMenu.py | 23 +++++++++++++++++++++++ Resources/Constants.py | 1 + Resources/ModelArray.py | 8 ++++++++ 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 205910817..27a73310b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 556138b2b..06eab4b0b 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -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], ] diff --git a/Resources/Build.py b/Resources/Build.py index ff51975ea..863116b15 100644 --- a/Resources/Build.py +++ b/Resources/Build.py @@ -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" diff --git a/Resources/CliMenu.py b/Resources/CliMenu.py index 356e3d4de..0748f8b71 100644 --- a/Resources/CliMenu.py +++ b/Resources/CliMenu.py @@ -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") diff --git a/Resources/Constants.py b/Resources/Constants.py index e323c4787..721b0e3d6 100644 --- a/Resources/Constants.py +++ b/Resources/Constants.py @@ -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 diff --git a/Resources/ModelArray.py b/Resources/ModelArray.py index 6f711a501..c8b3343d8 100644 --- a/Resources/ModelArray.py +++ b/Resources/ModelArray.py @@ -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",