Source-Changes-HG archive

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

[src/trunk]: src/sys/dev clean up font handling:



details:   https://anonhg.NetBSD.org/src/rev/81f5be6bcf24
branches:  trunk
changeset: 533373:81f5be6bcf24
user:      drochner <drochner%NetBSD.org@localhost>
date:      Fri Jun 28 22:24:11 2002 +0000

description:
clean up font handling:
-treat the builtin font like any other font at runtime
-for that, copy it to malloc()'d memory during attach()
-in early console initialization, if we have to consider a broken card
 (VGA_CONSOLE_ATI_BROKEN_FONTSEL), copy the builtin font to another
 location in font ram; the attach() code will do the rest
put the "quirk" code into effect again

diffstat:

 sys/dev/ic/vga.c      |  49 +++++++++++++++++++++++-------------
 sys/dev/ic/vga_subr.c |  68 ++++++++++++++++++++++++++++++++------------------
 sys/dev/ic/vgavar.h   |  10 ++++++-
 sys/dev/isa/vga_isa.c |   6 ++--
 sys/dev/pci/vga_pci.c |  29 +++++++++++++++++++--
 5 files changed, 111 insertions(+), 51 deletions(-)

diffs (truncated from 343 to 300 lines):

diff -r bf3e1331fdc6 -r 81f5be6bcf24 sys/dev/ic/vga.c
--- a/sys/dev/ic/vga.c  Fri Jun 28 21:55:08 2002 +0000
+++ b/sys/dev/ic/vga.c  Fri Jun 28 22:24:11 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga.c,v 1.55 2002/06/28 03:38:13 junyoung Exp $ */
+/* $NetBSD: vga.c,v 1.56 2002/06/28 22:24:11 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.55 2002/06/28 03:38:13 junyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.56 2002/06/28 22:24:11 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -52,6 +52,7 @@
 #include <dev/ic/pcdisplay.h>
 
 #include "opt_wsdisplay_compat.h" /* for WSCONS_SUPPORT_PCVTFONTS */
+#include "opt_vga.h"
 
 static struct wsdisplay_font _vga_builtinfont = {
        "builtin",
@@ -597,7 +598,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;
@@ -613,8 +615,18 @@
                vga_init(vc, iot, memt);
        }
 
+       vga_builtinfont.wsfont->data = malloc(8192, M_DEVBUF, M_WAITOK);
+       vga_readoutchars(&vc->hdl, vga_builtinfont.slot, 0, 256,
+                        vga_builtinfont.wsfont->fontheight,
+                        vga_builtinfont.wsfont->data);
+
+       if (quirks & VGA_QUIRK_ONEFONT) {
+               vc->vc_nfontslots = 1;
+               if (vga_builtinfont.slot != 0)
+                       vga_builtinfont.slot = -1;
+       } else
+               vc->vc_nfontslots = 8;
        vc->vc_type = type;
-       vc->vc_nfontslots = 8;
        vc->vc_funcs = vf;
 
        sc->sc_vc = vc;
@@ -647,6 +659,21 @@
 #else
        scr = vga_console_vc.currenttype;
 #endif
+#ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
+       /*
+        * On some (most/all?) ATI cards, only font slot 0 is usable.
+        * vga_init_screen() might need font slot 0 for a non-default
+        * console font, so save the builtin VGA font to another font slot
+        * for now and free slot 0. The attach() code will take care later.
+        */
+       vga_copyfont01(&vga_console_vc.hdl);
+       vga_console_vc.vc_fonts[0] = 0;
+       vga_builtinfont.slot = 1;
+       vga_console_vc.vc_fonts[1] = &vga_builtinfont;
+       vga_console_vc.vc_nfontslots = 1;
+#else
+       vga_console_vc.vc_nfontslots = 8;
+#endif
        vga_init_screen(&vga_console_vc, &vga_console_screen, scr, 1, &defattr);
 
        wsdisplay_cnattach(scr, &vga_console_screen,
@@ -836,8 +863,6 @@
        /* have to kick out another one */
        TAILQ_FOREACH(of, &vc->vc_fontlist, next) {
                if (of->slot != -1) {
-                       if (of == &vga_builtinfont)
-                               continue;
                        KASSERT(vc->vc_fonts[of->slot] == of);
                        slot = of->slot;
                        of->slot = -1;
@@ -847,18 +872,6 @@
        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, 16, NULL);
-               vga_builtinfont.slot = slot;
-               vga_builtinfont.usecount++;
-               vc->vc_fonts[slot] = &vga_builtinfont;
-               TAILQ_REMOVE(&vc->vc_fontlist, &vga_builtinfont, next);
-               TAILQ_INSERT_TAIL(&vc->vc_fontlist, &vga_builtinfont, next);
-               slot++;
-       }
-#endif
        vga_loadchars(&vc->hdl, slot, f->wsfont->firstchar,
                      f->wsfont->numchars, f->wsfont->fontheight,
                      f->wsfont->data);
diff -r bf3e1331fdc6 -r 81f5be6bcf24 sys/dev/ic/vga_subr.c
--- a/sys/dev/ic/vga_subr.c     Fri Jun 28 21:55:08 2002 +0000
+++ b/sys/dev/ic/vga_subr.c     Fri Jun 28 22:24:11 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga_subr.c,v 1.9 2002/06/27 06:26:54 junyoung Exp $ */
+/* $NetBSD: vga_subr.c,v 1.10 2002/06/28 22:24:11 drochner Exp $ */
 
 /*
  * Copyright (c) 1998
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vga_subr.c,v 1.9 2002/06/27 06:26:54 junyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga_subr.c,v 1.10 2002/06/28 22:24:11 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -87,7 +87,7 @@
 }
 
 void
-vga_loadchars(struct vga_handle *vh, int fontset, int first, int num, int lpc, 
+vga_loadchars(struct vga_handle *vh, int fontset, int first, int num, int lpc,
              char *data)
 {
        int offset, i, j, s;
@@ -98,41 +98,60 @@
        s = splhigh();
        fontram(vh);
 
-#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]);
+       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);
 }
 
 void
-vga_setfontset(struct vga_handle *vh, int fontset1, int fontset2)
+vga_readoutchars(struct vga_handle *vh, int fontset, int first, int num, int lpc,
+                char *data)
 {
+       int offset, i, j, s;
+
+       /* fontset number swizzle done in vga_setfontset() */
+       offset = (fontset << 13) | (first << 5);
+
+       s = splhigh();
+       fontram(vh);
+
+       for (i = 0; i < num; i++)
+               for (j = 0; j < lpc; j++)
+                       data[i * lpc + j] =
+                               bus_space_read_1(vh->vh_memt, vh->vh_allmemh,
+                                                offset + (i << 5) + j);
+
+       textram(vh);
+       splx(s);
+}
+
 #ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
