diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2014-02-13 02:27:49 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2014-02-13 02:27:49 +0100 |
commit | bfa5d8f54612811d306d1453b7d2da549bbc60ee (patch) | |
tree | 2d2aa2b167d5ce5031d5978f44fddaa722fb07cc /console-client/vga-support.c | |
parent | c8b5250cc50a3451ecce9685d8b3457b3c1b133d (diff) | |
download | hurd-bfa5d8f54612811d306d1453b7d2da549bbc60ee.tar.gz hurd-bfa5d8f54612811d306d1453b7d2da549bbc60ee.tar.bz2 hurd-bfa5d8f54612811d306d1453b7d2da549bbc60ee.zip |
Add --font-width option to force 8/9 pixel font width
This permits to choose between 720x400 or 640x400 textmode without
changing the font.
* console-client/vga-hw.h (VGA_ATTR_MODE_ADDR, VGA_ATTR_MODE_LGE,
VGA_ATTR_ENABLE_ADDR): New macros.
* console-client/vga-support.c (vga_state): Add `attr_mode' field.
(vga_init): Save attribute mode subregister content. Re-enable the
screen after that.
(vga_fini): Restore attribute mode subregister content. Re-enable the
screen after that.
(vga_set_font_width): When the font width is set to 9, enable VGA LGE to
properly handle box-drawing unicode characters. Re-nable the screen
after that.
(vga_exchange_palette_attributes): Use VGA_ATTR_ENABLE_ADDR macro
instead of harcoded 0x20.
* console-client/vga-dynafont.h (dynafont_new): Add `width' parameter.
* console-client/vga-dynafont.c (dynafont): Add `width' field.
(dynafont_new): Add `width' parameter, stored in `width' field of `df',
but using the font bbox as default value. Use it to decide whether to
use VGA LGE or not.
(dynafont_activate): Use `width' field of `df' instead of the font bbox
to configure the VGA glyph width.
* console-client/vga.c (vga_display_font_width): New variable.
(vga_display): New `df_width' field.
(argp_option): New `font-width' option.
(parse_opt): Handle `font-width' option.
(vga_display_init): Copy `vga_display_font_width' to `disp'.
(vga_display_start): Pass `df_width' to `dynafont_new'.
Diffstat (limited to 'console-client/vga-support.c')
-rw-r--r-- | console-client/vga-support.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/console-client/vga-support.c b/console-client/vga-support.c index ce4d7354..ce339e19 100644 --- a/console-client/vga-support.c +++ b/console-client/vga-support.c @@ -53,6 +53,8 @@ struct vga_state unsigned char crt_cursor_high; unsigned char crt_cursor_low; + unsigned char attr_mode; + char videomem[2 * 80 * 25]; unsigned char fontmem[2 * VGA_FONT_SIZE * VGA_FONT_HEIGHT]; }; @@ -124,6 +126,18 @@ vga_init (void) outb (VGA_CRT_CURSOR_LOW, VGA_CRT_ADDR_REG); vga_state->crt_cursor_low = inb (VGA_CRT_DATA_REG); + /* Side effect of reading the input status #1 register is to + reset the attribute mixed address/data register so that the + next write it expects is the address, not the data. */ + inb (VGA_INPUT_STATUS_1_REG); + outb (VGA_ATTR_MODE_ADDR, VGA_ATTR_ADDR_DATA_REG); + vga_state->attr_mode = inb (VGA_ATTR_DATA_READ_REG); + + /* Re-enable the screen. */ + inb (VGA_INPUT_STATUS_1_REG); + outb (VGA_ATTR_ENABLE_ADDR, VGA_ATTR_ADDR_DATA_REG); + outb (0x00, VGA_ATTR_ADDR_DATA_REG); + /* Read/write in interleaved mode. */ outb (VGA_GFX_MISC_ADDR, VGA_GFX_ADDR_REG); outb (VGA_GFX_MISC_CHAINOE | VGA_GFX_MISC_B8TOBF, VGA_GFX_DATA_REG); @@ -180,6 +194,15 @@ vga_fini (void) outb (VGA_CRT_CURSOR_LOW, VGA_CRT_ADDR_REG); outb (vga_state->crt_cursor_low, VGA_CRT_DATA_REG); + inb (VGA_INPUT_STATUS_1_REG); + outb (VGA_ATTR_MODE_ADDR, VGA_ATTR_ADDR_DATA_REG); + outb (vga_state->attr_mode, VGA_ATTR_DATA_READ_REG); + + /* Re-enable the screen. */ + inb (VGA_INPUT_STATUS_1_REG); + outb (VGA_ATTR_ENABLE_ADDR, VGA_ATTR_ADDR_DATA_REG); + outb (0x00, VGA_ATTR_ADDR_DATA_REG); + ioperm (VGA_MIN_REG, VGA_MAX_REG - VGA_MIN_REG + 1, 0); munmap (vga_videomem, VGA_VIDEO_MEM_LENGTH); } @@ -308,6 +331,20 @@ vga_set_font_width (int width) else saved &= ~VGA_SEQ_CLOCK_MODE_8; outb (saved, VGA_SEQ_DATA_REG); + + inb (VGA_INPUT_STATUS_1_REG); + outb (VGA_ATTR_MODE_ADDR, VGA_ATTR_ADDR_DATA_REG); + saved = inb (VGA_ATTR_DATA_READ_REG); + if (width == 8) + saved |= ~VGA_ATTR_MODE_LGE; + else + saved &= VGA_ATTR_MODE_LGE; + outb (saved, VGA_ATTR_ADDR_DATA_REG); + + /* Re-enable the screen. */ + inb (VGA_INPUT_STATUS_1_REG); + outb (VGA_ATTR_ENABLE_ADDR, VGA_ATTR_ADDR_DATA_REG); + outb (0x00, VGA_ATTR_ADDR_DATA_REG); } @@ -423,12 +460,8 @@ vga_exchange_palette_attributes (unsigned char index, { unsigned char attr; - /* Side effect of reading the input status #1 register is to - reset the attribute mixed address/data register so that the - next write it expects is the address, not the data. */ - inb (VGA_INPUT_STATUS_1_REG); - /* Set the address. */ + inb (VGA_INPUT_STATUS_1_REG); outb (index++, VGA_ATTR_ADDR_DATA_REG); attr = inb (VGA_ATTR_DATA_READ_REG); outb ((attr & ~077) | (*palette_attr & 077), VGA_ATTR_ADDR_DATA_REG); @@ -438,6 +471,6 @@ vga_exchange_palette_attributes (unsigned char index, /* Re-enable the screen, which was blanked during the palette operation. */ inb (VGA_INPUT_STATUS_1_REG); - outb (0x20, VGA_ATTR_ADDR_DATA_REG); + outb (VGA_ATTR_ENABLE_ADDR, VGA_ATTR_ADDR_DATA_REG); outb (0x00, VGA_ATTR_ADDR_DATA_REG); } |