Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/sbus support anti-aliased fonts, glyph caching etc.



details:   https://anonhg.NetBSD.org/src/rev/fe55d780611a
branches:  trunk
changeset: 781662:fe55d780611a
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Sep 21 01:07:44 2012 +0000

description:
support anti-aliased fonts, glyph caching etc.

diffstat:

 sys/dev/sbus/files.sbus |    4 +-
 sys/dev/sbus/p9100.c    |  202 +++++++++++++++++++++++++++++++++++++++++------
 sys/dev/sbus/p9100reg.h |   15 +-
 3 files changed, 185 insertions(+), 36 deletions(-)

diffs (truncated from 446 to 300 lines):

diff -r 609ff59856cb -r fe55d780611a sys/dev/sbus/files.sbus
--- a/sys/dev/sbus/files.sbus   Fri Sep 21 00:26:15 2012 +0000
+++ b/sys/dev/sbus/files.sbus   Fri Sep 21 01:07:44 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sbus,v 1.37 2010/08/18 21:11:50 macallan Exp $
+#      $NetBSD: files.sbus,v 1.38 2012/09/21 01:07:44 macallan Exp $
 #
 # Config file and device description for machine-independent SBUS code.
 # Included by ports that need it.
@@ -127,7 +127,7 @@
 defflag        opt_pnozz.h     PNOZZ_DEBUG
 defflag opt_pnozz.h    PNOZZ_EMUL_CG3
 defflag opt_pnozz.h    PNOZZ_USE_LATCH
-device pnozz: fb, rasops8, bt_dac, wsemuldisplaydev, vcons
+device pnozz: fb, rasops8, bt_dac, wsemuldisplaydev, vcons, glyphcache
 attach pnozz at sbus
 file   dev/sbus/p9100.c                pnozz needs-flag
 
diff -r 609ff59856cb -r fe55d780611a sys/dev/sbus/p9100.c
--- a/sys/dev/sbus/p9100.c      Fri Sep 21 00:26:15 2012 +0000
+++ b/sys/dev/sbus/p9100.c      Fri Sep 21 01:07:44 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: p9100.c,v 1.56 2012/01/11 16:08:57 macallan Exp $ */
+/*     $NetBSD: p9100.c,v 1.57 2012/09/21 01:07:44 macallan Exp $ */
 
 /*-
  * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: p9100.c,v 1.56 2012/01/11 16:08:57 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: p9100.c,v 1.57 2012/09/21 01:07:44 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -68,6 +68,7 @@
 #include <dev/rasops/rasops.h>
 
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/wscons/wsdisplay_glyphcachevar.h>
 
 #include "opt_wsemul.h"
 #include "rasops_glue.h"
@@ -132,6 +133,7 @@
        volatile uint32_t sc_last_offset;
        struct vcons_data vd;
        uint8_t         sc_dac_power;
+       glyphcache      sc_gc;
 };
 
 
@@ -167,6 +169,7 @@
     p9100_sbus_match, p9100_sbus_attach, NULL, NULL);
 
 static dev_type_open(p9100open);
+static dev_type_close(p9100close);
 static dev_type_ioctl(p9100ioctl);
 static dev_type_mmap(p9100mmap);
 
@@ -177,7 +180,7 @@
 
 /* frame buffer generic driver */
 static struct fbdriver p9100fbdriver = {
-       p9100unblank, p9100open, nullclose, p9100ioctl, nopoll,
+       p9100unblank, p9100open, p9100close, p9100ioctl, nopoll,
        p9100mmap, nokqfilter
 };
 
@@ -197,7 +200,7 @@
 
 #if NWSDISPLAY > 0
 static void    p9100_sync(struct p9100_softc *);
-static void    p9100_bitblt(void *, int, int, int, int, int, int, uint32_t);
+static void    p9100_bitblt(void *, int, int, int, int, int, int, int);
 static void    p9100_rectfill(void *, int, int, int, int, uint32_t);
 static void    p9100_clearscreen(struct p9100_softc *);
 
@@ -212,8 +215,11 @@
 static void    p9100_eraserows(void *, int, int, long);
 /*static int   p9100_mapchar(void *, int, u_int *);*/
 static void    p9100_putchar(void *, int, int, u_int, long);
+static void    p9100_putchar_aa(void *, int, int, u_int, long);
 static void    p9100_cursor(void *, int, int, int);
+#if 0
 static int     p9100_allocattr(void *, int, int, int, long *);
