libeg/screen.c
EFI_STATUS egSetMaxResolution()
{
    EFI_STATUS  Status = EFI_UNSUPPORTED;
    UINT32      Width = 0;
    UINT32      Height = 0;
    UINT32      BestMode = 0;
    UINT32      MaxMode;
    UINT32      Mode;
    UINTN       SizeOfInfo;
    EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;

    if (GraphicsOutput == NULL) {
        return EFI_UNSUPPORTED;
    }

    MaxMode = GraphicsOutput->Mode->MaxMode;
    for (Mode = 0; Mode < MaxMode; Mode++) {
        Status = GraphicsOutput->QueryMode(GraphicsOutput, Mode, &SizeOfInfo, &Info);
        if (Status == EFI_SUCCESS) {
          if (Width > Info->HorizontalResolution) {
            continue;
          }
          if (Height > Info->VerticalResolution) {
            continue;
          }
          Width = Info->HorizontalResolution;
          Height = Info->VerticalResolution;
          BestMode = Mode;
        }
    }
    
    Print(L"Found best mode %d: %dx%d\n", BestMode, Width, Height);
    
    // check if requested mode is equal to current mode
    if (BestMode == GraphicsOutput->Mode->Mode) {
        egScreenWidth = GraphicsOutput->Mode->Info->HorizontalResolution;
        egScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution;
        Status = EFI_SUCCESS;
    } else {
        Status = GopSetModeAndReconnectTextOut(BestMode);

        if (Status == EFI_SUCCESS) {
          egScreenWidth = Width;
          egScreenHeight = Height;
        } else {
          // we can not set BestMode - search for first one that we can
          Status = egSetMode(1);
        }
    }

    return Status;
}
// Set the maximum resolution supported by the Graphics Card and the connected
// monitor.
Set the maximum resolution supported by the Graphics Card and the connected
monitor.
Set the maximum resolution supported by the Graphics Card and the connected monitor .
EFI_STATUS egSetMaxResolution()
{
    EFI_STATUS  Status = EFI_UNSUPPORTED;
    UINT32      Width = 0;
    UINT32      Height = 0;
    UINT32      BestMode = 0;
    UINT32      MaxMode;
    UINT32      Mode;
    UINTN       SizeOfInfo;
    EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
    if (GraphicsOutput == NULL) {
        return EFI_UNSUPPORTED;
    }
    MaxMode = GraphicsOutput->Mode->MaxMode;
    for (Mode = 0; Mode < MaxMode; Mode++) {
        Status = GraphicsOutput->QueryMode(GraphicsOutput, Mode, &SizeOfInfo, &Info);
        if (Status == EFI_SUCCESS) {
          if (Width > Info->HorizontalResolution) {
            continue;
          }
          if (Height > Info->VerticalResolution) {
            continue;
          }
          Width = Info->HorizontalResolution;
          Height = Info->VerticalResolution;
          BestMode = Mode;
        }
    }
    Print(L"Found best mode %d: %dx%d\n", BestMode, Width, Height);
    if (BestMode == GraphicsOutput->Mode->Mode) {
        egScreenWidth = GraphicsOutput->Mode->Info->HorizontalResolution;
        egScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution;
        Status = EFI_SUCCESS;
    } else {
        Status = GopSetModeAndReconnectTextOut(BestMode);
        if (Status == EFI_SUCCESS) {
          egScreenWidth = Width;
          egScreenHeight = Height;
        } else {
          Status = egSetMode(1);
        }
    }
    return Status;
}
EFI_STATUS egSetMaxResolution ( ) { EFI_STATUS Status = EFI_UNSUPPORTED ; UINT32 Width = 0 ; UINT32 Height = 0 ; UINT32 BestMode = 0 ; UINT32 MaxMode ; UINT32 Mode ; UINTN SizeOfInfo ; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * Info ; if ( GraphicsOutput == NULL ) { return EFI_UNSUPPORTED ; } MaxMode = GraphicsOutput -> Mode -> MaxMode ; for ( Mode = 0 ; Mode < MaxMode ; Mode ++ ) { Status = GraphicsOutput -> QueryMode ( GraphicsOutput , Mode , & SizeOfInfo , & Info ) ; if ( Status == EFI_SUCCESS ) { if ( Width > Info -> HorizontalResolution ) { continue ; } if ( Height > Info -> VerticalResolution ) { continue ; } Width = Info -> HorizontalResolution ; Height = Info -> VerticalResolution ; BestMode = Mode ; } } Print ( L" \n " , BestMode , Width , Height ) ; if ( BestMode == GraphicsOutput -> Mode -> Mode ) { egScreenWidth = GraphicsOutput -> Mode -> Info -> HorizontalResolution ; egScreenHeight = GraphicsOutput -> Mode -> Info -> VerticalResolution ; Status = EFI_SUCCESS ; } else { Status = GopSetModeAndReconnectTextOut ( BestMode ) ; if ( Status == EFI_SUCCESS ) { egScreenWidth = Width ; egScreenHeight = Height ; } else { Status = egSetMode ( 1 ) ; } } return Status ; }
Set the maximum resolution supported by the Graphics Card and the connected
monitor.
Set the maximum resolution supported by the Graphics Card and the connected monitor .
// check if requested mode is equal to current mode // we can not set BestMode - search for first one that we can