From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Pawel Polawski <ppolawsk@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH v2 4/6] OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode
Date: Fri, 11 Mar 2022 06:43:13 +0100 [thread overview]
Message-ID: <20220311054315.876774-5-kraxel@redhat.com> (raw)
In-Reply-To: <20220311054315.876774-1-kraxel@redhat.com>
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>
---
OvmfPkg/VirtioGpuDxe/Gop.c | 60 ++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 29 deletions(-)
diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 2c15d542e3b1..337a7e19bffa 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -234,19 +234,22 @@ GopSetMode (
IN UINT32 ModeNumber
)
{
- VGPU_GOP *VgpuGop;
- UINT32 NewResourceId;
- UINTN NewNumberOfBytes;
- UINTN NewNumberOfPages;
- VOID *NewBackingStore;
- EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress;
- VOID *NewBackingStoreMap;
+ VGPU_GOP *VgpuGop;
+ UINT32 NewResourceId;
+ UINTN NewNumberOfBytes;
+ UINTN NewNumberOfPages;
+ VOID *NewBackingStore;
+ EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress;
+ VOID *NewBackingStoreMap;
+ UINTN SizeOfInfo;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo;
EFI_STATUS Status;
EFI_STATUS Status2;
- if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
- return EFI_UNSUPPORTED;
+ Status = GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo);
+ if (Status != EFI_SUCCESS) {
+ return Status;
}
VgpuGop = VGPU_GOP_FROM_GOP (This);
@@ -292,8 +295,8 @@ GopSetMode (
VgpuGop->ParentBus, // VgpuDev
NewResourceId, // ResourceId
VirtioGpuFormatB8G8R8X8Unorm, // Format
- mGopResolutions[ModeNumber].Width, // Width
- mGopResolutions[ModeNumber].Height // Height
+ GopModeInfo->HorizontalResolution, // Width
+ GopModeInfo->VerticalResolution // Height
);
if (EFI_ERROR (Status)) {
return Status;
@@ -303,8 +306,8 @@ GopSetMode (
// Allocate, zero and map guest backing store, for bus master common buffer
// operation.
//
- NewNumberOfBytes = mGopResolutions[ModeNumber].Width *
- mGopResolutions[ModeNumber].Height * sizeof (UINT32);
+ NewNumberOfBytes = GopModeInfo->HorizontalResolution *
+ GopModeInfo->VerticalResolution * sizeof (UINT32);
NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes);
Status = VirtioGpuAllocateZeroAndMapBackingStore (
VgpuGop->ParentBus, // VgpuDev
@@ -337,8 +340,8 @@ GopSetMode (
VgpuGop->ParentBus, // VgpuDev
0, // X
0, // Y
- mGopResolutions[ModeNumber].Width, // Width
- mGopResolutions[ModeNumber].Height, // Height
+ GopModeInfo->HorizontalResolution, // Width
+ GopModeInfo->VerticalResolution, // Height
0, // ScanoutId
NewResourceId // ResourceId
);
@@ -356,8 +359,8 @@ GopSetMode (
VgpuGop->ParentBus, // VgpuDev
0, // X
0, // Y
- mGopResolutions[ModeNumber].Width, // Width
- mGopResolutions[ModeNumber].Height, // Height
+ GopModeInfo->HorizontalResolution, // Width
+ GopModeInfo->VerticalResolution, // Height
NewResourceId // ResourceId
);
if (EFI_ERROR (Status)) {
@@ -367,13 +370,13 @@ GopSetMode (
// therefore non-recoverable.
//
Status2 = VirtioGpuSetScanout (
- VgpuGop->ParentBus, // VgpuDev
- 0, // X
- 0, // Y
- mGopResolutions[This->Mode->Mode].Width, // Width
- mGopResolutions[This->Mode->Mode].Height, // Height
- 0, // ScanoutId
- VgpuGop->ResourceId // ResourceId
+ VgpuGop->ParentBus, // VgpuDev
+ 0, // X
+ 0, // Y
+ VgpuGop->GopModeInfo.HorizontalResolution, // Width
+ VgpuGop->GopModeInfo.VerticalResolution, // Height
+ 0, // ScanoutId
+ VgpuGop->ResourceId // ResourceId
);
ASSERT_EFI_ERROR (Status2);
if (EFI_ERROR (Status2)) {
@@ -406,11 +409,9 @@ GopSetMode (
//
// Populate Mode and ModeInfo (mutable fields only).
//
- VgpuGop->GopMode.Mode = ModeNumber;
- VgpuGop->GopModeInfo.HorizontalResolution =
- mGopResolutions[ModeNumber].Width;
- VgpuGop->GopModeInfo.VerticalResolution = mGopResolutions[ModeNumber].Height;
- VgpuGop->GopModeInfo.PixelsPerScanLine = mGopResolutions[ModeNumber].Width;
+ VgpuGop->GopMode.Mode = ModeNumber;
+ VgpuGop->GopModeInfo = *GopModeInfo;
+ FreePool (GopModeInfo);
return EFI_SUCCESS;
DetachBackingStore:
@@ -435,6 +436,7 @@ GopSetMode (
CpuDeadLoop ();
}
+ FreePool (GopModeInfo);
return Status;
}
--
2.35.1
next prev parent reply other threads:[~2022-03-11 5:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 5:43 [PATCH v2 0/6] OvmfPkg/VirtioGpuDxe: use host display resolution Gerd Hoffmann
2022-03-11 5:43 ` [PATCH v2 1/6] OvmfPkg/VirtioGpuDxe: add VirtioGpuSendCommandWithReply Gerd Hoffmann
2022-03-11 5:43 ` [PATCH v2 2/6] OvmfPkg/VirtioGpuDxe: add GetDisplayInfo to virtio-gpu spec header Gerd Hoffmann
2022-03-11 5:43 ` [PATCH v2 3/6] OvmfPkg/VirtioGpuDxe: add VirtioGpuGetDisplayInfo Gerd Hoffmann
2022-03-11 5:43 ` Gerd Hoffmann [this message]
2022-03-11 5:43 ` [PATCH v2 5/6] OvmfPkg/VirtioGpuDxe: move code to GopInitialize Gerd Hoffmann
2022-03-11 5:43 ` [PATCH v2 6/6] OvmfPkg/VirtioGpuDxe: query native display resolution from host Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220311054315.876774-5-kraxel@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox