diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2022-01-17 10:58:16 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-01-29 17:04:21 +0000 |
commit | 55c05427b90230f15f4807a4daa2876e5e2f4998 (patch) | |
tree | 28c78321c8f3ea2f6d76eafc2f1fb5c59d0ee960 /OvmfPkg/QemuVideoDxe | |
parent | 336da55ca8db7777907362daf6e3ca5c9357cf27 (diff) | |
download | edk2-55c05427b90230f15f4807a4daa2876e5e2f4998.tar.gz edk2-55c05427b90230f15f4807a4daa2876e5e2f4998.tar.bz2 edk2-55c05427b90230f15f4807a4daa2876e5e2f4998.zip |
OvmfPkg/QemuVideoDxe: factor out QemuVideoBochsAddMode
Add helper function to add a video mode to the list of modes.
Move code. Minor debug logging tweaks, no other functional
change.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'OvmfPkg/QemuVideoDxe')
-rw-r--r-- | OvmfPkg/QemuVideoDxe/Initialize.c | 77 |
1 files changed, 47 insertions, 30 deletions
diff --git a/OvmfPkg/QemuVideoDxe/Initialize.c b/OvmfPkg/QemuVideoDxe/Initialize.c index 2b174d13fa..8c5c9176ad 100644 --- a/OvmfPkg/QemuVideoDxe/Initialize.c +++ b/OvmfPkg/QemuVideoDxe/Initialize.c @@ -245,16 +245,53 @@ STATIC QEMU_VIDEO_BOCHS_MODES QemuVideoBochsModes[] = { #define QEMU_VIDEO_BOCHS_MODE_COUNT \
(ARRAY_SIZE (QemuVideoBochsModes))
+STATIC
+VOID
+QemuVideoBochsAddMode (
+ QEMU_VIDEO_PRIVATE_DATA *Private,
+ UINT32 AvailableFbSize,
+ UINT32 Width,
+ UINT32 Height
+ )
+{
+ QEMU_VIDEO_MODE_DATA *ModeData = Private->ModeData + Private->MaxMode;
+ UINTN RequiredFbSize;
+
+ RequiredFbSize = (UINTN)Width * Height * 4;
+ if (RequiredFbSize > AvailableFbSize) {
+ DEBUG ((
+ DEBUG_INFO,
+ "Skipping Bochs Mode %dx%d, 32-bit (not enough vram)\n",
+ Width,
+ Height
+ ));
+ return;
+ }
+
+ ModeData->InternalModeIndex = (UINT32)Private->MaxMode;
+ ModeData->HorizontalResolution = Width;
+ ModeData->VerticalResolution = Height;
+ ModeData->ColorDepth = 32;
+ DEBUG ((
+ DEBUG_INFO,
+ "Adding Bochs Internal Mode %d: %dx%d, %d-bit\n",
+ ModeData->InternalModeIndex,
+ ModeData->HorizontalResolution,
+ ModeData->VerticalResolution,
+ ModeData->ColorDepth
+ ));
+
+ Private->MaxMode++;
+}
+
EFI_STATUS
QemuVideoBochsModeSetup (
QEMU_VIDEO_PRIVATE_DATA *Private,
BOOLEAN IsQxl
)
{
- UINT32 AvailableFbSize;
- UINT32 Index;
- QEMU_VIDEO_MODE_DATA *ModeData;
- QEMU_VIDEO_BOCHS_MODES *VideoMode;
+ UINT32 AvailableFbSize;
+ UINT32 Index;
//
// Fetch the available framebuffer size.
@@ -343,34 +380,14 @@ QemuVideoBochsModeSetup ( return EFI_OUT_OF_RESOURCES;
}
- ModeData = Private->ModeData;
- VideoMode = &QemuVideoBochsModes[0];
for (Index = 0; Index < QEMU_VIDEO_BOCHS_MODE_COUNT; Index++) {
- UINTN RequiredFbSize;
-
- RequiredFbSize = (UINTN)VideoMode->Width * VideoMode->Height * 4;
- if (RequiredFbSize <= AvailableFbSize) {
- ModeData->InternalModeIndex = Index;
- ModeData->HorizontalResolution = VideoMode->Width;
- ModeData->VerticalResolution = VideoMode->Height;
- ModeData->ColorDepth = 32;
- DEBUG ((
- DEBUG_INFO,
- "Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit\n",
- (INT32)(ModeData - Private->ModeData),
- ModeData->InternalModeIndex,
- ModeData->HorizontalResolution,
- ModeData->VerticalResolution,
- ModeData->ColorDepth
- ));
-
- ModeData++;
- }
-
- VideoMode++;
+ QemuVideoBochsAddMode (
+ Private,
+ AvailableFbSize,
+ QemuVideoBochsModes[Index].Width,
+ QemuVideoBochsModes[Index].Height
+ );
}
- Private->MaxMode = ModeData - Private->ModeData;
-
return EFI_SUCCESS;
}
|