Modify efi_find_gop_mode() so that passing cols or rows as 0 is interpreted as a request to attempt to keep the currently set mode, and do so if the mode query for information is successful and the depth is supported.
Signed-off-by: Roger Pau Monné <roger....@citrix.com> --- Changes since v1: - Only update cols or rows if the value is 0. - Leave depth alone. --- xen/common/efi/boot.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index b69c83e354..766a2553be 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -930,6 +930,27 @@ static UINTN __init efi_find_gop_mode(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop, UINTN gop_mode = ~0, info_size, size; unsigned int i; + if ( (!cols || !rows) && gop->Mode->Mode < gop->Mode->MaxMode ) + { + /* If no (valid) resolution suggested, try to use the current mode. */ + status = gop->QueryMode(gop, gop->Mode->Mode, &info_size, &mode_info); + if ( EFI_ERROR(status) ) + PrintErr(L"Invalid current graphics mode\r\n"); + else if ( mode_info->PixelFormat < PixelBltOnly ) + return gop->Mode->Mode; + else + { + /* + * Try to find a mode with the same resolution and a valid pixel + * format. + */ + if ( !cols ) + cols = mode_info->HorizontalResolution; + if ( !rows ) + rows = mode_info->VerticalResolution; + } + } + for ( i = size = 0; i < gop->Mode->MaxMode; ++i ) { unsigned int bpp = 0; -- 2.40.0