From ac2bb4f35e5a57326fc135134dc640899d0b5bd0 Mon Sep 17 00:00:00 2001 From: ratchov Date: Mon, 11 May 2015 06:46:21 +0000 Subject: [PATCH] Remove all audio format conversion code from the kernel (btw holding the kernel_lock), as we already do better conversions in user-mode. Yet, no need for every single driver to fiddle with the conversion code as they are done transparently by common MI code. With help from armani and miod, support from mpi ok armani@ --- sys/arch/hppa/conf/files.hppa | 4 +- sys/arch/hppa/gsc/harmony.c | 89 +---- sys/arch/luna88k/cbus/nec86hw.c | 523 ++-------------------------- sys/arch/luna88k/conf/files.luna88k | 4 +- sys/arch/macppc/conf/files.macppc | 14 +- sys/arch/macppc/dev/awacs.c | 113 +----- sys/arch/macppc/dev/i2s.c | 146 +------- sys/arch/sgi/dev/mavb.c | 229 +----------- sys/arch/sgi/hpc/files.hpc | 4 +- sys/arch/sparc/conf/files.sparc | 6 +- sys/arch/sparc/dev/audioamd.c | 5 +- sys/arch/sparc/dev/cs4231.c | 68 +--- sys/arch/sparc64/conf/files.sparc64 | 4 +- sys/arch/sparc64/dev/ce4231.c | 73 +--- sys/arch/vax/conf/files.vax | 4 +- sys/arch/vax/vsa/vsaudio.c | 5 +- sys/arch/zaurus/conf/files.zaurus | 4 +- sys/arch/zaurus/dev/zaurus_audio.c | 255 +------------- sys/conf/files | 11 +- sys/dev/auconv.c | 509 --------------------------- sys/dev/auconv.h | 101 ------ sys/dev/audio.c | 171 +++++---- sys/dev/audio_if.h | 5 +- sys/dev/ic/ac97.c | 6 +- sys/dev/ic/am7930.c | 92 +---- sys/dev/ic/am7930var.h | 10 +- sys/dev/ic/arcofi.c | 85 +---- sys/dev/isa/ad1848.c | 73 +--- sys/dev/isa/ess.c | 58 +-- sys/dev/isa/files.isa | 14 +- sys/dev/isa/files.isapnp | 4 +- sys/dev/isa/gus.c | 53 +-- sys/dev/isa/sbdsp.c | 80 +---- sys/dev/mulaw.c | 415 +--------------------- sys/dev/mulaw.h | 61 +--- sys/dev/pci/auacer.c | 119 +------ sys/dev/pci/auglx.c | 370 +------------------- sys/dev/pci/auich.c | 424 ++-------------------- sys/dev/pci/auixp.c | 241 +------------ sys/dev/pci/autri.c | 52 +-- sys/dev/pci/auvia.c | 80 +---- sys/dev/pci/azalia.c | 42 +-- sys/dev/pci/cmpci.c | 122 +------ sys/dev/pci/cs4280.c | 92 +---- sys/dev/pci/cs4281.c | 52 +-- sys/dev/pci/eap.c | 84 +---- sys/dev/pci/emuxki.c | 99 +----- sys/dev/pci/esa.c | 62 +--- sys/dev/pci/eso.c | 73 +--- sys/dev/pci/files.pci | 38 +- sys/dev/pci/fms.c | 99 +----- sys/dev/pci/maestro.c | 32 +- sys/dev/pci/neo.c | 81 +---- sys/dev/pci/sv.c | 72 +--- sys/dev/pci/yds.c | 94 +---- sys/dev/sbus/cs4231.c | 33 +- sys/dev/sbus/files.sbus | 4 +- sys/dev/tc/bba.c | 80 +---- sys/dev/tc/files.tc | 4 +- sys/dev/usb/files.usb | 4 +- sys/dev/usb/uaudio.c | 8 +- 61 files changed, 463 insertions(+), 5296 deletions(-) delete mode 100644 sys/dev/auconv.c delete mode 100644 sys/dev/auconv.h diff --git a/sys/arch/hppa/conf/files.hppa b/sys/arch/hppa/conf/files.hppa index 041bb7b97e8..9afb039da7e 100644 --- a/sys/arch/hppa/conf/files.hppa +++ b/sys/arch/hppa/conf/files.hppa @@ -1,4 +1,4 @@ -# $OpenBSD: files.hppa,v 1.92 2014/07/11 21:54:37 tedu Exp $ +# $OpenBSD: files.hppa,v 1.93 2015/05/11 06:46:21 ratchov Exp $ # # hppa-specific configuration info @@ -251,7 +251,7 @@ file arch/hppa/gsc/arcofi_gsc.c arcofi_gsc # CS4215/AD1849 based 16bit mono/stereo audio iface (most of others not w/ aone) # a.k.a. Audio Type 2 (optional beeper) -device harmony: audio, mulaw, auconv +device harmony: audio attach harmony at gsc file arch/hppa/gsc/harmony.c harmony diff --git a/sys/arch/hppa/gsc/harmony.c b/sys/arch/hppa/gsc/harmony.c index 2146781d858..c54836d5848 100644 --- a/sys/arch/hppa/gsc/harmony.c +++ b/sys/arch/hppa/gsc/harmony.c @@ -1,4 +1,4 @@ -/* $OpenBSD: harmony.c,v 1.29 2014/07/12 18:44:41 tedu Exp $ */ +/* $OpenBSD: harmony.c,v 1.30 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2003 Jason L. Wright (jason@thought.net) @@ -41,7 +41,6 @@ #include #include -#include #include #include @@ -428,24 +427,6 @@ harmony_query_encoding(void *vsc, struct audio_encoding *fp) fp->flags = 0; break; case 3: - strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - 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; - break; - case 6: if (sc->sc_hasulinear8) { strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; @@ -454,15 +435,6 @@ harmony_query_encoding(void *vsc, struct audio_encoding *fp) break; } /*FALLTHROUGH*/ - case 7: - if (sc->sc_hasulinear8) { - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - } - /*FALLTHROUGH*/ default: err = EINVAL; } @@ -477,76 +449,28 @@ harmony_set_params(void *vsc, int setmode, int usemode, { struct harmony_softc *sc = vsc; u_int32_t bits; - void (*pswcode)(void *, u_char *, int cnt) = NULL; - void (*rswcode)(void *, u_char *, int cnt) = NULL; switch (p->encoding) { case AUDIO_ENCODING_ULAW: - if (p->precision != 8) - return (EINVAL); bits = CNTL_FORMAT_ULAW; + p->precision = 8; break; case AUDIO_ENCODING_ALAW: - if (p->precision != 8) - return (EINVAL); bits = CNTL_FORMAT_ALAW; + p->precision = 8; break; case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 8) { - bits = CNTL_FORMAT_ULINEAR8; - rswcode = pswcode = change_sign8; - break; - } if (p->precision == 16) { bits = CNTL_FORMAT_SLINEAR16BE; break; } return (EINVAL); - case AUDIO_ENCODING_ULINEAR: - if (p->precision != 8) - return (EINVAL); - bits = CNTL_FORMAT_ULINEAR8; - break; - case AUDIO_ENCODING_SLINEAR: - if (p->precision != 8) - return (EINVAL); - bits = CNTL_FORMAT_ULINEAR8; - rswcode = pswcode = change_sign8; - break; - case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision == 8) { - bits = CNTL_FORMAT_ULINEAR8; - rswcode = pswcode = change_sign8; - break; - } - if (p->precision == 16) { - bits = CNTL_FORMAT_SLINEAR16BE; - rswcode = pswcode = swap_bytes; - break; - } - return (EINVAL); - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 8) { - bits = CNTL_FORMAT_ULINEAR8; - break; - } - if (p->precision == 16) { - bits = CNTL_FORMAT_SLINEAR16BE; - rswcode = pswcode = change_sign16_be; - break; - } - return (EINVAL); case AUDIO_ENCODING_ULINEAR_LE: + case AUDIO_ENCODING_ULINEAR_BE: if (p->precision == 8) { bits = CNTL_FORMAT_ULINEAR8; break; } - if (p->precision == 16) { - bits = CNTL_FORMAT_SLINEAR16BE; - pswcode = change_sign16_swap_bytes_le; - rswcode = swap_bytes_change_sign16_le; - break; - } return (EINVAL); default: return (EINVAL); @@ -562,8 +486,9 @@ harmony_set_params(void *vsc, int setmode, int usemode, else return (EINVAL); - p->sw_code = pswcode; - r->sw_code = rswcode; + r->sample_rate = p->sample_rate; + r->encoding = p->encoding; + r->precision = p->precision; p->bps = AUDIO_BPS(p->precision); r->bps = AUDIO_BPS(r->precision); p->msb = r->msb = 1; diff --git a/sys/arch/luna88k/cbus/nec86hw.c b/sys/arch/luna88k/cbus/nec86hw.c index ee3fd076b85..1e60ab8ff1c 100644 --- a/sys/arch/luna88k/cbus/nec86hw.c +++ b/sys/arch/luna88k/cbus/nec86hw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nec86hw.c,v 1.1 2014/12/28 13:03:18 aoyama Exp $ */ +/* $OpenBSD: nec86hw.c,v 1.2 2015/05/11 06:46:21 ratchov Exp $ */ /* $NecBSD: nec86hw.c,v 1.13 1998/03/14 07:04:54 kmatsuda Exp $ */ /* $NetBSD$ */ @@ -58,8 +58,6 @@ #include #include -#include -#include #if 0 #include @@ -107,17 +105,13 @@ static struct nec86hw_functable_entry nec86hw_functable[] = { output function, input function (without resampling), output function, input function (with resampling) */ { 8, 1, - nec86fifo_output_mono_8_direct, nec86fifo_input_mono_8_direct, - nec86fifo_output_mono_8_resamp, nec86fifo_input_mono_8_resamp }, + nec86fifo_output_mono_8_direct, nec86fifo_input_mono_8_direct }, { 16, 1, - nec86fifo_output_mono_16_direct, nec86fifo_input_mono_16_direct, - nec86fifo_output_mono_16_resamp, nec86fifo_input_mono_16_resamp }, + nec86fifo_output_mono_16_direct, nec86fifo_input_mono_16_direct }, { 8, 2, - nec86fifo_output_stereo_8_direct, nec86fifo_input_stereo_8_direct, - nec86fifo_output_stereo_8_resamp, nec86fifo_input_stereo_8_resamp }, + nec86fifo_output_stereo_8_direct, nec86fifo_input_stereo_8_direct }, { 16, 2, - nec86fifo_output_stereo_16_direct, nec86fifo_input_stereo_16_direct, - nec86fifo_output_stereo_16_resamp, nec86fifo_input_stereo_16_resamp }, + nec86fifo_output_stereo_16_direct, nec86fifo_input_stereo_16_direct }, }; #define NFUNCTABLEENTRY (sizeof(nec86hw_functable) / sizeof(nec86hw_functable[0])) @@ -133,8 +127,8 @@ nec86hw_attach(struct nec86hw_softc *sc) u_int8_t data; /* Set default encoding. */ - sc->func_fifo_output = nec86fifo_output_mono_8_resamp; - sc->func_fifo_input = nec86fifo_input_mono_8_resamp; + sc->func_fifo_output = nec86fifo_output_mono_8_direct; + sc->func_fifo_input = nec86fifo_input_mono_8_direct; (void) nec86hw_set_params(sc, AUMODE_RECORD, 0, &audio_default, &audio_default); (void) nec86hw_set_params(sc, AUMODE_PLAY, 0, @@ -222,76 +216,21 @@ nec86hw_set_params(void *addr, int mode, int usemode, struct audio_params *p, if ((p->channels != 1) && (p->channels != 2)) return EINVAL; - enc = p->encoding; - prec = p->precision; - switch (enc) { - case AUDIO_ENCODING_SLINEAR_BE: - case AUDIO_ENCODING_SLINEAR_LE: - if (prec == 8) - enc = AUDIO_ENCODING_SLINEAR; - break; - case AUDIO_ENCODING_ULINEAR_BE: - case AUDIO_ENCODING_ULINEAR_LE: - if (prec == 8) - enc = AUDIO_ENCODING_ULINEAR; - break; - case AUDIO_ENCODING_SLINEAR: - if (prec == 16) - enc = AUDIO_ENCODING_SLINEAR_LE; - break; - case AUDIO_ENCODING_ULINEAR: - if (prec == 16) - enc = AUDIO_ENCODING_ULINEAR_LE; - break; - case AUDIO_ENCODING_ULAW: - case AUDIO_ENCODING_ALAW: - break; - default: - return EINVAL; + if (p->precision == 8) + p->encoding = AUDIO_ENCODING_ULINEAR_LE; + else { + p->precision = 16; + p->encoding = AUDIO_ENCODING_SLINEAR_LE; } - - p->sw_code = NULL; - r->sw_code = NULL; - switch (enc) { - case AUDIO_ENCODING_ULAW: - p->sw_code = mulaw_to_ulinear8; - r->sw_code = ulinear8_to_mulaw; - enc = AUDIO_ENCODING_ULINEAR; - break; - case AUDIO_ENCODING_ALAW: - p->sw_code = alaw_to_ulinear8; - r->sw_code = ulinear8_to_alaw; - enc = AUDIO_ENCODING_ULINEAR; - break; - case AUDIO_ENCODING_ULINEAR_LE: - p->sw_code = r->sw_code = change_sign16; - enc = AUDIO_ENCODING_SLINEAR_LE; - break; - case AUDIO_ENCODING_ULINEAR_BE: - p->sw_code = r->sw_code = swap_bytes_change_sign16; - enc = AUDIO_ENCODING_SLINEAR_LE; - break; - case AUDIO_ENCODING_SLINEAR_BE: - p->sw_code = r->sw_code = swap_bytes; - enc = AUDIO_ENCODING_SLINEAR_LE; - break; - case AUDIO_ENCODING_SLINEAR: - p->sw_code = r->sw_code = change_sign8; - enc = AUDIO_ENCODING_ULINEAR; - break; - default: - break; - } - sc->channels = p->channels; sc->precision = prec; sc->encoding = enc; - sc->sc_orate = p->sample_rate; sc->hw_orate_bits = nec86hw_rate_bits(sc, p->sample_rate); - sc->hw_orate = nec86hw_rate_table[rate_type][sc->hw_orate_bits]; - sc->sc_irate = r->sample_rate; + sc->sc_orate = p->sample_rate = sc->hw_orate = + nec86hw_rate_table[rate_type][sc->hw_orate_bits]; sc->hw_irate_bits = nec86hw_rate_bits(sc, r->sample_rate); - sc->hw_irate = nec86hw_rate_table[rate_type][sc->hw_irate_bits]; + sc->sc_irate = r->sample_rate = sc->hw_irate = + nec86hw_rate_table[rate_type][sc->hw_irate_bits]; return 0; } @@ -301,22 +240,6 @@ nec86hw_query_encoding(void *addr, struct audio_encoding *fp) switch (fp->index) { case 0: - strlcpy(fp->name, AudioEmulaw, sizeof(fp->name)); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->bps = 1; - fp->msb = 1; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: - strlcpy(fp->name, AudioEalaw, sizeof(fp->name)); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->bps = 1; - fp->msb = 1; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: strlcpy(fp->name, AudioEulinear, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; @@ -324,31 +247,7 @@ nec86hw_query_encoding(void *addr, struct audio_encoding *fp) fp->msb = 1; fp->flags = 0; break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof(fp->name)); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->bps = 1; - fp->msb = 1; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: - strlcpy(fp->name, AudioEulinear_le, sizeof(fp->name)); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->bps = 2; - fp->msb = 1; /* is this OK? */ - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 5: - strlcpy(fp->name, AudioEulinear_be, sizeof(fp->name)); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->bps = 2; - fp->msb = 1; /* is this OK? */ - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: + case 1: strlcpy(fp->name, AudioEslinear_le, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; @@ -356,14 +255,6 @@ nec86hw_query_encoding(void *addr, struct audio_encoding *fp) fp->msb = 1; /* is this OK? */ fp->flags = 0; break; - case 7: - strlcpy(fp->name, AudioEslinear_be, sizeof(fp->name)); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->bps = 2; - fp->msb = 1; /* is this OK? */ - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return EINVAL; /*NOTREACHED*/ @@ -457,26 +348,10 @@ nec86hw_commit_settings(void *addr) return EINVAL; } - if (sc->sc_orate == sc->hw_orate) { - /* No need to resample. */ - sc->func_fifo_output = - nec86hw_functable[i].func_fifo_output_direct; - } else { - /* Resampling needed. */ - sc->func_fifo_output = - nec86hw_functable[i].func_fifo_output_resamp; - } - - if (sc->sc_irate == sc->hw_irate) { - /* No need to resample. */ - sc->func_fifo_input = - nec86hw_functable[i].func_fifo_input_direct; - } else { - /* Resampling needed. */ - sc->func_fifo_input = - nec86hw_functable[i].func_fifo_input_resamp; - } - + sc->func_fifo_output = + nec86hw_functable[i].func_fifo_output_direct; + sc->func_fifo_input = + nec86hw_functable[i].func_fifo_input_direct; return 0; } @@ -524,10 +399,8 @@ nec86hw_set_output_block(struct nec86hw_softc *sc, int cc) bpf = (sc->channels * sc->precision) / NBBY; /* bytes per frame */ sc->pdma_count = cc / bpf; - /* Size of the block after the rate-conversion. */ - hw_blocksize = - (sc->pdma_count * sc->hw_orate) / sc->sc_orate - * (sc->precision / NBBY * 2); + /* Size of the block */ + hw_blocksize = sc->pdma_count * (sc->precision / NBBY * 2); /* How many chunks the block should be divided into. */ sc->pdma_nchunk = @@ -578,10 +451,8 @@ nec86hw_set_input_block(struct nec86hw_softc *sc, int cc) (NEC86_BUFFSIZE * WATERMARK_RATIO_IN) / WATERMARK_MAX_RATIO; maxwatermark = nec86hw_round_watermark(watermark); - /* Size of the block before the rate-conversion. */ - hw_blocksize = - (sc->pdma_count * sc->hw_irate + (sc->sc_irate - 1)) - / sc->sc_irate * (sc->precision / NBBY * 2); + /* Size of the block */ + hw_blocksize = sc->pdma_count * (sc->precision / NBBY * 2); /* How many chunks the block should be divided into. */ sc->pdma_nchunk = (hw_blocksize + (maxwatermark - 1)) / maxwatermark; @@ -1279,133 +1150,6 @@ nec86fifo_output_mono_16_resamp(struct nec86hw_softc *sc, int cc) return rval; } -int -nec86fifo_output_stereo_8_resamp(struct nec86hw_softc *sc, int cc) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t *p = sc->pdma_ptr; - int i; - register int rval; - register u_int8_t d, d0_l, d0_r, d1_l, d1_r; - register u_long acc, orate, hw_orate; - - rval = 0; - - orate = sc->sc_orate; - hw_orate = sc->hw_orate; - acc = sc->conv_acc; - d0_l = sc->conv_last0_l; - d0_r = sc->conv_last0_r; - d1_l = sc->conv_last1_l; - d1_r = sc->conv_last1_r; - - for (i = 0; i < cc; i++) { - d0_l = d1_l; - d0_r = d1_r; - d1_l = *p++; - d1_r = *p++; - - while (acc <= hw_orate) { - /* Linear interpolation. (L) */ - d = ((d0_l * (hw_orate - acc)) + (d1_l * acc)) - / hw_orate; - /* unsigned -> signed (L) */ - d ^= 0x80; - bus_space_write_1(iot, ioh, NEC86_FIFODATA, d); - - /* Linear interpolation. (R) */ - d = ((d0_r * (hw_orate - acc)) + (d1_r * acc)) - / hw_orate; - /* unsigned -> signed (R) */ - d ^= 0x80; - bus_space_write_1(iot, ioh, NEC86_FIFODATA, d); - - acc += orate; - rval += 2; - } - - acc -= hw_orate; - } - - sc->conv_acc = acc; - sc->conv_last0_l = d0_l; - sc->conv_last0_r = d0_r; - sc->conv_last1_l = d1_l; - sc->conv_last1_r = d1_r; - - return rval; -} - -int -nec86fifo_output_stereo_16_resamp(struct nec86hw_softc *sc, int cc) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t *p = sc->pdma_ptr; - int i; - register int rval; - register u_short d, d0_l, d0_r, d1_l, d1_r; - register u_long acc, orate, hw_orate; - - rval = 0; - - orate = sc->sc_orate; - hw_orate = sc->hw_orate; - acc = sc->conv_acc; - - d0_l = sc->conv_last0_l; - d0_r = sc->conv_last0_r; - d1_l = sc->conv_last1_l; - d1_r = sc->conv_last1_r; - - for (i = 0; i < cc; i++) { - d0_l = d1_l; - d0_r = d1_r; - /* little endian signed -> unsigned (L) */ - d1_l = (*p | (*(p + 1) << 8)) ^ 0x8000; - p += 2; - /* little endian signed -> unsigned (R) */ - d1_r = (*p | (*(p + 1) << 8)) ^ 0x8000; - p += 2; - - while (acc <= hw_orate) { - /* Linear interpolation. (L) */ - d = ((d0_l * (hw_orate - acc)) + (d1_l * acc)) - / hw_orate; - /* unsigned -> signed (L) */ - d ^= 0x8000; - - bus_space_write_1(iot, ioh, NEC86_FIFODATA, - (d >> 8) & 0xff); /* -> big endian (L) */ - bus_space_write_1(iot, ioh, NEC86_FIFODATA, d & 0xff); - - /* Linear interpolation. (R) */ - d = ((d0_r * (hw_orate - acc)) + (d1_r * acc)) - / hw_orate; - /* unsigned -> signed (R) */ - d ^= 0x8000; - - bus_space_write_1(iot, ioh, NEC86_FIFODATA, - (d >> 8) & 0xff); /* -> big endian (R) */ - bus_space_write_1(iot, ioh, NEC86_FIFODATA, d & 0xff); - - acc += orate; - rval += 4; - } - - acc -= hw_orate; - } - - sc->conv_acc = acc; - sc->conv_last0_l = d0_l; - sc->conv_last0_r = d0_r; - sc->conv_last1_l = d1_l; - sc->conv_last1_r = d1_r; - - return rval; -} - /* * Read data from the FIFO ring buffer on the board. */ @@ -1534,223 +1278,6 @@ nec86fifo_input_stereo_16_direct(struct nec86hw_softc *sc, int cc) } } -/* - * Routines to read data with resampling. (linear interpolation) - */ -void -nec86fifo_input_mono_8_resamp(struct nec86hw_softc *sc, int cc) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t *p = sc->pdma_ptr; - int i; - register u_int8_t d_l, d_r; - register u_int8_t d0, d1; - register u_long acc, irate, hw_irate; - - irate = sc->sc_irate; - hw_irate = sc->hw_irate; - acc = sc->conv_acc; - d0 = sc->conv_last0; - d1 = sc->conv_last1; - - for (i = 0; i < cc; i++) { - while (acc > irate) { - d0 = d1; - /* signed -> unsigned (L) */ - d_l = bus_space_read_1(iot, ioh, NEC86_FIFODATA) ^ 0x80; - /* signed -> unsigned (R) */ - d_r = bus_space_read_1(iot, ioh, NEC86_FIFODATA) ^ 0x80; - /* Fake monoral recording by taking arithmetical mean. */ - d1 = (d_l + d_r) / 2; - - acc -= irate; - } - - /* Linear interpolation. */ - *p++ = ((d0 * (irate - acc)) + (d1 * acc)) / irate; - - acc += hw_irate; - } - - sc->conv_acc = acc; - sc->conv_last0 = d0; - sc->conv_last1 = d1; -} - -void -nec86fifo_input_mono_16_resamp(struct nec86hw_softc *sc, int cc) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t *p = sc->pdma_ptr; - int i; - register u_short d, d_l, d_r; - register u_short d0, d1; - register u_long acc, irate, hw_irate; - - irate = sc->sc_irate; - hw_irate = sc->hw_irate; - acc = sc->conv_acc; - d0 = sc->conv_last0; - d1 = sc->conv_last1; - - for (i = 0; i < cc; i++) { - while (acc > irate) { - d0 = d1; - /* big endian signed -> unsigned (L) */ - d_l = (bus_space_read_1(iot, ioh, NEC86_FIFODATA) - ^ 0x80) << 8; - d_l |= bus_space_read_1(iot, ioh, NEC86_FIFODATA); - /* big endian signed -> unsigned (R) */ - d_r = (bus_space_read_1(iot, ioh, NEC86_FIFODATA) - ^ 0x80) << 8; - d_r |= bus_space_read_1(iot, ioh, NEC86_FIFODATA); - /* Fake monoral recording by taking arithmetical mean. */ - d1 = (d_l + d_r) / 2; - - acc -= irate; - } - - /* Linear interpolation. */ - d = ((d0 * (irate - acc)) + (d1 * acc)) / irate; - -#if BYTE_ORDER == BIG_ENDIAN - /* -> big endian signed */ - *p++ = ((d >> 8) & 0xff) ^ 0x80; - *p++ = d & 0xff; -#else - /* -> little endian signed */ - *p++ = d & 0xff; - *p++ = ((d >> 8) & 0xff) ^ 0x80; -#endif - - acc += hw_irate; - } - - sc->conv_acc = acc; - sc->conv_last0 = d0; - sc->conv_last1 = d1; -} - -void -nec86fifo_input_stereo_8_resamp(struct nec86hw_softc *sc, int cc) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t *p = sc->pdma_ptr; - int i; - register u_int8_t d0_l, d0_r, d1_l, d1_r; - register u_long acc, irate, hw_irate; - - irate = sc->sc_irate; - hw_irate = sc->hw_irate; - acc = sc->conv_acc; - d0_l = sc->conv_last0_l; - d0_r = sc->conv_last0_r; - d1_l = sc->conv_last1_l; - d1_r = sc->conv_last1_r; - - for (i = 0; i < cc; i++) { - while (acc > irate) { - d0_l = d1_l; - d0_r = d1_r; - /* signed -> unsigned (L) */ - d1_l = bus_space_read_1(iot, ioh, NEC86_FIFODATA) - ^ 0x80; - /* signed -> unsigned (R) */ - d1_r = bus_space_read_1(iot, ioh, NEC86_FIFODATA) - ^ 0x80; - - acc -= irate; - } - - /* Linear interpolation. (L) */ - *p++ = ((d0_l * (irate - acc)) + (d1_l * acc)) / irate; - - /* Linear interpolation. (R) */ - *p++ = ((d0_r * (irate - acc)) + (d1_r * acc)) / irate; - - acc += hw_irate; - } - - sc->conv_acc = acc; - sc->conv_last0_l = d0_l; - sc->conv_last0_r = d0_r; - sc->conv_last1_l = d1_l; - sc->conv_last1_r = d1_r; -} - -void -nec86fifo_input_stereo_16_resamp(struct nec86hw_softc *sc, int cc) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t *p = sc->pdma_ptr; - int i; - register u_short d, d0_l, d0_r, d1_l, d1_r; - register u_long acc, irate, hw_irate; - - irate = sc->sc_irate; - hw_irate = sc->hw_irate; - acc = sc->conv_acc; - d0_l = sc->conv_last0_l; - d0_r = sc->conv_last0_r; - d1_l = sc->conv_last1_l; - d1_r = sc->conv_last1_r; - - for (i = 0; i < cc; i++) { - while (acc > irate) { - d0_l = d1_l; - d0_r = d1_r; - /* big endian signed -> unsigned (L) */ - d1_l = (bus_space_read_1(iot, ioh, NEC86_FIFODATA) - ^ 0x80) << 8; - d1_l |= bus_space_read_1(iot, ioh, NEC86_FIFODATA); - /* big endian signed -> unsigned (R) */ - d1_r = (bus_space_read_1(iot, ioh, NEC86_FIFODATA) - ^ 0x80) << 8; - d1_r |= bus_space_read_1(iot, ioh, NEC86_FIFODATA); - - acc -= irate; - } - - /* Linear interpolation. (L) */ - d = ((d0_l * (irate - acc)) + (d1_l * acc)) / irate; - -#if BYTE_ORDER == BIG_ENDIAN - /* -> big endian signed (L) */ - *p++ = ((d >> 8) & 0xff) ^ 0x80; - *p++ = d & 0xff; -#else - /* -> little endian signed (L) */ - *p++ = d & 0xff; - *p++ = ((d >> 8) & 0xff) ^ 0x80; -#endif - - /* Linear interpolation. (R) */ - d = ((d0_r * (irate - acc)) + (d1_r * acc)) / irate; - -#if BYTE_ORDER == BIG_ENDIAN - /* -> big endian signed (R) */ - *p++ = ((d >> 8) & 0xff) ^ 0x80; - *p++ = d & 0xff; -#else - /* -> little endian signed (R) */ - *p++ = d & 0xff; - *p++ = ((d >> 8) & 0xff) ^ 0x80; -#endif - - acc += hw_irate; - } - - sc->conv_acc = acc; - sc->conv_last0_l = d0_l; - sc->conv_last0_r = d0_r; - sc->conv_last1_l = d1_l; - sc->conv_last1_r = d1_r; -} - /* * Write padding zero's to the FIFO ring buffer on the board. */ diff --git a/sys/arch/luna88k/conf/files.luna88k b/sys/arch/luna88k/conf/files.luna88k index 837969ad6e3..f4d8fd9aa6c 100644 --- a/sys/arch/luna88k/conf/files.luna88k +++ b/sys/arch/luna88k/conf/files.luna88k @@ -1,4 +1,4 @@ -# $OpenBSD: files.luna88k,v 1.26 2015/03/03 23:50:37 aoyama Exp $ +# $OpenBSD: files.luna88k,v 1.27 2015/05/11 06:46:21 ratchov Exp $ # maxpartitions 16 @@ -68,7 +68,7 @@ attach pcex at cbus file arch/luna88k/cbus/pcex.c pcex needs-flag # NEC PC-9801-86 sound board -device necsb: audio, auconv, mulaw +device necsb: audio attach necsb at cbus file arch/luna88k/cbus/necsb.c necsb needs-flag file arch/luna88k/cbus/nec86.c necsb needs-flag diff --git a/sys/arch/macppc/conf/files.macppc b/sys/arch/macppc/conf/files.macppc index 45225c715cc..28c6cd7d6ec 100644 --- a/sys/arch/macppc/conf/files.macppc +++ b/sys/arch/macppc/conf/files.macppc @@ -1,4 +1,4 @@ -# $OpenBSD: files.macppc,v 1.80 2015/01/20 17:08:35 mpi Exp $ +# $OpenBSD: files.macppc,v 1.81 2015/05/11 06:46:21 ratchov Exp $ # # macppc-specific configuration info @@ -162,7 +162,7 @@ device abtn attach abtn at adb file arch/macppc/dev/abtn.c abtn -device awacs: audio, auconv, mulaw +device awacs: audio attach awacs at macobio file arch/macppc/dev/awacs.c awacs @@ -192,27 +192,27 @@ attach xlights at macobio file arch/macppc/dev/xlights.c xlights # snapper audio -device snapper: audio, auconv, mulaw, i2s +device snapper: audio, i2s attach snapper at macobio file arch/macppc/dev/snapper.c snapper # tumbler audio -device tumbler: audio, auconv, mulaw, i2s +device tumbler: audio, i2s attach tumbler at macobio file arch/macppc/dev/tumbler.c tumbler # onyx audio -device onyx: audio, auconv, mulaw, i2s +device onyx: audio, i2s attach onyx at macobio file arch/macppc/dev/onyx.c onyx # aoa audio -device aoa: audio, auconv, mulaw, i2s +device aoa: audio, i2s attach aoa at macobio file arch/macppc/dev/aoa.c aoa # daca audio -device daca: audio, auconv, mulaw, i2s +device daca: audio, i2s attach daca at macobio file arch/macppc/dev/daca.c daca diff --git a/sys/arch/macppc/dev/awacs.c b/sys/arch/macppc/dev/awacs.c index f8b0eab5744..6598493c830 100644 --- a/sys/arch/macppc/dev/awacs.c +++ b/sys/arch/macppc/dev/awacs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: awacs.c,v 1.30 2015/04/07 09:54:11 mpi Exp $ */ +/* $OpenBSD: awacs.c,v 1.31 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: awacs.c,v 1.4 2001/02/26 21:07:51 wiz Exp $ */ /*- @@ -33,9 +33,7 @@ #include #include -#include #include -#include #include #include @@ -503,53 +501,11 @@ awacs_query_encoding(void *h, struct audio_encoding *ae) { switch (ae->index) { case 0: - strlcpy(ae->name, AudioEslinear, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_SLINEAR; - ae->precision = 16; - ae->flags = 0; - break; - case 1: strlcpy(ae->name, AudioEslinear_be, sizeof ae->name); ae->encoding = AUDIO_ENCODING_SLINEAR_BE; ae->precision = 16; ae->flags = 0; break; - case 2: - strlcpy(ae->name, AudioEslinear_le, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_SLINEAR_LE; - ae->precision = 16; - ae->flags = 0; - break; - case 3: - strlcpy(ae->name, AudioEmulaw, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_ULAW; - ae->precision = 8; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: - strlcpy(ae->name, AudioEalaw, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_ALAW; - ae->precision = 8; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 5: - strlcpy(ae->name, AudioEulinear, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_ULINEAR; - ae->precision = 16; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(ae->name, AudioEulinear_le, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_ULINEAR_LE; - ae->precision = 16; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(ae->name, AudioEulinear_be, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_ULINEAR_BE; - ae->precision = 16; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -593,73 +549,12 @@ awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play, p->sample_rate = 4000; if (p->sample_rate > 50000) p->sample_rate = 50000; - if (p->precision > 16) - p->precision = 16; - if (p->channels > 2) - p->channels = 2; - p->factor = 1; - p->sw_code = NULL; awacs_write_reg(sc, AWACS_BYTE_SWAP, 0); - switch (p->encoding) { - - case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision != 16) - p->precision = 16; - if (p->channels == 2) - p->sw_code = swap_bytes; - else { - p->factor = 2; - p->sw_code = swap_bytes_mts; - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision != 16) - p->precision = 16; - if (p->channels == 1) { - p->factor = 2; - p->sw_code = noswap_bytes_mts; - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision != 16) - p->precision = 16; - if (p->channels == 2) - p->sw_code = swap_bytes_change_sign16_be; - else { - p->factor = 2; - p->sw_code = swap_bytes_change_sign16_be_mts; - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision != 16) - p->precision = 16; - if (p->channels == 2) - p->sw_code = change_sign16_be; - else { - p->factor = 2; - p->sw_code = change_sign16_be_mts; - } - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_be; - break; - } else - break; /* XXX */ - return (EINVAL); - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_be; - break; - } - return (EINVAL); - default: - return (EINVAL); - } + p->encoding = AUDIO_ENCODING_SLINEAR_BE; + p->precision = 16; + p->channels = 2; p->bps = AUDIO_BPS(p->precision); p->msb = 1; } diff --git a/sys/arch/macppc/dev/i2s.c b/sys/arch/macppc/dev/i2s.c index 288370bd8c3..37e6d897bcc 100644 --- a/sys/arch/macppc/dev/i2s.c +++ b/sys/arch/macppc/dev/i2s.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i2s.c,v 1.26 2015/04/07 09:54:11 mpi Exp $ */ +/* $OpenBSD: i2s.c,v 1.27 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: i2s.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */ /*- @@ -33,9 +33,7 @@ #include #include -#include #include -#include #include #include @@ -60,13 +58,9 @@ struct audio_params i2s_audio_default = { 16, /* precision */ 2, /* bps */ 1, /* msb */ - 2, /* channels */ - NULL, /* sw_code */ - 1 /* factor */ + 2 /* channels */ }; -struct i2s_mode *i2s_find_mode(u_int, u_int, u_int); - void i2s_mute(u_int, int); int i2s_cint(void *); u_int i2s_gpio_offset(struct i2s_softc *, char *, int *); @@ -244,59 +238,11 @@ i2s_query_encoding(h, ae) switch (ae->index) { case 0: - strlcpy(ae->name, AudioEslinear, sizeof(ae->name)); - ae->encoding = AUDIO_ENCODING_SLINEAR; - ae->precision = 16; - ae->flags = 0; - break; - case 1: strlcpy(ae->name, AudioEslinear_be, sizeof(ae->name)); ae->encoding = AUDIO_ENCODING_SLINEAR_BE; ae->precision = 16; ae->flags = 0; break; - case 2: - strlcpy(ae->name, AudioEslinear_le, sizeof(ae->name)); - ae->encoding = AUDIO_ENCODING_SLINEAR_LE; - ae->precision = 16; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(ae->name, AudioEulinear_be, sizeof(ae->name)); - ae->encoding = AUDIO_ENCODING_ULINEAR_BE; - ae->precision = 16; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: - strlcpy(ae->name, AudioEulinear_le, sizeof(ae->name)); - ae->encoding = AUDIO_ENCODING_ULINEAR_LE; - ae->precision = 16; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 5: - strlcpy(ae->name, AudioEmulaw, sizeof(ae->name)); - ae->encoding = AUDIO_ENCODING_ULAW; - ae->precision = 8; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(ae->name, AudioEalaw, sizeof(ae->name)); - ae->encoding = AUDIO_ENCODING_ALAW; - ae->precision = 8; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(ae->name, AudioEslinear, sizeof(ae->name)); - ae->encoding = AUDIO_ENCODING_SLINEAR; - ae->precision = 8; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 8: - strlcpy(ae->name, AudioEulinear, sizeof(ae->name)); - ae->encoding = AUDIO_ENCODING_ULINEAR; - ae->precision = 8; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: err = EINVAL; break; @@ -307,55 +253,12 @@ i2s_query_encoding(h, ae) } -struct i2s_mode { - u_int encoding; - u_int precision; - u_int channels; - void (*sw_code)(void *, u_char *, int); - int factor; -} i2s_modes[] = { - { AUDIO_ENCODING_SLINEAR_LE, 8, 1, linear8_to_linear16_be_mts, 4 }, - { AUDIO_ENCODING_SLINEAR_LE, 8, 2, linear8_to_linear16_be, 2 }, - { AUDIO_ENCODING_SLINEAR_LE, 16, 1, swap_bytes_mts, 2 }, - { AUDIO_ENCODING_SLINEAR_LE, 16, 2, swap_bytes, 1 }, - { AUDIO_ENCODING_SLINEAR_BE, 8, 1, linear8_to_linear16_be_mts, 4 }, - { AUDIO_ENCODING_SLINEAR_BE, 8, 2, linear8_to_linear16_be, 2 }, - { AUDIO_ENCODING_SLINEAR_BE, 16, 1, noswap_bytes_mts, 2 }, - { AUDIO_ENCODING_SLINEAR_BE, 16, 2, NULL, 1 }, - { AUDIO_ENCODING_ULINEAR_LE, 8, 1, ulinear8_to_linear16_be_mts, 4 }, - { AUDIO_ENCODING_ULINEAR_LE, 8, 2, ulinear8_to_linear16_be, 2 }, - { AUDIO_ENCODING_ULINEAR_LE, 16, 1, change_sign16_swap_bytes_le_mts, 2 }, - { AUDIO_ENCODING_ULINEAR_LE, 16, 2, swap_bytes_change_sign16_be, 1 }, - { AUDIO_ENCODING_ULINEAR_BE, 8, 1, ulinear8_to_linear16_be_mts, 4 }, - { AUDIO_ENCODING_ULINEAR_BE, 8, 2, ulinear8_to_linear16_be, 2 }, - { AUDIO_ENCODING_ULINEAR_BE, 16, 1, change_sign16_be_mts, 2 }, - { AUDIO_ENCODING_ULINEAR_BE, 16, 2, change_sign16_be, 1 } -}; - - -struct i2s_mode * -i2s_find_mode(u_int encoding, u_int precision, u_int channels) -{ - struct i2s_mode *m; - int i; - - for (i = 0; i < sizeof(i2s_modes)/sizeof(i2s_modes[0]); i++) { - m = &i2s_modes[i]; - if (m->encoding == encoding && - m->precision == precision && - m->channels == channels) - return (m); - } - return (NULL); -} - int i2s_set_params(h, setmode, usemode, play, rec) void *h; int setmode, usemode; struct audio_params *play, *rec; { - struct i2s_mode *m; struct i2s_softc *sc = h; struct audio_params *p; int mode; @@ -394,53 +297,8 @@ i2s_set_params(h, setmode, usemode, play, rec) p->channels = 2; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_LE: case AUDIO_ENCODING_SLINEAR_BE: - case AUDIO_ENCODING_ULINEAR_LE: - case AUDIO_ENCODING_ULINEAR_BE: - m = i2s_find_mode(p->encoding, p->precision, - p->channels); - if (m == NULL) { - printf("mode not found: %u/%u/%u\n", - p->encoding, p->precision, p->channels); - return (EINVAL); - } - p->factor = m->factor; - p->sw_code = m->sw_code; break; - - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - if (p->channels == 1) { - p->factor = 4; - p->sw_code = mulaw_to_slinear16_be_mts; - break; - } - if (p->channels == 2) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_be; - break; - } - } else - break; /* XXX */ - return (EINVAL); - - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - if (p->channels == 1) { - p->factor = 4; - p->sw_code = alaw_to_slinear16_be_mts; - break; - } - if (p->channels == 2) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_be; - break; - } - } else - break; /* XXX */ - return (EINVAL); - default: return (EINVAL); } diff --git a/sys/arch/sgi/dev/mavb.c b/sys/arch/sgi/dev/mavb.c index 0b2b422b872..eba9a936eb0 100644 --- a/sys/arch/sgi/dev/mavb.c +++ b/sys/arch/sgi/dev/mavb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mavb.c,v 1.17 2014/05/19 21:18:42 miod Exp $ */ +/* $OpenBSD: mavb.c,v 1.18 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -229,158 +229,29 @@ mavb_query_encoding(void *hdl, struct audio_encoding *ae) { switch (ae->index) { case 0: - /* 8-bit Unsigned Linear PCM. */ - strlcpy(ae->name, AudioEulinear, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_ULINEAR; - ae->precision = 8; - ae->flags = 0; - break; - case 1: - /* 16-bit Signed Linear PCM. */ + /* 24-bit Signed Linear PCM LSB-aligned. */ strlcpy(ae->name, AudioEslinear_be, sizeof ae->name); ae->encoding = AUDIO_ENCODING_SLINEAR_BE; - ae->precision = 16; - ae->flags = 0; - break; - case 2: - /* 8-bit mu-Law Companded. */ - strlcpy(ae->name, AudioEmulaw, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_ULAW; - ae->precision = 8; - ae->flags = 0; - break; - case 3: - /* 8-bit A-Law Companded. */ - strlcpy(ae->name, AudioEalaw, sizeof ae->name); - ae->encoding = AUDIO_ENCODING_ALAW; - ae->precision = 8; + ae->precision = 24; ae->flags = 0; break; default: return (EINVAL); } ae->bps = AUDIO_BPS(ae->precision); - ae->msb = 1; - + ae->msb = 0; return (0); } -/* - * For some reason SGI has decided to standardize their sound hardware - * interfaces on 24-bit PCM even though the AD1843 codec used in the - * Moosehead A/V Board only supports 16-bit and 8-bit formats. - * Therefore we must convert everything to 24-bit samples only to have - * the MACE hardware convert them back into 16-bit samples again. To - * complicate matters further, the 24-bit samples are embedded 32-bit - * integers. The 8-bit and 16-bit samples are first converted into - * 24-bit samples by padding them to the right with zeroes. Then they - * are sign-extended into 32-bit integers. This conversion is - * conveniently done through the software encoding layer of the high - * level audio driver by using the functions below. Conversion of - * mu-law and A-law formats is done by the hardware. - */ - -static void -linear16_to_linear24_be(void *hdl, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while ((cc -= 2) >= 0) { - q -= 4; - q[3] = 0; - q[2] = *--p; - q[1] = *--p; - q[0] = (*p & 0x80) ? 0xff : 0; - } -} - -static void -linear24_to_linear16_be(void *hdl, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[1]; - *q++ = p[2]; - p += 4; - } -} - -static void -ulinear8_to_ulinear24_be(void *hdl, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - q -= 4; - q[3] = 0; - q[2] = 0; - q[1] = *--p; - q[0] = (*p & 0x80) ? 0xff : 0; - } -} - -static void -ulinear24_to_ulinear8_be(void *hdl, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[1]; - p += 4; - } -} - -static void -linear16_to_linear24_be_mts(void *hdl, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while ((cc -= 2) >= 0) { - q -= 8; - q[3] = q[7] = 0; - q[2] = q[6] = *--p; - q[1] = q[5] = *--p; - q[0] = q[4] = (*p & 0x80) ? 0xff : 0; - } -} - -static void -ulinear8_to_ulinear24_be_mts(void *hdl, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 8; - while (--cc >= 0) { - q -= 8; - q[3] = q[7] = 0; - q[2] = q[6] = 0; - q[1] = q[5] = *--p; - q[0] = q[4] = (*p & 0x80) ? 0xff : 0; - } -} - void 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->precision = 24; + p->bps = 4; + p->msb = 0; p->channels = 2; - p->factor = 2; - if (mode == AUMODE_PLAY) - p->sw_code = linear16_to_linear24_be; - else - p->sw_code = linear24_to_linear16_be; } static int @@ -486,52 +357,11 @@ mavb_set_params(void *hdl, int setmode, int usemode, play->precision, play->channels)); if (setmode & AUMODE_PLAY) { - switch (play->encoding) { - case AUDIO_ENCODING_ULAW: - case AUDIO_ENCODING_ALAW: - case AUDIO_ENCODING_ULINEAR_BE: - if (play->precision != 8) - return (EINVAL); - switch (play->channels) { - case 1: - play->factor = 8; - play->sw_code = ulinear8_to_ulinear24_be_mts; - break; - case 2: - play->factor = 4; - play->sw_code = ulinear8_to_ulinear24_be; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (play->precision == 16) { - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = - linear16_to_linear24_be_mts; - break; - case 2: - play->factor = 2; - play->sw_code = - linear16_to_linear24_be; - break; - default: - return (EINVAL); - } - } else { - play->factor = 1; - play->sw_code = NULL; - play->channels = 2; - play->precision = 24; - } - break; - default: - return (EINVAL); - } - + play->encoding = AUDIO_ENCODING_SLINEAR_BE; + play->channels = 2; + play->precision = 24; + play->bps = AUDIO_BPS(play->precision); + play->msb = 0; error = mavb_set_play_rate(sc, play->sample_rate); if (error) return (error); @@ -540,38 +370,14 @@ mavb_set_params(void *hdl, int setmode, int usemode, if (error) return (error); - play->bps = AUDIO_BPS(play->precision); - play->msb = 0; } if (setmode & AUMODE_RECORD) { - switch (rec->encoding) { - case AUDIO_ENCODING_ULAW: - case AUDIO_ENCODING_ALAW: - case AUDIO_ENCODING_ULINEAR_BE: - if (rec->precision != 8) - return (EINVAL); - rec->factor = 4; - rec->sw_code = ulinear24_to_ulinear8_be; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (rec->precision == 16) { - rec->factor = 2; - rec->sw_code = linear24_to_linear16_be; - } else { - rec->factor = 1; - rec->sw_code = NULL; - rec->channels = 2; - rec->precision = 24; - break; - } - break; - default: - return (EINVAL); - } - - /* stereo to mono conversions not yet implemented */ + rec->encoding = AUDIO_ENCODING_SLINEAR_BE; rec->channels = 2; + rec->precision = 24; + rec->bps = AUDIO_BPS(rec->precision); + rec->msb = 0; error = mavb_set_rec_rate(sc, rec->sample_rate); if (error) @@ -580,9 +386,6 @@ 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 = 0; } return (0); diff --git a/sys/arch/sgi/hpc/files.hpc b/sys/arch/sgi/hpc/files.hpc index 43065f22e26..8bee3cac6fa 100644 --- a/sys/arch/sgi/hpc/files.hpc +++ b/sys/arch/sgi/hpc/files.hpc @@ -1,4 +1,4 @@ -# $OpenBSD: files.hpc,v 1.5 2014/04/18 21:55:24 jasper Exp $ +# $OpenBSD: files.hpc,v 1.6 2015/05/11 06:46:21 ratchov Exp $ # $NetBSD: files.hpc,v 1.14 2009/05/14 01:10:19 macallan Exp $ # IP20 RTC @@ -22,7 +22,7 @@ device wdsc: wd33c93ctrl, scsi, hpcdma attach wdsc at hpc file arch/sgi/hpc/wdsc.c wdsc -device haltwo: audio, auconv, mulaw +device haltwo: audio attach haltwo at hpc file arch/sgi/hpc/haltwo.c haltwo diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index e30debbc07c..6445cb1b8ac 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc,v 1.99 2015/03/30 20:30:20 miod Exp $ +# $OpenBSD: files.sparc,v 1.100 2015/05/11 06:46:21 ratchov Exp $ # $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 @@ -148,12 +148,12 @@ file arch/sparc/dev/hme.c hme attach esp at sbus, dma, obio file arch/sparc/dev/esp.c esp -device audioamd: audio, am7930, mulaw +device audioamd: audio, am7930 attach audioamd at mainbus, obio, sbus file arch/sparc/dev/audioamd.c audioamd file arch/sparc/sparc/amd7930intr.s audioamd -device audiocs: audio, auconv +device audiocs: audio attach audiocs at sbus file arch/sparc/dev/cs4231.c audiocs diff --git a/sys/arch/sparc/dev/audioamd.c b/sys/arch/sparc/dev/audioamd.c index 5547a3f2d4f..3f781117cf9 100644 --- a/sys/arch/sparc/dev/audioamd.c +++ b/sys/arch/sparc/dev/audioamd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audioamd.c,v 1.3 2013/05/15 21:19:16 ratchov Exp $ */ +/* $OpenBSD: audioamd.c,v 1.4 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: audioamd.c,v 1.26 2011/06/04 01:27:57 tsutsui Exp $ */ /* @@ -107,7 +107,8 @@ struct am7930_glue audioamd_glue = { audioamd_codec_iread16, audioamd_codec_iwrite16, audioamd_onopen, - audioamd_onclose + audioamd_onclose, + 8 }; /* diff --git a/sys/arch/sparc/dev/cs4231.c b/sys/arch/sparc/dev/cs4231.c index 0f5ab7d281a..89e05fc768d 100644 --- a/sys/arch/sparc/dev/cs4231.c +++ b/sys/arch/sparc/dev/cs4231.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4231.c,v 1.32 2014/07/12 18:44:42 tedu Exp $ */ +/* $OpenBSD: cs4231.c,v 1.33 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -47,7 +47,6 @@ #include #include -#include #include #include #include @@ -621,24 +620,6 @@ cs4231_query_encoding(addr, fp) fp->flags = 0; break; case 5: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - 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; - break; - case 8: strlcpy(fp->name, AudioEadpcm, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ADPCM; fp->precision = 8; @@ -660,8 +641,6 @@ cs4231_set_params(addr, setmode, usemode, p, r) { struct cs4231_softc *sc = (struct cs4231_softc *)addr; int err, bits, enc = p->encoding; - void (*pswcode)(void *, u_char *, int cnt) = NULL; - void (*rswcode)(void *, u_char *, int cnt) = NULL; switch (enc) { case AUDIO_ENCODING_ULAW: @@ -675,51 +654,20 @@ cs4231_set_params(addr, setmode, usemode, p, r) bits = FMT_ALAW >> 5; break; case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision == 8) { - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; - } else if (p->precision == 16) - bits = FMT_TWOS_COMP >> 5; - else + if (p->precision != 16) return (EINVAL); - break; - case AUDIO_ENCODING_ULINEAR: - if (p->precision != 8) - return (EINVAL); - bits = FMT_PCM8 >> 5; + bits = FMT_TWOS_COMP >> 5; break; case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 8) { - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; - } else if (p->precision == 16) - bits = FMT_TWOS_COMP_BE >> 5; - else - return (EINVAL); - break; - case AUDIO_ENCODING_SLINEAR: - if (p->precision != 8) + if (p->precision != 16) return (EINVAL); - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; + bits = FMT_TWOS_COMP_BE >> 5; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 8) - bits = FMT_PCM8 >> 5; - else if (p->precision == 16) { - bits = FMT_TWOS_COMP >> 5; - pswcode = rswcode = change_sign16_le; - } else - return (EINVAL); - break; case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 8) - bits = FMT_PCM8 >> 5; - else if (p->precision == 16) { - bits = FMT_TWOS_COMP_BE >> 5; - pswcode = rswcode = change_sign16_be; - } else + if (p->precision != 8) return (EINVAL); + bits = FMT_PCM8 >> 5; break; case AUDIO_ENCODING_ADPCM: if (p->precision != 8) @@ -737,8 +685,6 @@ cs4231_set_params(addr, setmode, usemode, p, r) if (err) return (err); - 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; diff --git a/sys/arch/sparc64/conf/files.sparc64 b/sys/arch/sparc64/conf/files.sparc64 index bc0f1b287fc..77f31fc8c5c 100644 --- a/sys/arch/sparc64/conf/files.sparc64 +++ b/sys/arch/sparc64/conf/files.sparc64 @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc64,v 1.145 2014/07/11 21:54:38 tedu Exp $ +# $OpenBSD: files.sparc64,v 1.146 2015/05/11 06:46:21 ratchov Exp $ # $NetBSD: files.sparc64,v 1.50 2001/08/10 20:53:50 eeh Exp $ # maxpartitions must be first item in files.${ARCH} @@ -243,7 +243,7 @@ device sabtty attach sabtty at sab file arch/sparc64/dev/sab.c sab | sabtty needs-flag -device audioce: audio, auconv +device audioce: audio attach audioce at ebus file arch/sparc64/dev/ce4231.c audioce diff --git a/sys/arch/sparc64/dev/ce4231.c b/sys/arch/sparc64/dev/ce4231.c index adb08d06851..3352fbadf8e 100644 --- a/sys/arch/sparc64/dev/ce4231.c +++ b/sys/arch/sparc64/dev/ce4231.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ce4231.c,v 1.31 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: ce4231.c,v 1.32 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -51,7 +51,6 @@ #include #include -#include #include #include @@ -508,24 +507,6 @@ ce4231_query_encoding(addr, fp) fp->flags = 0; break; case 5: - strlcpy(fp->name, AudioEslinear, sizeof(fp->name)); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEulinear_le, sizeof(fp->name)); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - 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; - break; - case 8: strlcpy(fp->name, AudioEadpcm, sizeof(fp->name)); fp->encoding = AUDIO_ENCODING_ADPCM; fp->precision = 8; @@ -547,66 +528,32 @@ ce4231_set_params(addr, setmode, usemode, p, r) { struct ce4231_softc *sc = (struct ce4231_softc *)addr; int err, bits, enc = p->encoding; - void (*pswcode)(void *, u_char *, int cnt) = NULL; - void (*rswcode)(void *, u_char *, int cnt) = NULL; if (p->precision > 16) p->precision = 16; switch (enc) { case AUDIO_ENCODING_ULAW: - if (p->precision != 8) - p->precision = 8; + p->precision = 8; bits = FMT_ULAW >> 5; break; case AUDIO_ENCODING_ALAW: - if (p->precision != 8) - p->precision = 8; + p->precision = 8; bits = FMT_ALAW >> 5; break; case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision == 8) { - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; - } else - bits = FMT_TWOS_COMP >> 5; - break; - case AUDIO_ENCODING_ULINEAR: - if (p->precision != 8) - p->precision = 8; - bits = FMT_PCM8 >> 5; + p->precision = 16; + bits = FMT_TWOS_COMP >> 5; break; case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 8) { - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; - } else - bits = FMT_TWOS_COMP_BE >> 5; - break; - case AUDIO_ENCODING_SLINEAR: - if (p->precision != 8) - p->precision = 8; - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; + p->precision = 16; + bits = FMT_TWOS_COMP_BE >> 5; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 8) - bits = FMT_PCM8 >> 5; - else { - bits = FMT_TWOS_COMP >> 5; - pswcode = rswcode = change_sign16_le; - } - break; case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 8) - bits = FMT_PCM8 >> 5; - else { - bits = FMT_TWOS_COMP_BE >> 5; - pswcode = rswcode = change_sign16_be; - } + p->precision = 8; break; case AUDIO_ENCODING_ADPCM: - if (p->precision != 8) - p->precision = 8; + p->precision = 8; bits = FMT_ADPCM >> 5; break; default: @@ -620,8 +567,6 @@ ce4231_set_params(addr, setmode, usemode, p, r) if (err) return (err); - 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; diff --git a/sys/arch/vax/conf/files.vax b/sys/arch/vax/conf/files.vax index d6c8b01fe97..14801813ddc 100644 --- a/sys/arch/vax/conf/files.vax +++ b/sys/arch/vax/conf/files.vax @@ -1,4 +1,4 @@ -# $OpenBSD: files.vax,v 1.58 2014/10/18 12:21:56 miod Exp $ +# $OpenBSD: files.vax,v 1.59 2015/05/11 06:46:21 ratchov Exp $ # $NetBSD: files.vax,v 1.60 1999/08/27 20:04:32 ragge Exp $ # # new style config file for vax architecture @@ -155,7 +155,7 @@ device led attach led at mainbus file arch/vax/vax/led.c led needs-flag -device vsaudio: audio, am7930, mulaw +device vsaudio: audio, am7930 attach vsaudio at vsbus file arch/vax/vsa/vsaudio.c vsaudio diff --git a/sys/arch/vax/vsa/vsaudio.c b/sys/arch/vax/vsa/vsaudio.c index b9fd534e145..eb03cf56baf 100644 --- a/sys/arch/vax/vsa/vsaudio.c +++ b/sys/arch/vax/vsa/vsaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vsaudio.c,v 1.4 2013/05/15 21:21:11 ratchov Exp $ */ +/* $OpenBSD: vsaudio.c,v 1.5 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2011 Miodrag Vallat. @@ -134,7 +134,8 @@ struct am7930_glue vsaudio_glue = { vsaudio_codec_iread16, vsaudio_codec_iwrite16, vsaudio_onopen, - vsaudio_onclose + vsaudio_onclose, + 8 }; /* diff --git a/sys/arch/zaurus/conf/files.zaurus b/sys/arch/zaurus/conf/files.zaurus index 0f909372749..1a566399193 100644 --- a/sys/arch/zaurus/conf/files.zaurus +++ b/sys/arch/zaurus/conf/files.zaurus @@ -1,4 +1,4 @@ -# $OpenBSD: files.zaurus,v 1.30 2014/10/18 12:21:57 miod Exp $ +# $OpenBSD: files.zaurus,v 1.31 2015/05/11 06:46:21 ratchov Exp $ # # First try for arm-specific configuration info # @@ -61,7 +61,7 @@ attach zts at pxaip file arch/zaurus/dev/zts.c zts # Zaurus sound -device zaudio: audio, auconv, mulaw, i2s, i2c +device zaudio: audio, i2s, i2c attach zaudio at pxaip file arch/zaurus/dev/zaurus_audio.c zaudio diff --git a/sys/arch/zaurus/dev/zaurus_audio.c b/sys/arch/zaurus/dev/zaurus_audio.c index f0bd34352ad..8d83c91a27d 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.18 2014/09/19 16:45:55 jsg Exp $ */ +/* $OpenBSD: zaurus_audio.c,v 1.19 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2005 Christopher Pascoe @@ -42,10 +42,7 @@ #include #include - #include -#include -#include #define WM8750_ADDRESS 0x1B #define SPKR_VOLUME 112 @@ -483,53 +480,11 @@ zaudio_query_encoding(void *hdl, struct audio_encoding *aep) { switch (aep->index) { case 0: - strlcpy(aep->name, AudioEulinear, sizeof(aep->name)); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = 0; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof(aep->name)); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof(aep->name)); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof(aep->name)); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(aep->name, AudioEslinear_le, sizeof(aep->name)); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -545,177 +500,9 @@ zaudio_set_params(void *hdl, int setmode, int usemode, struct zaudio_softc *sc = hdl; if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = NULL; - switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = mulaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = noswap_bytes_mts; - break; - case 2: - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = - ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = change_sign16_le_mts; - break; - case 2: - play->sw_code = change_sign16_le; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ALAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = alaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = - linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_mts; - break; - case 2: - play->sw_code = swap_bytes; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = - ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = - swap_bytes_change_sign16_le_mts; - break; - case 2: - play->sw_code = - swap_bytes_change_sign16_le; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - + play->precision = 16; + play->channels = 2; + play->encoding = AUDIO_ENCODING_SLINEAR_LE; play->bps = AUDIO_BPS(play->precision); play->msb = 1; @@ -724,37 +511,9 @@ zaudio_set_params(void *hdl, int setmode, int usemode, #if RECORD_XXX_NOT_YET if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = NULL; - switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - rec->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_SLINEAR_LE: - if (rec->precision == 8) - rec->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_LE: - if (rec->precision == 16) - rec->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ALAW: - rec->sw_code = ulinear8_to_alaw; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes; - else - rec->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (rec->precision == 16) - rec->sw_code = change_sign16_swap_bytes_le; - break; - default: - return (EINVAL); - } - + rec->precision = 16; + rec->channels = 2; + rec->encoding = AUDIO_ENCODING_SLINEAR_LE; rec->bps = AUDIO_BPS(rec->precision); rec->msb = 1; diff --git a/sys/conf/files b/sys/conf/files index 10916f534e6..af05b5c91b7 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.591 2014/12/28 21:32:44 krw Exp $ +# $OpenBSD: files,v 1.592 2015/05/11 06:46:21 ratchov Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -24,10 +24,6 @@ define video {} # filesystem firmware loading attribute define firmload -# audio device attributes -define mulaw -define auconv - # radio device attributes define tea5757 define lm700x @@ -489,7 +485,7 @@ define am7930 file dev/ic/am7930.c am7930 # Siemens PSB2160 audio codec, as found in HP systems -device arcofi: audio, auconv, mulaw +device arcofi: audio file dev/ic/arcofi.c arcofi # radio devices, attaches to radio hardware driver @@ -626,7 +622,6 @@ file ddb/db_variables.c ddb file ddb/db_watch.c ddb file ddb/db_write_cmd.c ddb file ddb/db_usrreq.c ddb -file dev/auconv.c auconv file dev/audio.c audio needs-flag file dev/cons.c file dev/diskmap.c @@ -641,7 +636,7 @@ file dev/ic/lm700x.c lm700x file dev/ic/tc921x.c tc921x file dev/ic/pt2254a.c pt2254a file dev/midi.c midi | midibus needs-flag -file dev/mulaw.c mulaw +file dev/mulaw.c audio needs-flag file dev/systrace.c systrace needs-flag file dev/vnd.c vnd needs-flag file dev/rnd.c diff --git a/sys/dev/auconv.c b/sys/dev/auconv.c deleted file mode 100644 index f2b3d0957b7..00000000000 --- a/sys/dev/auconv.c +++ /dev/null @@ -1,509 +0,0 @@ -/* $OpenBSD: auconv.c,v 1.10 2015/03/14 03:38:46 jsg Exp $ */ -/* $NetBSD: auconv.c,v 1.3 1999/11/01 18:12:19 augustss Exp $ */ - -/* - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#include -#include - -void -change_sign8(void *v, u_char *p, int cc) -{ - while (--cc >= 0) { - *p ^= 0x80; - ++p; - } -} - -void -change_sign16_le(void *v, u_char *p, int cc) -{ - while ((cc -= 2) >= 0) { - p[1] ^= 0x80; - p += 2; - } -} - -void -change_sign16_be(void *v, u_char *p, int cc) -{ - while ((cc -= 2) >= 0) { - p[0] ^= 0x80; - p += 2; - } -} - -void -swap_bytes(void *v, u_char *p, int cc) -{ - u_char t; - - while ((cc -= 2) >= 0) { - t = p[0]; - p[0] = p[1]; - p[1] = t; - p += 2; - } -} - -void -swap_bytes_change_sign16_le(void *v, u_char *p, int cc) -{ - u_char t; - - while ((cc -= 2) >= 0) { - t = p[1]; - p[1] = p[0] ^ 0x80; - p[0] = t; - p += 2; - } -} - -void -swap_bytes_change_sign16_be(void *v, u_char *p, int cc) -{ - u_char t; - - while ((cc -= 2) >= 0) { - t = p[0]; - p[0] = p[1] ^ 0x80; - p[1] = t; - p += 2; - } -} - -void -change_sign16_swap_bytes_le(void *v, u_char *p, int cc) -{ - swap_bytes_change_sign16_be(v, p, cc); -} - -void -change_sign16_swap_bytes_be(void *v, u_char *p, int cc) -{ - swap_bytes_change_sign16_le(v, p, cc); -} - -void -linear8_to_linear16_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while (--cc >= 0) { - q -= 2; - q[1] = *--p; - q[0] = 0; - } -} - -void -linear8_to_linear16_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while (--cc >= 0) { - q -= 2; - q[0] = *--p; - q[1] = 0; - } -} - -void -linear16_to_linear8_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 2) >= 0) { - *q++ = p[1]; - p += 2; - } -} - -void -linear16_to_linear8_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 2) >= 0) { - *q++ = p[0]; - p += 2; - } -} - -void -ulinear8_to_linear16_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while (--cc >= 0) { - q -= 2; - q[1] = (*--p) ^ 0x80; - q[0] = 0; - } -} - -void -ulinear8_to_linear16_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while (--cc >= 0) { - q -= 2; - q[0] = (*--p) ^ 0x80; - q[1] = 0; - } -} - -void -linear16_to_ulinear8_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 2) >= 0) { - *q++ = p[1] ^ 0x80; - p += 2; - } -} - -void -linear16_to_ulinear8_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 2) >= 0) { - *q++ = p[0] ^ 0x80; - p += 2; - } -} - -/* - * just expand mono to stereo, no other conversions - */ -void -noswap_bytes_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while ((cc -= 2) >= 0) { - q -= 4; - q[1] = q[3] = *--p; - q[0] = q[2] = *--p; - } -} - -/* - * same as swap_bytes(), plus expand mono to stereo - */ -void -swap_bytes_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while ((cc -= 2) >= 0) { - q -= 4; - q[0] = q[2] = *--p; - q[1] = q[3] = *--p; - } -} - -/* - * same as linear8_to_linear16_le(), plus expand mono to stereo - */ -void -linear8_to_linear16_le_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - q -= 4; - q[1] = q[3] = *--p; - q[0] = q[2] = 0; - } -} - -/* - * same as linear8_to_linear16_be(), plus expand mono to stereo - */ -void -linear8_to_linear16_be_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - q -= 4; - q[0] = q[2] = *--p; - q[1] = q[3] = 0; - } -} - -/* - * same as ulinear8_to_linear16_le(), plus expand mono to stereo - */ -void -ulinear8_to_linear16_le_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - q -= 4; - q[1] = q[3] = (*--p) ^ 0x80; - q[0] = q[2] = 0; - } -} - -/* - * same as ulinear8_to_linear16_be(), plus expand mono to stereo - */ -void -ulinear8_to_linear16_be_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - q -= 4; - q[0] = q[2] = (*--p) ^ 0x80; - q[1] = q[3] = 0; - } -} - -/* - * same as change_sign16_le(), plus expand mono to stereo - */ -void -change_sign16_le_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while ((cc -= 2) >= 0) { - q -= 4; - q[1] = q[3] = (*--p) ^ 0x80; - q[0] = q[2] = *--p; - } -} - -/* - * same as change_sign16_be(), plus expand mono to stereo - */ -void -change_sign16_be_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while ((cc -= 2) >= 0) { - q -= 4; - q[0] = q[2] = (*--p) ^ 0x80; - q[1] = q[3] = *--p; - } -} - -/* - * same as swap_bytes_change_sign16_le(), plus expand mono to stereo - */ -void -swap_bytes_change_sign16_le_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while ((cc -= 2) >= 0) { - q -= 4; - q[0] = q[2] = *--p; - q[1] = q[3] = (*--p) ^ 0x80; - } -} - -/* - * same as swap_bytes_change_sign16_be(), plus expand mono to stereo - */ -void -swap_bytes_change_sign16_be_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 2; - while ((cc -= 2) >= 0) { - q -= 4; - q[0] = q[2] = (*--p) ^ 0x80; - q[1] = q[3] = *--p; - } -} - -/* - * same as change_sign16_swap_bytes_le(), plus expand mono to stereo - */ -void -change_sign16_swap_bytes_le_mts(void *v, u_char *p, int cc) -{ - change_sign16_be_mts(v, p, cc); -} - -/* - * same as change_sign16_swap_bytes_be(), plus expand mono to stereo - */ -void -change_sign16_swap_bytes_be_mts(void *v, u_char *p, int cc) -{ - change_sign16_le_mts(v, p, cc); -} - - -void -linear16_decimator(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[0]; - *q++ = p[1]; - p += 4; - } -} - -void -linear16_to_linear8_le_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[1]; - p += 4; - } -} - -void -linear16_to_linear8_be_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[0]; - p += 4; - } -} - -void -linear16_to_ulinear8_le_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[1] ^ 0x80; - p += 4; - } -} - -void -linear16_to_ulinear8_be_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[0] ^ 0x80; - p += 4; - } -} - -void -change_sign16_le_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[0]; - *q++ = p[1] ^ 0x80; - p += 4; - } -} - -void -change_sign16_be_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[0] ^ 0x80; - *q++ = p[1]; - p += 4; - } -} - -void -swap_bytes_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[1]; - *q++ = p[0]; - p += 4; - } -} - -void -swap_bytes_change_sign16_be_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *q++ = p[1] ^ 0x80; - *q++ = p[0]; - p += 4; - } -} - -void -change_sign16_swap_bytes_le_stm(void *v, u_char *p, int cc) -{ - swap_bytes_change_sign16_be_stm(v, p, cc); -} diff --git a/sys/dev/auconv.h b/sys/dev/auconv.h deleted file mode 100644 index a5908e87ef5..00000000000 --- a/sys/dev/auconv.h +++ /dev/null @@ -1,101 +0,0 @@ -/* $OpenBSD: auconv.h,v 1.8 2008/06/26 05:42:14 ray Exp $ */ -/* $NetBSD: auconv.h,v 1.5 1999/11/01 18:12:19 augustss Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Lennart Augustsson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* Convert between signed and unsigned. */ -extern void change_sign8(void *, u_char *, int); -extern void change_sign16_le(void *, u_char *, int); -extern void change_sign16_be(void *, u_char *, int); -/* Convert between little and big endian. */ -extern void swap_bytes(void *, u_char *, int); -extern void swap_bytes_change_sign16_le(void *, u_char *, int); -extern void swap_bytes_change_sign16_be(void *, u_char *, int); -extern void change_sign16_swap_bytes_le(void *, u_char *, int); -extern void change_sign16_swap_bytes_be(void *, u_char *, int); -/* Byte expansion/contraction */ -extern void linear8_to_linear16_le(void *, u_char *, int); -extern void linear8_to_linear16_be(void *, u_char *, int); -extern void linear16_to_linear8_le(void *, u_char *, int); -extern void linear16_to_linear8_be(void *, u_char *, int); -/* Byte expansion/contraction with sign change */ -extern void ulinear8_to_linear16_le(void *, u_char *, int); -extern void ulinear8_to_linear16_be(void *, u_char *, int); -extern void linear16_to_ulinear8_le(void *, u_char *, int); -extern void linear16_to_ulinear8_be(void *, u_char *, int); - -/* same as above, plus converting mono to stereo */ -extern void noswap_bytes_mts(void *, u_char *, int); -extern void swap_bytes_mts(void *, u_char *, int); -extern void linear8_to_linear16_le_mts(void *, u_char *, int); -extern void linear8_to_linear16_be_mts(void *, u_char *, int); -extern void ulinear8_to_linear16_le_mts(void *, u_char *, int); -extern void ulinear8_to_linear16_be_mts(void *, u_char *, int); -extern void change_sign16_le_mts(void *, u_char *, int); -extern void change_sign16_be_mts(void *, u_char *, int); -extern void change_sign16_swap_bytes_le_mts(void *, u_char *, int); -extern void change_sign16_swap_bytes_be_mts(void *, u_char *, int); -void swap_bytes_change_sign16_le_mts(void *, u_char *, int); -void swap_bytes_change_sign16_be_mts(void *, u_char *, int); - -/* 16-bit signed linear stereo to mono. drops every other sample */ -void linear16_decimator(void *, u_char *, int); -void linear16_to_linear8_le_stm(void *, u_char *, int); -void linear16_to_linear8_be_stm(void *, u_char *, int); -void linear16_to_ulinear8_le_stm(void *, u_char *, int); -void linear16_to_ulinear8_be_stm(void *, u_char *, int); -void change_sign16_le_stm(void *, u_char *, int); -void change_sign16_be_stm(void *, u_char *, int); -void swap_bytes_stm(void *, u_char *, int); -void swap_bytes_change_sign16_be_stm(void *, u_char *, int); -void change_sign16_swap_bytes_le_stm(void *, u_char *, int); - -/* backwards compat for now */ -#if BYTE_ORDER == LITTLE_ENDIAN -#define change_sign16 change_sign16_le -#define change_sign16_swap_bytes swap_bytes_change_sign16_le -#define swap_bytes_change_sign16 swap_bytes_change_sign16_le -#define linear8_to_linear16 linear8_to_linear16_le -#define ulinear8_to_linear16 ulinear8_to_linear16_le -#define linear8_to_linear16_mts linear8_to_linear16_le_mts -#define ulinear8_to_linear16_mts ulinear8_to_linear16_le_mts -#define change_sign16_mts change_sign16_le_mts -#define change_sign16_swap_bytes_mts change_sign16_swap_bytes_le_mts -#else -#define change_sign16 change_sign16_be -#define change_sign16_swap_bytes swap_bytes_change_sign16_be -#define swap_bytes_change_sign16 swap_bytes_change_sign16_be -#define linear8_to_linear16 linear8_to_linear16_be -#define ulinear8_to_linear16 ulinear8_to_linear16_be -#define linear8_to_linear16_mts linear8_to_linear16_be_mts -#define ulinear8_to_linear16_mts ulinear8_to_linear16_be_mts -#define change_sign16_mts change_sign16_be_mts -#define change_sign16_swap_bytes_mts change_sign16_swap_bytes_be_mts -#endif diff --git a/sys/dev/audio.c b/sys/dev/audio.c index 8fac359ed8f..51c927c2ae3 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audio.c,v 1.129 2015/02/10 21:56:09 miod Exp $ */ +/* $OpenBSD: audio.c,v 1.130 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: audio.c,v 1.119 1999/11/09 16:50:47 augustss Exp $ */ /* @@ -52,7 +52,7 @@ #include #include - +#include #include #include "wskbd.h" /* NWSKBD (mixer tuning using keyboard) */ @@ -115,6 +115,11 @@ struct au_mixer_ports { u_int miport[AUDIO_N_PORTS]; }; +struct audio_emu { + void (*sw_code)(void *, u_char *, int); /* conv routine */ + int encoding; /* emulated encoding */ +}; + /* * Software state, per audio device. */ @@ -156,6 +161,9 @@ struct audio_softc { struct audio_params sc_pparams; /* play encoding parameters */ struct audio_params sc_rparams; /* record encoding parameters */ + struct audio_emu sc_pemu; /* play conversion params */ + struct audio_emu sc_remu; /* record conversion params */ + int sc_eof; /* EOF, i.e. zero sized write, counter */ u_long sc_wstamp; u_long sc_playdrop; @@ -212,6 +220,7 @@ int audiostartp(struct audio_softc *); void audio_rint(void *); void audio_pint(void *); int audio_check_params(struct audio_params *); +void audio_emu_setup(int, struct audio_params *, struct audio_emu *); void audio_set_blksize(struct audio_softc *, int, int); void audio_calc_blksize(struct audio_softc *, int); @@ -305,7 +314,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, 1, 1, 0, 1 }; + {8000, AUDIO_ENCODING_ULAW, 8, 1, 1, 1}; struct cfattach audio_ca = { sizeof(struct audio_softc), audioprobe, audioattach, @@ -416,7 +425,6 @@ audioattach(struct device *parent, struct device *self, void *aux) /* * Set default softc params */ - if (hwp->get_default_params) { hwp->get_default_params(hdlp, AUMODE_PLAY, &sc->sc_pparams); hwp->get_default_params(hdlp, AUMODE_RECORD, &sc->sc_rparams); @@ -424,6 +432,10 @@ audioattach(struct device *parent, struct device *self, void *aux) sc->sc_pparams = audio_default; sc->sc_rparams = audio_default; } + sc->sc_pemu.encoding = sc->sc_pparams.encoding; + sc->sc_pemu.sw_code = NULL; + sc->sc_remu.encoding = sc->sc_rparams.encoding; + sc->sc_remu.sw_code = NULL; /* Set up some default values */ sc->sc_rr.blkset = sc->sc_pr.blkset = 0; @@ -1139,17 +1151,16 @@ audio_open(dev_t dev, struct audio_softc *sc, int flags, int ifmt, goto bad; } #endif - AUDIO_INITINFO(&ai); ai.record.sample_rate = sc->sc_rparams.sample_rate; - ai.record.encoding = sc->sc_rparams.encoding; + ai.record.encoding = sc->sc_remu.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_pemu.encoding; ai.play.channels = sc->sc_pparams.channels; ai.play.precision = sc->sc_pparams.precision; ai.play.bps = sc->sc_pparams.bps; @@ -1217,10 +1228,9 @@ audio_drain(struct audio_softc *sc) u_char *inp = cb->inp; cc = cb->blksize - (inp - cb->start) % cb->blksize; - if (sc->sc_pparams.sw_code) { - int ncc = cc / sc->sc_pparams.factor; - audio_fill_silence(&sc->sc_pparams, cb->start, inp, ncc); - sc->sc_pparams.sw_code(sc->hw_hdl, inp, ncc); + if (sc->sc_pemu.sw_code) { + audio_fill_silence(&sc->sc_pparams, cb->start, inp, cc); + sc->sc_pemu.sw_code(sc->hw_hdl, inp, cc); } else audio_fill_silence(&sc->sc_pparams, cb->start, inp, cc); inp += cc; @@ -1446,11 +1456,10 @@ audio_read(dev_t dev, struct uio *uio, int ioflag) } mtx_leave(&audio_lock); - if (uio->uio_resid < cc / sc->sc_rparams.factor) - cc = uio->uio_resid * sc->sc_rparams.factor; + if (uio->uio_resid < cc) + cc = uio->uio_resid; DPRINTFN(1, ("audio_read: reading in write mode, cc=%d\n", cc)); - error = audio_silence_copyout(sc, - cc / sc->sc_rparams.factor, uio); + error = audio_silence_copyout(sc, cc, uio); sc->sc_wstamp += cc; } return (error); @@ -1479,7 +1488,7 @@ audio_read(dev_t dev, struct uio *uio, int ioflag) return error; } } - resid = uio->uio_resid * sc->sc_rparams.factor; + resid = uio->uio_resid; outp = cb->outp; cc = cb->used - cb->usedlow; /* maximum to read */ n = cb->end - outp; @@ -1494,9 +1503,9 @@ audio_read(dev_t dev, struct uio *uio, int ioflag) cb->outp = cb->start; mtx_leave(&audio_lock); DPRINTFN(1,("audio_read: outp=%p, cc=%d\n", outp, cc)); - if (sc->sc_rparams.sw_code) - sc->sc_rparams.sw_code(sc->hw_hdl, outp, cc); - error = uiomovei(outp, cc / sc->sc_rparams.factor, uio); + if (sc->sc_remu.sw_code) + sc->sc_remu.sw_code(sc->hw_hdl, outp, cc); + error = uiomove(outp, cc, uio); if (error) return error; } @@ -1681,19 +1690,18 @@ audio_write(dev_t dev, struct uio *uio, int ioflag) } if (!(sc->sc_mode & AUMODE_PLAY_ALL) && sc->sc_playdrop > 0) { - n = min(sc->sc_playdrop, uio->uio_resid * sc->sc_pparams.factor); + n = min(sc->sc_playdrop, uio->uio_resid); DPRINTF(("audio_write: playdrop %d\n", n)); - uio->uio_offset += n / sc->sc_pparams.factor; - uio->uio_resid -= n / sc->sc_pparams.factor; + uio->uio_offset += n; + uio->uio_resid -= n; sc->sc_playdrop -= n; if (uio->uio_resid == 0) return 0; } - DPRINTFN(1, ("audio_write: sr=%ld, enc=%d, prec=%d, chan=%d, sw=%p, fact=%d\n", - sc->sc_pparams.sample_rate, sc->sc_pparams.encoding, - sc->sc_pparams.precision, sc->sc_pparams.channels, - sc->sc_pparams.sw_code, sc->sc_pparams.factor)); + DPRINTFN(1, ("audio_write: sr=%ld, enc=%d, prec=%d, chan=%d\n", + sc->sc_pparams.sample_rate, sc->sc_pparams.encoding, + sc->sc_pparams.precision, sc->sc_pparams.channels)); while (uio->uio_resid > 0) { mtx_enter(&audio_lock); @@ -1712,7 +1720,7 @@ audio_write(dev_t dev, struct uio *uio, int ioflag) return error; } } - resid = uio->uio_resid * sc->sc_pparams.factor; + resid = uio->uio_resid; avail = cb->end - cb->inp; inp = cb->inp; cc = cb->usedhigh - cb->used; @@ -1736,14 +1744,13 @@ audio_write(dev_t dev, struct uio *uio, int ioflag) return error; } else mtx_leave(&audio_lock); - cc /= sc->sc_pparams.factor; DPRINTFN(1, ("audio_write: uiomove cc=%d inp=%p, left=%zd\n", cc, inp, uio->uio_resid)); error = uiomovei(inp, cc, uio); if (error) return 0; - if (sc->sc_pparams.sw_code) { - sc->sc_pparams.sw_code(sc->hw_hdl, inp, cc); + if (sc->sc_pemu.sw_code) { + sc->sc_pemu.sw_code(sc->hw_hdl, inp, cc); DPRINTFN(1, ("audio_write: expanded cc=%d\n", cc)); } } @@ -1817,19 +1824,16 @@ 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 * sc->sc_rparams.bps) */ case AUDIO_RERROR: *(int *)addr = sc->sc_rr.drops / - (sc->sc_rparams.factor * sc->sc_rparams.channels * - sc->sc_rparams.bps); + (sc->sc_rparams.channels * sc->sc_rparams.bps); break; case AUDIO_PERROR: *(int *)addr = sc->sc_pr.drops / - (sc->sc_pparams.factor * sc->sc_pparams.channels * - sc->sc_pparams.bps); + (sc->sc_pparams.channels * sc->sc_pparams.bps); break; /* @@ -1839,10 +1843,10 @@ audio_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) mtx_enter(&audio_lock); /* figure out where next DMA will start */ ao = (struct audio_offset *)addr; - ao->samples = sc->sc_rr.stamp / sc->sc_rparams.factor; + ao->samples = sc->sc_rr.stamp; ao->deltablks = (sc->sc_rr.stamp - sc->sc_rr.stamp_last) / sc->sc_rr.blksize; sc->sc_rr.stamp_last = sc->sc_rr.stamp; - ao->offset = (sc->sc_rr.inp - sc->sc_rr.start) / sc->sc_rparams.factor; + ao->offset = sc->sc_rr.inp - sc->sc_rr.start; mtx_leave(&audio_lock); break; @@ -1853,10 +1857,10 @@ audio_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) offs = sc->sc_pr.outp - sc->sc_pr.start + sc->sc_pr.blksize; if (sc->sc_pr.start + offs >= sc->sc_pr.end) offs = 0; - ao->samples = sc->sc_pr.stamp / sc->sc_pparams.factor; + ao->samples = sc->sc_pr.stamp; ao->deltablks = (sc->sc_pr.stamp - sc->sc_pr.stamp_last) / sc->sc_pr.blksize; sc->sc_pr.stamp_last = sc->sc_pr.stamp; - ao->offset = offs / sc->sc_pparams.factor; + ao->offset = offs; mtx_leave(&audio_lock); break; @@ -1865,7 +1869,7 @@ audio_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) * sample of what we write next? */ case AUDIO_WSEEK: - *(u_long *)addr = sc->sc_pr.used / sc->sc_pparams.factor; + *(u_long *)addr = sc->sc_pr.used; break; case AUDIO_SETINFO: @@ -2146,10 +2150,9 @@ audio_pint_silence(struct audio_softc *sc, struct audio_ringbuffer *cb, DPRINTFN(5, ("audio_pint_silence: fill cc=%d inp=%p, count=%d size=%d\n", cc, inp, sc->sc_sil_count, (int)(cb->end - cb->start))); - if (sc->sc_pparams.sw_code) { - int ncc = cc / sc->sc_pparams.factor; - audio_fill_silence(&sc->sc_pparams, cb->start, inp, ncc); - sc->sc_pparams.sw_code(sc->hw_hdl, inp, ncc); + if (sc->sc_pemu.sw_code) { + audio_fill_silence(&sc->sc_pparams, cb->start, inp, cc); + sc->sc_pemu.sw_code(sc->hw_hdl, inp, cc); } else audio_fill_silence(&sc->sc_pparams, cb->start, inp, cc); @@ -2163,10 +2166,9 @@ audio_pint_silence(struct audio_softc *sc, struct audio_ringbuffer *cb, DPRINTFN(5, ("audio_pint_silence: start fill %p %d\n", inp, cc)); - if (sc->sc_pparams.sw_code) { - int ncc = cc / sc->sc_pparams.factor; - audio_fill_silence(&sc->sc_pparams, cb->start, inp, ncc); - sc->sc_pparams.sw_code(sc->hw_hdl, inp, ncc); + if (sc->sc_pemu.sw_code) { + audio_fill_silence(&sc->sc_pparams, cb->start, inp, cc); + sc->sc_pemu.sw_code(sc->hw_hdl, inp, cc); } else audio_fill_silence(&sc->sc_pparams, cb->start, inp, cc); @@ -2437,12 +2439,12 @@ audio_check_params(struct audio_params *p) #endif switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - case AUDIO_ENCODING_ALAW: case AUDIO_ENCODING_ADPCM: if (p->precision != 8) p->precision = 8; break; + case AUDIO_ENCODING_ULAW: + case AUDIO_ENCODING_ALAW: case AUDIO_ENCODING_SLINEAR_LE: case AUDIO_ENCODING_SLINEAR_BE: case AUDIO_ENCODING_ULINEAR_LE: @@ -2461,6 +2463,36 @@ audio_check_params(struct audio_params *p) return (0); } +void +audio_emu_setup(int mode, struct audio_params *p, struct audio_emu *e) +{ + if (p->encoding == e->encoding) { + e->sw_code = NULL; + return; + } + switch (p->encoding) { + case AUDIO_ENCODING_ULAW: +#if BYTE_ORDER == LITTE_ENDIAN + e->encoding = AUDIO_ENCODING_SLINEAR_LE; +#else + e->encoding = AUDIO_ENCODING_SLINEAR_BE; +#endif + if (p->precision == 8) { + e->sw_code = (mode == AUMODE_PLAY) ? + slinear8_to_mulaw : mulaw_to_slinear8; + break; + } else if (p->precision == 24) { + e->sw_code = (mode == AUMODE_PLAY) ? + slinear24_to_mulaw24 : mulaw24_to_slinear24; + break; + } + /* FALLTHROUGH */ + default: + e->encoding = p->encoding; + e->sw_code = NULL; + } +} + int au_set_lr_value(struct audio_softc *sc, mixer_ctrl_t *ct, int l, int r) { @@ -2870,16 +2902,12 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai) if (!cleared) audio_clear(sc); modechange = cleared = 1; - rp.sw_code = 0; - rp.factor = 1; setmode |= AUMODE_RECORD; } if (np) { if (!cleared) audio_clear(sc); modechange = cleared = 1; - pp.sw_code = 0; - pp.factor = 1; setmode |= AUMODE_PLAY; } @@ -2903,10 +2931,16 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai) else rp = pp; } + sc->sc_pemu.encoding = pp.encoding; + sc->sc_remu.encoding = rp.encoding; error = hw->set_params(sc->hw_hdl, setmode, sc->sc_mode & (AUMODE_PLAY | AUMODE_RECORD), &pp, &rp); if (error) return (error); + if (sc->sc_mode & AUMODE_PLAY) + audio_emu_setup(AUMODE_PLAY, &pp, &sc->sc_pemu); + if (sc->sc_mode & AUMODE_RECORD) + audio_emu_setup(AUMODE_RECORD, &rp, &sc->sc_remu); if (!indep) { if (setmode == AUMODE_RECORD) { pp.sample_rate = rp.sample_rate; @@ -2960,7 +2994,7 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai) fpb = rp.sample_rate * audio_blk_ms / 1000; } else { fs = rp.channels * rp.bps; - fpb = (r->block_size * rp.factor) / fs; + fpb = r->block_size / fs; } if (sc->sc_rr.blkset == 0) audio_set_blksize(sc, AUMODE_RECORD, fpb); @@ -2970,7 +3004,7 @@ audiosetinfo(struct audio_softc *sc, struct audio_info *ai) fpb = pp.sample_rate * audio_blk_ms / 1000; } else { fs = pp.channels * pp.bps; - fpb = (p->block_size * pp.factor) / fs; + fpb = p->block_size / fs; } if (sc->sc_pr.blkset == 0) audio_set_blksize(sc, AUMODE_PLAY, fpb); @@ -3141,9 +3175,8 @@ audiogetinfo(struct audio_softc *sc, struct audio_info *ai) 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; - + p->encoding = sc->sc_pemu.encoding; + r->encoding = sc->sc_remu.encoding; r->port = au_get_port(sc, &sc->sc_inports); p->port = au_get_port(sc, &sc->sc_outports); @@ -3169,8 +3202,8 @@ audiogetinfo(struct audio_softc *sc, struct audio_info *ai) au_get_mute(sc, &sc->sc_outports, &ai->output_muted); - p->seek = sc->sc_pr.used / sc->sc_pparams.factor; - r->seek = sc->sc_rr.used / sc->sc_rparams.factor; + p->seek = sc->sc_pr.used; + r->seek = sc->sc_rr.used; p->samples = sc->sc_pr.stamp - sc->sc_pr.drops; r->samples = sc->sc_rr.stamp - sc->sc_rr.drops; @@ -3192,11 +3225,11 @@ audiogetinfo(struct audio_softc *sc, struct audio_info *ai) p->active = sc->sc_pbus; r->active = sc->sc_rbus; - p->buffer_size = sc->sc_pr.bufsize / sc->sc_pparams.factor; - r->buffer_size = sc->sc_rr.bufsize / sc->sc_rparams.factor; + p->buffer_size = sc->sc_pr.bufsize; + r->buffer_size = sc->sc_rr.bufsize; - r->block_size = sc->sc_rr.blksize / sc->sc_rparams.factor; - p->block_size = sc->sc_pr.blksize / sc->sc_pparams.factor; + r->block_size = sc->sc_rr.blksize; + p->block_size = sc->sc_pr.blksize; if (p->block_size != 0) { ai->hiwat = sc->sc_pr.usedhigh / sc->sc_pr.blksize; ai->lowat = sc->sc_pr.usedlow / sc->sc_pr.blksize; @@ -3213,19 +3246,15 @@ int audiogetbufinfo(struct audio_softc *sc, struct audio_bufinfo *info, int mode) { struct audio_ringbuffer *buf; - int factor; - factor = 1; if (mode == AUMODE_PLAY) { buf = &sc->sc_pr; - factor = sc->sc_pparams.factor; } else { buf = &sc->sc_rr; - factor = sc->sc_rparams.factor; } - info->seek = buf->used / factor; - info->blksize = buf->blksize / factor; + info->seek = buf->used; + info->blksize = buf->blksize; if (buf->blksize != 0) { info->hiwat = buf->usedhigh / buf->blksize; info->lowat = buf->usedlow / buf->blksize; diff --git a/sys/dev/audio_if.h b/sys/dev/audio_if.h index e86e754511a..7c2500ce9d5 100644 --- a/sys/dev/audio_if.h +++ b/sys/dev/audio_if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: audio_if.h,v 1.28 2013/05/15 08:29:24 ratchov Exp $ */ +/* $OpenBSD: audio_if.h,v 1.29 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: audio_if.h,v 1.24 1998/01/10 14:07:25 tv Exp $ */ /* @@ -59,9 +59,6 @@ struct audio_params { 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); - int factor; /* coding space change */ }; /* The default audio mode: 8 kHz mono mu-law */ diff --git a/sys/dev/ic/ac97.c b/sys/dev/ic/ac97.c index 505720e0fc0..c3429f50f97 100644 --- a/sys/dev/ic/ac97.c +++ b/sys/dev/ic/ac97.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ac97.c,v 1.79 2015/03/14 03:38:47 jsg Exp $ */ +/* $OpenBSD: ac97.c,v 1.80 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 1999, 2000 Constantine Sapuntzakis @@ -77,9 +77,7 @@ const struct audio_params ac97_audio_default = { 16, /* precision */ 2, /* bps */ 1, /* msb */ - 2, /* channels */ - NULL, /* sw_code */ - 1 /* factor */ + 2 /* channels */ }; const struct audio_mixer_enum ac97_on_off = { diff --git a/sys/dev/ic/am7930.c b/sys/dev/ic/am7930.c index dcb3e7074b4..ea0e80548aa 100644 --- a/sys/dev/ic/am7930.c +++ b/sys/dev/ic/am7930.c @@ -1,4 +1,4 @@ -/* $OpenBSD: am7930.c,v 1.5 2013/05/15 21:22:28 ratchov Exp $ */ +/* $OpenBSD: am7930.c,v 1.6 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: am7930.c,v 1.44 2001/11/13 13:14:34 lukem Exp $ */ /* @@ -45,7 +45,6 @@ #include #include -#include #include #include @@ -223,62 +222,13 @@ am7930_set_params(void *addr, int setmode, int usemode, if (p == NULL) continue; - switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - p->sw_code = NULL; - break; - case AUDIO_ENCODING_SLINEAR: - case AUDIO_ENCODING_SLINEAR_BE: - case AUDIO_ENCODING_SLINEAR_LE: - if (mode == AUMODE_PLAY) - p->sw_code = slinear8_to_mulaw; - else - p->sw_code = mulaw_to_slinear8; - break; - case AUDIO_ENCODING_ULINEAR: - case AUDIO_ENCODING_ULINEAR_BE: - case AUDIO_ENCODING_ULINEAR_LE: - if (mode == AUMODE_PLAY) - p->sw_code = ulinear8_to_mulaw; - else - p->sw_code = mulaw_to_ulinear8; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) - p->sw_code = alaw_to_mulaw; - else - p->sw_code = mulaw_to_alaw; - break; - default: - return EINVAL; - } - p->precision = 8; - p->bps = 1; - p->msb = 1; + p->encoding = AUDIO_ENCODING_ULAW; + p->precision = sc->sc_glue->precision; + p->bps = AUDIO_BPS(p->precision); + p->msb = 0; p->channels = 1; /* no other rates supported by amd chip */ p->sample_rate = 8000; - - if (sc->sc_glue->factor > 1) { - p->factor = sc->sc_glue->factor; - /* - * Remember which converter routine had been - * selected, if any, since there is no way - * to stack filters yet. - * - * Note that we rely upon the converters working - * in place (i.e. with factor == 1), which is - * correct as long as we don't try to emulate - * 16-bit encodings. - */ - if (mode == AUMODE_PLAY) { - sc->play_sw_code = p->sw_code; - p->sw_code = sc->sc_glue->output_conv; - } else { - sc->rec_sw_code = p->sw_code; - p->sw_code = sc->sc_glue->input_conv; - } - } } return 0; @@ -287,39 +237,17 @@ am7930_set_params(void *addr, int setmode, int usemode, int am7930_query_encoding(void *addr, struct audio_encoding *fp) { + struct am7930_softc *sc = addr; + switch (fp->index) { case 0: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->bps = 1; - fp->msb = 1; + fp->precision = sc->sc_glue->precision; + fp->bps = AUDIO_BPS(fp->precision); + fp->msb = 0; fp->flags = 0; break; - case 1: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->bps = 1; - fp->msb = 1; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEulinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR; - fp->precision = 8; - fp->bps = 1; - fp->msb = 1; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->bps = 1; - fp->msb = 1; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return EINVAL; /*NOTREACHED*/ diff --git a/sys/dev/ic/am7930var.h b/sys/dev/ic/am7930var.h index e8861c0fac1..a0a1945ce89 100644 --- a/sys/dev/ic/am7930var.h +++ b/sys/dev/ic/am7930var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: am7930var.h,v 1.2 2011/09/04 20:08:37 miod Exp $ */ +/* $OpenBSD: am7930var.h,v 1.3 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: am7930var.h,v 1.10 2005/01/15 15:19:52 kent Exp $ */ /* @@ -50,9 +50,7 @@ struct am7930_glue { void (*codec_iwrite16)(struct am7930_softc *sc, int, uint16_t); void (*onopen)(struct am7930_softc *sc); void (*onclose)(struct am7930_softc *sc); - int factor; - void (*input_conv)(void *, u_char *, int); - void (*output_conv)(void *, u_char *, int); + int precision; }; struct am7930_softc { @@ -67,10 +65,6 @@ struct am7930_softc { uint8_t sc_mic_mute; struct am7930_glue *sc_glue; - - /* saved audio_params sw_code if overwritten with the glue pointers */ - void (*play_sw_code)(void *, u_char *, int); - void (*rec_sw_code)(void *, u_char *, int); }; extern int am7930debug; diff --git a/sys/dev/ic/arcofi.c b/sys/dev/ic/arcofi.c index d99ceb3f122..81d4675b936 100644 --- a/sys/dev/ic/arcofi.c +++ b/sys/dev/ic/arcofi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arcofi.c,v 1.11 2014/12/19 22:44:58 guenther Exp $ */ +/* $OpenBSD: arcofi.c,v 1.12 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2011 Miodrag Vallat. @@ -38,8 +38,6 @@ #include #include -#include -#include #include #include @@ -327,9 +325,7 @@ arcofi_query_encoding(void *v, struct audio_encoding *ae) { switch (ae->index) { /* - * 8-bit encodings: u-Law and A-Law are native, linear are converted - * to u-Law (alternatively, they could be converted to 16-bit, but - * using u-Law allows us to convert in place). + * 8-bit encodings: u-Law and A-Law are native */ case 0: strlcpy(ae->name, AudioEmulaw, sizeof ae->name); @@ -343,47 +339,16 @@ arcofi_query_encoding(void *v, struct audio_encoding *ae) ae->encoding = AUDIO_ENCODING_ALAW; ae->flags = 0; break; - case 2: - strlcpy(ae->name, AudioEslinear, sizeof ae->name); - ae->precision = 8; - ae->encoding = AUDIO_ENCODING_SLINEAR; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(ae->name, AudioEulinear, sizeof ae->name); - ae->precision = 8; - ae->encoding = AUDIO_ENCODING_ULINEAR; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; /* - * 16-bit encodings: slinear big-endian is native, unsigned or - * little-endian are converted. + * 16-bit encodings: slinear big-endian is native */ - case 4: + case 2: strlcpy(ae->name, AudioEslinear_be, sizeof ae->name); ae->precision = 16; ae->encoding = AUDIO_ENCODING_SLINEAR_BE; ae->flags = 0; break; - case 5: - strlcpy(ae->name, AudioEslinear_le, sizeof ae->name); - ae->precision = 16; - ae->encoding = AUDIO_ENCODING_SLINEAR_LE; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(ae->name, AudioEulinear_be, sizeof ae->name); - ae->precision = 16; - ae->encoding = AUDIO_ENCODING_ULINEAR_BE; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(ae->name, AudioEulinear_le, sizeof ae->name); - ae->precision = 16; - ae->encoding = AUDIO_ENCODING_ULINEAR_LE; - ae->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return EINVAL; @@ -415,29 +380,9 @@ arcofi_set_param(struct arcofi_softc *sc, int set, int use, int mode, switch (ap->encoding) { case AUDIO_ENCODING_ULAW: sc->sc_shadow.cr4 |= CR4_ULAW; - ap->sw_code = NULL; break; case AUDIO_ENCODING_ALAW: sc->sc_shadow.cr4 &= ~CR4_ULAW; - ap->sw_code = NULL; - break; - case AUDIO_ENCODING_SLINEAR: - case AUDIO_ENCODING_SLINEAR_BE: - case AUDIO_ENCODING_SLINEAR_LE: - sc->sc_shadow.cr4 |= CR4_ULAW; - if (mode == AUMODE_PLAY) - ap->sw_code = slinear8_to_mulaw; - else - ap->sw_code = mulaw_to_slinear8; - break; - case AUDIO_ENCODING_ULINEAR: - case AUDIO_ENCODING_ULINEAR_BE: - case AUDIO_ENCODING_ULINEAR_LE: - sc->sc_shadow.cr4 |= CR4_ULAW; - if (mode == AUMODE_PLAY) - ap->sw_code = ulinear8_to_mulaw; - else - ap->sw_code = mulaw_to_ulinear8; break; default: return EINVAL; @@ -447,29 +392,7 @@ arcofi_set_param(struct arcofi_softc *sc, int set, int use, int mode, break; case 16: switch (ap->encoding) { -#if BYTE_ORDER == BIG_ENDIAN - case AUDIO_ENCODING_SLINEAR: -#endif case AUDIO_ENCODING_SLINEAR_BE: - ap->sw_code = NULL; - break; -#if BYTE_ORDER == LITTLE_ENDIAN - case AUDIO_ENCODING_SLINEAR: -#endif - case AUDIO_ENCODING_SLINEAR_LE: - ap->sw_code = swap_bytes; - break; -#if BYTE_ORDER == BIG_ENDIAN - case AUDIO_ENCODING_ULINEAR: -#endif - case AUDIO_ENCODING_ULINEAR_BE: - ap->sw_code = change_sign16_be; - break; -#if BYTE_ORDER == LITTLE_ENDIAN - case AUDIO_ENCODING_ULINEAR: -#endif - case AUDIO_ENCODING_ULINEAR_LE: - ap->sw_code = swap_bytes_change_sign16_be; break; default: return EINVAL; diff --git a/sys/dev/isa/ad1848.c b/sys/dev/isa/ad1848.c index 50694c5c9ba..4dcde647b05 100644 --- a/sys/dev/isa/ad1848.c +++ b/sys/dev/isa/ad1848.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ad1848.c,v 1.41 2015/05/08 07:25:36 jsg Exp $ */ +/* $OpenBSD: ad1848.c,v 1.42 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: ad1848.c,v 1.45 1998/01/30 02:02:38 augustss Exp $ */ /* @@ -81,7 +81,6 @@ #include #include -#include #include #include @@ -907,8 +906,6 @@ ad1848_mixer_set_port(struct ad1848_softc *ac, struct ad1848_devmap *map, int ad1848_query_encoding(void *addr, struct audio_encoding *fp) { - struct ad1848_softc *sc = addr; - switch (fp->index) { case 0: strlcpy(fp->name, AudioEmulaw, sizeof fp->name); @@ -934,40 +931,6 @@ ad1848_query_encoding(void *addr, struct audio_encoding *fp) fp->precision = 8; fp->flags = 0; break; - case 4: /* only on CS4231 */ - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = sc->mode == 1 ? AUDIO_ENCODINGFLAG_EMULATED : 0; - break; - - /* emulate some modes */ - case 5: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - 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; - break; - case 8: /* only on CS4231 */ - if (sc->mode == 1) - return EINVAL; - strlcpy(fp->name, AudioEadpcm, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ADPCM; - fp->precision = 8; - fp->flags = 0; - break; default: return EINVAL; /*NOTREACHED*/ @@ -984,46 +947,36 @@ ad1848_set_params(void *addr, int setmode, int usemode, struct audio_params *p, { struct ad1848_softc *sc = addr; int error, bits, enc; - void (*pswcode)(void *, u_char *buf, int cnt); - void (*rswcode)(void *, u_char *buf, int cnt); DPRINTF(("ad1848_set_params: %d %d %d %ld\n", p->encoding, p->precision, p->channels, p->sample_rate)); enc = p->encoding; - pswcode = rswcode = 0; switch (enc) { case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision == 8) { - enc = AUDIO_ENCODING_ULINEAR_LE; - pswcode = rswcode = change_sign8; - } + if (p->precision == 8) + return EINVAL; break; case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16 && sc->mode == 1) { - enc = AUDIO_ENCODING_SLINEAR_LE; - pswcode = rswcode = swap_bytes; - } + if (p->precision == 16) + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) { - enc = AUDIO_ENCODING_SLINEAR_LE; - pswcode = rswcode = change_sign16_le; - } + if (p->precision == 16) + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - enc = AUDIO_ENCODING_SLINEAR_LE; - pswcode = swap_bytes_change_sign16_le; - rswcode = change_sign16_swap_bytes_le; - } + if (p->precision == 16) + return EINVAL; break; } switch (enc) { - case AUDIO_ENCODING_ULAW: + case AUDIO_ENCODING_ULAW: + p->precision = 8; bits = FMT_ULAW; break; case AUDIO_ENCODING_ALAW: + p->precision = 8; bits = FMT_ALAW; break; case AUDIO_ENCODING_ADPCM: @@ -1058,8 +1011,6 @@ ad1848_set_params(void *addr, int setmode, int usemode, struct audio_params *p, if (error) return error; - p->sw_code = pswcode; - r->sw_code = rswcode; p->bps = AUDIO_BPS(p->precision); r->bps = AUDIO_BPS(r->precision); p->msb = 1; diff --git a/sys/dev/isa/ess.c b/sys/dev/isa/ess.c index 0aec993d924..22b322e907c 100644 --- a/sys/dev/isa/ess.c +++ b/sys/dev/isa/ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ess.c,v 1.20 2014/09/14 14:17:25 jsg Exp $ */ +/* $OpenBSD: ess.c,v 1.21 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: ess.c,v 1.44.4.1 1999/06/21 01:18:00 thorpej Exp $ */ /* @@ -81,8 +81,6 @@ #include #include -#include -#include #include #include @@ -1121,47 +1119,23 @@ ess_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; - case 4: + case 2: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: + case 3: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - break; default: return EINVAL; } @@ -1217,31 +1191,15 @@ ess_set_params(void *addr, int setmode, int usemode, if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_BE: case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; + if (p->precision != 8) + return EINVAL; break; case AUDIO_ENCODING_SLINEAR_LE: case AUDIO_ENCODING_ULINEAR_LE: break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_ulinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_ulinear16_le; - } else - p->sw_code = ulinear8_to_alaw; - break; default: return (EINVAL); } @@ -1301,7 +1259,7 @@ ess_audio1_trigger_output(void *addr, void *start, void *end, int blksize, ess_write_x_reg(sc, ESS_XCMD_AUDIO_CTRL, reg); reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO1_CTRL1); - if (param->precision * param->factor == 16) + if (param->precision == 16) reg |= ESS_AUDIO1_CTRL1_FIFO_SIZE; else reg &= ~ESS_AUDIO1_CTRL1_FIFO_SIZE; @@ -1365,7 +1323,7 @@ ess_audio2_trigger_output(void *addr, void *start, void *end, int blksize, } reg = ess_read_mix_reg(sc, ESS_MREG_AUDIO2_CTRL2); - if (param->precision * param->factor == 16) + if (param->precision == 16) reg |= ESS_AUDIO2_CTRL2_FIFO_SIZE; else reg &= ~ESS_AUDIO2_CTRL2_FIFO_SIZE; @@ -1440,7 +1398,7 @@ ess_audio1_trigger_input(void *addr, void *start, void *end, int blksize, ess_write_x_reg(sc, ESS_XCMD_AUDIO_CTRL, reg); reg = ess_read_x_reg(sc, ESS_XCMD_AUDIO1_CTRL1); - if (param->precision * param->factor == 16) + if (param->precision == 16) reg |= ESS_AUDIO1_CTRL1_FIFO_SIZE; else reg &= ~ESS_AUDIO1_CTRL1_FIFO_SIZE; diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index f28f80ce6e0..565e2bfb1be 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $OpenBSD: files.isa,v 1.117 2014/12/04 21:03:51 tedu Exp $ +# $OpenBSD: files.isa,v 1.118 2015/05/11 06:46:21 ratchov Exp $ # $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $ # # Config file and device description for machine-independent ISA code. @@ -222,7 +222,7 @@ define sbdsp {} file dev/isa/sbdsp.c sbdsp # SoundBlaster family -device sb: audio, isa_dma, sbdsp, mulaw, auconv, mpu, midibus +device sb: audio, isa_dma, sbdsp, mpu, midibus file dev/isa/sb.c sb attach sb at isa with sb_isa @@ -231,12 +231,12 @@ file dev/isa/sb_isa.c sb & (sb_isa | sb_isapnp) # Soundcards based on Sierra's Aria chipset. # Such as the Prometheus Aria 16 or the Diamond # sonic sound. -device aria: audio, mulaw +device aria: audio attach aria at isa file dev/isa/aria.c aria # ProAudio Spectrum -device pas: audio, isa_dma, sbdsp, mulaw, auconv +device pas: audio, isa_dma, sbdsp attach pas at isa file dev/isa/pas.c pas @@ -250,21 +250,21 @@ file dev/isa/ics2101.c ics2101 # Microsoft Windows Sound System -device wss: audio, isa_dma, ad1848, auconv +device wss: audio, isa_dma, ad1848 file dev/isa/wss.c wss attach wss at isa with wss_isa file dev/isa/wss_isa.c wss & (wss_isa | wss_isapnp) # ESS Technology ES1887/ES888/ES1888 -device ess {} : audio, isa_dma, mulaw, auconv, midibus +device ess {} : audio, isa_dma, midibus file dev/isa/ess.c ess # Gravis UltraSound & UltraSound MAX. # Use the "flags" keyword in a config file to specify an extra DMA # channel for full-duplex operation. -device gus: audio, isa_dma, ics2101, ad1848, mulaw, auconv +device gus: audio, isa_dma, ics2101, ad1848 file dev/isa/gus.c gus attach gus at isa with gus_isa diff --git a/sys/dev/isa/files.isapnp b/sys/dev/isa/files.isapnp index ddd27a512d0..76f1f6c77b5 100644 --- a/sys/dev/isa/files.isapnp +++ b/sys/dev/isa/files.isapnp @@ -1,4 +1,4 @@ -# $OpenBSD: files.isapnp,v 1.32 2014/10/12 18:51:23 miod Exp $ +# $OpenBSD: files.isapnp,v 1.33 2015/05/11 06:46:21 ratchov Exp $ # $NetBSD: files.isapnp,v 1.7 1997/10/16 17:16:36 matt Exp $ # # Config file and device description for machine-independent ISAPnP code. @@ -64,7 +64,7 @@ attach rt at isapnp with rt_isapnp file dev/isa/rt_isapnp.c rt_isapnp # Yamaha OPL3-SA3 -device ym: audio, isa_dma, ad1848, auconv, midibus +device ym: audio, isa_dma, ad1848, midibus attach ym at isapnp with ym_isapnp file dev/isa/ym.c ym_isapnp file dev/isa/ym_isapnp.c ym_isapnp diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index ea3abdfc068..cc16c8ca3b1 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gus.c,v 1.41 2014/09/14 14:17:25 jsg Exp $ */ +/* $OpenBSD: gus.c,v 1.42 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -106,8 +106,6 @@ #include #include #include -#include -#include #include #include @@ -1485,12 +1483,8 @@ gus_set_params(void *addr, int setmode, int usemode, struct audio_params *p, struct gus_softc *sc = addr; switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - case AUDIO_ENCODING_ALAW: case AUDIO_ENCODING_SLINEAR_LE: case AUDIO_ENCODING_ULINEAR_LE: - case AUDIO_ENCODING_SLINEAR_BE: - case AUDIO_ENCODING_ULINEAR_BE: break; default: return (EINVAL); @@ -1520,20 +1514,6 @@ gus_set_params(void *addr, int setmode, int usemode, struct audio_params *p, if (setmode & AUMODE_PLAY) sc->sc_orate = p->sample_rate; - switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - p->sw_code = mulaw_to_ulinear8; - r->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - p->sw_code = alaw_to_ulinear8; - r->sw_code = ulinear8_to_alaw; - break; - case AUDIO_ENCODING_ULINEAR_BE: - case AUDIO_ENCODING_SLINEAR_BE: - 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; @@ -3147,54 +3127,29 @@ gus_query_encoding(void *addr, struct audio_encoding *fp) { switch (fp->index) { case 0: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; - case 2: + case 1: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 3: + case 2: strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; - case 4: + case 3: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - 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; - break; - case 7: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - default: return(EINVAL); /*NOTREACHED*/ diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index 594fd067418..9d4ef0a393e 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdsp.c,v 1.34 2014/09/14 14:17:25 jsg Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.35 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -61,8 +61,6 @@ #include #include #include -#include -#include #include #include @@ -531,8 +529,6 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) struct sbdsp_softc *sc = addr; struct sbmode *m; u_int rate, tc, bmode; - void (*swcode)(void *, u_char *buf, int cnt); - int factor; int model; int chan; struct audio_params *p; @@ -633,44 +629,24 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) if (m->model == -1) return EINVAL; rate = p->sample_rate; - swcode = 0; - factor = 1; tc = 1; bmode = -1; if (model == SB_16) { switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_BE: if (p->precision == 16) - swcode = swap_bytes; + return EINVAL; /* fall into */ case AUDIO_ENCODING_SLINEAR_LE: bmode = SB_BMODE_SIGNED; break; case AUDIO_ENCODING_ULINEAR_BE: if (p->precision == 16) - swcode = swap_bytes; + return EINVAL; /* fall into */ case AUDIO_ENCODING_ULINEAR_LE: bmode = SB_BMODE_UNSIGNED; break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - swcode = mulaw_to_ulinear16_le; - factor = 2; - m = &sbpmodes[PLAY16]; - } else - swcode = ulinear8_to_mulaw; - bmode = SB_BMODE_UNSIGNED; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - swcode = alaw_to_ulinear16_le; - factor = 2; - m = &sbpmodes[PLAY16]; - } else - swcode = ulinear8_to_alaw; - bmode = SB_BMODE_UNSIGNED; - break; default: return EINVAL; } @@ -680,24 +656,6 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_LE: break; - case AUDIO_ENCODING_ULINEAR_LE: - swcode = change_sign16_le; - break; - case AUDIO_ENCODING_SLINEAR_BE: - swcode = swap_bytes; - break; - case AUDIO_ENCODING_ULINEAR_BE: - swcode = mode == AUMODE_PLAY ? - swap_bytes_change_sign16_le : change_sign16_swap_bytes_le; - break; - case AUDIO_ENCODING_ULAW: - swcode = mode == AUMODE_PLAY ? - mulaw_to_ulinear8 : ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - swcode = mode == AUMODE_PLAY ? - alaw_to_ulinear8 : ulinear8_to_alaw; - break; default: return EINVAL; } @@ -705,21 +663,9 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) p->sample_rate = SB_TC_TO_RATE(tc) / p->channels; } else { switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - case AUDIO_ENCODING_SLINEAR_LE: - swcode = change_sign8; - break; case AUDIO_ENCODING_ULINEAR_BE: case AUDIO_ENCODING_ULINEAR_LE: break; - case AUDIO_ENCODING_ULAW: - swcode = mode == AUMODE_PLAY ? - mulaw_to_ulinear8 : ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - swcode = mode == AUMODE_PLAY ? - alaw_to_ulinear8 : ulinear8_to_alaw; - break; default: return EINVAL; } @@ -742,13 +688,11 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) sc->sc_i.dmachan = chan; } - 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", + DPRINTF(("sbdsp_set_params: model=%d, mode=%d, rate=%ld, prec=%d, chan=%d, enc=%d -> tc=%02x, cmd=%02x, bmode=%02x, cmdchan=%02x\n", sc->sc_model, mode, p->sample_rate, p->precision, p->channels, - p->encoding, tc, m->cmd, bmode, m->cmdchan, swcode, factor)); + p->encoding, tc, m->cmd, bmode, m->cmdchan)); } @@ -763,15 +707,7 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) usemode == (AUMODE_PLAY | AUMODE_RECORD) && sc->sc_i.dmachan == sc->sc_o.dmachan) { DPRINTF(("sbdsp_set_params: fd=%d, usemode=%d, idma=%d, odma=%d\n", sc->sc_fullduplex, usemode, sc->sc_i.dmachan, sc->sc_o.dmachan)); - if (sc->sc_o.dmachan == sc->sc_drq8) { - /* Use 16 bit DMA for playing by expanding the samples. */ - play->sw_code = linear8_to_linear16_le; - play->factor = 2; - sc->sc_o.modep = &sbpmodes[PLAY16]; - sc->sc_o.dmachan = sc->sc_drq16; - } else { - return EINVAL; - } + return EINVAL; } DPRINTF(("sbdsp_set_params ichan=%d, ochan=%d\n", sc->sc_i.dmachan, sc->sc_o.dmachan)); @@ -1233,7 +1169,7 @@ sbdsp_trigger_input(addr, start, end, blksize, intr, arg, param) { struct sbdsp_softc *sc = addr; int stereo = param->channels == 2; - int width = param->precision * param->factor; + int width = param->precision; int filter; int rc; @@ -1370,7 +1306,7 @@ sbdsp_trigger_output(addr, start, end, blksize, intr, arg, param) { struct sbdsp_softc *sc = addr; int stereo = param->channels == 2; - int width = param->precision * param->factor; + int width = param->precision; int cmd; int rc; diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c index c2a340c1f68..36477f319e0 100644 --- a/sys/dev/mulaw.c +++ b/sys/dev/mulaw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mulaw.c,v 1.15 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: mulaw.c,v 1.16 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: mulaw.c,v 1.15 2001/01/18 20:28:20 jdolecek Exp $ */ /* @@ -212,51 +212,6 @@ static const u_char alawtolin16[256][2] = { {0x83,0x30}, {0x83,0x10}, {0x83,0x70}, {0x83,0x50}, }; -static const u_char lintoalaw[256] = { - 0x2a, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, 0x2b, 0x2b, - 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x29, - 0x2e, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x2f, 0x2f, - 0x2c, 0x2c, 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2d, - 0x22, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, 0x23, - 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, - 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, 0x27, - 0x24, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, 0x25, - 0x3a, 0x3a, 0x3b, 0x3b, 0x38, 0x38, 0x39, 0x39, - 0x3e, 0x3e, 0x3f, 0x3f, 0x3c, 0x3c, 0x3d, 0x3d, - 0x32, 0x32, 0x33, 0x33, 0x30, 0x30, 0x31, 0x31, - 0x36, 0x36, 0x37, 0x37, 0x34, 0x34, 0x35, 0x35, - 0x0a, 0x0b, 0x08, 0x09, 0x0e, 0x0f, 0x0c, 0x0d, - 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, - 0x1a, 0x18, 0x1e, 0x1c, 0x12, 0x10, 0x16, 0x14, - 0x6a, 0x6e, 0x62, 0x66, 0x7a, 0x72, 0x4a, 0x5a, - 0xd5, 0xc5, 0xf5, 0xfd, 0xe5, 0xe1, 0xed, 0xe9, - 0x95, 0x97, 0x91, 0x93, 0x9d, 0x9f, 0x99, 0x9b, - 0x85, 0x84, 0x87, 0x86, 0x81, 0x80, 0x83, 0x82, - 0x8d, 0x8c, 0x8f, 0x8e, 0x89, 0x88, 0x8b, 0x8a, - 0xb5, 0xb5, 0xb4, 0xb4, 0xb7, 0xb7, 0xb6, 0xb6, - 0xb1, 0xb1, 0xb0, 0xb0, 0xb3, 0xb3, 0xb2, 0xb2, - 0xbd, 0xbd, 0xbc, 0xbc, 0xbf, 0xbf, 0xbe, 0xbe, - 0xb9, 0xb9, 0xb8, 0xb8, 0xbb, 0xbb, 0xba, 0xba, - 0xa5, 0xa5, 0xa5, 0xa5, 0xa4, 0xa4, 0xa4, 0xa4, - 0xa7, 0xa7, 0xa7, 0xa7, 0xa6, 0xa6, 0xa6, 0xa6, - 0xa1, 0xa1, 0xa1, 0xa1, 0xa0, 0xa0, 0xa0, 0xa0, - 0xa3, 0xa3, 0xa3, 0xa3, 0xa2, 0xa2, 0xa2, 0xa2, - 0xad, 0xad, 0xad, 0xad, 0xac, 0xac, 0xac, 0xac, - 0xaf, 0xaf, 0xaf, 0xaf, 0xae, 0xae, 0xae, 0xae, - 0xa9, 0xa9, 0xa9, 0xa9, 0xa8, 0xa8, 0xa8, 0xa8, - 0xab, 0xab, 0xab, 0xab, 0xaa, 0xaa, 0xaa, 0xaa, -}; - -void -mulaw_to_ulinear8(void *v, u_char *p, int cc) -{ - /* Use the 16 bit table for 8 bits too. */ - while (--cc >= 0) { - *p = mulawtolin16[*p][0]; - ++p; - } -} - void mulaw_to_slinear8(void *v, u_char *p, int cc) { @@ -267,116 +222,6 @@ mulaw_to_slinear8(void *v, u_char *p, int cc) } } -void -mulaw_to_ulinear16_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc << 1; - while (--cc >= 0) { - --p; - q -= 2; - q[1] = mulawtolin16[*p][0]; - q[0] = mulawtolin16[*p][1]; - } -} - -void -mulaw_to_ulinear16_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc << 1; - while (--cc >= 0) { - --p; - q -= 2; - q[0] = mulawtolin16[*p][0]; - q[1] = mulawtolin16[*p][1]; - } -} - -void -mulaw_to_slinear16_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc << 1; - while (--cc >= 0) { - --p; - q -= 2; - q[1] = mulawtolin16[*p][0] ^ 0x80; - q[0] = mulawtolin16[*p][1]; - } -} - -void -mulaw_to_slinear16_le_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - --p; - q -= 4; - q[1] = q[3] = mulawtolin16[*p][0] ^ 0x80; - q[0] = q[2] = mulawtolin16[*p][1]; - } -} - -void -mulaw_to_slinear16_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc << 1; - while (--cc >= 0) { - --p; - q -= 2; - q[0] = mulawtolin16[*p][0] ^ 0x80; - q[1] = mulawtolin16[*p][1]; - } -} - -void -mulaw_to_slinear16_be_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - --p; - q -= 4; - q[0] = q[2] = mulawtolin16[*p][0] ^ 0x80; - q[1] = q[3] = mulawtolin16[*p][1]; - } -} - -void -slinear16_to_mulaw_le(void *v, u_char* p, int cc) -{ - u_char *q = p + 1; /* q points higher byte. */ - - while ((cc-= 2) >= 0) { - *p++ = lintomulaw[*q ^ 0x80]; - q +=2 ; - } -} - -void -ulinear8_to_mulaw(void *v, u_char *p, int cc) -{ - while (--cc >= 0) { - *p = lintomulaw[*p]; - ++p; - } -} - void slinear8_to_mulaw(void *v, u_char *p, int cc) { @@ -387,263 +232,25 @@ slinear8_to_mulaw(void *v, u_char *p, int cc) } void -alaw_to_ulinear8(void *v, u_char *p, int cc) -{ - /* Use the 16 bit table for 8 bits too. */ - while (--cc >= 0) { - *p = alawtolin16[*p][0]; - ++p; - } -} - -void -alaw_to_slinear8(void *v, u_char *p, int cc) -{ - /* Use the 16 bit table for 8 bits too. */ - while (--cc >= 0) { - *p = alawtolin16[*p][0] ^ 0x80; - ++p; - } -} - -void -alaw_to_ulinear16_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc << 1; - while (--cc >= 0) { - --p; - q -= 2; - q[1] = alawtolin16[*p][0]; - q[0] = alawtolin16[*p][1]; - } -} - -void -alaw_to_ulinear16_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc << 1; - while (--cc >= 0) { - --p; - q -= 2; - q[0] = alawtolin16[*p][0]; - q[1] = alawtolin16[*p][1]; - } -} - -void -alaw_to_slinear16_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc << 1; - while (--cc >= 0) { - --p; - q -= 2; - q[1] = alawtolin16[*p][0] ^ 0x80; - q[0] = alawtolin16[*p][1]; - } -} - -void -alaw_to_slinear16_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc << 1; - while (--cc >= 0) { - --p; - q -= 2; - q[0] = alawtolin16[*p][0] ^ 0x80; - q[1] = alawtolin16[*p][1]; - } -} - -void -ulinear8_to_alaw(void *v, u_char *p, int cc) -{ - while (--cc >= 0) { - *p = lintoalaw[*p]; - ++p; - } -} - -void -slinear8_to_alaw(void *v, u_char *p, int cc) -{ - while (--cc >= 0) { - *p = lintoalaw[*p ^ 0x80]; - ++p; - } -} - -void -slinear16_to_alaw_le(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 2) >= 0) { - *p = lintoalaw[q[1] ^ 0x80]; - ++p; - q += 2; - } -} - - -void -slinear16_to_alaw_be(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 2) >= 0) { - *p = lintoalaw[q[0] ^ 0x80]; - ++p; - q += 2; - } -} - -/* - * same as mulaw_to_ulinear16_le(), plus expand mono to stereo - */ -void -mulaw_to_ulinear16_le_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - --p; - q -= 4; - q[1] = q[3] = mulawtolin16[*p][0]; - q[0] = q[2] = mulawtolin16[*p][1]; - } -} - -/* - * same as mulaw_to_ulinear16_be(), plus expand mono to stereo - */ -void -mulaw_to_ulinear16_be_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - --p; - q -= 4; - q[0] = q[2] = mulawtolin16[*p][0]; - q[1] = q[3] = mulawtolin16[*p][1]; - } -} - -/* - * same as alaw_to_slinear16_le(), plus expand mono to stereo - */ -void -alaw_to_slinear16_le_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - --p; - q -= 4; - q[1] = q[3] = alawtolin16[*p][0] ^ 0x80; - q[0] = q[2] = alawtolin16[*p][1]; - } -} - -/* - * same as alaw_to_slinear16_be(), plus expand mono to stereo - */ -void -alaw_to_slinear16_be_mts(void *v, u_char *p, int cc) -{ - u_char *q = p; - - p += cc; - q += cc * 4; - while (--cc >= 0) { - --p; - q -= 4; - q[0] = q[2] = alawtolin16[*p][0] ^ 0x80; - q[1] = q[3] = alawtolin16[*p][1]; - } -} - -void -alaw_to_mulaw(void *v, u_char *p, int cc) -{ - while (--cc >= 0) { - *p = lintomulaw[alawtolin16[*p][0]]; - ++p; - } -} - -void -mulaw_to_alaw(void *v, u_char *p, int cc) -{ - while (--cc >= 0) { - *p = lintoalaw[mulawtolin16[*p][0]]; - ++p; - } -} - - - -void -slinear16_to_alaw_le_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *p = lintoalaw[q[1] ^ 0x80]; - ++p; - q += 4; - } -} - - -void -slinear16_to_alaw_be_stm(void *v, u_char *p, int cc) -{ - u_char *q = p; - - while ((cc -= 4) >= 0) { - *p = lintoalaw[q[0] ^ 0x80]; - ++p; - q += 4; - } -} - -void -slinear16_to_mulaw_le_stm(void *v, u_char* p, int cc) +mulaw24_to_slinear24(void *v, u_char *p, int cc) { - u_char *q = p; + int s, *q = (int *)p; while ((cc -= 4) >= 0) { - *p++ = lintomulaw[q[1] ^ 0x80]; - q += 4 ; + s = (*q >> 16) & 0xff; + *q = (int)((signed char)mulawtolin16[s][0] ^ 0x80) << 16 | + (u_int)mulawtolin16[s][1] << 8; + q++; } } void -slinear16_to_mulaw_be_stm(void *v, u_char* p, int cc) +slinear24_to_mulaw24(void *v, u_char *p, int cc) { - u_char *q = p; + u_int *q = (u_int *)p; while ((cc -= 4) >= 0) { - *p++ = lintomulaw[q[0] ^ 0x80]; - q += 4 ; + *q = lintomulaw[((*q >> 16) & 0xff) ^ 0x80] << 16; + q++; } } diff --git a/sys/dev/mulaw.h b/sys/dev/mulaw.h index 3355b52d9ec..3626e6a451f 100644 --- a/sys/dev/mulaw.h +++ b/sys/dev/mulaw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mulaw.h,v 1.14 2008/06/26 05:42:14 ray Exp $ */ +/* $OpenBSD: mulaw.h,v 1.15 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: mulaw.h,v 1.11 1999/11/01 18:12:19 augustss Exp $ */ /*- @@ -32,62 +32,9 @@ /* *_mts versions convert mono to stereo, in addition */ -/* Convert 8-bit mu-law to 16 bit unsigned linear. */ -extern void mulaw_to_ulinear16_le(void *, u_char *, int); -extern void mulaw_to_ulinear16_le_mts(void *, u_char *, int); -extern void mulaw_to_ulinear16_be(void *, u_char *, int); -extern void mulaw_to_ulinear16_be_mts(void *, u_char *, int); -/* Convert 8-bit mu-law to/from 16 bit signed linear. */ -extern void mulaw_to_slinear16_le(void *, u_char *, int); -extern void mulaw_to_slinear16_le_mts(void *, u_char *, int); -extern void mulaw_to_slinear16_be(void *, u_char *, int); -extern void mulaw_to_slinear16_be_mts(void *, u_char *, int); -extern void slinear16_to_mulaw_le(void *, u_char *, int); -/* Convert 8-bit mu-law to/from 8 bit unsigned linear. */ -extern void mulaw_to_ulinear8(void *, u_char *, int); -extern void ulinear8_to_mulaw(void *, u_char *, int); /* Convert 8-bit mu-law to/from 8 bit signed linear. */ extern void mulaw_to_slinear8(void *, u_char *, int); extern void slinear8_to_mulaw(void *, u_char *, int); -/* Convert 8-bit a-law to 16 bit unsigned linear. */ -extern void alaw_to_ulinear16_le(void *, u_char *, int); -extern void alaw_to_ulinear16_be(void *, u_char *, int); -/* Convert 8-bit a-law to/from 16 bit signed linear. */ -extern void alaw_to_slinear16_le(void *, u_char *, int); -extern void alaw_to_slinear16_le_mts(void *, u_char *, int); -extern void alaw_to_slinear16_be(void *, u_char *, int); -extern void alaw_to_slinear16_be_mts(void *, u_char *, int); -extern void slinear16_to_alaw_le(void *, u_char *, int); -extern void slinear16_to_alaw_be(void *, u_char *, int); -/* Convert 8-bit a-law to/from 8 bit unsigned linear. */ -extern void alaw_to_ulinear8(void *, u_char *, int); -extern void ulinear8_to_alaw(void *, u_char *, int); -/* Convert 8-bit a-law to/from 8 bit signed linear. */ -extern void alaw_to_slinear8(void *, u_char *, int); -extern void slinear8_to_alaw(void *, u_char *, int); -/* Convert 8-bit a-law to/from mulaw */ -void alaw_to_mulaw(void *, u_char *, int); -void mulaw_to_alaw(void *, u_char *, int); -/* Convert 16-bit signed linear stereo to 8-bit a-law mono */ -void slinear16_to_alaw_le_stm(void *, u_char *, int); -void slinear16_to_alaw_be_stm(void *, u_char *, int); -/* Convert 16-bit signed linear stereo to 8-bit mu-law mono */ -void slinear16_to_mulaw_le_stm(void *, u_char *, int); -void slinear16_to_mulaw_be_stm(void *, u_char *, int); - -/* backwards compat for now */ -#if BYTE_ORDER == LITTLE_ENDIAN -#define mulaw_to_ulinear16 mulaw_to_ulinear16_le -#define alaw_to_ulinear16 alaw_to_ulinear16_le -#define mulaw_to_slinear16 mulaw_to_slinear16_le -#define mulaw_to_slinear16_mts mulaw_to_slinear16_le_mts -#define alaw_to_slinear16 alaw_to_slinear16_le -#define alaw_to_slinear16_mts alaw_to_slinear16_le_mts -#else -#define mulaw_to_ulinear16 mulaw_to_ulinear16_be -#define alaw_to_ulinear16 alaw_to_ulinear16_be -#define mulaw_to_slinear16 mulaw_to_slinear16_be -#define mulaw_to_slinear16_mts mulaw_to_slinear16_be_mts -#define alaw_to_slinear16 alaw_to_slinear16_be -#define alaw_to_slinear16_mts alaw_to_slinear16_be_mts -#endif +/* Convert 24-bit mu-law to/from 24 bit signed linear. */ +void mulaw24_to_slinear24(void *, u_char *, int); +void slinear24_to_mulaw24(void *, u_char *, int); diff --git a/sys/dev/pci/auacer.c b/sys/dev/pci/auacer.c index 7a9fd7e905e..57fd2ebf120 100644 --- a/sys/dev/pci/auacer.c +++ b/sys/dev/pci/auacer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auacer.c,v 1.17 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: auacer.c,v 1.18 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: auacer.c,v 1.3 2004/11/10 04:20:26 kent Exp $ */ /*- @@ -51,8 +51,6 @@ #include #include -#include -#include #include @@ -449,53 +447,11 @@ auacer_query_encoding(void *v, struct audio_encoding *aep) switch (aep->index) { case 0: - strlcpy(aep->name, AudioEulinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -567,81 +523,12 @@ auacer_set_params(void *v, int setmode, int usemode, struct audio_params *play, continue; p->sample_rate = auacer_fixup_rate(p->sample_rate); - p->factor = 1; - if (p->precision == 8) - p->factor *= 2; - p->sw_code = NULL; - + p->precision = 16; + p->encoding = AUDIO_ENCODING_SLINEAR_LE; if (mode == AUMODE_RECORD) { if (p->channels > 2) p->channels = 2; } - - switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) { - p->sw_code = swap_bytes; - } else { - if (mode == AUMODE_PLAY) - p->sw_code = linear8_to_linear16_le; - else - p->sw_code = linear16_to_linear8_le; - } - break; - - case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision != 16) { - if (mode == AUMODE_PLAY) - p->sw_code = linear8_to_linear16_le; - else - p->sw_code = linear16_to_linear8_le; - } - break; - - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = - swap_bytes_change_sign16_le; - else - p->sw_code = - change_sign16_swap_bytes_le; - } else { - if (mode == AUMODE_PLAY) - p->sw_code = ulinear8_to_linear16_le; - else - p->sw_code = linear16_to_ulinear8_le; - } - break; - - case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) { - p->sw_code = change_sign16_le; - } else { - if (mode == AUMODE_PLAY) - p->sw_code = ulinear8_to_linear16_le; - else - p->sw_code = linear16_to_ulinear8_le; - } - break; - - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) - p->sw_code = mulaw_to_slinear16_le; - else - p->sw_code = slinear16_to_mulaw_le; - break; - - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) - p->sw_code = alaw_to_slinear16_le; - else - p->sw_code = slinear16_to_alaw_le; - break; - - default: - return (EINVAL); - } p->bps = AUDIO_BPS(p->precision); p->msb = 1; diff --git a/sys/dev/pci/auglx.c b/sys/dev/pci/auglx.c index 3b679f1e3e9..1e9b71cf337 100644 --- a/sys/dev/pci/auglx.c +++ b/sys/dev/pci/auglx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auglx.c,v 1.12 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: auglx.c,v 1.13 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2008 Marc Balmer @@ -51,8 +51,6 @@ #include #include #include -#include -#include #include @@ -484,53 +482,11 @@ auglx_query_encoding(void *v, struct audio_encoding *aep) { switch (aep->index) { case 0: - strlcpy(aep->name, AudioEulinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 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; - 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; - 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; - break; default: return EINVAL; } @@ -550,175 +506,9 @@ auglx_set_params(void *v, int setmode, int usemode, struct audio_params *play, u_int orate; if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = NULL; - if (play->precision > 16) - play->precision = 16; - if (play->channels > 2) - play->channels = 2; - switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = mulaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_SLINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return EINVAL; - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = noswap_bytes_mts; - break; - case 2: - break; - default: - return EINVAL; - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return EINVAL; - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = change_sign16_le_mts; - break; - case 2: - play->sw_code = change_sign16_le; - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_ALAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = alaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return EINVAL; - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_mts; - break; - case 2: - play->sw_code = swap_bytes; - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return EINVAL; - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_change_sign16_le_mts; - break; - case 2: - play->sw_code = swap_bytes_change_sign16_le; - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } + play->precision = 16; + play->channels = 2; + play->encoding = AUDIO_ENCODING_SLINEAR_LE; play->bps = AUDIO_BPS(play->precision); play->msb = 1; @@ -744,155 +534,9 @@ auglx_set_params(void *v, int setmode, int usemode, struct audio_params *play, } if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = 0; - if (rec->precision > 16) - rec->precision = 16; - if (rec->channels > 2) - rec->channels = 2; - switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - switch (rec->channels) { - case 1: - rec->sw_code = slinear16_to_mulaw_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = slinear16_to_mulaw_le; - rec->factor = 2; - break; - } - break; - case AUDIO_ENCODING_ALAW: - switch (rec->channels) { - case 1: - rec->sw_code = slinear16_to_alaw_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = slinear16_to_alaw_le; - rec->factor = 2; - break; - } - break; - case AUDIO_ENCODING_SLINEAR_LE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_linear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_linear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_decimator; - rec->factor = 2; - break; - case 2: - break; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_ulinear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_ulinear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = change_sign16_le_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = change_sign16_le; - break; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_linear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_linear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = swap_bytes_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = swap_bytes; - break; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_ulinear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_ulinear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = change_sign16_swap_bytes_le_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = change_sign16_swap_bytes_le; - break; - } - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } + rec->precision = 16; + rec->channels = 2; + rec->encoding = AUDIO_ENCODING_ULINEAR_LE; rec->bps = AUDIO_BPS(rec->precision); rec->msb = 1; diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c index 94adc5a3b71..c22915c169a 100644 --- a/sys/dev/pci/auich.c +++ b/sys/dev/pci/auich.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auich.c,v 1.103 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: auich.c,v 1.104 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2000,2001 Michael Shalayeff @@ -44,8 +44,6 @@ #include #include -#include -#include #include @@ -686,76 +684,17 @@ auich_get_default_params(void *addr, int mode, struct audio_params *params) int auich_query_encoding(void *v, struct audio_encoding *aep) { - struct auich_softc *sc = v; - if (sc->sc_spdif) { - switch (aep->index) { - case 0: - strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR_LE; - aep->precision = 16; - aep->flags = 0; - aep->bps = 2; - aep->msb = 1; - return (0); - default: - return (EINVAL); - } - } else { - switch (aep->index) { - case 0: - strlcpy(aep->name, AudioEulinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = 0; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: - strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR_LE; - aep->precision = 16; - aep->flags = 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; - 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; - 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; - break; - default: - return (EINVAL); - } - aep->bps = AUDIO_BPS(aep->precision); + switch (aep->index) { + case 0: + strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); + aep->encoding = AUDIO_ENCODING_SLINEAR_LE; + aep->precision = 16; + aep->flags = 0; + aep->bps = 2; aep->msb = 1; return (0); + default: + return (EINVAL); } } @@ -780,190 +719,29 @@ auich_set_params(void *v, int setmode, int usemode, } } if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = NULL; - if (play->precision > 16) - play->precision = 16; + play->precision = 16; switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - if (play->channels > 2) - play->channels = 2; - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = mulaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; case AUDIO_ENCODING_SLINEAR_LE: - switch (play->precision) { - case 8: - if (play->channels > 2) - play->channels = 2; - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - if (play->channels > 6) - play->channels = 6; - if (play->channels > 1) - play->channels &= ~1; - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = noswap_bytes_mts; - break; - case 2: - break; - case 4: - ext_id = codec->vtbl->get_caps(codec); - if (!(ext_id & AC97_EXT_AUDIO_SDAC)) - play->channels = 2; - break; - case 6: - ext_id = codec->vtbl->get_caps(codec); - if ((ext_id & AC97_BITS_6CH) != - AC97_BITS_6CH) - play->channels = 2; - break; - default: - return (EINVAL); - } - break; - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - if (play->channels > 2) - play->channels = 2; - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = change_sign16_le_mts; - break; - case 2: - play->sw_code = change_sign16_le; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ALAW: - if (play->channels > 2) - play->channels = 2; + if (play->channels > 6) + play->channels = 6; + if (play->channels > 1) + play->channels &= ~1; switch (play->channels) { case 1: - play->factor = 4; - play->sw_code = alaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (play->channels > 2) play->channels = 2; - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_mts; - break; - case 2: - play->sw_code = swap_bytes; - break; - default: - return (EINVAL); - } + case 2: break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (play->channels > 2) - play->channels = 2; - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } + case 4: + ext_id = codec->vtbl->get_caps(codec); + if (!(ext_id & AC97_EXT_AUDIO_SDAC)) + play->channels = 2; break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_change_sign16_le_mts; - break; - case 2: - play->sw_code = swap_bytes_change_sign16_le; - break; - default: - return (EINVAL); - } + case 6: + ext_id = codec->vtbl->get_caps(codec); + if ((ext_id & AC97_BITS_6CH) != + AC97_BITS_6CH) + play->channels = 2; break; default: return (EINVAL); @@ -1014,155 +792,9 @@ auich_set_params(void *v, int setmode, int usemode, } if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = 0; - if (rec->channels > 2) - rec->channels = 2; - if (rec->precision > 16) - rec->precision = 16; - switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - switch (rec->channels) { - case 1: - rec->sw_code = slinear16_to_mulaw_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = slinear16_to_mulaw_le; - rec->factor = 2; - break; - } - break; - case AUDIO_ENCODING_ALAW: - switch (rec->channels) { - case 1: - rec->sw_code = slinear16_to_alaw_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = slinear16_to_alaw_le; - rec->factor = 2; - break; - } - break; - case AUDIO_ENCODING_SLINEAR_LE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_linear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_linear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_decimator; - rec->factor = 2; - break; - case 2: - break; - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_ulinear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_ulinear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = change_sign16_le_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = change_sign16_le; - break; - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_linear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_linear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = swap_bytes_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = swap_bytes; - break; - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_ulinear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_ulinear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = change_sign16_swap_bytes_le_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = change_sign16_swap_bytes_le; - break; - } - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } + rec->channels = 2; + rec->precision = 16; + rec->encoding = AUDIO_ENCODING_SLINEAR_LE; rec->bps = AUDIO_BPS(rec->precision); rec->msb = 1; diff --git a/sys/dev/pci/auixp.c b/sys/dev/pci/auixp.c index 1291bfdb8fc..299d260e4c8 100644 --- a/sys/dev/pci/auixp.c +++ b/sys/dev/pci/auixp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auixp.c,v 1.34 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: auixp.c,v 1.35 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: auixp.c,v 1.9 2005/06/27 21:13:09 thorpej Exp $ */ /* @@ -68,8 +68,6 @@ #include #include -#include -#include #include #include @@ -222,53 +220,11 @@ auixp_query_encoding(void *hdl, struct audio_encoding *aep) { switch (aep->index) { case 0: - strlcpy(aep->name, AudioEulinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -373,171 +329,10 @@ auixp_set_params(void *hdl, int setmode, int usemode, co = (struct auixp_codec *) hdl; if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = NULL; - if (play->channels > 2) - play->channels = 2; - if (play->precision > 16) - play->precision = 16; + play->channels = 2; + play->precision = 16; switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = mulaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; case AUDIO_ENCODING_SLINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = noswap_bytes_mts; - break; - case 2: - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = change_sign16_le_mts; - break; - case 2: - play->sw_code = change_sign16_le; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ALAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = alaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_mts; - break; - case 2: - play->sw_code = swap_bytes; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_change_sign16_le_mts; - break; - case 2: - play->sw_code = swap_bytes_change_sign16_le; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } break; default: return (EINVAL); @@ -566,36 +361,10 @@ auixp_set_params(void *hdl, int setmode, int usemode, } if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = 0; - if (rec->channels > 2) - rec->channels = 2; - if (rec->precision > 16) - rec->precision = 16; + rec->channels = 2; + rec->precision = 16; switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - rec->sw_code = ulinear8_to_mulaw; - break; case AUDIO_ENCODING_SLINEAR_LE: - if (rec->precision == 8) - rec->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_LE: - if (rec->precision == 16) - rec->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ALAW: - rec->sw_code = ulinear8_to_alaw; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes; - else - rec->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes_change_sign16_le; break; default: return (EINVAL); diff --git a/sys/dev/pci/autri.c b/sys/dev/pci/autri.c index 50d11713885..1ba41523840 100644 --- a/sys/dev/pci/autri.c +++ b/sys/dev/pci/autri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autri.c,v 1.36 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: autri.c,v 1.37 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro. @@ -50,8 +50,6 @@ #include #include #include -#include -#include #include #include @@ -912,47 +910,23 @@ autri_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; - case 4: + case 2: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: + case 3: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - break; default: return (EINVAL); } @@ -983,30 +957,14 @@ autri_set_params(void *addr, int setmode, int usemode, struct audio_params *play p->precision = 16; if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_BE: case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; + if (p->precision != 16) + return EINVAL; break; case AUDIO_ENCODING_SLINEAR_LE: case AUDIO_ENCODING_ULINEAR_LE: - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) - p->sw_code = mulaw_to_ulinear8; - else - p->sw_code = ulinear8_to_mulaw; - - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) - p->sw_code = alaw_to_ulinear8; - else - p->sw_code = ulinear8_to_alaw; - break; default: return (EINVAL); diff --git a/sys/dev/pci/auvia.c b/sys/dev/pci/auvia.c index aed047d83dc..a68db8c2c89 100644 --- a/sys/dev/pci/auvia.c +++ b/sys/dev/pci/auvia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auvia.c,v 1.54 2015/05/07 01:55:43 jsg Exp $ */ +/* $OpenBSD: auvia.c,v 1.55 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: auvia.c,v 1.28 2002/11/04 16:38:49 kent Exp $ */ /*- @@ -48,8 +48,6 @@ #include #include -#include -#include #include @@ -543,47 +541,11 @@ auvia_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -603,7 +565,7 @@ auvia_set_params_sub(struct auvia_softc *sc, struct auvia_softc_chan *ch, if (!(sc->sc_flags & AUVIA_FLAGS_VT8233)) { regval = (p->channels == 2 ? AUVIA_RPMODE_STEREO : 0) - | (p->precision * p->factor == 16 ? + | (p->precision == 16 ? AUVIA_RPMODE_16BIT : 0) | AUVIA_RPMODE_INTR_FLAG | AUVIA_RPMODE_INTR_EOL | AUVIA_RPMODE_AUTOSTART; @@ -728,45 +690,15 @@ auvia_set_params(void *addr, int setmode, int usemode, } } - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) - p->sw_code = mode == AUMODE_PLAY? - swap_bytes_change_sign16_le : - change_sign16_swap_bytes_le; + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; - break; - case AUDIO_ENCODING_SLINEAR: - case AUDIO_ENCODING_ULINEAR: + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; break; default: return (EINVAL); diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index b126ef615b3..3fba10ecd0f 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.220 2015/02/10 06:19:44 dlg Exp $ */ +/* $OpenBSD: azalia.c,v 1.221 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -3910,8 +3909,6 @@ azalia_get_default_params(void *addr, int mode, struct audio_params *params) params->bps = 2; params->msb = 1; params->channels = 2; - params->sw_code = NULL; - params->factor = 1; } int @@ -3944,7 +3941,6 @@ azalia_match_format(codec_t *codec, int mode, audio_params_t *par) int azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) { - void (*swcode)(void *, u_char *, int) = NULL; char *cmode; int i, j; uint ochan, oenc, opre; @@ -3965,20 +3961,6 @@ azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) } i = azalia_match_format(codec, mode, par); - if (i == codec->nformats && par->channels == 1) { - /* find a 2 channel format and emulate mono */ - par->channels = 2; - i = azalia_match_format(codec, mode, par); - if (i != codec->nformats) { - par->factor = 2; - if (mode == AUMODE_RECORD) - swcode = linear16_decimator; - else - swcode = noswap_bytes_mts; - par->channels = 1; - } - } - par->channels = ochan; if (i == codec->nformats && (par->precision != 16 || par->encoding != AUDIO_ENCODING_SLINEAR_LE)) { /* try with default encoding/precision */ @@ -3986,20 +3968,6 @@ azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) par->precision = 16; i = azalia_match_format(codec, mode, par); } - if (i == codec->nformats && par->channels == 1) { - /* find a 2 channel format and emulate mono */ - par->channels = 2; - i = azalia_match_format(codec, mode, par); - if (i != codec->nformats) { - par->factor = 2; - if (mode == AUMODE_RECORD) - swcode = linear16_decimator; - else - swcode = noswap_bytes_mts; - par->channels = 1; - } - } - par->channels = ochan; if (i == codec->nformats && par->channels != 2) { /* try with default channels */ par->encoding = oenc; @@ -4045,7 +4013,6 @@ azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) return EINVAL; } } - par->sw_code = swcode; par->bps = AUDIO_BPS(par->precision); par->msb = 1; @@ -4328,11 +4295,8 @@ azalia_params2fmt(const audio_params_t *param, uint16_t *fmt) DPRINTFN(1, ("%s: prec=%d, chan=%d, rate=%ld\n", __func__, param->precision, param->channels, param->sample_rate)); - /* Only mono is emulated, and it is emulated from stereo. */ - if (param->sw_code != NULL) - ret |= 1; - else - ret |= param->channels - 1; + /* XXX: can channels be >2 ? */ + ret |= param->channels - 1; switch (param->precision) { case 8: diff --git a/sys/dev/pci/cmpci.c b/sys/dev/pci/cmpci.c index cb84442f414..d4e4d9940ad 100644 --- a/sys/dev/pci/cmpci.c +++ b/sys/dev/pci/cmpci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmpci.c,v 1.38 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: cmpci.c,v 1.39 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: cmpci.c,v 1.25 2004/10/26 06:32:20 xtraeme Exp $ */ /* @@ -62,8 +62,6 @@ int cmpcidebug = 0; #include #include -#include -#include #include #include @@ -654,47 +652,11 @@ cmpci_query_encoding(void *handle, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - 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; - break; default: return EINVAL; } @@ -713,8 +675,6 @@ cmpci_get_default_params(void *addr, int mode, struct audio_params *params) params->bps = 2; params->msb = 1; params->channels = 2; - params->sw_code = NULL; - params->factor = 1; } int @@ -778,7 +738,6 @@ cmpci_set_params(void *handle, int setmode, int usemode, /* format */ if (p->precision > 16) p->precision = 16; - p->sw_code = NULL; switch (p->channels) { case 1: md_format = CMPCI_REG_FORMAT_MONO; @@ -851,83 +810,16 @@ cmpci_set_params(void *handle, int setmode, int usemode, return (EINVAL); } switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - if (mode & AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - md_format |= CMPCI_REG_FORMAT_16BIT; - } else { - p->sw_code = ulinear8_to_mulaw; - md_format |= CMPCI_REG_FORMAT_8BIT; - } - break; - case AUDIO_ENCODING_ALAW: - if (mode & AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - md_format |= CMPCI_REG_FORMAT_16BIT; - } else { - p->sw_code = ulinear8_to_alaw; - md_format |= CMPCI_REG_FORMAT_8BIT; - } - break; case AUDIO_ENCODING_SLINEAR_LE: - switch (p->precision) { - case 8: - p->sw_code = change_sign8; - md_format |= CMPCI_REG_FORMAT_8BIT; - break; - case 16: - md_format |= CMPCI_REG_FORMAT_16BIT; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (p->precision) { - case 8: - md_format |= CMPCI_REG_FORMAT_8BIT; - p->sw_code = change_sign8; - break; - case 16: - md_format |= CMPCI_REG_FORMAT_16BIT; - p->sw_code = swap_bytes; - break; - default: + if (p->precision != 16) return (EINVAL); - } + md_format |= CMPCI_REG_FORMAT_16BIT; break; case AUDIO_ENCODING_ULINEAR_LE: - switch (p->precision) { - case 8: - md_format |= CMPCI_REG_FORMAT_8BIT; - break; - case 16: - md_format |= CMPCI_REG_FORMAT_16BIT; - p->sw_code = change_sign16_le; - break; - default: - return (EINVAL); - } - break; case AUDIO_ENCODING_ULINEAR_BE: - switch (p->precision) { - case 8: - md_format |= CMPCI_REG_FORMAT_8BIT; - break; - case 16: - md_format |= CMPCI_REG_FORMAT_16BIT; - if (mode & AUMODE_PLAY) - p->sw_code = - swap_bytes_change_sign16_le; - else - p->sw_code = - change_sign16_swap_bytes_le; - break; - default: + if (p->precision != 8) return (EINVAL); - } + md_format |= CMPCI_REG_FORMAT_8BIT; break; default: return (EINVAL); @@ -2015,7 +1907,7 @@ cmpci_trigger_output(void *handle, void *start, void *end, int blksize, reg_enable = CMPCI_REG_CH0_ENABLE; } - chan->bps = (param->channels > 1 ? 2 : 1) * param->bps * param->factor; + chan->bps = (param->channels > 1 ? 2 : 1) * param->bps; if (!chan->bps) return EINVAL; @@ -2060,7 +1952,7 @@ cmpci_trigger_input(void *handle, void *start, void *end, int blksize, cmpci_set_in_ports(sc); - chan->bps = param->channels * param->bps * param->factor; + chan->bps = param->channels * param->bps; if (!chan->bps) return EINVAL; diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 266079dca8f..8a4cf871614 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4280.c,v 1.46 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: cs4280.c,v 1.47 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */ /* @@ -78,8 +78,6 @@ int cs4280debug = 0; #include #include -#include -#include #include @@ -1020,53 +1018,11 @@ cs4280_query_encoding(void *addr, struct audio_encoding *fp) { switch (fp->index) { case 0: - strlcpy(fp->name, AudioEulinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR; - fp->precision = 8; - fp->flags = 0; - break; - case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = 0; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = 0; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = 0; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = 0; - break; default: return (EINVAL); } @@ -1116,51 +1072,11 @@ cs4280_set_params(void *addr, int setmode, int usemode, p->precision = 16; if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; /* capturing data is slinear */ switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (mode == AUMODE_RECORD) { - if (p->precision == 16) - p->sw_code = swap_bytes; - } - break; case AUDIO_ENCODING_SLINEAR_LE: break; - case AUDIO_ENCODING_ULINEAR_BE: - if (mode == AUMODE_RECORD) { - if (p->precision == 16) - p->sw_code = change_sign16_swap_bytes_le; - else - p->sw_code = change_sign8; - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - if (mode == AUMODE_RECORD) { - if (p->precision == 16) - p->sw_code = change_sign16_le; - else - p->sw_code = change_sign8; - } - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else { - p->sw_code = slinear8_to_mulaw; - } - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else { - p->sw_code = slinear8_to_alaw; - } - break; default: return (EINVAL); } @@ -1445,8 +1361,8 @@ cs4280_trigger_output(void *addr, void *start, void *end, int blksize, pdtc |= CS4280_MK_PDTC(param->precision * param->channels); BA1WRITE4(sc, CS4280_PDTC, pdtc); - DPRINTF(("param: precision=%d factor=%d channels=%d encoding=%d\n", - param->precision, param->factor, param->channels, + DPRINTF(("param: precision=%d channels=%d encoding=%d\n", + param->precision, param->channels, param->encoding)); for (p = sc->sc_dmas; p != NULL && BUFADDR(p) != start; p = p->next) ; @@ -1483,7 +1399,7 @@ cs4280_trigger_output(void *addr, void *start, void *end, int blksize, /* set PFIE */ pfie = BA1READ4(sc, CS4280_PFIE) & ~PFIE_MASK; - if (param->precision * param->factor == 8) + if (param->precision == 8) pfie |= PFIE_8BIT; if (param->channels == 1) pfie |= PFIE_MONO; diff --git a/sys/dev/pci/cs4281.c b/sys/dev/pci/cs4281.c index a78944334fe..0d2b8cd9a7e 100644 --- a/sys/dev/pci/cs4281.c +++ b/sys/dev/pci/cs4281.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4281.c,v 1.31 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: cs4281.c,v 1.32 2015/05/11 06:46:22 ratchov Exp $ */ /* $Tera: cs4281.c,v 1.18 2000/12/27 14:24:45 tacha Exp $ */ /* @@ -55,8 +55,6 @@ #include #include #include -#include -#include #include @@ -448,42 +446,30 @@ cs4281_query_encoding(addr, fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; - case 4: + case 2: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: + case 3: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 6: + case 4: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = 0; break; - case 7: + case 5: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; @@ -530,8 +516,6 @@ cs4281_set_params(addr, setmode, usemode, play, rec) p->precision = 16; if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_BE: @@ -542,20 +526,6 @@ cs4281_set_params(addr, setmode, usemode, play, rec) break; case AUDIO_ENCODING_ULINEAR_LE: break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->sw_code = mulaw_to_slinear8; - } else { - p->sw_code = slinear8_to_mulaw; - } - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->sw_code = alaw_to_slinear8; - } else { - p->sw_code = slinear8_to_alaw; - } - break; default: return (EINVAL); } @@ -634,8 +604,8 @@ cs4281_trigger_output(addr, start, end, blksize, intr, arg, param) /* stop playback DMA */ BA0WRITE4(sc, CS4281_DCR0, BA0READ4(sc, CS4281_DCR0) | DCRn_MSK); - DPRINTF(("param: precision=%d factor=%d channels=%d encoding=%d\n", - param->precision, param->factor, param->channels, + DPRINTF(("param: precision=%d channels=%d encoding=%d\n", + param->precision, param->channels, param->encoding)); for (p = sc->sc_dmas; p != NULL && BUFADDR(p) != start; p = p->next) ; @@ -662,7 +632,7 @@ cs4281_trigger_output(addr, start, end, blksize, intr, arg, param) } dma_count = sc->dma_size; - if (param->precision * param->factor != 8) + if (param->precision != 8) dma_count /= 2; /* 16 bit */ if (param->channels > 1) dma_count /= 2; /* Stereo */ @@ -674,7 +644,7 @@ cs4281_trigger_output(addr, start, end, blksize, intr, arg, param) /* set playback format */ fmt = BA0READ4(sc, CS4281_DMR0) & ~DMRn_FMTMSK; - if (param->precision * param->factor == 8) + if (param->precision == 8) fmt |= DMRn_SIZE8; if (param->channels == 1) fmt |= DMRn_MONO; @@ -756,7 +726,7 @@ cs4281_trigger_input(addr, start, end, blksize, intr, arg, param) sc->sc_rn = sc->sc_rs; dma_count = sc->dma_size; - if (param->precision * param->factor == 8) + if (param->precision == 8) dma_count /= 2; if (param->channels > 1) dma_count /= 2; @@ -768,7 +738,7 @@ cs4281_trigger_input(addr, start, end, blksize, intr, arg, param) /* set recording format */ fmt = BA0READ4(sc, CS4281_DMR1) & ~DMRn_FMTMSK; - if (param->precision * param->factor == 8) + if (param->precision == 8) fmt |= DMRn_SIZE8; if (param->channels == 1) fmt |= DMRn_MONO; diff --git a/sys/dev/pci/eap.c b/sys/dev/pci/eap.c index 1c77404505b..872e674ff41 100644 --- a/sys/dev/pci/eap.c +++ b/sys/dev/pci/eap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eap.c,v 1.50 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: eap.c,v 1.51 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: eap.c,v 1.46 2001/09/03 15:07:37 reinoud Exp $ */ /* @@ -61,8 +61,6 @@ #include #include #include -#include -#include #include #include @@ -875,47 +873,11 @@ eap_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -974,45 +936,15 @@ eap_set_params(void *addr, int setmode, int usemode, p->precision = 16; if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = swap_bytes_change_sign16_le; - else - p->sw_code = change_sign16_swap_bytes_le; - } + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; - break; + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; default: return (EINVAL); } @@ -1079,9 +1011,9 @@ eap_trigger_output( mtx_enter(&audio_lock); sic = EREAD4(sc, EAP_SIC); sic &= ~(EAP_P2_S_EB | EAP_P2_S_MB | EAP_INC_BITS); - sic |= EAP_SET_P2_ST_INC(0) | EAP_SET_P2_END_INC(param->precision * param->factor / 8); + sic |= EAP_SET_P2_ST_INC(0) | EAP_SET_P2_END_INC(param->precision / 8); sampshift = 0; - if (param->precision * param->factor == 16) { + if (param->precision == 16) { sic |= EAP_P2_S_EB; sampshift++; } @@ -1150,7 +1082,7 @@ eap_trigger_input( sic = EREAD4(sc, EAP_SIC); sic &= ~(EAP_R1_S_EB | EAP_R1_S_MB); sampshift = 0; - if (param->precision * param->factor == 16) { + if (param->precision == 16) { sic |= EAP_R1_S_EB; sampshift++; } diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c index 63cc9235f6c..3abce7857e3 100644 --- a/sys/dev/pci/emuxki.c +++ b/sys/dev/pci/emuxki.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emuxki.c,v 1.47 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: emuxki.c,v 1.48 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: emuxki.c,v 1.1 2001/10/17 18:39:41 jdolecek Exp $ */ /*- @@ -63,15 +63,11 @@ #include #include -#include -#include #include #include #include -#define slinear16_to_ulinear8_le linear16_to_ulinear8_le; - /* autconf goo */ int emuxki_match(struct device *, void *, void *); void emuxki_attach(struct device *, struct device *, void *); @@ -2098,47 +2094,11 @@ emuxki_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -2155,8 +2115,6 @@ emuxki_set_vparms(struct emuxki_voice *voice, struct audio_params *p) mode = (voice->use & EMU_VOICE_USE_PLAY) ? AUMODE_PLAY : AUMODE_RECORD; - p->factor = 1; - p->sw_code = NULL; if (p->channels > 2) p->channels = 2; if (p->precision > 16) @@ -2171,64 +2129,19 @@ emuxki_set_vparms(struct emuxki_voice *voice, struct audio_params *p) b16 = (p->precision == 16); else { b16 = 1; - if (p->precision == 8) - p->factor *= 2; + p->precision = 16; } switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - b16 = 1; - } else - p->sw_code = slinear16_to_mulaw_le; - break; - - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - b16 = 1; - } else - p->sw_code = slinear16_to_alaw_le; - break; - case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision == 8) { - if (mode == AUMODE_PLAY) - p->sw_code = change_sign8; - else - p->sw_code = linear16_to_linear8_le; - } + if (p->precision != 16) + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - else if (mode == AUMODE_RECORD) - p->sw_code = slinear16_to_ulinear8_le; - break; - - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else { - if (mode == AUMODE_PLAY) - p->sw_code = change_sign8; - else - p->sw_code = linear16_to_linear8_le; - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = swap_bytes_change_sign16_le; - else - p->sw_code = change_sign16_swap_bytes_le; - } else if (mode == AUMODE_RECORD) - p->sw_code = slinear16_to_ulinear8_le; + if (p->precision != 8) + return EINVAL; break; default: diff --git a/sys/dev/pci/esa.c b/sys/dev/pci/esa.c index 0c590636bee..0dc5db2bbed 100644 --- a/sys/dev/pci/esa.c +++ b/sys/dev/pci/esa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esa.c,v 1.28 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: esa.c,v 1.29 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: esa.c,v 1.12 2002/03/24 14:17:35 jmcneill Exp $ */ /* @@ -61,8 +61,6 @@ #include #include -#include -#include #include #include @@ -166,19 +164,7 @@ int esa_resume(struct esa_softc *); static audio_encoding_t esa_encoding[] = { { 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 } + { 1, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 2, 1, 0 } }; #define ESA_NENCODINGS 8 @@ -292,47 +278,15 @@ esa_set_params(void *hdl, int setmode, int usemode, struct audio_params *play, if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; - switch(p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = - swap_bytes_change_sign16_le; - else - p->sw_code = - change_sign16_swap_bytes_le; - } + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; break; default: return (EINVAL); @@ -369,7 +323,7 @@ esa_commit_settings(void *hdl) esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_DATA, vc->play.data_offset + ESA_SRC3_MODE_OFFSET, data); - if (p->precision * p->factor == 8) + if (p->precision == 8) data = 1; else data = 0; @@ -392,7 +346,7 @@ esa_commit_settings(void *hdl) esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_DATA, vc->rec.data_offset + ESA_SRC3_MODE_OFFSET, data); - if (r->precision * r->factor == 8) + if (r->precision == 8) data = 1; else data = 0; diff --git a/sys/dev/pci/eso.c b/sys/dev/pci/eso.c index cf78cb92cb7..73aa1b2a3cf 100644 --- a/sys/dev/pci/eso.c +++ b/sys/dev/pci/eso.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eso.c,v 1.39 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: eso.c,v 1.40 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: eso.c,v 1.48 2006/12/18 23:13:39 kleink Exp $ */ /* @@ -46,9 +46,6 @@ #include #include -#include -#include - #include #include #include @@ -672,47 +669,23 @@ eso_query_encoding(void *hdl, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; - case 4: + case 2: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: + case 3: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - break; default: return (EINVAL); } @@ -731,8 +704,6 @@ eso_get_default_params(void *addr, int mode, struct audio_params *params) params->bps = 2; params->msb = 1; params->channels = 2; - params->sw_code = NULL; - params->factor = 1; } int @@ -760,33 +731,15 @@ eso_set_params(void *hdl, int setmode, int usemode, if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = NULL; switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_BE: case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; + if (p->precision != 8) + return EINVAL; break; case AUDIO_ENCODING_SLINEAR_LE: case AUDIO_ENCODING_ULINEAR_LE: break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_ulinear16_le; - } else { - p->sw_code = ulinear8_to_mulaw; - } - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_ulinear16_le; - } else { - p->sw_code = ulinear8_to_alaw; - } - break; default: return (EINVAL); } @@ -1726,9 +1679,9 @@ eso_trigger_output(void *hdl, void *start, void *end, int blksize, DPRINTF(( "%s: trigger_output: start %p, end %p, blksize %d, intr %p(%p)\n", sc->sc_dev.dv_xname, start, end, blksize, intr, arg)); - DPRINTF(("%s: param: rate %lu, encoding %u, precision %u, channels %u, sw_code %p, factor %d\n", + DPRINTF(("%s: param: rate %lu, encoding %u, precision %u, channels %u\n", sc->sc_dev.dv_xname, param->sample_rate, param->encoding, - param->precision, param->channels, param->sw_code, param->factor)); + param->precision, param->channels)); /* Find DMA buffer. */ for (ed = sc->sc_dmas; ed != NULL && KVADDR(ed) != start; @@ -1747,7 +1700,7 @@ eso_trigger_output(void *hdl, void *start, void *end, int blksize, /* Compute drain timeout. */ sc->sc_pdrain = hz * (blksize * 3 / 2) / - (param->sample_rate * param->channels * param->bps * param->factor); + (param->sample_rate * param->channels * param->bps); /* DMA transfer count (in `words'!) reload using 2's complement. */ blksize = -(blksize >> 1); @@ -1756,7 +1709,7 @@ eso_trigger_output(void *hdl, void *start, void *end, int blksize, /* Update DAC to reflect DMA count and audio parameters. */ /* Note: we cache A2C2 in order to avoid r/m/w at interrupt time. */ - if (param->precision * param->factor == 16) + if (param->precision == 16) sc->sc_a2c2 |= ESO_MIXREG_A2C2_16BIT; else sc->sc_a2c2 &= ~ESO_MIXREG_A2C2_16BIT; @@ -1802,9 +1755,9 @@ eso_trigger_input(void *hdl, void *start, void *end, int blksize, DPRINTF(( "%s: trigger_input: start %p, end %p, blksize %d, intr %p(%p)\n", sc->sc_dev.dv_xname, start, end, blksize, intr, arg)); - DPRINTF(("%s: param: rate %lu, encoding %u, precision %u, channels %u, sw_code %p, factor %d\n", + DPRINTF(("%s: param: rate %lu, encoding %u, precision %u, channels %u\n", sc->sc_dev.dv_xname, param->sample_rate, param->encoding, - param->precision, param->channels, param->sw_code, param->factor)); + param->precision, param->channels)); /* * If we failed to configure the Audio 1 DMA controller, bail here @@ -1830,7 +1783,7 @@ eso_trigger_input(void *hdl, void *start, void *end, int blksize, /* Compute drain timeout. */ sc->sc_rdrain = hz * (blksize * 3 / 2) / - (param->sample_rate * param->channels * param->bps * param->factor); + (param->sample_rate * param->channels * param->bps); /* Set up ADC DMA converter parameters. */ actl = eso_read_ctlreg(sc, ESO_CTLREG_ACTL); @@ -1853,7 +1806,7 @@ eso_trigger_input(void *hdl, void *start, void *end, int blksize, /* Set up and enable Audio 1 DMA FIFO. */ a1c1 = ESO_CTLREG_A1C1_RESV1 | ESO_CTLREG_A1C1_FIFOENB; - if (param->precision * param->factor == 16) + if (param->precision == 16) a1c1 |= ESO_CTLREG_A1C1_16BIT; if (param->channels == 2) a1c1 |= ESO_CTLREG_A1C1_STEREO; diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci index 33391cc0002..2483a060a24 100644 --- a/sys/dev/pci/files.pci +++ b/sys/dev/pci/files.pci @@ -1,4 +1,4 @@ -# $OpenBSD: files.pci,v 1.314 2015/04/09 18:58:22 deraadt Exp $ +# $OpenBSD: files.pci,v 1.315 2015/05/11 06:46:22 ratchov Exp $ # $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $ # # Config file and device description for machine-independent PCI code. @@ -112,27 +112,27 @@ attach ips at pci file dev/pci/ips.c ips # Ensoniq AudioPCI S5016, 1371 -device eap: audio, auconv, mulaw, ac97, midibus +device eap: audio, ac97, midibus attach eap at pci file dev/pci/eap.c eap # ESS Solo-1 PCI AudioDrive -device eso {}: audio, auconv, mulaw, midibus +device eso {}: audio, midibus attach eso at pci file dev/pci/eso.c eso # Acer Labs M5455 -device auacer: audio, auconv, mulaw, ac97 +device auacer: audio, ac97 attach auacer at pci file dev/pci/auacer.c auacer # Intel 810/820/440MX ICH audio with AC'97 -device auich: audio, auconv, mulaw, ac97 +device auich: audio, ac97 attach auich at pci file dev/pci/auich.c auich # Intel 82801 HDA -device azalia: audio, auconv, mulaw, ac97 +device azalia: audio, ac97 attach azalia at pci file dev/pci/azalia.c azalia file dev/pci/azalia_codec.c azalia @@ -143,53 +143,53 @@ attach envy at pci file dev/pci/envy.c envy # Creative Labs EMU10k1 (SBLive! series and PCI512) -device emu: audio, auconv, mulaw, ac97 +device emu: audio, ac97 attach emu at pci file dev/pci/emuxki.c emu # Trident 4DWAVE based PCI audio (including SiS 7018, ALi M5451) -device autri: audio, auconv, mulaw, ac97, midibus +device autri: audio, ac97, midibus attach autri at pci file dev/pci/autri.c autri # ATI SB200/300/400 series AC'97 Audio -device auixp: audio, auconv, mulaw, ac97 +device auixp: audio, ac97 attach auixp at pci file dev/pci/auixp.c auixp # CS4280 CrystalClear Audio -device clcs: audio, auconv, mulaw, ac97, firmload +device clcs: audio, ac97, firmload attach clcs at pci file dev/pci/cs4280.c clcs # CS4281 CrystalClear Audio -device clct: audio, auconv, mulaw, ac97 +device clct: audio, ac97 attach clct at pci file dev/pci/cs4281.c clct # ESS Maestro -device maestro: audio, auconv, mulaw, ac97 +device maestro: audio, ac97 attach maestro at pci file dev/pci/maestro.c maestro # ESS Maestro3 -device esa: audio, auconv, mulaw, ac97 +device esa: audio, ac97 attach esa at pci file dev/pci/esa.c esa # Yamaha YMF Audio -device yds {}: audio, auconv, mulaw, ac97, firmload +device yds {}: audio, ac97, firmload attach yds at pci file dev/pci/yds.c yds # Forte Media FM801 -device fms: audio, auconv, mulaw, ac97, midibus, tea5757, radiobus +device fms: audio, ac97, midibus, tea5757, radiobus attach fms at pci file dev/pci/fms.c fms file dev/pci/fmsradio.c fms & radio # VIA VT82C686A AC'97 Audio -device auvia: audio, auconv, mulaw, ac97 +device auvia: audio, ac97 attach auvia at pci file dev/pci/auvia.c auvia @@ -272,7 +272,7 @@ attach siop at pci with siop_pci: siop_pci_common file dev/pci/siop_pci.c siop_pci # NeoMagic 256AV and 256ZX -device neo: audio, auconv, mulaw, ac97, firmload +device neo: audio, ac97, firmload attach neo at pci file dev/pci/neo.c neo @@ -324,7 +324,7 @@ attach txp at pci file dev/pci/if_txp.c txp # S3 SonicVibes (S3 617) -device sv: audio, auconv, mulaw +device sv: audio attach sv at pci file dev/pci/sv.c sv @@ -575,7 +575,7 @@ attach iwm at pci file dev/pci/if_iwm.c iwm # C-Media CMI8x38 Audio Chip -device cmpci {}: audio, auconv, mulaw +device cmpci {}: audio attach cmpci at pci file dev/pci/cmpci.c cmpci diff --git a/sys/dev/pci/fms.c b/sys/dev/pci/fms.c index 25b6885f7fd..58cef866471 100644 --- a/sys/dev/pci/fms.c +++ b/sys/dev/pci/fms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fms.c,v 1.26 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: fms.c,v 1.27 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: fms.c,v 1.5.4.1 2000/06/30 16:27:50 simonb Exp $ */ /*- @@ -50,9 +50,6 @@ #include #include -#include -#include - #include #if 0 #include @@ -439,53 +436,17 @@ fms_query_encoding(void *addr, struct audio_encoding *fp) switch (fp->index) { case 0: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 2: + case 1: strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; - case 3: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - 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; - break; - case 5: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - 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; - 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; - break; default: return EINVAL; } @@ -532,34 +493,15 @@ fms_set_params(void *addr, int setmode, int usemode, struct audio_params *play, int i; if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = 0; switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; case AUDIO_ENCODING_SLINEAR_LE: - if (play->precision == 8) - play->sw_code = change_sign8; + if (play->precision != 16) + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (play->precision == 16) - play->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ALAW: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (play->precision == 16) - play->sw_code = swap_bytes; - else - play->sw_code = change_sign8; - break; case AUDIO_ENCODING_ULINEAR_BE: - if (play->precision == 16) - play->sw_code = change_sign16_swap_bytes_le; + if (play->precision != 8) + return EINVAL; break; default: return EINVAL; @@ -572,38 +514,21 @@ fms_set_params(void *addr, int setmode, int usemode, struct audio_params *play, ; play->sample_rate = fms_rates[i].rate; sc->sc_play_reg = (play->channels == 2 ? FM_PLAY_STEREO : 0) | - (play->precision * play->factor == 16 ? FM_PLAY_16BIT : 0) | + (play->precision == 16 ? FM_PLAY_16BIT : 0) | (i << 8); } if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = 0; switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - rec->sw_code = ulinear8_to_mulaw; - break; case AUDIO_ENCODING_SLINEAR_LE: - if (rec->precision == 8) - rec->sw_code = change_sign8; + if (rec->precision != 16) + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (rec->precision == 16) - rec->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ALAW: - rec->sw_code = ulinear8_to_alaw; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes; - else - rec->sw_code = change_sign8; - break; case AUDIO_ENCODING_ULINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes_change_sign16_le; + if (rec->precision != 8) + return EINVAL; break; default: return EINVAL; @@ -617,7 +542,7 @@ fms_set_params(void *addr, int setmode, int usemode, struct audio_params *play, rec->sample_rate = fms_rates[i].rate; sc->sc_rec_reg = (rec->channels == 2 ? FM_REC_STEREO : 0) | - (rec->precision * rec->factor == 16 ? FM_REC_16BIT : 0) | + (rec->precision == 16 ? FM_REC_16BIT : 0) | (i << 8); } diff --git a/sys/dev/pci/maestro.c b/sys/dev/pci/maestro.c index 890eae1a4b0..54434d5ac10 100644 --- a/sys/dev/pci/maestro.c +++ b/sys/dev/pci/maestro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: maestro.c,v 1.38 2014/09/13 16:06:37 doug Exp $ */ +/* $OpenBSD: maestro.c,v 1.39 2015/05/11 06:46:22 ratchov 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 @@ -59,8 +59,6 @@ #include #include -#include -#include #include @@ -943,17 +941,7 @@ maestro_query_devinfo(void *self, mixer_devinfo_t *cp) struct audio_encoding maestro_tab[] = { {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, 2, 1, - AUDIO_ENCODINGFLAG_EMULATED}, - {5, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16, 2, 1, - AUDIO_ENCODINGFLAG_EMULATED}, - {6, AudioEmulaw, AUDIO_ENCODING_ULAW, 8, 1, 1, - AUDIO_ENCODINGFLAG_EMULATED}, - {7, AudioEalaw, AUDIO_ENCODING_ALAW, 8, 1, 1, - AUDIO_ENCODINGFLAG_EMULATED} + {2, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 1, 1, 0} }; int @@ -1046,8 +1034,6 @@ maestro_set_params(void *hdl, int setmode, int usemode, else if (play->sample_rate > 48000) play->sample_rate = 48000; - play->factor = 1; - play->sw_code = NULL; if (play->channels > 2) play->channels = 2; @@ -1055,24 +1041,12 @@ maestro_set_params(void *hdl, int setmode, int usemode, if (play->channels == 2) sc->play.mode |= MAESTRO_STEREO; - if (play->encoding == AUDIO_ENCODING_ULAW) { - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - } else if (play->encoding == AUDIO_ENCODING_ALAW) { - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - } else if (play->precision == 8) { + if (play->precision == 8) { sc->play.mode |= MAESTRO_8BIT; if (play->encoding == AUDIO_ENCODING_ULINEAR_LE || play->encoding == AUDIO_ENCODING_ULINEAR_BE) sc->play.mode |= MAESTRO_UNSIGNED; } - else if (play->encoding == AUDIO_ENCODING_ULINEAR_LE) - play->sw_code = change_sign16_le; - else if (play->encoding == AUDIO_ENCODING_SLINEAR_BE) - play->sw_code = swap_bytes; - else if (play->encoding == AUDIO_ENCODING_ULINEAR_BE) - play->sw_code = change_sign16_swap_bytes_le; else if (play->encoding != AUDIO_ENCODING_SLINEAR_LE) return (EINVAL); diff --git a/sys/dev/pci/neo.c b/sys/dev/pci/neo.c index 503eb352ab1..cfd183a26ee 100644 --- a/sys/dev/pci/neo.c +++ b/sys/dev/pci/neo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neo.c,v 1.29 2013/11/15 16:46:27 brad Exp $ */ +/* $OpenBSD: neo.c,v 1.30 2015/05/11 06:46:22 ratchov Exp $ */ /* * Copyright (c) 1999 Cameron Grant @@ -43,8 +43,6 @@ #include #include -#include -#include #include #include @@ -761,47 +759,11 @@ neo_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -853,44 +815,15 @@ neo_set_params(void *addr, int setmode, int usemode, NM_PLAYBACK_REG_OFFSET : NM_RECORD_REG_OFFSET; nm_wr(sc, base + NM_RATE_REG_OFFSET, x, 1); - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = swap_bytes_change_sign16_le; - else - p->sw_code = change_sign16_swap_bytes_le; - } + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; break; default: return (EINVAL); @@ -919,7 +852,7 @@ neo_trigger_output(void *addr, void *start, void *end, int blksize, sc->pintr = intr; sc->parg = arg; - ssz = (param->precision * param->factor == 16)? 2 : 1; + ssz = (param->precision == 16) ? 2 : 1; if (param->channels == 2) ssz <<= 1; @@ -950,7 +883,7 @@ neo_trigger_input(void *addr, void *start, void *end, int blksize, sc->rintr = intr; sc->rarg = arg; - ssz = (param->precision * param->factor == 16)? 2 : 1; + ssz = (param->precision == 16) ? 2 : 1; if (param->channels == 2) ssz <<= 1; diff --git a/sys/dev/pci/sv.c b/sys/dev/pci/sv.c index 5fef1c652cb..a7da7cf8b18 100644 --- a/sys/dev/pci/sv.c +++ b/sys/dev/pci/sv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sv.c,v 1.31 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: sv.c,v 1.32 2015/05/11 06:46:22 ratchov Exp $ */ /* * Copyright (c) 1998 Constantine Paul Sapuntzakis @@ -48,8 +48,6 @@ #include #include -#include -#include #include #include @@ -587,48 +585,12 @@ sv_query_encoding(void *addr, struct audio_encoding *fp) fp->precision = 8; fp->flags = 0; break; - case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: + case 1: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -643,41 +605,19 @@ sv_set_params(void *addr, int setmode, int usemode, struct audio_params *p, struct audio_params *r) { struct sv_softc *sc = addr; - void (*pswcode)(void *, u_char *buf, int cnt); - void (*rswcode)(void *, u_char *buf, int cnt); u_int32_t mode, val; u_int8_t reg; - pswcode = rswcode = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - rswcode = pswcode = swap_bytes; - else - pswcode = rswcode = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - pswcode = rswcode = change_sign8; + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - pswcode = swap_bytes_change_sign16_le; - rswcode = change_sign16_swap_bytes_le; - } - break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - pswcode = rswcode = change_sign16_le; + if (p->precision != 8) + return EINVAL; break; - case AUDIO_ENCODING_ULAW: - pswcode = mulaw_to_ulinear8; - rswcode = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - pswcode = alaw_to_ulinear8; - rswcode = ulinear8_to_alaw; - break; default: return (EINVAL); } @@ -695,8 +635,6 @@ sv_set_params(void *addr, int setmode, int usemode, if (p->sample_rate > 48000) p->sample_rate = 48000; - 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; diff --git a/sys/dev/pci/yds.c b/sys/dev/pci/yds.c index fdb3aa991c8..b63db724c69 100644 --- a/sys/dev/pci/yds.c +++ b/sys/dev/pci/yds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yds.c,v 1.49 2015/03/14 03:38:49 jsg Exp $ */ +/* $OpenBSD: yds.c,v 1.50 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: yds.c,v 1.5 2001/05/21 23:55:04 minoura Exp $ */ /* @@ -54,8 +54,6 @@ #include #include #include -#include -#include #include #include @@ -943,7 +941,7 @@ yds_intr(void *p) N_PLAY_SLOT_CTRL_BANK, BUS_DMASYNC_POSTWRITE| BUS_DMASYNC_POSTREAD); - dma = sc->pbankp[nbank]->pgstart * sc->sc_play.factor; + dma = sc->pbankp[nbank]->pgstart; cpu = sc->sc_play.offset; blk = sc->sc_play.blksize; len = sc->sc_play.length; @@ -1106,47 +1104,11 @@ yds_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 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; - 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; - 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; - break; default: return (EINVAL); } @@ -1185,46 +1147,15 @@ yds_set_params(void *addr, int setmode, int usemode, if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = swap_bytes_change_sign16_le; - else - p->sw_code = change_sign16_swap_bytes_le; - } + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->precision = 16; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->precision = 16; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; break; default: return (EINVAL); @@ -1366,13 +1297,6 @@ yds_trigger_output(void *addr, void *start, void *end, int blksize, *sc->ptbl = channels; /* Num of play */ - sc->sc_play.factor = 1; - if (param->channels == 2) - sc->sc_play.factor *= 2; - if (param->precision != 8) - sc->sc_play.factor *= 2; - l /= sc->sc_play.factor; - psb = sc->pbankp[0]; memset(psb, 0, sizeof(*psb)); psb->format = ((channels == 2 ? PSLT_FORMAT_STEREO : 0) | @@ -1479,12 +1403,6 @@ yds_trigger_input(void *addr, void *start, void *end, int blksize, l = ((char *)end - (char *)start); sc->sc_rec.length = l; - sc->sc_rec.factor = 1; - if (param->channels == 2) - sc->sc_rec.factor *= 2; - if (param->precision != 8) - sc->sc_rec.factor *= 2; - rsb = &sc->rbank[0]; memset(rsb, 0, sizeof(*rsb)); rsb->pgbase = s; diff --git a/sys/dev/sbus/cs4231.c b/sys/dev/sbus/cs4231.c index e8d2cb1940c..5798650b135 100644 --- a/sys/dev/sbus/cs4231.c +++ b/sys/dev/sbus/cs4231.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4231.c,v 1.33 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: cs4231.c,v 1.34 2015/05/11 06:46:22 ratchov Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -50,7 +50,6 @@ #include #include -#include #include #include @@ -559,8 +558,6 @@ cs4231_set_params(void *vsc, int setmode, int usemode, { struct cs4231_softc *sc = (struct cs4231_softc *)vsc; int err, bits, enc = p->encoding; - void (*pswcode)(void *, u_char *, int cnt) = NULL; - void (*rswcode)(void *, u_char *, int cnt) = NULL; switch (enc) { case AUDIO_ENCODING_ULAW: @@ -574,10 +571,7 @@ cs4231_set_params(void *vsc, int setmode, int usemode, bits = FMT_ALAW >> 5; break; case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision == 8) { - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; - } else if (p->precision == 16) + if (p->precision == 16) bits = FMT_TWOS_COMP >> 5; else return (EINVAL); @@ -588,36 +582,21 @@ cs4231_set_params(void *vsc, int setmode, int usemode, bits = FMT_PCM8 >> 5; break; case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 8) { - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; - } else if (p->precision == 16) + if (p->precision == 16) bits = FMT_TWOS_COMP_BE >> 5; else return (EINVAL); break; - case AUDIO_ENCODING_SLINEAR: - if (p->precision != 8) - return (EINVAL); - bits = FMT_PCM8 >> 5; - pswcode = rswcode = change_sign8; - break; case AUDIO_ENCODING_ULINEAR_LE: if (p->precision == 8) bits = FMT_PCM8 >> 5; - else if (p->precision == 16) { - bits = FMT_TWOS_COMP >> 5; - pswcode = rswcode = change_sign16_le; - } else + else return (EINVAL); break; case AUDIO_ENCODING_ULINEAR_BE: if (p->precision == 8) bits = FMT_PCM8 >> 5; - else if (p->precision == 16) { - bits = FMT_TWOS_COMP_BE >> 5; - pswcode = rswcode = change_sign16_be; - } else + else return (EINVAL); break; case AUDIO_ENCODING_ADPCM: @@ -636,8 +615,6 @@ cs4231_set_params(void *vsc, int setmode, int usemode, if (err) return (err); - 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; diff --git a/sys/dev/sbus/files.sbus b/sys/dev/sbus/files.sbus index e5e767759ae..614a1840bcf 100644 --- a/sys/dev/sbus/files.sbus +++ b/sys/dev/sbus/files.sbus @@ -1,4 +1,4 @@ -# $OpenBSD: files.sbus,v 1.41 2014/03/15 21:49:47 kettenis Exp $ +# $OpenBSD: files.sbus,v 1.42 2015/05/11 06:46:22 ratchov Exp $ # $NetBSD: files.sbus,v 1.16 2000/12/08 17:29:12 martin Exp $ # # Config file and device description for machine-independent SBUS code. @@ -51,7 +51,7 @@ file dev/sbus/if_ti_sbus.c ti_sbus attach gem at sbus with gem_sbus file dev/sbus/if_gem_sbus.c gem_sbus -device audiocs: audio, auconv +device audiocs: audio attach audiocs at sbus file dev/sbus/cs4231.c audiocs diff --git a/sys/dev/tc/bba.c b/sys/dev/tc/bba.c index e1d0373c8cf..a5ab938d179 100644 --- a/sys/dev/tc/bba.c +++ b/sys/dev/tc/bba.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bba.c,v 1.4 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: bba.c,v 1.5 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: bba.c,v 1.38 2011/06/04 01:27:57 tsutsui Exp $ */ /* * Copyright (c) 2011 Miodrag Vallat. @@ -125,8 +125,6 @@ void bba_codec_iwrite(struct am7930_softc *, int, uint8_t); void bba_codec_iwrite16(struct am7930_softc *, int, uint16_t); void bba_onopen(struct am7930_softc *); void bba_onclose(struct am7930_softc *); -void bba_output_conv(void *, u_char *, int); -void bba_input_conv(void *, u_char *, int); struct am7930_glue bba_glue = { bba_codec_iread, @@ -135,9 +133,7 @@ struct am7930_glue bba_glue = { bba_codec_iwrite16, bba_onopen, bba_onclose, - 4, - bba_input_conv, - bba_output_conv + 24 }; /* @@ -634,78 +630,6 @@ bba_mappage(void *v, void *mem, off_t offset, int prot) prot, BUS_DMA_WAITOK); } -void -bba_input_conv(void *v, u_char *p, int cc) -{ - struct bba_softc *sc = v; - u_char *p0 = p; - int cc0 = cc; - uint32_t *q = (uint32_t *)p; - - DPRINTF(("bba_input_conv(): v=%p p=%p cc=%d\n", v, p, cc)); - - /* convert data from dma stream - one byte per longword<23:16> */ -#ifdef __alpha__ - /* try to avoid smaller than 32 bit accesses whenever possible */ - if (((vaddr_t)p & 3) == 0) { - while (cc >= 4) { - uint32_t fp; - - /* alpha is little endian */ - fp = (*q++ >> 16) & 0xff; - fp |= ((*q++ >> 16) & 0xff) << 8; - fp |= ((*q++ >> 16) & 0xff) << 16; - fp |= ((*q++ >> 16) & 0xff) << 24; - *(uint32_t *)p = fp; - p += 4; - cc -= 4; - } - } -#endif - while (--cc >= 0) - *p++ = (*q++ >> 16) & 0xff; - - /* convert mulaw data to expected encoding if necessary */ - if (sc->sc_am7930.rec_sw_code != NULL) - (*sc->sc_am7930.rec_sw_code)(v, p0, cc0); -} - -void -bba_output_conv(void *v, u_char *p, int cc) -{ - struct bba_softc *sc = v; - uint32_t *q = (uint32_t *)p; - - DPRINTF(("bba_output_conv(): v=%p p=%p cc=%d\n", v, p, cc)); - - /* convert data to mulaw first if necessary */ - if (sc->sc_am7930.play_sw_code != NULL) - (*sc->sc_am7930.play_sw_code)(v, p, cc); - - /* convert data to dma stream - one byte per longword<23:16> */ - p += cc; - q += cc; -#ifdef __alpha__ - /* try to avoid smaller than 32 bit accesses whenever possible */ - if (((vaddr_t)p & 3) == 0) { - while (cc >= 4) { - uint32_t fp; - - p -= 4; - fp = *(uint32_t *)p; - /* alpha is little endian */ - *--q = ((fp >> 24) & 0xff) << 16; - *--q = ((fp >> 16) & 0xff) << 16; - *--q = ((fp >> 8) & 0xff) << 16; - *--q = (fp & 0xff) << 16; - cc -= 4; - } - } -#endif - while (--cc >= 0) - *--q = *--p << 16; -} - int bba_round_blocksize(void *v, int blk) { diff --git a/sys/dev/tc/files.tc b/sys/dev/tc/files.tc index 10973b3b413..b47daf622e4 100644 --- a/sys/dev/tc/files.tc +++ b/sys/dev/tc/files.tc @@ -1,4 +1,4 @@ -# $OpenBSD: files.tc,v 1.12 2014/10/18 12:21:57 miod Exp $ +# $OpenBSD: files.tc,v 1.13 2015/05/11 06:46:22 ratchov Exp $ # $NetBSD: files.tc,v 1.26 2001/11/28 10:21:24 lukem Exp $ # # Config file and device description for machine-independent @@ -24,7 +24,7 @@ attach le at tc with le_tc: le24, le_dec_subr file dev/tc/if_le_tc.c le_tc # baseboard audio -device bba: audio, am7930, mulaw +device bba: audio, am7930 attach bba at ioasic file dev/tc/bba.c bba diff --git a/sys/dev/usb/files.usb b/sys/dev/usb/files.usb index 4cbbd8ff3df..a2a5fda5708 100644 --- a/sys/dev/usb/files.usb +++ b/sys/dev/usb/files.usb @@ -1,4 +1,4 @@ -# $OpenBSD: files.usb,v 1.123 2015/04/16 08:55:21 mpi Exp $ +# $OpenBSD: files.usb,v 1.124 2015/05/11 06:46:22 ratchov Exp $ # $NetBSD: files.usb,v 1.16 2000/02/14 20:29:54 augustss Exp $ # # Config file and device description for machine-independent USB code. @@ -26,7 +26,7 @@ attach uhub at uhub with uhub_uhub define ucombus {[portno = -1]} # Audio devices -device uaudio: audio, auconv, mulaw +device uaudio: audio attach uaudio at uhub file dev/usb/uaudio.c uaudio diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index fed8a681876..e23915a4157 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.110 2015/03/14 03:38:49 jsg Exp $ */ +/* $OpenBSD: uaudio.c,v 1.111 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: uaudio.c,v 1.90 2004/10/29 17:12:53 kent Exp $ */ /* @@ -52,7 +52,6 @@ #include #include -#include #include #include @@ -2355,8 +2354,6 @@ uaudio_get_default_params(void *addr, int mode, struct audio_params *p) p->bps = 2; p->msb = 1; p->channels = 2; - p->sw_code = NULL; - p->factor = 1; /* If the device doesn't support the current mode, there's no * need to find better parameters. @@ -3493,9 +3490,6 @@ uaudio_set_params(void *addr, int setmode, int usemode, continue; } - p->sw_code = NULL; - p->factor = 1; - p->bps = sc->sc_alts[i].asf1desc->bSubFrameSize; p->msb = 1; -- 2.20.1