From nobody Fri May 17 04:49:27 2024 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+88605+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+88605+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649406221; cv=none; d=zohomail.com; s=zohoarc; b=fQ/eXzRXIWslApGOVR4P1r0SfMx4tVr+JMDldHMfF7+gG2dMduUAikrh+KND0Jqx30lOC5JejjE+CnULup7ykNwozaA0zmBdBe7HmtNDxc/iwGypTpnuq/RNuRHrXmJrUSIKRAwdBiHHHT3oi5N/84jRgEfqVXLNI6yY3xUBD5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649406221; 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=X8Jid9aiTqe3Y56eQedUHtSrAA+J8HttXy+8+wpZh6s=; b=QuKoJQYVGUd/ZRXMyiIDiykkgicq1G7dnsh7Gk1wYgMnguRoS2qzJ6SMkNPjOCrB1nA15aBp/2ytHmrSnr43ooJOiw53xxq/WYXL0IYHi0j3zOoFweEohztjIyfO3Yb7lbN9s0UeznMKE1TInsfDnxrq6A1ypRGEJiOSOlKVKTc= 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+88605+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 1649406221823377.8766601437162; Fri, 8 Apr 2022 01:23:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZSb3YY1788612x1NkPLHPk0v; Fri, 08 Apr 2022 01:23:41 -0700 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.web09.3456.1649406220834124899 for ; Fri, 08 Apr 2022 01:23:41 -0700 X-Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-17-PkLYiU0DMue_6DmhPYTbNg-1; Fri, 08 Apr 2022 04:23:35 -0400 X-MC-Unique: PkLYiU0DMue_6DmhPYTbNg-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 857BD1C08DB5; Fri, 8 Apr 2022 08:23:35 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2ACC7401475; Fri, 8 Apr 2022 08:23:35 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C84421800619; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 1/6] OvmfPkg/VirtioGpuDxe: add VirtioGpuSendCommandWithReply Date: Fri, 8 Apr 2022 10:23:28 +0200 Message-Id: <20220408082333.3023758-2-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: N5cjqtgmtYOnzQ1KnllE932Tx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649406221; bh=py8m1g5aoEmsMc7BmyAW0+X22ductKlJvCs5Zd2b7dg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=pLDqPGS8U7/rSgNMQO1k+O5BQ7G1PYOMf8L5UtZBIvcB3qUG7xsRr8OGnknJqLgD+Mf Sx8a0emh6AcRYP9AYT+HAL3bf9c9kAIGqD5ndY09tgjjw0WM4vYf+t4iBrkzXdf0/L1+5 GR+eodpDSfAjVK0hfX54D+o4PTb+5Lx+Seo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649406222665100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Extend VirtioGpuSendCommand() to support commands which return data, rename the function to VirtioGpuSendCommandWithReply() to indicate that. Add a new VirtioGpuSendCommand() function which is just a thin wrapper around VirtioGpuSendCommandWithReply() so existing code continues to work without changes. Signed-off-by: Gerd Hoffmann --- OvmfPkg/VirtioGpuDxe/Commands.c | 75 +++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Command= s.c index 873a71656700..b9a3ea923021 100644 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ b/OvmfPkg/VirtioGpuDxe/Commands.c @@ -393,6 +393,14 @@ VirtioGpuExitBoot ( @param[in] RequestSize Size of the entire caller-allocated request obje= ct, including the leading VIRTIO_GPU_CONTROL_HEADER. =20 + @param[in] ResponseType The type of the response (VirtioGpuResp*). + + @param[in,out] Response Pointer to the caller-allocated response object.= The + request must start with VIRTIO_GPU_CONTROL_HEADE= R. + + @param[in] ResponseSize Size of the entire caller-allocated response obj= ect, + including the leading VIRTIO_GPU_CONTROL_HEADER. + @retval EFI_SUCCESS Operation successful. =20 @retval EFI_DEVICE_ERROR The host rejected the request. The host e= rror @@ -404,22 +412,24 @@ VirtioGpuExitBoot ( **/ STATIC EFI_STATUS -VirtioGpuSendCommand ( +VirtioGpuSendCommandWithReply ( IN OUT VGPU_DEV *VgpuDev, IN VIRTIO_GPU_CONTROL_TYPE RequestType, IN BOOLEAN Fence, IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Header, - IN UINTN RequestSize + IN UINTN RequestSize, + IN VIRTIO_GPU_CONTROL_TYPE ResponseType, + IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Response, + IN UINTN ResponseSize ) { - DESC_INDICES Indices; - volatile VIRTIO_GPU_CONTROL_HEADER Response; - EFI_STATUS Status; - UINT32 ResponseSize; - EFI_PHYSICAL_ADDRESS RequestDeviceAddress; - VOID *RequestMap; - EFI_PHYSICAL_ADDRESS ResponseDeviceAddress; - VOID *ResponseMap; + DESC_INDICES Indices; + EFI_STATUS Status; + UINT32 ResponseSizeRet; + EFI_PHYSICAL_ADDRESS RequestDeviceAddress; + VOID *RequestMap; + EFI_PHYSICAL_ADDRESS ResponseDeviceAddress; + VOID *ResponseMap; =20 // // Initialize Header. @@ -457,8 +467,8 @@ VirtioGpuSendCommand ( Status =3D VirtioMapAllBytesInSharedBuffer ( VgpuDev->VirtIo, VirtioOperationBusMasterWrite, - (VOID *)&Response, - sizeof Response, + (VOID *)Response, + ResponseSize, &ResponseDeviceAddress, &ResponseMap ); @@ -480,7 +490,7 @@ VirtioGpuSendCommand ( VirtioAppendDesc ( &VgpuDev->Ring, ResponseDeviceAddress, - (UINT32)sizeof Response, + (UINT32)ResponseSize, VRING_DESC_F_WRITE, &Indices ); @@ -493,7 +503,7 @@ VirtioGpuSendCommand ( VIRTIO_GPU_CONTROL_QUEUE, &VgpuDev->Ring, &Indices, - &ResponseSize + &ResponseSizeRet ); if (EFI_ERROR (Status)) { goto UnmapResponse; @@ -502,7 +512,7 @@ VirtioGpuSendCommand ( // // Verify response size. // - if (ResponseSize !=3D sizeof Response) { + if (ResponseSize !=3D ResponseSizeRet) { DEBUG (( DEBUG_ERROR, "%a: malformed response to Request=3D0x%x\n", @@ -531,16 +541,17 @@ VirtioGpuSendCommand ( // // Parse the response. // - if (Response.Type =3D=3D VirtioGpuRespOkNodata) { + if (Response->Type =3D=3D (UINT32)ResponseType) { return EFI_SUCCESS; } =20 DEBUG (( DEBUG_ERROR, - "%a: Request=3D0x%x Response=3D0x%x\n", + "%a: Request=3D0x%x Response=3D0x%x (expected 0x%x)\n", __FUNCTION__, (UINT32)RequestType, - Response.Type + Response->Type, + ResponseType )); return EFI_DEVICE_ERROR; =20 @@ -553,6 +564,34 @@ VirtioGpuSendCommand ( return Status; } =20 +/** + Simplified version of VirtioGpuSendCommandWithReply() for commands + which do not send back any data. +**/ +STATIC +EFI_STATUS +VirtioGpuSendCommand ( + IN OUT VGPU_DEV *VgpuDev, + IN VIRTIO_GPU_CONTROL_TYPE RequestType, + IN BOOLEAN Fence, + IN OUT volatile VIRTIO_GPU_CONTROL_HEADER *Header, + IN UINTN RequestSize + ) +{ + volatile VIRTIO_GPU_CONTROL_HEADER Response; + + return VirtioGpuSendCommandWithReply ( + VgpuDev, + RequestType, + Fence, + Header, + RequestSize, + VirtioGpuRespOkNodata, + &Response, + sizeof (Response) + ); +} + /** The following functions send requests to the VirtIo GPU device model, aw= ait the answer from the host, and return a status. They share the following --=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 (#88605): https://edk2.groups.io/g/devel/message/88605 Mute This Topic: https://groups.io/mt/90331438/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- From nobody Fri May 17 04:49:27 2024 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+88608+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+88608+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649406225; cv=none; d=zohomail.com; s=zohoarc; b=GjscOM7rpX/7hct+dr0wubRx2IE2/4OMwUOrEkBZbeMirADz15zvwYvoVSk3aMnVTgOV7sU3n2c0L3owRNrRxlcQdeSfjh51SjeONspYwlfII9565W+MaMx8F5SvQSmFNJzC87bbVsahI7O0KP+W2tMFHvfySFnZ9zk6AYi2E58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649406225; 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=LCmE+Q8xmtsIEmGsmfs3eGjDnBNzdx70I5wc4ylTTco=; b=esyph3r1D+3hPd+r2R8zjpu2qTZCjfJSq90gEd6WxQ/Uhwu6n5A928U+m5yMFmD4qjruz/Q6wedUCnrWRVl2P8fasLzoI0uQ4qybr+Pfi6pc1RYvjOdsmDM7UP3oMQWZrwyjJAZyWu8/t6IGfI0zxmpgwyE9KGHJxxWBW6+2x7I= 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+88608+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 1649406225558700.1971729211988; Fri, 8 Apr 2022 01:23:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SYUSYY1788612xot0v8czaQX; Fri, 08 Apr 2022 01:23:45 -0700 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.3472.1649406224243196558 for ; Fri, 08 Apr 2022 01:23:44 -0700 X-Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-R6so7ENHM2qgK-FLGKegMg-1; Fri, 08 Apr 2022 04:23:37 -0400 X-MC-Unique: R6so7ENHM2qgK-FLGKegMg-1 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3A011C08DB5; Fri, 8 Apr 2022 08:23:36 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C442840E80E0; Fri, 8 Apr 2022 08:23:36 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CB6DC180062D; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 2/6] OvmfPkg/VirtioGpuDxe: add GetDisplayInfo to virtio-gpu spec header. Date: Fri, 8 Apr 2022 10:23:29 +0200 Message-Id: <20220408082333.3023758-3-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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: fdzXAYNqUgbXPMgXIQ4xgy4Xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649406225; bh=s11NZruEsgBVr1Mmvs+PWYfHLBh1KWeflT/j/h2rmKE=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=O+vEKdOoXNxHw2J9qSd8aTpD284atxa9JVcLR/tY7UMcn7xEDPdIicNXVE6IlH65n34 LBW8gi+nCHTAtuUHliXVT4/SrYWhBWOte+ySL4bfLS1K75oHXW3K+zlm+a7rF8yrMbALT 3tDPIiXsbGx9EVRG5piHszvh7+wesYVL0G0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649406226683100015 Content-Type: text/plain; charset="utf-8"; x-default="true" Add GetDisplayInfo command, reply and data struct to the virtio-gpu specification header file. Signed-off-by: Gerd Hoffmann --- OvmfPkg/Include/IndustryStandard/VirtioGpu.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Include/IndustryStandard/VirtioGpu.h b/OvmfPkg/Include= /IndustryStandard/VirtioGpu.h index 12559ccef5b1..13f719d4c0f2 100644 --- a/OvmfPkg/Include/IndustryStandard/VirtioGpu.h +++ b/OvmfPkg/Include/IndustryStandard/VirtioGpu.h @@ -37,6 +37,7 @@ typedef enum { // // - create/release a host-side 2D resource, // + VirtioGpuCmdGetDisplayInfo =3D 0x0100, VirtioGpuCmdResourceCreate2d =3D 0x0101, VirtioGpuCmdResourceUnref =3D 0x0102, // @@ -64,7 +65,8 @@ typedef enum { // // Success code for all of the above commands. // - VirtioGpuRespOkNodata =3D 0x1100, + VirtioGpuRespOkNodata =3D 0x1100, + VirtioGpuRespOkDisplayInfo =3D 0x1101, } VIRTIO_GPU_CONTROL_TYPE; =20 // @@ -207,4 +209,19 @@ typedef struct { } VIRTIO_GPU_RESOURCE_FLUSH; #pragma pack () =20 +// +// Response structure for VirtioGpuCmdGetDisplayInfo +// +#define VIRTIO_GPU_MAX_SCANOUTS 16 +#pragma pack (1) +typedef struct { + VIRTIO_GPU_CONTROL_HEADER Header; + struct { + VIRTIO_GPU_RECTANGLE Rectangle; + UINT32 Enabled; + UINT32 Flags; + } Pmodes[VIRTIO_GPU_MAX_SCANOUTS]; +} VIRTIO_GPU_RESP_DISPLAY_INFO; +#pragma pack () + #endif // _VIRTIO_GPU_H_ --=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 (#88608): https://edk2.groups.io/g/devel/message/88608 Mute This Topic: https://groups.io/mt/90331441/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- From nobody Fri May 17 04:49:27 2024 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+88607+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+88607+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649406224; cv=none; d=zohomail.com; s=zohoarc; b=j1NHkncPm6u+TlAmwNpUc4pwC8oLpQ94F29m36rtHgLCZnWYPVRX4gtqwRqQYZKSUm/yiw1coL9fbKhiSV+8y1JLydyfcTvxuLL0dQdyQFwwEr4RIClHmtRczU8zRfgMnShOUO/3vg1Z1zTjWzld6doYeOvIFA/SZIEfBT3BdpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649406224; 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=45kvN5qpWaIyAE5xxqs/LofC9Pl+YmSmLL3tEnNZn9w=; b=OIK7XWHxgQD91EPxCOv/3VAbYyitSqSD+cDs9avKVeSlxJaPXIR8TVAaMCbQYNh/3C5oW4db5ePYsaWMd9Dzl33TSkoOdzardzT3dtmmTrqGzaBtHnkDeU6jGa6yO5uxGqkrwHNQmD0psJb+AKmUWESSY4DNZLsX5jlyVFbuV3E= 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+88607+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 1649406224141435.0960282843133; Fri, 8 Apr 2022 01:23:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dJhqYY1788612xqZ6Ec2hPqd; Fri, 08 Apr 2022 01:23:43 -0700 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.web10.3398.1649406222988409676 for ; Fri, 08 Apr 2022 01:23:43 -0700 X-Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-308-AOoWvD8gPuCWWhV78qXRLA-1; Fri, 08 Apr 2022 04:23:41 -0400 X-MC-Unique: AOoWvD8gPuCWWhV78qXRLA-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD05328EA6FB; Fri, 8 Apr 2022 08:23:40 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C531A9D42; Fri, 8 Apr 2022 08:23:36 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CEB541800987; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 3/6] OvmfPkg/VirtioGpuDxe: add VirtioGpuGetDisplayInfo Date: Fri, 8 Apr 2022 10:23:30 +0200 Message-Id: <20220408082333.3023758-4-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: uKCEgQWb18mGLYxaCwGb9rubx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649406223; bh=23VlMW5BnywkAe9gNZsRP+AWZ2i/o9qH7SFRfm5Czu0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=n/SJnvZ0+NaTGV9B1TDMKagwb1w/c064F2uIZPCaGe0ElUPTCEwrDk37ao2oh9t3uUP AgVI09tlbZ+SQbkET2kQ9ukMNwm7AZXPfHefKGH1pc7gwny+b5XGQOHIMa0kFvG3TFnmL eViYtp2n+d8f7XpnhLkWZtlaZq4DTm4+xB8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649406224648100007 Content-Type: text/plain; charset="utf-8"; x-default="true" Add support for sending a GetDisplayInfo command. Signed-off-by: Gerd Hoffmann --- OvmfPkg/VirtioGpuDxe/VirtioGpu.h | 6 ++++++ OvmfPkg/VirtioGpuDxe/Commands.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h b/OvmfPkg/VirtioGpuDxe/Virtio= Gpu.h index 2155b261d43e..1d781088bb3f 100644 --- a/OvmfPkg/VirtioGpuDxe/VirtioGpu.h +++ b/OvmfPkg/VirtioGpuDxe/VirtioGpu.h @@ -366,6 +366,12 @@ VirtioGpuResourceFlush ( IN UINT32 ResourceId ); =20 +EFI_STATUS +VirtioGpuGetDisplayInfo ( + IN OUT VGPU_DEV *VgpuDev, + volatile VIRTIO_GPU_RESP_DISPLAY_INFO *Response + ); + /** Release guest-side and host-side resources that are related to an initia= lized VGPU_GOP.Gop. diff --git a/OvmfPkg/VirtioGpuDxe/Commands.c b/OvmfPkg/VirtioGpuDxe/Command= s.c index b9a3ea923021..4318d3d771c5 100644 --- a/OvmfPkg/VirtioGpuDxe/Commands.c +++ b/OvmfPkg/VirtioGpuDxe/Commands.c @@ -828,3 +828,23 @@ VirtioGpuResourceFlush ( sizeof Request ); } + +EFI_STATUS +VirtioGpuGetDisplayInfo ( + IN OUT VGPU_DEV *VgpuDev, + volatile VIRTIO_GPU_RESP_DISPLAY_INFO *Response + ) +{ + volatile VIRTIO_GPU_CONTROL_HEADER Request; + + return VirtioGpuSendCommandWithReply ( + VgpuDev, + VirtioGpuCmdGetDisplayInfo, + FALSE, // Fence + &Request, + sizeof Request, + VirtioGpuRespOkDisplayInfo, + &Response->Header, + sizeof *Response + ); +} --=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 (#88607): https://edk2.groups.io/g/devel/message/88607 Mute This Topic: https://groups.io/mt/90331440/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- From nobody Fri May 17 04:49:27 2024 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+88611+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+88611+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649406238; cv=none; d=zohomail.com; s=zohoarc; b=GflnBtAMUN4Uk2nE3B8fxywlR30QEN1u9DADE5xpdn2HSUCNrFNYsUCd8neKFbeNU3ubB+IA5OVIEjzdfGSq48/IFKkQBpKcAtB+IfdxoArnGts8gqY6tmAlPn2ZCV5YxPSi9oZDYDHgM0KqEacll+FVF8lYypFOp9HZ2kINHNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649406238; 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=IOAIu3Zqr0tzewnRDl3ZcEYwYvU4R+Ixo/gOpDBgNmQ=; b=WWHnY+AqKoxZ8hb2DMGT3Ot4HgC/XOJOpii1nfLVYCVwRF0+VLMOEjtzzhuSd23cz0RQQdvdpKW9+HaDMiPPCMrkd4ob1XIDtBSeq0WX95eYBPavB48ePoWbJCiijh81qP1v0aIXHmRr/JV5cKkuSGmyb6iDYNd59Cxi/cs440E= 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+88611+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 1649406238205892.959192000979; Fri, 8 Apr 2022 01:23:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id QvV9YY1788612xmLtGqCWNHy; Fri, 08 Apr 2022 01:23:57 -0700 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.3400.1649406237059714623 for ; Fri, 08 Apr 2022 01:23:57 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-367-aja8F9ToMSC0ERQ_0Lz2GQ-1; Fri, 08 Apr 2022 04:23:50 -0400 X-MC-Unique: aja8F9ToMSC0ERQ_0Lz2GQ-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA80286B8A3; Fri, 8 Apr 2022 08:23:49 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CFFC2166BA2; Fri, 8 Apr 2022 08:23:38 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D23F91800989; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 4/6] OvmfPkg/VirtioGpuDxe: use GopQueryMode in GopSetMode Date: Fri, 8 Apr 2022 10:23:31 +0200 Message-Id: <20220408082333.3023758-5-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: TMw4p1FzGc8KZiQaCA9Xi9VAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649406237; bh=AcGKIk8wGVpi7VuoxXK25Zk5IQiW6Wxikw90/ZW7AzE=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=kmEZ0bs77eESiiSQZAR4nq2C5MVjaBMDj1dja5idiDaQRFmsnkg8SiHi2Bs4yVIxWD2 h69taawXPXzrn3ZZDjMC6gtftucbbPH8Kj2+S3eEdtTB1EQGD807T2yMq0+R9Y+6UtnWP CyTWg4ypBoWHHb0vBnnKkGZ6CSyYex3eDiU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649406238805100003 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 --- 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; =20 EFI_STATUS Status; EFI_STATUS Status2; =20 - if (ModeNumber >=3D ARRAY_SIZE (mGopResolutions)) { - return EFI_UNSUPPORTED; + Status =3D GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo); + if (Status !=3D EFI_SUCCESS) { + return Status; } =20 VgpuGop =3D 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 buf= fer // operation. // - NewNumberOfBytes =3D mGopResolutions[ModeNumber].Width * - mGopResolutions[ModeNumber].Height * sizeof (UINT32); + NewNumberOfBytes =3D GopModeInfo->HorizontalResolution * + GopModeInfo->VerticalResolution * sizeof (UINT32); NewNumberOfPages =3D EFI_SIZE_TO_PAGES (NewNumberOfBytes); Status =3D 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 =3D 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 =3D ModeNumber; - VgpuGop->GopModeInfo.HorizontalResolution =3D - mGopResolutions[ModeNumber].Width; - VgpuGop->GopModeInfo.VerticalResolution =3D mGopResolutions[ModeNumber].= Height; - VgpuGop->GopModeInfo.PixelsPerScanLine =3D mGopResolutions[ModeNumber].= Width; + VgpuGop->GopMode.Mode =3D ModeNumber; + VgpuGop->GopModeInfo =3D *GopModeInfo; + FreePool (GopModeInfo); return EFI_SUCCESS; =20 DetachBackingStore: @@ -435,6 +436,7 @@ GopSetMode ( CpuDeadLoop (); } =20 + FreePool (GopModeInfo); return Status; } =20 --=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 (#88611): https://edk2.groups.io/g/devel/message/88611 Mute This Topic: https://groups.io/mt/90331444/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- From nobody Fri May 17 04:49:27 2024 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+88609+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+88609+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649406232; cv=none; d=zohomail.com; s=zohoarc; b=MhzMW3KRB67Zx/LdvcCkDFaK7a1HvOYfe6axqGUbJebBHg0tfy7wq+DDh631Zwr/3evXoXzxUU1MPaBaejWkY+0PEbH2t4TEW2VglFCZoVpMqy6kdtPda7+8zQi0fTB+8iA+Uk8wv/MobdowLomNCHcNcSPvdO0bfj+mhAOgi4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649406232; 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=6RUQ/AkSpW/T5c5jDwTtjF4ydM6h7ncDcMez/pumL3s=; b=YawB/19ckq4ZMsQbcks9J7b9/2o43GUKbgSlbT5Oe37HJXeAQ+nCpG4EN01QFB2rBbolKqN/de/6xMzr9CPBPYotiqi/WbGjJ0U3QpBtjGry/Q+MSlCrk8B212NwFX5w+4UGhebHkAIEfSGRrpOwSIhtFads3011mgCVpa9vZa4= 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+88609+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 164940623280041.797843276816934; Fri, 8 Apr 2022 01:23:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EwOeYY1788612xstVuavQDxN; Fri, 08 Apr 2022 01:23:52 -0700 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.3473.1649406231715558797 for ; Fri, 08 Apr 2022 01:23:51 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-210-Kkyi_TVLM6OThITnuj8sWw-1; Fri, 08 Apr 2022 04:23:50 -0400 X-MC-Unique: Kkyi_TVLM6OThITnuj8sWw-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC51318E0042; Fri, 8 Apr 2022 08:23:49 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39D782166BA3; Fri, 8 Apr 2022 08:23:42 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D5838180098A; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 5/6] OvmfPkg/VirtioGpuDxe: move code to GopInitialize Date: Fri, 8 Apr 2022 10:23:32 +0200 Message-Id: <20220408082333.3023758-6-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: x8bE9oNFARvL2uCVmvBYLmbRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649406232; bh=dM8RlTzxu0BBy6KEbWNZvcUuuNnX4Dg3rdBpY5OlN0c=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Q25KEAZ4wZusEkwpJg51XTyorrwFPJ9jNLG3TUzWGlLAyRTVKup4qDV7LdDPz0NLc+5 Ur+q8qiS3TBtEML7tp85tygLdqlz1+2l8BLD3DF1pqsDNP5P7QyacjEvAJahq982QdGta Wf3DFVJu4XwMixVS+BUr4hq8oXqA6J2kBQg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649406234707100003 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 --- 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[] =3D { #define VGPU_GOP_FROM_GOP(GopPointer) \ CR (GopPointer, VGPU_GOP, Gop, VGPU_GOP_SIG) =20 +STATIC +VOID +EFIAPI +GopInitialize ( + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This + ) +{ + VGPU_GOP *VgpuGop; + + VgpuGop =3D 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 =3D &VgpuGop->GopMode; + + VgpuGop->GopMode.MaxMode =3D (UINT32)(ARRAY_SIZE (mGopResolutions)); + VgpuGop->GopMode.Info =3D &VgpuGop->GopModeInfo; + VgpuGop->GopMode.SizeOfInfo =3D sizeof VgpuGop->GopModeInfo; + + VgpuGop->GopModeInfo.PixelFormat =3D PixelBltOnly; +} + // // EFI_GRAPHICS_OUTPUT_PROTOCOL member functions. // @@ -207,7 +233,7 @@ GopQueryMode ( { EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo; =20 - if (ModeNumber >=3D ARRAY_SIZE (mGopResolutions)) { + if (ModeNumber >=3D This->Mode->MaxMode) { return EFI_INVALID_PARAMETER; } =20 @@ -247,6 +273,11 @@ GopSetMode ( EFI_STATUS Status; EFI_STATUS Status2; =20 + if (!This->Mode) { + // SetMode() call in InitVgpuGop() triggers this. + GopInitialize (This); + } + Status =3D GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo); if (Status !=3D EFI_SUCCESS) { return Status; @@ -259,20 +290,6 @@ GopSetMode ( // calls. // if (VgpuGop->ResourceId =3D=3D 0) { - // - // Set up the Gop -> GopMode -> GopModeInfo pointer chain, and the oth= er - // (nonzero) constant fields. - // - // No direct framebuffer access is supported, only Blt() is. - // - VgpuGop->Gop.Mode =3D &VgpuGop->GopMode; - - VgpuGop->GopMode.MaxMode =3D (UINT32)(ARRAY_SIZE (mGopResolutions)); - VgpuGop->GopMode.Info =3D &VgpuGop->GopModeInfo; - VgpuGop->GopMode.SizeOfInfo =3D sizeof VgpuGop->GopModeInfo; - - VgpuGop->GopModeInfo.PixelFormat =3D PixelBltOnly; - // // This is the first time we create a host side resource. // --=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 (#88609): https://edk2.groups.io/g/devel/message/88609 Mute This Topic: https://groups.io/mt/90331442/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- From nobody Fri May 17 04:49:27 2024 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+88610+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+88610+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1649406237; cv=none; d=zohomail.com; s=zohoarc; b=X6QdZ8YDyRQxzs4PAj6QFw62H+DmdOTX4bPtyr3Ur465H0JI+O3JsEs1pMwhU454u1Myhz7R+XULIavaKPHTGXYocPtlNYsgBfrKe2nP/zSbsonaFxHe/aXchV/tBZyMtwQxGdXKXpwFsnLFKV21Bx52w50rE/RXDIIKnNAnIyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649406237; 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=lPlZsyNasSnuqmZrAqkic51bX4fvjnZici/T/9/SWcM=; b=Btfpcz2ETSp2upqDyQAowym3uJACJKgTE0aufLDceTEkhQWB6ioaFHNLXGfEx8ZF1nkvSgrvxJLy7JVZiaOX4uVsAJ+OrqHoIN3dMq6zoJu2coCPb0p/HXSxGaBBVZ76dJI8w/WHCH8qM61NA04Uv5crxB9+b2Vk0pzdTumwZ2M= 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+88610+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 1649406237280994.9372438279065; Fri, 8 Apr 2022 01:23:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 26beYY1788612x8nRntvM7WY; Fri, 08 Apr 2022 01:23:56 -0700 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.3474.1649406236133547571 for ; Fri, 08 Apr 2022 01:23:56 -0700 X-Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-386-MGMzz2MCMwWzbnSfjXO61Q-1; Fri, 08 Apr 2022 04:23:51 -0400 X-MC-Unique: MGMzz2MCMwWzbnSfjXO61Q-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 796A33811F2D; Fri, 8 Apr 2022 08:23:51 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 21ED0145B96C; Fri, 8 Apr 2022 08:23:51 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D88C8180098B; Fri, 8 Apr 2022 10:23:33 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Jiewen Yao , Pawel Polawski , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v3 6/6] OvmfPkg/VirtioGpuDxe: query native display resolution from host Date: Fri, 8 Apr 2022 10:23:33 +0200 Message-Id: <20220408082333.3023758-7-kraxel@redhat.com> In-Reply-To: <20220408082333.3023758-1-kraxel@redhat.com> References: <20220408082333.3023758-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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: 9TAUWBvh7NzoJmXy7z2uDiEBx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649406236; bh=R0ABOWOV+wrvAMcJyX4NVn0SY+L1k3fklkjctCDYKOc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=pVf7X9OKsnxkxWXapOH40JgPKPS5ezQJkjDZ8ePTrjnusAiXgB3Mw+fSr/hA3A8yq3/ IF3L36P9KfreY3uPIwrWKQgSeRnmsQ3YDK4FJjDYHGgaWicLTs8nNeFvJC8Mjv83uWd89 BG8doRTzmBD8s5madnEPgu1uGyOsTFj4CaM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649406238810100004 Content-Type: text/plain; charset="utf-8"; x-default="true" 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 (#88610): https://edk2.groups.io/g/devel/message/88610 Mute This Topic: https://groups.io/mt/90331443/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-