From 9c4f6c7ab011435a492dd5cb1847bf00f290c219 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 31 Jan 2018 10:48:07 -0500 Subject: Fall back to VGA if the palette API isn't supported I ported vesa to use the VBE service back in: commit 55f585a15f42ffe028ff37ea1f63543795dbf56e Author: Adam Jackson Date: Fri Sep 18 17:02:16 2009 -0400 Use VBE palette load, not VGA banging. I'm reasonably sure that worked on all the hardware I had handy at the time. But it doesn't work in seabios, which means 8bpp is broken under qemu. We query this API early in initialization, and if it fails ->savedPal will be NULL, so use that as the hint to fall back to VGA banging. Signed-off-by: Adam Jackson Reviewed-by: Dave Airlie --- src/vesa.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/vesa.c b/src/vesa.c index cbf6773..3f5b81c 100644 --- a/src/vesa.c +++ b/src/vesa.c @@ -1356,6 +1356,27 @@ VESALoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, int i, idx; int base; + if (!pVesa->savedPal) { +#define VESADACDelay() \ + do { \ + (void)inb(pVesa->ioBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \ + (void)inb(pVesa->ioBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \ + } while (0) + + for (i = 0; i < numColors; i++) { + idx = indices[i]; + outb(pVesa->ioBase + VGA_DAC_WRITE_ADDR, idx); + VESADACDelay(); + outb(pVesa->ioBase + VGA_DAC_DATA, colors[idx].red); + VESADACDelay(); + outb(pVesa->ioBase + VGA_DAC_DATA, colors[idx].green); + VESADACDelay(); + outb(pVesa->ioBase + VGA_DAC_DATA, colors[idx].blue); + VESADACDelay(); + } + return; + } + if (pVesa->pal == NULL) pVesa->pal = calloc(1, sizeof(CARD32) * 256); -- cgit v1.2.1