summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-11-29 19:08:24 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-11-29 19:08:24 +0000
commitf1383d2d04a9e6ec1da4df59ac0ff1478bb10f9b (patch)
tree512b51f4e326e33ded20210f85a3a55fcc606db9 /sys/dev/ic
parent1b439ba33ce246b10f77ec8ccd4790e890966526 (diff)
Add an unpack_attr function to struct wsdisplay_emulops, to match the
existing alloc_attr function. This allows rasops_unpack_attr to be kept private to rasops, yet available to the screen drivers.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/sti.c19
-rw-r--r--sys/dev/ic/vga.c46
2 files changed, 58 insertions, 7 deletions
diff --git a/sys/dev/ic/sti.c b/sys/dev/ic/sti.c
index 3e93b4821cb..baa164462ff 100644
--- a/sys/dev/ic/sti.c
+++ b/sys/dev/ic/sti.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sti.c,v 1.46 2006/11/29 12:15:27 miod Exp $ */
+/* $OpenBSD: sti.c,v 1.47 2006/11/29 19:08:22 miod Exp $ */
/*
* Copyright (c) 2000-2003 Michael Shalayeff
@@ -60,7 +60,8 @@ void sti_copycols(void *v, int row, int srccol, int dstcol, int ncols);
void sti_erasecols(void *v, int row, int startcol, int ncols, long attr);
void sti_copyrows(void *v, int srcrow, int dstrow, int nrows);
void sti_eraserows(void *v, int row, int nrows, long attr);
-int sti_alloc_attr(void *v, int fg, int bg, int flags, long *);
+int sti_alloc_attr(void *v, int fg, int bg, int flags, long *pattr);
+void sti_unpack_attr(void *v, long attr, int *fg, int *bg, int *ul);
struct wsdisplay_emulops sti_emulops = {
sti_cursor,
@@ -70,7 +71,8 @@ struct wsdisplay_emulops sti_emulops = {
sti_erasecols,
sti_copyrows,
sti_eraserows,
- sti_alloc_attr
+ sti_alloc_attr,
+ sti_unpack_attr
};
int sti_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p);
@@ -95,7 +97,7 @@ struct wsscreen_descr sti_default_screen = {
"default", 0, 0,
&sti_emulops,
0, 0,
- WSSCREEN_REVERSE | WSSCREEN_UNDERLINE
+ 0
};
const struct wsscreen_descr *sti_default_scrlist[] = {
@@ -1035,6 +1037,15 @@ sti_alloc_attr(v, fg, bg, flags, pattr)
return 0;
}
+void
+sti_unpack_attr(void *v, long attr, int *fg, int *bg, int *ul)
+{
+ *fg = WSCOL_WHITE;
+ *bg = WSCOL_BLACK;
+ if (ul != NULL)
+ *ul = 0;
+}
+
/*
* Console support
*/
diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c
index c5489d3df46..d6a58b4b81d 100644
--- a/sys/dev/ic/vga.c
+++ b/sys/dev/ic/vga.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vga.c,v 1.40 2006/11/29 12:13:54 miod Exp $ */
+/* $OpenBSD: vga.c,v 1.41 2006/11/29 19:08:22 miod Exp $ */
/* $NetBSD: vga.c,v 1.28.2.1 2000/06/30 16:27:47 simonb Exp $ */
/*
@@ -102,6 +102,7 @@ int vga_mapchar(void *, int, unsigned int *);
void vga_putchar(void *, int, int, u_int, long);
int vga_alloc_attr(void *, int, int, int, long *);
void vga_copyrows(void *, int, int, int);
+void vga_unpack_attr(void *, long, int *, int *, int *);
static const struct wsdisplay_emulops vga_emulops = {
pcdisplay_cursor,
@@ -111,13 +112,14 @@ static const struct wsdisplay_emulops vga_emulops = {
pcdisplay_erasecols,
vga_copyrows,
pcdisplay_eraserows,
- vga_alloc_attr
+ vga_alloc_attr,
+ vga_unpack_attr
};
/*
* translate WS(=ANSI) color codes to standard pc ones
*/
-static unsigned char fgansitopc[] = {
+static const unsigned char fgansitopc[] = {
#ifdef __alpha__
/*
* XXX DEC HAS SWITCHED THE CODES FOR BLUE AND RED!!!
@@ -140,6 +142,20 @@ static unsigned char fgansitopc[] = {
#endif
};
+/*
+ * translate standard pc color codes to WS(=ANSI) ones
+ */
+static const u_int8_t pctoansi[] = {
+#ifdef __alpha__
+ WSCOL_BLACK, WSCOL_RED, WSCOL_GREEN, WSCOL_BROWN,
+ WSCOL_BLUE, WSCOL_MAGENTA, WSCOL_CYAN, WSCOL_WHITE
+#else
+ WSCOL_BLACK, WSCOL_BLUE, WSCOL_GREEN, WSCOL_CYAN,
+ WSCOL_RED, WSCOL_MAGENTA, WSCOL_BROWN, WSCOL_WHITE
+#endif
+};
+
+
const struct wsscreen_descr vga_stdscreen = {
"80x25", 80, 25,
&vga_emulops,
@@ -980,6 +996,30 @@ vga_alloc_attr(id, fg, bg, flags, attrp)
}
void
+vga_unpack_attr(id, attr, fg, bg, ul)
+ void *id;
+ long attr;
+ int *fg, *bg, *ul;
+{
+ struct vgascreen *scr = id;
+ struct vga_config *vc = scr->cfg;
+
+ if (vc->hdl.vh_mono) {
+ *fg = (attr & 0x07) == 0x07 ? WSCOL_WHITE : WSCOL_BLACK;
+ *bg = attr & 0x70 ? WSCOL_WHITE : WSCOL_BLACK;
+ if (ul != NULL)
+ *ul = *fg != WSCOL_WHITE && (attr & 0x01) ? 1 : 0;
+ } else {
+ *fg = pctoansi[attr & 0x07];
+ *bg = pctoansi[(attr & 0x70) >> 4];
+ if (*ul != NULL)
+ *ul = 0;
+ }
+ if (attr & FG_INTENSE)
+ *fg += 8;
+}
+
+void
vga_copyrows(id, srcrow, dstrow, nrows)
void *id;
int srcrow, dstrow, nrows;