+#endif
 
 static int     p9100_putcmap(struct p9100_softc *, struct wsdisplay_cmap *);
 static int     p9100_getcmap(struct p9100_softc *, struct wsdisplay_cmap *);
@@ -292,7 +298,7 @@
        int isconsole;
        int node = sa->sa_node;
        int i, j;
-       uint8_t ver;
+       uint8_t ver, cmap[768];
 
 #if NWSDISPLAY > 0
        struct wsemuldisplaydev_attach_args aa;
@@ -412,18 +418,6 @@
        if ((1 << fb->fb_type.fb_depth) != fb->fb_type.fb_cmsize)
                printf(", %d entry colormap", fb->fb_type.fb_cmsize);
 
-       /* Initialize the default color map. */
-       j = 0;
-       for (i = 0; i < 256; i++) {
-               sc->sc_cmap.cm_map[i][0] = rasops_cmap[j];
-               j++;
-               sc->sc_cmap.cm_map[i][1] = rasops_cmap[j];
-               j++;
-               sc->sc_cmap.cm_map[i][2] = rasops_cmap[j];
-               j++;
-       }
-       p9100loadcmap(sc, 0, 256);
-
        /* make sure we are not blanked */
        if (isconsole)
                p9100_set_video(sc, 1);
@@ -448,12 +442,35 @@
 #if NWSDISPLAY > 0
        wsfont_init();
 
+#ifdef PNOZZ_DEBUG
+       /* make the glyph cache visible */
+       sc->sc_height -= 100;
+#endif
+
+       sc->sc_gc.gc_bitblt = p9100_bitblt;
+       sc->sc_gc.gc_blitcookie = sc;
+       sc->sc_gc.gc_rop = ROP_SRC;
+
        vcons_init(&sc->vd, sc, &p9100_defscreendesc, &p9100_accessops);
        sc->vd.init_screen = p9100_init_screen;
 
        vcons_init_screen(&sc->vd, &p9100_console_screen, 1, &defattr);
        p9100_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
 
+       /* Initialize the default color map. */
+       rasops_get_cmap(&p9100_console_screen.scr_ri, cmap, 768);
+
+       j = 0;
+       for (i = 0; i < 256; i++) {
+               sc->sc_cmap.cm_map[i][0] = cmap[j];
+               j++;
+               sc->sc_cmap.cm_map[i][1] = cmap[j];
+               j++;
+               sc->sc_cmap.cm_map[i][2] = cmap[j];
+               j++;
+       }
+       p9100loadcmap(sc, 0, 256);
+
        sc->sc_bg = (defattr >> 16) & 0xff;
        p9100_clearscreen(sc);
 
@@ -464,6 +481,13 @@
        p9100_defscreendesc.textops = &ri->ri_ops;
        p9100_defscreendesc.capabilities = ri->ri_caps;
 
+       glyphcache_init(&sc->sc_gc, sc->sc_height + 5,
+                       (0x200000 / sc->sc_stride) - sc->sc_height - 5,
+                       sc->sc_width,
+                       ri->ri_font->fontwidth,
+                       ri->ri_font->fontheight,
+                       defattr);
+
        if(isconsole) {
                wsdisplay_cnattach(&p9100_defscreendesc, ri, 0, 0, defattr);
                vcons_replay_msgbuf(&p9100_console_screen);
@@ -504,6 +528,22 @@
 }
 
 int
