]> xenbits.xensource.com Git - seabios.git/commitdiff
vgabios: Rename stdvga_bpp_factor to stdvga_vram_ratio.
authorKevin O'Connor <kevin@koconnor.net>
Tue, 10 Sep 2013 14:41:33 +0000 (10:41 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 19 Sep 2013 00:48:33 +0000 (20:48 -0400)
Invert the values returned by stdvga_bpp_factor and rename it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
vgasrc/bochsvga.c
vgasrc/clext.c
vgasrc/stdvga.c
vgasrc/stdvga.h

index b93213ce43eeaf839c302bbd2e74c5c6c0ddd02b..fcdf7e9074e7e07f7dd72d43094fa2d7e629ae1c 100644 (file)
@@ -412,7 +412,7 @@ bochsvga_setup(void)
         u16 height = GET_GLOBAL(m->info.height);
         u8 depth = GET_GLOBAL(m->info.depth);
         u32 mem = (height * DIV_ROUND_UP(width * vga_bpp(&m->info), 8)
-                   * 4 / stdvga_bpp_factor(&m->info));
+                   * stdvga_vram_ratio(&m->info));
 
         if (width > max_xres || depth > max_bpp || mem > totalmem) {
             dprintf(1, "Removing mode %x\n", GET_GLOBAL(m->mode));
index 012e2b1064ff04d3a18a236e5d72d9d07170424f..8377da133300bd184e1f962e09a3c8b97ae525b8 100644 (file)
@@ -328,17 +328,16 @@ clext_get_linelength(struct vgamode_s *vmode_g)
     u16 crtc_addr = stdvga_get_crtc();
     u8 reg13 = stdvga_crtc_read(crtc_addr, 0x13);
     u8 reg1b = stdvga_crtc_read(crtc_addr, 0x1b);
-    return (((reg1b & 0x10) << 4) + reg13) * stdvga_bpp_factor(vmode_g) * 2;
+    return (((reg1b & 0x10) << 4) + reg13) * 8 / stdvga_vram_ratio(vmode_g);
 }
 
 int
 clext_set_linelength(struct vgamode_s *vmode_g, int val)
 {
     u16 crtc_addr = stdvga_get_crtc();
-    int factor = stdvga_bpp_factor(vmode_g) * 2;
-    int new_line_offset = DIV_ROUND_UP(val, factor);
-    stdvga_crtc_write(crtc_addr, 0x13, new_line_offset);
-    stdvga_crtc_mask(crtc_addr, 0x1b, 0x10, (new_line_offset & 0x100) >> 4);
+    val = DIV_ROUND_UP(val * stdvga_vram_ratio(vmode_g), 8);
+    stdvga_crtc_write(crtc_addr, 0x13, val);
+    stdvga_crtc_mask(crtc_addr, 0x1b, 0x10, (val & 0x100) >> 4);
     return 0;
 }
 
@@ -352,14 +351,14 @@ clext_get_displaystart(struct vgamode_s *vmode_g)
     u8 b4 = stdvga_crtc_read(crtc_addr, 0x1d);
     int val = (b1 | (b2<<8) | ((b3 & 0x01) << 16) | ((b3 & 0x0c) << 15)
                | ((b4 & 0x80) << 12));
-    return val * stdvga_bpp_factor(vmode_g);
+    return val * 4 / stdvga_vram_ratio(vmode_g);
 }
 
 int
 clext_set_displaystart(struct vgamode_s *vmode_g, int val)
 {
     u16 crtc_addr = stdvga_get_crtc();
-    val /= stdvga_bpp_factor(vmode_g);
+    val = val * stdvga_vram_ratio(vmode_g) / 4;
     stdvga_crtc_write(crtc_addr, 0x0d, val);
     stdvga_crtc_write(crtc_addr, 0x0c, val >> 8);
     stdvga_crtc_mask(crtc_addr, 0x1d, 0x80, (val & 0x0800) >> 4);
index 1dd947e2e2261f55c3875c185dce3523822240d5..3c92eec6ce9c9d8cbbeaf4dd15c2f5333a460fd3 100644 (file)
@@ -212,19 +212,19 @@ stdvga_get_crtc(void)
     return VGAREG_MDA_CRTC_ADDRESS;
 }
 
-// Return the multiplication factor needed for the vga offset register.
+// Ratio between system visible framebuffer ram and the actual videoram used.
 int
-stdvga_bpp_factor(struct vgamode_s *vmode_g)
+stdvga_vram_ratio(struct vgamode_s *vmode_g)
 {
     switch (GET_GLOBAL(vmode_g->memmodel)) {
     case MM_TEXT:
         return 2;
     case MM_CGA:
-        return GET_GLOBAL(vmode_g->depth);
+        return 4 / GET_GLOBAL(vmode_g->depth);
     case MM_PLANAR:
-        return 1;
-    default:
         return 4;
+    default:
+        return 1;
     }
 }
 
@@ -278,14 +278,14 @@ int
 stdvga_get_linelength(struct vgamode_s *vmode_g)
 {
     u8 val = stdvga_crtc_read(stdvga_get_crtc(), 0x13);
-    return val * stdvga_bpp_factor(vmode_g) * 2;
+    return val * 8 / stdvga_vram_ratio(vmode_g);
 }
 
 int
 stdvga_set_linelength(struct vgamode_s *vmode_g, int val)
 {
-    int factor = stdvga_bpp_factor(vmode_g) * 2;
-    stdvga_crtc_write(stdvga_get_crtc(), 0x13, DIV_ROUND_UP(val, factor));
+    val = DIV_ROUND_UP(val * stdvga_vram_ratio(vmode_g), 8);
+    stdvga_crtc_write(stdvga_get_crtc(), 0x13, val);
     return 0;
 }
 
@@ -295,14 +295,14 @@ stdvga_get_displaystart(struct vgamode_s *vmode_g)
     u16 crtc_addr = stdvga_get_crtc();
     int addr = (stdvga_crtc_read(crtc_addr, 0x0c) << 8
                 | stdvga_crtc_read(crtc_addr, 0x0d));
-    return addr * stdvga_bpp_factor(vmode_g);
+    return addr * 4 / stdvga_vram_ratio(vmode_g);
 }
 
 int
 stdvga_set_displaystart(struct vgamode_s *vmode_g, int val)
 {
     u16 crtc_addr = stdvga_get_crtc();
-    val /= stdvga_bpp_factor(vmode_g);
+    val = val * stdvga_vram_ratio(vmode_g) / 4;
     stdvga_crtc_write(crtc_addr, 0x0c, val >> 8);
     stdvga_crtc_write(crtc_addr, 0x0d, val);
     return 0;
index d712a32f0f79950bd1a9a986fa9bfc452b8daa58..bb8b8d8606ae49c15a2bb164f1cd9295116bdfe6 100644 (file)
@@ -90,7 +90,7 @@ void stdvga_planar4_plane(int plane);
 void stdvga_load_font(u16 seg, void *src_far, u16 count
                       , u16 start, u8 destflags, u8 fontsize);
 u16 stdvga_get_crtc(void);
-int stdvga_bpp_factor(struct vgamode_s *vmode_g);
+int stdvga_vram_ratio(struct vgamode_s *vmode_g);
 void stdvga_set_cursor_shape(u8 start, u8 end);
 void stdvga_set_cursor_pos(int address);
 void stdvga_set_scan_lines(u8 lines);