summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64/dev/fb.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-12-02 11:25:10 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-12-02 11:25:10 +0000
commit5f7a51d9481bd1d438c6cefef01cde898e1e9cae (patch)
treee991a9c9d8596d7eba86952555d11f6c03481632 /sys/arch/sparc64/dev/fb.c
parentc7a7963da6902fde50c09b326f851dca9b7b5bb9 (diff)
Fix ri_devcmap[] to allow WSCOL_BLACK and WSCOL_WHITE to not have to be
different for sparc{,64} systems.
Diffstat (limited to 'sys/arch/sparc64/dev/fb.c')
-rw-r--r--sys/arch/sparc64/dev/fb.c100
1 files changed, 37 insertions, 63 deletions
diff --git a/sys/arch/sparc64/dev/fb.c b/sys/arch/sparc64/dev/fb.c
index 114f162821d..d189f340bbd 100644
--- a/sys/arch/sparc64/dev/fb.c
+++ b/sys/arch/sparc64/dev/fb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fb.c,v 1.14 2006/11/29 12:13:54 miod Exp $ */
+/* $OpenBSD: fb.c,v 1.15 2006/12/02 11:25:09 miod Exp $ */
/* $NetBSD: fb.c,v 1.23 1997/07/07 23:30:22 pk Exp $ */
/*
@@ -86,6 +86,15 @@
#include "wsdisplay.h"
/*
+ * Sun specific color indexes.
+ * Black is not really 7, but rather ~0; to fit within the 8 ANSI color
+ * palette we are using on console, we pick (~0) & 0x07 instead.
+ * This essentially swaps WSCOL_BLACK and WSCOL_WHITE.
+ */
+#define WSCOL_SUN_WHITE 0
+#define WSCOL_SUN_BLACK 7
+
+/*
* emergency unblank code
* XXX should be somewhat moved to wscons MI code
*/
@@ -105,7 +114,6 @@ fb_unblank()
static int a2int(char *, int);
static void fb_initwsd(struct sunfb *);
static void fb_updatecursor(struct rasops_info *);
-int fb_alloc_cattr(void *, int, int, int, long *);
void
fb_setsize(struct sunfb *sf, int def_depth, int def_width, int def_height,
@@ -184,15 +192,12 @@ fbwscons_init(struct sunfb *sf, int flags)
cols = a2int(getpropstring(optionsnode, "screen-#columns"), 80);
rasops_init(ri, rows, cols);
- if (ri->ri_caps & WSSCREEN_WSCOLORS)
- ri->ri_ops.alloc_attr = fb_alloc_cattr;
}
void
fbwscons_console_init(struct sunfb *sf, int row)
{
struct rasops_info *ri = &sf->sf_ro;
- int32_t tmp;
long defattr;
if (romgetcursoraddr(&sf->sf_crowp, &sf->sf_ccolp))
@@ -234,14 +239,20 @@ fbwscons_console_init(struct sunfb *sf, int row)
(sf->sf_ccolp != NULL || sf->sf_crowp != NULL))
ri->ri_updatecursor = fb_updatecursor;
- /*
- * Select appropriate color settings to mimic a
- * black on white Sun console.
- */
- if (sf->sf_depth > 8) {
- tmp = ri->ri_devcmap[WSCOL_WHITE];
- ri->ri_devcmap[WSCOL_WHITE] = ri->ri_devcmap[WSCOL_BLACK];
- ri->ri_devcmap[WSCOL_BLACK] = tmp;
+ if (sf->sf_depth == 8) {
+ /*
+ * If we are running with an indexed palette, compensate
+ * the swap of black and white through ri_devcmap.
+ */
+ ri->ri_devcmap[WSCOL_SUN_BLACK] = 0;
+ ri->ri_devcmap[WSCOL_SUN_WHITE] = 0xffffffff;
+ } else if (sf->sf_depth > 8) {
+ /*
+ * If we are running on a direct color frame buffer,
+ * make the ``normal'' white the same as the highlighted
+ * white.
+ */
+ ri->ri_devcmap[WSCOL_WHITE] = ri->ri_devcmap[WSCOL_WHITE + 8];
}
if (ISSET(ri->ri_caps, WSSCREEN_WSCOLORS))
@@ -259,22 +270,27 @@ fbwscons_setcolormap(struct sunfb *sf,
void (*setcolor)(void *, u_int, u_int8_t, u_int8_t, u_int8_t))
{
int i;
- u_char *color;
+ const u_char *color;
if (sf->sf_depth <= 8 && setcolor != NULL) {
for (i = 0; i < 16; i++) {
- color = (u_char *)&rasops_cmap[i * 3];
+ color = &rasops_cmap[i * 3];
setcolor(sf, i, color[0], color[1], color[2]);
}
for (i = 240; i < 256; i++) {
- color = (u_char *)&rasops_cmap[i * 3];
+ color = &rasops_cmap[i * 3];
setcolor(sf, i, color[0], color[1], color[2]);
}
- /* compensate for BoW palette */
- setcolor(sf, WSCOL_BLACK, 0, 0, 0);
- setcolor(sf, 0xff ^ WSCOL_BLACK, 255, 255, 255);
- setcolor(sf, WSCOL_WHITE, 255, 255, 255);
- setcolor(sf, 0xff ^ WSCOL_WHITE, 0, 0, 0);
+ /*
+ * Compensate for BoW default hardware palette: existing
+ * output (which we do not want to affect) is black on
+ * white with color index 0 being white and 0xff being
+ * black.
+ */
+ setcolor(sf, WSCOL_SUN_WHITE, 0xff, 0xff, 0xff);
+ setcolor(sf, 0xff ^ WSCOL_SUN_WHITE, 0, 0, 0);
+ setcolor(sf, WSCOL_SUN_BLACK, 0, 0, 0);
+ setcolor(sf, 0xff ^ (WSCOL_SUN_BLACK), 0xff, 0xff, 0xff);
}
}
@@ -304,46 +320,4 @@ fbwscons_attach(struct sunfb *sf, struct wsdisplay_accessops *op, int isconsole)
config_found(&sf->sf_dev, &waa, wsemuldisplaydevprint);
}
-/*
- * A variant of rasops_alloc_cattr() which handles the WSCOL_BLACK and
- * WSCOL_WHITE specific values wrt highlighting.
- */
-int
-fb_alloc_cattr(void *cookie, int fg, int bg, int flg, long *attrp)
-{
- int swap;
-
- if ((flg & WSATTR_BLINK) != 0)
- return (EINVAL);
-
- if ((flg & WSATTR_WSCOLORS) == 0) {
- fg = WSCOL_WHITE;
- bg = WSCOL_BLACK;
- }
-
- if ((flg & WSATTR_REVERSE) != 0) {
- swap = fg;
- fg = bg;
- bg = swap;
- }
-
- if ((flg & WSATTR_HILIT) != 0) {
- if (fg == WSCOL_BLACK)
- fg = 8; /* ``regular'' dark gray */
- else if (fg != WSCOL_WHITE) /* white is always highlighted */
- fg += 8;
- }
-
- flg = ((flg & WSATTR_UNDERLINE) ? 1 : 0);
-
- /* we're lucky we do not need a different isgray table... */
- if (rasops_isgray[fg])
- flg |= 2;
- if (rasops_isgray[bg])
- flg |= 4;
-
- *attrp = (bg << 16) | (fg << 24) | flg;
- return (0);
-}
-
#endif /* NWSDISPLAY */