Source-Changes-HG archive

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

[src/trunk]: src/sys/dev allow to overwrite the builtin VGA font if necessary,



details:   https://anonhg.NetBSD.org/src/rev/9aaf04726cb2
branches:  trunk
changeset: 533247:9aaf04726cb2
user:      drochner <drochner%NetBSD.org@localhost>
date:      Tue Jun 25 21:07:42 2002 +0000

description:
allow to overwrite the builtin VGA font if necessary,
make the number of available font slots variable,
set up a "quirk" mechanism to tell the generic vga code about crippled
VGA adapters which ignore the "fontsel" TS register,
initiate the quirk table with an ATI chip which happened to be on a board
I tested with.
Afaik quite a number of ATI chips suffers from the "loaded fonts don't
work" problem - these should be added.
Bad side effect of my change: The builtin font will be kicked out
always if a VGA_CONSOLE_SCREENTYPE is specified which needs a loaded
font. In early console initialization, we don't know much about the
graphics card, so we have to assume the worst (ie ATI:-).

diffstat:

 sys/dev/ic/vga.c      |  26 +++++++++++++++++++-------
 sys/dev/ic/vgavar.h   |   8 ++++++--
 sys/dev/isa/vga_isa.c |   6 +++---
 sys/dev/pci/vga_pci.c |  29 ++++++++++++++++++++++++++---
 4 files changed, 54 insertions(+), 15 deletions(-)

diffs (208 lines):

diff -r 0ab6d4174b4e -r 9aaf04726cb2 sys/dev/ic/vga.c
--- a/sys/dev/ic/vga.c  Tue Jun 25 20:28:36 2002 +0000
+++ b/sys/dev/ic/vga.c  Tue Jun 25 21:07:42 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga.c,v 1.50 2002/04/04 13:08:35 hannken Exp $ */
+/* $NetBSD: vga.c,v 1.51 2002/06/25 21:07:42 drochner Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.50 2002/04/04 13:08:35 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.51 2002/06/25 21:07:42 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -366,7 +366,8 @@
        if (cookie == -1) {
 #ifdef VGAFONTDEBUG
                if (scr != &vga_console_screen || vga_console_attached)
-                       printf("vga_getfont: %s not found\n", name);
+                       printf("vga_getfont: %s not found\n",
+                              name ? name : "<default>");
 #endif
                return (0);
        }
@@ -591,7 +592,8 @@
 
 void
 vga_common_attach(struct vga_softc *sc, bus_space_tag_t iot,
-                 bus_space_tag_t memt, int type, const struct vga_funcs *vf)
+                 bus_space_tag_t memt, int type, int quirks,
+                 const struct vga_funcs *vf)
 {
        int console;
        struct vga_config *vc;
@@ -608,6 +610,7 @@
        }
 
        vc->vc_type = type;
+       vc->vc_nfontslots = (quirks & VGA_QUIRK_ONEFONT) ? 1 : 8;
        vc->vc_funcs = vf;
 
        sc->sc_vc = vc;
@@ -640,6 +643,7 @@
 #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,
@@ -821,7 +825,7 @@
        if (f->slot != -1)
                goto toend;
 
-       for (slot = 0; slot < 8; slot++) {
+       for (slot = 0; slot < vc->vc_nfontslots; slot++) {
                if (!vc->vc_fonts[slot])
                        goto loadit;
        }
@@ -830,14 +834,22 @@
        TAILQ_FOREACH(of, &vc->vc_fontlist, next) {
                if (of->slot != -1) {
                        if (of == &vga_builtinfont)
-                               continue; /* XXX for now */
+                               continue;
                        KASSERT(vc->vc_fonts[of->slot] == of);
                        slot = of->slot;
                        of->slot = -1;
                        goto loadit;
                }
        }
