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
This commit is contained in:
parent
958680bc70
commit
9b3975fd12
|
@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.55 2002/06/28 03:38:13 junyoung Exp $");
|
|||
#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 @@ vga_init(struct vga_config *vc, bus_space_tag_t iot, bus_space_tag_t memt)
|
|||
|
||||
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_common_attach(struct vga_softc *sc, bus_space_tag_t iot,
|
|||
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;
|
||||
|
@ -646,6 +658,21 @@ vga_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, int type, int check)
|
|||
panic("vga_cnattach: invalid screen type");
|
||||
#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);
|
||||
|
||||
|
@ -836,8 +863,6 @@ vga_usefont(struct vga_config *vc, struct egavga_font *f)
|
|||
/* 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 @@ vga_usefont(struct vga_config *vc, struct egavga_font *f)
|
|||
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);
|
||||
|
|
|
@ -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 @@ textram(struct vga_handle *vh)
|
|||
}
|
||||
|
||||
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 @@ vga_loadchars(struct vga_handle *vh, int fontset, int first, int num, int lpc,
|
|||
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)
|
||||
{
|
||||
#ifdef VGA_CONSOLE_ATI_BROKEN_FONTSEL
|
||||
/* XXXBJY: 512 character mode is still broken. */
|
||||
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
|
||||
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 @@ vga_setfontset(struct vga_handle *vh, int fontset1, int fontset2)
|
|||
cmap = cmaptaba[fontset1] | cmaptabb[fontset2];
|
||||
|
||||
vga_ts_write(vh, fontsel, cmap);
|
||||
#endif /* VGA_CONSOLE_ATI_BROKEN_FONTSEL */
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -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 @@ _vga_crtc_write(struct vga_handle *vh, int reg, u_int8_t val)
|
|||
|
||||
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 *);
|
||||
|
|
|
@ -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 @@ vga_isa_attach(parent, self, aux)
|
|||
printf("\n");
|
||||
|
||||
vga_common_attach(sc, ia->ia_iot, ia->ia_memt, WSDISPLAY_TYPE_ISAVGA,
|
||||
NULL);
|
||||
0, NULL);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -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 @@ struct vga_pci_softc {
|
|||
|
||||
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 @@ const struct vga_funcs vga_pci_funcs = {
|
|||
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 @@ vga_pci_attach(struct device *parent, struct device *self, void *aux)
|
|||
/* 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
|
||||
|
|
Loading…
Reference in New Issue