Skip to content

Commit 0f5da72

Browse files
committed
reset HDA after use
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
1 parent 98b3d37 commit 0f5da72

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

rEFIt_UEFI/Platform/Settings.cpp

+22-7
Original file line numberDiff line numberDiff line change
@@ -7068,6 +7068,7 @@ GetDevices ()
70687068
}
70697069
if (gSettings.ResetHDA) {
70707070
//Slice method from VoodooHDA
7071+
//PCI_HDA_TCSEL_OFFSET = 0x44
70717072
UINT8 Value = 0;
70727073
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x44, 1, &Value);
70737074

@@ -7816,22 +7817,36 @@ SetDevices (LOADER_ENTRY *Entry)
78167817
}
78177818

78187819
// HDA
7819-
else if (gSettings.HDAInjection &&
7820-
(Pci.Hdr.ClassCode[2] == PCI_CLASS_MEDIA) &&
7820+
else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_MEDIA) &&
78217821
((Pci.Hdr.ClassCode[1] == PCI_CLASS_MEDIA_HDA) ||
78227822
(Pci.Hdr.ClassCode[1] == PCI_CLASS_MEDIA_AUDIO))) {
78237823
// HDMI injection inside
7824-
TmpDirty = setup_hda_devprop (PciIo, &PCIdevice, Entry->OSVersion);
7825-
StringDirty |= TmpDirty;
7826-
}
7824+
if (gSettings.HDAInjection ) {
7825+
TmpDirty = setup_hda_devprop (PciIo, &PCIdevice, Entry->OSVersion);
7826+
StringDirty |= TmpDirty;
7827+
}
7828+
if (gSettings.ResetHDA) {
7829+
7830+
//PCI_HDA_TCSEL_OFFSET = 0x44
7831+
UINT8 Value = 0;
7832+
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x44, 1, &Value);
7833+
7834+
if (EFI_ERROR(Status)) {
7835+
continue;
7836+
}
7837+
7838+
Value &= 0xf8;
7839+
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x44, 1, &Value);
7840+
}
7841+
}
78277842

78287843
//LPC
78297844
else if ((Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) &&
78307845
(Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA))
78317846
{
78327847
if (gSettings.LpcTune) {
78337848
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, GEN_PMCON_1, 1, &PmCon);
7834-
MsgLog ("Initial PmCon value=%hX\n", PmCon);
7849+
MsgLog ("Initial PmCon value=%hX\n", PmCon);
78357850

78367851
if (gSettings.EnableC6) {
78377852
PmCon |= 1 << 11;
@@ -7868,7 +7883,7 @@ SetDevices (LOADER_ENTRY *Entry)
78687883
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, GEN_PMCON_1, 1, &PmCon);
78697884

78707885
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16,GEN_PMCON_1, 1, &PmCon);
7871-
MsgLog ("Set PmCon value=%hX\n", PmCon);
7886+
MsgLog ("Set PmCon value=%hX\n", PmCon);
78727887

78737888
}
78747889
Rcba = 0;

rEFIt_UEFI/refit/menu.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1168,29 +1168,29 @@ VOID ApplyInputs(VOID)
11681168
EFI_DEVICE_PATH_PROTOCOL* DevicePath = NULL;
11691169
UINT8 TmpIndex;
11701170
if (OldChosenAudio > AudioNum) {
1171-
DBG("crasy OldChosenAudio = %lld\n", OldChosenAudio);
1171+
// DBG("crasy OldChosenAudio = %lld\n", OldChosenAudio);
11721172
OldChosenAudio = 0;
11731173
}
11741174
TmpIndex = OldChosenAudio & 0x2F;
1175-
DBG("Chosen output %u:%ls_%s\n", TmpIndex, AudioList[TmpIndex].Name,
1176-
AudioOutputNames[AudioList[TmpIndex].Device]);
1175+
// DBG("Chosen output %u:%ls_%s\n", TmpIndex, AudioList[TmpIndex].Name,
1176+
// AudioOutputNames[AudioList[TmpIndex].Device]);
11771177

11781178
DevicePath = DevicePathFromHandle(AudioList[TmpIndex].Handle);
1179-
DBG("choosen sound devicepath=%ls\n", DevicePathToStr(DevicePath));
1179+
// DBG("choosen sound devicepath=%ls\n", DevicePathToStr(DevicePath));
11801180
if (DevicePath != NULL) {
11811181
SetNvramVariable(L"Clover.SoundDevice", &gEfiAppleBootGuid,
11821182
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
11831183
GetDevicePathSize(DevicePath), (UINT8 *)DevicePath);
11841184
SetNvramVariable(L"Clover.SoundIndex", &gEfiAppleBootGuid,
11851185
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
11861186
1, (UINT8 *)&TmpIndex);
1187-
DBG(" sound written to nvram variables\n");
1187+
// DBG(" sound written to nvram variables\n");
11881188
}
11891189
}
11901190
i++; //120
11911191
if (InputItems[i].Valid) {
11921192
DefaultAudioVolume = (UINT8)StrDecimalToUintn(InputItems[i].SValue);
1193-
DBG(" set output volume to %d\n", DefaultAudioVolume);
1193+
// DBG(" set output volume to %d\n", DefaultAudioVolume);
11941194
if (DefaultAudioVolume > 100) {
11951195
// correct wrong input
11961196
DefaultAudioVolume = 90;

0 commit comments

Comments
 (0)