diff options
author | jkim <jkim@FreeBSD.org> | 2010-02-03 22:17:30 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2010-02-03 22:17:30 +0000 |
commit | 6d9c892adfa9a8030c9fa7fe2e8a51ac3b568ec6 (patch) | |
tree | de10d293f3d3e6a084adc9267bd11af955a4c1be | |
parent | f9144e3f76f10e10cfbd2c5233be70dc0fa5d2bf (diff) | |
download | FreeBSD-src-6d9c892adfa9a8030c9fa7fe2e8a51ac3b568ec6.zip FreeBSD-src-6d9c892adfa9a8030c9fa7fe2e8a51ac3b568ec6.tar.gz |
Use bytes per scan line from mode table. The previous implementation did
not reflect actual number of bytes when it was not exactly width * bpp * 8.
-rw-r--r-- | sys/dev/fb/vesa.c | 50 | ||||
-rw-r--r-- | sys/sys/fbio.h | 4 |
2 files changed, 16 insertions, 38 deletions
diff --git a/sys/dev/fb/vesa.c b/sys/dev/fb/vesa.c index 7fe2fc2..a1e2013 100644 --- a/sys/dev/fb/vesa.c +++ b/sys/dev/fb/vesa.c @@ -186,7 +186,9 @@ static int vesa_bios_load_palette2(int start, int colors, u_char *r, u_char *g, #define STATE_ALL (STATE_HW | STATE_DATA | STATE_DAC | STATE_REG) static ssize_t vesa_bios_state_buf_size(void); static int vesa_bios_save_restore(int code, void *p, size_t size); +#if 0 static int vesa_bios_get_line_length(void); +#endif static int vesa_bios_set_line_length(int pixel, int *bytes, int *lines); #if 0 static int vesa_bios_get_start(int *x, int *y); @@ -195,7 +197,6 @@ static int vesa_bios_set_start(int x, int y); static int vesa_map_gen_mode_num(int type, int color, int mode); static int vesa_translate_flags(u_int16_t vflags); static int vesa_translate_mmodel(u_int8_t vmodel); -static int vesa_get_line_width(video_info_t *info); static int vesa_bios_init(void); static void vesa_clear_modes(video_info_t *info, int color); static vm_offset_t vesa_map_buffer(u_int paddr, size_t size); @@ -567,6 +568,7 @@ vesa_bios_save_restore(int code, void *p, size_t size) return (regs.R_AX != 0x004f); } +#if 0 static int vesa_bios_get_line_length(void) { @@ -583,6 +585,7 @@ vesa_bios_get_line_length(void) return (regs.R_BX); } +#endif static int vesa_bios_set_line_length(int pixel, int *bytes, int *lines) @@ -716,37 +719,6 @@ vesa_translate_mmodel(u_int8_t vmodel) return (V_INFO_MM_OTHER); } -static int -vesa_get_line_width(video_info_t *info) -{ - int len; - int width; - - width = info->vi_width; - - if (info->vi_flags & V_INFO_GRAPHICS) - switch (info->vi_depth / info->vi_planes) { - case 1: - return (width / 8); - case 2: - return (width / 4); - case 4: - return (width / 2); - case 8: - return (width); - case 15: - case 16: - return (width * 2); - case 24: - case 32: - return (width * 4); - } - - len = vesa_bios_get_line_length(); - - return (len > 0 ? len : width); -} - #define VESA_MAXSTR 256 #define VESA_STRCPY(dst, src) do { \ @@ -933,10 +905,14 @@ vesa_bios_init(void) /* XXX window B */ vesa_vmode[modes].vi_window_size = vmode.v_wsize*1024; vesa_vmode[modes].vi_window_gran = vmode.v_wgran*1024; - if (vmode.v_modeattr & V_MODELFB) + if (vmode.v_modeattr & V_MODELFB) { vesa_vmode[modes].vi_buffer = vmode.v_lfb; - else + vesa_vmode[modes].vi_line_width = vers >= 0x0300 ? + vmode.v_linbpscanline : vmode.v_bpscanline; + } else { vesa_vmode[modes].vi_buffer = 0; + vesa_vmode[modes].vi_line_width = vmode.v_bpscanline; + } /* XXX */ vesa_vmode[modes].vi_buffer_size = vesa_adp_info->v_memsize*64*1024; @@ -987,8 +963,8 @@ vesa_bios_init(void) = vesa_translate_flags(vmode.v_modeattr) | V_INFO_VESA; /* Does it have enough memory to support this mode? */ - bsize = vesa_get_line_width(&vesa_vmode[modes]); - bsize *= vesa_vmode[modes].vi_height; + bsize = (size_t)vesa_vmode[modes].vi_line_width * + vesa_vmode[modes].vi_height; if (bsize > vesa_vmode[modes].vi_buffer_size) { #if VESA_DEBUG > 1 printf( @@ -1322,7 +1298,7 @@ vesa_set_mode(video_adapter_t *adp, int mode) vesa_adp->va_window_gran = info.vi_window_gran; } vesa_adp->va_window_orig = 0; - vesa_adp->va_line_width = vesa_get_line_width(&info); + vesa_adp->va_line_width = info.vi_line_width; vesa_adp->va_disp_start.x = 0; vesa_adp->va_disp_start.y = 0; #if VESA_DEBUG > 0 diff --git a/sys/sys/fbio.h b/sys/sys/fbio.h index 415ad96..5bc27ff 100644 --- a/sys/sys/fbio.h +++ b/sys/sys/fbio.h @@ -295,8 +295,10 @@ struct video_info { /* for MM_DIRECT only */ int vi_pixel_fields[4]; /* RGB and reserved fields */ int vi_pixel_fsizes[4]; + /* XXX for VESA only */ + int vi_line_width; /* reserved */ - u_char vi_reserved[64]; + u_char vi_reserved[60]; vm_offset_t vi_registers; /* physical address */ vm_offset_t vi_registers_size; }; |