Merge pull request #1033 from dortania/pullrequests/Ausdauersportler/main

Ausdauersportler: Add RX5500XT and Lexa MXM support (reworked)
This commit is contained in:
Mykola Grymalyuk
2023-03-11 20:39:06 -07:00
committed by GitHub
12 changed files with 3475 additions and 34 deletions
+4 -1
View File
@@ -249,6 +249,9 @@ IntelNvidiaDRM = [
# Mac Pro and Xserve
MacPro = ["MacPro3,1", "MacPro4,1", "MacPro5,1", "Xserve2,1", "Xserve3,1", "Dortania1,1"]
# MXM iMac
MXMiMac = ["iMac11,1", "iMac11,2", "iMac11,3", "iMac10,1", "iMac12,1", "iMac12,2", "Dortania1,1"]
NoAGPMSupport = ["MacBook4,1", "MacBookPro4,1", "iMac7,1", "iMac8,1", "MacPro3,1", "Xserve2,1", "Dortania1,1"]
AGDPSupport = [
@@ -350,4 +353,4 @@ Missing_USB_Map_Ventura = [
"iMac16,1",
"iMac16,2",
"iMac17,1",
]
]
+5
View File
@@ -796,6 +796,11 @@ class amd_ids:
0x67CF, # Unknown
]
polaris_spoof_ids = [
# Polaris 12 (Lexa)
0x6981, # Lexa XT [Radeon PRO WX 3200]
]
vega_ids = [
# GCN v5
# AMDRadeonX5000
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
Following patch required for iMacs with Navi MXM GPUs
Source: https://github.com/kingo132/a51m-r2-5700m-hackintosh/issues/13
File diff suppressed because it is too large Load Diff
+76 -17
View File
@@ -1,13 +1,14 @@
# Class for handling Graphics and Audio Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk
from resources import constants, device_probe, utilities
from resources.build import support
from data import smbios_data, model_array, os_data, cpu_data
import shutil, binascii, logging
from pathlib import Path
import shutil, binascii, logging
from resources import constants, device_probe, utilities
from resources.build import support
from data import smbios_data, model_array, os_data, cpu_data, video_bios_data
class build_graphics_audio:
@@ -21,17 +22,18 @@ class build_graphics_audio:
def build(self):
self.imac_mxm_patching()
self.graphics_handling()
self.audio_handling()
self.firmware_handling()
self.spoof_handling()
self.imac_mxm_patching()
self.ioaccel_workaround()
def graphics_handling(self):
if self.constants.allow_oc_everywhere is False and self.constants.serial_settings != "None":
support.build_support(self.model, self.constants, self.config).enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path)
if not support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is True:
support.build_support(self.model, self.constants, self.config).enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path)
# Mac Pro handling
if self.model in model_array.MacPro:
@@ -104,11 +106,33 @@ class build_graphics_audio:
if "nvda_drv" not in self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]:
self.config["NVRAM"]["Delete"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"] += ["nvda_drv"]
def backlight_path_detection(self):
# self.constants.custom_model: iMac has been modded with new dGPU
# self.computer.dgpu: dGPU has been found using the GFX0 path
# self.computer.dgpu.pci_path:
if not self.constants.custom_model and self.computer.dgpu and self.computer.dgpu.pci_path:
self.gfx0_path = self.computer.dgpu.pci_path
logging.info(f"- Found GFX0 Device Path: {self.gfx0_path}")
for i, device in enumerate(self.computer.gpus):
logging.info(f"- Found dGPU ({i + 1}): {utilities.friendly_hex(device.vendor_id)}:{utilities.friendly_hex(device.device_id)}")
self.config["#Revision"][f"Hardware-iMac-dGPU-{i + 1}"] = f"{utilities.friendly_hex(device.vendor_id)}:{utilities.friendly_hex(device.device_id)}"
if device.pci_path != self.computer.dgpu.pci_path:
logging.info("- device path and GFX0 Device path are different")
self.gfx0_path = device.pci_path
logging.info(f"- Set GFX0 Device Path: {self.gfx0_path}")
self.computer.dgpu.device_id = device.device_id
self.device_id = device.device_id
logging.info(f"- Found GPU Arch: {device.arch}")
if device.arch in [device_probe.AMD.Archs.Navi]:
self.computer.dgpu.arch = device.arch
# self.computer.dgpu.vendor_id = device.vendor_id
# self.vendor_id = device.vendor_id
else:
self.gfx0_path = self.computer.dgpu.pci_path
logging.info(f"- Found GFX0 Device Path: {self.gfx0_path}")
logging.info(f"- Found GPU Arch: {self.computer.dgpu.arch}")
else:
if not self.constants.custom_model:
logging.info("- Failed to find GFX0 Device path, falling back on known logic")
@@ -123,7 +147,7 @@ class build_graphics_audio:
def nvidia_mxm_patch(self, backlight_path):
if not support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is True:
# Ensure WEG is enabled as we need if for Backlight patching
support.build_support(self.model, self.constants, self.config).enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path)
support.build_support(self.model, self.constants, self.config).enable_kext("WhateverGreen.kext", self.constants.whatevergreen_navi_version, self.constants.whatevergreen_navi_path)
if self.model in ["iMac11,1", "iMac11,2", "iMac11,3", "iMac10,1"]:
logging.info("- Adding Nvidia Brightness Control and DRM patches")
self.config["DeviceProperties"]["Add"][backlight_path] = {
@@ -168,8 +192,22 @@ class build_graphics_audio:
logging.info("- Adding AMD DRM patches")
if not support.build_support(self.model, self.constants, self.config).get_kext_by_bundle_path("WhateverGreen.kext")["Enabled"] is True:
# Ensure WEG is enabled as we need if for Backlight patching
support.build_support(self.model, self.constants, self.config).enable_kext("WhateverGreen.kext", self.constants.whatevergreen_version, self.constants.whatevergreen_path)
self.config["DeviceProperties"]["Add"][backlight_path] = {"shikigva": 128, "unfairgva": 1, "agdpmod": "pikera", "rebuild-device-tree": 1, "enable-gva-support": 1}
support.build_support(self.model, self.constants, self.config).enable_kext("WhateverGreen.kext", self.constants.whatevergreen_navi_version, self.constants.whatevergreen_navi_path)
if not self.constants.custom_model:
if self.computer.dgpu.device_id == 0x7340:
logging.info(f"- Adding AMD RX5500XT vBIOS injection")
self.config["DeviceProperties"]["Add"][backlight_path] = {"shikigva": 128, "unfairgva": 1, "agdpmod": "pikera", "rebuild-device-tree": 1, "enable-gva-support": 1, "ATY,bin_image": binascii.unhexlify(video_bios_data.RX5500XT_64K) }
logging.info(f"- Adding AMD RX5500XT boot-args")
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " agdpmod=pikera applbkl=3"
elif self.computer.dgpu.device_id_unspoofed == 0x6981:
logging.info(f"- Adding AMD WX3200 device spoofing")
self.config["DeviceProperties"]["Add"][backlight_path] = {"shikigva": 128, "unfairgva": 1, "agdpmod": "pikera", "rebuild-device-tree": 1, "enable-gva-support": 1, "model": "AMD Radeon Pro WX 3200", "device-id": binascii.unhexlify("FF67")}
else:
self.config["DeviceProperties"]["Add"][backlight_path] = {"shikigva": 128, "unfairgva": 1, "agdpmod": "pikera", "rebuild-device-tree": 1, "enable-gva-support": 1}
else:
self.config["DeviceProperties"]["Add"][backlight_path] = {"shikigva": 128, "unfairgva": 1, "agdpmod": "pikera", "rebuild-device-tree": 1, "enable-gva-support": 1}
if self.constants.custom_model and self.model == "iMac11,2":
# iMac11,2 can have either PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0) or PciRoot(0x0)/Pci(0x1,0x0)/Pci(0x0,0x0)
# Set both properties when we cannot run hardware detection
@@ -207,7 +245,27 @@ class build_graphics_audio:
"CAIL,CAIL_DisableUVDPowerGating": 1,
"CAIL,CAIL_DisableVCEPowerGating": 1,
})
elif self.constants.imac_model == "AMD Lexa":
logging.info("- Adding Lexa Spoofing Patches")
self.config["DeviceProperties"]["Add"][backlight_path].update({
"model": "AMD Radeon Pro WX 3200",
"device-id": binascii.unhexlify("FF67"),
})
if self.model == "iMac11,2":
self.config["DeviceProperties"]["Add"]["PciRoot(0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)"].update({
"model": "AMD Radeon Pro WX 3200",
"device-id": binascii.unhexlify("FF67"),
})
elif self.constants.imac_model == "AMD Navi":
logging.info("- Adding Navi Spoofing Patches")
navi_backlight_path = backlight_path+"/Pci(0x0,0x0)/Pci(0x0,0x0)"
self.config["DeviceProperties"]["Add"][navi_backlight_path] = {
"ATY,bin_image": binascii.unhexlify(video_bios_data.RX5500XT_64K),
"shikigva": 128,
"unfairgva": 1,
"rebuild-device-tree": 1,
"enable-gva-support": 1
}
def audio_handling(self):
if (self.model in model_array.LegacyAudio or self.model in model_array.MacPro) and self.constants.set_alc_usage is True:
@@ -352,9 +410,9 @@ class build_graphics_audio:
def imac_mxm_patching(self):
self.backlight_path_detection()
# Check GPU Vendor
if self.constants.metal_build is True:
self.backlight_path_detection()
logging.info("- Adding Metal GPU patches on request")
if self.constants.imac_vendor == "AMD":
self.amd_mxm_patch(self.gfx0_path)
@@ -369,13 +427,12 @@ class build_graphics_audio:
device_probe.AMD.Archs.Legacy_GCN_8000,
device_probe.AMD.Archs.Legacy_GCN_9000,
device_probe.AMD.Archs.Polaris,
device_probe.AMD.Archs.Polaris_Spoof,
device_probe.AMD.Archs.Vega,
device_probe.AMD.Archs.Navi,
]:
self.backlight_path_detection()
self.amd_mxm_patch(self.gfx0_path)
elif self.computer.dgpu.arch == device_probe.NVIDIA.Archs.Kepler:
self.backlight_path_detection()
self.nvidia_mxm_patch(self.gfx0_path)
def ioaccel_workaround(self):
@@ -430,6 +487,7 @@ class build_graphics_audio:
if gpu in [
# Metal KDK (pre-AVX2.0)
device_probe.AMD.Archs.Polaris,
device_probe.AMD.Archs.Polaris_Spoof,
device_probe.AMD.Archs.Vega,
device_probe.AMD.Archs.Navi,
]:
@@ -454,8 +512,9 @@ class build_graphics_audio:
gpu = gpu.arch
if gpu in [
device_probe.AMD.Archs.Polaris,
device_probe.AMD.Archs.Polaris_Spoof,
device_probe.AMD.Archs.Vega,
device_probe.AMD.Archs.Navi,
]:
support.build_support(self.model, self.constants, self.config).enable_kext("KDKlessWorkaround.kext", self.constants.kdkless_version, self.constants.kdkless_path)
return
return
+5
View File
@@ -34,6 +34,7 @@ class Constants:
## https://github.com/acidanthera
self.lilu_version = "1.6.3" # Lilu
self.whatevergreen_version = "1.6.3" # WhateverGreen
self.whatevergreen_navi_version = "1.6.3-Navi" # WhateverGreen (Navi Patch)
self.airportbcrmfixup_version = "2.1.6" # AirPortBrcmFixup
self.nvmefix_version = "1.0.9" # NVMeFix
self.applealc_version = "1.6.3" # AppleALC
@@ -302,6 +303,10 @@ class Constants:
def whatevergreen_path(self):
return self.payload_kexts_path / Path(f"Acidanthera/WhateverGreen-v{self.whatevergreen_version}-{self.kext_variant}.zip")
@property
def whatevergreen_navi_path(self):
return self.payload_kexts_path / Path(f"Acidanthera/WhateverGreen-v{self.whatevergreen_navi_version}-{self.kext_variant}.zip")
@property
def airportbcrmfixup_path(self):
return self.payload_kexts_path / Path(f"Acidanthera/AirportBrcmFixup-v{self.airportbcrmfixup_version}-{self.kext_variant}.zip")
+14 -3
View File
@@ -20,8 +20,9 @@ class GenerateDefaults:
def __init__(self, model: str, host_is_target: bool, global_constants: constants.Constants):
self.constants: constants.Constants = global_constants
self.model: str = model
self.host_is_target: str = host_is_target
self.model: str = model
self.host_is_target: bool = host_is_target
# Reset Variables
self.constants.sip_status: bool = True
@@ -31,9 +32,16 @@ class GenerateDefaults:
self.constants.fu_status: bool = True
self.constants.fu_arguments: str = None
self.constants.custom_serial_number: str = ""
self.constants.custom_board_serial_number: str = ""
if self.host_is_target is True:
for gpu in self.constants.computer.gpus:
if gpu.device_id_unspoofed == -1:
gpu.device_id_unspoofed = gpu.device_id
if gpu.vendor_id_unspoofed == -1:
gpu.vendor_id_unspoofed = gpu.vendor_id
self._general_probe()
self._nvram_probe()
@@ -233,6 +241,7 @@ class GenerateDefaults:
device_probe.AMD.Archs.Legacy_GCN_8000,
device_probe.AMD.Archs.Legacy_GCN_9000,
device_probe.AMD.Archs.Polaris,
device_probe.AMD.Archs.Polaris_Spoof,
device_probe.AMD.Archs.Vega,
device_probe.AMD.Archs.Navi,
]:
@@ -241,6 +250,7 @@ class GenerateDefaults:
device_probe.AMD.Archs.Legacy_GCN_8000,
device_probe.AMD.Archs.Legacy_GCN_9000,
device_probe.AMD.Archs.Polaris,
device_probe.AMD.Archs.Polaris_Spoof,
device_probe.AMD.Archs.Vega,
device_probe.AMD.Archs.Navi,
]:
@@ -258,6 +268,7 @@ class GenerateDefaults:
# See if system can use the native AMD stack in Ventura
if gpu in [
device_probe.AMD.Archs.Polaris,
device_probe.AMD.Archs.Polaris_Spoof,
device_probe.AMD.Archs.Vega,
device_probe.AMD.Archs.Navi,
]:
+33 -11
View File
@@ -25,25 +25,41 @@ class CPU:
class PCIDevice:
VENDOR_ID: ClassVar[int] # Default vendor id, for subclasses.
vendor_id: int # The vendor ID of this PCI device
device_id: int # The device ID of this PCI device
vendor_id: int # The vendor ID of this PCI device
device_id: int # The device ID of this PCI device
class_code: int # The class code of this PCI device - https://pci-ids.ucw.cz/read/PD
name: Optional[str] = None # Name of IORegistryEntry
model: Optional[str] = None # model property
acpi_path: Optional[str] = None # ACPI Device Path
pci_path: Optional[str] = None # PCI Device Path
disable_metal: Optional[bool] = False # 'disable-metal' property
force_compatible: Optional[bool] = False # 'force-compat' property
name: Optional[str] = None # Name of IORegistryEntry
model: Optional[str] = None # model property
acpi_path: Optional[str] = None # ACPI Device Path
pci_path: Optional[str] = None # PCI Device Path
disable_metal: Optional[bool] = False # 'disable-metal' property
force_compatible: Optional[bool] = False # 'force-compat' property
vendor_id_unspoofed: Optional[int] = -1 # Unspoofed vendor ID of this PCI device
device_id_unspoofed: Optional[int] = -1 # Unspoofed device ID of this PCI device
@classmethod
def from_ioregistry(cls, entry: ioreg.io_registry_entry_t, anti_spoof=False):
properties: dict = ioreg.corefoundation_to_native(ioreg.IORegistryEntryCreateCFProperties(entry, None, ioreg.kCFAllocatorDefault, ioreg.kNilOptions)[1]) # type: ignore
if anti_spoof and "IOName" in properties:
vendor_id, device_id = (int(i, 16) for i in properties["IOName"][3:].split(","))
else:
vendor_id = None
device_id = None
vendor_id_unspoofed = None
device_id_unspoofed = None
if "IOName" in properties and properties["IOName"].startswith("pci"):
vendor_id_unspoofed, device_id_unspoofed = (int(i, 16) for i in properties["IOName"][3:].split(","))
if anti_spoof:
vendor_id = vendor_id_unspoofed
device_id = device_id_unspoofed
if vendor_id is None and device_id is None:
vendor_id, device_id = [int.from_bytes(properties[i][:4], byteorder="little") for i in ["vendor-id", "device-id"]]
if vendor_id_unspoofed is None and device_id_unspoofed is None:
vendor_id_unspoofed = vendor_id
device_id_unspoofed = device_id
device = cls(vendor_id, device_id, int.from_bytes(properties["class-code"][:6], byteorder="little"), name=ioreg.io_name_t_to_str(ioreg.IORegistryEntryGetName(entry, None)[1]))
if "model" in properties:
model = properties["model"]
@@ -56,6 +72,9 @@ class PCIDevice:
device.disable_metal = True
if "force-compat" in properties:
device.force_compatible = True
device.vendor_id_unspoofed = vendor_id_unspoofed
device.device_id_unspoofed = device_id_unspoofed
device.populate_pci_path(entry)
return device
@@ -242,6 +261,7 @@ class AMD(GPU):
Legacy_GCN_8000 = "Legacy GCN v2"
Legacy_GCN_9000 = "Legacy GCN v3"
Polaris = "Polaris"
Polaris_Spoof = "Polaris (Spoofed)"
Vega = "Vega"
Navi = "Navi"
Unknown = "Unknown"
@@ -263,6 +283,8 @@ class AMD(GPU):
self.arch = AMD.Archs.TeraScale_2
elif self.device_id in pci_data.amd_ids.polaris_ids:
self.arch = AMD.Archs.Polaris
elif self.device_id in pci_data.amd_ids.polaris_spoof_ids:
self.arch = AMD.Archs.Polaris_Spoof
elif self.device_id in pci_data.amd_ids.vega_ids:
self.arch = AMD.Archs.Vega
elif self.device_id in pci_data.amd_ids.navi_ids:
+6 -2
View File
@@ -2760,7 +2760,7 @@ class wx_python_gui:
# Dropdown: GPU Model
self.gpu_dropdown = wx.Choice(self.frame_modal)
for gpu in ["None", "Nvidia Kepler", "AMD GCN", "AMD Polaris"]:
for gpu in ["None", "Nvidia Kepler", "AMD GCN", "AMD Polaris", "AMD Navi", "AMD Lexa"]:
self.gpu_dropdown.Append(gpu)
self.gpu_dropdown.SetSelection(0)
self.gpu_dropdown.SetPosition(wx.Point(
@@ -3191,6 +3191,10 @@ class wx_python_gui:
self.constants.imac_model = "Polaris"
elif "GCN" in gpu_choice:
self.constants.imac_model = "Legacy GCN"
elif "Lexa" in gpu_choice:
self.constants.imac_model = "AMD Lexa"
elif "Navi" in gpu_choice:
self.constants.imac_model = "AMD Navi"
else:
raise Exception("Unknown GPU Model")
elif "Nvidia" in gpu_choice:
@@ -3885,4 +3889,4 @@ OpenCore Legacy Patcher by default knows the most ideal
subprocess.run(["defaults", "write", "-g", "Moraea_RimBetaDisabled", "-bool", "true"])
else:
subprocess.run(["defaults", "write", "-g", "Moraea_RimBetaDisabled", "-bool", "false"])
logging.info("Beta Rim Enabled:", event.IsChecked())
logging.info("Beta Rim Enabled:", event.IsChecked())