VirtualBox

Ignore:
Timestamp:
Jul 12, 2017 9:30:24 AM (8 years ago)
Author:
vboxsync
Message:

Main/Console: EFI graphics resolution cleanup, prepare for resolution based mode selection by default
Devices/EFI: use new CFGM keys (fall back to old ones if necessary), clean up variable and info field naming
Devices/EFI/Firmware: for both GOP and UGA (which is very deprecated) try to find the mode by resolution if possible

Location:
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaGraphicsOutput.c

    r67356 r67918  
    426426  )
    427427{
    428   EFI_STATUS                   Status;
    429   EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
    430   UINT32                        GopMode = 2;
     428  EFI_STATUS                    Status;
     429  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
     430  UINT32                        Index;
     431  UINT32                        HorizontalResolution = 1024;
     432  UINT32                        VerticalResolution = 768;
     433  UINT32                        ColorDepth = 32;
     434
     435  DEBUG((DEBUG_INFO, "%a:%d construct\n", __FILE__, __LINE__));
    431436
    432437  GraphicsOutput            = &Private->GraphicsOutput;
     
    461466  // Initialize the hardware
    462467  //
    463   VBoxVgaGetVmVariable(EFI_INFO_INDEX_GOP_MODE, (CHAR8 *)&GopMode, sizeof(GopMode));
    464 
    465   GraphicsOutput->SetMode (GraphicsOutput, GopMode);
     468  VBoxVgaGetVmVariable(EFI_INFO_INDEX_HORIZONTAL_RESOLUTION, (CHAR8 *)&HorizontalResolution,
     469                       sizeof(HorizontalResolution));
     470  VBoxVgaGetVmVariable(EFI_INFO_INDEX_VERTICAL_RESOLUTION, (CHAR8 *)&VerticalResolution,
     471                       sizeof(VerticalResolution));
     472  for (Index = 0; Index < Private->MaxMode; Index++)
     473  {
     474    if (   HorizontalResolution == Private->ModeData[Index].HorizontalResolution
     475        && VerticalResolution == Private->ModeData[Index].VerticalResolution
     476        && ColorDepth == Private->ModeData[Index].ColorDepth)
     477      break;
     478  }
     479  // not found? try mode number
     480  if (Index >= Private->MaxMode)
     481  {
     482    VBoxVgaGetVmVariable(EFI_INFO_INDEX_GRAPHICS_MODE, (CHAR8 *)&Index, sizeof(Index));
     483    // try with mode 2 (usually 1024x768) as a fallback
     484    if (Index >= Private->MaxMode)
     485      Index = 2;
     486    // try with mode 0 (usually 640x480) as a fallback
     487    if (Index >= Private->MaxMode)
     488      Index = 0;
     489  }
     490
     491  // skip mode setting completely if there is no valid mode
     492  if (Index >= Private->MaxMode)
     493    return EFI_UNSUPPORTED;
     494
     495  GraphicsOutput->SetMode (GraphicsOutput, Index);
    466496
    467497  DrawLogo (
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaUgaDraw.c

    r67356 r67918  
    9090  )
    9191{
    92   VBOX_VGA_PRIVATE_DATA  *Private;
    93   UINTN                           Index;
     92  VBOX_VGA_PRIVATE_DATA *Private;
     93  UINTN                 Index;
    9494
    9595  DEBUG((DEBUG_INFO, "%a:%d VIDEO: %dx%d %d bpp\n", __FILE__, __LINE__, HorizontalResolution, VerticalResolution, ColorDepth));
     
    328328{
    329329  EFI_UGA_DRAW_PROTOCOL *UgaDraw;
     330  UINT32                Index;
    330331  UINT32                HorizontalResolution = 1024;
    331332  UINT32                VerticalResolution = 768;
     333  UINT32                ColorDepth = 32;
    332334
    333335  //
     
    349351  // Initialize the hardware
    350352  //
    351   VBoxVgaGetVmVariable(EFI_INFO_INDEX_UGA_HORIZONTAL_RESOLUTION, (CHAR8 *)&HorizontalResolution,
     353  VBoxVgaGetVmVariable(EFI_INFO_INDEX_HORIZONTAL_RESOLUTION, (CHAR8 *)&HorizontalResolution,
    352354                       sizeof(HorizontalResolution));
    353   VBoxVgaGetVmVariable(EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION, (CHAR8 *)&VerticalResolution,
     355  VBoxVgaGetVmVariable(EFI_INFO_INDEX_VERTICAL_RESOLUTION, (CHAR8 *)&VerticalResolution,
    354356                       sizeof(VerticalResolution));
     357  for (Index = 0; Index < Private->MaxMode; Index++)
     358  {
     359    if (   HorizontalResolution == Private->ModeData[Index].HorizontalResolution
     360        && VerticalResolution == Private->ModeData[Index].VerticalResolution
     361        && ColorDepth == Private->ModeData[Index].ColorDepth)
     362      break;
     363  }
     364  // not found? try mode number
     365  if (Index >= Private->MaxMode)
     366  {
     367    VBoxVgaGetVmVariable(EFI_INFO_INDEX_GRAPHICS_MODE, (CHAR8 *)&Index, sizeof(Index));
     368    // try with mode 2 (usually 1024x768) as a fallback
     369    if (Index >= Private->MaxMode)
     370      Index = 2;
     371    // try with mode 0 (usually 640x480) as a fallback
     372    if (Index >= Private->MaxMode)
     373      Index = 0;
     374
     375    // get the resolution from the mode if valid
     376    if (Index < Private->MaxMode)
     377    {
     378      HorizontalResolution = Private->ModeData[Index].HorizontalResolution;
     379      VerticalResolution = Private->ModeData[Index].VerticalResolution;
     380      ColorDepth = Private->ModeData[Index].ColorDepth;
     381    }
     382  }
     383
     384  // skip mode setting completely if there is no valid mode
     385  if (Index >= Private->MaxMode)
     386    return EFI_UNSUPPORTED;
    355387
    356388  UgaDraw->SetMode (
     
    358390            HorizontalResolution,
    359391            VerticalResolution,
    360             32,
     392            ColorDepth,
    361393            60
    362394            );
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette