The GraphicsConsoleDxe driver (in MdeModulePkg/Universal/Console)
determines the preferred video resolution from the dynamic PCDs
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution

Before BDS connects the console(s), let's retrieve the preferred
resolution from the OVMF platform configuration, and set the above PCDs
accordingly.

Setting the GOP resolution during boot is useful when the guest OS (for
lack of a dedicated display driver) continues to work with the original
GOP resolution and framebuffer.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---

Notes:
    v2:
    - retrieve preferred resolution with PlatformConfigLib rather than direct
      variable access [Jordan]
    - setting the preferred resolution with user tools (UEFI shell, guest OS
      tools) is no longer recommended

 OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf |  3 +++
 OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c      | 32 +++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf 
b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
index a2b72ba..d4aba98 100644
--- a/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
+++ b/OvmfPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
@@ -52,12 +52,15 @@
   NvVarsFileLib
   QemuFwCfgLib
   LoadLinuxLib
+  PlatformConfigLib
 
 [Pcd]
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution
 
 [Pcd.IA32, Pcd.X64]
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock
diff --git a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c 
b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
index ab9c93e..38f8625 100644
--- a/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c
@@ -14,6 +14,7 @@
 
 #include "BdsPlatform.h"
 #include "QemuBootOrder.h"
+#include <Library/PlatformConfigLib.h>
 
 
 //
@@ -1027,6 +1028,36 @@ Returns:
 }
 
 
+/**
+  Read the preferred resolution from the platform configuration, and pass it to
+  GraphicsConsoleDxe via dynamic PCDs.
+
+  @retval EFI_SUCCESS            PCDs have been set.
+  @return                        Status codes from PlatformConfigLoad().
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+SetPreferredResolution (
+  VOID
+  )
+{
+  EFI_STATUS      Status;
+  PLATFORM_CONFIG PlatformConfig;
+  UINT64          OptionalElements;
+
+  Status = PlatformConfigLoad (&PlatformConfig, &OptionalElements);
+  if (EFI_ERROR (Status)) {
+    DEBUG (((Status == EFI_NOT_FOUND) ? EFI_D_VERBOSE : EFI_D_ERROR,
+      "%a: failed to load platform config: %r\n", __FUNCTION__, Status));
+    return Status;
+  }
+  PcdSet32 (PcdVideoHorizontalResolution, PlatformConfig.HorizontalResolution);
+  PcdSet32 (PcdVideoVerticalResolution, PlatformConfig.VerticalResolution);
+  return EFI_SUCCESS;
+}
+
+
 VOID
 EFIAPI
 PlatformBdsPolicyBehavior (
@@ -1108,6 +1139,7 @@ Returns:
   //
   // Connect platform console
   //
+  SetPreferredResolution ();
   Status = PlatformBdsConnectConsole (gPlatformConsole);
   if (EFI_ERROR (Status)) {
     //
-- 
1.8.3.1



------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to