From nobody Tue Feb 10 03:37:44 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+87449+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+87449+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646977419; cv=none; d=zohomail.com; s=zohoarc; b=f2E7fdswKI/nYJo+ZCitRC0fGi03obsTr6JGOzjmzPRdv4wyc5s1mcI4edNbwNK6MQKD1eu9WooT067qJRUnZXzjsnxT+fqKPXPY0w4WgLJ6tqsWV0jskrMQmgiWFsuYXA6IHsc41FhItetuFz5aIcZFQcyq6ti+KSjBNekAFh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646977419; 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=tN/1Ql+zRIbyu/7HXnwgeCKJ9EnQoSwW64517udayFA=; b=LGJu03eha9P/K5tUbm0VzMPICiLoSp2aj4yft4lMKHlyMkBNOrvD6u1vNGdSnH0C1vcnLRDStyTgOEIHGSvZ7o6UjP9MUddV5cw774olyiohb73ddY3BjpxbRcCbbC3J5rz7FZ44rhz5CGfU63qom7LS6+0C52F5DpwBSmhmscU= 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+87449+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 1646977419378947.9181383987901; Thu, 10 Mar 2022 21:43:39 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id UduJYY1788612xqpjKHIArTX; Thu, 10 Mar 2022 21:43:39 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.2676.1646977418453074874 for ; Thu, 10 Mar 2022 21:43:38 -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-333-iCu5-ifzPNSPbwFUSEbhaA-1; Fri, 11 Mar 2022 00:43:36 -0500 X-MC-Unique: iCu5-ifzPNSPbwFUSEbhaA-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70D221006AA7 for ; Fri, 11 Mar 2022 05:43:35 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.196.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7C0E57CA4; Fri, 11 Mar 2022 05:43:34 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BEF211800796; Fri, 11 Mar 2022 06:43:15 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Pawel Polawski , Gerd Hoffmann Subject: [edk2-devel] [PATCH v2 6/6] OvmfPkg/VirtioGpuDxe: query native display resolution from host Date: Fri, 11 Mar 2022 06:43:15 +0100 Message-Id: <20220311054315.876774-7-kraxel@redhat.com> In-Reply-To: <20220311054315.876774-1-kraxel@redhat.com> References: <20220311054315.876774-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: YTeBCuqT7BE1ezTJy7X74czNx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646977419; bh=hFX3jpcu+xqpBvBy69bKOguX9Jg7T82RzqY8P/WhP6E=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=hYqR48OIAQ2l8/GA7F2frjYL4yEk+1Y77s5fWlVGoABuc4gO9renpjBzAO7KqGu58KV m+/1+02qrCwNf2ivjnapklK5VU2Me16VWSQoE37kqH57qlQNDTHwlx17mAfpA7ttDtJyQ 45QLgBMscBgjMSjAF84OEqNLK5bw5ZrVCDc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646977420769100006 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.35.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 (#87449): https://edk2.groups.io/g/devel/message/87449 Mute This Topic: https://groups.io/mt/89705201/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-