Skip to content

Commit

Permalink
OpenCoreUefiInOut: Fixed ReconnectOnResChange reconnecting even wit…
Browse files Browse the repository at this point in the history
…hout res change
  • Loading branch information
vit9696 committed May 10, 2020
1 parent 7dac5f8 commit 6caff2a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ OpenCore Changelog
- Enforced the use of builtin picker when external fails
- Fixed warnings for empty NVRAM variables (e.g. rtc-blacklist)
- Added `ApplePanic` to store panic logs on ESP root
- Fixed `ReconnectOnResChange` reconnecting even without res change

#### v0.5.8
- Fixed invalid CPU object reference in SSDT-PLUG
Expand Down
27 changes: 15 additions & 12 deletions Library/OcConsoleLib/OcConsoleLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ OcSetConsoleResolutionForProtocol (

if (ModeNumber == GraphicsOutput->Mode->Mode) {
DEBUG ((DEBUG_INFO, "OCC: Current mode matches desired mode %u\n", (UINT32) ModeNumber));
return EFI_SUCCESS;
return EFI_ALREADY_STARTED;
}

//
Expand Down Expand Up @@ -275,23 +275,26 @@ OcSetConsoleResolution (
IN UINT32 Bpp OPTIONAL
)
{
EFI_STATUS Status;
EFI_STATUS Result;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;

#ifdef OC_CONSOLE_CHANGE_ALL_RESOLUTIONS
EFI_STATUS Status;
UINTN HandleCount;
EFI_HANDLE *HandleBuffer;
UINTN Index;

Status = gBS->LocateHandleBuffer (
Result = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiGraphicsOutputProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);

if (!EFI_ERROR (Status)) {
if (!EFI_ERROR (Result)) {
Result = EFI_NOT_FOUND;

DEBUG ((DEBUG_INFO, "OCC: Found %u handles with GOP\n", (UINT32) HandleCount));

for (Index = 0; Index < HandleCount; ++Index) {
Expand All @@ -308,29 +311,29 @@ OcSetConsoleResolution (
continue;
}

Status = OcSetConsoleResolutionForProtocol (GraphicsOutput, Width, Height, Bpp);
Result = OcSetConsoleResolutionForProtocol (GraphicsOutput, Width, Height, Bpp);
}

FreePool (HandleBuffer);
} else {
DEBUG ((DEBUG_INFO, "OCC: Failed to find handles with GOP\n"));
DEBUG ((DEBUG_INFO, "OCC: Failed to find handles with GOP - %r\n", Result));
}
#else
Status = gBS->HandleProtocol (
Result = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID **) &GraphicsOutput
);

if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "OCC: Missing GOP on ConOut - %r\n", Status));
return Status;
if (EFI_ERROR (Result)) {
DEBUG ((DEBUG_WARN, "OCC: Missing GOP on ConOut - %r\n", Result));
return Result;
}

Status = OcSetConsoleResolutionForProtocol (GraphicsOutput, Width, Height, Bpp);
Result = OcSetConsoleResolutionForProtocol (GraphicsOutput, Width, Height, Bpp);
#endif

return Status;
return Result;
}

EFI_STATUS
Expand Down
6 changes: 4 additions & 2 deletions Platform/OpenCore/OpenCoreUefiInOut.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ OcLoadUefiOutputSupport (
Bpp
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_WARN : DEBUG_INFO,
EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED ? DEBUG_WARN : DEBUG_INFO,
"OC: Changed resolution to %ux%u@%u (max: %d) from %a - %r\n",
Width,
Height,
Expand All @@ -236,6 +236,8 @@ OcLoadUefiOutputSupport (
OC_BLOB_GET (&Config->Uefi.Output.Resolution),
Status
));
} else {
Status = EFI_UNSUPPORTED;
}

if (Config->Uefi.Output.DirectGopRendering) {
Expand All @@ -255,7 +257,7 @@ OcLoadUefiOutputSupport (
}
}

if (Config->Uefi.Output.ReconnectOnResChange) {
if (Config->Uefi.Output.ReconnectOnResChange && !EFI_ERROR (Status)) {
OcReconnectConsole ();
}

Expand Down

0 comments on commit 6caff2a

Please sign in to comment.