Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci/voyager split voyagerfb_putchar() into one metho...
details: https://anonhg.NetBSD.org/src/rev/d8a49060334b
branches: trunk
changeset: 778240:d8a49060334b
user: macallan <macallan%NetBSD.org@localhost>
date: Tue Mar 20 14:59:36 2012 +0000
description:
split voyagerfb_putchar() into one method for mono fonts and one for
anti-aliased fonts
diffstat:
sys/dev/pci/voyager/voyagerfb.c | 214 ++++++++++++++++++++++-----------------
1 files changed, 119 insertions(+), 95 deletions(-)
diffs (275 lines):
diff -r 561ce6d2c50b -r d8a49060334b sys/dev/pci/voyager/voyagerfb.c
--- a/sys/dev/pci/voyager/voyagerfb.c Tue Mar 20 13:03:33 2012 +0000
+++ b/sys/dev/pci/voyager/voyagerfb.c Tue Mar 20 14:59:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: voyagerfb.c,v 1.18 2012/03/13 18:40:34 elad Exp $ */
+/* $NetBSD: voyagerfb.c,v 1.19 2012/03/20 14:59:36 macallan Exp $ */
/*
* Copyright (c) 2009, 2011 Michael Lorenz
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.18 2012/03/13 18:40:34 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: voyagerfb.c,v 1.19 2012/03/20 14:59:36 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -142,7 +142,8 @@
int, int, int);
static void voyagerfb_cursor(void *, int, int, int);
-static void voyagerfb_putchar(void *, int, int, u_int, long);
+static void voyagerfb_putchar_mono(void *, int, int, u_int, long);
+static void voyagerfb_putchar_aa32(void *, int, int, u_int, long);
static void voyagerfb_copycols(void *, int, int, int, int);
static void voyagerfb_erasecols(void *, int, int, int, long);
static void voyagerfb_copyrows(void *, int, int, int);
@@ -548,7 +549,8 @@
ri->ri_flg |= RI_CLEAR;
}
#ifdef VOYAGERFB_ANTIALIAS
- ri->ri_flg |= RI_ENABLE_ALPHA;
+ if (sc->sc_depth == 32)
+ ri->ri_flg |= RI_ENABLE_ALPHA;
#endif
rasops_init(ri, 0, 0);
@@ -563,7 +565,10 @@
ri->ri_ops.eraserows = voyagerfb_eraserows;
ri->ri_ops.erasecols = voyagerfb_erasecols;
ri->ri_ops.cursor = voyagerfb_cursor;
- ri->ri_ops.putchar = voyagerfb_putchar;
+ if (FONT_IS_ALPHA(ri->ri_font)) {
+ ri->ri_ops.putchar = voyagerfb_putchar_aa32;
+ } else
+ ri->ri_ops.putchar = voyagerfb_putchar_mono;
}
static int
@@ -844,9 +849,8 @@
}
}
-
static void
-voyagerfb_putchar(void *cookie, int row, int col, u_int c, long attr)
+voyagerfb_putchar_mono(void *cookie, int row, int col, u_int c, long attr)
{
struct rasops_info *ri = cookie;
struct wsdisplay_font *font = PICK_FONT(ri, c);
@@ -856,6 +860,67 @@
int fg, bg;
uint8_t *data;
int x, y, wi, he;
+
+ if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL)
+ return;
+
+ if (!CHAR_IN_FONT(c, font))
+ return;
+
+ wi = font->fontwidth;
+ he = font->fontheight;
+
+ bg = ri->ri_devcmap[(attr >> 16) & 0x0f];
+ fg = ri->ri_devcmap[(attr >> 24) & 0x0f];
+ x = ri->ri_xorigin + col * wi;
+ y = ri->ri_yorigin + row * he;
+ if (c == 0x20) {
+ voyagerfb_rectfill(sc, x, y, wi, he, bg);
+ return;
+ }
+
+ data = WSFONT_GLYPH(c, font);
+
+ cmd = ROP_COPY |
+ SM502_CTRL_USE_ROP2 |
+ SM502_CTRL_CMD_HOSTWRT |
+ SM502_CTRL_HOSTBLT_MONO |
+ SM502_CTRL_QUICKSTART_E |
+ SM502_CTRL_MONO_PACK_32BIT;
+ voyagerfb_ready(sc);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_CONTROL, cmd);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_FOREGROUND, fg);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_BACKGROUND, bg);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_SRC, 0);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_DST, (x << 16) | y);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh,
+ SM502_DIMENSION, (wi << 16) | he);
+ /* now feed the data, padded to 32bit */
+ switch (ri->ri_font->stride) {
+ case 1:
+ voyagerfb_feed8(sc, data, ri->ri_fontscale);
+ break;
+ case 2:
+ voyagerfb_feed16(sc, (uint16_t *)data,
+ ri->ri_fontscale);
+ break;
+ }
+}
+
+static void
+voyagerfb_putchar_aa32(void *cookie, int row, int col, u_int c, long attr)
+{
+ struct rasops_info *ri = cookie;
+ struct wsdisplay_font *font = PICK_FONT(ri, c);
+ struct vcons_screen *scr = ri->ri_hw;
+ struct voyagerfb_softc *sc = scr->scr_cookie;
+ uint32_t cmd;
+ int fg, bg;
+ uint8_t *data;
+ int x, y, wi, he;
+ int i, j, r, g, b, aval, pad;
+ int rf, gf, bf, rb, gb, bb;
+ uint32_t pixel;
int rv;
if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL)
@@ -877,98 +942,57 @@
}
data = WSFONT_GLYPH(c, font);
- if (!FONT_IS_ALPHA(font)) {
- /* this is a mono font */
- cmd = ROP_COPY |
- SM502_CTRL_USE_ROP2 |
- SM502_CTRL_CMD_HOSTWRT |
- SM502_CTRL_HOSTBLT_MONO |
- SM502_CTRL_QUICKSTART_E |
- SM502_CTRL_MONO_PACK_32BIT;
- voyagerfb_ready(sc);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_CONTROL, cmd);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_FOREGROUND, fg);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_BACKGROUND, bg);
- bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_SRC, 0);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_DST, (x << 16) | y);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_DIMENSION, (wi << 16) | he);
- /* now feed the data, padded to 32bit */
- switch (ri->ri_font->stride) {
- case 1:
- voyagerfb_feed8(sc, data, ri->ri_fontscale);
- break;
- case 2:
- voyagerfb_feed16(sc, (uint16_t *)data,
- ri->ri_fontscale);
- break;
-
- }
- } else {
- /*
- * alpha font
- * we can't accelerate the actual alpha blending but
- * we can at least use a host blit to go through the
- * pipeline instead of having to sync the engine
- */
- int i, j, r, g, b, aval, pad;
- int rf, gf, bf, rb, gb, bb;
- uint32_t pixel;
+ /*
+ * we can't accelerate the actual alpha blending but
+ * we can at least use a host blit to go through the
+ * pipeline instead of having to sync the engine
+ */
- rv = glyphcache_try(&sc->sc_gc, c, x, y, attr);
- if (rv == GC_OK)
- return;
+ rv = glyphcache_try(&sc->sc_gc, c, x, y, attr);
+ if (rv == GC_OK)
+ return;
- cmd = ROP_COPY |
- SM502_CTRL_USE_ROP2 |
- SM502_CTRL_CMD_HOSTWRT |
- SM502_CTRL_QUICKSTART_E;
- voyagerfb_ready(sc);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_CONTROL, cmd);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_SRC, 0);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_DST, (x << 16) | y);
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_DIMENSION, (wi << 16) | he);
- rf = (fg >> 16) & 0xff;
- rb = (bg >> 16) & 0xff;
- gf = (fg >> 8) & 0xff;
- gb = (bg >> 8) & 0xff;
- bf = fg & 0xff;
- bb = bg & 0xff;
- pad = wi & 1;
- for (i = 0; i < he; i++) {
- for (j = 0; j < wi; j++) {
- aval = *data;
- data++;
- if (aval == 0) {
- pixel = bg;
- } else if (aval == 255) {
- pixel = fg;
- } else {
- r = aval * rf + (255 - aval) * rb;
- g = aval * gf + (255 - aval) * gb;
- b = aval * bf + (255 - aval) * bb;
- pixel = (r & 0xff00) << 8 |
- (g & 0xff00) |
- (b & 0xff00) >> 8;
- }
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_DATAPORT, pixel);
+ cmd = ROP_COPY |
+ SM502_CTRL_USE_ROP2 |
+ SM502_CTRL_CMD_HOSTWRT |
+ SM502_CTRL_QUICKSTART_E;
+ voyagerfb_ready(sc);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_CONTROL, cmd);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_SRC, 0);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_DST, (x << 16) | y);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_DIMENSION, (wi << 16) | he);
+ rf = (fg >> 16) & 0xff;
+ rb = (bg >> 16) & 0xff;
+ gf = (fg >> 8) & 0xff;
+ gb = (bg >> 8) & 0xff;
+ bf = fg & 0xff;
+ bb = bg & 0xff;
+ pad = wi & 1;
+ for (i = 0; i < he; i++) {
+ for (j = 0; j < wi; j++) {
+ aval = *data;
+ data++;
+ if (aval == 0) {
+ pixel = bg;
+ } else if (aval == 255) {
+ pixel = fg;
+ } else {
+ r = aval * rf + (255 - aval) * rb;
+ g = aval * gf + (255 - aval) * gb;
+ b = aval * bf + (255 - aval) * bb;
+ pixel = (r & 0xff00) << 8 |
+ (g & 0xff00) |
+ (b & 0xff00) >> 8;
}
- if (pad)
- bus_space_write_4(sc->sc_memt, sc->sc_regh,
- SM502_DATAPORT, 0);
+ bus_space_write_4(sc->sc_memt, sc->sc_regh,
+ SM502_DATAPORT, pixel);
}
- if (rv == GC_ADD) {
- glyphcache_add(&sc->sc_gc, c, x, y);
- }
+ if (pad)
+ bus_space_write_4(sc->sc_memt, sc->sc_regh,
+ SM502_DATAPORT, 0);
+ }
+ if (rv == GC_ADD) {
+ glyphcache_add(&sc->sc_gc, c, x, y);
}
}
Home |
Main Index |
Thread Index |
Old Index