]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 8 Apr 2022 08:23:31 +0000 (10:23 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 25 Apr 2022 21:01:13 +0000 (21:01 +0000)
Call GopQueryMode() in GopSetMode(), use the ModeInfo returned when
setting the mode.  This is needed to properly handle modes which are
not on the static mGopResolutions list.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
OvmfPkg/VirtioGpuDxe/Gop.c

index 2c15d542e3b1e0c7aedd2564918b1576d39e9522..337a7e19bffaf95fb75dcd6206308a52088b3f1b 100644 (file)
@@ -234,19 +234,22 @@ GopSetMode (
   IN  UINT32                        ModeNumber\r
   )\r
 {\r
-  VGPU_GOP              *VgpuGop;\r
-  UINT32                NewResourceId;\r
-  UINTN                 NewNumberOfBytes;\r
-  UINTN                 NewNumberOfPages;\r
-  VOID                  *NewBackingStore;\r
-  EFI_PHYSICAL_ADDRESS  NewBackingStoreDeviceAddress;\r
-  VOID                  *NewBackingStoreMap;\r
+  VGPU_GOP                              *VgpuGop;\r
+  UINT32                                NewResourceId;\r
+  UINTN                                 NewNumberOfBytes;\r
+  UINTN                                 NewNumberOfPages;\r
+  VOID                                  *NewBackingStore;\r
+  EFI_PHYSICAL_ADDRESS                  NewBackingStoreDeviceAddress;\r
+  VOID                                  *NewBackingStoreMap;\r
+  UINTN                                 SizeOfInfo;\r
+  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *GopModeInfo;\r
 \r
   EFI_STATUS  Status;\r
   EFI_STATUS  Status2;\r
 \r
-  if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {\r
-    return EFI_UNSUPPORTED;\r
+  Status = GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo);\r
+  if (Status != EFI_SUCCESS) {\r
+    return Status;\r
   }\r
 \r
   VgpuGop = VGPU_GOP_FROM_GOP (This);\r
@@ -292,8 +295,8 @@ GopSetMode (
              VgpuGop->ParentBus,                // VgpuDev\r
              NewResourceId,                     // ResourceId\r
              VirtioGpuFormatB8G8R8X8Unorm,      // Format\r
-             mGopResolutions[ModeNumber].Width, // Width\r
-             mGopResolutions[ModeNumber].Height // Height\r
+             GopModeInfo->HorizontalResolution, // Width\r
+             GopModeInfo->VerticalResolution    // Height\r
              );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -303,8 +306,8 @@ GopSetMode (
   // Allocate, zero and map guest backing store, for bus master common buffer\r
   // operation.\r
   //\r
-  NewNumberOfBytes = mGopResolutions[ModeNumber].Width *\r
-                     mGopResolutions[ModeNumber].Height * sizeof (UINT32);\r
+  NewNumberOfBytes = GopModeInfo->HorizontalResolution *\r
+                     GopModeInfo->VerticalResolution * sizeof (UINT32);\r
   NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes);\r
   Status           = VirtioGpuAllocateZeroAndMapBackingStore (\r
                        VgpuGop->ParentBus,            // VgpuDev\r
@@ -337,8 +340,8 @@ GopSetMode (
              VgpuGop->ParentBus,                 // VgpuDev\r
              0,                                  // X\r
              0,                                  // Y\r
-             mGopResolutions[ModeNumber].Width,  // Width\r
-             mGopResolutions[ModeNumber].Height, // Height\r
+             GopModeInfo->HorizontalResolution,  // Width\r
+             GopModeInfo->VerticalResolution,    // Height\r
              0,                                  // ScanoutId\r
              NewResourceId                       // ResourceId\r
              );\r
@@ -356,8 +359,8 @@ GopSetMode (
                VgpuGop->ParentBus,                 // VgpuDev\r
                0,                                  // X\r
                0,                                  // Y\r
-               mGopResolutions[ModeNumber].Width,  // Width\r
-               mGopResolutions[ModeNumber].Height, // Height\r
+               GopModeInfo->HorizontalResolution,  // Width\r
+               GopModeInfo->VerticalResolution,    // Height\r
                NewResourceId                       // ResourceId\r
                );\r
     if (EFI_ERROR (Status)) {\r
@@ -367,13 +370,13 @@ GopSetMode (
       // therefore non-recoverable.\r
       //\r
       Status2 = VirtioGpuSetScanout (\r
-                  VgpuGop->ParentBus,                       // VgpuDev\r
-                  0,                                        // X\r
-                  0,                                        // Y\r
-                  mGopResolutions[This->Mode->Mode].Width,  // Width\r
-                  mGopResolutions[This->Mode->Mode].Height, // Height\r
-                  0,                                        // ScanoutId\r
-                  VgpuGop->ResourceId                       // ResourceId\r
+                  VgpuGop->ParentBus,                        // VgpuDev\r
+                  0,                                         // X\r
+                  0,                                         // Y\r
+                  VgpuGop->GopModeInfo.HorizontalResolution, // Width\r
+                  VgpuGop->GopModeInfo.VerticalResolution,   // Height\r
+                  0,                                         // ScanoutId\r
+                  VgpuGop->ResourceId                        // ResourceId\r
                   );\r
       ASSERT_EFI_ERROR (Status2);\r
       if (EFI_ERROR (Status2)) {\r
@@ -406,11 +409,9 @@ GopSetMode (
   //\r
   // Populate Mode and ModeInfo (mutable fields only).\r
   //\r
-  VgpuGop->GopMode.Mode                     = ModeNumber;\r
-  VgpuGop->GopModeInfo.HorizontalResolution =\r
-    mGopResolutions[ModeNumber].Width;\r
-  VgpuGop->GopModeInfo.VerticalResolution = mGopResolutions[ModeNumber].Height;\r
-  VgpuGop->GopModeInfo.PixelsPerScanLine  = mGopResolutions[ModeNumber].Width;\r
+  VgpuGop->GopMode.Mode = ModeNumber;\r
+  VgpuGop->GopModeInfo  = *GopModeInfo;\r
+  FreePool (GopModeInfo);\r
   return EFI_SUCCESS;\r
 \r
 DetachBackingStore:\r
@@ -435,6 +436,7 @@ DestroyHostResource:
     CpuDeadLoop ();\r
   }\r
 \r
+  FreePool (GopModeInfo);\r
   return Status;\r
 }\r
 \r