]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/QemuVideoDxe/Gop.c
OvmfPkg/QemuVideoDxe: Frame buffer config size may change in new mode
[mirror_edk2.git] / OvmfPkg / QemuVideoDxe / Gop.c
index 5485ba3c28716c524be53b291e6804492fad62ed..359e9217d3d143fbbe90c6a742cd15b9e74cd73b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Graphics Output Protocol functions for the QEMU video controller.\r
 \r
-  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -189,30 +189,35 @@ Routine Description:
   QemuVideoCompleteModeData (Private, This->Mode);\r
 \r
   //\r
-  // Allocate when using first time.\r
+  // Re-initialize the frame buffer configure when mode changes.\r
   //\r
-  if (Private->FrameBufferBltConfigure == NULL) {\r
-    Status = FrameBufferBltConfigure (\r
-               (VOID*) (UINTN) This->Mode->FrameBufferBase,\r
-               This->Mode->Info,\r
-               Private->FrameBufferBltConfigure,\r
-               &Private->FrameBufferBltConfigureSize\r
-               );\r
-    ASSERT (Status == RETURN_BUFFER_TOO_SMALL);\r
+  Status = FrameBufferBltConfigure (\r
+             (VOID*) (UINTN) This->Mode->FrameBufferBase,\r
+             This->Mode->Info,\r
+             Private->FrameBufferBltConfigure,\r
+             &Private->FrameBufferBltConfigureSize\r
+             );\r
+  if (Status == RETURN_BUFFER_TOO_SMALL) {\r
+    //\r
+    // Frame buffer configure may be larger in new mode.\r
+    //\r
+    if (Private->FrameBufferBltConfigure != NULL) {\r
+      FreePool (Private->FrameBufferBltConfigure);\r
+    }\r
     Private->FrameBufferBltConfigure =\r
       AllocatePool (Private->FrameBufferBltConfigureSize);\r
-  }\r
+    ASSERT (Private->FrameBufferBltConfigure != NULL);\r
 \r
-  //\r
-  // Create the configuration for FrameBufferBltLib\r
-  //\r
-  ASSERT (Private->FrameBufferBltConfigure != NULL);\r
-  Status = FrameBufferBltConfigure (\r
-              (VOID*) (UINTN) This->Mode->FrameBufferBase,\r
-              This->Mode->Info,\r
-              Private->FrameBufferBltConfigure,\r
-              &Private->FrameBufferBltConfigureSize\r
-              );\r
+    //\r
+    // Create the configuration for FrameBufferBltLib\r
+    //\r
+    Status = FrameBufferBltConfigure (\r
+                (VOID*) (UINTN) This->Mode->FrameBufferBase,\r
+                This->Mode->Info,\r
+                Private->FrameBufferBltConfigure,\r
+                &Private->FrameBufferBltConfigureSize\r
+                );\r
+  }\r
   ASSERT (Status == RETURN_SUCCESS);\r
 \r
   return EFI_SUCCESS;\r