Subject: Font switching for buggy cards (Re: Working 80x50 patch)
To: NetBSD port-i386 <port-i386@netbsd.org>
From: Bang Jun-Young <bjy@mogua.org>
List: port-i386
Date: 12/19/2000 01:06:12
This is a multi-part message in MIME format.
--------------F162224F0F59EAC75A1F33FD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I wrote:
> Right. It's sometimes quite expensive for a slow machine to copy 16-32kB
> of font data back and forth at a time, althouth such an operation occurs
> only when switching between different text modes (80x25 -> 80x50, or 
> vice versa).

I have written a new patch which does above. It works nicely with my
machine, and I would appreciate it if anybody tries this one and tell me 
if he succeded or not. 

Known problems:

a) 512 character mode is broken. You won't be able to load such fonts.
b) find how to detect buggy graphics cards. 

In addition, I started writing a graphical console driver and have 
succeeded in switching initial text mode to graphics mode. More soon 
within this week. :-)

Jun-Young

--
Bang Jun-Young <bjy@mogua.org>
--------------F162224F0F59EAC75A1F33FD
Content-Type: text/plain; charset=us-ascii;
 name="fontsel.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="fontsel.patch"

--- vga.c	Thu Aug 31 17:05:58 2000
+++ vga.c.new	Tue Dec 19 00:22:37 2000
@@ -885,6 +885,18 @@
 			break;
 	if (slot == 8)
 		return (ENOSPC);
+	if (slot == 1) {
+		/* Load the builtin font to slot 1. */
+		vga_loadchars(&vc->hdl, slot, 0, 256, f->height, 
+			      (char *)NULL);
+		vc->vc_fonts[slot] = &vga_builtinfont;
+#ifdef VGAFONTDEBUG
+		printf("vga: load %s (8x%d, enc %d) font to slot %d\n", 
+		       vc->vc_fonts[slot]->name, vc->vc_fonts[slot]->height,
+		       vc->vc_fonts[slot]->encoding, slot);
+#endif		
+		slot++;
+	}
 
 	f = malloc(sizeof(struct vgafont), M_DEVBUF, M_WAITOK);
 	strncpy(f->name, data->name, sizeof(f->name));
--- vga_subr.c	Tue Jan 25 02:44:03 2000
+++ vga_subr.c.new	Tue Dec 19 00:20:46 2000
@@ -100,11 +100,15 @@
 	s = splhigh();
 	fontram(vh);
 
-	for (i = 0; i < num; i++)
-		for (j = 0; j < lpc; j++)
-			bus_space_write_1(vh->vh_memt, vh->vh_allmemh,
-					  offset + (i << 5) + j,
-					  data[i * lpc + j]);
+	if (fontset == 1)
+		bus_space_copy_region_1(vh->vh_memt, vh->vh_allmemh, 0,
+					vh->vh_allmemh, offset, 8192);
+	else				
+		for (i = 0; i < num; i++)
+			for (j = 0; j < lpc; j++)
+				bus_space_write_1(vh->vh_memt, vh->vh_allmemh,
+						  offset + (i << 5) + j,
+						  data[i * lpc + j]);
 
 	textram(vh);
 	splx(s);
@@ -115,6 +119,7 @@
 	struct vga_handle *vh;
 	int fontset1, fontset2;
 {
+#if 0
 	u_int8_t cmap;
 	static u_int8_t cmaptaba[] = {
 		0x00, 0x10, 0x01, 0x11,
@@ -129,6 +134,26 @@
 	cmap = cmaptaba[fontset1] | cmaptabb[fontset2];
 
 	vga_ts_write(vh, fontsel, cmap);
+#else
+	int s;
+
+	s = splhigh();
+	fontram(vh);
+
+	if (fontset1 == 0)
+		fontset1++;
+	bus_space_copy_region_1(vh->vh_memt, vh->vh_allmemh, fontset1 << 13,
+				vh->vh_allmemh, 0, 8192);
+#if 0 /* XXXBJY 512 character mode is still broken. */
+	if (fontset1 != fontset2) 
+		bus_space_copy_region_1(vh->vh_memt, vh->vh_allmemh, 
+					fontset2 << 13,	vh->vh_allmemh, 
+					1 << 13, 8192);
+#endif
+
+	textram(vh);
+	splx(s);
+#endif
 }
 
 void

--------------F162224F0F59EAC75A1F33FD--