[PATCH xf86-video-vesa 2/4] Fall back to VGA if the palette API isn't supported

Adam Jackson ajax at redhat.com
Wed Jan 31 15:48:07 UTC 2018


I ported vesa to use the VBE service back in:

    commit 55f585a15f42ffe028ff37ea1f63543795dbf56e
    Author: Adam Jackson <ajax at redhat.com>
    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 <ajax at redhat.com>
---
 src/vesa.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

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);
 
-- 
2.14.3



More information about the xorg-devel mailing list