OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode

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>
This commit is contained in:
Gerd Hoffmann
2022-04-08 10:23:31 +02:00
committed by mergify[bot]
parent 82c07f2cc7
commit 5f6ecaa398

View File

@ -241,12 +241,15 @@ GopSetMode (
VOID *NewBackingStore; VOID *NewBackingStore;
EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress; EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress;
VOID *NewBackingStoreMap; VOID *NewBackingStoreMap;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo;
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS Status2; EFI_STATUS Status2;
if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) { Status = GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo);
return EFI_UNSUPPORTED; if (Status != EFI_SUCCESS) {
return Status;
} }
VgpuGop = VGPU_GOP_FROM_GOP (This); VgpuGop = VGPU_GOP_FROM_GOP (This);
@ -292,8 +295,8 @@ GopSetMode (
VgpuGop->ParentBus, // VgpuDev VgpuGop->ParentBus, // VgpuDev
NewResourceId, // ResourceId NewResourceId, // ResourceId
VirtioGpuFormatB8G8R8X8Unorm, // Format VirtioGpuFormatB8G8R8X8Unorm, // Format
mGopResolutions[ModeNumber].Width, // Width GopModeInfo->HorizontalResolution, // Width
mGopResolutions[ModeNumber].Height // Height GopModeInfo->VerticalResolution // Height
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
@ -303,8 +306,8 @@ GopSetMode (
// Allocate, zero and map guest backing store, for bus master common buffer // Allocate, zero and map guest backing store, for bus master common buffer
// operation. // operation.
// //
NewNumberOfBytes = mGopResolutions[ModeNumber].Width * NewNumberOfBytes = GopModeInfo->HorizontalResolution *
mGopResolutions[ModeNumber].Height * sizeof (UINT32); GopModeInfo->VerticalResolution * sizeof (UINT32);
NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes); NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes);
Status = VirtioGpuAllocateZeroAndMapBackingStore ( Status = VirtioGpuAllocateZeroAndMapBackingStore (
VgpuGop->ParentBus, // VgpuDev VgpuGop->ParentBus, // VgpuDev
@ -337,8 +340,8 @@ GopSetMode (
VgpuGop->ParentBus, // VgpuDev VgpuGop->ParentBus, // VgpuDev
0, // X 0, // X
0, // Y 0, // Y
mGopResolutions[ModeNumber].Width, // Width GopModeInfo->HorizontalResolution, // Width
mGopResolutions[ModeNumber].Height, // Height GopModeInfo->VerticalResolution, // Height
0, // ScanoutId 0, // ScanoutId
NewResourceId // ResourceId NewResourceId // ResourceId
); );
@ -356,8 +359,8 @@ GopSetMode (
VgpuGop->ParentBus, // VgpuDev VgpuGop->ParentBus, // VgpuDev
0, // X 0, // X
0, // Y 0, // Y
mGopResolutions[ModeNumber].Width, // Width GopModeInfo->HorizontalResolution, // Width
mGopResolutions[ModeNumber].Height, // Height GopModeInfo->VerticalResolution, // Height
NewResourceId // ResourceId NewResourceId // ResourceId
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -370,8 +373,8 @@ GopSetMode (
VgpuGop->ParentBus, // VgpuDev VgpuGop->ParentBus, // VgpuDev
0, // X 0, // X
0, // Y 0, // Y
mGopResolutions[This->Mode->Mode].Width, // Width VgpuGop->GopModeInfo.HorizontalResolution, // Width
mGopResolutions[This->Mode->Mode].Height, // Height VgpuGop->GopModeInfo.VerticalResolution, // Height
0, // ScanoutId 0, // ScanoutId
VgpuGop->ResourceId // ResourceId VgpuGop->ResourceId // ResourceId
); );
@ -407,10 +410,8 @@ GopSetMode (
// Populate Mode and ModeInfo (mutable fields only). // Populate Mode and ModeInfo (mutable fields only).
// //
VgpuGop->GopMode.Mode = ModeNumber; VgpuGop->GopMode.Mode = ModeNumber;
VgpuGop->GopModeInfo.HorizontalResolution = VgpuGop->GopModeInfo = *GopModeInfo;
mGopResolutions[ModeNumber].Width; FreePool (GopModeInfo);
VgpuGop->GopModeInfo.VerticalResolution = mGopResolutions[ModeNumber].Height;
VgpuGop->GopModeInfo.PixelsPerScanLine = mGopResolutions[ModeNumber].Width;
return EFI_SUCCESS; return EFI_SUCCESS;
DetachBackingStore: DetachBackingStore:
@ -435,6 +436,7 @@ DestroyHostResource:
CpuDeadLoop (); CpuDeadLoop ();
} }
FreePool (GopModeInfo);
return Status; return Status;
} }