From nobody Mon Feb 9 12:43:29 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+85732+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+85732+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642413549; cv=none; d=zohomail.com; s=zohoarc; b=F939CBgQ8MXw3qc3D/DqjLmqM5f3pQqKQWg25wtLzEpZBysAeslX0fYCr4JMdORnviKa+yFBTOLVg/DrPgjyOp/bQTA8VHLkm3Y+pvcwN703HhVkgyYBu1XiKEbqWwFDiaIk49NlCHVvrp39IAr5f5g4mJgHp5O9uE9uG2FRh0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642413549; 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=BVRSu7E4enSd9bB7yksUPMq9090Q2cXMClE1egkmR8s=; b=h9Qicw0oGkq17xImBENGJW2JlnCiS/AUJS43kbjdUw7hIBH8Kiqdp8SoEZ+IDneAmiz1PIfHM4m+jSPvTaFCQ32P/4OKq/vJEHxNKzPxzKrdGE2ATSAlpFfvuCiDL7xCGx6uiLDXoknCN49RMj1eFSl/k6ZieLWiN25v4zurnD8= 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+85732+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 1642413549166293.0939327341513; Mon, 17 Jan 2022 01:59:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5diSYY1788612xXICTGy5q03; Mon, 17 Jan 2022 01:59:08 -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.web08.9315.1642413548117853052 for ; Mon, 17 Jan 2022 01:59:08 -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-661-YmFjGU16MJCxiTwjbKEkzg-1; Mon, 17 Jan 2022 04:59:02 -0500 X-MC-Unique: YmFjGU16MJCxiTwjbKEkzg-1 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5CFB41023F4D; Mon, 17 Jan 2022 09:59:00 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00AFC7B9F2; Mon, 17 Jan 2022 09:58:54 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4232E1800634; Mon, 17 Jan 2022 10:58:17 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Gerd Hoffmann , Jordan Justen , Min Xu , Jiewen Yao , Julien Grall , Tom Lendacky , Brijesh Singh , James Bottomley , Erdem Aktas , Pawel Polawski , Anthony Perard , Ard Biesheuvel Subject: [edk2-devel] [PATCH v2 5/5] OvmfPkg/QemuVideoDxe: parse edid blob, detect display resolution Date: Mon, 17 Jan 2022 10:58:17 +0100 Message-Id: <20220117095817.1964424-6-kraxel@redhat.com> In-Reply-To: <20220117095817.1964424-1-kraxel@redhat.com> References: <20220117095817.1964424-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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: eBcIGAxOdoS8gy8te7KZZDZLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1642413548; bh=gH0y4a1TMYHBv7omHeG7S6mTDNTGDU2zEJXfMDaaBD4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=miFGfesJGDE2cMvrPm95hS7Q2yQy6Wnz4ShcuMFNavgc7BYgywYhvsszfpIkycxsVEm UNTAfiwwLdGYi2Q7RMYowdImHtv5hu25bK3XUNjSaJ9CymDOd+2HC02TEQiCHJ93lUV1w Zz8ZHMxqzBrJQLjtdwifTfcS2YWadz9dEL0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1642413550099100001 Content-Type: text/plain; charset="utf-8" Check whenever an EDID blob is present. In case it is get the display resolution from it. Unless PcdVideoResolutionSource indicates the display resolution has been set already update PcdVideoHorizontalResolution and PcdVideoVerticalResolution accordingly. Also add the resolution to the mode list. This will make OVMF boot up with the display resolution configured by QEMU, which is 1024x768 by default. The resolution can be set using the xres and yres properties. Here is an example for FullHD: qemu-system-x86_64 -device VGA,xres=3D1920,yres=3D1080 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3778 Ref: https://bugzilla.redhat.com/show_bug.cgi?id=3D1749250 Signed-off-by: Gerd Hoffmann --- OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 3 + OvmfPkg/QemuVideoDxe/Qemu.h | 2 + OvmfPkg/QemuVideoDxe/Initialize.c | 102 +++++++++++++++++++++++++- 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/Q= emuVideoDxe.inf index fe8befd51d3c..43a6e07faa88 100644 --- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf +++ b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf @@ -63,4 +63,7 @@ [Protocols] =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId + gUefiOvmfPkgTokenSpaceGuid.PcdVideoResolutionSource gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution + gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h index 1e6507f44caa..57341a0bbfc4 100644 --- a/OvmfPkg/QemuVideoDxe/Qemu.h +++ b/OvmfPkg/QemuVideoDxe/Qemu.h @@ -115,6 +115,8 @@ typedef struct { FRAME_BUFFER_CONFIGURE *FrameBufferBltConfigure; UINTN FrameBufferBltConfigureSize; UINT8 FrameBufferVramBarIndex; + + UINT8 Edid[128]; } QEMU_VIDEO_PRIVATE_DATA; =20 /// diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c b/OvmfPkg/QemuVideoDxe/Initi= alize.c index 8c5c9176ad21..2a3cbc65c32a 100644 --- a/OvmfPkg/QemuVideoDxe/Initialize.c +++ b/OvmfPkg/QemuVideoDxe/Initialize.c @@ -284,6 +284,88 @@ QemuVideoBochsAddMode ( Private->MaxMode++; } =20 +STATIC +VOID +QemuVideoBochsEdid ( + QEMU_VIDEO_PRIVATE_DATA *Private, + UINT32 *XRes, + UINT32 *YRes + ) +{ + EFI_STATUS Status; + + if (Private->Variant !=3D QEMU_VIDEO_BOCHS_MMIO) { + return; + } + + Status =3D Private->PciIo->Mem.Read ( + Private->PciIo, + EfiPciIoWidthUint8, + PCI_BAR_IDX2, + 0, + sizeof (Private->Edid), + Private->Edid + ); + if (Status !=3D EFI_SUCCESS) { + DEBUG (( + DEBUG_INFO, + "%a: mmio read failed\n", + __FUNCTION__ + )); + return; + } + + if ((Private->Edid[0] !=3D 0x00) || + (Private->Edid[1] !=3D 0xff)) + { + DEBUG (( + DEBUG_INFO, + "%a: magic check failed\n", + __FUNCTION__ + )); + return; + } + + DEBUG (( + DEBUG_INFO, + "%a: blob found (extensions: %d)\n", + __FUNCTION__, + Private->Edid[126] + )); + + if ((Private->Edid[54] =3D=3D 0x00) && + (Private->Edid[55] =3D=3D 0x00)) + { + DEBUG (( + DEBUG_INFO, + "%a: no detailed timing descriptor\n", + __FUNCTION__ + )); + return; + } + + *XRes =3D Private->Edid[56] | ((Private->Edid[58] & 0xf0) << 4); + *YRes =3D Private->Edid[59] | ((Private->Edid[61] & 0xf0) << 4); + DEBUG (( + DEBUG_INFO, + "%a: default resolution: %dx%d\n", + __FUNCTION__, + *XRes, + *YRes + )); + + 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); + } + + // TODO: register edid as gEfiEdidDiscoveredProtocolGuid ? +} + EFI_STATUS QemuVideoBochsModeSetup ( QEMU_VIDEO_PRIVATE_DATA *Private, @@ -291,7 +373,7 @@ QemuVideoBochsModeSetup ( ) { UINT32 AvailableFbSize; - UINT32 Index; + UINT32 Index, XRes =3D 0, YRes =3D 0; =20 // // Fetch the available framebuffer size. @@ -374,13 +456,29 @@ QemuVideoBochsModeSetup ( // Setup Video Modes // Private->ModeData =3D AllocatePool ( - sizeof (Private->ModeData[0]) * QEMU_VIDEO_BOCHS_M= ODE_COUNT + sizeof (Private->ModeData[0]) * (QEMU_VIDEO_BOCHS_= MODE_COUNT+1) ); if (Private->ModeData =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 + QemuVideoBochsEdid (Private, &XRes, &YRes); + if (XRes && YRes) { + QemuVideoBochsAddMode ( + Private, + AvailableFbSize, + XRes, + YRes + ); + } + for (Index =3D 0; Index < QEMU_VIDEO_BOCHS_MODE_COUNT; Index++) { + if ((QemuVideoBochsModes[Index].Width =3D=3D XRes) && + (QemuVideoBochsModes[Index].Height =3D=3D YRes)) + { + continue; // duplicate with edid resolution + } + QemuVideoBochsAddMode ( Private, AvailableFbSize, --=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 (#85732): https://edk2.groups.io/g/devel/message/85732 Mute This Topic: https://groups.io/mt/88481083/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-