Fix the calculation of bytes_per_pixel
authorH. Peter Anvin <hpa@zytor.com>
Thu, 14 Feb 2008 02:03:17 +0000 (18:03 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Thu, 14 Feb 2008 02:03:17 +0000 (18:03 -0800)
Handle cases where __vesa_info.mi.bpp is not a multiple of 8, e.g. 15.
Remove totally redundant switch statement in vesacon_update_characters().

com32/lib/sys/vesa/drawtxt.c
com32/lib/sys/vesa/initvesa.c

index 7a2347c..9e222ec 100644 (file)
@@ -93,21 +93,6 @@ static void vesacon_update_characters(int row, int col, int nrows, int ncols)
   pixel_offset = ((row*height+VIDEO_BORDER)*VIDEO_X_SIZE)+
     (col*width+VIDEO_BORDER);
 
-  switch (__vesacon_pixel_format) {
-  case PXF_BGR24:
-    bytes_per_pixel = 3;
-    break;
-  case PXF_BGRA32:
-    bytes_per_pixel = 4;
-    break;
-  case PXF_LE_RGB16_565:
-    bytes_per_pixel = 2;
-    break;
-  default:
-    bytes_per_pixel = 0;
-    break;
-  }
-
   fbrowptr = ((uint8_t *)__vesa_info.mi.lfb_ptr) + 
     (row*height+VIDEO_BORDER) * __vesa_info.mi.logical_scan +
     (col*width+VIDEO_BORDER) * bytes_per_pixel;
index abea95a..d5aa9ba 100644 (file)
@@ -235,7 +235,7 @@ static int vesacon_set_mode(void)
 
   mi = &__vesa_info.mi;
   mode = bestmode;
-  __vesacon_bytes_per_pixel = mi->bpp >> 3;
+  __vesacon_bytes_per_pixel = (mi->bpp+7) >> 3;
 
   /* Download the SYSLINUX- or BIOS-provided font */
   rm.eax.w[0] = 0x0018;                /* Query custom font */