Module Name:    src
Committed By:   rin
Date:           Wed Jul 31 02:04:15 UTC 2019

Modified Files:
        src/sys/dev/rasops: rasops.c rasops.h rasops15.c rasops2.c rasops24.c
            rasops32.c rasops4.c rasops8.c rasops_putchar_width.h

Log Message:
Switch to per-device stamp, and retire stamp_mutex.

XXX
Bump kernel version after other changes for struct rasops_info.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/dev/rasops/rasops.c
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/rasops/rasops.h
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/rasops/rasops15.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/rasops/rasops2.c
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/rasops/rasops24.c \
    src/sys/dev/rasops/rasops32.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/rasops/rasops4.c
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/rasops/rasops8.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/rasops/rasops_putchar_width.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/rasops/rasops.c
diff -u src/sys/dev/rasops/rasops.c:1.102 src/sys/dev/rasops/rasops.c:1.103
--- src/sys/dev/rasops/rasops.c:1.102	Wed Jul 31 00:14:25 2019
+++ src/sys/dev/rasops/rasops.c	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops.c,v 1.102 2019/07/31 00:14:25 rin Exp $	*/
+/*	 $NetBSD: rasops.c,v 1.103 2019/07/31 02:04:14 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.102 2019/07/31 00:14:25 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.103 2019/07/31 02:04:14 rin Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -489,6 +489,13 @@ rasops_reconfig(struct rasops_info *ri, 
 		    WSSCREEN_WSCOLORS | WSSCREEN_REVERSE;
 	}
 
+#ifndef RASOPS_SMALL
+	if (ri->ri_stamp != NULL) {
+		kmem_free(ri->ri_stamp, ri->ri_stamp_len);
+		ri->ri_stamp = NULL;
+	}
+#endif
+
 	switch (ri->ri_depth) {
 #if NRASOPS1 > 0
 	case 1:
@@ -1670,7 +1677,6 @@ rasops_make_box_chars_alpha(struct rasop
  * For now this is either a copy of rasops_cmap[] or an R3G3B2 map, it should
  * probably be a linear ( or gamma corrected? ) ramp for higher depths.
  */
- 
 int
 rasops_get_cmap(struct rasops_info *ri, uint8_t *palette, size_t bytes)
 {
@@ -1707,3 +1713,15 @@ rasops_get_cmap(struct rasops_info *ri, 
 		memcpy(palette, rasops_cmap, uimin(bytes, sizeof(rasops_cmap)));
 	return 0;
 }
+
+#ifndef RASOPS_SMALL
+void
+rasops_allocstamp(struct rasops_info *ri, size_t len)
+{
+
+	KASSERT(ri->ri_stamp == NULL);
+	ri->ri_stamp_len = len;
+	ri->ri_stamp = kmem_zalloc(len, KM_SLEEP);
+	ri->ri_stamp_attr = 0;
+}
+#endif

Index: src/sys/dev/rasops/rasops.h
diff -u src/sys/dev/rasops/rasops.h:1.39 src/sys/dev/rasops/rasops.h:1.40
--- src/sys/dev/rasops/rasops.h:1.39	Wed Jul 31 00:14:25 2019
+++ src/sys/dev/rasops/rasops.h	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops.h,v 1.39 2019/07/31 00:14:25 rin Exp $ */
+/* 	$NetBSD: rasops.h,v 1.40 2019/07/31 02:04:14 rin Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -132,6 +132,11 @@ struct rasops_info {
 	/* Callbacks so we can share some code */
 	void	(*ri_do_cursor)(struct rasops_info *);
 
+	/* 4x1 stamp for optimized character blitting */
+	void	*ri_stamp;
+	long	ri_stamp_attr;
+	size_t	ri_stamp_len;
+
 #if NRASOPS_ROTATION > 0
 	/* Used to intercept putchar to permit display rotation */
 	struct	wsdisplay_emulops ri_real_ops;
@@ -182,6 +187,8 @@ void	rasops15_init(struct rasops_info *)
 void	rasops24_init(struct rasops_info *);
 void	rasops32_init(struct rasops_info *);
 
+void	rasops_allocstamp(struct rasops_info *, size_t);
+
 #define	DELTA(p, d, cast) ((p) = (cast)((uint8_t *)(p) + (d)))
 
 #define	FONT_GLYPH(uc, font, ri)					\

Index: src/sys/dev/rasops/rasops15.c
diff -u src/sys/dev/rasops/rasops15.c:1.32 src/sys/dev/rasops/rasops15.c:1.33
--- src/sys/dev/rasops/rasops15.c:1.32	Wed Jul 31 00:14:25 2019
+++ src/sys/dev/rasops/rasops15.c	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops15.c,v 1.32 2019/07/31 00:14:25 rin Exp $	*/
+/* 	$NetBSD: rasops15.c,v 1.33 2019/07/31 02:04:14 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.32 2019/07/31 00:14:25 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops15.c,v 1.33 2019/07/31 02:04:14 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -55,13 +55,6 @@ static void	rasops15_makestamp(struct ra
 
 #ifndef RASOPS_SMALL
 /*
- * 4x1 stamp for optimized character blitting
- */
-static uint32_t	stamp[32];
-static long	stamp_attr;
-static int	stamp_mutex;	/* XXX see note in readme */
-
-/*
  * offset = STAMP_SHIFT(fontbits, nibble #) & STAMP_MASK
  * destination uint32_t[0] = STAMP_READ(offset)
  * destination uint32_t[1] = STAMP_READ(offset + 4)
@@ -106,8 +99,12 @@ rasops15_init(struct rasops_info *ri)
 #endif	/* !RASOPS_SMALL */
 	default:
 		ri->ri_ops.putchar = rasops15_putchar;
-		break;
+		return;
 	}
