From 02732f945ed2ec2b4fd03421923720608b28a615 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Thu, 16 Dec 2021 11:44:34 -0500 Subject: [PATCH] loader.efi: Do not use as frame buffer BLT-only GOPs. Kernel needs physical frame buffer address and size, which Block Transfer-only Graphics Output Protocol instances do not have. Some recent ASUS boards like PRIME Z690M-PLUS D4 and PRIME H570-Plus report two GOPs, out of which the second one support ConOut protocol, that made it preferable, but is BLT-only, that made console unusable. Discussed with: tsoome (previous version) MFC after: 1 week --- stand/efi/loader/framebuffer.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c index 03752b77a24e..0a00b3645b36 100644 --- a/stand/efi/loader/framebuffer.c +++ b/stand/efi/loader/framebuffer.c @@ -567,21 +567,33 @@ efi_find_framebuffer(teken_gfx_t *gfx_state) /* * Search for ConOut protocol, if not found, use first handle. */ - gop_handle = *hlist; + gop_handle = NULL; for (i = 0; i < nhandles; i++) { - void *dummy = NULL; + EFI_GRAPHICS_OUTPUT *tgop; + void *dummy; + + status = OpenProtocolByHandle(hlist[i], &gop_guid, (void **)&tgop); + if (status != EFI_SUCCESS) + continue; + + if (tgop->Mode->Info->PixelFormat == PixelBltOnly || + tgop->Mode->Info->PixelFormat >= PixelFormatMax) + continue; status = OpenProtocolByHandle(hlist[i], &conout_guid, &dummy); if (status == EFI_SUCCESS) { gop_handle = hlist[i]; + gop = tgop; break; + } else if (gop_handle == NULL) { + gop_handle = hlist[i]; + gop = tgop; } } - status = OpenProtocolByHandle(gop_handle, &gop_guid, (void **)&gop); free(hlist); - if (status == EFI_SUCCESS) { + if (gop_handle != NULL) { gfx_state->tg_fb_type = FB_GOP; gfx_state->tg_private = gop; if (edid_info == NULL)