Introduce video resolution and text mode PCDs for BIOS setup in BDS module. User can use these PCDs to customize video resolution and text mode for setup when launching BIOS setup.

Signed-off-by: li-elvin
Reviewed-by: niruiyu


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12671 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
li-elvin
2011-11-08 07:34:56 +00:00
parent f98c268559
commit 72861c22e5
6 changed files with 249 additions and 19 deletions

View File

@@ -939,6 +939,187 @@ ShowProgress (
return EFI_SUCCESS;
}
/**
This function will change video resolution and text mode for setup when setup is launched.
@param None.
@retval EFI_SUCCESS Mode is changed successfully.
@retval Others Mode failed to changed.
**/
EFI_STATUS
EFIAPI
ChangeModeForSetup (
VOID
)
{
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
UINT32 MaxGopMode;
UINT32 MaxTextMode;
UINT32 ModeNumber;
UINT32 SetupTextModeColumn;
UINT32 SetupTextModeRow;
UINT32 SetupHorizontalResolution;
UINT32 SetupVerticalResolution;
UINTN HandleCount;
EFI_HANDLE *HandleBuffer;
EFI_STATUS Status;
UINTN Index;
UINTN CurrentColumn;
UINTN CurrentRow;
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID**)&GraphicsOutput
);
if (EFI_ERROR (Status)) {
GraphicsOutput = NULL;
}
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiSimpleTextOutProtocolGuid,
(VOID**)&SimpleTextOut
);
if (EFI_ERROR (Status)) {
SimpleTextOut = NULL;
}
if ((GraphicsOutput == NULL) && (SimpleTextOut == NULL)) {
return EFI_UNSUPPORTED;
}
//
// Get user defined text mode for setup.
//
SetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);
SetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);
SetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);
SetupTextModeRow = PcdGet32 (PcdSetupConOutRow);
MaxGopMode = GraphicsOutput->Mode->MaxMode;
MaxTextMode = SimpleTextOut->Mode->MaxMode;
//
// 1. If current video resolution is same with setup video resolution,
// video resolution need not be changed.
// 1.1. If current text mode is same with setup text mode, text mode need not be changed.
// 1.2. If current text mode is different with setup text mode, text mode need be changed to setup text mode.
// 2. If current video resolution is different with setup video resolution, we need restart whole console drivers.
//
for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
Status = GraphicsOutput->QueryMode (
GraphicsOutput,
ModeNumber,
&SizeOfInfo,
&Info
);
if (!EFI_ERROR (Status)) {
if ((Info->HorizontalResolution == SetupHorizontalResolution) &&
(Info->VerticalResolution == SetupVerticalResolution)) {
if ((GraphicsOutput->Mode->Info->HorizontalResolution == SetupHorizontalResolution) &&
(GraphicsOutput->Mode->Info->VerticalResolution == SetupVerticalResolution)) {
//
// If current video resolution is same with setup video resolution,
// then check if current text mode is same with setup text mode.
//
Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
ASSERT_EFI_ERROR (Status);
if (CurrentColumn == SetupTextModeColumn && CurrentRow == SetupTextModeRow) {
//
// Current text mode is same with setup text mode, text mode need not be change.
//
FreePool (Info);
return EFI_SUCCESS;
} else {
//
// Current text mode is different with setup text mode, text mode need be change to new text mode.
//
for (Index = 0; Index < MaxTextMode; Index++) {
Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
if (!EFI_ERROR(Status)) {
if ((CurrentColumn == SetupTextModeColumn) && (CurrentRow == SetupTextModeRow)) {
//
// setup text mode is supported, set it.
//
Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
ASSERT_EFI_ERROR (Status);
//
// Update text mode PCD.
//
PcdSet32 (PcdConOutColumn, SetupTextModeColumn);
PcdSet32 (PcdConOutRow, SetupTextModeRow);
FreePool (Info);
return EFI_SUCCESS;
}
}
}
if (Index == MaxTextMode) {
//
// If setup text mode is not supported, return error.
//
FreePool (Info);
return EFI_UNSUPPORTED;
}
}
} else {
FreePool (Info);
//
// If current video resolution is not same with the setup video resolution, set new video resolution.
// In this case, the drivers which produce simple text out need be restarted.
//
Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
if (!EFI_ERROR (Status)) {
//
// Set PCD to restart GraphicsConsole and Consplitter to change video resolution
// and produce new text mode based on new resolution.
//
PcdSet32 (PcdVideoHorizontalResolution, SetupHorizontalResolution);
PcdSet32 (PcdVideoVerticalResolution, SetupVerticalResolution);
PcdSet32 (PcdConOutColumn, SetupTextModeColumn);
PcdSet32 (PcdConOutRow, SetupTextModeRow);
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiSimpleTextOutProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < HandleCount; Index++) {
gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
}
for (Index = 0; Index < HandleCount; Index++) {
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
}
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}
break;
}
}
}
}
FreePool (Info);
}
}
if (ModeNumber == MaxGopMode) {
//
// If the new resolution is not supported, return error.
//
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
/**
This function is the main entry of the platform setup entry.
The function will present the main menu of the system setup,
@@ -996,7 +1177,11 @@ PlatformBdsEnterFrontPage (
}
do {
//
// Set proper video resolution and text mode for setup
//
ChangeModeForSetup ();
InitializeFrontPage (FALSE);
//