Add ability to customize I/O region and DAC offset based on pnpbios idstr.

Add CSC0000 id from Dell Latitude CPi.
This commit is contained in:
groo 2000-02-20 22:03:49 +00:00
parent 7fffbf8679
commit 024d345241

View File

@ -1,4 +1,4 @@
/* $NetBSD: wss_pnpbios.c,v 1.2 1999/11/14 02:15:51 thorpej Exp $ */
/* $NetBSD: wss_pnpbios.c,v 1.3 2000/02/20 22:03:49 groo Exp $ */
/*
* Copyright (c) 1999
* Matthias Drochner. All rights reserved.
@ -49,11 +49,42 @@
int wss_pnpbios_match __P((struct device *, struct cfdata *, void *));
void wss_pnpbios_attach __P((struct device *, struct device *, void *));
int wss_pnpbios_hints_index __P((const char *));
struct cfattach wss_pnpbios_ca = {
sizeof(struct wss_softc), wss_pnpbios_match, wss_pnpbios_attach
};
struct wss_pnpbios_hint {
char idstr[8];
int io_region_idx_ad1848; /* which region index is the DAC? */
int io_region_idx_opl; /* which region index is the OPL? */
int offset_ad1848; /* offset from start of DAC region */
};
struct wss_pnpbios_hint wss_pnpbios_hints[] = {
{ "NMX2210", 1, 2, WSS_CODEC },
{ "CSC0000", 0, 1, 0 }, /* Dell Latitude CPi */
{ { 0 }, 0, 0, 0 }
};
int
wss_pnpbios_hints_index(idstr)
const char *idstr;
{
int idx = 0;
while (wss_pnpbios_hints[idx].idstr[0] != 0) {
if (!strcmp(wss_pnpbios_hints[idx].idstr, idstr))
return idx;
++idx;
}
return -1;
}
int
wss_pnpbios_match(parent, match, aux)
struct device *parent;
@ -62,7 +93,7 @@ wss_pnpbios_match(parent, match, aux)
{
struct pnpbiosdev_attach_args *aa = aux;
if (strcmp(aa->idstr, "NMX2210"))
if (wss_pnpbios_hints_index(aa->idstr) == -1)
return (0);
return (2); /* beat sb */
@ -76,6 +107,8 @@ wss_pnpbios_attach(parent, self, aux)
struct wss_softc *sc = (void *)self;
struct pnpbiosdev_attach_args *aa = aux;
struct audio_attach_args arg;
struct wss_pnpbios_hint *wph;
#if 0
static u_char interrupt_bits[12] = {
-1, -1, -1, -1, -1, -1, -1, 0x08, -1, 0x10, 0x18, 0x20
@ -83,11 +116,15 @@ wss_pnpbios_attach(parent, self, aux)
static u_char dma_bits[4] = {1, 2, 0, 3};
#endif
if (pnpbios_io_map(aa->pbt, aa->resc, 1, &sc->sc_iot, &sc->sc_ioh)) {
wph = &wss_pnpbios_hints[wss_pnpbios_hints_index(aa->idstr)];
if (pnpbios_io_map(aa->pbt, aa->resc, wph->io_region_idx_ad1848,
&sc->sc_iot, &sc->sc_ioh)) {
printf(": can't map i/o space\n");
return;
}
if (pnpbios_io_map(aa->pbt, aa->resc, 2, &sc->sc_iot, &sc->sc_opl_ioh)) {
if (pnpbios_io_map(aa->pbt, aa->resc, wph->io_region_idx_opl,
&sc->sc_iot, &sc->sc_opl_ioh)) {
printf(": can't map i/o space\n");
return;
}
@ -107,7 +144,7 @@ wss_pnpbios_attach(parent, self, aux)
sc->wss_recdrq = -1;
sc->sc_ad1848.sc_ad1848.sc_iot = sc->sc_iot;
bus_space_subregion(sc->sc_iot, sc->sc_ioh, WSS_CODEC, 4,
bus_space_subregion(sc->sc_iot, sc->sc_ioh, wph->offset_ad1848, 4,
&sc->sc_ad1848.sc_ad1848.sc_ioh);
printf("\n");