diff --git a/sys/arch/arm32/mainbus/lmcaudio.c b/sys/arch/arm32/mainbus/lmcaudio.c index 4c05d0d0e1dd..6180697cbe3a 100644 --- a/sys/arch/arm32/mainbus/lmcaudio.c +++ b/sys/arch/arm32/mainbus/lmcaudio.c @@ -1,4 +1,4 @@ -/* $NetBSD: lmcaudio.c,v 1.6 1997/05/07 18:51:31 augustss Exp $ */ +/* $NetBSD: lmcaudio.c,v 1.7 1997/05/09 22:16:27 augustss Exp $ */ /* * Copyright (c) 1996, Danny C Tsen. @@ -329,17 +329,14 @@ lmcaudio_drain(addr) | Interface to the generic audio driver | * ************************************************************************* */ -int lmcaudio_query_encoding __P((void *, struct audio_encoding *)); -int lmcaudio_set_out_params __P((void *, struct audio_params *)); -int lmcaudio_set_in_params __P((void *, struct audio_params *)); -int lmcaudio_round_blocksize __P((void *, int)); +int lmcaudio_query_encoding __P((void *, struct audio_encoding *)); +int lmcaudio_set_params __P((void *, int, struct audio_params *, struct audio_params *)); +int lmcaudio_round_blocksize __P((void *, int)); int lmcaudio_set_out_port __P((void *, int)); int lmcaudio_get_out_port __P((void *)); int lmcaudio_set_in_port __P((void *, int)); int lmcaudio_get_in_port __P((void *)); -int lmcaudio_commit_settings __P((void *)); -void lmcaudio_sw_encode __P((void *, int, u_char *, int)); -void lmcaudio_sw_decode __P((void *, int, u_char *, int)); +int lmcaudio_commit_settings __P((void *)); int lmcaudio_start_output __P((void *, void *, int, void (*)(), void *)); int lmcaudio_start_input __P((void *, void *, int, void (*)(), void *)); int lmcaudio_halt_output __P((void *)); @@ -360,31 +357,21 @@ struct audio_device lmcaudio_device = { }; int -lmcaudio_set_in_params(addr, p) +lmcaudio_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + int mode; + struct audio_params *p, *q; { - struct vidcaudio_softc *sc = addr; - if (p->encoding != AUDIO_ENCODING_LINEAR_LE || p->precision != 16 || p->channels != 2) return EINVAL; - return 0; -} -int -lmcaudio_set_out_params(addr, p) - void *addr; - struct audio_params *p; -{ - struct vidcaudio_softc *sc = addr; - - if (p->encoding != AUDIO_ENCODING_LINEAR_LE || - p->precision != 16 || - p->channels != 2) - return EINVAL; - lmcaudio_rate(p->sample_rate); + /* Update setting for the other mode. */ + q->sample_rate = p->sample_rate; + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; return 0; } @@ -466,31 +453,6 @@ printf ( "DEBUG: committ_settings\n" ); return(0); } -void -lmcaudio_sw_encode(addr, e, p, cc) - void *addr; - int e; - u_char *p; - int cc; -{ -#ifdef DEBUG - printf ( "DEBUG: sw_encode\n" ); -#endif - return; -} - -void -lmcaudio_sw_decode(addr, e, p, cc) - void *addr; - int e; - u_char *p; - int cc; -{ -#ifdef DEBUG - printf ( "DEBUG: sw_decode\n" ); -#endif -} - #define ROUND(s) ( ((int)s) & (~(NBPG-1)) ) extern char *auzero_block; @@ -644,16 +606,13 @@ struct audio_hw_if lmcaudio_hw_if = { lmcaudio_close, lmcaudio_drain, lmcaudio_query_encoding, - lmcaudio_set_out_params, - lmcaudio_set_in_params, + lmcaudio_set_params, lmcaudio_round_blocksize, lmcaudio_set_out_port, lmcaudio_get_out_port, lmcaudio_set_in_port, lmcaudio_get_in_port, lmcaudio_commit_settings, - lmcaudio_sw_encode, - lmcaudio_sw_decode, lmcaudio_start_output, lmcaudio_start_input, lmcaudio_halt_output, diff --git a/sys/arch/arm32/mainbus/vidcaudio.c b/sys/arch/arm32/mainbus/vidcaudio.c index 217a0704fbe3..0f8d888bb4be 100644 --- a/sys/arch/arm32/mainbus/vidcaudio.c +++ b/sys/arch/arm32/mainbus/vidcaudio.c @@ -1,4 +1,4 @@ -/* $NetBSD: vidcaudio.c,v 1.12 1997/05/07 18:51:33 augustss Exp $ */ +/* $NetBSD: vidcaudio.c,v 1.13 1997/05/09 22:16:28 augustss Exp $ */ /* * Copyright (c) 1995 Melvin Tang-Richardson @@ -293,15 +293,13 @@ vidcaudio_close(addr) * ************************************************************************* */ int vidcaudio_query_encoding __P((void *, struct audio_encoding *)); -int vidcaudio_set_params __P((void *, struct audio_params *)); +int vidcaudio_set_params __P((void *, int, struct audio_params *, struct audio_params *)); int vidcaudio_round_blocksize __P((void *, int)); int vidcaudio_set_out_port __P((void *, int)); int vidcaudio_get_out_port __P((void *)); int vidcaudio_set_in_port __P((void *, int)); int vidcaudio_get_in_port __P((void *)); int vidcaudio_commit_settings __P((void *)); -void vidcaudio_sw_encode __P((void *, int, u_char *, int)); -void vidcaudio_sw_decode __P((void *, int, u_char *, int)); int vidcaudio_start_output __P((void *, void *, int, void (*)(), void *)); int vidcaudio_start_input __P((void *, void *, int, void (*)(), void *)); int vidcaudio_halt_output __P((void *)); @@ -339,16 +337,21 @@ int vidcaudio_query_encoding ( void *addr, struct audio_encoding *fp ) } int -vidcaudio_set_params(addr, p) +vidcaudio_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + struct audio_params *p, *q; { - struct vidcaudio_softc *sc = addr; - if (p->encoding != AUDIO_ENCODING_ULAW || p->channels != 8) return EINVAL; vidcaudio_rate(4 * p->sample_rate / (3 * 1024)); /* XXX probably wrong */ + p->sw_code = 0; + + /* Update setting for the other mode. */ + q->sample_rate = p->sample_rate; + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; return 0; } @@ -394,21 +397,6 @@ printf ( "DEBUG: committ_settings\n" ); return 0; } -void vidcaudio_sw_encode ( void *addr, int e, u_char *p, int cc ) -{ -#ifdef DEBUG - printf ( "DEBUG: sw_encode\n" ); -#endif - return; -} - -void vidcaudio_sw_decode ( void *addr, int e, u_char *p, int cc ) -{ -#ifdef DEBUG - printf ( "DEBUG: sw_decode\n" ); -#endif -} - #define ROUND(s) ( ((int)s) & (~(NBPG-1)) ) int vidcaudio_start_output ( void *addr, void *p, int cc, @@ -525,15 +513,12 @@ struct audio_hw_if vidcaudio_hw_if = { NULL, vidcaudio_query_encoding, vidcaudio_set_params, - vidcaudio_set_params, vidcaudio_round_blocksize, vidcaudio_set_out_port, vidcaudio_get_out_port, vidcaudio_set_in_port, vidcaudio_get_in_port, vidcaudio_commit_settings, - vidcaudio_sw_encode, - vidcaudio_sw_decode, vidcaudio_start_output, vidcaudio_start_input, vidcaudio_halt_output, diff --git a/sys/arch/arm32/vidc/lmcaudio.c b/sys/arch/arm32/vidc/lmcaudio.c index 4c05d0d0e1dd..6180697cbe3a 100644 --- a/sys/arch/arm32/vidc/lmcaudio.c +++ b/sys/arch/arm32/vidc/lmcaudio.c @@ -1,4 +1,4 @@ -/* $NetBSD: lmcaudio.c,v 1.6 1997/05/07 18:51:31 augustss Exp $ */ +/* $NetBSD: lmcaudio.c,v 1.7 1997/05/09 22:16:27 augustss Exp $ */ /* * Copyright (c) 1996, Danny C Tsen. @@ -329,17 +329,14 @@ lmcaudio_drain(addr) | Interface to the generic audio driver | * ************************************************************************* */ -int lmcaudio_query_encoding __P((void *, struct audio_encoding *)); -int lmcaudio_set_out_params __P((void *, struct audio_params *)); -int lmcaudio_set_in_params __P((void *, struct audio_params *)); -int lmcaudio_round_blocksize __P((void *, int)); +int lmcaudio_query_encoding __P((void *, struct audio_encoding *)); +int lmcaudio_set_params __P((void *, int, struct audio_params *, struct audio_params *)); +int lmcaudio_round_blocksize __P((void *, int)); int lmcaudio_set_out_port __P((void *, int)); int lmcaudio_get_out_port __P((void *)); int lmcaudio_set_in_port __P((void *, int)); int lmcaudio_get_in_port __P((void *)); -int lmcaudio_commit_settings __P((void *)); -void lmcaudio_sw_encode __P((void *, int, u_char *, int)); -void lmcaudio_sw_decode __P((void *, int, u_char *, int)); +int lmcaudio_commit_settings __P((void *)); int lmcaudio_start_output __P((void *, void *, int, void (*)(), void *)); int lmcaudio_start_input __P((void *, void *, int, void (*)(), void *)); int lmcaudio_halt_output __P((void *)); @@ -360,31 +357,21 @@ struct audio_device lmcaudio_device = { }; int -lmcaudio_set_in_params(addr, p) +lmcaudio_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + int mode; + struct audio_params *p, *q; { - struct vidcaudio_softc *sc = addr; - if (p->encoding != AUDIO_ENCODING_LINEAR_LE || p->precision != 16 || p->channels != 2) return EINVAL; - return 0; -} -int -lmcaudio_set_out_params(addr, p) - void *addr; - struct audio_params *p; -{ - struct vidcaudio_softc *sc = addr; - - if (p->encoding != AUDIO_ENCODING_LINEAR_LE || - p->precision != 16 || - p->channels != 2) - return EINVAL; - lmcaudio_rate(p->sample_rate); + /* Update setting for the other mode. */ + q->sample_rate = p->sample_rate; + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; return 0; } @@ -466,31 +453,6 @@ printf ( "DEBUG: committ_settings\n" ); return(0); } -void -lmcaudio_sw_encode(addr, e, p, cc) - void *addr; - int e; - u_char *p; - int cc; -{ -#ifdef DEBUG - printf ( "DEBUG: sw_encode\n" ); -#endif - return; -} - -void -lmcaudio_sw_decode(addr, e, p, cc) - void *addr; - int e; - u_char *p; - int cc; -{ -#ifdef DEBUG - printf ( "DEBUG: sw_decode\n" ); -#endif -} - #define ROUND(s) ( ((int)s) & (~(NBPG-1)) ) extern char *auzero_block; @@ -644,16 +606,13 @@ struct audio_hw_if lmcaudio_hw_if = { lmcaudio_close, lmcaudio_drain, lmcaudio_query_encoding, - lmcaudio_set_out_params, - lmcaudio_set_in_params, + lmcaudio_set_params, lmcaudio_round_blocksize, lmcaudio_set_out_port, lmcaudio_get_out_port, lmcaudio_set_in_port, lmcaudio_get_in_port, lmcaudio_commit_settings, - lmcaudio_sw_encode, - lmcaudio_sw_decode, lmcaudio_start_output, lmcaudio_start_input, lmcaudio_halt_output, diff --git a/sys/arch/arm32/vidc/vidcaudio.c b/sys/arch/arm32/vidc/vidcaudio.c index 217a0704fbe3..0f8d888bb4be 100644 --- a/sys/arch/arm32/vidc/vidcaudio.c +++ b/sys/arch/arm32/vidc/vidcaudio.c @@ -1,4 +1,4 @@ -/* $NetBSD: vidcaudio.c,v 1.12 1997/05/07 18:51:33 augustss Exp $ */ +/* $NetBSD: vidcaudio.c,v 1.13 1997/05/09 22:16:28 augustss Exp $ */ /* * Copyright (c) 1995 Melvin Tang-Richardson @@ -293,15 +293,13 @@ vidcaudio_close(addr) * ************************************************************************* */ int vidcaudio_query_encoding __P((void *, struct audio_encoding *)); -int vidcaudio_set_params __P((void *, struct audio_params *)); +int vidcaudio_set_params __P((void *, int, struct audio_params *, struct audio_params *)); int vidcaudio_round_blocksize __P((void *, int)); int vidcaudio_set_out_port __P((void *, int)); int vidcaudio_get_out_port __P((void *)); int vidcaudio_set_in_port __P((void *, int)); int vidcaudio_get_in_port __P((void *)); int vidcaudio_commit_settings __P((void *)); -void vidcaudio_sw_encode __P((void *, int, u_char *, int)); -void vidcaudio_sw_decode __P((void *, int, u_char *, int)); int vidcaudio_start_output __P((void *, void *, int, void (*)(), void *)); int vidcaudio_start_input __P((void *, void *, int, void (*)(), void *)); int vidcaudio_halt_output __P((void *)); @@ -339,16 +337,21 @@ int vidcaudio_query_encoding ( void *addr, struct audio_encoding *fp ) } int -vidcaudio_set_params(addr, p) +vidcaudio_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + struct audio_params *p, *q; { - struct vidcaudio_softc *sc = addr; - if (p->encoding != AUDIO_ENCODING_ULAW || p->channels != 8) return EINVAL; vidcaudio_rate(4 * p->sample_rate / (3 * 1024)); /* XXX probably wrong */ + p->sw_code = 0; + + /* Update setting for the other mode. */ + q->sample_rate = p->sample_rate; + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; return 0; } @@ -394,21 +397,6 @@ printf ( "DEBUG: committ_settings\n" ); return 0; } -void vidcaudio_sw_encode ( void *addr, int e, u_char *p, int cc ) -{ -#ifdef DEBUG - printf ( "DEBUG: sw_encode\n" ); -#endif - return; -} - -void vidcaudio_sw_decode ( void *addr, int e, u_char *p, int cc ) -{ -#ifdef DEBUG - printf ( "DEBUG: sw_decode\n" ); -#endif -} - #define ROUND(s) ( ((int)s) & (~(NBPG-1)) ) int vidcaudio_start_output ( void *addr, void *p, int cc, @@ -525,15 +513,12 @@ struct audio_hw_if vidcaudio_hw_if = { NULL, vidcaudio_query_encoding, vidcaudio_set_params, - vidcaudio_set_params, vidcaudio_round_blocksize, vidcaudio_set_out_port, vidcaudio_get_out_port, vidcaudio_set_in_port, vidcaudio_get_in_port, vidcaudio_commit_settings, - vidcaudio_sw_encode, - vidcaudio_sw_decode, vidcaudio_start_output, vidcaudio_start_input, vidcaudio_halt_output, diff --git a/sys/arch/sparc/dev/am7930_sparc.c b/sys/arch/sparc/dev/am7930_sparc.c index e1cb76075fac..29b9fae3e5be 100644 --- a/sys/arch/sparc/dev/am7930_sparc.c +++ b/sys/arch/sparc/dev/am7930_sparc.c @@ -1,4 +1,4 @@ -/* $NetBSD: am7930_sparc.c,v 1.19 1997/05/07 18:51:35 augustss Exp $ */ +/* $NetBSD: am7930_sparc.c,v 1.20 1997/05/09 22:16:29 augustss Exp $ */ /* * Copyright (c) 1995 Rolf Grossmann @@ -206,7 +206,7 @@ static const u_short ger_coeff[] = { int amd7930_open __P((dev_t, int)); void amd7930_close __P((void *)); int amd7930_query_encoding __P((void *, struct audio_encoding *)); -int amd7930_set_params __P((void *, struct audio_params *)); +int amd7930_set_params __P((void *, int, struct audio_params *, struct audio_params *)); int amd7930_round_blocksize __P((void *, int)); int amd7930_set_out_port __P((void *, int)); int amd7930_get_out_port __P((void *)); @@ -234,15 +234,12 @@ struct audio_hw_if sa_hw_if = { NULL, amd7930_query_encoding, amd7930_set_params, - amd7930_set_params, amd7930_round_blocksize, amd7930_set_out_port, amd7930_get_out_port, amd7930_set_in_port, amd7930_get_in_port, amd7930_commit_settings, - NULL, - NULL, amd7930_start_output, amd7930_start_input, amd7930_halt_output, @@ -398,17 +395,25 @@ amd7930_close(addr) } int -amd7930_set_params(addr, p) +amd7930_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + int mode; + struct audio_params *p, *q; { if (p->sample_rate < 7500 || p->sample_rate > 8500 || p->encoding != AUDIO_ENCODING_ULAW || p->precision != 8 || p->channels != 1) return EINVAL; - p->sample_rate = 8000; - return 0; /* no other sampling rates supported by amd chip */ + p->sample_rate = 8000; /* no other sampling rates supported by amd chip */ + + /* Update setting for the other mode. */ + q->sample_rate = p->sample_rate; + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; + + return 0; } int diff --git a/sys/arch/sparc/dev/amd7930.c b/sys/arch/sparc/dev/amd7930.c index 25159ecb2ac1..7a3fdb48839f 100644 --- a/sys/arch/sparc/dev/amd7930.c +++ b/sys/arch/sparc/dev/amd7930.c @@ -1,4 +1,4 @@ -/* $NetBSD: amd7930.c,v 1.19 1997/05/07 18:51:35 augustss Exp $ */ +/* $NetBSD: amd7930.c,v 1.20 1997/05/09 22:16:29 augustss Exp $ */ /* * Copyright (c) 1995 Rolf Grossmann @@ -206,7 +206,7 @@ static const u_short ger_coeff[] = { int amd7930_open __P((dev_t, int)); void amd7930_close __P((void *)); int amd7930_query_encoding __P((void *, struct audio_encoding *)); -int amd7930_set_params __P((void *, struct audio_params *)); +int amd7930_set_params __P((void *, int, struct audio_params *, struct audio_params *)); int amd7930_round_blocksize __P((void *, int)); int amd7930_set_out_port __P((void *, int)); int amd7930_get_out_port __P((void *)); @@ -234,15 +234,12 @@ struct audio_hw_if sa_hw_if = { NULL, amd7930_query_encoding, amd7930_set_params, - amd7930_set_params, amd7930_round_blocksize, amd7930_set_out_port, amd7930_get_out_port, amd7930_set_in_port, amd7930_get_in_port, amd7930_commit_settings, - NULL, - NULL, amd7930_start_output, amd7930_start_input, amd7930_halt_output, @@ -398,17 +395,25 @@ amd7930_close(addr) } int -amd7930_set_params(addr, p) +amd7930_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + int mode; + struct audio_params *p, *q; { if (p->sample_rate < 7500 || p->sample_rate > 8500 || p->encoding != AUDIO_ENCODING_ULAW || p->precision != 8 || p->channels != 1) return EINVAL; - p->sample_rate = 8000; - return 0; /* no other sampling rates supported by amd chip */ + p->sample_rate = 8000; /* no other sampling rates supported by amd chip */ + + /* Update setting for the other mode. */ + q->sample_rate = p->sample_rate; + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; + + return 0; } int diff --git a/sys/dev/audio.c b/sys/dev/audio.c index 9ce13f583a26..ab8ec05a7f66 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $NetBSD: audio.c,v 1.44 1997/05/07 19:24:34 augustss Exp $ */ +/* $NetBSD: audio.c,v 1.45 1997/05/09 22:16:30 augustss Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -160,7 +160,8 @@ int audio_drain __P((struct audio_softc *)); void audio_clear __P((struct audio_softc *)); /* The default audio mode: 8 kHz mono ulaw */ -static struct audio_params audio_default = { 8000, AUDIO_ENCODING_ULAW, 8, 1 }; +static struct audio_params audio_default = + { 8000, AUDIO_ENCODING_ULAW, 8, 1, 0 }; #ifdef AUDIO_DEBUG void @@ -213,8 +214,7 @@ audio_hardware_attach(hwp, hdlp) if (hwp->open == 0 || hwp->close == 0 || hwp->query_encoding == 0 || - hwp->set_in_params == 0 || - hwp->set_out_params == 0 || + hwp->set_params == 0 || hwp->round_blocksize == 0 || hwp->set_out_port == 0 || hwp->get_out_port == 0 || @@ -540,10 +540,12 @@ audio_open(dev, flags, ifmt, p) sc->sc_rparams = audio_default; sc->sc_pparams = audio_default; /** XXX should we abort on error? */ - error = hw->set_in_params(sc->hw_hdl, &sc->sc_rparams); + error = hw->set_params(sc->hw_hdl, AUMODE_RECORD, + &sc->sc_rparams, &sc->sc_pparams); if (error) return (error); - error = hw->set_out_params(sc->hw_hdl, &sc->sc_pparams); + error = hw->set_params(sc->hw_hdl, AUMODE_PLAY, + &sc->sc_pparams, &sc->sc_rparams); if (error) return (error); } @@ -786,9 +788,8 @@ audio_read(dev, uio, ioflag) return (error); } hp = cb->hp; - if (hw->sw_decode) - hw->sw_decode(sc->hw_hdl, sc->sc_rparams.encoding, - hp, blocksize); + if (sc->sc_rparams.sw_code) + sc->sc_rparams.sw_code(sc->hw_hdl, hp, blocksize); error = uiomove(hp, blocksize, uio); if (error) break; @@ -941,8 +942,6 @@ audio_alloc_auzero(sc, bs) struct audio_softc *sc; int bs; { - struct audio_hw_if *hw = sc->hw_if; - if (sc->auzero_block) free(sc->auzero_block, M_DEVBUF); @@ -953,9 +952,8 @@ audio_alloc_auzero(sc, bs) } #endif audio_fill_silence(&sc->sc_pparams, sc->auzero_block, bs); - if (hw->sw_encode) - hw->sw_encode(sc->hw_hdl, sc->sc_pparams.encoding, - sc->auzero_block, bs); + if (sc->sc_pparams.sw_code) + sc->sc_pparams.sw_code(sc->hw_hdl, sc->auzero_block, bs); } @@ -1003,10 +1001,9 @@ audio_write(dev, uio, ioflag) cc = min(cb->fill, uio->uio_resid); error = uiomove(cb->otp, cc, uio); if (error == 0) { - if (hw->sw_encode) - hw->sw_encode(sc->hw_hdl, - sc->sc_pparams.encoding, cb->otp, - cc); + if (sc->sc_pparams.sw_code) + sc->sc_pparams.sw_code(sc->hw_hdl, + cb->otp, cc); cb->fill -= cc; cb->otp += cc; } @@ -1104,9 +1101,8 @@ audio_write(dev, uio, ioflag) break; } - if (hw->sw_encode) - hw->sw_encode(sc->hw_hdl, sc->sc_pparams.encoding, - cb->tp, blocksize); + if (sc->sc_pparams.sw_code) + sc->sc_pparams.sw_code(sc->hw_hdl, cb->tp, blocksize); /* wrap the ring buffer if at end */ s = splaudio(); @@ -1604,7 +1600,7 @@ audiosetinfo(sc, ai) return error; if (nr) { audio_clear(sc); - error = hw->set_in_params(sc->hw_hdl, &rp); + error = hw->set_params(sc->hw_hdl, AUMODE_RECORD, &rp, &sc->sc_pparams); if (error) return (error); sc->sc_rparams = rp; @@ -1614,7 +1610,7 @@ audiosetinfo(sc, ai) if (!cleared) audio_clear(sc); cleared = 1; - error = hw->set_out_params(sc->hw_hdl, &pp); + error = hw->set_params(sc->hw_hdl, AUMODE_PLAY, &pp, &sc->sc_rparams); if (error) return (error); sc->sc_pparams = pp; diff --git a/sys/dev/audio_if.h b/sys/dev/audio_if.h index ec33ec38e7ee..00d6c7534cb2 100644 --- a/sys/dev/audio_if.h +++ b/sys/dev/audio_if.h @@ -1,4 +1,4 @@ -/* $NetBSD: audio_if.h,v 1.11 1997/04/29 21:01:45 augustss Exp $ */ +/* $NetBSD: audio_if.h,v 1.12 1997/05/09 22:16:31 augustss Exp $ */ /* * Copyright (c) 1994 Havard Eidnes. @@ -45,6 +45,8 @@ struct audio_params { u_int encoding; /* e.g. ulaw, linear, etc */ u_int precision; /* bits/sample */ u_int channels; /* mono(1), stereo(2) */ + /* Software en/decode functions, set if SW coding required by HW */ + void (*sw_code)__P((void *, u_char *, int)); }; struct audio_hw_if { @@ -62,8 +64,7 @@ struct audio_hw_if { * The values in the params struct may be changed (e.g. rounding * to the nearest sample rate.) */ - int (*set_out_params)__P((void *, struct audio_params *)); - int (*set_in_params)__P((void *, struct audio_params *)); + int (*set_params)__P((void *, int, struct audio_params *, struct audio_params *)); /* Hardware may have some say in the blocksize to choose */ int (*round_blocksize)__P((void *, int)); @@ -84,10 +85,6 @@ struct audio_hw_if { */ int (*commit_settings)__P((void *)); - /* Software en/decode functions, set if SW coding required by HW */ - void (*sw_encode)__P((void *, int, u_char *, int)); - void (*sw_decode)__P((void *, int, u_char *, int)); - /* Start input/output routines. These usually control DMA. */ int (*start_output)__P((void *, void *, int, void (*)(void *), void *)); diff --git a/sys/dev/ic/am7930.c b/sys/dev/ic/am7930.c index 5ccf0e1e66be..16f820f8d455 100644 --- a/sys/dev/ic/am7930.c +++ b/sys/dev/ic/am7930.c @@ -1,4 +1,4 @@ -/* $NetBSD: am7930.c,v 1.19 1997/05/07 18:51:35 augustss Exp $ */ +/* $NetBSD: am7930.c,v 1.20 1997/05/09 22:16:29 augustss Exp $ */ /* * Copyright (c) 1995 Rolf Grossmann @@ -206,7 +206,7 @@ static const u_short ger_coeff[] = { int amd7930_open __P((dev_t, int)); void amd7930_close __P((void *)); int amd7930_query_encoding __P((void *, struct audio_encoding *)); -int amd7930_set_params __P((void *, struct audio_params *)); +int amd7930_set_params __P((void *, int, struct audio_params *, struct audio_params *)); int amd7930_round_blocksize __P((void *, int)); int amd7930_set_out_port __P((void *, int)); int amd7930_get_out_port __P((void *)); @@ -234,15 +234,12 @@ struct audio_hw_if sa_hw_if = { NULL, amd7930_query_encoding, amd7930_set_params, - amd7930_set_params, amd7930_round_blocksize, amd7930_set_out_port, amd7930_get_out_port, amd7930_set_in_port, amd7930_get_in_port, amd7930_commit_settings, - NULL, - NULL, amd7930_start_output, amd7930_start_input, amd7930_halt_output, @@ -398,17 +395,25 @@ amd7930_close(addr) } int -amd7930_set_params(addr, p) +amd7930_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + int mode; + struct audio_params *p, *q; { if (p->sample_rate < 7500 || p->sample_rate > 8500 || p->encoding != AUDIO_ENCODING_ULAW || p->precision != 8 || p->channels != 1) return EINVAL; - p->sample_rate = 8000; - return 0; /* no other sampling rates supported by amd chip */ + p->sample_rate = 8000; /* no other sampling rates supported by amd chip */ + + /* Update setting for the other mode. */ + q->sample_rate = p->sample_rate; + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; + + return 0; } int diff --git a/sys/dev/isa/ad1848.c b/sys/dev/isa/ad1848.c index 075a3ea6e317..e9d21849e711 100644 --- a/sys/dev/isa/ad1848.c +++ b/sys/dev/isa/ad1848.c @@ -1,4 +1,4 @@ -/* $NetBSD: ad1848.c,v 1.26 1997/05/07 18:51:41 augustss Exp $ */ +/* $NetBSD: ad1848.c,v 1.27 1997/05/09 22:16:34 augustss Exp $ */ /* * Copyright (c) 1994 John Brezak @@ -85,6 +85,7 @@ #include #include +#include #include #include @@ -150,13 +151,15 @@ static int ad1848_init_values[] = { void ad1848_reset __P((struct ad1848_softc *)); int ad1848_set_speed __P((struct ad1848_softc *, u_long *)); void ad1848_mute_monitor __P((void *, int)); -int ad1848_set_params __P((void *, struct audio_params *)); static int ad_read __P((struct ad1848_softc *, int)); static __inline void ad_write __P((struct ad1848_softc *, int, int)); static void ad_set_MCE __P((struct ad1848_softc *, int)); static void wait_for_calibration __P((struct ad1848_softc *)); +void ad1848_sign8(void *, u_char *, int); +void ad1848_sign16(void *, u_char *, int); +void ad1848_swap(void *, u_char *, int); static int ad_read(sc, reg) @@ -492,7 +495,7 @@ ad1848_attach(sc) int i; struct ad1848_volume vol_mid = {220, 220}; struct ad1848_volume vol_0 = {0, 0}; - struct audio_params params; + struct audio_params params, xparams; sc->sc_locked = 0; @@ -513,8 +516,8 @@ ad1848_attach(sc) params.precision = 8; params.channels = 1; params.encoding = AUDIO_ENCODING_ULAW; - (void) ad1848_set_in_params(sc, ¶ms); - (void) ad1848_set_out_params(sc, ¶ms); + (void) ad1848_set_params(sc, AUMODE_RECORD, ¶ms, &xparams); + (void) ad1848_set_params(sc, AUMODE_PLAY, ¶ms, &xparams); /* Set default gains */ (void) ad1848_set_rec_gain(sc, &vol_mid); @@ -923,6 +926,8 @@ ad1848_query_encoding(addr, fp) void *addr; struct audio_encoding *fp; { + struct ad1848_softc *sc = addr; + switch (fp->index) { case 0: strcpy(fp->name, AudioEmulaw); @@ -937,48 +942,117 @@ ad1848_query_encoding(addr, fp) fp->flags = 0; break; case 2: - strcpy(fp->name, AudioEadpcm); - fp->encoding = AUDIO_ENCODING_ADPCM; - fp->precision = 8; - fp->flags = 0; - break; - case 3: strcpy(fp->name, AudioElinear_le); fp->encoding = AUDIO_ENCODING_LINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 4: - strcpy(fp->name, AudioElinear_be); - fp->encoding = AUDIO_ENCODING_LINEAR_BE; - fp->precision = 16; - fp->flags = 0; - break; - case 5: + case 3: strcpy(fp->name, AudioEulinear); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; + + case 4: /* only on CS4231 */ + strcpy(fp->name, AudioElinear_be); + fp->encoding = AUDIO_ENCODING_LINEAR_BE; + fp->precision = 16; + fp->flags = sc->mode == 1; + break; + + /* emulate some modes */ + case 5: + strcpy(fp->name, AudioElinear); + fp->encoding = AUDIO_ENCODING_LINEAR; + fp->precision = 8; + fp->flags = 1; + break; + case 6: + strcpy(fp->name, AudioEulinear_le); + fp->encoding = AUDIO_ENCODING_ULINEAR_LE; + fp->precision = 16; + fp->flags = 1; + break; + + case 7: /* only on CS4231 */ + if (sc->mode == 1) + return EINVAL; + strcpy(fp->name, AudioEadpcm); + fp->encoding = AUDIO_ENCODING_ADPCM; + fp->precision = 8; + fp->flags = 0; + break; default: - return(EINVAL); + return EINVAL; /*NOTREACHED*/ } return (0); } -int -ad1848_set_params(addr, p) +void +ad1848_sign8(addr, p, cc) void *addr; - struct audio_params *p; + u_char *p; + int cc; { - register struct ad1848_softc *sc = addr; - int error, bits; + change_sign8(p, cc); +} + +void +ad1848_sign16(addr, p, cc) + void *addr; + u_char *p; + int cc; +{ + change_sign16(p, cc); +} + +void +ad1848_swap(addr, p, cc) + void *addr; + u_char *p; + int cc; +{ + swap_bytes(p, cc); +} + +int +ad1848_set_params(addr, mode, p, q) + void *addr; + int mode; + struct audio_params *p, *q; +{ + struct ad1848_softc *sc = addr; + int error, bits, enc; DPRINTF(("ad1848_set_params: %d %d %d %d\n", p->encoding, p->precision, p->channels, p->sample_rate)); - switch (p->encoding) { + p->sw_code = 0; + + enc = p->encoding; + switch (enc) { + case AUDIO_ENCODING_LINEAR_LE: + if (p->precision == 8) { + enc = AUDIO_ENCODING_ULINEAR_LE; + p->sw_code = ad1848_sign8; + } + break; + case AUDIO_ENCODING_LINEAR_BE: + if (p->precision == 16 && sc->mode == 1) { + enc = AUDIO_ENCODING_LINEAR_LE; + p->sw_code = ad1848_swap; + } + break; + case AUDIO_ENCODING_ULINEAR_LE: + if (p->precision == 16) { + enc = AUDIO_ENCODING_LINEAR_LE; + p->sw_code = ad1848_sign16; + } + break; + } + switch (enc) { case AUDIO_ENCODING_ULAW: bits = FMT_ULAW >> 5; break; @@ -1001,7 +1075,6 @@ ad1848_set_params(addr, p) return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - case AUDIO_ENCODING_ULINEAR_BE: if (p->precision == 8) bits = FMT_PCM8 >> 5; else @@ -1023,28 +1096,16 @@ ad1848_set_params(addr, p) sc->precision = p->precision; sc->need_commit = 1; + /* Update setting for the other mode. */ + q->sample_rate = p->sample_rate; + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; + DPRINTF(("ad1848_set_params succeeded\n")); return (0); } -/* We always set both play and record parameters */ -int -ad1848_set_in_params(addr, p) - void *addr; - struct audio_params *p; -{ - return ad1848_set_params(addr, p); -} - -/* We always set both play and record parameters */ -int -ad1848_set_out_params(addr, p) - void *addr; - struct audio_params *p; -{ - return ad1848_set_params(addr, p); -} - int ad1848_set_rec_port(sc, port) register struct ad1848_softc *sc; diff --git a/sys/dev/isa/ad1848var.h b/sys/dev/isa/ad1848var.h index 840eb7a29955..5fcaf986cb4a 100644 --- a/sys/dev/isa/ad1848var.h +++ b/sys/dev/isa/ad1848var.h @@ -1,4 +1,4 @@ -/* $NetBSD: ad1848var.h,v 1.13 1997/04/29 21:01:35 augustss Exp $ */ +/* $NetBSD: ad1848var.h,v 1.14 1997/05/09 22:16:35 augustss Exp $ */ /* * Copyright (c) 1994 John Brezak @@ -108,8 +108,7 @@ void ad1848_close __P((void *)); void ad1848_forceintr __P((struct ad1848_softc *)); int ad1848_query_encoding __P((void *, struct audio_encoding *)); -int ad1848_set_in_params __P((void *, struct audio_params *)); -int ad1848_set_out_params __P((void *, struct audio_params *)); +int ad1848_set_params __P((void *, int, struct audio_params *, struct audio_params *)); int ad1848_round_blocksize __P((void *, int)); diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index 9f294b32db01..d62cac16015a 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $NetBSD: files.isa,v 1.28 1997/04/04 20:56:41 mycroft Exp $ +# $NetBSD: files.isa,v 1.29 1997/05/09 22:16:35 augustss Exp $ # # Config.new file and device description for machine-independent ISA code. # Included by ports that need it. Requires that the SCSI files be @@ -221,12 +221,12 @@ device pss {[port = -1], [size = 0], [iomem = -1], [iosiz = 0], [irq = -1], [drq = -1]} attach pss at isa -device sp: audio, isadma, ad1848 +device sp: audio, isadma, ad1848, mulaw attach sp at pss file dev/isa/pss.c pss needs-flag # Microsoft Windows Sound System -device wss: audio, isadma, ad1848 +device wss: audio, isadma, ad1848, mulaw attach wss at isa file dev/isa/wss.c wss needs-flag diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index 695f8a32e355..21f9d0dc5eca 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $NetBSD: gus.c,v 1.24 1997/05/07 18:51:43 augustss Exp $ */ +/* $NetBSD: gus.c,v 1.25 1997/05/09 22:16:37 augustss Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -357,10 +357,8 @@ int gus_set_in_gain __P((caddr_t, u_int, u_char)); int gus_get_in_gain __P((caddr_t)); int gus_set_out_gain __P((caddr_t, u_int, u_char)); int gus_get_out_gain __P((caddr_t)); -int gus_set_in_params __P((void *, struct audio_params *)); -int gus_set_out_params __P((void *, struct audio_params *)); -int gusmax_set_in_params __P((void *, struct audio_params *)); -int gusmax_set_out_params __P((void *, struct audio_params *)); +int gus_set_params __P((void *, int, struct audio_params *, struct audio_params *)); +int gusmax_set_params __P((void *, int, struct audio_params *, struct audio_params *)); int gus_round_blocksize __P((void *, int)); int gus_set_out_port __P((void *, int)); int gus_get_out_port __P((void *)); @@ -391,8 +389,9 @@ int gus_getdev __P((void *, struct audio_device *)); int gus_set_io_params __P((struct gus_softc *, struct audio_params *)); STATIC void gus_deinterleave __P((struct gus_softc *, void *, int)); -STATIC void gus_expand __P((void *, int, u_char *, int)); -STATIC void gusmax_expand __P((void *, int, u_char *, int)); +STATIC void gus_expand __P((void *, u_char *, int)); +STATIC void gusmax_expand __P((void *, u_char *, int)); +STATIC void gus_compress __P((void *, u_char *, int)); STATIC int gus_mic_ctl __P((void *, int)); STATIC int gus_linein_ctl __P((void *, int)); @@ -605,8 +604,7 @@ struct audio_hw_if gus_hw_if = { gus_query_encoding, - gus_set_out_params, - gus_set_in_params, + gus_set_params, gus_round_blocksize, @@ -617,9 +615,6 @@ struct audio_hw_if gus_hw_if = { gus_commit_settings, - gus_expand, - mulaw_compress, - gus_dma_output, gus_dma_input, gus_halt_out_dma, @@ -998,27 +993,26 @@ gusopen(dev, flags) } STATIC void -gusmax_expand(hdl, encoding, buf, count) +gusmax_expand(hdl, buf, count) void *hdl; - int encoding; u_char *buf; int count; { register struct ad1848_softc *ac = hdl; - gus_expand(ac->parent, encoding, buf, count); + gus_expand(ac->parent, buf, count); } STATIC void -gus_expand(hdl, encoding, buf, count) +gus_expand(hdl, buf, count) void *hdl; - int encoding; u_char *buf; int count; { struct gus_softc *sc = hdl; - mulaw_expand(NULL, encoding, buf, count); + if (sc->sc_encoding == AUDIO_ENCODING_ULAW) + mulaw_to_ulinear8(buf, count); /* * If we need stereo deinterleaving, do it now. */ @@ -1026,6 +1020,16 @@ gus_expand(hdl, encoding, buf, count) gus_deinterleave(sc, (void *)buf, count); } +STATIC void +gus_compress(hdl, buf, count) + void *hdl; + u_char *buf; + int count; +{ + + ulinear8_to_mulaw(buf, count); +} + STATIC void gus_deinterleave(sc, buf, size) register struct gus_softc *sc; @@ -2099,39 +2103,28 @@ gus_set_volume(sc, voice, volume) */ int -gusmax_set_in_params(addr, p) +gusmax_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + int mode; + struct audio_params *p, *q; { register struct ad1848_softc *ac = addr; register struct gus_softc *sc = ac->parent; int error; - error = ad1848_set_in_params(ac, p); + error = ad1848_set_params(ac, mode, p, q); if (error) return error; - return gus_set_in_params(sc, p); + error = gus_set_params(sc, mode, p, q); + p->sw_code = mode == AUMODE_RECORD ? gus_compress : gusmax_expand; + return error; } int -gusmax_set_out_params(addr, p) +gus_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; -{ - register struct ad1848_softc *ac = addr; - register struct gus_softc *sc = ac->parent; - int error; - - error = ad1848_set_in_params(ac, p); - if (error) - return error; - return gus_set_in_params(sc, p); -} - -int -gus_set_in_params(addr, p) - void *addr; - struct audio_params *p; + int mode; + struct audio_params *p, *q; { register struct gus_softc *sc = addr; int error; @@ -2139,28 +2132,19 @@ gus_set_in_params(addr, p) error = gus_set_io_params(sc, p); if (error) return error; - sc->sc_irate = p->sample_rate; - return 0; -} + if (p->sample_rate > gus_max_frequency[sc->sc_voices - GUS_MIN_VOICES]) + p->sample_rate = gus_max_frequency[sc->sc_voices - GUS_MIN_VOICES]; + if (mode == AUMODE_RECORD) + sc->sc_irate = p->sample_rate; + else + sc->sc_orate = p->sample_rate; -int -gus_set_out_params(addr, p) - void *addr; - struct audio_params *p; -{ - register struct gus_softc *sc = addr; - int rate = p->sample_rate; - int error; - - error = gus_set_io_params(sc, p); - if (error) - return error; - - if (rate > gus_max_frequency[sc->sc_voices - GUS_MIN_VOICES]) - rate = gus_max_frequency[sc->sc_voices - GUS_MIN_VOICES]; - - p->sample_rate = sc->sc_orate = rate; + p->sw_code = mode == AUMODE_RECORD ? gus_compress : gus_expand; + /* Update setting for the other mode. */ + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; return 0; } @@ -2803,8 +2787,7 @@ gus_init_cs4231(sc) ad1848_query_encoding, /* query encoding */ - gusmax_set_out_params, - gusmax_set_in_params, + gusmax_set_params, gusmax_round_blocksize, @@ -2815,9 +2798,6 @@ gus_init_cs4231(sc) gusmax_commit_settings, - gusmax_expand, /* XXX use codec */ - mulaw_compress, - gusmax_dma_output, gusmax_dma_input, gusmax_halt_out_dma, diff --git a/sys/dev/isa/pas.c b/sys/dev/isa/pas.c index ff6adeeacbb9..27b961e604ad 100644 --- a/sys/dev/isa/pas.c +++ b/sys/dev/isa/pas.c @@ -1,4 +1,4 @@ -/* $NetBSD: pas.c,v 1.25 1997/04/29 21:01:37 augustss Exp $ */ +/* $NetBSD: pas.c,v 1.26 1997/05/09 22:16:38 augustss Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -53,7 +53,6 @@ #include #include -#include #include #include @@ -106,16 +105,13 @@ struct audio_hw_if pas_hw_if = { sbdsp_close, NULL, sbdsp_query_encoding, - sbdsp_set_out_params, - sbdsp_set_in_params, + sbdsp_set_params, sbdsp_round_blocksize, sbdsp_set_out_port, sbdsp_get_out_port, sbdsp_set_in_port, sbdsp_get_in_port, sbdsp_commit_settings, - mulaw_expand, - mulaw_compress, sbdsp_dma_output, sbdsp_dma_input, sbdsp_haltdma, diff --git a/sys/dev/isa/pss.c b/sys/dev/isa/pss.c index 6a584861bc4e..38104601b7d8 100644 --- a/sys/dev/isa/pss.c +++ b/sys/dev/isa/pss.c @@ -1,4 +1,4 @@ -/* $NetBSD: pss.c,v 1.26 1997/05/07 18:51:45 augustss Exp $ */ +/* $NetBSD: pss.c,v 1.27 1997/05/09 22:16:39 augustss Exp $ */ /* * Copyright (c) 1994 John Brezak @@ -235,16 +235,13 @@ struct audio_hw_if pss_audio_if = { ad1848_close, NULL, ad1848_query_encoding, - ad1848_set_out_params, - ad1848_set_in_params, + ad1848_set_params, ad1848_round_blocksize, pss_set_out_port, pss_get_out_port, pss_set_in_port, pss_get_in_port, ad1848_commit_settings, - NULL, - NULL, ad1848_dma_output, ad1848_dma_input, ad1848_halt_out_dma, diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c index 8e3aaa4ee01f..bd8c66b922f1 100644 --- a/sys/dev/isa/sb.c +++ b/sys/dev/isa/sb.c @@ -1,4 +1,4 @@ -/* $NetBSD: sb.c,v 1.45 1997/04/29 21:01:39 augustss Exp $ */ +/* $NetBSD: sb.c,v 1.46 1997/05/09 22:16:40 augustss Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -48,7 +48,6 @@ #include #include -#include #include #include @@ -87,16 +86,13 @@ struct audio_hw_if sb_hw_if = { sbdsp_close, NULL, sbdsp_query_encoding, - sbdsp_set_out_params, - sbdsp_set_in_params, + sbdsp_set_params, sbdsp_round_blocksize, sbdsp_set_out_port, sbdsp_get_out_port, sbdsp_set_in_port, sbdsp_get_in_port, sbdsp_commit_settings, - mulaw_expand, - mulaw_compress, sbdsp_dma_output, sbdsp_dma_input, sbdsp_haltdma, diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index dd0e03c93d65..7a0ade5e0a8d 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbdsp.c,v 1.44 1997/05/07 18:51:47 augustss Exp $ */ +/* $NetBSD: sbdsp.c,v 1.45 1997/05/09 22:16:41 augustss Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -57,6 +57,7 @@ #include #include +#include #include #include @@ -128,6 +129,8 @@ int sbdsp16_setrate __P((struct sbdsp_softc *, int, int, int *)); int sbdsp_tctosr __P((struct sbdsp_softc *, int)); int sbdsp_set_timeconst __P((struct sbdsp_softc *, int)); int sbdsp_set_io_params __P((struct sbdsp_softc *, struct audio_params *)); +void sbdsp_mulaw_expand __P((void *, u_char *, int)); +void sbdsp_mulaw_compress __P((void *, u_char *, int)); #ifdef AUDIO_DEBUG void sb_printsc __P((struct sbdsp_softc *)); @@ -397,62 +400,78 @@ sbdsp_set_io_params(sc, p) return (0); } +void +sbdsp_mulaw_expand(v, p, cc) + void *v; + u_char *p; + int cc; +{ + mulaw_to_ulinear8(p, cc); +} + +void +sbdsp_mulaw_compress(v, p, cc) + void *v; + u_char *p; + int cc; +{ + ulinear8_to_mulaw(p, cc); +} + int -sbdsp_set_in_params(addr, p) +sbdsp_set_params(addr, mode, p, q) void *addr; - struct audio_params *p; + int mode; + struct audio_params *p, *q; { register struct sbdsp_softc *sc = addr; - int error; + int error, rate; error = sbdsp_set_io_params(sc, p); if (error) return error; - if (ISSB16CLASS(sc)) - error = sbdsp16_setrate(sc, p->sample_rate, SB_INPUT_RATE, &sc->sc_irate); - else - error = sbdsp_srtotc(sc, p->sample_rate, SB_INPUT_RATE, &sc->sc_itc, &sc->sc_imode); + if (mode == AUMODE_RECORD) { + if (ISSB16CLASS(sc)) { + error = sbdsp16_setrate(sc, p->sample_rate, SB_INPUT_RATE, + &sc->sc_irate); + rate = sc->sc_irate; + } else { + error = sbdsp_srtotc(sc, p->sample_rate, SB_INPUT_RATE, + &sc->sc_itc, &sc->sc_imode); + rate = sbdsp_tctosr(sc, sc->sc_itc); + } + } else { + if (ISSB16CLASS(sc)) { + error = sbdsp16_setrate(sc, p->sample_rate, SB_OUTPUT_RATE, + &sc->sc_orate); + rate = sc->sc_orate; + } else { + error = sbdsp_srtotc(sc, p->sample_rate, SB_OUTPUT_RATE, + &sc->sc_otc, &sc->sc_omode); + rate = sbdsp_tctosr(sc, sc->sc_otc); + } + } if (error) return error; sc->sc_precision = p->precision; sc->sc_channels = p->channels; - if (ISSB16CLASS(sc)) - p->sample_rate = sc->sc_irate; - else - p->sample_rate = sbdsp_tctosr(sc, sc->sc_itc); + + p->sample_rate = rate; + if (p->encoding == AUDIO_ENCODING_ULAW) { + p->sw_code = mode == AUMODE_PLAY ? + sbdsp_mulaw_expand : sbdsp_mulaw_compress; + } else + p->sw_code = 0; + + /* Update setting for the other mode. */ + q->encoding = p->encoding; + q->channels = p->channels; + q->precision = p->precision; return 0; } -int -sbdsp_set_out_params(addr, p) - void *addr; - struct audio_params *p; -{ - register struct sbdsp_softc *sc = addr; - int error; - - error = sbdsp_set_io_params(sc, p); - if (error) - return error; - - if (ISSB16CLASS(sc)) - error = sbdsp16_setrate(sc, p->sample_rate, SB_OUTPUT_RATE, &sc->sc_orate); - else - error = sbdsp_srtotc(sc, p->sample_rate, SB_OUTPUT_RATE, &sc->sc_otc, &sc->sc_omode); - if (error) - return error; - - sc->sc_precision = p->precision; - sc->sc_channels = p->channels; - if (ISSB16CLASS(sc)) - p->sample_rate = sc->sc_orate; - else - p->sample_rate = sbdsp_tctosr(sc, sc->sc_otc); - return 0; -} - int sbdsp_set_ifilter(addr, which) void *addr; diff --git a/sys/dev/isa/sbdspvar.h b/sys/dev/isa/sbdspvar.h index 48b46562f4d6..abb0a4d933e2 100644 --- a/sys/dev/isa/sbdspvar.h +++ b/sys/dev/isa/sbdspvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: sbdspvar.h,v 1.19 1997/04/29 21:01:40 augustss Exp $ */ +/* $NetBSD: sbdspvar.h,v 1.20 1997/05/09 22:16:42 augustss Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -162,8 +162,7 @@ int sbdsp_get_out_gain __P((void *)); int sbdsp_set_monitor_gain __P((void *, u_int)); int sbdsp_get_monitor_gain __P((void *)); int sbdsp_query_encoding __P((void *, struct audio_encoding *)); -int sbdsp_set_out_params __P((void *, struct audio_params *)); -int sbdsp_set_in_params __P((void *, struct audio_params *)); +int sbdsp_set_params __P((void *, int, struct audio_params *, struct audio_params *)); int sbdsp_set_ifilter __P((void *, int)); int sbdsp_get_ifilter __P((void *)); int sbdsp_round_blocksize __P((void *, int)); diff --git a/sys/dev/isa/wss.c b/sys/dev/isa/wss.c index 88ae5ecc2b19..d9ebbcbf4f13 100644 --- a/sys/dev/isa/wss.c +++ b/sys/dev/isa/wss.c @@ -1,4 +1,4 @@ -/* $NetBSD: wss.c,v 1.24 1997/05/07 18:51:49 augustss Exp $ */ +/* $NetBSD: wss.c,v 1.25 1997/05/09 22:16:43 augustss Exp $ */ /* * Copyright (c) 1994 John Brezak @@ -163,16 +163,13 @@ struct audio_hw_if wss_hw_if = { ad1848_close, NULL, ad1848_query_encoding, - ad1848_set_out_params, - ad1848_set_in_params, + ad1848_set_params, ad1848_round_blocksize, wss_set_out_port, wss_get_out_port, wss_set_in_port, wss_get_in_port, ad1848_commit_settings, - NULL, - NULL, ad1848_dma_output, ad1848_dma_input, ad1848_halt_out_dma, diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c index c20a173ef406..ee8edcfba0dc 100644 --- a/sys/dev/mulaw.c +++ b/sys/dev/mulaw.c @@ -34,6 +34,7 @@ #include #include +#include #include static u_char mulawtolin[256] = { @@ -107,48 +108,67 @@ static u_char lintomulaw[256] = { }; void -mulaw_compress(hdl, e, p, cc) - void *hdl; - int e; +mulaw_to_ulinear8(p, cc) u_char *p; int cc; { - u_char *tab; - - switch (e) { - case AUDIO_ENCODING_ULAW: - tab = lintomulaw; - break; - default: - return; - } - while (--cc >= 0) { - *p = tab[*p]; + *p = mulawtolin[*p]; ++p; } } void -mulaw_expand(hdl, e, p, cc) - void *hdl; - int e; +ulinear8_to_mulaw(p, cc) u_char *p; int cc; { - u_char *tab; - - switch (e) { - case AUDIO_ENCODING_ULAW: - tab = mulawtolin; - break; - default: - return; - } - while (--cc >= 0) { - *p = tab[*p]; + *p = lintomulaw[*p]; ++p; } } +void +change_sign8(p, cc) + u_char *p; + int cc; +{ + while (--cc >= 0) { + *p = *p ^ 0x80; + ++p; + } +} + +void +change_sign16(p, cc) + u_char *p; + int cc; +{ +#if BYTE_ORDER == LITTLE_ENDIAN + while ((cc -=2) >= 0) { + p[1] = p[1] ^ 0x80; + p += 2; + } +#else + while ((cc -=2) >= 0) { + *p = *p ^ 0x80; + p += 2; + } +#endif +} + +void +swap_bytes(p, cc) + u_char *p; + int cc; +{ + u_char t; + + while ((cc -=2) >= 0) { + t = p[0]; + p[0] = p[1]; + p[1] = t; + p += 2; + } +} diff --git a/sys/dev/mulaw.h b/sys/dev/mulaw.h index ec93ea3d17b3..21c848630554 100644 --- a/sys/dev/mulaw.h +++ b/sys/dev/mulaw.h @@ -1,4 +1,4 @@ -/* $NetBSD: mulaw.h,v 1.2 1996/02/27 22:29:42 jtc Exp $ */ +/* $NetBSD: mulaw.h,v 1.3 1997/05/09 22:16:33 augustss Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -36,8 +36,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* - * Convert 8-bit mu-law to/from 8 bit unsigned linear (PCM8) - */ -extern void mulaw_compress __P((void *hw_hdl, int encoding, unsigned char *buf, int cnt)); -extern void mulaw_expand __P((void *hw_hdl, int encoding, unsigned char *buf, int cnt)); +/* Convert 8-bit mu-law to/from 8 bit unsigned linear. */ +extern void mulaw_to_ulinear8 __P((u_char *buf, int cnt)); +extern void ulinear8_to_mulaw __P((u_char *buf, int cnt)); +/* Convert between signed and unsigned. */ +extern void change_sign8 __P((u_char *buf, int cnt)); +extern void change_sign16 __P((u_char *buf, int cnt)); +/* Convert between little and big endian. */ +extern void swap_bytes __P((u_char *buf, int cnt));