+
+#ifndef RASOPS_SMALL
+	rasops_allocstamp(ri, sizeof(uint32_t) * 32);
+#endif
 }
 
 #define	RASOPS_DEPTH	15
@@ -121,12 +118,13 @@ rasops15_init(struct rasops_info *ri)
 static void
 rasops15_makestamp(struct rasops_info *ri, long attr)
 {
+	uint32_t *stamp = (uint32_t *)ri->ri_stamp;
 	uint32_t fg, bg;
 	int i;
 
 	fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 0xffff;
 	bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xffff;
-	stamp_attr = attr;
+	ri->ri_stamp_attr = attr;
 
 	for (i = 0; i < 32; i += 2) {
 #if BYTE_ORDER == LITTLE_ENDIAN

Index: src/sys/dev/rasops/rasops2.c
diff -u src/sys/dev/rasops/rasops2.c:1.27 src/sys/dev/rasops/rasops2.c:1.28
--- src/sys/dev/rasops/rasops2.c:1.27	Wed Jul 31 00:14:25 2019
+++ src/sys/dev/rasops/rasops2.c	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops2.c,v 1.27 2019/07/31 00:14:25 rin Exp $	*/
+/* 	$NetBSD: rasops2.c,v 1.28 2019/07/31 02:04:14 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.27 2019/07/31 00:14:25 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops2.c,v 1.28 2019/07/31 02:04:14 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -55,13 +55,6 @@ static void	rasops2_putchar8(void *, int
 static void	rasops2_putchar12(void *, int, int col, u_int, long);
 static void	rasops2_putchar16(void *, int, int col, u_int, long);
 static void	rasops2_makestamp(struct rasops_info *, long);
-
-/*
- * 4x1 stamp for optimized character blitting
- */
-static uint8_t	stamp[16];
-static long	stamp_attr;
-static int	stamp_mutex;	/* XXX see note in README */
 #endif
 
 /*
@@ -79,6 +72,12 @@ void
 rasops2_init(struct rasops_info *ri)
 {
 
+	if ((ri->ri_font->fontwidth & 3) != 0) {
+		ri->ri_ops.erasecols = rasops2_erasecols;
+		ri->ri_ops.copycols = rasops2_copycols;
+		ri->ri_do_cursor = rasops2_do_cursor;
+	}
+
 	switch (ri->ri_font->fontwidth) {
 #ifndef RASOPS_SMALL
 	case 8:
@@ -94,14 +93,12 @@ rasops2_init(struct rasops_info *ri)
 	default:
 		panic("fontwidth not 8/12/16 or RASOPS_SMALL - fixme!");
 		ri->ri_ops.putchar = rasops2_putchar;
-		break;
+		return;
 	}
 
-	if ((ri->ri_font->fontwidth & 3) != 0) {
-		ri->ri_ops.erasecols = rasops2_erasecols;
-		ri->ri_ops.copycols = rasops2_copycols;
-		ri->ri_do_cursor = rasops2_do_cursor;
-	}
+#ifndef RASOPS_SMALL
+	rasops_allocstamp(ri, sizeof(uint8_t) * 16);
+#endif
 }
 
 /*
@@ -121,11 +118,12 @@ rasops2_putchar(void *cookie, int row, i
 static void
 rasops2_makestamp(struct rasops_info *ri, long attr)
 {
+	uint8_t *stamp = (uint8_t *)ri->ri_stamp;
 	int i, fg, bg;
 
 	fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 3;
 	bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 3;
-	stamp_attr = attr;
+	ri->ri_stamp_attr = attr;
 
 	for (i = 0; i < 16; i++) {
 #if BYTE_ORDER == BIG_ENDIAN

Index: src/sys/dev/rasops/rasops24.c
diff -u src/sys/dev/rasops/rasops24.c:1.40 src/sys/dev/rasops/rasops24.c:1.41
--- src/sys/dev/rasops/rasops24.c:1.40	Wed Jul 31 00:14:25 2019
+++ src/sys/dev/rasops/rasops24.c	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops24.c,v 1.40 2019/07/31 00:14:25 rin Exp $	*/
+/* 	$NetBSD: rasops24.c,v 1.41 2019/07/31 02:04:14 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.40 2019/07/31 00:14:25 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops24.c,v 1.41 2019/07/31 02:04:14 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -56,13 +56,6 @@ static void 	rasops24_putchar8(void *, i
 static void 	rasops24_putchar12(void *, int, int, u_int, long);
 static void 	rasops24_putchar16(void *, int, int, u_int, long);
 static void	rasops24_makestamp(struct rasops_info *, long);
-
-/*
- * 4x1 stamp for optimized character blitting
- */
-static uint32_t	stamp[64];
-static long	stamp_attr;
-static int	stamp_mutex;	/* XXX see note in readme */
 #endif
 
 /*
@@ -82,14 +75,6 @@ void
 rasops24_init(struct rasops_info *ri)
 {
 
-#ifndef RASOPS_SMALL
-	/*
-	 * Different devcmap's are used depending on font widths,
-	 * therefore we need reset stamp here.
-	 */
-	stamp_attr = 0;
-#endif
-
 	if (ri->ri_rnum == 0) {
 		ri->ri_rnum = ri->ri_gnum = ri->ri_bnum = 8;
 
@@ -120,8 +105,12 @@ rasops24_init(struct rasops_info *ri)
 #endif
 	default:
 		ri->ri_ops.putchar = rasops24_putchar;
-		break;
+		return;
 	}
+
+#ifndef RASOPS_SMALL
+	rasops_allocstamp(ri, sizeof(uint32_t) * 64);
+#endif
 }
 
 #define	RASOPS_DEPTH	24
@@ -135,12 +124,13 @@ rasops24_init(struct rasops_info *ri)
 static void
 rasops24_makestamp(struct rasops_info *ri, long attr)
 {
+	uint32_t *stamp = (uint32_t *)ri->ri_stamp;
 	uint32_t fg, bg, c1, c2, c3, c4;
 	int i;
 
 	fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 0xffffff;
 	bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xffffff;
-	stamp_attr = attr;
+	ri->ri_stamp_attr = attr;
 
 	for (i = 0; i < 64; i += 4) {
 #if BYTE_ORDER == LITTLE_ENDIAN
@@ -192,7 +182,7 @@ rasops24_eraserows(void *cookie, int row
 {
 	struct rasops_info *ri = (struct rasops_info *)cookie;
 	int n9, n3, n1, cnt, stride;
-	uint32_t *rp, *dp, *hp, clr, xstamp[3];
+	uint32_t *rp, *dp, *hp, clr, stamp[3];
 
 	hp = NULL;	/* XXX GCC */
 
@@ -219,18 +209,18 @@ rasops24_eraserows(void *cookie, int row
 #endif
 
 	clr = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xffffff;
-	xstamp[0] = (clr <<  8) | (clr >> 16);
-	xstamp[1] = (clr << 16) | (clr >>  8);
-	xstamp[2] = (clr << 24) |  clr;
+	stamp[0] = (clr <<  8) | (clr >> 16);
+	stamp[1] = (clr << 16) | (clr >>  8);
+	stamp[2] = (clr << 24) |  clr;
 
 #if BYTE_ORDER == LITTLE_ENDIAN
 	if ((ri->ri_flg & RI_BSWAP) == 0) {
 #else
 	if ((ri->ri_flg & RI_BSWAP) != 0) {
 #endif
-		xstamp[0] = bswap32(xstamp[0]);
-		xstamp[1] = bswap32(xstamp[1]);
-		xstamp[2] = bswap32(xstamp[2]);
+		stamp[0] = bswap32(stamp[0]);
+		stamp[1] = bswap32(stamp[1]);
+		stamp[2] = bswap32(stamp[2]);
 	}
 
 	/*
@@ -262,19 +252,19 @@ rasops24_eraserows(void *cookie, int row
 	while (num--) {
 		dp = rp;
 		for (cnt = n9; cnt; cnt--) {
-			dp[0] = xstamp[0]; dp[1] = xstamp[1]; dp[2] = xstamp[2];
-			dp[3] = xstamp[0]; dp[4] = xstamp[1]; dp[5] = xstamp[2];
-			dp[6] = xstamp[0]; dp[7] = xstamp[1]; dp[8] = xstamp[2];
+			dp[0] = stamp[0]; dp[1] = stamp[1]; dp[2] = stamp[2];
+			dp[3] = stamp[0]; dp[4] = stamp[1]; dp[5] = stamp[2];
+			dp[6] = stamp[0]; dp[7] = stamp[1]; dp[8] = stamp[2];
 			dp += 9;
 		}
 
 		for (cnt = n3; cnt; cnt--) {
-			dp[0] = xstamp[0]; dp[1] = xstamp[1]; dp[2] = xstamp[2];
+			dp[0] = stamp[0]; dp[1] = stamp[1]; dp[2] = stamp[2];
 			dp += 3;
 		}
 
 		for (cnt = 0; cnt < n1; cnt++)
-			*dp++ = xstamp[cnt];
+			*dp++ = stamp[cnt];
 
 		if (ri->ri_hwbits) {
 			memcpy(hp, rp, stride);
@@ -291,7 +281,7 @@ static void
 rasops24_erasecols(void *cookie, int row, int col, int num, long attr)
 {
 	struct rasops_info *ri = (struct rasops_info *)cookie;
-	int n12, n4, height, cnt, slop1, slop2, clr, xstamp[3];
+	int n12, n4, height, cnt, slop1, slop2, clr, stamp[3];
 	uint32_t *dp;
 	uint8_t *rp, *hp, *dbp;
 
@@ -331,18 +321,18 @@ rasops24_erasecols(void *cookie, int row
 	height = ri->ri_font->fontheight;
 
 	clr = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xffffff;
-	xstamp[0] = (clr <<  8) | (clr >> 16);
-	xstamp[1] = (clr << 16) | (clr >>  8);
-	xstamp[2] = (clr << 24) |  clr;
+	stamp[0] = (clr <<  8) | (clr >> 16);
+	stamp[1] = (clr << 16) | (clr >>  8);
+	stamp[2] = (clr << 24) |  clr;
 
 #if BYTE_ORDER == LITTLE_ENDIAN
 	if ((ri->ri_flg & RI_BSWAP) == 0) {
 #else
 	if ((ri->ri_flg & RI_BSWAP) != 0) {
 #endif
-		xstamp[0] = bswap32(xstamp[0]);
-		xstamp[1] = bswap32(xstamp[1]);
-		xstamp[2] = bswap32(xstamp[2]);
+		stamp[0] = bswap32(stamp[0]);
+		stamp[1] = bswap32(stamp[1]);
+		stamp[2] = bswap32(stamp[2]);
 	}
 
 	/*
@@ -377,15 +367,15 @@ rasops24_erasecols(void *cookie, int row
 
 		/* 12 pels per loop */
 		for (cnt = n12; cnt; cnt--) {
-			dp[0] = xstamp[0]; dp[1] = xstamp[1]; dp[2] = xstamp[2];
-			dp[3] = xstamp[0]; dp[4] = xstamp[1]; dp[5] = xstamp[2];
-			dp[6] = xstamp[0]; dp[7] = xstamp[1]; dp[8] = xstamp[2];
+			dp[0] = stamp[0]; dp[1] = stamp[1]; dp[2] = stamp[2];
+			dp[3] = stamp[0]; dp[4] = stamp[1]; dp[5] = stamp[2];
+			dp[6] = stamp[0]; dp[7] = stamp[1]; dp[8] = stamp[2];
 			dp += 9;
 		}
 
 		/* 4 pels per loop */
 		for (cnt = n4; cnt; cnt--) {
-			dp[0] = xstamp[0]; dp[1] = xstamp[1]; dp[2] = xstamp[2];
+			dp[0] = stamp[0]; dp[1] = stamp[1]; dp[2] = stamp[2];
 			dp += 3;
 		}
 
Index: src/sys/dev/rasops/rasops32.c
diff -u src/sys/dev/rasops/rasops32.c:1.40 src/sys/dev/rasops/rasops32.c:1.41
--- src/sys/dev/rasops/rasops32.c:1.40	Wed Jul 31 00:14:25 2019
+++ src/sys/dev/rasops/rasops32.c	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/*	 $NetBSD: rasops32.c,v 1.40 2019/07/31 00:14:25 rin Exp $	*/
+/*	 $NetBSD: rasops32.c,v 1.41 2019/07/31 02:04:14 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.40 2019/07/31 00:14:25 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops32.c,v 1.41 2019/07/31 02:04:14 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -51,13 +51,6 @@ static void	rasops32_putchar8(void *, in
 static void	rasops32_putchar12(void *, int, int, u_int, long);
 static void	rasops32_putchar16(void *, int, int, u_int, long);
 static void	rasops32_makestamp(struct rasops_info *, long);
-
-/*
- * 4x1 stamp for optimized character blitting
- */
-static uint32_t	stamp[64];
-static long	stamp_attr;
-static int	stamp_mutex;	/* XXX see note in readme */
 #endif
 
 /*
@@ -105,8 +98,12 @@ rasops32_init(struct rasops_info *ri)
 #endif
 	default:
 		ri->ri_ops.putchar = rasops32_putchar;
-		break;
+		return;
 	}
+
+#ifndef RASOPS_SMALL
+	rasops_allocstamp(ri, sizeof(uint32_t) * 64);
+#endif
 }
 
 #define	RASOPS_DEPTH	32
@@ -120,12 +117,13 @@ rasops32_init(struct rasops_info *ri)
 static void
 rasops32_makestamp(struct rasops_info *ri, long attr)
 {
+	uint32_t *stamp = (uint32_t *)ri->ri_stamp;
 	uint32_t fg, bg;
 	int i;
 
 	fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf];
 	bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf];
-	stamp_attr = attr;
+	ri->ri_stamp_attr = attr;
 
 	for (i = 0; i < 64; i += 4) {
 		stamp[i + 0] = i & 32 ? fg : bg;

Index: src/sys/dev/rasops/rasops4.c
diff -u src/sys/dev/rasops/rasops4.c:1.21 src/sys/dev/rasops/rasops4.c:1.22
--- src/sys/dev/rasops/rasops4.c:1.21	Wed Jul 31 00:14:25 2019
+++ src/sys/dev/rasops/rasops4.c	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops4.c,v 1.21 2019/07/31 00:14:25 rin Exp $	*/
+/* 	$NetBSD: rasops4.c,v 1.22 2019/07/31 02:04:14 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.21 2019/07/31 00:14:25 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops4.c,v 1.22 2019/07/31 02:04:14 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -55,13 +55,6 @@ static void	rasops4_putchar8(void *, int
 static void	rasops4_putchar12(void *, int, int col, u_int, long);
 static void	rasops4_putchar16(void *, int, int col, u_int, long);
 static void	rasops4_makestamp(struct rasops_info *, long);
-
-/*
- * 4x1 stamp for optimized character blitting
- */
-static uint16_t	stamp[16];
-static long	stamp_attr;
-static int	stamp_mutex;	/* XXX see note in README */
 #endif
 
 /*
@@ -100,8 +93,12 @@ rasops4_init(struct rasops_info *ri)
 	default:
 		panic("fontwidth not 8/12/16 or RASOPS_SMALL - fixme!");
 		ri->ri_ops.putchar = rasops4_putchar;
-		break;
+		return;
 	}
+
+#ifndef RASOPS_SMALL
+	rasops_allocstamp(ri, sizeof(uint16_t) * 16);
+#endif
 }
 
 /*
@@ -121,11 +118,12 @@ rasops4_putchar(void *cookie, int row, i
 static void
 rasops4_makestamp(struct rasops_info *ri, long attr)
 {
+	uint16_t *stamp = (uint16_t *)ri->ri_stamp;
 	int i, fg, bg;
 
 	fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 0xf;
 	bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xf;
-	stamp_attr = attr;
+	ri->ri_stamp_attr = attr;
 
 	for (i = 0; i < 16; i++) {
 #if BYTE_ORDER == BIG_ENDIAN

Index: src/sys/dev/rasops/rasops8.c
diff -u src/sys/dev/rasops/rasops8.c:1.45 src/sys/dev/rasops/rasops8.c:1.46
--- src/sys/dev/rasops/rasops8.c:1.45	Wed Jul 31 00:14:25 2019
+++ src/sys/dev/rasops/rasops8.c	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/* 	$NetBSD: rasops8.c,v 1.45 2019/07/31 00:14:25 rin Exp $	*/
+/* 	$NetBSD: rasops8.c,v 1.46 2019/07/31 02:04:14 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.45 2019/07/31 00:14:25 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops8.c,v 1.46 2019/07/31 02:04:14 rin Exp $");
 
 #include "opt_rasops.h"
 
@@ -51,13 +51,6 @@ static void 	rasops8_putchar8(void *, in
 static void 	rasops8_putchar12(void *, int, int, u_int, long);
 static void 	rasops8_putchar16(void *, int, int, u_int, long);
 static void	rasops8_makestamp(struct rasops_info *ri, long);
-
-/*
- * 4x1 stamp for optimized character blitting
- */
-static uint32_t	stamp[16];
-static long	stamp_attr;
-static int	stamp_mutex;	/* XXX see note in README */
 #endif
 
 /*
@@ -103,8 +96,12 @@ rasops8_init(struct rasops_info *ri)
 #endif /* !RASOPS_SMALL */
 	default:
 		ri->ri_ops.putchar = rasops8_putchar;
-		break;
+		return;
 	}
+
+#ifndef RASOPS_SMALL
+	rasops_allocstamp(ri, sizeof(uint32_t) * 16);
+#endif
 }
 
 #define	RASOPS_DEPTH	8
@@ -118,12 +115,13 @@ rasops8_init(struct rasops_info *ri)
 static void
 rasops8_makestamp(struct rasops_info *ri, long attr)
 {
+	uint32_t *stamp = (uint32_t *)ri->ri_stamp;
 	uint32_t fg, bg;
 	int i;
 
 	fg = ri->ri_devcmap[((uint32_t)attr >> 24) & 0xf] & 0xff;
 	bg = ri->ri_devcmap[((uint32_t)attr >> 16) & 0xf] & 0xff;
-	stamp_attr = attr;
+	ri->ri_stamp_attr = attr;
 
 	for (i = 0; i < 16; i++) {
 #if BYTE_ORDER == BIG_ENDIAN

Index: src/sys/dev/rasops/rasops_putchar_width.h
diff -u src/sys/dev/rasops/rasops_putchar_width.h:1.9 src/sys/dev/rasops/rasops_putchar_width.h:1.10
--- src/sys/dev/rasops/rasops_putchar_width.h:1.9	Tue Jul 30 15:29:40 2019
+++ src/sys/dev/rasops/rasops_putchar_width.h	Wed Jul 31 02:04:14 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: rasops_putchar_width.h,v 1.9 2019/07/30 15:29:40 rin Exp $ */
+/* $NetBSD: rasops_putchar_width.h,v 1.10 2019/07/31 02:04:14 rin Exp $ */
 
 /* NetBSD: rasops8.c,v 1.41 2019/07/25 03:02:44 rin Exp  */
 /*-
@@ -204,9 +204,10 @@ PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH
 {
 	struct rasops_info *ri = (struct rasops_info *)cookie;
 	struct wsdisplay_font *font = PICK_FONT(ri, uc);
+	STAMP_TYPE *stamp = (STAMP_TYPE *)ri->ri_stamp;
 	int height, fs;
-	STAMP_TYPE *rp, *hp;
 	uint8_t *fr;
+	STAMP_TYPE *rp, *hp;
 
 	hp = NULL; /* XXX GCC */
 
@@ -223,15 +224,8 @@ PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH
 	if (!CHAR_IN_FONT(uc, font))
 		return;
 
-	/* Can't risk remaking the stamp if it's already in use */
-	if (stamp_mutex++) {
-		stamp_mutex--;
-		PUTCHAR(RASOPS_DEPTH)(cookie, row, col, uc, attr);
-		return;
-	}
-
 	/* Recompute stamp? */
-	if (attr != stamp_attr)
+	if (attr != ri->ri_stamp_attr)
 		MAKESTAMP(RASOPS_DEPTH)(ri, attr);
 
 	rp = (STAMP_TYPE *)(ri->ri_bits + row * ri->ri_yscale +
@@ -275,8 +269,6 @@ PUTCHAR_WIDTH(RASOPS_DEPTH, RASOPS_WIDTH
 			memcpy(hp, rp, SUBST_BYTES);
 		}
 	}
-
-	stamp_mutex--;
 }
 
 #undef	STAMP_TYPE

Reply via email to