From 134fa6111fed4ccd1a1f53faceb88a5d1766da17 Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Thu, 8 Sep 2022 18:40:36 +0200 Subject: [PATCH] vesa BIOS patching: try to use modes reported as invalid by the BIOS It seems some versions of Intel BIOS report the mode as invalid after patching (probably there is not enough patching), but setting the mode will actually work. So, if we detect no mode with our patches, and we detect a broken mode, attempt to use that. May fix #17929 Change-Id: Icb9259a79b5a49d18946b682af89dda16176e854 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5628 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/add-ons/kernel/drivers/graphics/vesa/patch.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/add-ons/kernel/drivers/graphics/vesa/patch.cpp b/src/add-ons/kernel/drivers/graphics/vesa/patch.cpp index e4ba09efec..2bc44c7d24 100644 --- a/src/add-ons/kernel/drivers/graphics/vesa/patch.cpp +++ b/src/add-ons/kernel/drivers/graphics/vesa/patch.cpp @@ -364,6 +364,8 @@ status_t vesa_set_custom_display_mode(vesa_info& info, display_mode& mode) { int32 modeIndex = -1; + int32 brokenModeIndex = -1; + if (info.shared_info->bios_type == kUnknownBiosType) return B_NOT_SUPPORTED; @@ -404,10 +406,11 @@ vesa_set_custom_display_mode(vesa_info& info, display_mode& mode) for (uint32 i = 0; i < info.shared_info->vesa_mode_count; i++) { status = vbe_get_mode_info(state, info.modes[i].mode, &modeInfo); if (status != B_OK) { - // Sometimes the patching prevents us from getting the mode info? + // Sometimes the patching prevents us from getting the mode info. The modesetting + // still works, so we can detect the "broken" mode this way and then activate it. dprintf(DEVICE_NAME ": vesa_set_custom_display_mode(): cannot get mode info for %x\n", info.modes[i].mode); - // Just ignore modes that turn out to be invalid... + brokenModeIndex = info.modes[i].mode; continue; } @@ -418,6 +421,9 @@ vesa_set_custom_display_mode(vesa_info& info, display_mode& mode) } } + if (modeIndex < 0) + modeIndex = brokenModeIndex; + if (modeIndex >= 0) { dprintf(DEVICE_NAME ": custom mode resolution %dx%d succesfully patched at index %" B_PRIx32 "\n", modeInfo.width, modeInfo.height, modeIndex);