From fa2e072d35ae5d9ea39d08deb9560e2df11c750e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20H=C3=A4user?= <8659494+mhaeuser@users.noreply.github.com> Date: Sat, 1 May 2021 17:18:16 +0200 Subject: [PATCH] OpenCanopy: Require minimum resolution --- Platform/OpenCanopy/GuiIo.h | 2 +- Platform/OpenCanopy/OpenCanopy.c | 2 +- Platform/OpenCanopy/Output/OutputStGop.c | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Platform/OpenCanopy/GuiIo.h b/Platform/OpenCanopy/GuiIo.h index 0233c645..e00ae554 100644 --- a/Platform/OpenCanopy/GuiIo.h +++ b/Platform/OpenCanopy/GuiIo.h @@ -18,7 +18,7 @@ typedef struct GUI_KEY_CONTEXT_ GUI_KEY_CONTEXT; GUI_OUTPUT_CONTEXT * GuiOutputConstruct ( - VOID + IN UINT32 Scale ); EFI_STATUS diff --git a/Platform/OpenCanopy/OpenCanopy.c b/Platform/OpenCanopy/OpenCanopy.c index 2abc20ec..af693cda 100644 --- a/Platform/OpenCanopy/OpenCanopy.c +++ b/Platform/OpenCanopy/OpenCanopy.c @@ -811,7 +811,7 @@ GuiLibConstruct ( INT64 CursorX; INT64 CursorY; - mOutputContext = GuiOutputConstruct (); + mOutputContext = GuiOutputConstruct (GuiContext->Scale); if (mOutputContext == NULL) { DEBUG ((DEBUG_WARN, "OCUI: Failed to initialise output\n")); return EFI_UNSUPPORTED; diff --git a/Platform/OpenCanopy/Output/OutputStGop.c b/Platform/OpenCanopy/Output/OutputStGop.c index 48ec9a86..12e5d323 100644 --- a/Platform/OpenCanopy/Output/OutputStGop.c +++ b/Platform/OpenCanopy/Output/OutputStGop.c @@ -15,6 +15,9 @@ #include "../GuiIo.h" +#define MIN_RESOLUTION_HORIZONTAL 640U +#define MIN_RESOLUTION_VERTICAL 480U + struct GUI_OUTPUT_CONTEXT_ { EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; }; @@ -45,7 +48,7 @@ InternalGuiOutputLocateGop ( GUI_OUTPUT_CONTEXT * GuiOutputConstruct ( - VOID + IN UINT32 Scale ) { // TODO: alloc on the fly? @@ -58,6 +61,19 @@ GuiOutputConstruct ( return NULL; } + if (Gop->Mode->Info->HorizontalResolution < MIN_RESOLUTION_HORIZONTAL * Scale + || Gop->Mode->Info->VerticalResolution < MIN_RESOLUTION_VERTICAL * Scale) { + DEBUG (( + DEBUG_INFO, + "OCUI: Expected at least %dx%d for resolution, actual %dx%d\n", + MIN_RESOLUTION_HORIZONTAL * Scale, + MIN_RESOLUTION_VERTICAL * Scale, + Context.Gop->Mode->Info->HorizontalResolution, + Context.Gop->Mode->Info->VerticalResolution + )); + return NULL; + } + Context.Gop = Gop; return &Context; }