Allow configuring GMUX usage for Windows

Closes https://github.com/dortania/OpenCore-Legacy-Patcher/issues/502
This commit is contained in:
Mykola Grymalyuk
2021-09-24 10:29:43 -06:00
parent 2683b7a7f0
commit 0ccb2c74d2
8 changed files with 84 additions and 6 deletions

View File

@@ -166,7 +166,7 @@ class BuildOpenCore:
("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path, lambda: self.model in ModelArray.EthernetMarvell),
("CatalinaBCM5701Ethernet.kext", self.constants.bcm570_version, self.constants.bcm570_path, lambda: self.model in ModelArray.EthernetBroadcom),
# Legacy audio
("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path, lambda: self.model in ModelArray.LegacyAudio or self.model in ModelArray.MacPro),
("AppleALC.kext", self.constants.applealc_version, self.constants.applealc_path, lambda: (self.model in ModelArray.LegacyAudio or self.model in ModelArray.MacPro) and self.constants.set_alc_usage is True),
# IDE patch
("AppleIntelPIIXATA.kext", self.constants.piixata_version, self.constants.piixata_path, lambda: self.model in ModelArray.IDEPatch),
# Misc
@@ -711,7 +711,7 @@ class BuildOpenCore:
if self.constants.validate is False:
print("- Adding bootmgfw.efi BlessOverride")
self.config["Misc"]["BlessOverride"] += ["\\EFI\\Microsoft\\Boot\\bootmgfw.efi"]
if self.model in ModelArray.dGPU_switch:
if self.model in ModelArray.dGPU_switch and self.constants.dGPU_switch is True:
print("- Allowing GMUX switching in Windows")
self.config["Booter"]["Quirks"]["SignalAppleOS"] = True
if self.constants.allow_fv_root is True:

View File

@@ -631,3 +631,49 @@ handle acceleration tasks.
print("")
print(self.constants.computer)
input("\nPress [ENTER] to exit: ")
def applealc_support(self):
Utilities.cls()
Utilities.header(["Set AppleALC usage"])
print(
"""
By default this patcher will install audio patches in-memory via
AppleALC. However for systems that cannot achieve boot screen support,
this option will allow you to install the legacy AppleHDA patch via
root patching.
If AppleALC is detected, the Patcher will not install AppleHDA.
"""
)
change_menu = input("Set AppleALC usage?(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.set_alc_usage = True
elif change_menu in {"n", "N", "no", "No"}:
self.constants.set_alc_usage = False
elif change_menu in {"q", "Q", "Quit", "quit"}:
print("Returning to previous menu")
else:
self.applealc_support()
def dGPU_switch_support(self):
Utilities.cls()
Utilities.header(["Set Windows GMUX support"])
print(
"""
With OCLP, we're able to restore iGPU funbctionality on iGPU+dGPU
MacBook Pros. However for some this may not be desires, ie. eGPUs
for Windows may prefer to only work with the dGPU and eGPU present.
"""
)
change_menu = input("Set Windows GMUX support?(y/n/q): ")
if change_menu in {"y", "Y", "yes", "Yes"}:
self.constants.dGPU_switch = True
elif change_menu in {"n", "N", "no", "No"}:
self.constants.dGPU_switch = False
elif change_menu in {"q", "Q", "Quit", "quit"}:
print("Returning to previous menu")
else:
self.dGPU_switch_support()

View File

@@ -14,7 +14,7 @@ class Constants:
def __init__(self):
# Patcher Versioning
self.patcher_version = "0.3.0" # OpenCore-Legacy-Patcher
self.patcher_support_pkg_version = "0.1.3" # PatcherSupportPkg
self.patcher_support_pkg_version = "0.1.4" # PatcherSupportPkg
# OpenCore Versioning
# https://github.com/acidanthera/OpenCorePkg
@@ -141,6 +141,8 @@ class Constants:
self.disallow_cpufriend = False # Disable CPUFriend
self.enable_wake_on_wlan = False # Allow Wake on WLAN for modern Broadcom
self.disable_thunderbolt = False # Disable Thunderbolt Controller
self.set_alc_usage = True # Set AppleALC usage
self.dGPU_switch = True # Set Display GPU Switching for Windows
# OS Versions
## Based off Major Kernel Version
@@ -564,9 +566,14 @@ class Constants:
return self.payload_apple_private_frameworks_path / Path("Brightness-Control")
# Apple Extensions
# El Capitan Extensions
@property
def audio_path(self):
return self.payload_apple_kexts_path / Path("Audio")
# High Sierra Extensions
@property
def audio_v2_path(self):
return self.payload_apple_kexts_path / Path("Audio-v2")
# GPU Kexts and Bundles

View File

@@ -294,8 +294,11 @@ set million colour before rebooting"""
Utilities.process_status(self.elevated(["chown", "-Rf", "root:wheel", f"{self.mount_private_frameworks}/DisplayServices.framework"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT))
def add_audio_patch(self):
self.delete_old_binaries(SysPatchArray.DeleteVolumeControl)
self.add_new_binaries(SysPatchArray.AddVolumeControl, self.constants.audio_path)
if self.model in ["iMac7,1", "iMac8,1"]:
self.delete_old_binaries(SysPatchArray.DeleteVolumeControl)
self.add_new_binaries(SysPatchArray.AddVolumeControl, self.constants.audio_path)
else:
self.add_new_binaries(SysPatchArray.AddVolumeControlv2, self.constants.audio_v2_path)
def add_wifi_patch(self):
print("- Merging Wireless CoreSerices patches")
@@ -668,7 +671,9 @@ set million colour before rebooting"""
if self.constants.detected_os > self.constants.catalina:
self.brightness_legacy = True
if self.model in ["iMac7,1", "iMac8,1"]:
if self.model in ["iMac7,1", "iMac8,1"] or (self.model in ModelArray.LegacyAudio and Utilities.check_kext_loaded("AppleALC", self.constants.detected_os) is False):
# Special hack for systems with botched GOPs
# TL;DR: No Boot Screen breaks Lilu, therefore breaking audio
if self.constants.detected_os > self.constants.catalina:
self.legacy_audio = True

View File

@@ -187,6 +187,10 @@ AddVolumeControl = [
"IOAudioFamily.kext",
]
AddVolumeControlv2 = [
"AppleHDA.kext",
]
DeleteVolumeControl = [
"AppleVirtIO.kext",
"AppleVirtualGraphics.kext",

View File

@@ -152,6 +152,15 @@ def amfi_status():
else:
return True
def check_kext_loaded(kext_name, os_version):
if os_version > Constants.Constants().catalina:
kext_loaded = subprocess.run(["kmutil", "showloaded", "--list-only", "--variant-suffix", "release"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
kext_loaded = subprocess.run(["kextstat", "-l"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if kext_name in kext_loaded.stdout.decode():
return True
else:
return False
def check_oclp_boot():
if get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True):