-       panic("vga_usefont");
+
+       /*
+        * 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;
 
 loadit:
        vga_loadchars(&vc->hdl, slot, 0, 256,
diff -r 0ab6d4174b4e -r 9aaf04726cb2 sys/dev/ic/vgavar.h
--- a/sys/dev/ic/vgavar.h       Tue Jun 25 20:28:36 2002 +0000
+++ b/sys/dev/ic/vgavar.h       Tue Jun 25 21:07:42 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vgavar.h,v 1.10 2001/12/29 17:40:35 junyoung Exp $ */
+/* $NetBSD: vgavar.h,v 1.11 2002/06/25 21:07:42 drochner Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -58,6 +58,7 @@
        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 */
 
@@ -183,7 +184,10 @@
 
 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, const struct vga_funcs *);
+                         bus_space_tag_t, int, int,
+                         const struct vga_funcs *);
+#define VGA_QUIRK_ONEFONT      0x01
+#define VGA_QUIRK_NOFASTSCROLL 0x02
 int    vga_is_console(bus_space_tag_t, int);
 
 int    vga_cnattach(bus_space_tag_t, bus_space_tag_t, int, int);
diff -r 0ab6d4174b4e -r 9aaf04726cb2 sys/dev/isa/vga_isa.c
--- a/sys/dev/isa/vga_isa.c     Tue Jun 25 20:28:36 2002 +0000
+++ b/sys/dev/isa/vga_isa.c     Tue Jun 25 21:07:42 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga_isa.c,v 1.7 2002/01/07 21:47:13 thorpej Exp $ */
+/* $NetBSD: vga_isa.c,v 1.8 2002/06/25 21:07:43 drochner 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.7 2002/01/07 21:47:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga_isa.c,v 1.8 2002/06/25 21:07:43 drochner 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,
-           NULL);
+                         0, NULL);
 }
 
 int
diff -r 0ab6d4174b4e -r 9aaf04726cb2 sys/dev/pci/vga_pci.c
--- a/sys/dev/pci/vga_pci.c     Tue Jun 25 20:28:36 2002 +0000
+++ b/sys/dev/pci/vga_pci.c     Tue Jun 25 21:07:42 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga_pci.c,v 1.11 2002/05/30 12:06:43 drochner Exp $ */
+/* $NetBSD: vga_pci.c,v 1.12 2002/06/25 21:07:43 drochner Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga_pci.c,v 1.11 2002/05/30 12:06:43 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga_pci.c,v 1.12 2002/06/25 21:07:43 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -73,6 +73,7 @@
 
 int    vga_pci_match(struct device *, struct cfdata *, void *);
 void   vga_pci_attach(struct device *, struct device *, void *);
+static int vga_pci_lookup_quirks(struct pci_attach_args *);
 
 struct cfattach vga_pci_ca = {
        sizeof(struct vga_pci_softc), 
@@ -88,6 +89,28 @@
        vga_pci_mmap,
 };
 
+static const struct {
+       int id;
+       int quirks;
+} vga_pci_quirks[] = {
+       {PCI_ID_CODE(PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE_XL_AGP),
+        VGA_QUIRK_ONEFONT},
+};
+
+static int
+vga_pci_lookup_quirks(pa)
+       struct pci_attach_args *pa;
+{
+       int i;
+
+       for (i = 0; i < sizeof(vga_pci_quirks) / sizeof (vga_pci_quirks[0]);
+            i++) {
+               if (vga_pci_quirks[i].id == pa->pa_id)
+                       return (vga_pci_quirks[i].quirks);
+       }
+       return (0);
+}
+
 int
 vga_pci_match(struct device *parent, struct cfdata *match, void *aux)
 {
@@ -181,7 +204,7 @@
        /* XXX Expansion ROM? */
 
        vga_common_attach(sc, pa->pa_iot, pa->pa_memt, WSDISPLAY_TYPE_PCIVGA,
-           &vga_pci_funcs);
+                         vga_pci_lookup_quirks(pa), &vga_pci_funcs);
 }
 
 int



Home | Main Index | Thread Index | Old Index