Home | History | Annotate | Line # | Download | only in isapnp
mpu_isapnp.c revision 1.4
      1  1.1   mycroft #include "midi.h"
      2  1.1   mycroft 
      3  1.1   mycroft #include <sys/param.h>
      4  1.1   mycroft #include <sys/systm.h>
      5  1.1   mycroft #include <sys/errno.h>
      6  1.1   mycroft #include <sys/ioctl.h>
      7  1.1   mycroft #include <sys/syslog.h>
      8  1.1   mycroft #include <sys/device.h>
      9  1.1   mycroft #include <sys/proc.h>
     10  1.1   mycroft 
     11  1.1   mycroft #include <machine/bus.h>
     12  1.1   mycroft 
     13  1.1   mycroft #include <sys/audioio.h>
     14  1.1   mycroft #include <dev/audio_if.h>
     15  1.1   mycroft #include <dev/midi_if.h>
     16  1.1   mycroft #include <dev/mulaw.h>
     17  1.1   mycroft 
     18  1.1   mycroft #include <dev/isa/isavar.h>
     19  1.1   mycroft #include <dev/isa/isadmavar.h>
     20  1.1   mycroft 
     21  1.1   mycroft #include <dev/isapnp/isapnpreg.h>
     22  1.1   mycroft #include <dev/isapnp/isapnpvar.h>
     23  1.1   mycroft #include <dev/isapnp/isapnpdevs.h>
     24  1.1   mycroft 
     25  1.4  augustss #include <dev/ic/mpuvar.h>
     26  1.1   mycroft 
     27  1.1   mycroft int	mpu_isapnp_match __P((struct device *, struct cfdata *, void *));
     28  1.1   mycroft void	mpu_isapnp_attach __P((struct device *, struct device *, void *));
     29  1.1   mycroft 
     30  1.1   mycroft struct mpu_isapnp_softc {
     31  1.1   mycroft 	struct device sc_dev;
     32  1.1   mycroft 	void *sc_ih;
     33  1.1   mycroft 
     34  1.1   mycroft 	struct mpu_softc sc_mpu;
     35  1.1   mycroft };
     36  1.1   mycroft 
     37  1.1   mycroft struct cfattach mpu_isapnp_ca = {
     38  1.1   mycroft 	sizeof(struct mpu_isapnp_softc), mpu_isapnp_match, mpu_isapnp_attach
     39  1.1   mycroft };
     40  1.1   mycroft 
     41  1.1   mycroft int
     42  1.1   mycroft mpu_isapnp_match(parent, match, aux)
     43  1.1   mycroft 	struct device *parent;
     44  1.1   mycroft 	struct cfdata *match;
     45  1.1   mycroft 	void *aux;
     46  1.1   mycroft {
     47  1.3   mycroft 	int pri, variant;
     48  1.2   mycroft 
     49  1.3   mycroft 	pri = isapnp_devmatch(aux, &isapnp_mpu_devinfo, &variant);
     50  1.3   mycroft 	if (pri && variant > 0)
     51  1.3   mycroft 		pri = 0;
     52  1.3   mycroft 	return (pri);
     53  1.1   mycroft }
     54  1.1   mycroft 
     55  1.1   mycroft void
     56  1.1   mycroft mpu_isapnp_attach(parent, self, aux)
     57  1.1   mycroft 	struct device *parent, *self;
     58  1.1   mycroft 	void *aux;
     59  1.1   mycroft {
     60  1.1   mycroft 	struct mpu_isapnp_softc *sc = (struct mpu_isapnp_softc *)self;
     61  1.1   mycroft 	struct isapnp_attach_args *ipa = aux;
     62  1.1   mycroft 
     63  1.1   mycroft 	printf("\n");
     64  1.1   mycroft 
     65  1.1   mycroft 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
     66  1.1   mycroft 		printf("%s: error in region allocation\n",
     67  1.1   mycroft 		       sc->sc_dev.dv_xname);
     68  1.1   mycroft 		return;
     69  1.1   mycroft 	}
     70  1.1   mycroft 
     71  1.1   mycroft 	sc->sc_mpu.iot = ipa->ipa_iot;
     72  1.1   mycroft 	sc->sc_mpu.ioh = ipa->ipa_io[0].h;
     73  1.1   mycroft 
     74  1.1   mycroft 	if (!mpu_find(&sc->sc_mpu)) {
     75  1.1   mycroft 		printf("%s: find failed\n", sc->sc_dev.dv_xname);
     76  1.1   mycroft 		return;
     77  1.1   mycroft 	}
     78  1.1   mycroft 
     79  1.1   mycroft 	printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
     80  1.1   mycroft 	       ipa->ipa_devclass);
     81  1.1   mycroft 
     82  1.1   mycroft 	midi_attach_mi(&mpu_midi_hw_if, &sc->sc_mpu, &sc->sc_dev);
     83  1.1   mycroft 
     84  1.1   mycroft 	sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
     85  1.1   mycroft 	    ipa->ipa_irq[0].type, IPL_AUDIO, mpu_intr, &sc->sc_mpu);
     86  1.1   mycroft }
     87