AudioDxe: Add --restore-nosnoop flag

This commit is contained in:
MikeBeaton 2022-02-10 00:40:37 +00:00
parent f3004e2e7b
commit 0455326487
12 changed files with 51 additions and 26 deletions

View File

@ -2,6 +2,7 @@ OpenCore Changelog
==================
#### v0.7.9
- Added auto-detect `macOS Installer` volume name for use when `.disk_label` file cannot be displayed
- Added `--restore-nosnoop` flag to AudioDxe, making v0.7.7 fix for Windows sound opt-in
#### v0.7.8
- Updated ocvalidate to warn about insecure `DmgLoading` with secure `SecureBootModel` (already disallowed in runtime)

View File

@ -1 +1 @@
234bf876a6e9ec92239d908af9aae409
8fe92652e6b6bf444b97fb743cae2a52

Binary file not shown.

View File

@ -6537,6 +6537,9 @@ with the boot menu.
High Definition Audio support driver in UEFI firmware for most Intel and some other analog audio controllers.
\emph{Note}: AudioDxe is a staging driver, refer to \href{https://github.com/acidanthera/bugtracker/issues/740}{acidanthera/bugtracker\#740}
for known issues.
\subsubsection{Configuration}
Most UEFI audio configuration is handled via the \hyperref[uefiaudioprops]{\texttt{UEFI Audio Properties}}
@ -6590,10 +6593,15 @@ on most Apple hardware, and possibly some others) may be specified in \texttt{UE
Values for driver parameters can be specified in hexadecimal beginning with \texttt{0x} or
in decimal, e.g. \texttt{-{}-gpio-pins=0x12} or \texttt{-{}-gpio-pins=18}.
\end{itemize}
\emph{Note}: AudioDxe is a staging driver, refer to \href{https://github.com/acidanthera/bugtracker/issues/740}{acidanthera/bugtracker\#740}
for known issues.
\item \texttt{-{}-restore-nosnoop} - Boolean flag, enabled if present. \medskip
AudioDxe clears the Intel HDA No Snoop Enable (NSNPEN) bit. On some systems, this change must
be reversed on exit in order to avoid breaking sound in Windows. If so, this flag should
be added to AudioDxe driver arguments.
Not enabled by default, since restoring the flag can prevent sound from working in macOS on
some other systems. \medskip
\end{itemize}
\subsection{Properties}\label{uefiprops}

Binary file not shown.

View File

@ -1,7 +1,7 @@
\documentclass[]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL PreviousConfiguration.tex Mon Feb 7 23:02:40 2022
%DIF ADD ../Configuration.tex Mon Feb 7 23:05:00 2022
%DIF DEL PreviousConfiguration.tex Wed Feb 9 09:37:10 2022
%DIF ADD ../Configuration.tex Wed Feb 9 23:42:58 2022
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
@ -6597,7 +6597,11 @@ with the boot menu.
High Definition Audio support driver in UEFI firmware for most Intel and some other analog audio controllers.
\subsubsection{Configuration}
\DIFaddbegin \emph{\DIFadd{Note}}\DIFadd{: AudioDxe is a staging driver, refer to }\href{https://github.com/acidanthera/bugtracker/issues/740}{\DIFadd{acidanthera/bugtracker\#740}}
\DIFadd{for known issues.
}
\DIFaddend \subsubsection{Configuration}
Most UEFI audio configuration is handled via the \hyperref[uefiaudioprops]{\texttt{UEFI Audio Properties}}
section, but if required the following additonal configuration options (which are needed to produce sound
@ -6650,10 +6654,22 @@ on most Apple hardware, and possibly some others) may be specified in \texttt{UE
Values for driver parameters can be specified in hexadecimal beginning with \texttt{0x} or
in decimal, e.g. \texttt{-{}-gpio-pins=0x12} or \texttt{-{}-gpio-pins=18}.
\end{itemize}
\DIFdelbegin %DIFDELCMD < \end{itemize}
%DIFDELCMD < %%%
\DIFdelend
\emph{Note}: AudioDxe is a staging driver, refer to \href{https://github.com/acidanthera/bugtracker/issues/740}{acidanthera/bugtracker\#740}
for known issues.
\DIFdelbegin \emph{\DIFdel{Note}}%DIFAUXCMD
\DIFdel{: AudioDxe is a staging driver, refer to }\href{https://github.com/acidanthera/bugtracker/issues/740}{\DIFdel{acidanthera/bugtracker\#740}}
%DIFAUXCMD
\DIFdel{for known issues. }\DIFdelend \DIFaddbegin \item \texttt{\DIFadd{-}{}\DIFadd{-restore-nosnoop}} \DIFadd{- Boolean flag, enabled if present. }\medskip
\DIFadd{AudioDxe clears the Intel HDA No Snoop Enable (NSNPEN) bit. On some systems, this change must
be reversed on exit in order to avoid breaking sound in Windows. If so, this flag should
be added to AudioDxe driver arguments.
Not enabled by default, since restoring the flag can prevent sound from working in macOS on
some other systems. }\medskip
\end{itemize}
\DIFaddend
\subsection{Properties}\label{uefiprops}

Binary file not shown.

View File

@ -722,12 +722,6 @@
## @Prompt Audio codec setup code should produce an error when no valid output bits are specified.
gOpenCorePkgTokenSpaceGuid.PcdAudioCodecErrorOnNoOutputs|TRUE|BOOLEAN|0x00000005
## Indicates if AudioDxe will try to reset the PCI associated with the HDA controller on Exit Boot Services.<BR><BR>
## TRUE - Register event to reset the controller on Exit Boot Services.<BR>
## FALSE - Do not reset the contoller on Exit Boot Services.<BR>
## @Prompt AudioDxe will try to reset the HDA controller on Exit Boot Services.
gOpenCorePkgTokenSpaceGuid.PcdAudioControllerResetPciOnExitBootServices|TRUE|BOOLEAN|0x00000006
## Indicates if AudioDxe will try EFI_OPEN_PROTOCOL_GET_PROTOCOL if EFI_OPEN_PROTOCOL_BY_DRIVER
## fails with access denied.<BR><BR>
## TRUE - Use EFI_OPEN_PROTOCOL_GET_PROTOCOL if EFI_OPEN_PROTOCOL_BY_DRIVER fails.<BR>

View File

@ -32,8 +32,9 @@
#include <Library/OcBootManagementLib.h>
#include <Library/OcFlexArrayLib.h>
UINTN gGpioSetupStageMask = GPIO_SETUP_STAGE_NONE;
UINTN gGpioPinMask = GPIO_PIN_MASK_AUTO;
UINTN gGpioSetupStageMask = GPIO_SETUP_STAGE_NONE;
UINTN gGpioPinMask = GPIO_PIN_MASK_AUTO;
BOOLEAN gRestoreNoSnoop = FALSE;
/**
HdaController Driver Binding.
@ -87,11 +88,13 @@ AudioDxeInit(
Status = OcParseLoadOptions (LoadedImage, &ParsedLoadOptions);
if (!EFI_ERROR (Status)) {
gRestoreNoSnoop = OcHasParsedVar (ParsedLoadOptions, L"--restore-nosnoop", TRUE);
Status = OcParsedVarsGetInt (ParsedLoadOptions, L"--gpio-setup", &gGpioSetupStageMask, TRUE);
if (Status == EFI_NOT_FOUND && OcHasParsedVar (ParsedLoadOptions, L"--gpio-setup", TRUE)) {
gGpioSetupStageMask = GPIO_SETUP_STAGE_ALL;
}
DEBUG ((DEBUG_INFO, "HDA: GPIO setup stages 0x%X\n", gGpioSetupStageMask));
DEBUG ((DEBUG_INFO, "HDA: GPIO setup stages 0x%X, restore NSNPEN %d\n", gGpioSetupStageMask, gRestoreNoSnoop));
if (gGpioSetupStageMask != GPIO_SETUP_STAGE_NONE) {
OcParsedVarsGetInt (ParsedLoadOptions, L"--gpio-pins", &gGpioPinMask, TRUE);

View File

@ -87,7 +87,8 @@ extern EFI_AUDIO_DECODE_PROTOCOL gEfiAudioDecodeProtocol;
//
// Stored parsed config.
//
extern UINTN gGpioSetupStageMask;
extern UINTN gGpioPinMask;
extern UINTN gGpioSetupStageMask;
extern UINTN gGpioPinMask;
extern BOOLEAN gRestoreNoSnoop;
#endif // EFI_AUDIODXE_H

View File

@ -64,7 +64,6 @@
[FeaturePcd]
gOpenCorePkgTokenSpaceGuid.PcdAudioCodecErrorOnNoOutputs ## CONSUMES
gOpenCorePkgTokenSpaceGuid.PcdAudioControllerResetPciOnExitBootServices ## CONSUMES
gOpenCorePkgTokenSpaceGuid.PcdAudioControllerTryProtocolGetMode ## CONSUMES
gOpenCorePkgTokenSpaceGuid.PcdAudioControllerUsePinCapsForOutputs ## CONSUMES

View File

@ -362,9 +362,10 @@ HdaControllerExitBootServicesHandler (
//
// Restore No Snoop Enable bit at Exit Boot Services to avoid breaking in-OS sound in Windows with some firmware.
// Note: Windows sound is fine even without this on many systems where AudioDxe disables No Snoop.
// Windows sound is fine even without this on many systems where AudioDxe disables No Snoop, and doing this
// (even though it should only be restoring the previous value) breaks macOS sound on some systems.
// REF: https://github.com/acidanthera/bugtracker/issues/1909
// REF: https://github.com/acidanthera/bugtracker/issues/740#issuecomment-998762564
// REF: https://github.com/acidanthera/bugtracker/issues/1945
// REF: Intel I/O Controller Hub 9 (ICH9) Family Datasheet (DEVC - Device Conrol Register/NSNPEN)
//
HdaControllerRestoreNoSnoopEn (HdaControllerDev);
@ -415,8 +416,10 @@ HdaControllerReset (
return EFI_SUCCESS;
}
if (PcdGetBool (PcdAudioControllerResetPciOnExitBootServices)
&& HdaControllerDev->ExitBootServicesEvent == NULL) {
//
// Currently restore NSNPEN is the only functionality needed at ExitBootServices.
//
if (gRestoreNoSnoop && HdaControllerDev->ExitBootServicesEvent == NULL) {
Status = gBS->CreateEvent (
EVT_SIGNAL_EXIT_BOOT_SERVICES,
TPL_CALLBACK,