IN UINT32 ModeNumber\r
)\r
{\r
- VGPU_GOP *VgpuGop;\r
- UINT32 NewResourceId;\r
- UINTN NewNumberOfBytes;\r
- UINTN NewNumberOfPages;\r
- VOID *NewBackingStore;\r
- EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress;\r
- VOID *NewBackingStoreMap;\r
+ VGPU_GOP *VgpuGop;\r
+ UINT32 NewResourceId;\r
+ UINTN NewNumberOfBytes;\r
+ UINTN NewNumberOfPages;\r
+ VOID *NewBackingStore;\r
+ EFI_PHYSICAL_ADDRESS NewBackingStoreDeviceAddress;\r
+ VOID *NewBackingStoreMap;\r
+ UINTN SizeOfInfo;\r
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GopModeInfo;\r
\r
EFI_STATUS Status;\r
EFI_STATUS Status2;\r
\r
- if (ModeNumber >= ARRAY_SIZE (mGopResolutions)) {\r
- return EFI_UNSUPPORTED;\r
+ Status = GopQueryMode (This, ModeNumber, &SizeOfInfo, &GopModeInfo);\r
+ if (Status != EFI_SUCCESS) {\r
+ return Status;\r
}\r
\r
VgpuGop = VGPU_GOP_FROM_GOP (This);\r
VgpuGop->ParentBus, // VgpuDev\r
NewResourceId, // ResourceId\r
VirtioGpuFormatB8G8R8X8Unorm, // Format\r
- mGopResolutions[ModeNumber].Width, // Width\r
- mGopResolutions[ModeNumber].Height // Height\r
+ GopModeInfo->HorizontalResolution, // Width\r
+ GopModeInfo->VerticalResolution // Height\r
);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
// Allocate, zero and map guest backing store, for bus master common buffer\r
// operation.\r
//\r
- NewNumberOfBytes = mGopResolutions[ModeNumber].Width *\r
- mGopResolutions[ModeNumber].Height * sizeof (UINT32);\r
+ NewNumberOfBytes = GopModeInfo->HorizontalResolution *\r
+ GopModeInfo->VerticalResolution * sizeof (UINT32);\r
NewNumberOfPages = EFI_SIZE_TO_PAGES (NewNumberOfBytes);\r
Status = VirtioGpuAllocateZeroAndMapBackingStore (\r
VgpuGop->ParentBus, // VgpuDev\r
VgpuGop->ParentBus, // VgpuDev\r
0, // X\r
0, // Y\r
- mGopResolutions[ModeNumber].Width, // Width\r
- mGopResolutions[ModeNumber].Height, // Height\r
+ GopModeInfo->HorizontalResolution, // Width\r
+ GopModeInfo->VerticalResolution, // Height\r
0, // ScanoutId\r
NewResourceId // ResourceId\r
);\r
VgpuGop->ParentBus, // VgpuDev\r
0, // X\r
0, // Y\r
- mGopResolutions[ModeNumber].Width, // Width\r
- mGopResolutions[ModeNumber].Height, // Height\r
+ GopModeInfo->HorizontalResolution, // Width\r
+ GopModeInfo->VerticalResolution, // Height\r
NewResourceId // ResourceId\r
);\r
if (EFI_ERROR (Status)) {\r
// therefore non-recoverable.\r
//\r
Status2 = VirtioGpuSetScanout (\r
- VgpuGop->ParentBus, // VgpuDev\r
- 0, // X\r
- 0, // Y\r
- mGopResolutions[This->Mode->Mode].Width, // Width\r
- mGopResolutions[This->Mode->Mode].Height, // Height\r
- 0, // ScanoutId\r
- VgpuGop->ResourceId // ResourceId\r
+ VgpuGop->ParentBus, // VgpuDev\r
+ 0, // X\r
+ 0, // Y\r
+ VgpuGop->GopModeInfo.HorizontalResolution, // Width\r
+ VgpuGop->GopModeInfo.VerticalResolution, // Height\r
+ 0, // ScanoutId\r
+ VgpuGop->ResourceId // ResourceId\r
);\r
ASSERT_EFI_ERROR (Status2);\r
if (EFI_ERROR (Status2)) {\r
//\r
// Populate Mode and ModeInfo (mutable fields only).\r
//\r
- VgpuGop->GopMode.Mode = ModeNumber;\r
- VgpuGop->GopModeInfo.HorizontalResolution =\r
- mGopResolutions[ModeNumber].Width;\r
- VgpuGop->GopModeInfo.VerticalResolution = mGopResolutions[ModeNumber].Height;\r
- VgpuGop->GopModeInfo.PixelsPerScanLine = mGopResolutions[ModeNumber].Width;\r
+ VgpuGop->GopMode.Mode = ModeNumber;\r
+ VgpuGop->GopModeInfo = *GopModeInfo;\r
+ FreePool (GopModeInfo);\r
return EFI_SUCCESS;\r
\r
DetachBackingStore:\r
CpuDeadLoop ();\r
}\r
\r
+ FreePool (GopModeInfo);\r
return Status;\r
}\r
\r