From 525b6a6ada693cf3fe0bd4de3fe38ad393bf463a Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sun, 26 Apr 2020 06:28:30 +0300 Subject: [PATCH] OcConsoleLib: Fixed handling 24-bit screen resolutions --- Changelog.md | 1 + Library/OcConsoleLib/OcConsoleLib.c | 12 +++++++++--- Library/OcConsoleLib/TextOutputBuiltin.c | 23 +++++++++++++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index c258989e..3659cec5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -20,6 +20,7 @@ OpenCore Changelog - Added experimental `BootProtect` `Security` option - Fixed kext injection in 10.8 installer - Added timeout support to OpenCanopy user interface +- Fixed handling 24-bit screen resolutions #### v0.5.7 - Added TimeMachine detection to picker diff --git a/Library/OcConsoleLib/OcConsoleLib.c b/Library/OcConsoleLib/OcConsoleLib.c index 3a927258..74c3e982 100644 --- a/Library/OcConsoleLib/OcConsoleLib.c +++ b/Library/OcConsoleLib/OcConsoleLib.c @@ -89,10 +89,16 @@ OcSetConsoleResolutionForProtocol ( // // Custom resolution is requested. // - if (Info->HorizontalResolution == Width && Info->VerticalResolution == Height + if (Info->HorizontalResolution == Width + && Info->VerticalResolution == Height + && (Bpp == 0 || Bpp == 24 || Bpp == 32) && (Info->PixelFormat == PixelRedGreenBlueReserved8BitPerColor - || Info->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) - && (Bpp == 0 || Bpp == 24 || Bpp == 32)) { + || Info->PixelFormat == PixelBlueGreenRedReserved8BitPerColor + || (Info->PixelFormat == PixelBitMask + && (Info->PixelInformation.RedMask == 0xFF000000U + || Info->PixelInformation.RedMask == 0xFF0000U + || Info->PixelInformation.RedMask == 0xFF00U + || Info->PixelInformation.RedMask == 0xFFU)))) { ModeNumber = ModeIndex; FreePool (Info); break; diff --git a/Library/OcConsoleLib/TextOutputBuiltin.c b/Library/OcConsoleLib/TextOutputBuiltin.c index 87188566..afea88a7 100644 --- a/Library/OcConsoleLib/TextOutputBuiltin.c +++ b/Library/OcConsoleLib/TextOutputBuiltin.c @@ -363,12 +363,27 @@ RenderResync ( Info = mGraphicsOutput->Mode->Info; if (Info->HorizontalResolution < TGT_CHAR_WIDTH * 3 - || Info->VerticalResolution < TGT_CHAR_HEIGHT * 3 - || (Info->PixelFormat != PixelRedGreenBlueReserved8BitPerColor - && Info->PixelFormat != PixelBlueGreenRedReserved8BitPerColor)) { + || Info->VerticalResolution < TGT_CHAR_HEIGHT * 3) { return EFI_DEVICE_ERROR; } + if (Info->PixelFormat != PixelRedGreenBlueReserved8BitPerColor + && Info->PixelFormat != PixelBlueGreenRedReserved8BitPerColor) { + // + // DuetPkg may report bit mask image output. + // + if (Info->PixelFormat != PixelBitMask) { + return EFI_DEVICE_ERROR; + } + + if (Info->PixelInformation.RedMask != 0xFF000000U + && Info->PixelInformation.RedMask != 0xFF0000U + && Info->PixelInformation.RedMask != 0xFF00U + && Info->PixelInformation.RedMask != 0xFFU) { + return EFI_DEVICE_ERROR; + } + } + if (mCharacterBuffer != NULL) { FreePool (mCharacterBuffer); } @@ -933,7 +948,7 @@ OcUseBuiltinTextOutput ( Status = AsciiTextReset (&mAsciiTextOutputProtocol, TRUE); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "OCC: Cannot setup ASCII output\n")); + DEBUG ((DEBUG_INFO, "OCC: Cannot setup ASCII output - %r\n", Status)); return; }