From 1657931791df6f774accbb48ba9d42eac31d77d9 Mon Sep 17 00:00:00 2001 From: jakemsr Date: Thu, 15 Jul 2010 03:43:11 +0000 Subject: [PATCH] add two new members to structs audio_encoding and audio_prinfo. for both structs, the new members are 'bps' and 'msb', which describe the number of bytes per sample and data alignment in the sample, respectively. drivers must properly set these fields in the 'query_encoding', 'set_parameters' and 'get_default_params' hardware interface methods. discussed with ratchov, deraadt --- lib/libsndio/sun.c | 14 +++--- share/man/man4/audio.4 | 24 ++++++---- share/man/man9/audio.9 | 6 ++- sys/arch/hppa/gsc/harmony.c | 10 +++- sys/arch/macppc/dev/awacs.c | 7 ++- sys/arch/macppc/dev/i2s.c | 9 +++- sys/arch/sgi/dev/mavb.c | 12 ++++- sys/arch/sparc/dev/amd7930.c | 17 ++++--- sys/arch/sparc/dev/cs4231.c | 7 ++- sys/arch/sparc64/dev/ce4231.c | 7 ++- sys/arch/zaurus/dev/zaurus_audio.c | 27 +++++++---- sys/dev/audio.c | 75 +++++++++++++++++++++--------- sys/dev/audio_if.h | 6 ++- sys/dev/bluetooth/btsco.c | 7 ++- sys/dev/ic/ac97.c | 4 +- sys/dev/isa/ad1848.c | 9 +++- sys/dev/isa/ess.c | 23 +++++---- sys/dev/isa/gus.c | 8 +++- sys/dev/isa/sbdsp.c | 34 +++++++++----- sys/dev/pci/auacer.c | 24 ++++++---- sys/dev/pci/auglx.c | 26 +++++++---- sys/dev/pci/auich.c | 27 +++++++---- sys/dev/pci/auixp.c | 26 +++++++---- sys/dev/pci/autri.c | 6 ++- sys/dev/pci/auvia.c | 28 +++++++---- sys/dev/pci/azalia.c | 8 +++- sys/dev/pci/cmpci.c | 9 +++- sys/dev/pci/cs4280.c | 7 ++- sys/dev/pci/cs4281.c | 7 ++- sys/dev/pci/eap.c | 24 ++++++---- sys/dev/pci/emuxki.c | 7 ++- sys/dev/pci/envy.c | 8 +++- sys/dev/pci/esa.c | 31 ++++++------ sys/dev/pci/eso.c | 8 +++- sys/dev/pci/fms.c | 28 +++++++---- sys/dev/pci/maestro.c | 21 +++++---- sys/dev/pci/neo.c | 25 ++++++---- sys/dev/pci/sv.c | 25 ++++++---- sys/dev/pci/yds.c | 24 ++++++---- sys/dev/sbus/cs4231.c | 8 +++- sys/dev/usb/uaudio.c | 30 ++++++++---- sys/sys/audioio.h | 6 ++- usr.bin/audioctl/audioctl.c | 10 ++-- 43 files changed, 505 insertions(+), 224 deletions(-) diff --git a/lib/libsndio/sun.c b/lib/libsndio/sun.c index 962a0d3063e..9f603d890d6 100644 --- a/lib/libsndio/sun.c +++ b/lib/libsndio/sun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sun.c,v 1.37 2010/05/25 06:49:13 ratchov Exp $ */ +/* $OpenBSD: sun.c,v 1.38 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -88,9 +88,9 @@ static struct sio_ops sun_ops = { static int sun_infotoenc(struct sun_hdl *hdl, struct audio_prinfo *ai, struct sio_par *par) { - par->msb = 1; + par->msb = ai->msb; par->bits = ai->precision; - par->bps = SIO_BPS(par->bits); + par->bps = ai->bps; switch (ai->encoding) { case AUDIO_ENCODING_SLINEAR_LE: par->le = 1; @@ -267,8 +267,8 @@ sun_getcap(struct sio_hdl *sh, struct sio_cap *cap) continue; } cap->enc[nenc].bits = ae.precision; - cap->enc[nenc].bps = SIO_BPS(ae.precision); - cap->enc[nenc].msb = 1; + cap->enc[nenc].bps = ae.bps; + cap->enc[nenc].msb = ae.msb; enc_map |= (1 << nenc); nenc++; } @@ -639,9 +639,9 @@ sun_setpar(struct sio_hdl *sh, struct sio_par *par) return 0; } ibpf = (hdl->sio.mode & SIO_REC) ? - aui.record.channels * SIO_BPS(aui.record.precision) : 1; + aui.record.channels * aui.record.bps : 1; obpf = (hdl->sio.mode & SIO_PLAY) ? - aui.play.channels * SIO_BPS(aui.play.precision) : 1; + aui.play.channels * aui.play.bps : 1; DPRINTF("sun_setpar: bpf = (%u, %u)\n", ibpf, obpf); diff --git a/share/man/man4/audio.4 b/share/man/man4/audio.4 index ca3a7f993e8..3c880b259f7 100644 --- a/share/man/man4/audio.4 +++ b/share/man/man4/audio.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: audio.4,v 1.61 2009/06/27 14:28:39 jmc Exp $ +.\" $OpenBSD: audio.4,v 1.62 2010/07/15 03:43:11 jakemsr Exp $ .\" $NetBSD: audio.4,v 1.20 1998/05/28 17:27:15 augustss Exp $ .\" .\" Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 27 2009 $ +.Dd $Mdocdate: July 15 2010 $ .Dt AUDIO 4 .Os .Sh NAME @@ -239,6 +239,8 @@ typedef struct audio_encoding { char name[MAX_AUDIO_DEV_LEN]; /* name of encoding */ int encoding; /* value for encoding parameter */ int precision; /* value for precision parameter */ + int bps; /* value for bps parameter */ + int msb; /* value for msb parameter */ int flags; #define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */ } audio_encoding_t; @@ -388,6 +390,8 @@ struct audio_prinfo { u_int sample_rate; /* sample rate in bit/s */ u_int channels; /* number of channels, usually 1 or 2 */ u_int precision; /* number of bits/sample */ + u_int bps; /* number of bytes/sample */ + u_int msb; /* data alignment */ u_int encoding; /* data encoding (AUDIO_ENCODING_* below) */ u_int gain; /* volume level */ u_int port; /* selected I/O port */ @@ -443,13 +447,17 @@ unsigned linear encoding with big endian byte order The .Va precision parameter describes the number of bits of audio data per sample. -For sample formats such as 8, 16, and 32-bit, where the number of audio data -bits is a power of 2, +The +.Va bps +parameter describes the number of bytes of audio data per sample. +The +.Va msb +parameter describes the alignment of the data in the sample. +It is only meaningful when .Va precision -is also exactly the size of each sample. -For other sample formats the sample size is the smallest power of -2 bits that the data can fit into. -For example the sample size of 20 and 24-bit formats is 32 bits. +/ NBBY < +.Va bps . +A value of 1 means the data is aligned to the most significant bit. .Pp The .Va gain , diff --git a/share/man/man9/audio.9 b/share/man/man9/audio.9 index de6e8e98809..590ebb0f804 100644 --- a/share/man/man9/audio.9 +++ b/share/man/man9/audio.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: audio.9,v 1.21 2008/10/27 07:53:24 jmc Exp $ +.\" $OpenBSD: audio.9,v 1.22 2010/07/15 03:43:11 jakemsr Exp $ .\" $NetBSD: audio.9,v 1.14 2000/02/11 22:56:15 kleink Exp $ .\" .\" Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: October 27 2008 $ +.Dd $Mdocdate: July 15 2010 $ .Dt AUDIO 9 .Os .Sh NAME @@ -93,6 +93,8 @@ struct audio_params { u_long sample_rate; /* sample rate */ u_int encoding; /* mu-law, linear, etc */ u_int precision; /* bits/sample */ + u_int bps; /* bytes/sample */ + u_int msb; /* data alignment */ u_int channels; /* mono(1), stereo(2) */ /* Software en/decode functions, set if SW coding required by HW */ void (*sw_code)(void *, u_char *, int); diff --git a/sys/arch/hppa/gsc/harmony.c b/sys/arch/hppa/gsc/harmony.c index 8dc70d91c79..a9b6bf36fd7 100644 --- a/sys/arch/hppa/gsc/harmony.c +++ b/sys/arch/hppa/gsc/harmony.c @@ -1,4 +1,4 @@ -/* $OpenBSD: harmony.c,v 1.26 2008/04/21 00:32:42 jakemsr Exp $ */ +/* $OpenBSD: harmony.c,v 1.27 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 2003 Jason L. Wright (jason@thought.net) @@ -464,6 +464,8 @@ harmony_query_encoding(void *vsc, struct audio_encoding *fp) default: err = EINVAL; } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; return (err); } @@ -558,9 +560,13 @@ harmony_set_params(void *vsc, int setmode, int usemode, else return (EINVAL); - bits |= harmony_speed_bits(sc, &p->sample_rate); p->sw_code = pswcode; r->sw_code = rswcode; + p->bps = AUDIO_BPS(p->precision); + r->bps = AUDIO_BPS(r->precision); + p->msb = r->msb = 1; + + bits |= harmony_speed_bits(sc, &p->sample_rate); sc->sc_cntlbits = bits; sc->sc_need_commit = 1; diff --git a/sys/arch/macppc/dev/awacs.c b/sys/arch/macppc/dev/awacs.c index be1e2629dff..38cebed5e65 100644 --- a/sys/arch/macppc/dev/awacs.c +++ b/sys/arch/macppc/dev/awacs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: awacs.c,v 1.24 2008/10/30 06:22:38 todd Exp $ */ +/* $OpenBSD: awacs.c,v 1.25 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: awacs.c,v 1.4 2001/02/26 21:07:51 wiz Exp $ */ /*- @@ -549,6 +549,9 @@ awacs_query_encoding(void *h, struct audio_encoding *ae) default: return (EINVAL); } + ae->bps = AUDIO_BPS(ae->precision); + ae->msb = 1; + return (0); } @@ -653,6 +656,8 @@ awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play, default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } /* Set the speed */ diff --git a/sys/arch/macppc/dev/i2s.c b/sys/arch/macppc/dev/i2s.c index 0e3989d0ab8..a1cfd0a0081 100644 --- a/sys/arch/macppc/dev/i2s.c +++ b/sys/arch/macppc/dev/i2s.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i2s.c,v 1.17 2008/11/07 19:53:20 todd Exp $ */ +/* $OpenBSD: i2s.c,v 1.18 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: i2s.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */ /*- @@ -57,6 +57,8 @@ struct audio_params i2s_audio_default = { 44100, /* sample_rate */ AUDIO_ENCODING_SLINEAR_BE, /* encoding */ 16, /* precision */ + 2, /* bps */ + 1, /* msb */ 2, /* channels */ NULL, /* sw_code */ 1 /* factor */ @@ -308,6 +310,8 @@ i2s_query_encoding(h, ae) err = EINVAL; break; } + ae->bps = AUDIO_BPS(ae->precision); + ae->msb = 1; return (err); } @@ -457,6 +461,9 @@ i2s_set_params(h, setmode, usemode, play, rec) p->sample_rate = sc->sc_rate; + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; + return 0; } diff --git a/sys/arch/sgi/dev/mavb.c b/sys/arch/sgi/dev/mavb.c index 78deca07723..b6fe1327577 100644 --- a/sys/arch/sgi/dev/mavb.c +++ b/sys/arch/sgi/dev/mavb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mavb.c,v 1.12 2010/07/02 03:24:50 blambert Exp $ */ +/* $OpenBSD: mavb.c,v 1.13 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -262,6 +262,8 @@ mavb_query_encoding(void *hdl, struct audio_encoding *ae) default: return (EINVAL); } + ae->bps = AUDIO_BPS(ae->precision); + ae->msb = 1; return (0); } @@ -374,6 +376,8 @@ mavb_get_default_params(void *hdl, int mode, struct audio_params *p) p->sample_rate = 48000; p->encoding = AUDIO_ENCODING_SLINEAR_BE; p->precision = 16; + p->bps = 2; + p->msb = 1; p->channels = 2; p->factor = 2; if (mode == AUMODE_PLAY) @@ -535,6 +539,9 @@ mavb_set_params(void *hdl, int setmode, int usemode, error = mavb_set_play_format(sc, play->encoding); if (error) return (error); + + play->bps = AUDIO_BPS(play->precision); + play->msb = 1; } if (setmode & AUMODE_RECORD) { @@ -569,6 +576,9 @@ mavb_set_params(void *hdl, int setmode, int usemode, error = mavb_set_rec_format(sc, rec->encoding); if (error) return (error); + + rec->bps = AUDIO_BPS(rec->precision); + rec->msb = 1; } return (0); diff --git a/sys/arch/sparc/dev/amd7930.c b/sys/arch/sparc/dev/amd7930.c index 9c84d7fa035..410c123ead6 100644 --- a/sys/arch/sparc/dev/amd7930.c +++ b/sys/arch/sparc/dev/amd7930.c @@ -1,4 +1,4 @@ -/* $OpenBSD: amd7930.c,v 1.32 2009/04/10 20:53:51 miod Exp $ */ +/* $OpenBSD: amd7930.c,v 1.33 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: amd7930.c,v 1.37 1998/03/30 14:23:40 pk Exp $ */ /* @@ -389,12 +389,13 @@ amd7930_set_params(addr, setmode, usemode, p, r) int setmode, usemode; struct audio_params *p, *r; { - 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; /* no other rates supported by amd chip */ + p->encoding = AUDIO_ENCODING_ULAW; + p->precision = 8; + p->bps = 1; + p->msb = 1; + p->channels = 1; + /* no other rates supported by amd chip */ + p->sample_rate = 8000; return (0); } @@ -409,6 +410,8 @@ amd7930_query_encoding(addr, fp) strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; + fp->bps = 1; + fp->msb = 1; fp->flags = 0; break; default: diff --git a/sys/arch/sparc/dev/cs4231.c b/sys/arch/sparc/dev/cs4231.c index bb5671f33e6..830871b3820 100644 --- a/sys/arch/sparc/dev/cs4231.c +++ b/sys/arch/sparc/dev/cs4231.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4231.c,v 1.28 2010/06/18 23:47:24 miod Exp $ */ +/* $OpenBSD: cs4231.c,v 1.29 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -645,6 +645,8 @@ cs4231_query_encoding(addr, fp) default: err = EINVAL; } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; return (err); } @@ -735,6 +737,9 @@ cs4231_set_params(addr, setmode, usemode, p, r) p->sw_code = pswcode; r->sw_code = rswcode; + p->bps = AUDIO_BPS(p->precision); + r->bps = AUDIO_BPS(r->precision); + p->msb = r->msb = 1; sc->sc_format_bits = bits; sc->sc_channels = p->channels; diff --git a/sys/arch/sparc64/dev/ce4231.c b/sys/arch/sparc64/dev/ce4231.c index 9a16ed0e114..93f9cab66bf 100644 --- a/sys/arch/sparc64/dev/ce4231.c +++ b/sys/arch/sparc64/dev/ce4231.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ce4231.c,v 1.25 2010/02/22 00:43:30 jakemsr Exp $ */ +/* $OpenBSD: ce4231.c,v 1.26 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -694,6 +694,8 @@ ce4231_query_encoding(addr, fp) default: err = EINVAL; } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; return (err); } @@ -780,6 +782,9 @@ ce4231_set_params(addr, setmode, usemode, p, r) p->sw_code = pswcode; r->sw_code = rswcode; + p->bps = AUDIO_BPS(p->precision); + r->bps = AUDIO_BPS(r->precision); + p->msb = r->msb = 1; sc->sc_format_bits = bits; sc->sc_channels = p->channels; diff --git a/sys/arch/zaurus/dev/zaurus_audio.c b/sys/arch/zaurus/dev/zaurus_audio.c index f50d886e759..5c21453d590 100644 --- a/sys/arch/zaurus/dev/zaurus_audio.c +++ b/sys/arch/zaurus/dev/zaurus_audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_audio.c,v 1.10 2008/04/21 00:32:42 jakemsr Exp $ */ +/* $OpenBSD: zaurus_audio.c,v 1.11 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 2005 Christopher Pascoe @@ -492,52 +492,55 @@ zaudio_query_encoding(void *hdl, struct audio_encoding *aep) aep->encoding = AUDIO_ENCODING_ULINEAR; aep->precision = 8; aep->flags = 0; - return (0); + break; case 1: strlcpy(aep->name, AudioEmulaw, sizeof(aep->name)); aep->encoding = AUDIO_ENCODING_ULAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(aep->name, AudioEalaw, sizeof(aep->name)); aep->encoding = AUDIO_ENCODING_ALAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(aep->name, AudioEslinear, sizeof(aep->name)); aep->encoding = AUDIO_ENCODING_SLINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(aep->name, AudioEslinear_le, sizeof(aep->name)); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; - return (0); + break; case 5: strlcpy(aep->name, AudioEulinear_le, sizeof(aep->name)); aep->encoding = AUDIO_ENCODING_ULINEAR_LE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(aep->name, AudioEslinear_be, sizeof(aep->name)); aep->encoding = AUDIO_ENCODING_SLINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(aep->name, AudioEulinear_be, sizeof(aep->name)); aep->encoding = AUDIO_ENCODING_ULINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + aep->bps = AUDIO_BPS(aep->precision); + aep->msb = 1; + return (0); } int @@ -716,6 +719,9 @@ zaudio_set_params(void *hdl, int setmode, int usemode, return (EINVAL); } + play->bps = AUDIO_BPS(play->precision); + play->msb = 1; + pxa2x0_i2s_setspeed(&sc->sc_i2s, &play->sample_rate); } @@ -752,6 +758,9 @@ zaudio_set_params(void *hdl, int setmode, int usemode, return (EINVAL); } + rec->bps = AUDIO_BPS(rec->precision); + rec->msb = 1; + pxa2x0_i2s_setspeed(sc, &rec->sample_rate); } #endif diff --git a/sys/dev/audio.c b/sys/dev/audio.c index e3244dc6997..91fdddd069e 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audio.c,v 1.107 2009/11/09 17:53:39 nicm Exp $ */ +/* $OpenBSD: audio.c,v 1.108 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: audio.c,v 1.119 1999/11/09 16:50:47 augustss Exp $ */ /* @@ -100,8 +100,6 @@ int audiodebug = 0; #define ROUNDSIZE(x) x &= -16 /* round to nice boundary */ -#define AUDIO_BPS(bits) ((bits) <= 8 ? 1 : (((bits) <= 16) ? 2 : 4)) - int audio_blk_ms = AUDIO_BLK_MS; int audiosetinfo(struct audio_softc *, struct audio_info *); @@ -218,7 +216,7 @@ int au_portof(struct audio_softc *, char *); /* The default audio mode: 8 kHz mono ulaw */ struct audio_params audio_default = - { 8000, AUDIO_ENCODING_ULAW, 8, 1, 0, 1 }; + { 8000, AUDIO_ENCODING_ULAW, 8, 1, 1, 1, 0, 1 }; struct cfattach audio_ca = { sizeof(struct audio_softc), audioprobe, audioattach, @@ -568,8 +566,8 @@ audio_printsc(struct audio_softc *sc) void audio_print_params(char *s, struct audio_params *p) { - printf("audio: %s sr=%ld, enc=%d, chan=%d, prec=%d\n", s, - p->sample_rate, p->encoding, p->channels, p->precision); + printf("audio: %s sr=%ld, enc=%d, chan=%d, prec=%d bps=%d\n", s, + p->sample_rate, p->encoding, p->channels, p->precision, p->bps); } #endif @@ -891,7 +889,7 @@ audio_initbufs(struct audio_softc *sc) sc->sc_pnintr = 0; sc->sc_pblktime = (u_long)( (u_long)sc->sc_pr.blksize * 100000 / - (u_long)(AUDIO_BPS(sc->sc_pparams.precision) * + (u_long)(sc->sc_pparams.bps * sc->sc_pparams.channels * sc->sc_pparams.sample_rate)) * 10; DPRINTF(("audio: play blktime = %lu for %d\n", @@ -899,7 +897,7 @@ audio_initbufs(struct audio_softc *sc) sc->sc_rnintr = 0; sc->sc_rblktime = (u_long)( (u_long)sc->sc_rr.blksize * 100000 / - (u_long)(AUDIO_BPS(sc->sc_rparams.precision) * + (u_long)(sc->sc_rparams.bps * sc->sc_rparams.channels * sc->sc_rparams.sample_rate)) * 10; DPRINTF(("audio: record blktime = %lu for %d\n", @@ -1041,11 +1039,15 @@ audio_open(dev_t dev, struct audio_softc *sc, int flags, int ifmt, ai.record.encoding = sc->sc_rparams.encoding; ai.record.channels = sc->sc_rparams.channels; ai.record.precision = sc->sc_rparams.precision; + ai.record.bps = sc->sc_rparams.bps; + ai.record.msb = sc->sc_rparams.msb; ai.record.pause = 0; ai.play.sample_rate = sc->sc_pparams.sample_rate; - ai.play.encoding = sc->sc_pparams.encoding; + ai.play.encoding = sc->sc_pparams.encoding; ai.play.channels = sc->sc_pparams.channels; ai.play.precision = sc->sc_pparams.precision; + ai.play.bps = sc->sc_pparams.bps; + ai.play.msb = sc->sc_pparams.msb; ai.play.pause = 0; ai.mode = mode; sc->sc_rr.blkset = sc->sc_pr.blkset = 0; /* Block sizes not set yet */ @@ -1351,7 +1353,7 @@ audio_set_blksize(struct audio_softc *sc, int mode, int fpb) { rb = &sc->sc_rr; } - fs = parm->channels * AUDIO_BPS(parm->precision); + fs = parm->channels * parm->bps; bs = fpb * fs; maxbs = rb->bufsize / 2; if (bs > maxbs) @@ -1387,7 +1389,7 @@ void audio_fill_silence(struct audio_params *params, u_char *start, u_char *p, int n) { size_t rounderr; - int i, samplesz, nsamples; + int i, nsamples; u_char auzero[4] = {0, 0, 0, 0}; /* @@ -1395,11 +1397,10 @@ audio_fill_silence(struct audio_params *params, u_char *start, u_char *p, int n) * beginning of the sample, so we overwrite partially written * ones. */ - samplesz = AUDIO_BPS(params->precision); - rounderr = (p - start) % samplesz; + rounderr = (p - start) % params->bps; p -= rounderr; n += rounderr; - nsamples = n / samplesz; + nsamples = n / params->bps; switch (params->encoding) { case AUDIO_ENCODING_SLINEAR_LE: @@ -1412,10 +1413,16 @@ audio_fill_silence(struct audio_params *params, u_char *start, u_char *p, int n) auzero[0] = 0x55; break; case AUDIO_ENCODING_ULINEAR_LE: - auzero[samplesz - 1] = 0x80; + if (params->msb == 1) + auzero[params->bps - 1] = 0x80; + else + auzero[params->bps - 1] = 1 << ((params->precision + 7) % NBBY); break; case AUDIO_ENCODING_ULINEAR_BE: - auzero[0] = 0x80; + if (params->msb == 1) + auzero[0] = 0x80; + else + auzero[0] = 1 << ((params->precision + 7) % NBBY); break; case AUDIO_ENCODING_MPEG_L1_STREAM: case AUDIO_ENCODING_MPEG_L1_PACKETS: @@ -1430,7 +1437,7 @@ audio_fill_silence(struct audio_params *params, u_char *start, u_char *p, int n) break; } while (--nsamples >= 0) { - for (i = 0; i < samplesz; i++) + for (i = 0; i < params->bps; i++) *p++ = auzero[i]; } } @@ -1617,18 +1624,18 @@ audio_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) * original formula: * sc->sc_rr.drops / * sc->sc_rparams.factor / - * (sc->sc_rparams.channels * AUDIO_BPS(sc->sc_rparams.precision)) + * (sc->sc_rparams.channels * sc->sc_rparams.bps) */ case AUDIO_RERROR: *(int *)addr = sc->sc_rr.drops / (sc->sc_rparams.factor * sc->sc_rparams.channels * - AUDIO_BPS(sc->sc_rparams.precision)); + sc->sc_rparams.bps); break; case AUDIO_PERROR: *(int *)addr = sc->sc_pr.drops / (sc->sc_pparams.factor * sc->sc_pparams.channels * - AUDIO_BPS(sc->sc_pparams.precision)); + sc->sc_pparams.bps); break; /* @@ -2603,6 +2610,22 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai) rp.precision = r->precision; nr++; } + if (p->bps != ~0) { + pp.bps = p->bps; + np++; + } + if (r->bps != ~0) { + rp.bps = r->bps; + nr++; + } + if (p->msb != ~0) { + pp.msb = p->msb; + np++; + } + if (r->msb != ~0) { + rp.msb = r->msb; + nr++; + } if (p->channels != ~0) { pp.channels = p->channels; np++; @@ -2669,11 +2692,15 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai) pp.encoding = rp.encoding; pp.channels = rp.channels; pp.precision = rp.precision; + pp.bps = rp.bps; + pp.msb = rp.msb; } else if (setmode == AUMODE_PLAY) { rp.sample_rate = pp.sample_rate; rp.encoding = pp.encoding; rp.channels = pp.channels; rp.precision = pp.precision; + rp.bps = pp.bps; + rp.msb = pp.msb; } } sc->sc_rparams = rp; @@ -2711,7 +2738,7 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai) if (r->block_size == ~0 || r->block_size == 0) { fpb = rp.sample_rate * audio_blk_ms / 1000; } else { - fs = rp.channels * AUDIO_BPS(rp.precision); + fs = rp.channels * rp.bps; fpb = (r->block_size * rp.factor) / fs; } if (sc->sc_rr.blkset == 0) @@ -2721,7 +2748,7 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai) if (p->block_size == ~0 || p->block_size == 0) { fpb = pp.sample_rate * audio_blk_ms / 1000; } else { - fs = pp.channels * AUDIO_BPS(pp.precision); + fs = pp.channels * pp.bps; fpb = (p->block_size * pp.factor) / fs; } if (sc->sc_pr.blkset == 0) @@ -2894,6 +2921,10 @@ audiogetinfo(struct audio_softc *sc, struct audio_info *ai) r->channels = sc->sc_rparams.channels; p->precision = sc->sc_pparams.precision; r->precision = sc->sc_rparams.precision; + p->bps = sc->sc_pparams.bps; + r->bps = sc->sc_rparams.bps; + p->msb = sc->sc_pparams.msb; + r->msb = sc->sc_rparams.msb; p->encoding = sc->sc_pparams.encoding; r->encoding = sc->sc_rparams.encoding; diff --git a/sys/dev/audio_if.h b/sys/dev/audio_if.h index 1e3164f6861..5557edd3067 100644 --- a/sys/dev/audio_if.h +++ b/sys/dev/audio_if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: audio_if.h,v 1.26 2008/04/21 00:32:42 jakemsr Exp $ */ +/* $OpenBSD: audio_if.h,v 1.27 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: audio_if.h,v 1.24 1998/01/10 14:07:25 tv Exp $ */ /* @@ -38,6 +38,8 @@ #ifndef _SYS_DEV_AUDIO_IF_H_ #define _SYS_DEV_AUDIO_IF_H_ +#define AUDIO_BPS(bits) (bits) <= 8 ? 1 : ((bits) <= 16 ? 2 : 4) + /* * Generic interface to hardware driver. */ @@ -52,6 +54,8 @@ struct audio_params { u_long sample_rate; /* sample rate */ u_int encoding; /* mu-law, linear, etc */ u_int precision; /* bits/sample */ + u_int bps; /* bytes/sample */ + u_int msb; /* data alignment */ u_int channels; /* mono(1), stereo(2) */ /* Software en/decode functions, set if SW coding required by HW */ void (*sw_code)(void *, u_char *, int); diff --git a/sys/dev/bluetooth/btsco.c b/sys/dev/bluetooth/btsco.c index c0f2df5c0bb..513823652cf 100644 --- a/sys/dev/bluetooth/btsco.c +++ b/sys/dev/bluetooth/btsco.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btsco.c,v 1.4 2008/11/25 18:29:27 todd Exp $ */ +/* $OpenBSD: btsco.c,v 1.5 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: btsco.c,v 1.22 2008/08/06 15:01:23 plunky Exp $ */ /*- @@ -732,10 +732,11 @@ btsco_query_encoding(void *hdl, struct audio_encoding *ae) ae->precision = 16; ae->flags = 0; break; - default: err = EINVAL; } + ae->bps = AUDIO_BPS(ae->precision); + ae->msb = 1; return err; } @@ -769,6 +770,8 @@ btsco_set_params(void *hdl, int setmode, int usemode, p->sample_rate = 8000; p->encoding = AUDIO_ENCODING_SLINEAR_LE; p->precision = 16; + p->bps = 2; + p->msb = 1; p->channels = 1; } return 0; diff --git a/sys/dev/ic/ac97.c b/sys/dev/ic/ac97.c index f90c3cd3cbb..d86cd54d70c 100644 --- a/sys/dev/ic/ac97.c +++ b/sys/dev/ic/ac97.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ac97.c,v 1.72 2010/02/25 21:22:42 ratchov Exp $ */ +/* $OpenBSD: ac97.c,v 1.73 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 1999, 2000 Constantine Sapuntzakis @@ -76,6 +76,8 @@ const struct audio_params ac97_audio_default = { 48000, /* sample_rate */ AUDIO_ENCODING_SLINEAR_LE, /* encoding */ 16, /* precision */ + 2, /* bps */ + 1, /* msb */ 2, /* channels */ NULL, /* sw_code */ 1 /* factor */ diff --git a/sys/dev/isa/ad1848.c b/sys/dev/isa/ad1848.c index 815928a44f6..5d46684d965 100644 --- a/sys/dev/isa/ad1848.c +++ b/sys/dev/isa/ad1848.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ad1848.c,v 1.34 2010/06/30 11:21:35 jakemsr Exp $ */ +/* $OpenBSD: ad1848.c,v 1.35 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: ad1848.c,v 1.45 1998/01/30 02:02:38 augustss Exp $ */ /* @@ -1014,6 +1014,9 @@ ad1848_query_encoding(addr, fp) return EINVAL; /*NOTREACHED*/ } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + return (0); } @@ -1101,6 +1104,10 @@ ad1848_set_params(addr, setmode, usemode, p, r) p->sw_code = pswcode; r->sw_code = rswcode; + p->bps = AUDIO_BPS(p->precision); + r->bps = AUDIO_BPS(r->precision); + p->msb = 1; + r->msb = 1; sc->format_bits = bits; sc->channels = p->channels; diff --git a/sys/dev/isa/ess.c b/sys/dev/isa/ess.c index fd54aa49b50..c285986ee03 100644 --- a/sys/dev/isa/ess.c +++ b/sys/dev/isa/ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ess.c,v 1.15 2010/06/30 20:39:02 blambert Exp $ */ +/* $OpenBSD: ess.c,v 1.16 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: ess.c,v 1.44.4.1 1999/06/21 01:18:00 thorpej Exp $ */ /* @@ -1141,52 +1141,55 @@ ess_query_encoding(addr, fp) fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; - return (0); + break; case 1: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; - return (0); + break; case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return (0); + break; case 5: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; - return (0); + break; case 6: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return EINVAL; } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + return (0); } @@ -1266,6 +1269,8 @@ ess_set_params(addr, setmode, usemode, play, rec) default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } if (usemode == AUMODE_RECORD) diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index f71de03e445..b370c587cf0 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gus.c,v 1.33 2009/08/26 22:29:09 jasper Exp $ */ +/* $OpenBSD: gus.c,v 1.34 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -1573,6 +1573,9 @@ gus_set_params(addr, setmode, usemode, p, r) r->sw_code = p->sw_code = swap_bytes; break; } + p->bps = AUDIO_BPS(p->precision); + r->bps = AUDIO_BPS(r->precision); + p->msb = r->msb = 1; return 0; } @@ -3310,6 +3313,9 @@ gus_query_encoding(addr, fp) return(EINVAL); /*NOTREACHED*/ } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + return (0); } diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index e2f0176e97b..32d63f06567 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdsp.c,v 1.30 2010/04/03 23:22:42 jakemsr Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.31 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -451,7 +451,7 @@ sbdsp_query_encoding(addr, fp) struct audio_encoding *fp; { struct sbdsp_softc *sc = addr; - int emul; + int emul, found = 0; emul = ISSB16CLASS(sc) ? 0 : AUDIO_ENCODINGFLAG_EMULATED; @@ -461,27 +461,35 @@ sbdsp_query_encoding(addr, fp) fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; - return 0; + found = 1; + break; case 1: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + found = 1; + break; case 2: strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + found = 1; + break; case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = emul; - return 0; + found = 1; + break; } - if (!ISSB16CLASS(sc) && sc->sc_model != SB_JAZZ) + if (found) { + fp->bps = 1; + fp->msb = 1; + return 0; + } else if (!ISSB16CLASS(sc) && sc->sc_model != SB_JAZZ) return EINVAL; switch(fp->index) { @@ -490,28 +498,30 @@ sbdsp_query_encoding(addr, fp) fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return 0; + break; case 5: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = emul; - return 0; + break; case 6: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 7: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; default: return EINVAL; } + fp->bps = 2; + fp->msb = 1; return 0; } @@ -737,6 +747,8 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) p->sw_code = swcode; p->factor = factor; + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; 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)); diff --git a/sys/dev/pci/auacer.c b/sys/dev/pci/auacer.c index c81adfe8b21..f36d9a3957d 100644 --- a/sys/dev/pci/auacer.c +++ b/sys/dev/pci/auacer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auacer.c,v 1.6 2010/04/08 00:23:53 tedu Exp $ */ +/* $OpenBSD: auacer.c,v 1.7 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: auacer.c,v 1.3 2004/11/10 04:20:26 kent Exp $ */ /*- @@ -461,52 +461,56 @@ auacer_query_encoding(void *v, struct audio_encoding *aep) aep->encoding = AUDIO_ENCODING_ULINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 1: strlcpy(aep->name, AudioEmulaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(aep->name, AudioEalaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ALAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(aep->name, AudioEslinear, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; - return (0); + break; case 5: strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_LE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + aep->bps = AUDIO_BPS(aep->precision); + aep->msb = 1; + + return (0); } int @@ -646,6 +650,8 @@ auacer_set_params(void *v, int setmode, int usemode, struct audio_params *play, default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; if (AC97_IS_FIXED_RATE(sc->codec_if)) p->sample_rate = AC97_SINGLE_RATE; diff --git a/sys/dev/pci/auglx.c b/sys/dev/pci/auglx.c index b5159624a08..6e22cb94258 100644 --- a/sys/dev/pci/auglx.c +++ b/sys/dev/pci/auglx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auglx.c,v 1.3 2010/04/20 22:05:43 tedu Exp $ */ +/* $OpenBSD: auglx.c,v 1.4 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 2008 Marc Balmer @@ -497,52 +497,56 @@ auglx_query_encoding(void *v, struct audio_encoding *aep) aep->encoding = AUDIO_ENCODING_ULINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 1: strlcpy(aep->name, AudioEmulaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 2: strlcpy(aep->name, AudioEalaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ALAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 3: strlcpy(aep->name, AudioEslinear, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; - return 0; + break; case 5: strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_LE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 6: strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 7: strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; default: return EINVAL; } + aep->bps = AUDIO_BPS(aep->precision); + aep->msb = 1; + + return 0; } @@ -725,6 +729,8 @@ auglx_set_params(void *v, int setmode, int usemode, struct audio_params *play, default: return EINVAL; } + play->bps = AUDIO_BPS(play->precision); + play->msb = 1; orate = adj_rate = play->sample_rate; @@ -900,6 +906,8 @@ auglx_set_params(void *v, int setmode, int usemode, struct audio_params *play, default: return EINVAL; } + rec->bps = AUDIO_BPS(rec->precision); + rec->msb = 1; orate = rec->sample_rate; error = ac97_set_rate(sc->codec_if, AC97_REG_PCM_LR_ADC_RATE, diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c index c2b0db58dea..abbc9533477 100644 --- a/sys/dev/pci/auich.c +++ b/sys/dev/pci/auich.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auich.c,v 1.82 2010/06/07 23:35:24 ratchov Exp $ */ +/* $OpenBSD: auich.c,v 1.83 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 2000,2001 Michael Shalayeff @@ -685,6 +685,8 @@ auich_query_encoding(v, aep) aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; + aep->bps = 2; + aep->msb = 1; return (0); default: return (EINVAL); @@ -696,52 +698,55 @@ auich_query_encoding(v, aep) aep->encoding = AUDIO_ENCODING_ULINEAR; aep->precision = 8; aep->flags = 0; - return (0); + break; case 1: strlcpy(aep->name, AudioEmulaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(aep->name, AudioEalaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ALAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(aep->name, AudioEslinear, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; - return (0); + break; case 5: strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_LE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + aep->bps = AUDIO_BPS(aep->precision); + aep->msb = 1; + return (0); } } @@ -960,6 +965,8 @@ auich_set_params(v, setmode, usemode, play, rec) default: return (EINVAL); } + play->bps = AUDIO_BPS(play->precision); + play->msb = 1; orate = adj_rate = play->sample_rate; if (sc->sc_ac97rate != 0) @@ -1145,6 +1152,8 @@ auich_set_params(v, setmode, usemode, play, rec) default: return (EINVAL); } + rec->bps = AUDIO_BPS(rec->precision); + rec->msb = 1; orate = rec->sample_rate; if (sc->sc_ac97rate != 0) diff --git a/sys/dev/pci/auixp.c b/sys/dev/pci/auixp.c index 2564d52164b..9b7782986d8 100644 --- a/sys/dev/pci/auixp.c +++ b/sys/dev/pci/auixp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auixp.c,v 1.24 2009/10/12 19:43:52 jakemsr Exp $ */ +/* $OpenBSD: auixp.c,v 1.25 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: auixp.c,v 1.9 2005/06/27 21:13:09 thorpej Exp $ */ /* @@ -233,52 +233,56 @@ auixp_query_encoding(void *hdl, struct audio_encoding *aep) aep->encoding = AUDIO_ENCODING_ULINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 1: strlcpy(aep->name, AudioEmulaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(aep->name, AudioEalaw, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ALAW; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(aep->name, AudioEslinear, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR; aep->precision = 8; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; - return (0); + break; case 5: strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_LE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); aep->encoding = AUDIO_ENCODING_ULINEAR_BE; aep->precision = 16; aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + aep->bps = AUDIO_BPS(aep->precision); + aep->msb = 1; + + return (0); } @@ -545,6 +549,8 @@ auixp_set_params(void *hdl, int setmode, int usemode, default: return (EINVAL); } + play->bps = AUDIO_BPS(play->precision); + play->msb = 1; temprate = play->sample_rate; error = ac97_set_rate(co->codec_if, @@ -601,6 +607,8 @@ auixp_set_params(void *hdl, int setmode, int usemode, default: return (EINVAL); } + rec->bps = AUDIO_BPS(rec->precision); + rec->msb = 1; error = ac97_set_rate(co->codec_if, AC97_REG_PCM_LR_ADC_RATE, &rec->sample_rate); diff --git a/sys/dev/pci/autri.c b/sys/dev/pci/autri.c index 9419bb45263..5389362351a 100644 --- a/sys/dev/pci/autri.c +++ b/sys/dev/pci/autri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autri.c,v 1.24 2010/04/08 00:23:53 tedu Exp $ */ +/* $OpenBSD: autri.c,v 1.25 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro. @@ -992,6 +992,8 @@ autri_query_encoding(addr, fp) default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; return 0; } @@ -1047,6 +1049,8 @@ autri_set_params(addr, setmode, usemode, play, rec) default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } return 0; diff --git a/sys/dev/pci/auvia.c b/sys/dev/pci/auvia.c index 0a785295abd..ad07c927e08 100644 --- a/sys/dev/pci/auvia.c +++ b/sys/dev/pci/auvia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auvia.c,v 1.44 2008/10/25 22:30:43 jakemsr Exp $ */ +/* $OpenBSD: auvia.c,v 1.45 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: auvia.c,v 1.28 2002/11/04 16:38:49 kent Exp $ */ /*- @@ -503,6 +503,8 @@ auvia_query_encoding(void *addr, struct audio_encoding *fp) fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; + fp->bps = 2; + fp->msb = 1; return (0); default: return (EINVAL); @@ -514,54 +516,59 @@ auvia_query_encoding(void *addr, struct audio_encoding *fp) fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; - return (0); + break; case 1: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return (0); + break; case 5: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + + return (0); } } + void auvia_set_params_sub(struct auvia_softc *sc, struct auvia_softc_chan *ch, struct audio_params *p) @@ -740,6 +747,9 @@ auvia_set_params(void *addr, int setmode, int usemode, return (EINVAL); } auvia_set_params_sub(sc, ch, p); + + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } return 0; diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index 72c6c041fce..4e003915e44 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.173 2010/06/27 21:47:07 jakemsr Exp $ */ +/* $OpenBSD: azalia.c,v 1.174 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -3871,6 +3871,8 @@ azalia_get_default_params(void *addr, int mode, struct audio_params *params) params->sample_rate = 48000; params->encoding = AUDIO_ENCODING_SLINEAR_LE; params->precision = 16; + params->bps = 2; + params->msb = 1; params->channels = 2; params->sw_code = NULL; params->factor = 1; @@ -4008,6 +4010,8 @@ azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) } } par->sw_code = swcode; + par->bps = AUDIO_BPS(par->precision); + par->msb = 1; return (0); } @@ -4377,6 +4381,8 @@ azalia_create_encodings(codec_t *this) this->encs[i].index = i; this->encs[i].encoding = encs[i] & 0xff; this->encs[i].precision = encs[i] >> 8; + this->encs[i].bps = AUDIO_BPS(encs[i] >> 8); + this->encs[i].msb = 1; this->encs[i].flags = 0; switch (this->encs[i].encoding) { case AUDIO_ENCODING_SLINEAR_LE: diff --git a/sys/dev/pci/cmpci.c b/sys/dev/pci/cmpci.c index eb15bdfb63d..53344a42e93 100644 --- a/sys/dev/pci/cmpci.c +++ b/sys/dev/pci/cmpci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmpci.c,v 1.25 2010/04/08 00:23:53 tedu Exp $ */ +/* $OpenBSD: cmpci.c,v 1.26 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: cmpci.c,v 1.25 2004/10/26 06:32:20 xtraeme Exp $ */ /* @@ -629,6 +629,9 @@ cmpci_query_encoding(void *handle, struct audio_encoding *fp) default: return EINVAL; } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + return 0; } @@ -638,6 +641,8 @@ cmpci_get_default_params(void *addr, int mode, struct audio_params *params) params->sample_rate = 48000; params->encoding = AUDIO_ENCODING_SLINEAR_LE; params->precision = 16; + params->bps = 2; + params->msb = 1; params->channels = 2; params->sw_code = NULL; params->factor = 1; @@ -858,6 +863,8 @@ cmpci_set_params(void *handle, int setmode, int usemode, default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; if (mode & AUMODE_PLAY) { if (sc->sc_play_channel == 1) { cmpci_reg_partial_write_4(sc, diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 9aee12b604d..8d278d9e9b8 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4280.c,v 1.33 2009/01/20 20:00:06 grange Exp $ */ +/* $OpenBSD: cs4280.c,v 1.34 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */ /* @@ -1106,6 +1106,9 @@ cs4280_query_encoding(addr, fp) default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + return (0); } @@ -1199,6 +1202,8 @@ cs4280_set_params(addr, setmode, usemode, play, rec) default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } /* set sample rate */ diff --git a/sys/dev/pci/cs4281.c b/sys/dev/pci/cs4281.c index 3f2f658ccee..43e3147e948 100644 --- a/sys/dev/pci/cs4281.c +++ b/sys/dev/pci/cs4281.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4281.c,v 1.22 2008/10/25 22:30:43 jakemsr Exp $ */ +/* $OpenBSD: cs4281.c,v 1.23 2010/07/15 03:43:11 jakemsr Exp $ */ /* $Tera: cs4281.c,v 1.18 2000/12/27 14:24:45 tacha Exp $ */ /* @@ -494,6 +494,9 @@ cs4281_query_encoding(addr, fp) default: return EINVAL; } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + return (0); } @@ -558,6 +561,8 @@ cs4281_set_params(addr, setmode, usemode, play, rec) default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } /* set sample rate */ diff --git a/sys/dev/pci/eap.c b/sys/dev/pci/eap.c index 799dd2d2675..148642476f0 100644 --- a/sys/dev/pci/eap.c +++ b/sys/dev/pci/eap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eap.c,v 1.39 2010/06/20 10:22:25 ratchov Exp $ */ +/* $OpenBSD: eap.c,v 1.40 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: eap.c,v 1.46 2001/09/03 15:07:37 reinoud Exp $ */ /* @@ -765,52 +765,56 @@ eap_query_encoding(void *addr, struct audio_encoding *fp) fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; - return (0); + break; case 1: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return (0); + break; case 5: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + + return (0); } void @@ -904,6 +908,8 @@ eap_set_params(void *addr, int setmode, int usemode, default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } if (!sc->sc_1371) { diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c index f190ed1315b..a61798e95ca 100644 --- a/sys/dev/pci/emuxki.c +++ b/sys/dev/pci/emuxki.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emuxki.c,v 1.33 2009/03/29 21:53:52 sthen Exp $ */ +/* $OpenBSD: emuxki.c,v 1.34 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: emuxki.c,v 1.1 2001/10/17 18:39:41 jdolecek Exp $ */ /*- @@ -2145,6 +2145,9 @@ emuxki_query_encoding(void *addr, struct audio_encoding *fp) default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + return (0); } @@ -2234,6 +2237,8 @@ emuxki_set_vparms(struct emuxki_voice *voice, struct audio_params *p) default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; return (emuxki_voice_set_audioparms(voice, p->channels == 2, b16, p->sample_rate)); diff --git a/sys/dev/pci/envy.c b/sys/dev/pci/envy.c index 39d483694d7..d328ba6d8d1 100644 --- a/sys/dev/pci/envy.c +++ b/sys/dev/pci/envy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: envy.c,v 1.36 2010/04/08 00:23:53 tedu Exp $ */ +/* $OpenBSD: envy.c,v 1.37 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 2007 Alexandre Ratchov * @@ -1542,6 +1542,8 @@ envy_query_encoding(void *self, struct audio_encoding *enc) strlcpy(enc->name, AudioEslinear_le, sizeof(enc->name)); enc->encoding = AUDIO_ENCODING_SLINEAR_LE; enc->precision = 24; + enc->bps = 4; + enc->msb = 1; enc->flags = 0; return 0; } @@ -1577,11 +1579,15 @@ envy_set_params(void *self, int setmode, int usemode, if (setmode & AUMODE_PLAY) { p->encoding = AUDIO_ENCODING_SLINEAR; p->precision = 24; + p->bps = 4; + p->msb = 1; p->channels = sc->isht ? sc->card->noch : ENVY_PCHANS; } if (setmode & AUMODE_RECORD) { r->encoding = AUDIO_ENCODING_SLINEAR; r->precision = 24; + r->bps = 4; + r->msb = 1; r->channels = sc->isht ? sc->card->nich : ENVY_RCHANS; } return 0; diff --git a/sys/dev/pci/esa.c b/sys/dev/pci/esa.c index 57da8a0753c..1f9413cdbbf 100644 --- a/sys/dev/pci/esa.c +++ b/sys/dev/pci/esa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esa.c,v 1.18 2009/11/13 02:22:19 deraadt Exp $ */ +/* $OpenBSD: esa.c,v 1.19 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: esa.c,v 1.12 2002/03/24 14:17:35 jmcneill Exp $ */ /* @@ -165,19 +165,20 @@ int esa_suspend(struct esa_softc *); int esa_resume(struct esa_softc *); static audio_encoding_t esa_encoding[] = { - { 0, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 0 }, - { 1, AudioEmulaw, AUDIO_ENCODING_ULAW, 8, - AUDIO_ENCODINGFLAG_EMULATED }, - { 2, AudioEalaw, AUDIO_ENCODING_ALAW, 8, AUDIO_ENCODINGFLAG_EMULATED }, - { 3, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, - AUDIO_ENCODINGFLAG_EMULATED }, /* XXX: Are you sure? */ - { 4, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 0 }, - { 5, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16, - AUDIO_ENCODINGFLAG_EMULATED }, - { 6, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16, - AUDIO_ENCODINGFLAG_EMULATED }, - { 7, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16, - AUDIO_ENCODINGFLAG_EMULATED } + { 0, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 1, 1, 0 }, + { 1, AudioEmulaw, AUDIO_ENCODING_ULAW, 8, 1, 1, + AUDIO_ENCODINGFLAG_EMULATED }, + { 2, AudioEalaw, AUDIO_ENCODING_ALAW, 8, 1, 1, + AUDIO_ENCODINGFLAG_EMULATED }, + { 3, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, 1, 1, + AUDIO_ENCODINGFLAG_EMULATED }, + { 4, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 2, 1, 0 }, + { 5, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16, 2, 1, + AUDIO_ENCODINGFLAG_EMULATED }, + { 6, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16, 2, 1, + AUDIO_ENCODINGFLAG_EMULATED }, + { 7, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16, 2, 1, + AUDIO_ENCODINGFLAG_EMULATED } }; #define ESA_NENCODINGS 8 @@ -336,6 +337,8 @@ esa_set_params(void *hdl, int setmode, int usemode, struct audio_params *play, default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; ch->mode = *p; } diff --git a/sys/dev/pci/eso.c b/sys/dev/pci/eso.c index e92805052cf..7edba2c8865 100644 --- a/sys/dev/pci/eso.c +++ b/sys/dev/pci/eso.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eso.c,v 1.31 2010/05/23 11:41:07 deraadt Exp $ */ +/* $OpenBSD: eso.c,v 1.32 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: eso.c,v 1.48 2006/12/18 23:13:39 kleink Exp $ */ /* @@ -676,6 +676,8 @@ eso_query_encoding(void *hdl, struct audio_encoding *fp) default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; return (0); } @@ -686,6 +688,8 @@ eso_get_default_params(void *addr, int mode, struct audio_params *params) params->sample_rate = 48000; params->encoding = AUDIO_ENCODING_ULINEAR_LE; params->precision = 16; + params->bps = 2; + params->msb = 1; params->channels = 2; params->sw_code = NULL; params->factor = 1; @@ -746,6 +750,8 @@ eso_set_params(void *hdl, int setmode, int usemode, default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; /* * We'll compute both possible sample rate dividers and pick diff --git a/sys/dev/pci/fms.c b/sys/dev/pci/fms.c index 3f1bcb650b6..ec021d39fca 100644 --- a/sys/dev/pci/fms.c +++ b/sys/dev/pci/fms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fms.c,v 1.21 2010/04/04 00:50:36 jakemsr Exp $ */ +/* $OpenBSD: fms.c,v 1.22 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: fms.c,v 1.5.4.1 2000/06/30 16:27:50 simonb Exp $ */ /*- @@ -463,52 +463,56 @@ fms_query_encoding(addr, fp) fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 1: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return 0; + break; case 2: strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; - return 0; + break; case 3: strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 4: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 5: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 6: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; case 7: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return 0; + break; default: return EINVAL; } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + + return 0; } void @@ -582,6 +586,9 @@ fms_set_params(addr, setmode, usemode, play, rec) default: return EINVAL; } + play->bps = AUDIO_BPS(play->precision); + play->msb = 1; + for (i = 0; i < 10 && play->sample_rate > fms_rates[i].limit; i++) ; @@ -623,6 +630,9 @@ fms_set_params(addr, setmode, usemode, play, rec) default: return EINVAL; } + rec->bps = AUDIO_BPS(rec->precision); + rec->msb = 1; + for (i = 0; i < 10 && rec->sample_rate > fms_rates[i].limit; i++) ; diff --git a/sys/dev/pci/maestro.c b/sys/dev/pci/maestro.c index 63036064786..dea2b251000 100644 --- a/sys/dev/pci/maestro.c +++ b/sys/dev/pci/maestro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: maestro.c,v 1.28 2010/04/08 00:23:53 tedu Exp $ */ +/* $OpenBSD: maestro.c,v 1.29 2010/07/15 03:43:11 jakemsr Exp $ */ /* $FreeBSD: /c/ncvs/src/sys/dev/sound/pci/maestro.c,v 1.3 2000/11/21 12:22:11 julian Exp $ */ /* * FreeBSD's ESS Agogo/Maestro driver @@ -974,18 +974,18 @@ maestro_query_devinfo(self, cp) } struct audio_encoding maestro_tab[] = { - {0, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 0}, - {1, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, 0}, - {2, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 0}, - {3, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16, + {0, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 2, 1, 0}, + {1, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, 1, 1, 0}, + {2, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 1, 1, 0}, + {3, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16, 2, 1, AUDIO_ENCODINGFLAG_EMULATED}, - {4, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16, + {4, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16, 2, 1, AUDIO_ENCODINGFLAG_EMULATED}, - {5, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16, + {5, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16, 2, 1, AUDIO_ENCODINGFLAG_EMULATED}, - {6, AudioEmulaw, AUDIO_ENCODING_ULAW, 8, + {6, AudioEmulaw, AUDIO_ENCODING_ULAW, 8, 1, 1, AUDIO_ENCODINGFLAG_EMULATED}, - {7, AudioEalaw, AUDIO_ENCODING_ALAW, 8, + {7, AudioEalaw, AUDIO_ENCODING_ALAW, 8, 1, 1, AUDIO_ENCODINGFLAG_EMULATED} }; @@ -1117,6 +1117,9 @@ maestro_set_params(hdl, setmode, usemode, play, rec) else if (play->encoding != AUDIO_ENCODING_SLINEAR_LE) return (EINVAL); + play->bps = AUDIO_BPS(play->precision); + play->msb = 1; + maestro_set_speed(&sc->play, &play->sample_rate); return (0); } diff --git a/sys/dev/pci/neo.c b/sys/dev/pci/neo.c index f67cc61505d..496d07b496d 100644 --- a/sys/dev/pci/neo.c +++ b/sys/dev/pci/neo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neo.c,v 1.23 2008/10/25 22:30:43 jakemsr Exp $ */ +/* $OpenBSD: neo.c,v 1.24 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 1999 Cameron Grant @@ -782,52 +782,56 @@ neo_query_encoding(addr, fp) fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; - return (0); + break; case 1: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return (0); + break; case 5: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + + return (0); } void @@ -916,9 +920,10 @@ neo_set_params(addr, setmode, usemode, play, rec) default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } - return (0); } diff --git a/sys/dev/pci/sv.c b/sys/dev/pci/sv.c index 78882cca0e2..6d608fadf46 100644 --- a/sys/dev/pci/sv.c +++ b/sys/dev/pci/sv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sv.c,v 1.26 2009/06/23 06:39:48 jsg Exp $ */ +/* $OpenBSD: sv.c,v 1.27 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 1998 Constantine Paul Sapuntzakis @@ -611,52 +611,56 @@ sv_query_encoding(addr, fp) fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; - return (0); + break; case 1: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return (0); + break; case 5: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + + return (0); } int @@ -720,6 +724,9 @@ sv_set_params(addr, setmode, usemode, p, r) p->sw_code = pswcode; r->sw_code = rswcode; + p->bps = AUDIO_BPS(p->precision); + r->bps = AUDIO_BPS(r->precision); + p->msb = r->msb = 1; /* Set the encoding */ reg = sv_read_indirect(sc, SV_DMA_DATA_FORMAT); diff --git a/sys/dev/pci/yds.c b/sys/dev/pci/yds.c index 8c9b600a312..fd5addc3d6c 100644 --- a/sys/dev/pci/yds.c +++ b/sys/dev/pci/yds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yds.c,v 1.33 2010/04/06 22:28:07 tedu Exp $ */ +/* $OpenBSD: yds.c,v 1.34 2010/07/15 03:43:11 jakemsr Exp $ */ /* $NetBSD: yds.c,v 1.5 2001/05/21 23:55:04 minoura Exp $ */ /* @@ -1140,52 +1140,56 @@ yds_query_encoding(addr, fp) fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; - return (0); + break; case 1: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(fp->name, AudioEalaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return (0); + break; case 5: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + + return (0); } void @@ -1263,6 +1267,8 @@ yds_set_params(addr, setmode, usemode, play, rec) default: return (EINVAL); } + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } return 0; diff --git a/sys/dev/sbus/cs4231.c b/sys/dev/sbus/cs4231.c index 4a74570aa19..358b6deeec5 100644 --- a/sys/dev/sbus/cs4231.c +++ b/sys/dev/sbus/cs4231.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4231.c,v 1.29 2008/04/21 00:32:43 jakemsr Exp $ */ +/* $OpenBSD: cs4231.c,v 1.30 2010/07/15 03:43:11 jakemsr Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -547,6 +547,9 @@ cs4231_query_encoding(void *vsc, struct audio_encoding *fp) default: err = EINVAL; } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + return (err); } @@ -635,6 +638,9 @@ cs4231_set_params(void *vsc, int setmode, int usemode, p->sw_code = pswcode; r->sw_code = rswcode; + p->bps = AUDIO_BPS(p->precision); + r->bps = AUDIO_BPS(r->precision); + p->msb = r->msb = 1; sc->sc_format_bits = bits; sc->sc_channels = p->channels; diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index 5d64bf555d4..ed5959e33fb 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.73 2009/12/04 20:50:59 jakemsr Exp $ */ +/* $OpenBSD: uaudio.c,v 1.74 2010/07/15 03:43:12 jakemsr Exp $ */ /* $NetBSD: uaudio.c,v 1.90 2004/10/29 17:12:53 kent Exp $ */ /* @@ -531,52 +531,56 @@ uaudio_query_encoding(void *addr, struct audio_encoding *fp) fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = flags&HAS_8U ? 0 : AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 1: strlcpy(fp->name, AudioEmulaw, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_ULAW; fp->precision = 8; fp->flags = flags&HAS_MULAW ? 0 : AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 2: strlcpy(fp->name, AudioEalaw, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_ALAW; fp->precision = 8; fp->flags = flags&HAS_ALAW ? 0 : AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 3: strlcpy(fp->name, AudioEslinear, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = flags&HAS_8 ? 0 : AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 4: strlcpy(fp->name, AudioEslinear_le, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; - return (0); + break; case 5: strlcpy(fp->name, AudioEulinear_le, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 6: strlcpy(fp->name, AudioEslinear_be, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; case 7: strlcpy(fp->name, AudioEulinear_be, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - return (0); + break; default: return (EINVAL); } + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 1; + + return (0); } const usb_interface_descriptor_t * @@ -2221,6 +2225,8 @@ uaudio_get_default_params(void *addr, int mode, struct audio_params *p) p->sample_rate = 44100; p->encoding = AUDIO_ENCODING_SLINEAR_LE; p->precision = 16; + p->bps = 2; + p->msb = 1; p->channels = 2; p->sw_code = NULL; p->factor = 1; @@ -2249,6 +2255,9 @@ uaudio_get_default_params(void *addr, int mode, struct audio_params *p) } uaudio_match_alt(sc, p, mode, p->encoding, p->precision); + + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; } int @@ -3248,6 +3257,9 @@ uaudio_set_params(void *addr, int setmode, int usemode, p->sw_code = swcode; p->factor = factor; + p->bps = AUDIO_BPS(p->precision); + p->msb = 1; + if (mode == AUMODE_PLAY) paltidx = i; else diff --git a/sys/sys/audioio.h b/sys/sys/audioio.h index 657c83950a3..1e72c131317 100644 --- a/sys/sys/audioio.h +++ b/sys/sys/audioio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: audioio.h,v 1.20 2008/11/16 23:36:54 jakemsr Exp $ */ +/* $OpenBSD: audioio.h,v 1.21 2010/07/15 03:43:12 jakemsr Exp $ */ /* $NetBSD: audioio.h,v 1.24 1998/08/13 06:28:41 mrg Exp $ */ /* @@ -45,6 +45,8 @@ struct audio_prinfo { u_int sample_rate; /* sample rate in bit/s */ u_int channels; /* number of channels, usually 1 or 2 */ u_int precision; /* number of bits/sample */ + u_int bps; /* number of bytes/sample */ + u_int msb; /* data alignment */ u_int encoding; /* data encoding (AUDIO_ENCODING_* below) */ u_int gain; /* volume level */ u_int port; /* selected I/O port */ @@ -144,6 +146,8 @@ typedef struct audio_encoding { char name[MAX_AUDIO_DEV_LEN]; int encoding; int precision; + int bps; + int msb; int flags; #define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */ } audio_encoding_t; diff --git a/usr.bin/audioctl/audioctl.c b/usr.bin/audioctl/audioctl.c index 374a7917d28..ef4d7c8fee3 100644 --- a/usr.bin/audioctl/audioctl.c +++ b/usr.bin/audioctl/audioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audioctl.c,v 1.20 2009/11/12 07:32:26 ratchov Exp $ */ +/* $OpenBSD: audioctl.c,v 1.21 2010/07/15 03:43:12 jakemsr Exp $ */ /* $NetBSD: audioctl.c,v 1.14 1998/04/27 16:55:23 augustss Exp $ */ /* @@ -96,6 +96,8 @@ struct field { { "play.sample_rate", &info.play.sample_rate, UINT, ALIAS }, { "play.channels", &info.play.channels, UINT, 0 }, { "play.precision", &info.play.precision, UINT, 0 }, + { "play.bps", &info.play.bps, UINT, 0 }, + { "play.msb", &info.play.msb, UINT, 0 }, { "play.encoding", &info.play.encoding, ENC, 0 }, { "play.gain", &info.play.gain, UINT, 0 }, { "play.balance", &info.play.balance, UCHAR, 0 }, @@ -116,6 +118,8 @@ struct field { { "record.sample_rate", &info.record.sample_rate,UINT, ALIAS }, { "record.channels", &info.record.channels, UINT, 0 }, { "record.precision", &info.record.precision, UINT, 0 }, + { "record.bps", &info.record.bps, UINT, 0 }, + { "record.msb", &info.record.msb, UINT, 0 }, { "record.encoding", &info.record.encoding, ENC, 0 }, { "record.gain", &info.record.gain, UINT, 0 }, { "record.balance", &info.record.balance, UCHAR, 0 }, @@ -320,8 +324,8 @@ getinfo(int fd) break; if (pos) encbuf[pos++] = ','; - snprintf(encbuf+pos, sizeof(encbuf)-pos, "%s:%d%s", - enc.name, enc.precision, + snprintf(encbuf+pos, sizeof(encbuf)-pos, "%s:%d:%d:%d%s", + enc.name, enc.precision, enc.bps, enc.msb, enc.flags & AUDIO_ENCODINGFLAG_EMULATED ? "*" : ""); pos += strlen(encbuf+pos); } -- 2.20.1