Split device_t and softc for sb(4) and all its attachments.

This commit is contained in:
cube 2008-03-15 21:09:02 +00:00
parent 22c6c5ebca
commit 612c30d938
11 changed files with 156 additions and 157 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sb_pnpbios.c,v 1.12 2006/11/16 01:32:39 christos Exp $ */
/* $NetBSD: sb_pnpbios.c,v 1.13 2008/03/15 21:09:02 cube Exp $ */
/*
* Copyright (c) 1999
* Matthias Drochner. All rights reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sb_pnpbios.c,v 1.12 2006/11/16 01:32:39 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: sb_pnpbios.c,v 1.13 2008/03/15 21:09:02 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -53,15 +53,14 @@ __KERNEL_RCSID(0, "$NetBSD: sb_pnpbios.c,v 1.12 2006/11/16 01:32:39 christos Exp
#include <dev/isa/sbdspvar.h>
int sb_pnpbios_match(struct device *, struct cfdata *, void *);
void sb_pnpbios_attach(struct device *, struct device *, void *);
int sb_pnpbios_match(device_t, cfdata_t, void *);
void sb_pnpbios_attach(device_t, device_t, void *);
CFATTACH_DECL(sb_pnpbios, sizeof(struct sbdsp_softc),
CFATTACH_DECL_NEW(sb_pnpbios, sizeof(struct sbdsp_softc),
sb_pnpbios_match, sb_pnpbios_attach, NULL, NULL);
int
sb_pnpbios_match(struct device *parent, struct cfdata *match,
void *aux)
sb_pnpbios_match(device_t parent, cfdata_t match, void *aux)
{
struct pnpbiosdev_attach_args *aa = aux;
@ -73,14 +72,14 @@ sb_pnpbios_match(struct device *parent, struct cfdata *match,
}
void
sb_pnpbios_attach(struct device *parent, struct device *self,
void *aux)
sb_pnpbios_attach(device_t parent, device_t self, void *aux)
{
struct sbdsp_softc *sc = (void *)self;
struct sbdsp_softc *sc = device_private(self);
struct pnpbiosdev_attach_args *aa = aux;
sc->sc_dev = self;
if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) {
printf(": can't map i/o space\n");
aprint_error(": can't map i/o space\n");
return;
}
@ -91,24 +90,24 @@ sb_pnpbios_attach(struct device *parent, struct device *self,
if (pnpbios_getirqnum(aa->pbt, aa->resc, 0, &sc->sc_irq,
NULL)) {
printf(": can't get IRQ\n");
aprint_error(": can't get IRQ\n");
return;
}
if (pnpbios_getdmachan(aa->pbt, aa->resc, 0, &sc->sc_drq8)) {
printf(": can't get DMA channel\n");
aprint_errpr(": can't get DMA channel\n");
return;
}
if (pnpbios_getdmachan(aa->pbt, aa->resc, 1, &sc->sc_drq16))
sc->sc_drq16 = -1;
printf("\n");
aprint_normal("\n");
pnpbios_print_devres(self, aa);
printf("%s", self->dv_xname);
aprint_normal("%s", device_xname(self));
if (!sbmatch(sc)) {
printf("%s: sbmatch failed\n", sc->sc_dev.dv_xname);
aprint_error_dev(self, "%s: sbmatch failed\n");
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mpu_sb.c,v 1.12 2007/10/19 12:00:21 ad Exp $ */
/* $NetBSD: mpu_sb.c,v 1.13 2008/03/15 21:09:02 cube Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mpu_sb.c,v 1.12 2007/10/19 12:00:21 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: mpu_sb.c,v 1.13 2008/03/15 21:09:02 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -57,18 +57,17 @@ __KERNEL_RCSID(0, "$NetBSD: mpu_sb.c,v 1.12 2007/10/19 12:00:21 ad Exp $");
#include <dev/isa/isavar.h>
#include <dev/isa/sbdspvar.h>
int mpu_sb_match(struct device *, struct cfdata *, void *);
void mpu_sb_attach(struct device *, struct device *, void *);
int mpu_sb_match(device_t, cfdata_t, void *);
void mpu_sb_attach(device_t, device_t, void *);
CFATTACH_DECL(mpu_sb, sizeof(struct mpu_softc),
mpu_sb_match, mpu_sb_attach, NULL, NULL);
int
mpu_sb_match(struct device *parent, struct cfdata *match,
void *aux)
mpu_sb_match(device_t parent, cfdata_t match, void *aux)
{
struct audio_attach_args *aa = (struct audio_attach_args *)aux;
struct sbdsp_softc *ssc = (struct sbdsp_softc *)parent;
struct sbdsp_softc *ssc = device_private(parent);
struct mpu_softc sc;
if (aa->type != AUDIODEV_TYPE_MPU)
@ -80,12 +79,12 @@ mpu_sb_match(struct device *parent, struct cfdata *match,
}
void
mpu_sb_attach(struct device *parent, struct device *self, void *aux)
mpu_sb_attach(device_t parent, device_t self, void *aux)
{
struct sbdsp_softc *ssc = (struct sbdsp_softc *)parent;
struct mpu_softc *sc = (struct mpu_softc *)self;
struct sbdsp_softc *ssc = device_private(parent);
struct mpu_softc *sc = device_private(self);
printf("\n");
aprint_normal("\n");
sc->ioh = ssc->sc_mpu_ioh;
sc->iot = ssc->sc_mpu_iot;

View File

@ -1,4 +1,4 @@
/* $NetBSD: opl_sb.c,v 1.15 2007/10/19 12:00:21 ad Exp $ */
/* $NetBSD: opl_sb.c,v 1.16 2008/03/15 21:09:02 cube Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: opl_sb.c,v 1.15 2007/10/19 12:00:21 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: opl_sb.c,v 1.16 2008/03/15 21:09:02 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -61,17 +61,17 @@ __KERNEL_RCSID(0, "$NetBSD: opl_sb.c,v 1.15 2007/10/19 12:00:21 ad Exp $");
#include <dev/isa/isavar.h>
#include <dev/isa/sbdspvar.h>
int opl_sb_match(struct device *, struct cfdata *, void *);
void opl_sb_attach(struct device *, struct device *, void *);
int opl_sb_match(device_t, cfdata_t, void *);
void opl_sb_attach(device_t, device_t, void *);
CFATTACH_DECL(opl_sb, sizeof(struct opl_softc),
opl_sb_match, opl_sb_attach, NULL, NULL);
int
opl_sb_match(struct device *parent, struct cfdata *match, void *aux)
opl_sb_match(device_t parent, cfdata_t match, void *aux)
{
struct audio_attach_args *aa = (struct audio_attach_args *)aux;
struct sbdsp_softc *ssc = (struct sbdsp_softc *)parent;
struct sbdsp_softc *ssc = device_private(parent);
if (aa->type != AUDIODEV_TYPE_OPL)
return (0);
@ -79,10 +79,10 @@ opl_sb_match(struct device *parent, struct cfdata *match, void *aux)
}
void
opl_sb_attach(struct device *parent, struct device *self, void *aux)
opl_sb_attach(device_t parent, device_t self, void *aux)
{
struct sbdsp_softc *ssc = (struct sbdsp_softc *)parent;
struct opl_softc *sc = (struct opl_softc *)self;
struct sbdsp_softc *ssc = device_private(parent);
struct opl_softc *sc = device_private(self);
sc->ioh = ssc->sc_ioh;
sc->iot = ssc->sc_iot;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pas.c,v 1.66 2007/10/19 12:00:21 ad Exp $ */
/* $NetBSD: pas.c,v 1.67 2008/03/15 21:09:02 cube Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@ -57,7 +57,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pas.c,v 1.66 2007/10/19 12:00:21 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: pas.c,v 1.67 2008/03/15 21:09:02 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -253,15 +253,15 @@ pasconf(int model, int sbbase, int sbirq, int sbdrq)
paswrite(P_M_MV508_INPUTMIX | 30, PARALLEL_MIXER);
}
int pasprobe(struct device *, struct cfdata *, void *);
void pasattach(struct device *, struct device *, void *);
static int pasfind(struct device *, struct pas_softc *,
int pasprobe(device_t, cfdata_t, void *);
void pasattach(device_t, device_t, void *);
static int pasfind(cfdata_t, struct pas_softc *,
struct isa_attach_args *, int);
/* argument to pasfind */
#define PASPROBE 1
#define PASATTACH 0
CFATTACH_DECL(pas, sizeof(struct pas_softc),
CFATTACH_DECL_NEW(pas, sizeof(struct pas_softc),
pasprobe, pasattach, NULL, NULL);
/*
@ -269,7 +269,7 @@ CFATTACH_DECL(pas, sizeof(struct pas_softc),
*/
int
pasprobe(struct device *parent, struct cfdata *match, void *aux)
pasprobe(device_t parent, cfdata_t match, void *aux)
{
struct isa_attach_args *ia;
struct pas_softc probesc, *sc;
@ -287,16 +287,14 @@ pasprobe(struct device *parent, struct cfdata *match, void *aux)
return 0;
memset(sc, 0, sizeof *sc);
sc->sc_sbdsp.sc_dev.dv_cfdata = match;
strcpy(sc->sc_sbdsp.sc_dev.dv_xname, "pas");
return pasfind(parent, sc, aux, PASPROBE);
return pasfind(match, sc, aux, PASPROBE);
}
/*
* Probe for the soundblaster hardware.
*/
static int
pasfind(struct device *parent, struct pas_softc *sc,
pasfind(cfdata_t match, struct pas_softc *sc,
struct isa_attach_args *ia, int probing)
{
int iobase;
@ -427,7 +425,7 @@ pasfind(struct device *parent, struct pas_softc *sc,
sc->sc_sbdsp.sc_drq8 = ia->ia_drq[0].ir_drq;
sc->sc_sbdsp.sc_drq16 = -1; /* XXX */
if (sbdsp_probe(&sc->sc_sbdsp) == 0) {
if (sbdsp_probe(&sc->sc_sbdsp, match) == 0) {
DPRINTF(("pas: sbdsp probe failed\n"));
goto unmap;
}
@ -459,17 +457,18 @@ pasfind(struct device *parent, struct pas_softc *sc,
* pseudo-device driver .
*/
void
pasattach(struct device *parent, struct device *self, void *aux)
pasattach(device_t parent, device_t self, void *aux)
{
struct pas_softc *sc;
struct isa_attach_args *ia;
int iobase;
sc = (struct pas_softc *)self;
sc = device_private(self);
sc->sc_sbdsp.sc_dev = self;
ia = (struct isa_attach_args *)aux;
iobase = ia->ia_io[0].ir_addr;
if (!pasfind(parent, sc, ia, PASATTACH)) {
printf("%s: pasfind failed\n", sc->sc_sbdsp.sc_dev.dv_xname);
if (!pasfind(device_cfdata(self), sc, ia, PASATTACH)) {
aprint_error_dev(self, "pasfind failed\n");
return;
}
@ -478,7 +477,7 @@ pasattach(struct device *parent, struct device *self, void *aux)
sc->sc_sbdsp.sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
IST_EDGE, IPL_AUDIO, sbdsp_intr, &sc->sc_sbdsp);
printf(" ProAudio Spectrum %s [rev %d] ", pasnames[sc->model],
aprint_normal(" ProAudio Spectrum %s [rev %d] ", pasnames[sc->model],
sc->rev);
sbdsp_attach(&sc->sc_sbdsp);
@ -488,7 +487,7 @@ pasattach(struct device *parent, struct device *self, void *aux)
snprintf(pas_device.version, sizeof(pas_device.version), "%d",
sc->rev);
audio_attach_mi(&pas_hw_if, &sc->sc_sbdsp, &sc->sc_sbdsp.sc_dev);
audio_attach_mi(&pas_hw_if, &sc->sc_sbdsp, sc->sc_sbdsp.sc_dev);
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: sb.c,v 1.87 2007/10/19 12:00:22 ad Exp $ */
/* $NetBSD: sb.c,v 1.88 2008/03/15 21:09:02 cube Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sb.c,v 1.87 2007/10/19 12:00:22 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sb.c,v 1.88 2008/03/15 21:09:02 cube Exp $");
#include "midi.h"
@ -115,7 +115,7 @@ const struct audio_hw_if sb_hw_if = {
int
sbmatch(struct sbdsp_softc *sc)
sbmatch(struct sbdsp_softc *sc, int probing, cfdata_t match)
{
static const u_char drq_conf[8] = {
0x01, 0x02, -1, 0x08, -1, 0x20, 0x40, 0x80
@ -125,7 +125,7 @@ sbmatch(struct sbdsp_softc *sc)
-1, -1, 0x01, -1, -1, 0x02, -1, 0x04, -1, 0x01, 0x08
};
if (sbdsp_probe(sc) == 0)
if (sbdsp_probe(sc, match) == 0)
return 0;
/*
@ -133,14 +133,16 @@ sbmatch(struct sbdsp_softc *sc)
*/
if (ISSBPROCLASS(sc)) {
if (!SBP_DRQ_VALID(sc->sc_drq8)) {
printf("%s: configured DMA chan %d invalid\n",
sc->sc_dev.dv_xname, sc->sc_drq8);
aprint_error("%s: configured DMA chan %d invalid\n",
probing ? "sbmatch" : device_xname(sc->sc_dev),
sc->sc_drq8);
return 0;
}
} else {
if (!SB_DRQ_VALID(sc->sc_drq8)) {
printf("%s: configured DMA chan %d invalid\n",
sc->sc_dev.dv_xname, sc->sc_drq8);
aprint_error("%s: configured DMA chan %d invalid\n",
probing ? "sbmatch" : device_xname(sc->sc_dev),
sc->sc_drq8);
return 0;
}
}
@ -157,8 +159,9 @@ sbmatch(struct sbdsp_softc *sc)
if (sc->sc_drq16 == -1)
sc->sc_drq16 = sc->sc_drq8;
if (!SB16_DRQ_VALID(sc->sc_drq16)) {
printf("%s: configured DMA chan %d invalid\n",
sc->sc_dev.dv_xname, sc->sc_drq16);
aprint_error("%s: configured DMA chan %d invalid\n",
probing ? "sbmatch" : device_xname(sc->sc_dev),
sc->sc_drq16);
return 0;
}
} else
@ -166,14 +169,16 @@ sbmatch(struct sbdsp_softc *sc)
if (ISSBPROCLASS(sc)) {
if (!SBP_IRQ_VALID(sc->sc_irq)) {
printf("%s: configured irq %d invalid\n",
sc->sc_dev.dv_xname, sc->sc_irq);
aprint_error("%s: configured irq %d invalid\n",
probing ? "sbmatch" : device_xname(sc->sc_dev),
sc->sc_irq);
return 0;
}
} else {
if (!SB_IRQ_VALID(sc->sc_irq)) {
printf("%s: configured irq %d invalid\n",
sc->sc_dev.dv_xname, sc->sc_irq);
aprint_error("%s: configured irq %d invalid\n",
probing ? "sbmatch" : device_xname(sc->sc_dev),
sc->sc_irq);
return 0;
}
}
@ -181,55 +186,62 @@ sbmatch(struct sbdsp_softc *sc)
if (ISSB16CLASS(sc) && !(sc->sc_quirks & SB_QUIRK_NO_INIT_DRQ)) {
int w, r;
if (sc->sc_irq >= __arraycount(irq_conf)) {
printf("%s: Cannot handle irq %d\n",
sc->sc_dev.dv_xname, sc->sc_irq);
aprint_error("%s: Cannot handle irq %d\n",
probing ? "sbmatch" : device_xname(sc->sc_dev),
sc->sc_irq);
return 0;
}
if (sc->sc_drq16 >= __arraycount(drq_conf)) {
printf("%s: Cannot handle drq16 %d\n",
sc->sc_dev.dv_xname, sc->sc_drq16);
aprint_error("%s: Cannot handle drq16 %d\n",
probing ? "sbmatch" : device_xname(sc->sc_dev),
sc->sc_drq16);
return 0;
}
if (sc->sc_drq8 >= __arraycount(drq_conf)) {
printf("%s: Cannot handle drq8 %d\n",
sc->sc_dev.dv_xname, sc->sc_drq8);
aprint_error("%s: Cannot handle drq8 %d\n",
probing ? "sbmatch" : device_xname(sc->sc_dev),
sc->sc_drq8);
return 0;
}
#if 0
printf("%s: old drq conf %02x\n", sc->sc_dev.dv_xname,
printf("%s: old drq conf %02x\n", device_xname(sc->sc_dev),
sbdsp_mix_read(sc, SBP_SET_DRQ));
printf("%s: try drq conf %02x\n", sc->sc_dev.dv_xname,
printf("%s: try drq conf %02x\n", device_xname(sc->sc_dev),
drq_conf[sc->sc_drq16] | drq_conf[sc->sc_drq8]);
#endif
w = drq_conf[sc->sc_drq16] | drq_conf[sc->sc_drq8];
sbdsp_mix_write(sc, SBP_SET_DRQ, w);
r = sbdsp_mix_read(sc, SBP_SET_DRQ) & 0xeb;
if (r != w) {
printf("%s: setting drq mask %02x failed, got %02x\n",
sc->sc_dev.dv_xname, w, r);
aprint_error("%s: setting drq mask %02x failed, "
"got %02x\n",
probing ? "sbmatch" : device_xname(sc->sc_dev), w,
r);
return 0;
}
#if 0
printf("%s: new drq conf %02x\n", sc->sc_dev.dv_xname,
printf("%s: new drq conf %02x\n", device_xname(sc->sc_dev),
sbdsp_mix_read(sc, SBP_SET_DRQ));
#endif
#if 0
printf("%s: old irq conf %02x\n", sc->sc_dev.dv_xname,
printf("%s: old irq conf %02x\n", device_xname(sc->sc_dev),
sbdsp_mix_read(sc, SBP_SET_IRQ));
printf("%s: try irq conf %02x\n", sc->sc_dev.dv_xname,
printf("%s: try irq conf %02x\n", device_xname(sc->sc_dev),
irq_conf[sc->sc_irq]);
#endif
w = irq_conf[sc->sc_irq];
sbdsp_mix_write(sc, SBP_SET_IRQ, w);
r = sbdsp_mix_read(sc, SBP_SET_IRQ) & 0x0f;
if (r != w) {
printf("%s: setting irq mask %02x failed, got %02x\n",
sc->sc_dev.dv_xname, w, r);
aprint_error("%s: setting irq mask %02x failed, "
"got %02x\n",
probing ? "sbmatch" : device_xname(sc->sc_dev), w,
r);
return 0;
}
#if 0
printf("%s: new irq conf %02x\n", sc->sc_dev.dv_xname,
printf("%s: new irq conf %02x\n", device_xname(sc->sc_dev),
sbdsp_mix_read(sc, SBP_SET_IRQ));
#endif
}
@ -245,7 +257,7 @@ sbattach(struct sbdsp_softc *sc)
sbdsp_attach(sc);
audio_attach_mi(&sb_hw_if, sc, &sc->sc_dev);
audio_attach_mi(&sb_hw_if, sc, sc->sc_dev);
#if NMPU > 0
switch(sc->sc_hasmpu) {
@ -253,13 +265,13 @@ sbattach(struct sbdsp_softc *sc)
case SBMPU_NONE: /* no mpu */
break;
case SBMPU_INTERNAL: /* try to attach midi directly */
midi_attach_mi(&sb_midi_hw_if, sc, &sc->sc_dev);
midi_attach_mi(&sb_midi_hw_if, sc, sc->sc_dev);
break;
case SBMPU_EXTERNAL: /* search for mpu */
arg.type = AUDIODEV_TYPE_MPU;
arg.hwif = 0;
arg.hdl = 0;
sc->sc_mpudev = config_found(&sc->sc_dev, &arg, audioprint);
sc->sc_mpudev = config_found_ia(sc->sc_dev, "sbdsp", &arg, audioprint);
break;
}
#endif
@ -267,7 +279,7 @@ sbattach(struct sbdsp_softc *sc)
arg.type = AUDIODEV_TYPE_OPL;
arg.hwif = 0;
arg.hdl = 0;
(void)config_found(&sc->sc_dev, &arg, audioprint);
(void)config_found_ia(sc->sc_dev, "sbdsp", &arg, audioprint);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sb_isa.c,v 1.35 2007/10/19 12:00:22 ad Exp $ */
/* $NetBSD: sb_isa.c,v 1.36 2008/03/15 21:09:02 cube Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sb_isa.c,v 1.35 2007/10/19 12:00:22 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sb_isa.c,v 1.36 2008/03/15 21:09:02 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -60,13 +60,13 @@ __KERNEL_RCSID(0, "$NetBSD: sb_isa.c,v 1.35 2007/10/19 12:00:22 ad Exp $");
#include <dev/isa/sbdspvar.h>
static int sbfind(struct device *, struct sbdsp_softc *, int,
struct isa_attach_args *);
static int sbfind(device_t, struct sbdsp_softc *, int,
struct isa_attach_args *, cfdata_t);
int sb_isa_match(struct device *, struct cfdata *, void *);
void sb_isa_attach(struct device *, struct device *, void *);
int sb_isa_match(device_t, cfdata_t, void *);
void sb_isa_attach(device_t, device_t, void *);
CFATTACH_DECL(sb_isa, sizeof(struct sbdsp_softc),
CFATTACH_DECL_NEW(sb_isa, sizeof(struct sbdsp_softc),
sb_isa_match, sb_isa_attach, NULL, NULL);
/*
@ -77,10 +77,7 @@ CFATTACH_DECL(sb_isa, sizeof(struct sbdsp_softc),
* Probe for the soundblaster hardware.
*/
int
sb_isa_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
sb_isa_match(device_t parent, cfdata_t match, void *aux)
{
struct isa_attach_args *ia = aux;
struct sbdsp_softc probesc, *sc = &probesc;
@ -96,14 +93,12 @@ sb_isa_match(parent, match, aux)
return (0);
memset(sc, 0, sizeof *sc);
strcpy(sc->sc_dev.dv_xname, "sb");
sc->sc_dev.dv_cfdata = match;
return sbfind(parent, sc, 1, aux);
return sbfind(parent, sc, 1, aux, match);
}
static int
sbfind(struct device *parent, struct sbdsp_softc *sc, int probing,
struct isa_attach_args *ia)
sbfind(device_t parent, struct sbdsp_softc *sc, int probing,
struct isa_attach_args *ia, cfdata_t match)
{
int rc = 0;
@ -128,7 +123,7 @@ sbfind(struct device *parent, struct sbdsp_softc *sc, int probing,
sc->sc_drq8 = ia->ia_drq[0].ir_drq;
sc->sc_drq16 = ia->ia_drq[1].ir_drq;
if (!sbmatch(sc))
if (!sbmatch(sc, probing, match))
goto bad;
rc = 1;
@ -162,17 +157,17 @@ bad:
* pseudo-device driver .
*/
void
sb_isa_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
sb_isa_attach(device_t parent, device_t self, void *aux)
{
struct sbdsp_softc *sc = (struct sbdsp_softc *)self;
struct sbdsp_softc *sc = device_private(self);
struct isa_attach_args *ia = aux;
if (!sbfind(parent, sc, 0, ia) ||
sc->sc_dev = self;
if (!sbfind(parent, sc, 0, ia, device_cfdata(self)) ||
bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr,
ia->ia_io[0].ir_size, 0, &sc->sc_ioh)) {
printf("%s: sbfind failed\n", sc->sc_dev.dv_xname);
aprint_error_dev(self, "sbfind failed\n");
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sbdsp.c,v 1.127 2007/10/19 12:00:22 ad Exp $ */
/* $NetBSD: sbdsp.c,v 1.128 2008/03/15 21:09:02 cube Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sbdsp.c,v 1.127 2007/10/19 12:00:22 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sbdsp.c,v 1.128 2008/03/15 21:09:02 cube Exp $");
#include "midi.h"
#include "mpu.h"
@ -267,7 +267,7 @@ sb_printsc(struct sbdsp_softc *sc)
* Probe for the soundblaster hardware.
*/
int
sbdsp_probe(struct sbdsp_softc *sc)
sbdsp_probe(struct sbdsp_softc *sc, cfdata_t match)
{
if (sbdsp_reset(sc) < 0) {
@ -275,7 +275,7 @@ sbdsp_probe(struct sbdsp_softc *sc)
return 0;
}
/* if flags set, go and probe the jazz16 stuff */
if (device_cfdata(&sc->sc_dev)->cf_flags & 1)
if (match->cf_flags & 1)
sbdsp_jazz16_probe(sc);
else
sbversion(sc);
@ -422,8 +422,8 @@ sbdsp_attach(struct sbdsp_softc *sc)
error = isa_dmamap_create(sc->sc_ic, sc->sc_drq8,
sc->sc_drq8_maxsize, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW);
if (error) {
printf("%s: can't create map for drq %d\n",
sc->sc_dev.dv_xname, sc->sc_drq8);
aprint_error_dev(sc->sc_dev,
"can't create map for drq %d\n", sc->sc_drq8);
return;
}
}
@ -434,14 +434,14 @@ sbdsp_attach(struct sbdsp_softc *sc)
error = isa_dmamap_create(sc->sc_ic, sc->sc_drq16,
sc->sc_drq16_maxsize, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW);
if (error) {
printf("%s: can't create map for drq %d\n",
sc->sc_dev.dv_xname, sc->sc_drq16);
aprint_error_dev(sc->sc_dev,
"can't create map for drq %d\n", sc->sc_drq16);
isa_dmamap_destroy(sc->sc_ic, sc->sc_drq8);
return;
}
}
powerhook_establish(sc->sc_dev.dv_xname, sbdsp_powerhook, sc);
powerhook_establish(device_xname(sc->sc_dev), sbdsp_powerhook, sc);
}
static void

View File

@ -1,4 +1,4 @@
/* $NetBSD: sbdspvar.h,v 1.58 2006/04/13 09:47:19 cube Exp $ */
/* $NetBSD: sbdspvar.h,v 1.59 2008/03/15 21:09:02 cube Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@ -92,7 +92,7 @@
* most basic communications with the sb card.
*/
struct sbdsp_softc {
struct device sc_dev; /* base device */
device_t sc_dev; /* base device */
isa_chipset_tag_t sc_ic;
bus_space_tag_t sc_iot; /* tag */
bus_space_handle_t sc_ioh; /* handle */
@ -198,7 +198,7 @@ struct malloc_type;
int sbdsp_open(void *, int);
void sbdsp_close(void *);
int sbdsp_probe(struct sbdsp_softc *);
int sbdsp_probe(struct sbdsp_softc *, cfdata_t);
void sbdsp_attach(struct sbdsp_softc *);
int sbdsp_set_in_gain(void *, u_int, u_char);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sbvar.h,v 1.4 2005/12/11 12:22:03 christos Exp $ */
/* $NetBSD: sbvar.h,v 1.5 2008/03/15 21:09:02 cube Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -37,5 +37,5 @@
*/
struct sbdsp_softc;
int sbmatch(struct sbdsp_softc *);
int sbmatch(struct sbdsp_softc *, int, cfdata_t);
void sbattach(struct sbdsp_softc *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sb_isapnp.c,v 1.51 2007/10/19 12:00:33 ad Exp $ */
/* $NetBSD: sb_isapnp.c,v 1.52 2008/03/15 21:09:02 cube Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sb_isapnp.c,v 1.51 2007/10/19 12:00:33 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sb_isapnp.c,v 1.52 2008/03/15 21:09:02 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -63,10 +63,10 @@ __KERNEL_RCSID(0, "$NetBSD: sb_isapnp.c,v 1.51 2007/10/19 12:00:33 ad Exp $");
#include <dev/isa/sbvar.h>
#include <dev/isa/sbdspvar.h>
int sb_isapnp_match(struct device *, struct cfdata *, void *);
void sb_isapnp_attach(struct device *, struct device *, void *);
int sb_isapnp_match(device_t, cfdata_t, void *);
void sb_isapnp_attach(device_t, device_t, void *);
CFATTACH_DECL(sb_isapnp, sizeof(struct sbdsp_softc),
CFATTACH_DECL_NEW(sb_isapnp, sizeof(struct sbdsp_softc),
sb_isapnp_match, sb_isapnp_attach, NULL, NULL);
/*
@ -77,8 +77,7 @@ CFATTACH_DECL(sb_isapnp, sizeof(struct sbdsp_softc),
* Probe for the soundblaster hardware.
*/
int
sb_isapnp_match(struct device *parent, struct cfdata *match,
void *aux)
sb_isapnp_match(device_t parent, cfdata_t match, void *aux)
{
int pri, variant;
@ -93,14 +92,15 @@ sb_isapnp_match(struct device *parent, struct cfdata *match,
* pseudo-device driver.
*/
void
sb_isapnp_attach(struct device *parent, struct device *self, void *aux)
sb_isapnp_attach(device_t parent, device_t self, void *aux)
{
struct sbdsp_softc *sc;
struct isapnp_attach_args *ipa;
sc = device_private(self);
sc->sc_dev = self;
ipa = aux;
printf("\n");
aprint_normal("\n");
/*
* Avance logic ALS100+ does not like being frobbed
@ -110,8 +110,7 @@ sb_isapnp_attach(struct device *parent, struct device *self, void *aux)
sc->sc_quirks = SB_QUIRK_NO_INIT_DRQ;
if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
printf("%s: error in region allocation\n",
sc->sc_dev.dv_xname);
aprint_error_dev(self, "error in region allocation\n");
return;
}
@ -155,16 +154,15 @@ sb_isapnp_attach(struct device *parent, struct device *self, void *aux)
}
#endif
if (!sbmatch(sc)) {
printf("%s: sbmatch failed\n", sc->sc_dev.dv_xname);
if (!sbmatch(sc, 0, device_cfdata(self))) {
aprint_error_dev(self, "sbmatch failed\n");
return;
}
sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
ipa->ipa_irq[0].type, IPL_AUDIO, sbdsp_intr, sc);
printf("%s: %s %s", sc->sc_dev.dv_xname, ipa->ipa_devident,
ipa->ipa_devclass);
aprint_normal_dev(self, "%s %s", ipa->ipa_devident, ipa->ipa_devclass);
sbattach(sc);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sb_ofisa.c,v 1.15 2007/10/19 12:00:38 ad Exp $ */
/* $NetBSD: sb_ofisa.c,v 1.16 2008/03/15 21:09:02 cube Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sb_ofisa.c,v 1.15 2007/10/19 12:00:38 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sb_ofisa.c,v 1.16 2008/03/15 21:09:02 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -60,17 +60,14 @@ __KERNEL_RCSID(0, "$NetBSD: sb_ofisa.c,v 1.15 2007/10/19 12:00:38 ad Exp $");
#include <dev/isa/sbvar.h>
#include <dev/isa/sbdspvar.h>
int sb_ofisa_match(struct device *, struct cfdata *, void *);
void sb_ofisa_attach(struct device *, struct device *, void *);
int sb_ofisa_match(device_t, cfdata_t, void *);
void sb_ofisa_attach(device_t, device_t, void *);
CFATTACH_DECL(sb_ofisa, sizeof(struct sbdsp_softc),
CFATTACH_DECL_NEW(sb_ofisa, sizeof(struct sbdsp_softc),
sb_ofisa_match, sb_ofisa_attach, NULL, NULL);
int
sb_ofisa_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
sb_ofisa_match(device_t parent, cfdata_t cf, void *aux)
{
struct ofisa_attach_args *aa = aux;
static const char *const compatible_strings[] = {
@ -94,9 +91,7 @@ sb_ofisa_match(parent, cf, aux)
}
void
sb_ofisa_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
sb_ofisa_attach(device_t parent, device_t self, void *aux)
{
struct sbdsp_softc *sc = device_private(self);
struct ofisa_attach_args *aa = aux;
@ -106,6 +101,8 @@ sb_ofisa_attach(parent, self, aux)
int n, ndrq;
char *model;
sc->sc_dev = self;
/*
* We're living on an OFW. We have to ask the OFW what our
* registers and interrupts properties look like.
@ -148,7 +145,7 @@ sb_ofisa_attach(parent, self, aux)
sc->sc_iot = aa->iot;
if (bus_space_map(sc->sc_iot, reg.addr, reg.len, 0, &sc->sc_ioh)) {
printf(": unable to map register space\n");
aprint_error(": unable to map register space\n");
return;
}
@ -171,18 +168,18 @@ sb_ofisa_attach(parent, self, aux)
sc->sc_drq16 = dma[n].drq;
break;
default:
printf(": weird DMA width %d\n", dma[n].width);
aprint_error(": weird DMA width %d\n", dma[n].width);
return;
}
}
if (sc->sc_drq8 == DRQUNK) {
printf(": no 8-bit DMA channel\n");
aprint_error(": no 8-bit DMA channel\n");
return;
}
if (sbmatch(sc) == 0) {
printf(": sbmatch failed\n");
aprint_error(": sbmatch failed\n");
return;
}
@ -193,7 +190,7 @@ sb_ofisa_attach(parent, self, aux)
if (n > 0) {
model = alloca(n);
if (OF_getprop(aa->oba.oba_phandle, "model", model, n) == n)
printf(": %s\n%s", model, sc->sc_dev.dv_xname);
aprint_normal(": %s\n%s", model, device_xname(self));
}
sbattach(sc);