+p9100close(dev_t dev, int flags, int mode, struct lwp *l)
+{
+       struct p9100_softc *sc = device_lookup_private(&pnozz_cd, minor(dev));
+
+#if NWSDISPLAY > 0
+       p9100_init_engine(sc);
+       p9100_set_depth(sc, 8);
+       p9100loadcmap(sc, 0, 256);
+       p9100_clearscreen(sc);
+       glyphcache_wipe(&sc->sc_gc);
+       vcons_redraw_screen(sc->vd.active);
+#endif
+       return 0;
+}
+
+int
 p9100ioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
 {
        struct p9100_softc *sc = device_lookup_private(&pnozz_cd, minor(dev));
@@ -688,7 +728,7 @@
        p9100_ctl_write_4(sc, WINDOW_MIN, 0);
        p9100_ctl_write_4(sc, WINDOW_MAX, rmax);
        p9100_ctl_write_4(sc, BYTE_CLIP_MIN, 0);
-       p9100_ctl_write_4(sc, BYTE_CLIP_MAX, rmax);
+       p9100_ctl_write_4(sc, BYTE_CLIP_MAX, 0x3fff3fff);
        p9100_ctl_write_4(sc, DRAW_MODE, 0);
        p9100_ctl_write_4(sc, PLANE_MASK, 0xffffffff);
        p9100_ctl_write_4(sc, PATTERN0, 0xffffffff);
@@ -732,7 +772,7 @@
 /* screen-to-screen blit */
 static void
 p9100_bitblt(void *cookie, int xs, int ys, int xd, int yd, int wi,
-    int he, uint32_t rop)
+    int he, int rop)
 {
        struct p9100_softc *sc = cookie;
        uint32_t src, dst, srcw, dstw;
@@ -747,6 +787,7 @@
        p9100_sync(sc);
        
        p9100_ctl_write_4(sc, RASTER_OP, rop);
+       p9100_ctl_write_4(sc, BYTE_CLIP_MAX, 0x3fff3fff);
 
        p9100_ctl_write_4(sc, ABS_XY0, src << sc->sc_depthshift);
        p9100_ctl_write_4(sc, ABS_XY1, srcw << sc->sc_depthshift);
@@ -768,6 +809,7 @@
        src = ((xs & 0x3fff) << 16) | (ys & 0x3fff);
        srcw = (((xs + wi) & 0x3fff) << 16) | ((ys + he) & 0x3fff);
        p9100_sync(sc);
+       p9100_ctl_write_4(sc, BYTE_CLIP_MAX, 0x3fff3fff);
        p9100_set_color_reg(sc, FOREGROUND_COLOR, col);
        p9100_set_color_reg(sc, BACKGROUND_COLOR, col);
        p9100_ctl_write_4(sc, RASTER_OP, ROP_PAT);
@@ -794,6 +836,7 @@
        p9100_set_color_reg(sc,FOREGROUND_COLOR,bg);
        p9100_set_color_reg(sc,BACKGROUND_COLOR,fg);
 
+       p9100_ctl_write_4(sc, BYTE_CLIP_MAX, 0x3fff3fff);
        p9100_ctl_write_4(sc, RASTER_OP, ROP_SRC);
        p9100_ctl_write_4(sc, ABS_X0, x);
        p9100_ctl_write_4(sc, ABS_XY1, (x << 16) | (y & 0xFFFFL));
@@ -1089,7 +1132,7 @@
        struct vcons_screen *scr = ri->ri_hw;
        struct p9100_softc *sc = scr->scr_cookie;
 
-       int fg, bg, uc, i;
+       int fg, bg, i;
        uint8_t *data;
        int x, y, wi, he;
 
@@ -1107,9 +1150,7 @@
        if (c == 0x20) {
                p9100_rectfill(sc, x, y, wi, he, bg);
        } else {
-               uc = c - font->firstchar;
-               data = (uint8_t *)font->data + uc *
-                   ri->ri_fontscale;
+               data = WSFONT_GLYPH(c, font);
 
                p9100_setup_mono(sc, x, y, wi, 1, fg, bg);
                for (i = 0; i < he; i++) {
@@ -1120,6 +1161,107 @@
        }
 }
 
+static void
+p9100_putchar_aa(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 p9100_softc *sc = scr->scr_cookie;
+       uint32_t bg, latch = 0, bg8, fg8, pixel;
+       int i, j, x, y, wi, he, r, g, b, aval, rwi;
+       int r1, g1, b1, r0, g0, b0, fgo, bgo;
+       uint8_t *data8;
+       int rv;
+
+       if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) 
+               return;
+
+       if (!CHAR_IN_FONT(c, font))
+               return;
+
+       wi = font->fontwidth;
+       rwi = (wi + 3) & ~3;
+       he = font->fontheight;
+
+       bg = ri->ri_devcmap[(attr >> 16) & 0xf];
+       x = ri->ri_xorigin + col * wi;
+       y = ri->ri_yorigin + row * he;
+
+       if (c == 0x20) {
+               p9100_rectfill(sc, x, y, wi, he, bg);
+               return;
+       }
+
+       rv = glyphcache_try(&sc->sc_gc, c, x, y, attr);
+       if (rv == GC_OK)
+               return;
+
+       data8 = WSFONT_GLYPH(c, font);
+
+       p9100_sync(sc);
+
+       p9100_ctl_write_4(sc, RASTER_OP, ROP_SRC);
+       p9100_ctl_write_4(sc, ABS_X0, x);
+       p9100_ctl_write_4(sc, ABS_XY1, (x << 16) | (y & 0xFFFFL));



Home | Main Index | Thread Index | Old Index