[SeaBIOS] Splash Screen fix (RGB bits per channel)

Steve Goodrich steve.goodrich at se-eng.com
Mon Apr 9 18:29:03 CEST 2012

I was trying to get a JPG splash screen working and found a problem
displaying the image correctly.  I'm going to bypass the arguments around
including a splash screen inside a product that completes before the monitor
can even sync; this is simply about code.

Anyway, the code as written was finding the first video mode of the correct
width/height and using that.  Unfortunately, the mode was a 5-5-5 while the
JPG was being decoded as 5-6-5 (bits per RGB channel).  The patch below add
a check for the proper bits-per-channel value before accepting/using the
mode.  I'm not a JPG expert, so I don't know if this will work for all
situations but I thought I'd submit it for review.

            -- Steve G.

diff --git a/src/bootsplash.c b/src/bootsplash.c
index 76b72c1..69ba018 100644
--- a/src/bootsplash.c
+++ b/src/bootsplash.c
@@ -53,7 +53,8 @@ static int
 find_videomode(struct vbe_info *vesa_info, struct vbe_mode_info *mode_info
                , int width, int height, int bpp_req)
-    dprintf(3, "Finding vesa mode with dimensions %d/%d\n", width, height);
+    dprintf(3, "Finding vesa mode with dimensions %d x %d (%d bpp)\n",
+            width, height, bpp_req);
     u16 *videomodes = SEGOFF_TO_FLATPTR(vesa_info->video_mode);
     for (;; videomodes++) {
         u16 videomode = *videomodes;
@@ -84,6 +85,12 @@ find_videomode(struct vbe_info *vesa_info, struct
vbe_mode_info *mode_info
             if (depth != bpp_req)
+        // if this is 16 bits per pixel but R:G:B is not 5:6:5 format,
+        if ((depth == 16) &&
+            ((mode_info->red_size != 5) ||
+             (mode_info->green_size != 6) ||
+             (mode_info->blue_size != 5)))
+            continue;
         return videomode;

More information about the SeaBIOS mailing list