aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/vt/hw/ofwfb/ofwfb.c
diff options
context:
space:
mode:
authorNathan Whitehorn <nwhitehorn@FreeBSD.org>2015-03-10 17:04:11 +0000
committerNathan Whitehorn <nwhitehorn@FreeBSD.org>2015-03-10 17:04:11 +0000
commit25023a8a88c50fb3bdcc5af1639a19f51e19b64e (patch)
treef198f4677ce98320ff740c11460ca224a0780841 /sys/dev/vt/hw/ofwfb/ofwfb.c
parent996f8471b103642312b3fb83365f5f9dd617b13e (diff)
downloadsrc-25023a8a88c50fb3bdcc5af1639a19f51e19b64e.tar.gz
src-25023a8a88c50fb3bdcc5af1639a19f51e19b64e.zip
Let unchangeable 8-bit frame buffers have vaguely correct colors.
MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=279855
Diffstat (limited to 'sys/dev/vt/hw/ofwfb/ofwfb.c')
-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 ad5b664a9d71..acad5d4d86c6 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: