OvmfPkg: QemuVideoDxe: filter BOCHS modes vs. available frame buffer size

In the next patch we'll add many new BOCHS modes, some of which require
large frame buffers.

The size of the QXL VGA compatibility framebuffer can be changed with the

  -global qxl-vga.vgamem_mb=$NUM_MB

QEMU option.

If $NUM_MB would exceed 32, then the following two QEMU options are
necessary instead:

  -global qxl-vga.vgamem_mb=$NUM_MB         \
  -global qxl-vga.ram_size_mb=$((NUM_MB*2))

because the compatibility framebuffer can't cover more than half of PCI
BAR #0. The latter defaults to 64MB in size, and is controlled by
"ram_size_mb".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15288 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Laszlo Ersek 2014-03-03 08:41:08 +00:00 committed by jljusten
parent cd15261014
commit ec88061ec8
1 changed files with 33 additions and 17 deletions

View File

@ -200,7 +200,7 @@ QemuVideoCirrusModeSetup (
ModeData ++ ;
VideoMode ++;
}
Private->MaxMode = QEMU_VIDEO_CIRRUS_MODE_COUNT;
Private->MaxMode = ModeData - Private->ModeData;
return EFI_SUCCESS;
}
@ -222,10 +222,19 @@ QemuVideoBochsModeSetup (
QEMU_VIDEO_PRIVATE_DATA *Private
)
{
UINT32 AvailableFbSize;
UINT32 Index;
QEMU_VIDEO_MODE_DATA *ModeData;
QEMU_VIDEO_BOCHS_MODES *VideoMode;
//
// fetch available framebuffer size
//
AvailableFbSize = BochsRead (Private, VBE_DISPI_INDEX_VIDEO_MEMORY_64K);
AvailableFbSize *= SIZE_64KB;
DEBUG ((EFI_D_VERBOSE, "%a: AvailableFbSize=0x%x\n", __FUNCTION__,
AvailableFbSize));
//
// Setup Video Modes
//
@ -238,25 +247,32 @@ QemuVideoBochsModeSetup (
ModeData = Private->ModeData;
VideoMode = &QemuVideoBochsModes[0];
for (Index = 0; Index < QEMU_VIDEO_BOCHS_MODE_COUNT; Index ++) {
ModeData->InternalModeIndex = Index;
ModeData->HorizontalResolution = VideoMode->Width;
ModeData->VerticalResolution = VideoMode->Height;
ModeData->ColorDepth = VideoMode->ColorDepth;
ModeData->RefreshRate = 60;
DEBUG ((EFI_D_INFO,
"Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
(INT32) (ModeData - Private->ModeData),
ModeData->InternalModeIndex,
ModeData->HorizontalResolution,
ModeData->VerticalResolution,
ModeData->ColorDepth,
ModeData->RefreshRate
));
UINTN RequiredFbSize;
ModeData ++ ;
ASSERT (VideoMode->ColorDepth % 8 == 0);
RequiredFbSize = (UINTN) VideoMode->Width * VideoMode->Height *
(VideoMode->ColorDepth / 8);
if (RequiredFbSize <= AvailableFbSize) {
ModeData->InternalModeIndex = Index;
ModeData->HorizontalResolution = VideoMode->Width;
ModeData->VerticalResolution = VideoMode->Height;
ModeData->ColorDepth = VideoMode->ColorDepth;
ModeData->RefreshRate = 60;
DEBUG ((EFI_D_INFO,
"Adding Mode %d as Bochs Internal Mode %d: %dx%d, %d-bit, %d Hz\n",
(INT32) (ModeData - Private->ModeData),
ModeData->InternalModeIndex,
ModeData->HorizontalResolution,
ModeData->VerticalResolution,
ModeData->ColorDepth,
ModeData->RefreshRate
));
ModeData ++ ;
}
VideoMode ++;
}
Private->MaxMode = QEMU_VIDEO_BOCHS_MODE_COUNT;
Private->MaxMode = ModeData - Private->ModeData;
return EFI_SUCCESS;
}