From nobody Mon Feb 9 21:20:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86362+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86362+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643873185; cv=none; d=zohomail.com; s=zohoarc; b=PXIGmYpaVVEYBgl/RSDIqFlNzBeauyiwADRFmfi7c0fpG56ix+j/5Xc0KC6uC4dejhmp0RtvVX9wvqPXjAMYbAMkiU1btVlvXTB94vQZPOSlX/Qzk6Hk8Hs0rPob3fxrzAusJ68cFAWmJ9Ayps9u21vfA0Zq0egMUZrLZjSjJrw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643873185; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=2qn/UAtOYDKtbdxeTaBKYOp2LI3yja2vggCmABxVQXQ=; b=Z0A/rnAS7xV/bbNFRzlsIx26TFwyiblRXKbjgu/NiFjdj91v9oiFpPo+4Q2e+yEGqBkRaCUGPk5pzze6FscdN8IWeLqtNsM1rEut60VSAlIEBg5bwvgX+hBn42C7KEE/R6zcVnop5OY7xSzPW25AMweR8bTAbjh4aNmUNnjll3c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86362+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1643873185155381.9399149006998; Wed, 2 Feb 2022 23:26:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id MOKtYY1788612xmyBzk5Ya4t; Wed, 02 Feb 2022 23:26:24 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web08.6254.1643873183463297612 for ; Wed, 02 Feb 2022 23:26:24 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-336-XdKmv7FXOEirwqr5qfmwIw-1; Thu, 03 Feb 2022 02:26:21 -0500 X-MC-Unique: XdKmv7FXOEirwqr5qfmwIw-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4356551086 for ; Thu, 3 Feb 2022 07:26:19 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B1F5A5F917; Thu, 3 Feb 2022 07:26:18 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B3BE91800614; Thu, 3 Feb 2022 08:26:00 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Pawel Polawski , Gerd Hoffmann Subject: [edk2-devel] [PATCH 6/6] OvmfPkg/VirtioGpuDxe: query native display resolution from host Date: Thu, 3 Feb 2022 08:26:00 +0100 Message-Id: <20220203072600.1646396-7-kraxel@redhat.com> In-Reply-To: <20220203072600.1646396-1-kraxel@redhat.com> References: <20220203072600.1646396-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: Ooy35bMBv7VXeKmGAwtkq8cvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643873184; bh=12DM0LsoZIkTz5IUBIgiyFkMey+ckhuTf9JD5W7mG1Q=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=b3+8KG1opjnM0VB+PL+3YE87FidJhUk+7p4LpCbHARCQGgO9fALAPR/Twky0XpyGGwj sf4y0AqBJGxBHG3nWLUcYchlb2RR7R1iSK0ALycsbQ9b5kRV9yWDis/wxjR30trf5Fepm Fr2bhzE1yo8fv+WY/33+zRMvCclwKxRAZg4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643873187627100002 Content-Type: text/plain; charset="utf-8" Try query native display resolution from the host. When successfull setup PcdVideoHorizontalResolution and PcdVideoVerticalResolution accordingly and add the video mode to the GOP mode list if needed. Signed-off-by: Gerd Hoffmann --- OvmfPkg/VirtioGpuDxe/VirtioGpu.inf | 6 ++ OvmfPkg/VirtioGpuDxe/VirtioGpu.h | 6 ++ OvmfPkg/VirtioGpuDxe/Gop.c | 92 ++++++++++++++++++++++++++++-- 3 files changed, 99 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf b/OvmfPkg/VirtioGpuDxe/Virt= ioGpu.inf index 9e66bcd4b97f..d88c87e129f0 100644 --- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf +++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.inf @@ -25,6 +25,7 @@ [Sources] =20 [Packages] MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] @@ -43,3 +44,8 @@ [Protocols] gEfiGraphicsOutputProtocolGuid ## BY_START gEfiPciIoProtocolGuid ## TO_START gVirtioDeviceProtocolGuid ## TO_START + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdVideoResolutionSource + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h b/OvmfPkg/VirtioGpuDxe/Virtio= Gpu.h index 1d781088bb3f..45da56415297 100644 --- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h +++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h @@ -151,6 +151,12 @@ struct VGPU_GOP_STRUCT { // BackingStore is non-NULL. // VOID *BackingStoreMap; + + // + // native display resolution + // + UINT32 NativeXRes; + UINT32 NativeYRes; }; =20 // diff --git a/OvmfPkg/VirtioGpuDxe/Gop.c b/OvmfPkg/VirtioGpuDxe/Gop.c index 05daefcbfbc8..70a81c10c8b5 100644 --- a/OvmfPkg/VirtioGpuDxe/Gop.c +++ b/OvmfPkg/VirtioGpuDxe/Gop.c @@ -9,6 +9,7 @@ **/ =20 #include +#include =20 #include "VirtioGpu.h" =20 @@ -192,6 +193,47 @@ STATIC CONST GOP_RESOLUTION mGopResolutions[] =3D { #define VGPU_GOP_FROM_GOP(GopPointer) \ CR (GopPointer, VGPU_GOP, Gop, VGPU_GOP_SIG) =20 +STATIC +VOID +EFIAPI +GopNativeResolution ( + IN VGPU_GOP *VgpuGop, + OUT UINT32 *XRes, + OUT UINT32 *YRes + ) +{ + volatile VIRTIO_GPU_RESP_DISPLAY_INFO DisplayInfo; + EFI_STATUS Status; + UINTN Index; + + Status =3D VirtioGpuGetDisplayInfo (VgpuGop->ParentBus, &DisplayInfo); + if (Status !=3D EFI_SUCCESS) { + return; + } + + for (Index =3D 0; Index < VIRTIO_GPU_MAX_SCANOUTS; Index++) { + if (!DisplayInfo.Pmodes[Index].Enabled || + !DisplayInfo.Pmodes[Index].Rectangle.Width || + !DisplayInfo.Pmodes[Index].Rectangle.Height) + { + continue; + } + + DEBUG (( + DEBUG_INFO, + "%a: #%d: %dx%d\n", + __FUNCTION__, + Index, + DisplayInfo.Pmodes[Index].Rectangle.Width, + DisplayInfo.Pmodes[Index].Rectangle.Height + )); + if ((*XRes =3D=3D 0) || (*YRes =3D=3D 0)) { + *XRes =3D DisplayInfo.Pmodes[Index].Rectangle.Width; + *YRes =3D DisplayInfo.Pmodes[Index].Rectangle.Height; + } + } +} + STATIC VOID EFIAPI @@ -199,7 +241,9 @@ GopInitialize ( IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This ) { - VGPU_GOP *VgpuGop; + VGPU_GOP *VgpuGop; + EFI_STATUS Status; + UINT32 XRes =3D 0, YRes =3D 0, Index; =20 VgpuGop =3D VGPU_GOP_FROM_GOP (This); =20 @@ -216,6 +260,37 @@ GopInitialize ( VgpuGop->GopMode.SizeOfInfo =3D sizeof VgpuGop->GopModeInfo; =20 VgpuGop->GopModeInfo.PixelFormat =3D PixelBltOnly; + + // + // query host for display resolution + // + GopNativeResolution (VgpuGop, &XRes, &YRes); + if ((XRes =3D=3D 0) || (YRes =3D=3D 0)) { + return; + } + + if (PcdGet8 (PcdVideoResolutionSource) =3D=3D 0) { + Status =3D PcdSet32S (PcdVideoHorizontalResolution, XRes); + ASSERT_RETURN_ERROR (Status); + Status =3D PcdSet32S (PcdVideoVerticalResolution, YRes); + ASSERT_RETURN_ERROR (Status); + Status =3D PcdSet8S (PcdVideoResolutionSource, 2); + ASSERT_RETURN_ERROR (Status); + } + + VgpuGop->NativeXRes =3D XRes; + VgpuGop->NativeYRes =3D YRes; + for (Index =3D 0; Index < ARRAY_SIZE (mGopResolutions); Index++) { + if ((mGopResolutions[Index].Width =3D=3D XRes) && + (mGopResolutions[Index].Height =3D=3D YRes)) + { + // native resolution already is in mode list + return; + } + } + + // add to mode list + VgpuGop->GopMode.MaxMode++; } =20 // @@ -242,10 +317,17 @@ GopQueryMode ( return EFI_OUT_OF_RESOURCES; } =20 - GopModeInfo->HorizontalResolution =3D mGopResolutions[ModeNumber].Width; - GopModeInfo->VerticalResolution =3D mGopResolutions[ModeNumber].Height; - GopModeInfo->PixelFormat =3D PixelBltOnly; - GopModeInfo->PixelsPerScanLine =3D mGopResolutions[ModeNumber].Width; + if (ModeNumber < ARRAY_SIZE (mGopResolutions)) { + GopModeInfo->HorizontalResolution =3D mGopResolutions[ModeNumber].Widt= h; + GopModeInfo->VerticalResolution =3D mGopResolutions[ModeNumber].Heig= ht; + } else { + VGPU_GOP *VgpuGop =3D VGPU_GOP_FROM_GOP (This); + GopModeInfo->HorizontalResolution =3D VgpuGop->NativeXRes; + GopModeInfo->VerticalResolution =3D VgpuGop->NativeYRes; + } + + GopModeInfo->PixelFormat =3D PixelBltOnly; + GopModeInfo->PixelsPerScanLine =3D GopModeInfo->HorizontalResolution; =20 *SizeOfInfo =3D sizeof *GopModeInfo; *Info =3D GopModeInfo; --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86362): https://edk2.groups.io/g/devel/message/86362 Mute This Topic: https://groups.io/mt/88878650/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-