Module Name:    src
Committed By:   macallan
Date:           Thu Feb 16 17:33:28 UTC 2012

Modified Files:
        src/sys/dev/pci: files.pci r128fb.c radeonfb.c radeonfbvar.h

Log Message:
cache glyphs in video memory when using anti-aliased fonts on r128fb and
radeonfb


To generate a diff of this commit:
cvs rdiff -u -r1.354 -r1.355 src/sys/dev/pci/files.pci
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/r128fb.c
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/pci/radeonfb.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/radeonfbvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/files.pci
diff -u src/sys/dev/pci/files.pci:1.354 src/sys/dev/pci/files.pci:1.355
--- src/sys/dev/pci/files.pci:1.354	Tue Jan 24 01:58:40 2012
+++ src/sys/dev/pci/files.pci	Thu Feb 16 17:33:28 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.354 2012/01/24 01:58:40 rkujawa Exp $
+#	$NetBSD: files.pci,v 1.355 2012/02/16 17:33:28 macallan Exp $
 #
 # Config file and device description for machine-independent PCI code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -837,7 +837,7 @@ file	dev/pci/unichromefb.c		unichromefb 
 
 # ATI Radeon framebuffer console driver
 # (Note: to enable the BIOS parser, add options RADEON_BIOS_INIT to the config)
-device	radeonfb: wsemuldisplaydev, videomode, rasops8, rasops32, vcons, splash, i2cbus, i2c_bitbang, ddc_read_edid, edid, drm
+device	radeonfb: wsemuldisplaydev, videomode, rasops8, rasops32, vcons, splash, i2cbus, i2c_bitbang, ddc_read_edid, edid, drm, glyphcache
 attach	radeonfb at pci
 file	dev/pci/radeonfb.c	radeonfb
 file	dev/pci/radeonfb_i2c.c	radeonfb
@@ -980,7 +980,7 @@ attach	ichsmb at pci
 file	dev/pci/ichsmb.c		ichsmb
 
 # ATI Rage 128 framebuffer console driver
-device	r128fb: wsemuldisplaydev, rasops8, rasops32, vcons, videomode, i2cbus, i2c_bitbang
+device	r128fb: wsemuldisplaydev, rasops8, rasops32, vcons, videomode, i2cbus, i2c_bitbang, glyphcache
 attach	r128fb at pci
 file	dev/pci/r128fb.c		r128fb
 defflag	opt_r128fb.h	R128FB_DEBUG
@@ -1041,7 +1041,7 @@ defflag	opt_voyager.h	VOYAGER_DEBUG
 include "dev/pci/hdaudio/files.hdaudio"
 
 # Permedia 2 / Sun PGX32 / Raptor
-device	pm2fb: wsemuldisplaydev, rasops8, vcons, videomode, i2cbus, i2c_bitbang
+device	pm2fb: wsemuldisplaydev, rasops8, rasops32, vcons, videomode, i2cbus, i2c_bitbang, ddc_read_edid, edid
 attach	pm2fb at pci
 file	dev/pci/pm2fb.c		pm2fb
 defflag	opt_pm2fb.h	PM2FB_DEBUG

Index: src/sys/dev/pci/r128fb.c
diff -u src/sys/dev/pci/r128fb.c:1.28 src/sys/dev/pci/r128fb.c:1.29
--- src/sys/dev/pci/r128fb.c:1.28	Mon Jan 30 19:41:22 2012
+++ src/sys/dev/pci/r128fb.c	Thu Feb 16 17:33:28 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: r128fb.c,v 1.28 2012/01/30 19:41:22 drochner Exp $	*/
+/*	$NetBSD: r128fb.c,v 1.29 2012/02/16 17:33:28 macallan Exp $	*/
 
 /*
  * Copyright (c) 2007 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.28 2012/01/30 19:41:22 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.29 2012/02/16 17:33:28 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
 #include <dev/pci/wsdisplay_pci.h>
+#include <dev/wscons/wsdisplay_glyphcachevar.h>
 
 #include <dev/i2c/i2cvar.h>
 
@@ -93,6 +94,7 @@ struct r128fb_softc {
 	u_char sc_cmap_blue[256];
 	/* engine stuff */
 	uint32_t sc_master_cntl;
+	glyphcache sc_gc;
 };
 
 static int	r128fb_match(device_t, cfdata_t, void *);
