Last active
October 7, 2017 00:06
-
-
Save encounter/de739a2b6d579342b4888ae711027441 to your computer and use it in GitHub Desktop.
systemd-boot patch to set max UEFI resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c | |
index 1e990b382..c7471aaac 100644 | |
--- a/src/boot/efi/boot.c | |
+++ b/src/boot/efi/boot.c | |
@@ -492,6 +492,7 @@ static BOOLEAN menu_run(Config *config, ConfigEntry **chosen_entry, CHAR16 *load | |
BOOLEAN wait = FALSE; | |
graphics_mode(FALSE); | |
+ set_max_resolution(); | |
uefi_call_wrapper(ST->ConIn->Reset, 2, ST->ConIn, FALSE); | |
uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE); | |
uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK); | |
diff --git a/src/boot/efi/graphics.c b/src/boot/efi/graphics.c | |
index 4854baf87..c6540a2af 100644 | |
--- a/src/boot/efi/graphics.c | |
+++ b/src/boot/efi/graphics.c | |
@@ -86,3 +86,38 @@ EFI_STATUS graphics_mode(BOOLEAN on) { | |
return err; | |
} | |
+ | |
+EFI_STATUS set_max_resolution() { | |
+ EFI_GUID GraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; | |
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = NULL; | |
+ EFI_STATUS err; | |
+ | |
+ UINTN i; | |
+ UINTN width, height; | |
+ UINTN best_mode = 0, best_width = 0, best_height = 0; | |
+ UINTN graphics_info_size; | |
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *graphics_info; | |
+ | |
+ err = LibLocateProtocol(&GraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput); | |
+ if (EFI_ERROR(err)) | |
+ return err; | |
+ | |
+ for (i = 0; i < GraphicsOutput->Mode->MaxMode; i++) { | |
+ err = uefi_call_wrapper(GraphicsOutput->QueryMode, 4, GraphicsOutput, i, &graphics_info_size, &graphics_info); | |
+ if (err == EFI_SUCCESS) { | |
+ width = graphics_info->HorizontalResolution; | |
+ height = graphics_info->VerticalResolution; | |
+ if (width > best_width || (width == best_width && height > best_height)) { | |
+ best_mode = i; | |
+ best_width = width; | |
+ best_height = height; | |
+ } | |
+ } | |
+ } | |
+ | |
+ if (best_mode != GraphicsOutput->Mode->Mode) { | |
+ return uefi_call_wrapper(GraphicsOutput->SetMode, 2, GraphicsOutput, best_mode); | |
+ } | |
+ | |
+ return EFI_SUCCESS; | |
+} | |
diff --git a/src/boot/efi/graphics.h b/src/boot/efi/graphics.h | |
index cf48e647e..ba9c4c6eb 100644 | |
--- a/src/boot/efi/graphics.h | |
+++ b/src/boot/efi/graphics.h | |
@@ -19,4 +19,6 @@ | |
#define __SDBOOT_GRAPHICS_H | |
EFI_STATUS graphics_mode(BOOLEAN on); | |
+ | |
+EFI_STATUS set_max_resolution(); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment