Fix Country Code detection

Closes https://github.com/dortania/OpenCore-Legacy-Patcher/issues/184
This commit is contained in:
Mykola Grymalyuk
2021-06-18 19:08:01 -06:00
parent c5fd4036a7
commit 292e09a0d7
3 changed files with 17 additions and 6 deletions

View File

@@ -8,6 +8,7 @@
- Deprecates Apple-Binaries-OCLP
- Fix full screen and Airplay to Mac support for Intel HD4000 iGPUs
- Automatically set `CMIO_Unit_Input_ASC.DoNotUseOpenCL` on TeraScale 2 GPUs
- Fix Country Code detection on Wireless Cards
## 0.1.9
- Fix incorrect AMFI and SIP detection

View File

@@ -239,8 +239,8 @@ class BuildOpenCore:
# iMac11,x-12,x also apply
arpt_path = "PciRoot(0x0)/Pci(0x1C,0x1)/Pci(0x0,0x0)"
print(f"- Using known DevicePath {arpt_path}")
print("- Applying fake ID for WiFi")
self.config["DeviceProperties"]["Add"][arpt_path] = {"device-id": binascii.unhexlify("ba430000"), "compatible": "pci14e4,43ba"}
print(f"- Applying fake ID for WiFi, setting Country Code: {self.computer.wifi.country_code}")
self.config["DeviceProperties"]["Add"][arpt_path] = {"device-id": binascii.unhexlify("ba430000"), "compatible": "pci14e4,43ba", "brcmfx-country": self.computer.wifi.country_code}
# WiFi patches
# TODO: -a is not supported in Lion and older, need to add proper fix
@@ -258,6 +258,13 @@ class BuildOpenCore:
# This works around OCLP spoofing the Wifi card and therefore unable to actually detect the correct device
if self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirportBrcmNIC:
self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
print(f"- Setting Wireless Card's Country Code: {self.computer.wifi.country_code}")
if not self.constants.custom_model and self.computer.wifi and self.computer.wifi.pci_path:
arpt_path = self.computer.wifi.pci_path
print(f"- Found ARPT device at {arpt_path}")
self.config["DeviceProperties"]["Add"][arpt_path] = {"brcmfx-country": self.computer.wifi.wifi.country_code}
else:
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" brcmfx-country={self.computer.wifi.country_code}"
elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm4360:
wifi_fake_id(self)
elif self.computer.wifi.chipset == device_probe.Broadcom.Chipsets.AirPortBrcm4331:
@@ -271,9 +278,7 @@ class BuildOpenCore:
self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path)
self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
else:
if self.model in ["iMac14,1", "iMac14,2", "iMac14,3"]:
self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
elif self.model in ModelArray.WifiBCM94331:
if self.model in ModelArray.WifiBCM94331:
wifi_fake_id(self)
elif self.model in ModelArray.WifiBCM94322:
self.enable_kext("IO80211Mojave.kext", self.constants.io80211mojave_version, self.constants.io80211mojave_path)
@@ -285,6 +290,10 @@ class BuildOpenCore:
elif self.model in ModelArray.WifiAtheros:
self.enable_kext("IO80211HighSierra.kext", self.constants.io80211high_sierra_version, self.constants.io80211high_sierra_path)
self.get_kext_by_bundle_path("IO80211HighSierra.kext/Contents/PlugIns/AirPortAtheros40.kext")["Enabled"] = True
else:
self.enable_kext("AirportBrcmFixup.kext", self.constants.airportbcrmfixup_version, self.constants.airportbcrmfixup_path)
print(f"- Setting Wireless Card's Country Code: {self.computer.wifi.country_code}")
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += f" brcmfx-country={self.computer.wifi.country_code}"
# CPUFriend
pp_map_path = Path(self.constants.platform_plugin_plist_path) / Path(f"{self.model}/Info.plist")

View File

@@ -1,6 +1,7 @@
import binascii
import enum
import itertools
import plistlib
import subprocess
from dataclasses import dataclass, field
from typing import Any, ClassVar, Optional, Type
@@ -104,7 +105,7 @@ class WirelessCard(PCIDevice):
chipset: enum.Enum = field(init=False)
def __post_init__(self):
system_profiler = plistlib.loads(subprocess.run("system_profiler -xml SPAirPortDataType", stdout=subprocess.PIPE).stdout)
system_profiler = plistlib.loads(subprocess.run("system_profiler -xml SPAirPortDataType".split(), stdout=subprocess.PIPE).stdout)
self.country_code = system_profiler[0]["_items"][0]["spairport_airport_interfaces"][0]["spairport_wireless_country_code"]
self.detect_chipset()