From: Kevin O'Connor Date: Mon, 16 Jan 2012 23:48:26 +0000 (-0500) Subject: vgabios: Simplify planar4 vgafb code. X-Git-Tag: rel-1.7.0~91 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=160d34abcea594100f7322ba9d3a774ea33cb2c9;p=seabios.git vgabios: Simplify planar4 vgafb code. Don't bother programming the vga registers to manipulate the framebuffer when in planar4 mode. Instead, just switch between the four planes and do the manipulation with regular reads and writes. This makes the code simpler to understand (the vga hardware manipulations are arcane and complex). Note, this could make text scrolling in planar4 mode slower and more likely to result in tearing. However, it's unlikely anything important uses the vgabios in planar4 mode. Signed-off-by: Kevin O'Connor --- diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c index d1841bf..0fab905 100644 --- a/vgasrc/stdvga.c +++ b/vgasrc/stdvga.c @@ -159,6 +159,20 @@ stdvga_set_text_block_specifier(u8 spec) stdvga_sequ_write(0x03, spec); } +// Enable reads and writes to the given "plane" when in planar4 mode. +void +stdvga_planar4_plane(int plane) +{ + if (plane < 0) { + // Return to default mode (read plane0, write all planes) + stdvga_sequ_write(0x02, 0x0f); + stdvga_grdc_write(0x04, 0); + } else { + stdvga_sequ_write(0x02, 1<sstart); if (nblines < rows) dest_far = memcpy_stride(seg, dest_far, src_far, cols * cwidth , stride, (rows - nblines) * cheight); - if (attr < 0) - attr = 0x07; - attr = (attr << 8) | ' '; memset16_stride(seg, dest_far, attr, cols * cwidth , stride, nblines * cheight); } @@ -217,29 +220,20 @@ write_gfx_char_pl4(struct vgamode_s *vmode_g } u16 addr = cp.x + cp.y * cheight * nbcols; u16 src = ca.car * cheight; - stdvga_sequ_write(0x02, 0x0f); - stdvga_grdc_write(0x05, 0x02); - if (ca.attr & 0x80) - stdvga_grdc_write(0x03, 0x18); - else - stdvga_grdc_write(0x03, 0x00); - u8 i; - for (i = 0; i < cheight; i++) { - u8 *dest_far = (void*)(addr + i * nbcols); - u8 j; - for (j = 0; j < 8; j++) { - u8 mask = 0x80 >> j; - stdvga_grdc_write(0x08, mask); - GET_FARVAR(SEG_GRAPH, *(volatile u8*)dest_far); - if (GET_GLOBAL(fdata_g[src + i]) & mask) - SET_FARVAR(SEG_GRAPH, *dest_far, ca.attr & 0x0f); - else - SET_FARVAR(SEG_GRAPH, *dest_far, 0x00); + int i; + for (i=0; i<4; i++) { + stdvga_planar4_plane(i); + u8 colors = ((ca.attr & (1<memmodel)) { case MM_PLANAR: addr_far = (void*)(x / 8 + y * GET_BDA(video_cols)); mask = 0x80 >> (x & 0x07); - stdvga_grdc_write(0x08, mask); - stdvga_grdc_write(0x05, 0x02); - GET_FARVAR(SEG_GRAPH, *(volatile u8*)addr_far); - if (color & 0x80) - stdvga_grdc_write(0x03, 0x18); - SET_FARVAR(SEG_GRAPH, *addr_far, color); - stdvga_grdc_write(0x08, 0xff); - stdvga_grdc_write(0x05, 0x00); - stdvga_grdc_write(0x03, 0x00); + for (i=0; i<4; i++) { + stdvga_planar4_plane(i); + u8 colors = (color & (1<depth) == 2) @@ -470,11 +464,12 @@ vgafb_read_pixel(u16 x, u16 y) mask = 0x80 >> (x & 0x07); attr = 0x00; for (i = 0; i < 4; i++) { - stdvga_grdc_write(0x04, i); + stdvga_planar4_plane(i); data = GET_FARVAR(SEG_GRAPH, *addr_far) & mask; if (data > 0) attr |= (0x01 << i); } + stdvga_planar4_plane(-1); break; case MM_CGA: addr_far = (void*)((x >> 2) + (y >> 1) * 80);