diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-12-02 11:25:10 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-12-02 11:25:10 +0000 |
commit | 5f7a51d9481bd1d438c6cefef01cde898e1e9cae (patch) | |
tree | e991a9c9d8596d7eba86952555d11f6c03481632 /sys | |
parent | c7a7963da6902fde50c09b326f851dca9b7b5bb9 (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')
-rw-r--r-- | sys/arch/sparc/dev/fb.c | 100 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/fb.c | 100 | ||||
-rw-r--r-- | sys/dev/wscons/wsdisplayvar.h | 10 | ||||
-rw-r--r-- | sys/dev/wscons/wsemul_sun.c | 22 |
4 files changed, 81 insertions, 151 deletions
diff --git a/sys/arch/sparc/dev/fb.c b/sys/arch/sparc/dev/fb.c index 36bac1da16c..cf38948d23f 100644 --- a/sys/arch/sparc/dev/fb.c +++ b/sys/arch/sparc/dev/fb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fb.c,v 1.40 2006/11/29 12:13:54 miod Exp $ */ +/* $OpenBSD: fb.c,v 1.41 2006/12/02 11:25:07 miod Exp $ */ /* $NetBSD: fb.c,v 1.23 1997/07/07 23:30:22 pk Exp $ */ /* @@ -90,6 +90,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 */ @@ -111,7 +120,6 @@ static int a2int(char *, int); #endif static void fb_initwsd(struct sunfb *); static void fb_updatecursor(struct rasops_info *); -int fb_alloc_cattr(void *, int, int, int, long *); int fb_alloc_screen(void *, const struct wsscreen_descr *, void **, int *, int *, long *); void fb_free_screen(void *, void *); @@ -367,15 +375,12 @@ fbwscons_init(struct sunfb *sf, int flags) #endif 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 (CPU_ISSUN4 || romgetcursoraddr(&sf->sf_crowp, &sf->sf_ccolp)) @@ -417,14 +422,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 hilighted + * white. + */ + ri->ri_devcmap[WSCOL_WHITE] = ri->ri_devcmap[WSCOL_WHITE + 8]; } if (ISSET(ri->ri_caps, WSSCREEN_WSCOLORS)) @@ -443,22 +454,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); } } @@ -535,48 +551,6 @@ fb_show_screen(void *v, void *cookie, int waitok, void (*cb)(void *, int, int), return (0); } -/* - * 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); -} - #if defined(SUN4) /* 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 */ diff --git a/sys/dev/wscons/wsdisplayvar.h b/sys/dev/wscons/wsdisplayvar.h index 15138079c99..3ca65a69866 100644 --- a/sys/dev/wscons/wsdisplayvar.h +++ b/sys/dev/wscons/wsdisplayvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplayvar.h,v 1.21 2006/11/29 19:11:17 miod Exp $ */ +/* $OpenBSD: wsdisplayvar.h,v 1.22 2006/12/02 11:25:09 miod Exp $ */ /* $NetBSD: wsdisplayvar.h,v 1.30 2005/02/04 02:10:49 perry Exp $ */ /* @@ -64,20 +64,14 @@ struct wsdisplay_emulops { int (*alloc_attr)(void *c, int fg, int bg, int flags, long *attrp); void (*unpack_attr)(void *c, long attr, int *fg, int *bg, int *ul); /* fg / bg values. Made identical to ANSI terminal color codes. */ -/* XXX should be #if NWSEMUL_SUN > 1 */ -#if defined(__sparc__) || defined(__sparc64__) -#define WSCOL_WHITE 0 -#define WSCOL_BLACK 15 -#else #define WSCOL_BLACK 0 -#define WSCOL_WHITE 7 -#endif #define WSCOL_RED 1 #define WSCOL_GREEN 2 #define WSCOL_BROWN 3 #define WSCOL_BLUE 4 #define WSCOL_MAGENTA 5 #define WSCOL_CYAN 6 +#define WSCOL_WHITE 7 /* flag values: */ #define WSATTR_REVERSE 1 #define WSATTR_HILIT 2 diff --git a/sys/dev/wscons/wsemul_sun.c b/sys/dev/wscons/wsemul_sun.c index 944e934dae6..633b67456c6 100644 --- a/sys/dev/wscons/wsemul_sun.c +++ b/sys/dev/wscons/wsemul_sun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsemul_sun.c,v 1.17 2006/08/17 06:27:04 miod Exp $ */ +/* $OpenBSD: wsemul_sun.c,v 1.18 2006/12/02 11:25:09 miod Exp $ */ /* $NetBSD: wsemul_sun.c,v 1.11 2000/01/05 11:19:36 drochner Exp $ */ /* @@ -471,27 +471,15 @@ wsemul_sun_control(edp, c) flags |= WSATTR_REVERSE; break; /* ANSI foreground color */ - case 30: - fgcol = WSCOL_BLACK; - break; - case 31: case 32: case 33: - case 34: case 35: case 36: + case 30: case 31: case 32: case 33: + case 34: case 35: case 36: case 37: fgcol = ARG(n,edp->nargs) - 30; break; - case 37: - fgcol = WSCOL_WHITE; - break; /* ANSI background color */ - case 40: - bgcol = WSCOL_BLACK; - break; - case 41: case 42: case 43: - case 44: case 45: case 46: + case 40: case 41: case 42: case 43: + case 44: case 45: case 46: case 47: bgcol = ARG(n,edp->nargs) - 40; break; - case 47: - bgcol = WSCOL_WHITE; - break; } } setattr: |