NetBSD/sys/dev/isapnp/mpu_isapnp.c

90 lines
2.0 KiB
C
Raw Normal View History

/* $NetBSD: mpu_isapnp.c,v 1.16 2007/10/19 12:00:33 ad Exp $ */
2001-11-13 10:56:39 +03:00
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mpu_isapnp.c,v 1.16 2007/10/19 12:00:33 ad Exp $");
2001-11-13 10:56:39 +03:00
1999-03-22 10:39:33 +03:00
#include "midi.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/bus.h>
1999-03-22 10:39:33 +03:00
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/midi_if.h>
#include <dev/mulaw.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
#include <dev/isapnp/isapnpreg.h>
#include <dev/isapnp/isapnpvar.h>
#include <dev/isapnp/isapnpdevs.h>
#include <dev/ic/mpuvar.h>
1999-03-22 10:39:33 +03:00
2005-02-04 05:10:35 +03:00
int mpu_isapnp_match(struct device *, struct cfdata *, void *);
void mpu_isapnp_attach(struct device *, struct device *, void *);
1999-03-22 10:39:33 +03:00
struct mpu_isapnp_softc {
struct device sc_dev;
void *sc_ih;
struct mpu_softc sc_mpu;
};
2002-10-01 01:31:52 +04:00
CFATTACH_DECL(mpu_isapnp, sizeof(struct mpu_isapnp_softc),
2002-10-02 20:33:28 +04:00
mpu_isapnp_match, mpu_isapnp_attach, NULL, NULL);
1999-03-22 10:39:33 +03:00
int
mpu_isapnp_match(struct device *parent, struct cfdata *match,
void *aux)
1999-03-22 10:39:33 +03:00
{
int pri, variant;
1999-03-22 12:44:12 +03:00
pri = isapnp_devmatch(aux, &isapnp_mpu_devinfo, &variant);
if (pri && variant > 0)
pri = 0;
return (pri);
1999-03-22 10:39:33 +03:00
}
void
mpu_isapnp_attach(struct device *parent, struct device *self,
void *aux)
1999-03-22 10:39:33 +03:00
{
2006-03-29 10:51:47 +04:00
struct mpu_isapnp_softc *sc = device_private(self);
1999-03-22 10:39:33 +03:00
struct isapnp_attach_args *ipa = aux;
printf("\n");
if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
2005-02-27 03:26:58 +03:00
printf("%s: error in region allocation\n",
1999-03-22 10:39:33 +03:00
sc->sc_dev.dv_xname);
return;
}
sc->sc_mpu.iot = ipa->ipa_iot;
sc->sc_mpu.ioh = ipa->ipa_io[0].h;
if (!mpu_find(&sc->sc_mpu)) {
printf("%s: find failed\n", sc->sc_dev.dv_xname);
return;
}
printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
ipa->ipa_devclass);
sc->sc_mpu.model = "Roland MPU-401 MIDI UART";
1999-03-22 10:39:33 +03:00
midi_attach_mi(&mpu_midi_hw_if, &sc->sc_mpu, &sc->sc_dev);
sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
ipa->ipa_irq[0].type, IPL_AUDIO, mpu_intr, &sc->sc_mpu);
}