diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/isa/sbdsp.c | 85 | ||||
-rw-r--r-- | sys/dev/isa/sbdspvar.h | 13 |
2 files changed, 51 insertions, 47 deletions
diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index 7c86fdb0b6b..01ad1c2a3ef 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdsp.c,v 1.14 1999/07/20 16:36:05 deraadt Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.15 2001/02/03 05:22:24 mickey Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -103,7 +103,7 @@ struct { * tc = 65536 - 256 * 10^ 6 / sr * Since we can only use the upper byte of the HS TC, the two formulae * are equivalent. (Why didn't they say so?) E.g., - * (65536 - 256 * 10 ^ 6 / x) >> 8 = 256 - 10^6 / x + * (65536 - 256 * 10 ^ 6 / x) >> 8 = 256 - 10^6 / x * * The crossover point (from low- to high-speed modes) is different * for the SBPRO and SB20. The table on p. 12-5 gives the following data: @@ -199,9 +199,9 @@ sb_printsc(sc) struct sbdsp_softc *sc; { int i; - + printf("open %d dmachan %d/%d %d/%d iobase 0x%x irq %d\n", - (int)sc->sc_open, sc->sc_i.run, sc->sc_o.run, + (int)sc->sc_open, sc->sc_i.run, sc->sc_o.run, sc->sc_drq8, sc->sc_drq16, sc->sc_iobase, sc->sc_irq); printf("irate %d itc %x orate %d otc %x\n", @@ -359,7 +359,7 @@ sbdsp_attach(sc) sbdsp_set_in_ports(sc, 1 << SB_MIC_VOL); if (sc->sc_mixer_model != SBM_NONE) { - /* Reset the mixer.*/ + /* Reset the mixer.*/ sbdsp_mix_write(sc, SBP_MIX_RESET, SBP_MIX_RESET); /* And set our own default values */ for (i = 0; i < SB_NDEVS; i++) { @@ -399,7 +399,8 @@ sbdsp_attach(sc) SBVER_MAJOR(sc->sc_version), SBVER_MINOR(sc->sc_version), sc->sc_model == SB_JAZZ ? ": <Jazz16>" : ""); - sc->sc_fullduplex = ISSB16CLASS(sc) && + timeout_set(&sc->sc_tmo, sbdsp_to, sbdsp_to); + sc->sc_fullduplex = ISSB16CLASS(sc) && sc->sc_drq8 != -1 && sc->sc_drq16 != -1 && sc->sc_drq8 != sc->sc_drq16; } @@ -535,7 +536,7 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) return EBUSY; model = sc->sc_model; - if (model > SB_16) + if (model > SB_16) model = SB_16; /* later models work like SB16 */ /* @@ -556,19 +557,19 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) } /* Set first record info, then play info */ - for (mode = AUMODE_RECORD; mode != -1; + for (mode = AUMODE_RECORD; mode != -1; mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) { if ((setmode & mode) == 0) continue; p = mode == AUMODE_PLAY ? play : rec; /* Locate proper commands */ - for(m = mode == AUMODE_PLAY ? sbpmodes : sbrmodes; + for(m = mode == AUMODE_PLAY ? sbpmodes : sbrmodes; m->model != -1; m++) { if (model == m->model && p->channels == m->channels && p->precision == m->precision && - p->sample_rate >= m->lowrate && + p->sample_rate >= m->lowrate && p->sample_rate < m->highrate) break; } @@ -633,11 +634,11 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) swap_bytes_change_sign16 : change_sign16_swap_bytes; break; case AUDIO_ENCODING_ULAW: - swcode = mode == AUMODE_PLAY ? + swcode = mode == AUMODE_PLAY ? mulaw_to_ulinear8 : ulinear8_to_mulaw; break; case AUDIO_ENCODING_ALAW: - swcode = mode == AUMODE_PLAY ? + swcode = mode == AUMODE_PLAY ? alaw_to_ulinear8 : ulinear8_to_alaw; break; default: @@ -655,11 +656,11 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) case AUDIO_ENCODING_ULINEAR_LE: break; case AUDIO_ENCODING_ULAW: - swcode = mode == AUMODE_PLAY ? + swcode = mode == AUMODE_PLAY ? mulaw_to_ulinear8 : ulinear8_to_mulaw; break; case AUDIO_ENCODING_ALAW: - swcode = mode == AUMODE_PLAY ? + swcode = mode == AUMODE_PLAY ? alaw_to_ulinear8 : ulinear8_to_alaw; break; default: @@ -686,7 +687,7 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) p->sw_code = swcode; p->factor = factor; - DPRINTF(("sbdsp_set_params: model=%d, mode=%d, rate=%ld, prec=%d, chan=%d, enc=%d -> tc=%02x, cmd=%02x, bmode=%02x, cmdchan=%02x, swcode=%p, factor=%d\n", + DPRINTF(("sbdsp_set_params: model=%d, mode=%d, rate=%ld, prec=%d, chan=%d, enc=%d -> tc=%02x, cmd=%02x, bmode=%02x, cmdchan=%02x, swcode=%p, factor=%d\n", sc->sc_model, mode, p->sample_rate, p->precision, p->channels, p->encoding, tc, m->cmd, bmode, m->cmdchan, swcode, factor)); @@ -713,7 +714,7 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) return EINVAL; } } - DPRINTF(("sbdsp_set_params ichan=%d, ochan=%d\n", + DPRINTF(("sbdsp_set_params ichan=%d, ochan=%d\n", sc->sc_i.dmachan, sc->sc_o.dmachan)); return 0; @@ -736,7 +737,7 @@ sbdsp_set_ifilter(addr, which) mixval |= SBP_FILTER_ON | SBP_IFILTER_HIGH; break; case SB_BASS: - mixval |= SBP_FILTER_ON | SBP_IFILTER_LOW; + mixval |= SBP_FILTER_ON | SBP_IFILTER_LOW; break; default: return; @@ -750,7 +751,7 @@ sbdsp_get_ifilter(addr) void *addr; { struct sbdsp_softc *sc = addr; - + sc->in_filter = sbdsp_mix_read(sc, SBP_INFILTER) & SBP_IFILTER_MASK; switch (sc->in_filter) { @@ -1018,7 +1019,7 @@ sbdsp_pause(sc) { extern int hz; - timeout(sbdsp_to, sbdsp_to, hz/8); + timeout_add(&sc->sc_tmo, hz/8); (void)tsleep(sbdsp_to, PWAIT, "sbpause", 0); } @@ -1144,7 +1145,7 @@ sbdsp_set_timeconst(sc, tc) if (sbdsp_wdsp(sc, SB_DSP_TIMECONST) < 0 || sbdsp_wdsp(sc, tc) < 0) return EIO; - + return 0; } @@ -1221,7 +1222,7 @@ sbdsp_trigger_input(addr, start, end, blksize, intr, arg, param) (sbdsp_mix_read(sc, SBP_INFILTER) & ~SBP_IFILTER_MASK) | filter); } - + if (ISSB16CLASS(sc)) { if (sbdsp16_set_rate(sc, SB_DSP16_INPUTRATE, sc->sc_i.rate)) { DPRINTF(("sbdsp_trigger_input: rate=%d set failed\n", @@ -1236,7 +1237,7 @@ sbdsp_trigger_input(addr, start, end, blksize, intr, arg, param) } } - DPRINTF(("sbdsp: dma start loop input start=%p end=%p chan=%d\n", + DPRINTF(("sbdsp: dma start loop input start=%p end=%p chan=%d\n", start, end, sc->sc_i.dmachan)); isa_dmastart(sc->sc_isa, sc->sc_i.dmachan, start, end - start, NULL, DMAMODE_READ | DMAMODE_LOOP, BUS_DMA_NOWAIT); @@ -1250,7 +1251,7 @@ sbdsp_block_input(addr) { struct sbdsp_softc *sc = addr; int cc = sc->sc_i.blksize; - + DPRINTFN(2, ("sbdsp_block_input: sc=%p cc=%d\n", addr, cc)); if (sc->sc_i.run != SB_NOTRUNNING) @@ -1270,7 +1271,7 @@ sbdsp_block_input(addr) if (ISSB16CLASS(sc)) { DPRINTFN(3, ("sbdsp16 input command cmd=0x%02x bmode=0x%02x cc=%d\n", sc->sc_i.modep->cmd, sc->sc_i.bmode, cc)); - if (sbdsp_wdsp(sc, sc->sc_i.modep->cmd) < 0 || + if (sbdsp_wdsp(sc, sc->sc_i.modep->cmd) < 0 || sbdsp_wdsp(sc, sc->sc_i.bmode) < 0 || sbdsp_wdsp(sc, cc) < 0 || sbdsp_wdsp(sc, cc >> 8) < 0) { @@ -1356,7 +1357,7 @@ sbdsp_trigger_output(addr, start, end, blksize, intr, arg, param) if (cmd && sbdsp_wdsp(sc, cmd) < 0) return (EIO); } - + if (ISSB16CLASS(sc)) { if (sbdsp16_set_rate(sc, SB_DSP16_OUTPUTRATE, sc->sc_o.rate)) { DPRINTF(("sbdsp_trigger_output: rate=%d set failed\n", @@ -1385,7 +1386,7 @@ sbdsp_block_output(addr) { struct sbdsp_softc *sc = addr; int cc = sc->sc_o.blksize; - + DPRINTFN(2, ("sbdsp_block_output: sc=%p cc=%d\n", addr, cc)); if (sc->sc_o.run != SB_NOTRUNNING) @@ -1403,9 +1404,9 @@ sbdsp_block_output(addr) } else if (sc->sc_o.run == SB_NOTRUNNING) { /* Initialize looping PCM */ if (ISSB16CLASS(sc)) { - DPRINTF(("sbdsp_block_output: SB16 cmd=0x%02x bmode=0x%02x cc=%d\n", + DPRINTF(("sbdsp_block_output: SB16 cmd=0x%02x bmode=0x%02x cc=%d\n", sc->sc_o.modep->cmd,sc->sc_o.bmode, cc)); - if (sbdsp_wdsp(sc, sc->sc_o.modep->cmd) < 0 || + if (sbdsp_wdsp(sc, sc->sc_o.modep->cmd) < 0 || sbdsp_wdsp(sc, sc->sc_o.bmode) < 0 || sbdsp_wdsp(sc, cc) < 0 || sbdsp_wdsp(sc, cc >> 8) < 0) { @@ -1434,7 +1435,7 @@ sbdsp_block_output(addr) /* * Only the DSP unit on the sound blaster generates interrupts. * There are three cases of interrupt: reception of a midi byte - * (when mode is enabled), completion of dma transmission, or + * (when mode is enabled), completion of dma transmission, or * completion of a dma reception. * * If there is interrupt sharing or a spurious interrupt occurs @@ -1609,7 +1610,7 @@ sbdsp_mixer_set_port(addr, cp) int mask, bits; int lmask, rmask, lbits, rbits; int mute, swap; - + if (sc->sc_open == SB_OPEN_MIDI) return EBUSY; @@ -1662,7 +1663,7 @@ sbdsp_mixer_set_port(addr, cp) if (cp->un.value.num_channels != 1) return EINVAL; - lgain = rgain = SB_ADJUST_MIC_GAIN(sc, + lgain = rgain = SB_ADJUST_MIC_GAIN(sc, cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]); break; case SB_PCSPEAKER: @@ -1671,21 +1672,21 @@ sbdsp_mixer_set_port(addr, cp) /* fall into */ case SB_INPUT_GAIN: case SB_OUTPUT_GAIN: - lgain = rgain = SB_ADJUST_2_GAIN(sc, + lgain = rgain = SB_ADJUST_2_GAIN(sc, cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]); break; default: switch (cp->un.value.num_channels) { case 1: - lgain = rgain = SB_ADJUST_GAIN(sc, + lgain = rgain = SB_ADJUST_GAIN(sc, cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]); break; case 2: if (sc->sc_mixer_model == SBM_CT1335) return EINVAL; - lgain = SB_ADJUST_GAIN(sc, + lgain = SB_ADJUST_GAIN(sc, cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT]); - rgain = SB_ADJUST_GAIN(sc, + rgain = SB_ADJUST_GAIN(sc, cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT]); break; default: @@ -1796,7 +1797,7 @@ sbdsp_mixer_get_port(addr, cp) mixer_ctrl_t *cp; { struct sbdsp_softc *sc = addr; - + if (sc->sc_open == SB_OPEN_MIDI) return EBUSY; @@ -1841,13 +1842,13 @@ sbdsp_mixer_get_port(addr, cp) default: switch (cp->un.value.num_channels) { case 1: - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = + cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->gain[cp->dev][SB_LEFT]; break; case 2: - cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = + cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->gain[cp->dev][SB_LEFT]; - cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = + cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->gain[cp->dev][SB_RIGHT]; break; default: @@ -1899,7 +1900,7 @@ sbdsp_mixer_query_devinfo(addr, dip) struct sbdsp_softc *sc = addr; int chan, class, is1745; - DPRINTF(("sbdsp_mixer_query_devinfo: model=%d index=%d\n", + DPRINTF(("sbdsp_mixer_query_devinfo: model=%d index=%d\n", sc->sc_mixer_model, dip->index)); if (sc->sc_mixer_model == SBM_NONE) @@ -2022,7 +2023,7 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->un.e.member[1].ord = 1; } return 0; - + case SB_TREBLE: dip->prev = dip->next = AUDIO_MIXER_LAST; strcpy(dip->label.name, AudioNtreble); @@ -2041,7 +2042,7 @@ sbdsp_mixer_query_devinfo(addr, dip) dip->un.e.member[1].ord = 1; } return 0; - + case SB_RECORD_CLASS: /* record source class */ dip->type = AUDIO_MIXER_CLASS; dip->mixer_class = SB_RECORD_CLASS; diff --git a/sys/dev/isa/sbdspvar.h b/sys/dev/isa/sbdspvar.h index d5cf4dcb1fb..700660a1c5d 100644 --- a/sys/dev/isa/sbdspvar.h +++ b/sys/dev/isa/sbdspvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdspvar.h,v 1.11 1999/08/05 05:32:41 deraadt Exp $ */ +/* $OpenBSD: sbdspvar.h,v 1.12 2001/02/03 05:22:24 mickey Exp $ */ /* $NetBSD: sbdspvar.h,v 1.37 1998/08/10 00:20:39 mycroft Exp $ */ /* @@ -40,6 +40,8 @@ #include <dev/ic/mpuvar.h> #endif +#include <sys/timeout.h> + #define SB_MASTER_VOL 0 #define SB_MIDI_VOL 1 #define SB_CD_VOL 2 @@ -100,6 +102,7 @@ struct sbdsp_softc { bus_space_handle_t sc_ioh; /* handle */ void *sc_ih; /* interrupt vectoring */ struct device *sc_isa; + struct timeout sc_tmo; int sc_iobase; /* I/O port base address */ int sc_irq; /* interrupt */ @@ -118,13 +121,13 @@ struct sbdsp_softc { #define SB_LEFT 0 #define SB_RIGHT 1 #define SB_LR 0 - + u_int in_mask; /* input ports */ u_int in_port; /* XXX needed for MI interface */ u_int in_filter; /* one of SB_TREBLE_EQ, SB_BASS_EQ, 0 */ u_int spkr_state; /* non-null is on */ - + struct sbdsp_state { u_int rate; /* Sample rate */ u_char tc; /* Time constant */ @@ -237,7 +240,7 @@ int sbdsp_mixer_set_port __P((void *, mixer_ctrl_t *)); int sbdsp_mixer_get_port __P((void *, mixer_ctrl_t *)); int sbdsp_mixer_query_devinfo __P((void *, mixer_devinfo_t *)); -void *sb_malloc __P((void *, unsigned long, int, int)); +void *sb_malloc __P((void *, unsigned long, int, int)); void sb_free __P((void *, void *, int)); unsigned long sb_round __P((void *, unsigned long)); int sb_mappage __P((void *, void *, int, int)); @@ -245,7 +248,7 @@ int sb_mappage __P((void *, void *, int, int)); int sbdsp_get_props __P((void *)); -int sbdsp_midi_open __P((void *, int, +int sbdsp_midi_open __P((void *, int, void (*iintr)__P((void *, int)), void (*ointr)__P((void *)), void *arg)); void sbdsp_midi_close __P((void *)); |