From 0f5da727e0ac2dfc4de53c66cd4cb980a4f01a32 Mon Sep 17 00:00:00 2001 From: SergeySlice Date: Fri, 5 Jun 2020 15:15:31 +0300 Subject: [PATCH] reset HDA after use Signed-off-by: SergeySlice --- rEFIt_UEFI/Platform/Settings.cpp | 29 ++++++++++++++++++++++------- rEFIt_UEFI/refit/menu.cpp | 12 ++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 6379dfe11..e6858c91e 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -7068,6 +7068,7 @@ GetDevices () } if (gSettings.ResetHDA) { //Slice method from VoodooHDA + //PCI_HDA_TCSEL_OFFSET = 0x44 UINT8 Value = 0; Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x44, 1, &Value); @@ -7816,14 +7817,28 @@ SetDevices (LOADER_ENTRY *Entry) } // HDA - else if (gSettings.HDAInjection && - (Pci.Hdr.ClassCode[2] == PCI_CLASS_MEDIA) && + else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_MEDIA) && ((Pci.Hdr.ClassCode[1] == PCI_CLASS_MEDIA_HDA) || (Pci.Hdr.ClassCode[1] == PCI_CLASS_MEDIA_AUDIO))) { // HDMI injection inside - TmpDirty = setup_hda_devprop (PciIo, &PCIdevice, Entry->OSVersion); - StringDirty |= TmpDirty; - } + if (gSettings.HDAInjection ) { + TmpDirty = setup_hda_devprop (PciIo, &PCIdevice, Entry->OSVersion); + StringDirty |= TmpDirty; + } + if (gSettings.ResetHDA) { + + //PCI_HDA_TCSEL_OFFSET = 0x44 + UINT8 Value = 0; + Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x44, 1, &Value); + + if (EFI_ERROR(Status)) { + continue; + } + + Value &= 0xf8; + PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x44, 1, &Value); + } + } //LPC else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) && @@ -7831,7 +7846,7 @@ SetDevices (LOADER_ENTRY *Entry) { if (gSettings.LpcTune) { Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, GEN_PMCON_1, 1, &PmCon); - MsgLog ("Initial PmCon value=%hX\n", PmCon); + MsgLog ("Initial PmCon value=%hX\n", PmCon); if (gSettings.EnableC6) { PmCon |= 1 << 11; @@ -7868,7 +7883,7 @@ SetDevices (LOADER_ENTRY *Entry) PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, GEN_PMCON_1, 1, &PmCon); Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16,GEN_PMCON_1, 1, &PmCon); - MsgLog ("Set PmCon value=%hX\n", PmCon); + MsgLog ("Set PmCon value=%hX\n", PmCon); } Rcba = 0; diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index 39b036726..deae6faae 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -1168,15 +1168,15 @@ VOID ApplyInputs(VOID) EFI_DEVICE_PATH_PROTOCOL* DevicePath = NULL; UINT8 TmpIndex; if (OldChosenAudio > AudioNum) { - DBG("crasy OldChosenAudio = %lld\n", OldChosenAudio); +// DBG("crasy OldChosenAudio = %lld\n", OldChosenAudio); OldChosenAudio = 0; } TmpIndex = OldChosenAudio & 0x2F; - DBG("Chosen output %u:%ls_%s\n", TmpIndex, AudioList[TmpIndex].Name, - AudioOutputNames[AudioList[TmpIndex].Device]); +// DBG("Chosen output %u:%ls_%s\n", TmpIndex, AudioList[TmpIndex].Name, +// AudioOutputNames[AudioList[TmpIndex].Device]); DevicePath = DevicePathFromHandle(AudioList[TmpIndex].Handle); - DBG("choosen sound devicepath=%ls\n", DevicePathToStr(DevicePath)); +// DBG("choosen sound devicepath=%ls\n", DevicePathToStr(DevicePath)); if (DevicePath != NULL) { SetNvramVariable(L"Clover.SoundDevice", &gEfiAppleBootGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -1184,13 +1184,13 @@ VOID ApplyInputs(VOID) SetNvramVariable(L"Clover.SoundIndex", &gEfiAppleBootGuid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, 1, (UINT8 *)&TmpIndex); - DBG(" sound written to nvram variables\n"); +// DBG(" sound written to nvram variables\n"); } } i++; //120 if (InputItems[i].Valid) { DefaultAudioVolume = (UINT8)StrDecimalToUintn(InputItems[i].SValue); - DBG(" set output volume to %d\n", DefaultAudioVolume); +// DBG(" set output volume to %d\n", DefaultAudioVolume); if (DefaultAudioVolume > 100) { // correct wrong input DefaultAudioVolume = 90;