Reviewed-by: Andrei Warkentin ________________________________ From: Samer El-Haj-Mahmoud Sent: Tuesday, July 21, 2020 9:01 PM To: devel@edk2.groups.io Cc: Leif Lindholm ; Pete Batard ; Andrei Warkentin ; Ard Biesheuvel Subject: [edk2-platform][PATCH v1 3/3] Platforms/RaspberryPi: Fix GOP FrameBufferSize returned by SetMode() GOP SetMode() returns the frame buffer size in FrameBufferSize. The value is obtained from the RPi mailbox call to AllocateBuffer (tag RPI_MBOX_ALLOC_FB), which for a native resolution of 1920 x 1080 returns 8355840 bytes. The size should be 1920 x 1080 x 4 (bytes/pixel), or 8294400 bytes, as defined by the UEFI Spec: "FrameBufferSize : Amount of frame buffer needed to support the active mode as defined by PixelsPerScanLine x VerticalResolution x PixelElementSize". This change forces the returned FrameBufferSize to match the value required by UEFI Spec. The actual buffer allocted by the VPU is larger due to the alignment request when calling RPI_MBOX_ALLOC_FB (32 bytes). A vertical resolution of 1080 aligns to 1088 on 32-bytes, resulting in the increased buffer size (1920 x 1088 x 4 = 8355840). This fixes the SetMode_Conf failure reported by SCT tests at https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpftf%2FRPi4%2Fissues%2F73&data=02%7C01%7Cawarkentin%40vmware.com%7C48ef278196e648255b8a08d82de317fe%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637309800670078866&sdata=Y3sRmqyjYpzRQ8H%2BVnXPtlKZP9yaOy%2FXqBr%2B8vNMLKM%3D&reserved=0 Cc: Leif Lindholm Cc: Pete Batard Cc: Andrei Warkentin Cc: Ard Biesheuvel Signed-off-by: Samer El-Haj-Mahmoud --- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c index f50ffc816cf1..a42e4d9b8a1b 100644 --- a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c +++ b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c @@ -279,7 +279,8 @@ DisplaySetMode ( This->Mode->Info->PixelsPerScanLine = Mode->Width; This->Mode->SizeOfInfo = sizeof (*This->Mode->Info); This->Mode->FrameBufferBase = FbBase; - This->Mode->FrameBufferSize = FbSize; + This->Mode->FrameBufferSize = Mode->Width * Mode->Height * PI3_BYTES_PER_PIXEL; + DEBUG((DEBUG_INFO, "Reported Mode->FrameBufferSize is %u\n", This->Mode->FrameBufferSize)); ClearScreen (This); return EFI_SUCCESS; -- 2.17.1