@@ -118,7 +120,7 @@ static void	r128fb_init(struct r128fb_so
 static void	r128fb_flush_engine(struct r128fb_softc *);
 static void	r128fb_rectfill(struct r128fb_softc *, int, int, int, int,
 			    uint32_t);
-static void	r128fb_bitblt(struct r128fb_softc *, int, int, int, int, int,
+static void	r128fb_bitblt(void *, int, int, int, int, int,
 			    int, int);
 
 static void	r128fb_cursor(void *, int, int, int);
@@ -309,6 +311,9 @@ r128fb_attach(device_t parent, device_t 
 		}
 	}
 
+	sc->sc_gc.gc_bitblt = r128fb_bitblt;
+	sc->sc_gc.gc_blitcookie = sc;
+	sc->sc_gc.gc_rop = R128_ROP3_S;
 	if (is_console) {
 		vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
 		    &defattr);
@@ -320,6 +325,12 @@ r128fb_attach(device_t parent, device_t 
 		sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
 		sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
 		sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
+		glyphcache_init(&sc->sc_gc, sc->sc_height,
+				sc->sc_width,
+				(0x800000 / sc->sc_stride) - sc->sc_height,
+				ri->ri_font->fontwidth,
+				ri->ri_font->fontheight,
+				defattr);
 		wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
 		    defattr);
 		vcons_replay_msgbuf(&sc->sc_console_screen);
@@ -329,6 +340,12 @@ r128fb_attach(device_t parent, device_t 
 		 * until someone actually allocates a screen for us
 		 */
 		(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
+		glyphcache_init(&sc->sc_gc, sc->sc_height,
+				sc->sc_width,
+				(0x800000 / sc->sc_stride) - sc->sc_height,
+				ri->ri_font->fontwidth,
+				ri->ri_font->fontheight,
+				defattr);
 	}
 
 	/* no suspend/resume support yet */
@@ -411,6 +428,7 @@ r128fb_ioctl(void *v, void *vs, u_long c
 			if(new_mode == WSDISPLAYIO_MODE_EMUL) {
 				r128fb_init(sc);
 				r128fb_restore_palette(sc);
+				glyphcache_wipe(&sc->sc_gc);
 				r128fb_rectfill(sc, 0, 0, sc->sc_width,
 				    sc->sc_height, ms->scr_ri.ri_devcmap[
 				    (ms->scr_defattr >> 16) & 0xff]);
@@ -549,6 +567,10 @@ r128fb_init_screen(void *cookie, struct 
 	ri->ri_ops.cursor = r128fb_cursor;
 	if (FONT_IS_ALPHA(ri->ri_font)) {
 		ri->ri_ops.putchar = r128fb_putchar_aa;
+		printf("before: %08x\n", (uint32_t)sc->sc_gc.gc_attr);
+		ri->ri_ops.allocattr(ri, WS_DEFAULT_FG, WS_DEFAULT_BG,
+		     0, &sc->sc_gc.gc_attr);
+		printf("after: %08x\n", (uint32_t)sc->sc_gc.gc_attr);
 	} else
 		ri->ri_ops.putchar = r128fb_putchar;
 }
@@ -744,9 +766,10 @@ r128fb_rectfill(struct r128fb_softc *sc,
 }
 
 static void
-r128fb_bitblt(struct r128fb_softc *sc, int xs, int ys, int xd, int yd,
+r128fb_bitblt(void *cookie, int xs, int ys, int xd, int yd,
     int wi, int he, int rop)
 {
+	struct r128fb_softc *sc = cookie;
 	uint32_t dp_cntl = 0;
 
 	r128fb_wait(sc, 5);
@@ -925,6 +948,7 @@ r128fb_putchar_aa(void *cookie, int row,
 	int i, x, y, wi, he, r, g, b, aval;
 	int r1, g1, b1, r0, g0, b0, fgo, bgo;
 	uint8_t *data8;
+	int rv;
 
 	if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL) 
 		return;
@@ -943,6 +967,10 @@ r128fb_putchar_aa(void *cookie, int row,
 		return;
 	}
 
+	rv = glyphcache_try(&sc->sc_gc, c, x, y, attr);
+	if (rv == GC_OK)
+		return;
+
 	data8 = WSFONT_GLYPH(c, font);
 
 	r128fb_wait(sc, 5);
@@ -1014,6 +1042,9 @@ r128fb_putchar_aa(void *cookie, int row,
 		bus_space_write_stream_4(sc->sc_memt, sc->sc_regh,
 				    R128_HOST_DATA0, latch);
 	}
+	if (rv == GC_ADD) {
+		glyphcache_add(&sc->sc_gc, c, x, y);
+	}
 }
 
 static void

Index: src/sys/dev/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.53 src/sys/dev/pci/radeonfb.c:1.54
--- src/sys/dev/pci/radeonfb.c:1.53	Mon Jan 30 19:41:23 2012
+++ src/sys/dev/pci/radeonfb.c	Thu Feb 16 17:33:28 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.53 2012/01/30 19:41:23 drochner Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.54 2012/02/16 17:33:28 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.53 2012/01/30 19:41:23 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.54 2012/02/16 17:33:28 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v
 #include <dev/videomode/edidvar.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
 #include <dev/pci/wsdisplay_pci.h>
+#include <dev/wscons/wsdisplay_glyphcachevar.h>
 
 #include <dev/pci/pcidevs.h>
 #include <dev/pci/pcireg.h>
@@ -143,8 +144,8 @@ static int radeonfb_set_curpos(struct ra
 /* acceleration support */
 static void  radeonfb_rectfill(struct radeonfb_display *, int dstx, int dsty,
     int width, int height, uint32_t color);
-static void radeonfb_bitblt(struct radeonfb_display *, int srcx, int srcy,
-    int dstx, int dsty, int width, int height, int rop, uint32_t mask);
+static void radeonfb_bitblt(void *, int srcx, int srcy,
+    int dstx, int dsty, int width, int height, int rop);
 
 /* hw cursor support */
 static void radeonfb_cursor_cmap(struct radeonfb_display *);
@@ -862,6 +863,15 @@ radeonfb_attach(device_t parent, device_
 		dp->rd_splash.si_stride = ri->ri_stride;
 		dp->rd_splash.si_fillrect = NULL;
 #endif
+		dp->rd_gc.gc_bitblt = radeonfb_bitblt;
+		dp->rd_gc.gc_rop = RADEON_ROP3_S;
+		dp->rd_gc.gc_blitcookie = dp;
+		glyphcache_init(&dp->rd_gc, dp->rd_virty + 4,
+		    (0x800000 / dp->rd_stride) - (dp->rd_virty + 4),
+		    dp->rd_virty,
+		    ri->ri_font->fontwidth,
+		    ri->ri_font->fontheight,
+		    defattr);
 		if (dp->rd_console) {
 
 			radeonfb_modeswitch(dp);
@@ -1011,6 +1021,7 @@ radeonfb_ioctl(void *v, void *vs,
 			if ((dp->rd_wsmode == WSDISPLAYIO_MODE_EMUL) &&
 			    (dp->rd_vd.active)) {
 				radeonfb_engine_init(dp);
+				glyphcache_wipe(&dp->rd_gc);
 				radeonfb_init_palette(sc, dp == &sc->sc_displays[0] ? 0 : 1);
 				radeonfb_modeswitch(dp);
 				vcons_redraw_screen(dp->rd_vd.active);
@@ -2497,6 +2508,7 @@ radeonfb_putchar_aa32(void *cookie, int 
 	int 			i, r, g, b, aval;
 	int 			rf, gf, bf, rb, gb, bb;
 	uint32_t 		pixel;
+	int rv;
 
 	if (dp->rd_wsmode != WSDISPLAYIO_MODE_EMUL)
 		return;
@@ -2517,6 +2529,10 @@ radeonfb_putchar_aa32(void *cookie, int 
 		radeonfb_rectfill(dp, xd, yd, w, h, bg);
 		return;
 	}
+	rv = glyphcache_try(&dp->rd_gc, c, xd, yd, attr);
+	if (rv == GC_OK)
+		return;
+
 	data = WSFONT_GLYPH(c, font);
 
 	gmc = dp->rd_format << RADEON_GMC_DST_DATATYPE_SHIFT;
@@ -2575,6 +2591,8 @@ radeonfb_putchar_aa32(void *cookie, int 
 			radeonfb_wait_fifo(sc, 20);
 		PUT32(sc, RADEON_HOST_DATA0, pixel);
 	}
+	if (rv == GC_ADD)
+		glyphcache_add(&dp->rd_gc, c, xd, yd);
 }
 
 /*
@@ -2628,7 +2646,7 @@ radeonfb_copyrows(void *cookie, int srcr
 		w = ri->ri_emuwidth;
 		h = ri->ri_font->fontheight * nrows;
 		radeonfb_bitblt(dp, x, ys, x, yd, w, h,
-		    RADEON_ROP3_S, 0xffffffff);
+		    RADEON_ROP3_S);
 	}
 }
 
@@ -2647,7 +2665,7 @@ radeonfb_copycols(void *cookie, int row,
 		w = ri->ri_font->fontwidth * ncols;
 		h = ri->ri_font->fontheight;
 		radeonfb_bitblt(dp, xs, y, xd, y, w, h,
-		    RADEON_ROP3_S, 0xffffffff);
+		    RADEON_ROP3_S);
 	}
 }
 
@@ -2688,7 +2706,7 @@ radeonfb_cursor(void *cookie, int on, in
 		/* first turn off the old cursor */
 		if (ri->ri_flg & RI_CURSOR) {
 			radeonfb_bitblt(dp, x, y, x, y, wi, he,
-			    RADEON_ROP3_Dn, 0xffffffff);
+			    RADEON_ROP3_Dn);
 			ri->ri_flg &= ~RI_CURSOR;
 		}
 		ri->ri_crow = row;
@@ -2698,7 +2716,7 @@ radeonfb_cursor(void *cookie, int on, in
 			x = ri->ri_ccol * wi + ri->ri_xorigin;
 			y = ri->ri_crow * he + ri->ri_yorigin;
 			radeonfb_bitblt(dp, x, y, x, y, wi, he,
-			    RADEON_ROP3_Dn, 0xffffffff);
+			    RADEON_ROP3_Dn);
 			ri->ri_flg |= RI_CURSOR;
 		}
 	} else {
@@ -2740,9 +2758,10 @@ radeonfb_rectfill(struct radeonfb_displa
 }
 
 static void
-radeonfb_bitblt(struct radeonfb_display *dp, int srcx, int srcy,
-    int dstx, int dsty, int width, int height, int rop, uint32_t mask)
+radeonfb_bitblt(void *cookie, int srcx, int srcy,
+    int dstx, int dsty, int width, int height, int rop)
 {
+	struct radeonfb_display *dp = cookie;
 	struct radeonfb_softc	*sc = dp->rd_softc;
 	uint32_t		gmc;
 	uint32_t		dir;
@@ -2772,7 +2791,7 @@ radeonfb_bitblt(struct radeonfb_display 
 	    RADEON_DP_SRC_SOURCE_MEMORY |
 	    rop | gmc);
 
-	PUT32(sc, RADEON_DP_WRITE_MASK, mask);
+	PUT32(sc, RADEON_DP_WRITE_MASK, 0xffffffff);
 	PUT32(sc, RADEON_DP_CNTL, dir);
 	PUT32(sc, RADEON_SRC_Y_X, (srcy << 16) | srcx);
 	PUT32(sc, RADEON_DST_Y_X, (dsty << 16) | dstx);

Index: src/sys/dev/pci/radeonfbvar.h
diff -u src/sys/dev/pci/radeonfbvar.h:1.13 src/sys/dev/pci/radeonfbvar.h:1.14
--- src/sys/dev/pci/radeonfbvar.h:1.13	Mon Jan 30 19:41:23 2012
+++ src/sys/dev/pci/radeonfbvar.h	Thu Feb 16 17:33:28 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: radeonfbvar.h,v 1.13 2012/01/30 19:41:23 drochner Exp $ */
+/* $NetBSD: radeonfbvar.h,v 1.14 2012/02/16 17:33:28 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -53,6 +53,7 @@
 #include <dev/wsfont/wsfont.h>
 #include <dev/rasops/rasops.h>
 #include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/wscons/wsdisplay_glyphcachevar.h>
 #include <dev/videomode/videomode.h>
 #include <dev/videomode/edidvar.h>
 #ifdef SPLASHSCREEN
@@ -191,6 +192,7 @@ struct radeonfb_display {
 	struct vcons_screen	rd_vscreen;
 	struct vcons_data	rd_vd;
 	void (*rd_putchar)(void *, int, int, u_int, long);
+	glyphcache		rd_gc;
 
 #if 0
 	uint8_t			rd_cmap_red[256];

Reply via email to