From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4AA3E225E966E for ; Wed, 21 Mar 2018 17:19:15 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2018 17:25:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,341,1517904000"; d="scan'208";a="26481706" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga008.fm.intel.com with ESMTP; 21 Mar 2018 17:25:45 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 21 Mar 2018 17:25:45 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 21 Mar 2018 17:25:45 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.80]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.226]) with mapi id 14.03.0319.002; Thu, 22 Mar 2018 08:25:43 +0800 From: "Yao, Jiewen" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "Dong, Eric" Thread-Topic: [Patch 2/2] MdeModulePkg/CapsuleApp: Center bitmap at bottom of screen Thread-Index: AQHTwVl8IPsPepqrt021mgcpPxztIaPbZeKQ Date: Thu, 22 Mar 2018 00:25:42 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AB0B3F2@shsmsx102.ccr.corp.intel.com> References: <20180321211325.16388-1-michael.d.kinney@intel.com> <20180321211325.16388-3-michael.d.kinney@intel.com> In-Reply-To: <20180321211325.16388-3-michael.d.kinney@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDZjZWEyYmMtNTZiMC00MzM0LWI1ZGItNDBhODFjZjVhNTlmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJkUXFITk1UVHRSc2tGMUFPZkNJaG5za0szZXFYdCtFUThGY1N5dXllbEV2ZDJsenlxWWdOYnFjVFRuaG1pR2gxIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch 2/2] MdeModulePkg/CapsuleApp: Center bitmap at bottom of screen X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Mar 2018 00:19:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Kinney, Michael D > Sent: Thursday, March 22, 2018 5:13 AM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen ; Zeng, Star ; > Dong, Eric > Subject: [Patch 2/2] MdeModulePkg/CapsuleApp: Center bitmap at bottom of > screen >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D907 >=20 > When -G option is used to convert a BMP file to a UX capsule, > the bitmap is centered horizontally and placed in the lower > half of the screen below the boot logo. >=20 > This matches examples shown in the following pages: >=20 > https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/user-ex= p > erience-for-uefi-firmware-updates > https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/boot-sc= r > een-components >=20 > Checks are also made to make sure the bitmap provided > fits in the current GOP mode. >=20 > Cc: Jiewen Yao > Cc: Star Zeng > Cc: Eric Dong > Signed-off-by: Michael D Kinney > Contributed-under: TianoCore Contribution Agreement 1.1 > --- > MdeModulePkg/Application/CapsuleApp/CapsuleApp.c | 63 > ++++++++++++++++++++-- > MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf | 3 +- > 2 files changed, 61 insertions(+), 5 deletions(-) >=20 > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > index b9ff812179..e1e48befc2 100644 > --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -173,15 +174,21 @@ CreateBmpFmp ( > EFI_DISPLAY_CAPSULE *DisplayCapsule; > EFI_STATUS Status; > EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; > + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; > + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *GopBlt; > + UINTN GopBltSize; > + UINTN Height; > + UINTN Width; >=20 > Status =3D gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, > (VOID **)&Gop); > if (EFI_ERROR(Status)) { > Print(L"CapsuleApp: NO GOP is found.\n"); > return EFI_UNSUPPORTED; > } > + Info =3D Gop->Mode->Info; > Print(L"Current GOP: Mode - %d, ", Gop->Mode->Mode); > - Print(L"HorizontalResolution - %d, ", > Gop->Mode->Info->HorizontalResolution); > - Print(L"VerticalResolution - %d\n", Gop->Mode->Info->VerticalResolutio= n); > + Print(L"HorizontalResolution - %d, ", Info->HorizontalResolution); > + Print(L"VerticalResolution - %d\n", Info->VerticalResolution); > // HorizontalResolution >=3D BMP_IMAGE_HEADER.PixelWidth > // VerticalResolution >=3D BMP_IMAGE_HEADER.PixelHeight >=20 > @@ -207,6 +214,35 @@ CreateBmpFmp ( > goto Done; > } >=20 > + GopBlt =3D NULL; > + Status =3D TranslateBmpToGopBlt ( > + BmpBuffer, > + FileSize, > + &GopBlt, > + &GopBltSize, > + &Height, > + &Width > + ); > + if (EFI_ERROR(Status)) { > + Print(L"CapsuleApp: BMP image (%s) is not valid.\n", BmpName); > + goto Done; > + } > + if (GopBlt !=3D NULL) { > + FreePool (GopBlt); > + } > + Print(L"BMP image (%s), Width - %d, Height - %d\n", BmpName, Width, > Height); > + > + if (Height > Info->VerticalResolution) { > + Status =3D EFI_INVALID_PARAMETER; > + Print(L"CapsuleApp: BMP image (%s) height is larger than current > resolution.\n", BmpName); > + goto Done; > + } > + if (Width > Info->HorizontalResolution) { > + Status =3D EFI_INVALID_PARAMETER; > + Print(L"CapsuleApp: BMP image (%s) width is larger than current > resolution.\n", BmpName); > + goto Done; > + } > + > FullCapsuleBufferSize =3D sizeof(EFI_DISPLAY_CAPSULE) + FileSize; > FullCapsuleBuffer =3D AllocatePool(FullCapsuleBufferSize); > if (FullCapsuleBuffer =3D=3D NULL) { > @@ -226,8 +262,27 @@ CreateBmpFmp ( > DisplayCapsule->ImagePayload.ImageType =3D 0; // BMP > DisplayCapsule->ImagePayload.Reserved =3D 0; > DisplayCapsule->ImagePayload.Mode =3D Gop->Mode->Mode; > - DisplayCapsule->ImagePayload.OffsetX =3D 0; > - DisplayCapsule->ImagePayload.OffsetY =3D 0; > + > + // > + // Center the bitmap horizontally > + // > + DisplayCapsule->ImagePayload.OffsetX =3D > (UINT32)((Info->HorizontalResolution - Width) / 2); > + > + // > + // Put bitmap 3/4 down the display. If bitmap is too tall, then align= bottom > + // of bitmap at bottom of display. > + // > + DisplayCapsule->ImagePayload.OffsetY =3D > + MIN ( > + (UINT32)(Info->VerticalResolution - Height), > + (UINT32)(((3 * Info->VerticalResolution) - (2 * Height)) / 4) > + ); > + > + Print(L"BMP image (%s), OffsetX - %d, OffsetY - %d\n", > + BmpName, > + DisplayCapsule->ImagePayload.OffsetX, > + DisplayCapsule->ImagePayload.OffsetY > + ); >=20 > CopyMem((DisplayCapsule + 1), BmpBuffer, FileSize); >=20 > diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > index b06c4ea1bc..3a67c6b909 100644 > --- a/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf > @@ -4,7 +4,7 @@ > # This application can trigger capsule update process. It can also > # generate capsule image, or dump capsule variable information. > # > -# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved. > +# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved. > # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the= BSD > License > # which accompanies this distribution. The full text of the license ma= y be > found at > @@ -63,6 +63,7 @@ [LibraryClasses] > UefiRuntimeServicesTableLib > UefiLib > PrintLib > + BmpSupportLib >=20 > [UserExtensions.TianoCore."ExtraFiles"] > CapsuleAppExtra.uni > -- > 2.14.2.windows.3