unload audiodxe before system start

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2020-06-18 19:08:00 +03:00
parent 9be63c456d
commit 109d1f581c
9 changed files with 1249 additions and 1228 deletions

View File

@ -52,7 +52,8 @@ EFI_STATUS
EFIAPI EFIAPI
AudioDxeInit( AudioDxeInit(
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable) { IN EFI_SYSTEM_TABLE *SystemTable)
{
DEBUG((DEBUG_INFO, "Starting AudioDxe...\n")); DEBUG((DEBUG_INFO, "Starting AudioDxe...\n"));
// Create variables. // Create variables.

View File

@ -550,7 +550,8 @@ HdaCodecFindUpstreamOutput(
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
HdaCodecParsePorts( HdaCodecParsePorts(
IN HDA_CODEC_DEV *HdaCodecDev) { IN HDA_CODEC_DEV *HdaCodecDev)
{
//DEBUG((DEBUG_INFO, "HdaCodecParsePorts(): start\n")); //DEBUG((DEBUG_INFO, "HdaCodecParsePorts(): start\n"));
// Create variables. // Create variables.
@ -650,7 +651,8 @@ HdaCodecParsePorts(
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
HdaCodecInstallProtocols( HdaCodecInstallProtocols(
IN HDA_CODEC_DEV *HdaCodecDev) { IN HDA_CODEC_DEV *HdaCodecDev)
{
DEBUG((DEBUG_INFO, "HdaCodecInstallProtocols(): start\n")); DEBUG((DEBUG_INFO, "HdaCodecInstallProtocols(): start\n"));
// Create variables. // Create variables.
@ -1161,3 +1163,4 @@ HdaCodecDriverBindingStop(
gBS->CloseProtocol(ControllerHandle, &gEfiHdaIoProtocolGuid, This->DriverBindingHandle, ControllerHandle); gBS->CloseProtocol(ControllerHandle, &gEfiHdaIoProtocolGuid, This->DriverBindingHandle, ControllerHandle);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -589,7 +589,8 @@ HdaCodecAudioIoStartPlaybackAsync(
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
HdaCodecAudioIoStopPlayback( HdaCodecAudioIoStopPlayback(
IN EFI_AUDIO_IO_PROTOCOL *This) { IN EFI_AUDIO_IO_PROTOCOL *This)
{
DEBUG((DEBUG_INFO, "HdaCodecAudioIoStopPlayback(): start\n")); DEBUG((DEBUG_INFO, "HdaCodecAudioIoStopPlayback(): start\n"));
// Create variables. // Create variables.

View File

@ -352,8 +352,9 @@ HdaControllerScanCodecs(
// Clear STATESTS register. // Clear STATESTS register.
HdaStatests = HDA_REG_STATESTS_CLEAR; HdaStatests = HDA_REG_STATESTS_CLEAR;
Status = PciIo->Mem.Write(PciIo, EfiPciIoWidthUint16, PCI_HDA_BAR, HDA_REG_STATESTS, 1, &HdaStatests); Status = PciIo->Mem.Write(PciIo, EfiPciIoWidthUint16, PCI_HDA_BAR, HDA_REG_STATESTS, 1, &HdaStatests);
if (EFI_ERROR(Status)) if (EFI_ERROR(Status)) {
return Status; return Status;
}
// Install protocols on each codec. // Install protocols on each codec.

View File

@ -37,7 +37,7 @@ HdaControllerInitCorb(
EFI_PCI_IO_PROTOCOL *PciIo = HdaDev->PciIo; EFI_PCI_IO_PROTOCOL *PciIo = HdaDev->PciIo;
// HDA register values. // HDA register values.
UINT8 HdaCorbSize; UINT8 HdaCorbSize = 0;
UINT32 HdaLowerCorbBaseAddr; UINT32 HdaLowerCorbBaseAddr;
UINT32 HdaUpperCorbBaseAddr; UINT32 HdaUpperCorbBaseAddr;
UINT16 HdaCorbWp; UINT16 HdaCorbWp;
@ -197,7 +197,7 @@ HdaControllerSetCorb(
// Create variables. // Create variables.
EFI_STATUS Status; EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo = HdaDev->PciIo; EFI_PCI_IO_PROTOCOL *PciIo = HdaDev->PciIo;
UINT8 HdaCorbCtl; UINT8 HdaCorbCtl = 0;
UINT64 Tmp; UINT64 Tmp;
// Get current value of CORBCTL. // Get current value of CORBCTL.

View File

@ -325,11 +325,12 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
UINT16 DensityThreshold = 0x96; UINT16 DensityThreshold = 0x96;
UINT64 ConfigStatus = 0; UINT64 ConfigStatus = 0;
Color = gSettings.DefaultBackgroundColor; Color = gSettings.DefaultBackgroundColor;
AddNvramVariable(L"DefaultBackgroundColor", &gEfiAppleNvramGuid, Attributes, 4, &Color); DBG("set DefaultBackgroundColor=0x%x\n", Color);
SetNvramVariable(L"DefaultBackgroundColor", &gEfiAppleNvramGuid, Attributes, 4, &Color);
// add some UI variables // add some UI variables
AddNvramVariable(L"ActualDensity", &gEfiAppleBootGuid, Attributes, 2, &ActualDensity); SetNvramVariable(L"ActualDensity", &gEfiAppleBootGuid, Attributes, 2, &ActualDensity);
AddNvramVariable(L"DensityThreshold", &gEfiAppleBootGuid, Attributes, 2, &DensityThreshold); SetNvramVariable(L"DensityThreshold", &gEfiAppleBootGuid, Attributes, 2, &DensityThreshold);
AddNvramVariable(L"gfx-saved-config-restore-status", &gEfiAppleNvramGuid, Attributes, 8, &ConfigStatus); SetNvramVariable(L"gfx-saved-config-restore-status", &gEfiAppleNvramGuid, Attributes, 8, &ConfigStatus);
} }
if (gSettings.UIScale == 0x80000000) { if (gSettings.UIScale == 0x80000000) {

View File

@ -393,8 +393,12 @@ EFI_STATUS CheckSyncSound(BOOLEAN Stop)
Status = HdaIo->GetStream(HdaIo, EfiHdaIoTypeOutput, &StreamRunning); Status = HdaIo->GetStream(HdaIo, EfiHdaIoTypeOutput, &StreamRunning);
if ((EFI_ERROR(Status) || Stop) && StreamRunning) { if ((EFI_ERROR(Status) || Stop) && StreamRunning) {
DBG("stream stopping\n"); DBG("stream stopping & controller reset\n");
HdaIo->StopStream(HdaIo, EfiHdaIoTypeOutput); HdaIo->StopStream(HdaIo, EfiHdaIoTypeOutput);
// HDA_IO_PRIVATE_DATA *HdaIoPrivateData = HDA_IO_PRIVATE_DATA_FROM_THIS(HdaIo);
// HDA_CONTROLLER_DEV *HdaControllerDev = HdaIoPrivateData->HdaControllerDev;
// EFI_PCI_IO_PROTOCOL *PciIo = HdaControllerDev->PciIo;
// HdaControllerCleanup(HdaControllerDev);
} }
if (!StreamRunning) { if (!StreamRunning) {

View File

@ -108,6 +108,8 @@ EFI_HANDLE ConsoleInHandle;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* SimpleTextEx; EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL* SimpleTextEx;
EFI_KEY_DATA KeyData; EFI_KEY_DATA KeyData;
EFI_HANDLE AudioDriverHandle;
CONST CHAR8* AudioOutputNames[] = { CONST CHAR8* AudioOutputNames[] = {
"LineOut", "LineOut",
"Speaker", "Speaker",
@ -831,8 +833,13 @@ VOID LOADER_ENTRY::StartLoader()
} }
if (AudioIo) { if (AudioIo) {
// AudioIo->StopPlayback(AudioIo); AudioIo->StopPlayback(AudioIo);
CheckSyncSound(true); // CheckSyncSound(true);
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding = NULL;
Status = gBS->HandleProtocol(AudioDriverHandle, &gEfiDriverBindingProtocolGuid, (VOID **)&DriverBinding);
if (DriverBinding) {
DriverBinding->Stop(DriverBinding, AudioDriverHandle, 0, NULL);
}
} }
// DBG("Set FakeCPUID: 0x%X\n", gSettings.FakeCPUID); // DBG("Set FakeCPUID: 0x%X\n", gSettings.FakeCPUID);
@ -1153,6 +1160,9 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
continue; continue;
} }
if (StrStr(FileName, L"AudioDxe") != NULL) {
AudioDriverHandle = DriverHandle;
}
if (StrStr(FileName, L"EmuVariable") != NULL) { if (StrStr(FileName, L"EmuVariable") != NULL) {
gDriversFlags.EmuVariableLoaded = TRUE; gDriversFlags.EmuVariableLoaded = TRUE;
} else if (StrStr(FileName, L"Video") != NULL) { } else if (StrStr(FileName, L"Video") != NULL) {