svn commit: r279855 - head/sys/dev/vt/hw/ofwfb

Nathan Whitehorn nwhitehorn at FreeBSD.org
Tue Mar 10 17:04:12 UTC 2015


Author: nwhitehorn
Date: Tue Mar 10 17:04:11 2015
New Revision: 279855
URL: https://svnweb.freebsd.org/changeset/base/279855

Log:
  Let unchangeable 8-bit frame buffers have vaguely correct colors.
  
  MFC after:	2 weeks

Modified:
  head/sys/dev/vt/hw/ofwfb/ofwfb.c

Modified: head/sys/dev/vt/hw/ofwfb/ofwfb.c
==============================================================================
--- head/sys/dev/vt/hw/ofwfb/ofwfb.c	Tue Mar 10 16:06:07 2015	(r279854)
+++ head/sys/dev/vt/hw/ofwfb/ofwfb.c	Tue Mar 10 17:04:11 2015	(r279855)
@@ -54,6 +54,7 @@ struct ofwfb_softc {
 	phandle_t	sc_node;
 	ihandle_t	sc_handle;
 	bus_space_tag_t	sc_memt;
+	int		iso_palette;
 };
 
 static vd_probe_t	ofwfb_probe;
@@ -73,6 +74,12 @@ static const struct vt_driver vt_ofwfb_d
 	.vd_priority	= VD_PRIORITY_GENERIC+1,
 };
 
+static unsigned char ofw_colors[16] = {
+	/* See "16-color Text Extension" Open Firmware document, page 4 */
+	0, 4, 2, 6, 1, 5, 3, 7,
+	8, 12, 10, 14, 9, 13, 11, 15
+};
+
 static struct ofwfb_softc ofwfb_conssoftc;
 VT_DRIVER_DECLARE(vt_ofwfb, vt_ofwfb_driver);
 
@@ -121,6 +128,11 @@ ofwfb_bitblt_bitmap(struct vt_device *vd
 	bgc = sc->fb_cmap[bg];
 	b = m = 0;
 
+	if (((struct ofwfb_softc *)vd->vd_softc)->iso_palette) {
+		fg = ofw_colors[fg];
+		bg = ofw_colors[bg];
+	}
+
 	line = (sc->fb_stride * y) + x * sc->fb_bpp/8;
 	if (mask == NULL && sc->fb_bpp == 8 && (width % 8 == 0)) {
 		/* Don't try to put off screen pixels */
@@ -255,7 +267,7 @@ static void
 ofwfb_initialize(struct vt_device *vd)
 {
 	struct ofwfb_softc *sc = vd->vd_softc;
-	int i;
+	int i, err;
 	cell_t retval;
 	uint32_t oldpix;
 
@@ -263,18 +275,24 @@ ofwfb_initialize(struct vt_device *vd)
 	 * Set up the color map
 	 */
 
+	sc->iso_palette = 0;
 	switch (sc->fb.fb_bpp) {
 	case 8:
 		vt_generate_cons_palette(sc->fb.fb_cmap, COLOR_FORMAT_RGB, 255,
 		    16, 255, 8, 255, 0);
 
 		for (i = 0; i < 16; i++) {
-			OF_call_method("color!", sc->sc_handle, 4, 1,
+			err = OF_call_method("color!", sc->sc_handle, 4, 1,
 			    (cell_t)((sc->fb.fb_cmap[i] >> 16) & 0xff),
 			    (cell_t)((sc->fb.fb_cmap[i] >> 8) & 0xff),
 			    (cell_t)((sc->fb.fb_cmap[i] >> 0) & 0xff),
 			    (cell_t)i, &retval);
+			if (err)
+				break;
 		}
+		if (i != 16)
+			sc->iso_palette = 1;
+				
 		break;
 
 	case 32:


More information about the svn-src-head mailing list