From ca6210d5e9d1f33f1a697bf7cd183a0ffb8dfaa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 9 Sep 2008 15:18:51 +0000 Subject: [PATCH] * closest_video_mode() now only returns modes with a width less or equal than the one specified. This should fix the "video mode out of range" message of your monitor during boot, in case you had that one. Thanks to Hartmut Reh for his help to be able to spot this. * The mode returned by find_edid_mode(..., true) was never used. * find_edid_mode() did not return any mode if there were no detailed modes available. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27390 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/bios_ia32/video.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/system/boot/platform/bios_ia32/video.cpp b/src/system/boot/platform/bios_ia32/video.cpp index c159543a3d..3a3eefd311 100644 --- a/src/system/boot/platform/bios_ia32/video.cpp +++ b/src/system/boot/platform/bios_ia32/video.cpp @@ -117,6 +117,10 @@ find_video_mode(int32 width, int32 height, bool allowPalette) } +/*! Returns the VESA mode closest to the one specified, with a width less or + equal as specified. + The height as well as the depth may vary in both directions, though. +*/ static video_mode * closest_video_mode(int32 width, int32 height, int32 depth) { @@ -126,6 +130,12 @@ closest_video_mode(int32 width, int32 height, int32 depth) video_mode *mode = NULL; while ((mode = (video_mode *)list_get_next_item(&sModeList, mode)) != NULL) { + if (mode->width > width) { + // Only choose modes with a width less or equal than the searched + // one; or else it might well be that the monitor cannot keep up. + continue; + } + uint32 diff = 2 * abs(mode->width - width) + abs(mode->height - height) + abs(mode->bits_per_pixel - depth); @@ -173,7 +183,7 @@ find_edid_mode(edid1_info &info, bool allowPalette) } } - return NULL; + return mode; } @@ -1097,7 +1107,7 @@ platform_init_video(void) // mode video_mode *defaultMode = find_edid_mode(info, false); if (defaultMode == NULL) - find_edid_mode(info, true); + defaultMode = find_edid_mode(info, true); if (defaultMode != NULL) { // We found a new default mode to use!