public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
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 5/6] OvmfPkg/VirtioGpuDxe: move code to GopInitialize
Date: Fri, 11 Mar 2022 06:43:14 +0100	[thread overview]
Message-ID: <20220311054315.876774-6-kraxel@redhat.com> (raw)
In-Reply-To: <20220311054315.876774-1-kraxel@redhat.com>

Add new function to initialize the GOP, move over setup code.  Handle
initialization first, specifically before calling GopQueryMode(), so
GopQueryMode is never called before GopInitialize() did complete.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 OvmfPkg/VirtioGpuDxe/Gop.c | 47 ++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 15 deletions(-)

diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c
index 337a7e19bffa..05daefcbfbc8 100644
--- a/OvmfPkg/VirtioGpuDxe/Gop.c
+++ b/OvmfPkg/VirtioGpuDxe/Gop.c
@@ -192,6 +192,32 @@ STATIC CONST GOP_RESOLUTION  mGopResolutions[] = {
 #define VGPU_GOP_FROM_GOP(GopPointer) \
           CR (GopPointer, VGPU_GOP, Gop, VGPU_GOP_SIG)
 
+STATIC
+VOID
+EFIAPI
+GopInitialize (
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL  *This
+  )
+{
+  VGPU_GOP  *VgpuGop;
+
+  VgpuGop = VGPU_GOP_FROM_GOP (This);
+
+  //
+  // Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the other
+  // (nonzero) constant fields.
+  //
+  // No direct framebuffer access is supported, only Blt() is.
+  //
+  VgpuGop->Gop.Mode = &VgpuGop->GopMode;
+
+  VgpuGop->GopMode.MaxMode    = (UINT32)(ARRAY_SIZE (mGopResolutions));
+  VgpuGop->GopMode.Info       = &VgpuGop->GopModeInfo;
+  VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;
+
+  VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly;
+}
+
 //
 // EFI_GRAPHICS_OUTPUT_PROTOCOL member functions.
 //
@@ -207,7 +233,7 @@ GopQueryMode (
 {
   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *GopModeInfo;
 
-  if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {
+  if (ModeNumber >= This->Mode->MaxMode) {
     return EFI_INVALID_PARAMETER;
   }
 
@@ -247,6 +273,11 @@ GopSetMode (
   EFI_STATUS  Status;
   EFI_STATUS  Status2;
 
+  if (!This->Mode) {
+    // SetMode() call in InitVgpuGop() triggers this.
+    GopInitialize (This);
+  }
+
   Status = GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo);
   if (Status != EFI_SUCCESS) {
     return Status;
@@ -259,20 +290,6 @@ GopSetMode (
   // calls.
   //
   if (VgpuGop->ResourceId == 0) {
-    //
-    // Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the other
-    // (nonzero) constant fields.
-    //
-    // No direct framebuffer access is supported, only Blt() is.
-    //
-    VgpuGop->Gop.Mode = &VgpuGop->GopMode;
-
-    VgpuGop->GopMode.MaxMode    = (UINT32)(ARRAY_SIZE (mGopResolutions));
-    VgpuGop->GopMode.Info       = &VgpuGop->GopModeInfo;
-    VgpuGop->GopMode.SizeOfInfo = sizeof VgpuGop->GopModeInfo;
-
-    VgpuGop->GopModeInfo.PixelFormat = PixelBltOnly;
-
     //
     // This is the first time we create a host side resource.
     //
-- 
2.35.1


  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 ` [PATCH v2 4/6] OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode Gerd Hoffmann
2022-03-11  5:43 ` Gerd Hoffmann [this message]
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-6-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