Add user-configurable CPUFriend

Closes https://github.com/dortania/OpenCore-Legacy-Patcher/issues/199
This commit is contained in:
Mykola Grymalyuk
2021-05-08 14:04:01 -06:00
parent 9b89b62219
commit 2a9f94ac99
6 changed files with 31 additions and 7 deletions

View File

@@ -6,7 +6,7 @@
- Innie 0ccd95e (1.3.0 release - 01-16-2021)
- Fix MacBookPro5,4 audio support
- Increment binaries
- AppleALC fceb8b0 (1.6.1 rolling - 05-04-2021)
- AppleALC 58b57ee (1.6.1 rolling - 05-07-2021)
- Support custom CPU names in About This Mac
- Fix NightShift accidentally disabling on Minimal SMBIOS configs
- Fix iMac9,1 audio support

View File

@@ -115,6 +115,7 @@ system_profiler SPHardwareDataType | grep 'Model Identifier'
[f"Assume Legacy GPU:\t\t\t{self.constants.assume_legacy}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).force_accel_setting],
[f"Allow OpenCore on native Models:\t{self.constants.allow_oc_everywhere}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).allow_native_models],
[f"Download more RAM:\t\t\t{self.constants.download_ram}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).download_more_ram_dot_com],
[f"Disable CPU Friend:\t\t{self.constants.disallow_cpufriend}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).disable_cpufriend],
[f"Set Custom name {self.constants.custom_cpu_model_value}", CliMenu.MenuOptions(self.constants.custom_model or self.current_model, self.constants).custom_cpu],
]

View File

@@ -92,7 +92,7 @@ class BuildOpenCore:
("AppleMCEReporterDisabler.kext", self.constants.mce_version, self.constants.mce_path, lambda: self.model in ModelArray.DualSocket),
("AAAMouSSE.kext", self.constants.mousse_version, self.constants.mousse_path, lambda: self.model in ModelArray.SSEEmulator),
("telemetrap.kext", self.constants.telemetrap_version, self.constants.telemetrap_path, lambda: self.model in ModelArray.MissingSSE42),
("CPUFriend.kext", self.constants.cpufriend_version, self.constants.cpufriend_path, lambda: self.model != "iMac7,1" and self.constants.allow_oc_everywhere is False),
("CPUFriend.kext", self.constants.cpufriend_version, self.constants.cpufriend_path, lambda: self.model != "iMac7,1" and self.constants.allow_oc_everywhere is False and self.constants.disallow_cpufriend is False),
# Ethernet patches
("nForceEthernet.kext", self.constants.nforce_version, self.constants.nforce_path, lambda: self.model in ModelArray.EthernetNvidia),
("MarvelYukonEthernet.kext", self.constants.marvel_version, self.constants.marvel_path, lambda: self.model in ModelArray.EthernetMarvell),
@@ -312,12 +312,18 @@ class BuildOpenCore:
# AGPM Patch
if self.model in ModelArray.DualGPUPatch:
print("- Adding dual GPU patch")
if not self.constants.custom_model:
gfx0_path: str = subprocess.run([self.constants.gfxutil_path] + f"-f GFX0".split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.decode()
if gfx0_path == "":
gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"
else:
gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"
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": "vit9696", "shikigva": 256}
self.config["DeviceProperties"]["Add"][gfx0_path] = {"agdpmod": "vit9696", "shikigva": 256}
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x2,0x0)"] = {"disable-gpu-min": "20.0.0"}
else:
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"] = {"agdpmod": "vit9696"}
self.config["DeviceProperties"]["Add"][gfx0_path] = {"agdpmod": "vit9696"}
# HiDPI OpenCanopy and FileVault
if self.model in ModelArray.HiDPIpicker:
@@ -342,12 +348,12 @@ class BuildOpenCore:
print(f"- Found GFX0 device at {self.gfx0_path}")
except IndexError:
print("- Failed to find GFX0 Device path, falling back on known logic")
if self.model == ["iMac11,1", "iMac11,3"]:
if self.model in ["iMac11,1", "iMac11,3"]:
self.gfx0_path = "PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"
else:
self.gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"
else:
if self.model == ["iMac11,1", "iMac11,3"]:
if self.model in ["iMac11,1", "iMac11,3"]:
self.gfx0_path = "PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"
else:
self.gfx0_path = "PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)"
@@ -635,7 +641,7 @@ class BuildOpenCore:
self.config["PlatformInfo"]["CustomMemory"] = True
# USB Map and CPUFriend Patching
if self.constants.allow_oc_everywhere is False and self.model != "iMac7,1":
if self.constants.allow_oc_everywhere is False and self.model != "iMac7,1" and self.constants.disallow_cpufriend is False:
new_map_ls = Path(self.constants.map_contents_folder) / Path("Info.plist")
map_config = plistlib.load(Path(new_map_ls).open("rb"))

View File

@@ -396,3 +396,19 @@ Currently only offers 1.5TB bundles
self.constants.download_ram = False
else:
print("Invalid option")
def disable_cpufriend(self):
Utilities.cls()
Utilities.header(["Disable CPU Friend?"])
print("""Only recommended for advanced users
Disabling CPUFriend forces macOS into using a different
Mac's power profile for CPUs and GPUs, which can harm the
hardware
""")
change_menu = input("Disable CPU Friend?(y/n): ")
if change_menu == "y":
self.constants.disallow_cpufriend = True
elif change_menu == "n":
self.constants.disallow_cpufriend = False
else:
print("Invalid option")

View File

@@ -76,6 +76,7 @@ class Constants:
self.custom_cpu_model_value = ""
self.custom_color = ""
self.download_ram = False
self.disallow_cpufriend = False
# OS Versions
self.tiger = 8