diff options
| author | mycroft <mycroft@NetBSD.org> | 1999-03-22 07:37:35 +0000 |
|---|---|---|
| committer | mycroft <mycroft@NetBSD.org> | 1999-03-22 07:37:35 +0000 |
| commit | 97de30ff263eec034e02eefc2853c1a07440e869 (patch) | |
| tree | 1c977ef9839012a05856ef87fcf00dbdc5700b7d /sys/dev | |
| parent | bed9aad370dafd4454e7455ca215cd28f04994fa (diff) | |
Several things:
* Rearrange the speed mapping table and adjust the code so that the highest
rate can actually be used. Previously we ended up rounding up slightly
lower speeds and then losing because set_params couldn't set the mode
back to the current one.
* Allow 260 as a valid I/O address, since the SB1 can be jumpered to this.
* Change the MPU-401 code so it can be attached as a separate device.
(XXX Really, the SB code ought to just attach a subdevice itself.)
* Do not attach an OPL on the SB1. Writing to the OPL registers at
SB_base+0 on this card wedges my machine.
(XXX Should we access it at 388 instead? The Creative web site claims
that this board *does* have an OPL2, but I haven't played with this
extensively.)
* Allocate the SB DMA channels at open time, rather than attach time, so
that a single DRQ can be used for multiple cards (if only one is in use
at a given time).
(XXX Let me tell you why this is a horrible hack. If the ISA DMA code
tries to allocate a bounce buffer after boot time, it will generally fail,
because there is no contiguous memory below 16MB and the code to allocate
contiguous pages doesn't know how to move things around. Now, we
shouldn't ever be using bounce buffers here, because we use
isa_dmamem_alloc(). So we just turn off BUS_DMA_ALLOCNOW and we don't
actually try to. That's cool, and it even works, but isa_dmamem_alloc()
has the same problem. It just happens that we allocate the ring buffers
at boot time, and whenever we reallocate them (due to the buffer size
changing), we just deallocated the previous (contiguous) buffer, so we get
lucky. This is absolutely disgusting and needs to be fixed.)
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/isa/files.isa | 8 | ||||
| -rw-r--r-- | sys/dev/isa/mpu.c (renamed from sys/dev/isa/mpu401.c) | 111 | ||||
| -rw-r--r-- | sys/dev/isa/mpuvar.h (renamed from sys/dev/isa/mpu401var.h) | 20 | ||||
| -rw-r--r-- | sys/dev/isa/sb.c | 87 | ||||
| -rw-r--r-- | sys/dev/isa/sb_isa.c | 6 | ||||
| -rw-r--r-- | sys/dev/isa/sbdsp.c | 85 | ||||
| -rw-r--r-- | sys/dev/isa/sbdspvar.h | 6 | ||||
| -rw-r--r-- | sys/dev/isa/sbreg.h | 4 |
8 files changed, 153 insertions, 174 deletions
diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index 5ba6da9391d..e06b4b7855c 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $NetBSD: files.isa,v 1.81 1998/12/16 11:33:50 christos Exp $ +# $NetBSD: files.isa,v 1.82 1999/03/22 07:37:35 mycroft Exp $ # # Config file and device description for machine-independent ISA code. # Included by ports that need it. Requires that the SCSI files be @@ -248,15 +248,15 @@ file dev/isa/if_ix.c ix # # MPU401 MIDI UART compatibles -define mpu401 -file dev/isa/mpu401.c mpu401 & midi +device mpu: midibus +file dev/isa/mpu.c (mpu | sb) needs-flag # the SoundBlaster DSP, or close likenesses; used by other drivers define sbdsp { } file dev/isa/sbdsp.c sbdsp # SoundBlaster family -device sb: audio, isadma, sbdsp, mulaw, auconv, mpu401, midibus +device sb: audio, isadma, sbdsp, mulaw, auconv, midibus file dev/isa/sb.c sb needs-flag attach sb at isa with sb_isa diff --git a/sys/dev/isa/mpu401.c b/sys/dev/isa/mpu.c index 982c93cd2dd..befa507ae2f 100644 --- a/sys/dev/isa/mpu401.c +++ b/sys/dev/isa/mpu.c @@ -1,4 +1,6 @@ -/* $NetBSD: mpu401.c,v 1.3 1998/11/25 22:17:06 augustss Exp $ */ +/* $NetBSD: mpu.c,v 1.1 1999/03/22 07:37:35 mycroft Exp $ */ + +#define AUDIO_DEBUG /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -55,12 +57,12 @@ #include <dev/isa/isavar.h> #include <dev/isa/isadmavar.h> -#include <dev/isa/mpu401var.h> +#include <dev/isa/mpuvar.h> #ifdef AUDIO_DEBUG -#define DPRINTF(x) if (mpu401debug) printf x -#define DPRINTFN(n,x) if (mpu401debug >= (n)) printf x -int mpu401debug = 0; +#define DPRINTF(x) if (mpudebug) printf x +#define DPRINTFN(n,x) if (mpudebug >= (n)) printf x +int mpudebug = 100; #else #define DPRINTF(x) #define DPRINTFN(n,x) @@ -80,29 +82,37 @@ int mpu401debug = 0; #define MPU_GETSTATUS(iot, ioh) (bus_space_read_1(iot, ioh, MPU_STATUS)) -int mpu401_reset(struct mpu401_softc *); -static __inline int mpu401_waitready(struct mpu401_softc *); -void mpu401_readinput(struct mpu401_softc *); +int mpu_reset(struct mpu_softc *); +static __inline int mpu_waitready(struct mpu_softc *); +void mpu_readinput(struct mpu_softc *); + +struct midi_hw_if mpu_midi_hw_if = { + mpu_open, + mpu_close, + mpu_output, + mpu_getinfo, + 0, /* ioctl */ +}; int -mpu401_find(sc) - struct mpu401_softc *sc; +mpu_find(sc) + struct mpu_softc *sc; { if (MPU_GETSTATUS(sc->iot, sc->ioh) == 0xff) { - DPRINTF(("mpu401_find: No status\n")); + DPRINTF(("mpu_find: No status\n")); goto bad; } sc->open = 0; sc->intr = 0; - if (mpu401_reset(sc) == 0) + if (mpu_reset(sc) == 0) return 1; bad: return 0; } static __inline int -mpu401_waitready(sc) - struct mpu401_softc *sc; +mpu_waitready(sc) + struct mpu_softc *sc; { int i; @@ -115,16 +125,16 @@ mpu401_waitready(sc) } int -mpu401_reset(sc) - struct mpu401_softc *sc; +mpu_reset(sc) + struct mpu_softc *sc; { bus_space_tag_t iot = sc->iot; bus_space_handle_t ioh = sc->ioh; int i; int s; - if (mpu401_waitready(sc)) { - DPRINTF(("mpu401_reset: not ready\n")); + if (mpu_waitready(sc)) { + DPRINTF(("mpu_reset: not ready\n")); return EIO; } s = splaudio(); /* Don't let the interrupt get our ACK. */ @@ -137,23 +147,25 @@ mpu401_reset(sc) } } splx(s); - DPRINTF(("mpu401_reset: No ACK\n")); + DPRINTF(("mpu_reset: No ACK\n")); return EIO; } int -mpu401_open(sc, flags, iintr, ointr, arg) - struct mpu401_softc *sc; +mpu_open(addr, flags, iintr, ointr, arg) + void *addr; int flags; void (*iintr)__P((void *, int)); void (*ointr)__P((void *)); void *arg; { - DPRINTF(("mpu401_open: sc=%p\n", sc)); + struct mpu_softc *sc = addr; + + DPRINTF(("mpu_open: sc=%p\n", sc)); if (sc->open) return EBUSY; - if (mpu401_reset(sc) != 0) + if (mpu_reset(sc) != 0) return EIO; bus_space_write_1(sc->iot, sc->ioh, MPU_COMMAND, MPU_UART_MODE); @@ -164,19 +176,21 @@ mpu401_open(sc, flags, iintr, ointr, arg) } void -mpu401_close(sc) - struct mpu401_softc *sc; +mpu_close(addr) + void *addr; { - DPRINTF(("mpu401_close: sc=%p\n", sc)); + struct mpu_softc *sc = addr; + + DPRINTF(("mpu_close: sc=%p\n", sc)); sc->open = 0; sc->intr = 0; - mpu401_reset(sc); /* exit UART mode */ + mpu_reset(sc); /* exit UART mode */ } void -mpu401_readinput(sc) - struct mpu401_softc *sc; +mpu_readinput(sc) + struct mpu_softc *sc; { bus_space_tag_t iot = sc->iot; bus_space_handle_t ioh = sc->ioh; @@ -184,27 +198,28 @@ mpu401_readinput(sc) while(!(MPU_GETSTATUS(iot, ioh) & MPU_INPUT_EMPTY)) { data = bus_space_read_1(iot, ioh, MPU_DATA); - DPRINTFN(3, ("mpu401_rea: sc=%p 0x%02x\n", sc, data)); + DPRINTFN(3, ("mpu_rea: sc=%p 0x%02x\n", sc, data)); if (sc->intr) sc->intr(sc->arg, data); } } int -mpu401_output(sc, d) - struct mpu401_softc *sc; +mpu_output(addr, d) + void *addr; int d; { + struct mpu_softc *sc = addr; int s; - DPRINTFN(3, ("mpu401_output: sc=%p 0x%02x\n", sc, d)); + DPRINTFN(3, ("mpu_output: sc=%p 0x%02x\n", sc, d)); if (!(MPU_GETSTATUS(sc->iot, sc->ioh) & MPU_INPUT_EMPTY)) { s = splaudio(); - mpu401_readinput(sc); + mpu_readinput(sc); splx(s); } - if (mpu401_waitready(sc)) { - DPRINTF(("mpu401_output: not ready\n")); + if (mpu_waitready(sc)) { + DPRINTF(("mpu_output: not ready\n")); return EIO; } bus_space_write_1(sc->iot, sc->ioh, MPU_DATA, d); @@ -212,12 +227,26 @@ mpu401_output(sc, d) } void -mpu401_intr(sc) - struct mpu401_softc *sc; +mpu_getinfo(addr, mi) + void *addr; + struct midi_info *mi; +{ + + mi->name = "MPU-401 MIDI UART"; + mi->props = 0; +} + +int +mpu_intr(addr) + void *addr; { + struct mpu_softc *sc = addr; + if (MPU_GETSTATUS(sc->iot, sc->ioh) & MPU_INPUT_EMPTY) { - DPRINTF(("mpu401_intr: no data\n")); - return; + DPRINTF(("mpu_intr: no data\n")); + return (0); + } else { + mpu_readinput(sc); + return (1); } - mpu401_readinput(sc); } diff --git a/sys/dev/isa/mpu401var.h b/sys/dev/isa/mpuvar.h index c8b05cd3c8d..fd59eb968d6 100644 --- a/sys/dev/isa/mpu401var.h +++ b/sys/dev/isa/mpuvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: mpu401var.h,v 1.3 1998/11/25 22:17:06 augustss Exp $ */ +/* $NetBSD: mpuvar.h,v 1.1 1999/03/22 07:37:35 mycroft Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -36,21 +36,21 @@ * POSSIBILITY OF SUCH DAMAGE. */ -struct mpu401_softc { +struct mpu_softc { bus_space_tag_t iot; /* tag */ bus_space_handle_t ioh; /* handle */ - int iobase; int open; - void (*intr)__P((void*, int)); /* midi input intr handler */ + void (*intr)__P((void *, int)); /* midi input intr handler */ void *arg; /* arg for intr() */ }; -struct midi_hw_if mpu401_midi_hw_if; +struct midi_hw_if mpu_midi_hw_if; -void mpu401_intr __P((struct mpu401_softc *)); -int mpu401_find __P((struct mpu401_softc *)); -int mpu401_open __P((struct mpu401_softc *, int, +int mpu_find __P((struct mpu_softc *)); +int mpu_open __P((void *, int, void (*iintr)__P((void *, int)), void (*ointr)__P((void *)), void *arg)); -void mpu401_close __P((struct mpu401_softc *)); -int mpu401_output __P((struct mpu401_softc *, int)); +void mpu_close __P((void *)); +int mpu_output __P((void *, int)); +void mpu_getinfo __P((void *, struct midi_info *)); +int mpu_intr __P((void *)); diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c index 6735941f636..f30825ee67b 100644 --- a/sys/dev/isa/sb.c +++ b/sys/dev/isa/sb.c @@ -1,4 +1,4 @@ -/* $NetBSD: sb.c,v 1.66 1999/02/19 16:10:44 mycroft Exp $ */ +/* $NetBSD: sb.c,v 1.67 1999/03/22 07:37:35 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -62,13 +62,6 @@ #include <dev/isa/sbdspvar.h> #if NMIDI > 0 -int sb_mpu401_open __P((void *, int, - void (*iintr)__P((void *, int)), - void (*ointr)__P((void *)), void *arg)); -void sb_mpu401_close __P((void *)); -int sb_mpu401_output __P((void *, int)); -void sb_mpu401_getinfo __P((void *, struct midi_info *)); - struct midi_hw_if sb_midi_hw_if = { sbdsp_midi_open, sbdsp_midi_close, @@ -76,14 +69,6 @@ struct midi_hw_if sb_midi_hw_if = { sbdsp_midi_getinfo, 0, /* ioctl */ }; - -struct midi_hw_if sb_mpu401_hw_if = { - sb_mpu401_open, - sb_mpu401_close, - sb_mpu401_output, - sb_mpu401_getinfo, - 0, /* ioctl */ -}; #endif struct audio_device sb_device = { @@ -247,30 +232,29 @@ sbattach(sc) struct sbdsp_softc *sc; { struct audio_attach_args arg; -#if NMIDI > 0 - struct midi_hw_if *mhw = &sb_midi_hw_if; -#endif sbdsp_attach(sc); #if NMIDI > 0 - sc->sc_hasmpu = 0; - if (ISSB16CLASS(sc) && sc->sc_mpu_sc.iobase != 0) { - sc->sc_mpu_sc.iot = sc->sc_iot; - if (mpu401_find(&sc->sc_mpu_sc)) { - sc->sc_hasmpu = 1; - mhw = &sb_mpu401_hw_if; - } + if (ISSB16CLASS(sc)) { + if (sc->sc_hasmpu && mpu_find(&sc->sc_mpu)) + midi_attach_mi(&mpu_midi_hw_if, &sc->sc_mpu, &sc->sc_dev); + else + sc->sc_hasmpu = 0; + } else { + sc->sc_hasmpu = 0; + midi_attach_mi(&sb_midi_hw_if, sc, &sc->sc_dev); } - midi_attach_mi(mhw, sc, &sc->sc_dev); #endif audio_attach_mi(&sb_hw_if, sc, &sc->sc_dev); - arg.type = AUDIODEV_TYPE_OPL; - arg.hwif = 0; - arg.hdl = 0; - (void)config_found(&sc->sc_dev, &arg, audioprint); + if (sc->sc_model >= SB_20) { + arg.type = AUDIODEV_TYPE_OPL; + arg.hwif = 0; + arg.hdl = 0; + (void)config_found(&sc->sc_dev, &arg, audioprint); + } } /* @@ -301,44 +285,3 @@ sb_getdev(addr, retp) return 0; } - -#if NMIDI > 0 - -#define SBMPU(a) (&((struct sbdsp_softc *)addr)->sc_mpu_sc) - -int -sb_mpu401_open(addr, flags, iintr, ointr, arg) - void *addr; - int flags; - void (*iintr)__P((void *, int)); - void (*ointr)__P((void *)); - void *arg; -{ - return mpu401_open(SBMPU(addr), flags, iintr, ointr, arg); -} - -int -sb_mpu401_output(addr, d) - void *addr; - int d; -{ - return mpu401_output(SBMPU(addr), d); -} - -void -sb_mpu401_close(addr) - void *addr; -{ - mpu401_close(SBMPU(addr)); -} - -void -sb_mpu401_getinfo(addr, mi) - void *addr; - struct midi_info *mi; -{ - mi->name = "SB MPU-401 UART"; - mi->props = 0; -} -#endif - diff --git a/sys/dev/isa/sb_isa.c b/sys/dev/isa/sb_isa.c index 2c35a777636..52a2c610e88 100644 --- a/sys/dev/isa/sb_isa.c +++ b/sys/dev/isa/sb_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: sb_isa.c,v 1.20 1999/02/19 16:10:44 mycroft Exp $ */ +/* $NetBSD: sb_isa.c,v 1.21 1999/03/22 07:37:35 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -121,10 +121,6 @@ sbfind(parent, sc, ia) if (!sbmatch(sc)) goto bad; - if ((sc->sc_drq8 != -1 && !isa_drq_isfree(sc->sc_ic, sc->sc_drq8)) || - (sc->sc_drq16 != -1 && !isa_drq_isfree(sc->sc_ic, sc->sc_drq16))) - goto bad; - if (ISSBPROCLASS(sc)) ia->ia_iosize = SBP_NPORT; else diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index d2332810761..65639a31779 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbdsp.c,v 1.96 1999/02/22 02:16:40 mycroft Exp $ */ +/* $NetBSD: sbdsp.c,v 1.97 1999/03/22 07:37:35 mycroft Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -171,17 +171,17 @@ struct sbmode { static struct sbmode sbpmodes[] = { { SB_1, 1, 8, 4000,22727,SB_DSP_WDMA ,SB_DSP_HALT ,SB_DSP_CONT }, { SB_20, 1, 8, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT }, - { SB_2x, 1, 8, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT }, { SB_2x, 1, 8,22727,45454,SB_DSP_HS_OUTPUT,SB_DSP_HALT ,SB_DSP_CONT }, - { SB_PRO, 1, 8, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT }, + { SB_2x, 1, 8, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT }, { SB_PRO, 1, 8,22727,45454,SB_DSP_HS_OUTPUT,SB_DSP_HALT ,SB_DSP_CONT }, + { SB_PRO, 1, 8, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT }, { SB_PRO, 2, 8,11025,22727,SB_DSP_HS_OUTPUT,SB_DSP_HALT ,SB_DSP_CONT }, /* Yes, we write the record mode to set 16-bit playback mode. weird, huh? */ - { SB_JAZZ,1, 8, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, { SB_JAZZ,1, 8,22727,45454,SB_DSP_HS_OUTPUT,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, + { SB_JAZZ,1, 8, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, { SB_JAZZ,2, 8,11025,22727,SB_DSP_HS_OUTPUT,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_STEREO }, - { SB_JAZZ,1,16, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,JAZZ16_RECORD_MONO }, { SB_JAZZ,1,16,22727,45454,SB_DSP_HS_OUTPUT,SB_DSP_HALT ,SB_DSP_CONT ,JAZZ16_RECORD_MONO }, + { SB_JAZZ,1,16, 4000,22727,SB_DSP_WDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,JAZZ16_RECORD_MONO }, { SB_JAZZ,2,16,11025,22727,SB_DSP_HS_OUTPUT,SB_DSP_HALT ,SB_DSP_CONT ,JAZZ16_RECORD_STEREO }, { SB_16, 1, 8, 5000,45000,SB_DSP16_WDMA_8 ,SB_DSP_HALT ,SB_DSP_CONT }, { SB_16, 2, 8, 5000,45000,SB_DSP16_WDMA_8 ,SB_DSP_HALT ,SB_DSP_CONT }, @@ -193,16 +193,16 @@ static struct sbmode sbpmodes[] = { static struct sbmode sbrmodes[] = { { SB_1, 1, 8, 4000,12987,SB_DSP_RDMA ,SB_DSP_HALT ,SB_DSP_CONT }, { SB_20, 1, 8, 4000,12987,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT }, - { SB_2x, 1, 8, 4000,12987,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT }, { SB_2x, 1, 8,12987,14925,SB_DSP_HS_INPUT ,SB_DSP_HALT ,SB_DSP_CONT }, - { SB_PRO, 1, 8, 4000,22727,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, + { SB_2x, 1, 8, 4000,12987,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT }, { SB_PRO, 1, 8,22727,45454,SB_DSP_HS_INPUT ,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, + { SB_PRO, 1, 8, 4000,22727,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, { SB_PRO, 2, 8,11025,22727,SB_DSP_HS_INPUT ,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_STEREO }, - { SB_JAZZ,1, 8, 4000,22727,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, { SB_JAZZ,1, 8,22727,45454,SB_DSP_HS_INPUT ,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, + { SB_JAZZ,1, 8, 4000,22727,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_MONO }, { SB_JAZZ,2, 8,11025,22727,SB_DSP_HS_INPUT ,SB_DSP_HALT ,SB_DSP_CONT ,SB_DSP_RECORD_STEREO }, - { SB_JAZZ,1,16, 4000,22727,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,JAZZ16_RECORD_MONO }, { SB_JAZZ,1,16,22727,45454,SB_DSP_HS_INPUT ,SB_DSP_HALT ,SB_DSP_CONT ,JAZZ16_RECORD_MONO }, + { SB_JAZZ,1,16, 4000,22727,SB_DSP_RDMA_LOOP,SB_DSP_HALT ,SB_DSP_CONT ,JAZZ16_RECORD_MONO }, { SB_JAZZ,2,16,11025,22727,SB_DSP_HS_INPUT ,SB_DSP_HALT ,SB_DSP_CONT ,JAZZ16_RECORD_STEREO }, { SB_16, 1, 8, 5000,45000,SB_DSP16_RDMA_8 ,SB_DSP_HALT ,SB_DSP_CONT }, { SB_16, 2, 8, 5000,45000,SB_DSP16_RDMA_8 ,SB_DSP_HALT ,SB_DSP_CONT }, @@ -367,26 +367,6 @@ sbdsp_attach(sc) int i; u_int v; - /* - * Create our DMA maps. - */ - if (sc->sc_drq8 != -1) { - if (isa_dmamap_create(sc->sc_ic, sc->sc_drq8, - MAX_ISADMA, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) { - printf("%s: can't create map for drq %d\n", - sc->sc_dev.dv_xname, sc->sc_drq8); - return; - } - } - if (sc->sc_drq16 != -1 && sc->sc_drq16 != sc->sc_drq8) { - if (isa_dmamap_create(sc->sc_ic, sc->sc_drq16, - MAX_ISADMA, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) { - printf("%s: can't create map for drq %d\n", - sc->sc_dev.dv_xname, sc->sc_drq16); - return; - } - } - pparams = audio_default; rparams = audio_default; sbdsp_set_params(sc, AUMODE_RECORD|AUMODE_PLAY, 0, &pparams, &rparams); @@ -603,7 +583,7 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) p->channels == m->channels && p->precision == m->precision && p->sample_rate >= m->lowrate && - p->sample_rate < m->highrate) + p->sample_rate <= m->highrate) break; } if (m->model == -1) @@ -887,17 +867,39 @@ sbdsp_open(addr, flags) int flags; { struct sbdsp_softc *sc = addr; + int error; DPRINTF(("sbdsp_open: sc=%p\n", sc)); if (sc->sc_open != SB_CLOSED) - return EBUSY; - if (sbdsp_reset(sc) != 0) - return EIO; - + return (EBUSY); sc->sc_open = SB_OPEN_AUDIO; sc->sc_openflags = flags; + if (sc->sc_drq8 != -1) { + error = isa_dmamap_create(sc->sc_ic, sc->sc_drq8, + MAX_ISADMA, BUS_DMA_NOWAIT); + if (error) { + printf("%s: can't create map for drq %d\n", + sc->sc_dev.dv_xname, sc->sc_drq8); + goto bad; + } + } + if (sc->sc_drq16 != -1 && sc->sc_drq16 != sc->sc_drq8) { + error = isa_dmamap_create(sc->sc_ic, sc->sc_drq16, + MAX_ISADMA, BUS_DMA_NOWAIT); + if (error) { + printf("%s: can't create map for drq %d\n", + sc->sc_dev.dv_xname, sc->sc_drq16); + goto bad; + } + } + + if (sbdsp_reset(sc) != 0) { + error = EIO; + goto bad; + } + if (ISSBPRO(sc) && sbdsp_wdsp(sc, SB_DSP_RECORD_MONO) < 0) { DPRINTF(("sbdsp_open: can't set mono mode\n")); @@ -912,7 +914,11 @@ sbdsp_open(addr, flags) */ DPRINTF(("sbdsp_open: opened\n")); - return 0; + return (0); + +bad: + sc->sc_open = SB_CLOSED; + return (error); } void @@ -931,8 +937,13 @@ sbdsp_close(addr) sc->sc_intr8 = 0; sc->sc_intr16 = 0; - sc->sc_open = SB_CLOSED; + if (sc->sc_drq8 != -1) + isa_dmamap_destroy(sc->sc_ic, sc->sc_drq8); + if (sc->sc_drq16 != -1 && sc->sc_drq16 != sc->sc_drq8) + isa_dmamap_destroy(sc->sc_ic, sc->sc_drq16); + + sc->sc_open = SB_CLOSED; DPRINTF(("sbdsp_close: closed\n")); } @@ -1518,7 +1529,7 @@ sbdsp_intr(arg) } #if NMIDI > 0 if ((irq & SBP_IRQ_MPU401) && sc->sc_hasmpu) { - mpu401_intr(&sc->sc_mpu_sc); + mpu_intr(&sc->sc_mpu); } #endif return 1; diff --git a/sys/dev/isa/sbdspvar.h b/sys/dev/isa/sbdspvar.h index 8599ce44360..4132f6c0c56 100644 --- a/sys/dev/isa/sbdspvar.h +++ b/sys/dev/isa/sbdspvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: sbdspvar.h,v 1.41 1999/02/19 16:10:44 mycroft Exp $ */ +/* $NetBSD: sbdspvar.h,v 1.42 1999/03/22 07:37:36 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -36,7 +36,7 @@ #include "midi.h" #if NMIDI > 0 -#include <dev/isa/mpu401var.h> +#include <dev/isa/mpuvar.h> #endif #define SB_MASTER_VOL 0 @@ -174,7 +174,7 @@ struct sbdsp_softc { #if NMIDI > 0 int sc_hasmpu; - struct mpu401_softc sc_mpu_sc; /* MPU401 Uart state */ + struct mpu_softc sc_mpu; /* MPU401 Uart state */ #endif }; diff --git a/sys/dev/isa/sbreg.h b/sys/dev/isa/sbreg.h index a250e70fba6..4f3fc274f2b 100644 --- a/sys/dev/isa/sbreg.h +++ b/sys/dev/isa/sbreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: sbreg.h,v 1.27 1999/02/18 07:08:36 mycroft Exp $ */ +/* $NetBSD: sbreg.h,v 1.28 1999/03/22 07:37:36 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -288,7 +288,7 @@ #define SBP_DRQ_VALID(chan) ((chan) == 0 || (chan) == 1 || (chan) == 3) #define SB_DRQ_VALID(chan) ((chan) == 1) -#define SB_BASE_VALID(base) ((base) == 0x220 || (base) == 0x240) +#define SB_BASE_VALID(base) ((base) == 0x220 || (base) == 0x240 || (base) == 0x260) #define SB_INPUT_RATE 0 #define SB_OUTPUT_RATE 1 |
