aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/fb/vga.c
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2010-03-24 15:37:47 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2010-03-24 15:37:47 +0000
commit1e161437f8e1defd8dd87315c7fe14317fd568da (patch)
treeab25901d4be317fc52f8c8ccdac152659d2f5736 /sys/dev/fb/vga.c
parent592a685e337043edc9cbf12c51e300c1994cbd7c (diff)
downloadsrc-1e161437f8e1defd8dd87315c7fe14317fd568da.tar.gz
src-1e161437f8e1defd8dd87315c7fe14317fd568da.zip
Teach VGA framebuffer about 8-bit palette format for VESA.
Notes
Notes: svn path=/head/; revision=205604
Diffstat (limited to 'sys/dev/fb/vga.c')
-rw-r--r--sys/dev/fb/vga.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/dev/fb/vga.c b/sys/dev/fb/vga.c
index 7d702ad2b8e9..1bcf93507559 100644
--- a/sys/dev/fb/vga.c
+++ b/sys/dev/fb/vga.c
@@ -1979,6 +1979,7 @@ vga_show_font(video_adapter_t *adp, int page)
static int
vga_save_palette(video_adapter_t *adp, u_char *palette)
{
+ int bits;
int i;
prologue(adp, V_ADP_PALETTE, ENODEV);
@@ -1988,8 +1989,9 @@ vga_save_palette(video_adapter_t *adp, u_char *palette)
* VGA has 6 bit DAC .
*/
outb(PALRADR, 0x00);
+ bits = (adp->va_flags & V_ADP_DAC8) != 0 ? 0 : 2;
for (i = 0; i < 256*3; ++i)
- palette[i] = inb(PALDATA) << 2;
+ palette[i] = inb(PALDATA) << bits;
inb(adp->va_crtc_addr + 6); /* reset flip/flop */
return 0;
}
@@ -1998,15 +2000,17 @@ static int
vga_save_palette2(video_adapter_t *adp, int base, int count,
u_char *r, u_char *g, u_char *b)
{
+ int bits;
int i;
prologue(adp, V_ADP_PALETTE, ENODEV);
outb(PALRADR, base);
+ bits = (adp->va_flags & V_ADP_DAC8) != 0 ? 0 : 2;
for (i = 0; i < count; ++i) {
- r[i] = inb(PALDATA) << 2;
- g[i] = inb(PALDATA) << 2;
- b[i] = inb(PALDATA) << 2;
+ r[i] = inb(PALDATA) << bits;
+ g[i] = inb(PALDATA) << bits;
+ b[i] = inb(PALDATA) << bits;
}
inb(adp->va_crtc_addr + 6); /* reset flip/flop */
return 0;
@@ -2021,14 +2025,16 @@ vga_save_palette2(video_adapter_t *adp, int base, int count,
static int
vga_load_palette(video_adapter_t *adp, u_char *palette)
{
+ int bits;
int i;
prologue(adp, V_ADP_PALETTE, ENODEV);
outb(PIXMASK, 0xff); /* no pixelmask */
outb(PALWADR, 0x00);
+ bits = (adp->va_flags & V_ADP_DAC8) != 0 ? 0 : 2;
for (i = 0; i < 256*3; ++i)
- outb(PALDATA, palette[i] >> 2);
+ outb(PALDATA, palette[i] >> bits);
inb(adp->va_crtc_addr + 6); /* reset flip/flop */
outb(ATC, 0x20); /* enable palette */
return 0;
@@ -2038,16 +2044,18 @@ static int
vga_load_palette2(video_adapter_t *adp, int base, int count,
u_char *r, u_char *g, u_char *b)
{
+ int bits;
int i;
prologue(adp, V_ADP_PALETTE, ENODEV);
outb(PIXMASK, 0xff); /* no pixelmask */
outb(PALWADR, base);
+ bits = (adp->va_flags & V_ADP_DAC8) != 0 ? 0 : 2;
for (i = 0; i < count; ++i) {
- outb(PALDATA, r[i] >> 2);
- outb(PALDATA, g[i] >> 2);
- outb(PALDATA, b[i] >> 2);
+ outb(PALDATA, r[i] >> bits);
+ outb(PALDATA, g[i] >> bits);
+ outb(PALDATA, b[i] >> bits);
}
inb(adp->va_crtc_addr + 6); /* reset flip/flop */
outb(ATC, 0x20); /* enable palette */