提交 ced62ddf 编写于 作者: V vit9696

OcMainLib: Added `ResetTrafficClass` to reset TCSEL to T0 on legacy HDA

上级 6a69e346
......@@ -19,6 +19,7 @@ OpenCore Changelog
- Added `acdtinfo` utility to lookup certain products
- Fixed `FSBFrequency` calculation with fractional multiplier
- Fixed showing core count for some AMD CPUs
- Added `ResetTrafficClass` to reset TCSEL to T0 on legacy HDA
#### v0.6.6
- Added keyboard and pointer entry scroll support in OpenCanopy
......
......@@ -6142,6 +6142,19 @@ functioning. Feature highlights:
\emph{Note}: \texttt{Enabled} can be used in separate from \texttt{StartupMute}
NVRAM variable to avoid conflicts when the firmware is able to play boot chime.
\item
\texttt{ResetTrafficClass}\\
\textbf{Type}: \texttt{plist\ boolean}\\
\textbf{Failsafe}: \texttt{false}\\
\textbf{Description}: Set HDA Traffic Class Select Register to \texttt{TC0}.
AppleHDA kext will function correctly only if \texttt{TCSEL} register is configured
to use \texttt{TC0} traffic class. Refer to Intel I/O Controller Hub 9 (ICH9) Family
Datasheet (or any other ICH datasheet) for more details about this register.
\emph{Note}: This option is independent from \texttt{AudioSupport}. If AppleALC is used
it is preferred to use AppleALC \texttt{alctsel} property instead.
\item
\texttt{SetupDelay}\\
\textbf{Type}: \texttt{plist\ integer}\\
......
此差异已折叠。
......@@ -1086,6 +1086,8 @@
<integer>20</integer>
<key>PlayChime</key>
<string>Auto</string>
<key>ResetTrafficClass</key>
<false/>
<key>SetupDelay</key>
<integer>0</integer>
<key>VolumeAmplifier</key>
......
......@@ -1283,6 +1283,8 @@
<integer>20</integer>
<key>PlayChime</key>
<string>Auto</string>
<key>ResetTrafficClass</key>
<false/>
<key>SetupDelay</key>
<integer>0</integer>
<key>VolumeAmplifier</key>
......
......@@ -590,7 +590,8 @@ typedef enum {
_(BOOLEAN , AudioSupport , , FALSE , ()) \
_(UINT8 , AudioCodec , , 0 , ()) \
_(UINT8 , AudioOut , , 0 , ()) \
_(UINT8 , MinimumVolume , , 0 , ())
_(UINT8 , MinimumVolume , , 0 , ()) \
_(BOOLEAN , ResetTrafficClass , , FALSE , ())
OC_DECLARE (OC_UEFI_AUDIO)
///
......
......@@ -714,6 +714,7 @@ mUefiAudioSchema[] = {
OC_SCHEMA_BOOLEAN_IN ("AudioSupport", OC_GLOBAL_CONFIG, Uefi.Audio.AudioSupport),
OC_SCHEMA_INTEGER_IN ("MinimumVolume", OC_GLOBAL_CONFIG, Uefi.Audio.MinimumVolume),
OC_SCHEMA_STRING_IN ("PlayChime", OC_GLOBAL_CONFIG, Uefi.Audio.PlayChime),
OC_SCHEMA_BOOLEAN_IN ("ResetTrafficClass", OC_GLOBAL_CONFIG, Uefi.Audio.ResetTrafficClass),
OC_SCHEMA_INTEGER_IN ("SetupDelay", OC_GLOBAL_CONFIG, Uefi.Audio.SetupDelay),
OC_SCHEMA_INTEGER_IN ("VolumeAmplifier", OC_GLOBAL_CONFIG, Uefi.Audio.VolumeAmplifier),
};
......
......@@ -51,6 +51,7 @@
gOcInterfaceProtocolGuid ## SOMETIMES_CONSUMES
gEfiSecurityArchProtocolGuid ## SOMETIMES_CONSUMES
gEfiSecurity2ArchProtocolGuid ## SOMETIMES_CONSUMES
gEfiPciIoProtocolGuid ## SOMETIMES_CONSUMES
[LibraryClasses]
DevicePathLib
......
......@@ -17,7 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/AppleVariable.h>
#include <Guid/OcVariable.h>
#include <Guid/GlobalVariable.h>
#include <IndustryStandard/Pci30.h>
#include <Protocol/AudioDecode.h>
#include <Protocol/PciIo.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
......@@ -469,6 +471,84 @@ OcAudioExitBootServices (
OcAudio->StopPlayback (OcAudio, TRUE);
}
STATIC
VOID
ResetAudioTrafficClass (
VOID
)
{
EFI_STATUS Status;
UINTN HandleCount;
EFI_HANDLE *HandleBuffer;
UINTN Index;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT32 ClassCode;
UINT8 TrafficClass;
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiPciIoProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OC: No PCI devices for TCSEL reset - %r\n", Status));
return;
}
for (Index = 0; Index < HandleCount; ++Index) {
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiPciIoProtocolGuid,
(VOID **) &PciIo
);
if (EFI_ERROR (Status)) {
continue;
}
Status = PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint32,
OFFSET_OF (PCI_DEVICE_INDEPENDENT_REGION, RevisionID),
1,
&ClassCode
);
if (EFI_ERROR (Status)) {
continue;
}
ClassCode >>= 16U; ///< Drop revision and minor codes.
if (ClassCode == (PCI_CLASS_MEDIA << 8 | PCI_CLASS_MEDIA_AUDIO)
|| ClassCode == (PCI_CLASS_MEDIA << 8 | 0x3 /* PCI_CLASS_MEDIA_HDA */)) {
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x44 /* TCSEL */, 1, &TrafficClass);
if (EFI_ERROR (Status)) {
continue;
}
DEBUG ((
DEBUG_INFO,
"OC: Discovered audio device at %u/%u with TCSEL %X\n",
(UINT32) (Index + 1),
(UINT32) HandleCount,
TrafficClass
));
//
// Update Traffic Class Select Register to TC0.
// This is required for AppleHDA to output audio on some machines.
// See Intel I/O Controller Hub 9 (ICH9) Family Datasheet for more details.
//
if ((TrafficClass & 0x7U) != 0) {
TrafficClass &= ~0x7U;
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x44 /* TCSEL */, 1, &TrafficClass);
}
}
}
}
VOID
OcLoadUefiAudioSupport (
IN OC_STORAGE_CONTEXT *Storage,
......@@ -483,6 +563,10 @@ OcLoadUefiAudioSupport (
UINT8 VolumeLevel;
BOOLEAN Muted;
if (Config->Uefi.Audio.ResetTrafficClass) {
ResetAudioTrafficClass ();
}
if (!Config->Uefi.Audio.AudioSupport) {
DEBUG ((DEBUG_INFO, "OC: Requested not to use audio\n"));
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册