summaryrefslogtreecommitdiffstats
path: root/sys/dev/vt
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2015-03-10 17:04:11 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2015-03-10 17:04:11 +0000
commit9f2a127decf36a6f4c98114b704c179d4a33c516 (patch)
treef198f4677ce98320ff740c11460ca224a0780841 /sys/dev/vt
parent3121e258c76aac03e285cba717a62be6d46f1b60 (diff)
downloadFreeBSD-src-9f2a127decf36a6f4c98114b704c179d4a33c516.zip
FreeBSD-src-9f2a127decf36a6f4c98114b704c179d4a33c516.tar.gz
Let unchangeable 8-bit frame buffers have vaguely correct colors.
MFC after: 2 weeks
Diffstat (limited to 'sys/dev/vt')
-rw-r--r--sys/dev/vt/hw/ofwfb/ofwfb.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/sys/dev/vt/hw/ofwfb/ofwfb.c b/sys/dev/vt/hw/ofwfb/ofwfb.c
index ad5b664..acad5d4 100644
--- a/sys/dev/vt/hw/ofwfb/ofwfb.c
+++ b/sys/dev/vt/hw/ofwfb/ofwfb.c
@@ -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_driver = {
.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, const struct vt_window *vw,
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:
OpenPOWER on IntegriCloud