-# $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
# 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
-/* $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)
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/rndvar.h>
#include <machine/cpu.h>
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;
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;
}
{
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);
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;
-/* $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$ */
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#if 0
#include <dev/ic/ym2203reg.h>
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]))
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,
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;
}
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;
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;
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*/
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;
}
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 =
(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;
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.
*/
}
}
-/*
- * 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.
*/
-# $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
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
-# $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
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
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
-/* $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 $ */
/*-
#include <sys/malloc.h>
#include <sys/systm.h>
-#include <dev/auconv.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
#include <machine/bus.h>
#include <machine/autoconf.h>
{
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);
}
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;
}
-/* $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 $ */
/*-
#include <sys/malloc.h>
#include <sys/systm.h>
-#include <dev/auconv.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
#include <dev/ofw/openfirm.h>
#include <macppc/dev/dbdma.h>
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 *);
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;
}
-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;
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);
}
-/* $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
{
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
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);
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)
error = mavb_set_rec_format(sc, rec->encoding);
if (error)
return (error);
-
- rec->bps = AUDIO_BPS(rec->precision);
- rec->msb = 0;
}
return (0);
-# $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
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
-# $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
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
-/* $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 $ */
/*
audioamd_codec_iread16,
audioamd_codec_iwrite16,
audioamd_onopen,
- audioamd_onclose
+ audioamd_onclose,
+ 8
};
/*
-/* $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)
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/ic/apcdmareg.h>
#include <dev/ic/ad1848reg.h>
#include <dev/ic/cs4231reg.h>
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;
{
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:
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)
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;
-# $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}
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
-/* $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)
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <sparc64/dev/ebusreg.h>
#include <sparc64/dev/ebusvar.h>
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;
{
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:
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;
-# $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
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
-/* $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.
vsaudio_codec_iread16,
vsaudio_codec_iwrite16,
vsaudio_onopen,
- vsaudio_onclose
+ vsaudio_onclose,
+ 8
};
/*
-# $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
#
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
-/* $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 <pascoe@openbsd.org>
#include <zaurus/dev/zaurus_scoopvar.h>
#include <dev/i2c/wm8750reg.h>
-
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#define WM8750_ADDRESS 0x1B
#define SPKR_VOLUME 112
{
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);
}
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;
#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;
-# $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
# filesystem firmware loading attribute
define firmload
-# audio device attributes
-define mulaw
-define auconv
-
# radio device attributes
define tea5757
define lm700x
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
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
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
+++ /dev/null
-/* $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 <sys/types.h>
-#include <dev/auconv.h>
-
-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);
-}
+++ /dev/null
-/* $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
-/* $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 $ */
/*
#include <sys/endian.h>
#include <dev/audio_if.h>
-
+#include <dev/mulaw.h>
#include <dev/rndvar.h>
#include "wskbd.h" /* NWSKBD (mixer tuning using keyboard) */
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.
*/
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;
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);
/* 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,
/*
* 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);
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;
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;
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;
}
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);
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;
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;
}
}
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);
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;
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));
}
}
*
* 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;
/*
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;
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;
* 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:
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);
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);
#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:
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)
{
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;
}
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;
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);
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);
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);
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;
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;
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;
-/* $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 $ */
/*
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 */
-/* $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
16, /* precision */
2, /* bps */
1, /* msb */
- 2, /* channels */
- NULL, /* sw_code */
- 1 /* factor */
+ 2 /* channels */
};
const struct audio_mixer_enum ac97_on_off = {
-/* $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 $ */
/*
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
#include <dev/ic/am7930reg.h>
#include <dev/ic/am7930var.h>
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;
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*/
-/* $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 $ */
/*
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 {
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;
-/* $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.
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
-#include <dev/mulaw.h>
#include <machine/autoconf.h>
#include <machine/bus.h>
{
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);
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;
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;
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;
-/* $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 $ */
/*
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
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);
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*/
{
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:
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;
-/* $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 $ */
/*
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
-#include <dev/mulaw.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
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;
}
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);
}
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;
}
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;
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;
-# $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.
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
# 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
# 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
-# $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.
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
-/* $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 $ */
/*-
#include <machine/cpufunc.h>
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
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);
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;
{
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*/
-/* $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.
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/midi_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
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;
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;
}
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;
}
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;
}
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));
}
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));
{
struct sbdsp_softc *sc = addr;
int stereo = param->channels == 2;
- int width = param->precision * param->factor;
+ int width = param->precision;
int filter;
int rc;
{
struct sbdsp_softc *sc = addr;
int stereo = param->channels == 2;
- int width = param->precision * param->factor;
+ int width = param->precision;
int cmd;
int rc;
-/* $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 $ */
/*
{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)
{
}
}
-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)
{
}
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++;
}
}
-/* $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 $ */
/*-
/* *_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);
-/* $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 $ */
/*-
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <machine/bus.h>
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);
}
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;
-/* $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 <mbalmer@openbsd.org>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
{
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;
}
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;
}
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;
-/* $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
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <machine/bus.h>
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);
}
}
}
}
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);
}
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;
-/* $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 $ */
/*
#include <dev/pci/pcivar.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
#include <dev/pci/auixpreg.h>
{
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);
}
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);
}
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);
-/* $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.
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/midi_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
#include <dev/ic/mpuvar.h>
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);
}
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);
-/* $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 $ */
/*-
#include <dev/pci/pcivar.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
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);
}
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;
}
}
- 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);
-/* $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 $ */
/*-
#include <sys/types.h>
#include <sys/timeout.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pcivar.h>
params->bps = 2;
params->msb = 1;
params->channels = 2;
- params->sw_code = NULL;
- params->factor = 1;
}
int
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;
}
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 */
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;
return EINVAL;
}
}
- par->sw_code = swcode;
par->bps = AUDIO_BPS(par->precision);
par->msb = 1;
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:
-/* $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 $ */
/*
#include <dev/audio_if.h>
#include <dev/midi_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/pci/cmpcireg.h>
#include <dev/pci/cmpcivar.h>
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;
}
params->bps = 2;
params->msb = 1;
params->channels = 2;
- params->sw_code = NULL;
- params->factor = 1;
}
int
/* format */
if (p->precision > 16)
p->precision = 16;
- p->sw_code = NULL;
switch (p->channels) {
case 1:
md_format = CMPCI_REG_FORMAT_MONO;
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);
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;
cmpci_set_in_ports(sc);
- chan->bps = param->channels * param->bps * param->factor;
+ chan->bps = param->channels * param->bps;
if (!chan->bps)
return EINVAL;
-/* $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 $ */
/*
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
{
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);
}
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);
}
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)
;
/* 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;
-/* $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 $ */
/*
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/midi_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
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;
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:
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);
}
/* 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)
;
}
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 */
/* 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;
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;
/* 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;
-/* $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 $ */
/*
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/midi_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
#include <machine/bus.h>
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);
}
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);
}
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++;
}
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++;
}
-/* $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 $ */
/*-
#include <dev/pci/pcidevs.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
-#include <dev/mulaw.h>
#include <dev/ic/ac97.h>
#include <dev/pci/emuxkireg.h>
#include <dev/pci/emuxkivar.h>
-#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 *);
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);
}
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)
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:
-/* $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 $ */
/*
#include <dev/pci/pcivar.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
#include <dev/pci/esareg.h>
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
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);
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;
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;
-/* $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 $ */
/*
#include <dev/audio_if.h>
#include <dev/midi_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
-
#include <dev/ic/mpuvar.h>
#include <dev/ic/i8237reg.h>
#include <dev/pci/esoreg.h>
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);
}
params->bps = 2;
params->msb = 1;
params->channels = 2;
- params->sw_code = NULL;
- params->factor = 1;
}
int
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);
}
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;
/* 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);
/* 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;
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
/* 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);
/* 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;
-# $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.
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
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
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
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
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
-/* $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 $ */
/*-
#include <dev/pci/pcivar.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
-
#include <dev/ic/ac97.h>
#if 0
#include <dev/ic/mpuvar.h>
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;
}
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;
;
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;
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);
}
-/* $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
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
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
else if (play->sample_rate > 48000)
play->sample_rate = 48000;
- play->factor = 1;
- play->sw_code = NULL;
if (play->channels > 2)
play->channels = 2;
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);
-/* $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 <gandalf@vilnya.demon.co.uk>
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
#include <dev/pci/neoreg.h>
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);
}
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);
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;
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;
-/* $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
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/i8237reg.h>
#include <dev/ic/s3_617.h>
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);
}
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);
}
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;
-/* $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 $ */
/*
#include <sys/audioio.h>
#include <dev/audio_if.h>
#include <dev/midi_if.h>
-#include <dev/mulaw.h>
-#include <dev/auconv.h>
#include <dev/ic/ac97.h>
#include <machine/bus.h>
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;
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);
}
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);
*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) |
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;
-/* $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)
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/auconv.h>
#include <dev/ic/ad1848reg.h>
#include <dev/ic/cs4231reg.h>
{
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:
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);
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:
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;
-# $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.
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
-/* $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.
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,
bba_codec_iwrite16,
bba_onopen,
bba_onclose,
- 4,
- bba_input_conv,
- bba_output_conv
+ 24
};
/*
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)
{
-# $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
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
-# $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.
define ucombus {[portno = -1]}
# Audio devices
-device uaudio: audio, auconv, mulaw
+device uaudio: audio
attach uaudio at uhub
file dev/usb/uaudio.c uaudio
-/* $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 $ */
/*
#include <sys/audioio.h>
#include <dev/audio_if.h>
-#include <dev/mulaw.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdevs.h>
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.
continue;
}
- p->sw_code = NULL;
- p->factor = 1;
-
p->bps = sc->sc_alts[i].asf1desc->bSubFrameSize;
p->msb = 1;