Subject: Re: CVS commit: syssrc/sys/dev
To: Matthias Drochner <M.Drochner@fz-juelich.de>
From: Bang Jun-Young <junyoung@mogua.com>
List: source-changes
Date: 06/26/2002 23:05:08
On Wed, Jun 26, 2002 at 12:39:23PM +0200, Matthias Drochner wrote:
> 
> junyoung@mogua.com said:
> > What I was considering is to add `options ATI_BROKEN_FONTSEL'
> 
> I can't find any traces of your patch in my mailbox. Would
> you please send it again?

I'm attaching a new patch I've just made against -current source.

> 
> Just to explain things a bit more: Another reason why I made the
> number of available font slots variable is to share the font
> selection/loading code with the EGA driver in the future.
> (might be of limited interest, and I don't even have hardware
> to test with, but should be straightforward)

Is there anybody still using such a card with his machine? I have
a couple of old ISA VGA's to give away for free (+ S&H ;-).

> 
> I'm not opposed to an option which enables the "ATI-save"
> behavior, it should be present in GENERIC* kernels however.

Do you mean it should be enabled by default?

> What also should be done is to make the default screen type
> depending on the console screen type, not hardwired to 80x25.

As set in /etc/wscons.conf?

Jun-Young

-- 
Bang Jun-Young <junyoung@mogua.com>

Index: conf/files
===================================================================
RCS file: /cvsroot/syssrc/sys/conf/files,v
retrieving revision 1.536
diff -u -r1.536 files
--- conf/files	2002/06/24 08:06:20	1.536
+++ conf/files	2002/06/26 13:14:31
@@ -764,6 +764,7 @@
 file	dev/ic/pcdisplay_chars.c	pcdisplayops
 # VGA graphics
 #
+defflag opt_vga.h 		VGA_CONSOLE_ATI_BROKEN_FONTSEL	
 device	vga: wsemuldisplaydev, pcdisplayops
 file	dev/ic/vga.c			vga			needs-flag
 file	dev/ic/vga_subr.c		vga
Index: dev/ic/vga.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/vga.c,v
retrieving revision 1.51
diff -u -r1.51 vga.c
--- dev/ic/vga.c	2002/06/25 21:07:42	1.51
+++ dev/ic/vga.c	2002/06/26 13:14:32
@@ -1,4 +1,4 @@
-/* $NetBSD: vga.c,v 1.51 2002/06/25 21:07:42 drochner Exp $ */
+/* $NetBSD: vga.c,v 1.50 2002/04/04 13:08:35 hannken Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.51 2002/06/25 21:07:42 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.50 2002/04/04 13:08:35 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -366,8 +366,7 @@
 	if (cookie == -1) {
 #ifdef VGAFONTDEBUG
 		if (scr != &vga_console_screen || vga_console_attached)
-			printf("vga_getfont: %s not found\n",
-			       name ? name : "<default>");
+			printf("vga_getfont: %s not found\n", name);
 #endif
 		return (0);
 	}
@@ -592,8 +591,7 @@
 
 void
 vga_common_attach(struct vga_softc *sc, bus_space_tag_t iot,
-		  bus_space_tag_t memt, int type, int quirks,
-		  const struct vga_funcs *vf)
+		  bus_space_tag_t memt, int type, const struct vga_funcs *vf)
 {
 	int console;
 	struct vga_config *vc;
@@ -610,7 +608,6 @@
 	}
 
 	vc->vc_type = type;
-	vc->vc_nfontslots = (quirks & VGA_QUIRK_ONEFONT) ? 1 : 8;
 	vc->vc_funcs = vf;
 
 	sc->sc_vc = vc;
@@ -643,7 +640,6 @@
 #else
 	scr = vga_console_vc.currenttype;
 #endif
-	vga_console_vc.vc_nfontslots = 1; /* for now assume buggy adapter */
 	vga_init_screen(&vga_console_vc, &vga_console_screen, scr, 1, &defattr);
 
 	wsdisplay_cnattach(scr, &vga_console_screen,
@@ -825,33 +821,34 @@
 	if (f->slot != -1)
 		goto toend;
 
-	for (slot = 0; slot < vc->vc_nfontslots; slot++) {
+	for (slot = 0; slot < 8; slot++) {
 		if (!vc->vc_fonts[slot])
 			goto loadit;
 	}
-
+	
 	/* have to kick out another one */
 	TAILQ_FOREACH(of, &vc->vc_fontlist, next) {
 		if (of->slot != -1) {
 			if (of == &vga_builtinfont)
-				continue;
+				continue; /* XXX for now */
 			KASSERT(vc->vc_fonts[of->slot] == of);
 			slot = of->slot;
 			of->slot = -1;
 			goto loadit;
 		}
 	}
-
-	/*
-	 * This should only happen if there is only 1 font slot
-	 * which is occupied by the builtin font.
-	 * Last resort: kick out the builtin font.
-	 */
-	KASSERT(vc->vc_fonts[0] == &vga_builtinfont);
-	TAILQ_REMOVE(&vc->vc_fontlist, &vga_builtinfont, next);
-	slot = 0;
+	panic("vga_usefont");
 
 loadit:
+#ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
+	if (slot == 1) {
+		/* Load the builtin font to slot 1. */
+		vga_loadchars(&vc->hdl, slot, 0, 256, f->wsfont->fontheight,
+			      NULL);
+		vc->vc_fonts[slot] = &vga_builtinfont;
+		slot++;
+	}
+#endif
 	vga_loadchars(&vc->hdl, slot, 0, 256,
 		      f->wsfont->fontheight, f->wsfont->data);
 	f->slot = slot;
Index: dev/ic/vga_subr.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/vga_subr.c,v
retrieving revision 1.8
diff -u -r1.8 vga_subr.c
--- dev/ic/vga_subr.c	2001/12/13 08:34:55	1.8
+++ dev/ic/vga_subr.c	2002/06/26 13:14:32
@@ -98,11 +98,17 @@
 	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]);
+#ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
+	if (fontset == 1)
+		bus_space_copy_region_1(vh->vh_memt, vh->vh_allmemh, 0,
+					vh->vh_allmemh, offset, 8192);
+	else
+#endif
+		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);
@@ -111,6 +117,22 @@
 void
 vga_setfontset(struct vga_handle *vh, int fontset1, int fontset2)
 {
+#ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
+	/* XXXBJY: 512 character mode is still broken. */
+
+	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);
+	
+	textram(vh);
+	splx(s);
+#else
 	u_int8_t cmap;
 	static u_int8_t cmaptaba[] = {
 		0x00, 0x10, 0x01, 0x11,
@@ -125,6 +147,7 @@
 	cmap = cmaptaba[fontset1] | cmaptabb[fontset2];
 
 	vga_ts_write(vh, fontsel, cmap);
+#endif /* VGA_CONSOLE_ATI_BROKEN_FONTSEL */
 }
 
 void
Index: dev/ic/vgavar.h
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/vgavar.h,v
retrieving revision 1.11
diff -u -r1.11 vgavar.h
--- dev/ic/vgavar.h	2002/06/25 21:07:42	1.11
+++ dev/ic/vgavar.h	2002/06/26 13:14:32
@@ -1,4 +1,4 @@
-/* $NetBSD: vgavar.h,v 1.11 2002/06/25 21:07:42 drochner Exp $ */
+/* $NetBSD: vgavar.h,v 1.10 2001/12/29 17:40:35 junyoung Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -29,6 +29,8 @@
 
 #include <sys/callout.h>
 
+#include "opt_vga.h"
+
 struct vga_handle {
 	struct pcdisplay_handle vh_ph;
 	bus_space_handle_t vh_ioh_vga, vh_allmemh;
@@ -58,7 +60,6 @@
 	bus_space_tag_t vc_biostag;
 	bus_space_handle_t vc_bioshdl;
 
-	int vc_nfontslots;
 	struct egavga_font *vc_fonts[8]; /* currently loaded */
 	TAILQ_HEAD(, egavga_font) vc_fontlist; /* LRU queue */
 
@@ -184,10 +185,7 @@
 
 int	vga_common_probe(bus_space_tag_t, bus_space_tag_t);
 void	vga_common_attach(struct vga_softc *, bus_space_tag_t,
-			  bus_space_tag_t, int, int,
-			  const struct vga_funcs *);
-#define VGA_QUIRK_ONEFONT	0x01
-#define VGA_QUIRK_NOFASTSCROLL	0x02
+			  bus_space_tag_t, int, const struct vga_funcs *);
 int	vga_is_console(bus_space_tag_t, int);
 
 int	vga_cnattach(bus_space_tag_t, bus_space_tag_t, int, int);
Index: dev/isa/vga_isa.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/isa/vga_isa.c,v
retrieving revision 1.9
diff -u -r1.9 vga_isa.c
--- dev/isa/vga_isa.c	2002/06/26 09:38:37	1.9
+++ dev/isa/vga_isa.c	2002/06/26 13:14:32
@@ -1,4 +1,4 @@
-/* $NetBSD: vga_isa.c,v 1.9 2002/06/26 09:38:37 simonb Exp $ */
+/* $NetBSD: vga_isa.c,v 1.7 2002/01/07 21:47:13 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga_isa.c,v 1.9 2002/06/26 09:38:37 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga_isa.c,v 1.7 2002/01/07 21:47:13 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -116,7 +116,7 @@
 	printf("\n");
 
 	vga_common_attach(sc, ia->ia_iot, ia->ia_memt, WSDISPLAY_TYPE_ISAVGA,
-	    0, NULL);
+	    NULL);
 }
 
 int