-       /* XXXBJY: 512 character mode is still broken. */
-
+void
+vga_copyfont01(struct vga_handle *vh)
+{
        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);
-       
+
+       bus_space_copy_region_1(vh->vh_memt,
+                               vh->vh_allmemh, 0,
+                               vh->vh_allmemh, 1 << 13,
+                               1 << 13);
+
        textram(vh);
        splx(s);
-#else
+}
+#endif
+
+void
+vga_setfontset(struct vga_handle *vh, int fontset1, int fontset2)
+{
        u_int8_t cmap;
        static u_int8_t cmaptaba[] = {
                0x00, 0x10, 0x01, 0x11,
@@ -147,7 +166,6 @@
        cmap = cmaptaba[fontset1] | cmaptabb[fontset2];
 
        vga_ts_write(vh, fontsel, cmap);
-#endif /* VGA_CONSOLE_ATI_BROKEN_FONTSEL */
 }
 
 void
diff -r bf3e1331fdc6 -r 81f5be6bcf24 sys/dev/ic/vgavar.h
--- a/sys/dev/ic/vgavar.h       Fri Jun 28 21:55:08 2002 +0000
+++ b/sys/dev/ic/vgavar.h       Fri Jun 28 22:24:11 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vgavar.h,v 1.12 2002/06/27 06:26:54 junyoung Exp $ */
+/* $NetBSD: vgavar.h,v 1.13 2002/06/28 22:24:11 drochner Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -186,12 +186,18 @@
 
 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);
 
 struct wsscreen_descr;
 void   vga_loadchars(struct vga_handle *, int, int, int, int, char *);
+void   vga_readoutchars(struct vga_handle *, int, int, int, int, char *);
+#ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
+void   vga_copyfont01(struct vga_handle *);
+#endif
 void   vga_setfontset(struct vga_handle *, int, int);
 void   vga_setscreentype(struct vga_handle *, const struct wsscreen_descr *);
diff -r bf3e1331fdc6 -r 81f5be6bcf24 sys/dev/isa/vga_isa.c
--- a/sys/dev/isa/vga_isa.c     Fri Jun 28 21:55:08 2002 +0000
+++ b/sys/dev/isa/vga_isa.c     Fri Jun 28 22:24:11 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vga_isa.c,v 1.10 2002/06/27 06:26:54 junyoung Exp $ */
+/* $NetBSD: vga_isa.c,v 1.11 2002/06/28 22:24:13 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.10 2002/06/27 06:26:54 junyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga_isa.c,v 1.11 2002/06/28 22:24:13 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 bf3e1331fdc6 -r 81f5be6bcf24 sys/dev/pci/vga_pci.c
--- a/sys/dev/pci/vga_pci.c     Fri Jun 28 21:55:08 2002 +0000
+++ b/sys/dev/pci/vga_pci.c     Fri Jun 28 22:24:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vga_pci.c,v 1.14 2002/06/27 06:44:17 junyoung Exp $    */
+/*     $NetBSD: vga_pci.c,v 1.15 2002/06/28 22:24:13 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.14 2002/06/27 06:44:17 junyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vga_pci.c,v 1.15 2002/06/28 22:24:13 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -73,6 +73,7 @@
 
 int    vga_pci_match(struct device *, struct cfdata *, void *);



Home | Main Index | Thread Index | Old Index