1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-30 12:04:07 +00:00

Let unchangeable 8-bit frame buffers have vaguely correct colors.

MFC after:	2 weeks
This commit is contained in:
Nathan Whitehorn 2015-03-10 17:04:11 +00:00
parent 996f8471b1
commit 25023a8a88
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=279855

View File

@ -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: