From 84195804a1631c88c1356438d22f4a51681d8c55 Mon Sep 17 00:00:00 2001
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Date: Mon, 17 Jun 2024 10:30:07 +0200
Subject: [PATCH] BootLogoLib: align logo coords to be even

If we draw logo at odd coords then BootLogoLib goes into exception and
boot process ends:

Synchronous Exception at 0x00000101FB943E48
PC 0x0101FB943E48 (0x0101FB93F000+0x00004E48) [ 0] QemuVideoDxe.dll
PC 0x0101FB943314 (0x0101FB93F000+0x00004314) [ 0] QemuVideoDxe.dll
PC 0x0101FB92F798 (0x0101FB92D000+0x00002798) [ 1] ConSplitterDxe.dll
PC 0x0101FBA96BC4 (0x0101FBA8E000+0x00008BC4) [ 2] BdsDxe.dll
PC 0x0101FF7FDF50 (0x0101FF7F3000+0x0000AF50) [ 3] DxeCore.dll

This change resizes logo from 193x58 to 194x58px to make it's sizes
even. And if coords are odd then they are bumped a bit to make things
work.

Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>

This is a temporary workaround for an alignment problem in EDK2/qemu, see  the
discussion at https://mail.gnu.org/archive/html/qemu-devel/2024-06/msg02964.html.

Upstream-Status: Inappropriate [workaround]
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../Library/BootLogoLib/BootLogoLib.c         |   4 ++++
 MdeModulePkg/Logo/Logo.bmp                    | Bin 12446 -> 34010 bytes
 2 files changed, 4 insertions(+)

diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
index 478ec2d40e..3b7b5f3146 100644
--- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
+++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c
@@ -205,6 +205,10 @@ BootLogoEnableLogo (
     DestX += OffsetX;
     DestY += OffsetY;
 
+    // align logo to even coords
+    if (DestX % 2 != 0) DestX++;
+    if (DestY % 2 != 0) DestY++;
+
     if ((DestX >= 0) && (DestY >= 0)) {
       if (GraphicsOutput != NULL) {
         Status = GraphicsOutput->Blt (
diff --git a/MdeModulePkg/Logo/Logo.bmp b/MdeModulePkg/Logo/Logo.bmp
index 3e85229e17595ba1f9c59e13692a4f8362ebc850..136345a56ac44e3ea8d3c91114b5a2676dc90e2a 100644
GIT binary patch
-- 
2.34.1

