diff options
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/auacer.c | 119 | ||||
-rw-r--r-- | sys/dev/pci/auglx.c | 370 | ||||
-rw-r--r-- | sys/dev/pci/auich.c | 424 | ||||
-rw-r--r-- | sys/dev/pci/auixp.c | 241 | ||||
-rw-r--r-- | sys/dev/pci/autri.c | 52 | ||||
-rw-r--r-- | sys/dev/pci/auvia.c | 80 | ||||
-rw-r--r-- | sys/dev/pci/azalia.c | 42 | ||||
-rw-r--r-- | sys/dev/pci/cmpci.c | 122 | ||||
-rw-r--r-- | sys/dev/pci/cs4280.c | 92 | ||||
-rw-r--r-- | sys/dev/pci/cs4281.c | 52 | ||||
-rw-r--r-- | sys/dev/pci/eap.c | 84 | ||||
-rw-r--r-- | sys/dev/pci/emuxki.c | 99 | ||||
-rw-r--r-- | sys/dev/pci/esa.c | 62 | ||||
-rw-r--r-- | sys/dev/pci/eso.c | 73 | ||||
-rw-r--r-- | sys/dev/pci/files.pci | 38 | ||||
-rw-r--r-- | sys/dev/pci/fms.c | 99 | ||||
-rw-r--r-- | sys/dev/pci/maestro.c | 32 | ||||
-rw-r--r-- | sys/dev/pci/neo.c | 81 | ||||
-rw-r--r-- | sys/dev/pci/sv.c | 72 | ||||
-rw-r--r-- | sys/dev/pci/yds.c | 94 |
20 files changed, 166 insertions, 2162 deletions
diff --git a/sys/dev/pci/auacer.c b/sys/dev/pci/auacer.c index 7a9fd7e905e..57fd2ebf120 100644 --- a/sys/dev/pci/auacer.c +++ b/sys/dev/pci/auacer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auacer.c,v 1.17 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: auacer.c,v 1.18 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: auacer.c,v 1.3 2004/11/10 04:20:26 kent Exp $ */ /*- @@ -51,8 +51,6 @@ #include <sys/audioio.h> #include <dev/audio_if.h> -#include <dev/mulaw.h> -#include <dev/auconv.h> #include <machine/bus.h> @@ -449,53 +447,11 @@ auacer_query_encoding(void *v, struct audio_encoding *aep) switch (aep->index) { case 0: - strlcpy(aep->name, AudioEulinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; break; - case 5: - strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR_LE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR_BE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR_BE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -567,81 +523,12 @@ auacer_set_params(void *v, int setmode, int usemode, struct audio_params *play, continue; p->sample_rate = auacer_fixup_rate(p->sample_rate); - p->factor = 1; - if (p->precision == 8) - p->factor *= 2; - p->sw_code = NULL; - + p->precision = 16; + p->encoding = AUDIO_ENCODING_SLINEAR_LE; if (mode == AUMODE_RECORD) { if (p->channels > 2) p->channels = 2; } - - switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) { - p->sw_code = swap_bytes; - } else { - if (mode == AUMODE_PLAY) - p->sw_code = linear8_to_linear16_le; - else - p->sw_code = linear16_to_linear8_le; - } - break; - - case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision != 16) { - if (mode == AUMODE_PLAY) - p->sw_code = linear8_to_linear16_le; - else - p->sw_code = linear16_to_linear8_le; - } - break; - - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = - swap_bytes_change_sign16_le; - else - p->sw_code = - change_sign16_swap_bytes_le; - } else { - if (mode == AUMODE_PLAY) - p->sw_code = ulinear8_to_linear16_le; - else - p->sw_code = linear16_to_ulinear8_le; - } - break; - - case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) { - p->sw_code = change_sign16_le; - } else { - if (mode == AUMODE_PLAY) - p->sw_code = ulinear8_to_linear16_le; - else - p->sw_code = linear16_to_ulinear8_le; - } - break; - - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) - p->sw_code = mulaw_to_slinear16_le; - else - p->sw_code = slinear16_to_mulaw_le; - break; - - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) - p->sw_code = alaw_to_slinear16_le; - else - p->sw_code = slinear16_to_alaw_le; - break; - - default: - return (EINVAL); - } p->bps = AUDIO_BPS(p->precision); p->msb = 1; diff --git a/sys/dev/pci/auglx.c b/sys/dev/pci/auglx.c index 3b679f1e3e9..1e9b71cf337 100644 --- a/sys/dev/pci/auglx.c +++ b/sys/dev/pci/auglx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auglx.c,v 1.12 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: auglx.c,v 1.13 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2008 Marc Balmer <mbalmer@openbsd.org> @@ -51,8 +51,6 @@ #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> @@ -484,53 +482,11 @@ auglx_query_encoding(void *v, struct audio_encoding *aep) { switch (aep->index) { case 0: - strlcpy(aep->name, AudioEulinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; break; - case 5: - strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR_LE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR_BE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR_BE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return EINVAL; } @@ -550,175 +506,9 @@ auglx_set_params(void *v, int setmode, int usemode, struct audio_params *play, u_int orate; if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = NULL; - if (play->precision > 16) - play->precision = 16; - if (play->channels > 2) - play->channels = 2; - switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = mulaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_SLINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return EINVAL; - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = noswap_bytes_mts; - break; - case 2: - break; - default: - return EINVAL; - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return EINVAL; - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = change_sign16_le_mts; - break; - case 2: - play->sw_code = change_sign16_le; - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_ALAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = alaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return EINVAL; - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_mts; - break; - case 2: - play->sw_code = swap_bytes; - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return EINVAL; - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_change_sign16_le_mts; - break; - case 2: - play->sw_code = swap_bytes_change_sign16_le; - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } + play->precision = 16; + play->channels = 2; + play->encoding = AUDIO_ENCODING_SLINEAR_LE; play->bps = AUDIO_BPS(play->precision); play->msb = 1; @@ -744,155 +534,9 @@ auglx_set_params(void *v, int setmode, int usemode, struct audio_params *play, } if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = 0; - if (rec->precision > 16) - rec->precision = 16; - if (rec->channels > 2) - rec->channels = 2; - switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - switch (rec->channels) { - case 1: - rec->sw_code = slinear16_to_mulaw_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = slinear16_to_mulaw_le; - rec->factor = 2; - break; - } - break; - case AUDIO_ENCODING_ALAW: - switch (rec->channels) { - case 1: - rec->sw_code = slinear16_to_alaw_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = slinear16_to_alaw_le; - rec->factor = 2; - break; - } - break; - case AUDIO_ENCODING_SLINEAR_LE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_linear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_linear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_decimator; - rec->factor = 2; - break; - case 2: - break; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_ulinear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_ulinear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = change_sign16_le_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = change_sign16_le; - break; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_linear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_linear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = swap_bytes_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = swap_bytes; - break; - } - break; - default: - return EINVAL; - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_ulinear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_ulinear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = change_sign16_swap_bytes_le_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = change_sign16_swap_bytes_le; - break; - } - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } + rec->precision = 16; + rec->channels = 2; + rec->encoding = AUDIO_ENCODING_ULINEAR_LE; rec->bps = AUDIO_BPS(rec->precision); rec->msb = 1; diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c index 94adc5a3b71..c22915c169a 100644 --- a/sys/dev/pci/auich.c +++ b/sys/dev/pci/auich.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auich.c,v 1.103 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: auich.c,v 1.104 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2000,2001 Michael Shalayeff @@ -44,8 +44,6 @@ #include <sys/audioio.h> #include <dev/audio_if.h> -#include <dev/mulaw.h> -#include <dev/auconv.h> #include <machine/bus.h> @@ -686,76 +684,17 @@ auich_get_default_params(void *addr, int mode, struct audio_params *params) int auich_query_encoding(void *v, struct audio_encoding *aep) { - struct auich_softc *sc = v; - if (sc->sc_spdif) { - switch (aep->index) { - case 0: - strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR_LE; - aep->precision = 16; - aep->flags = 0; - aep->bps = 2; - aep->msb = 1; - return (0); - default: - return (EINVAL); - } - } else { - switch (aep->index) { - case 0: - strlcpy(aep->name, AudioEulinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = 0; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: - strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR_LE; - aep->precision = 16; - aep->flags = 0; - break; - case 5: - strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR_LE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR_BE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR_BE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - default: - return (EINVAL); - } - aep->bps = AUDIO_BPS(aep->precision); + switch (aep->index) { + case 0: + strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); + aep->encoding = AUDIO_ENCODING_SLINEAR_LE; + aep->precision = 16; + aep->flags = 0; + aep->bps = 2; aep->msb = 1; return (0); + default: + return (EINVAL); } } @@ -780,190 +719,29 @@ auich_set_params(void *v, int setmode, int usemode, } } if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = NULL; - if (play->precision > 16) - play->precision = 16; + play->precision = 16; switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - if (play->channels > 2) - play->channels = 2; - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = mulaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; case AUDIO_ENCODING_SLINEAR_LE: - switch (play->precision) { - case 8: - if (play->channels > 2) - play->channels = 2; - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - if (play->channels > 6) - play->channels = 6; - if (play->channels > 1) - play->channels &= ~1; - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = noswap_bytes_mts; - break; - case 2: - break; - case 4: - ext_id = codec->vtbl->get_caps(codec); - if (!(ext_id & AC97_EXT_AUDIO_SDAC)) - play->channels = 2; - break; - case 6: - ext_id = codec->vtbl->get_caps(codec); - if ((ext_id & AC97_BITS_6CH) != - AC97_BITS_6CH) - play->channels = 2; - break; - default: - return (EINVAL); - } - break; - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - if (play->channels > 2) - play->channels = 2; - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = change_sign16_le_mts; - break; - case 2: - play->sw_code = change_sign16_le; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ALAW: - if (play->channels > 2) - play->channels = 2; + if (play->channels > 6) + play->channels = 6; + if (play->channels > 1) + play->channels &= ~1; switch (play->channels) { case 1: - play->factor = 4; - play->sw_code = alaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (play->channels > 2) play->channels = 2; - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_mts; - break; - case 2: - play->sw_code = swap_bytes; - break; - default: - return (EINVAL); - } + case 2: break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (play->channels > 2) - play->channels = 2; - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } + case 4: + ext_id = codec->vtbl->get_caps(codec); + if (!(ext_id & AC97_EXT_AUDIO_SDAC)) + play->channels = 2; break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_change_sign16_le_mts; - break; - case 2: - play->sw_code = swap_bytes_change_sign16_le; - break; - default: - return (EINVAL); - } + case 6: + ext_id = codec->vtbl->get_caps(codec); + if ((ext_id & AC97_BITS_6CH) != + AC97_BITS_6CH) + play->channels = 2; break; default: return (EINVAL); @@ -1014,155 +792,9 @@ auich_set_params(void *v, int setmode, int usemode, } if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = 0; - if (rec->channels > 2) - rec->channels = 2; - if (rec->precision > 16) - rec->precision = 16; - switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - switch (rec->channels) { - case 1: - rec->sw_code = slinear16_to_mulaw_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = slinear16_to_mulaw_le; - rec->factor = 2; - break; - } - break; - case AUDIO_ENCODING_ALAW: - switch (rec->channels) { - case 1: - rec->sw_code = slinear16_to_alaw_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = slinear16_to_alaw_le; - rec->factor = 2; - break; - } - break; - case AUDIO_ENCODING_SLINEAR_LE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_linear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_linear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_decimator; - rec->factor = 2; - break; - case 2: - break; - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_ulinear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_ulinear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = change_sign16_le_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = change_sign16_le; - break; - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_linear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_linear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = swap_bytes_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = swap_bytes; - break; - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (rec->precision) { - case 8: - switch (rec->channels) { - case 1: - rec->sw_code = linear16_to_ulinear8_le_stm; - rec->factor = 4; - break; - case 2: - rec->sw_code = linear16_to_ulinear8_le; - rec->factor = 2; - break; - } - break; - case 16: - switch (rec->channels) { - case 1: - rec->sw_code = change_sign16_swap_bytes_le_stm; - rec->factor = 2; - break; - case 2: - rec->sw_code = change_sign16_swap_bytes_le; - break; - } - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } + rec->channels = 2; + rec->precision = 16; + rec->encoding = AUDIO_ENCODING_SLINEAR_LE; rec->bps = AUDIO_BPS(rec->precision); rec->msb = 1; diff --git a/sys/dev/pci/auixp.c b/sys/dev/pci/auixp.c index 1291bfdb8fc..299d260e4c8 100644 --- a/sys/dev/pci/auixp.c +++ b/sys/dev/pci/auixp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auixp.c,v 1.34 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: auixp.c,v 1.35 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: auixp.c,v 1.9 2005/06/27 21:13:09 thorpej Exp $ */ /* @@ -68,8 +68,6 @@ #include <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> @@ -222,53 +220,11 @@ auixp_query_encoding(void *hdl, struct audio_encoding *aep) { switch (aep->index) { case 0: - strlcpy(aep->name, AudioEulinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: - strlcpy(aep->name, AudioEmulaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(aep->name, AudioEalaw, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ALAW; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(aep->name, AudioEslinear, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR; - aep->precision = 8; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(aep->name, AudioEslinear_le, sizeof aep->name); aep->encoding = AUDIO_ENCODING_SLINEAR_LE; aep->precision = 16; aep->flags = 0; break; - case 5: - strlcpy(aep->name, AudioEulinear_le, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR_LE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(aep->name, AudioEslinear_be, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_SLINEAR_BE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(aep->name, AudioEulinear_be, sizeof aep->name); - aep->encoding = AUDIO_ENCODING_ULINEAR_BE; - aep->precision = 16; - aep->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -373,171 +329,10 @@ auixp_set_params(void *hdl, int setmode, int usemode, co = (struct auixp_codec *) hdl; if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = NULL; - if (play->channels > 2) - play->channels = 2; - if (play->precision > 16) - play->precision = 16; + play->channels = 2; + play->precision = 16; switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = mulaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; case AUDIO_ENCODING_SLINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = noswap_bytes_mts; - break; - case 2: - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = change_sign16_le_mts; - break; - case 2: - play->sw_code = change_sign16_le; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ALAW: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = alaw_to_slinear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = linear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = linear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_mts; - break; - case 2: - play->sw_code = swap_bytes; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - switch (play->precision) { - case 8: - switch (play->channels) { - case 1: - play->factor = 4; - play->sw_code = ulinear8_to_linear16_le_mts; - break; - case 2: - play->factor = 2; - play->sw_code = ulinear8_to_linear16_le; - break; - default: - return (EINVAL); - } - break; - case 16: - switch (play->channels) { - case 1: - play->factor = 2; - play->sw_code = swap_bytes_change_sign16_le_mts; - break; - case 2: - play->sw_code = swap_bytes_change_sign16_le; - break; - default: - return (EINVAL); - } - break; - default: - return (EINVAL); - } break; default: return (EINVAL); @@ -566,36 +361,10 @@ auixp_set_params(void *hdl, int setmode, int usemode, } if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = 0; - if (rec->channels > 2) - rec->channels = 2; - if (rec->precision > 16) - rec->precision = 16; + rec->channels = 2; + rec->precision = 16; switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - rec->sw_code = ulinear8_to_mulaw; - break; case AUDIO_ENCODING_SLINEAR_LE: - if (rec->precision == 8) - rec->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_LE: - if (rec->precision == 16) - rec->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ALAW: - rec->sw_code = ulinear8_to_alaw; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes; - else - rec->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes_change_sign16_le; break; default: return (EINVAL); diff --git a/sys/dev/pci/autri.c b/sys/dev/pci/autri.c index 50d11713885..1ba41523840 100644 --- a/sys/dev/pci/autri.c +++ b/sys/dev/pci/autri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autri.c,v 1.36 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: autri.c,v 1.37 2015/05/11 06:46:21 ratchov Exp $ */ /* * Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro. @@ -50,8 +50,6 @@ #include <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> @@ -912,47 +910,23 @@ autri_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; - case 4: + case 2: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: + case 3: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -983,31 +957,15 @@ autri_set_params(void *addr, int setmode, int usemode, struct audio_params *play p->precision = 16; if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_BE: case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; + if (p->precision != 16) + return EINVAL; break; case AUDIO_ENCODING_SLINEAR_LE: case AUDIO_ENCODING_ULINEAR_LE: break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) - p->sw_code = mulaw_to_ulinear8; - else - p->sw_code = ulinear8_to_mulaw; - - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) - p->sw_code = alaw_to_ulinear8; - else - p->sw_code = ulinear8_to_alaw; - - break; default: return (EINVAL); } diff --git a/sys/dev/pci/auvia.c b/sys/dev/pci/auvia.c index aed047d83dc..a68db8c2c89 100644 --- a/sys/dev/pci/auvia.c +++ b/sys/dev/pci/auvia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auvia.c,v 1.54 2015/05/07 01:55:43 jsg Exp $ */ +/* $OpenBSD: auvia.c,v 1.55 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: auvia.c,v 1.28 2002/11/04 16:38:49 kent Exp $ */ /*- @@ -48,8 +48,6 @@ #include <dev/pci/pcivar.h> #include <dev/audio_if.h> -#include <dev/mulaw.h> -#include <dev/auconv.h> #include <dev/ic/ac97.h> @@ -543,47 +541,11 @@ auvia_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -603,7 +565,7 @@ auvia_set_params_sub(struct auvia_softc *sc, struct auvia_softc_chan *ch, if (!(sc->sc_flags & AUVIA_FLAGS_VT8233)) { regval = (p->channels == 2 ? AUVIA_RPMODE_STEREO : 0) - | (p->precision * p->factor == 16 ? + | (p->precision == 16 ? AUVIA_RPMODE_16BIT : 0) | AUVIA_RPMODE_INTR_FLAG | AUVIA_RPMODE_INTR_EOL | AUVIA_RPMODE_AUTOSTART; @@ -728,45 +690,15 @@ auvia_set_params(void *addr, int setmode, int usemode, } } - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) - p->sw_code = mode == AUMODE_PLAY? - swap_bytes_change_sign16_le : - change_sign16_swap_bytes_le; + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; - break; - case AUDIO_ENCODING_SLINEAR: - case AUDIO_ENCODING_ULINEAR: + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; break; default: return (EINVAL); diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index b126ef615b3..3fba10ecd0f 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.220 2015/02/10 06:19:44 dlg Exp $ */ +/* $OpenBSD: azalia.c,v 1.221 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -47,7 +47,6 @@ #include <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> @@ -3910,8 +3909,6 @@ azalia_get_default_params(void *addr, int mode, struct audio_params *params) params->bps = 2; params->msb = 1; params->channels = 2; - params->sw_code = NULL; - params->factor = 1; } int @@ -3944,7 +3941,6 @@ azalia_match_format(codec_t *codec, int mode, audio_params_t *par) int azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) { - void (*swcode)(void *, u_char *, int) = NULL; char *cmode; int i, j; uint ochan, oenc, opre; @@ -3965,20 +3961,6 @@ azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) } i = azalia_match_format(codec, mode, par); - if (i == codec->nformats && par->channels == 1) { - /* find a 2 channel format and emulate mono */ - par->channels = 2; - i = azalia_match_format(codec, mode, par); - if (i != codec->nformats) { - par->factor = 2; - if (mode == AUMODE_RECORD) - swcode = linear16_decimator; - else - swcode = noswap_bytes_mts; - par->channels = 1; - } - } - par->channels = ochan; if (i == codec->nformats && (par->precision != 16 || par->encoding != AUDIO_ENCODING_SLINEAR_LE)) { /* try with default encoding/precision */ @@ -3986,20 +3968,6 @@ azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) par->precision = 16; i = azalia_match_format(codec, mode, par); } - if (i == codec->nformats && par->channels == 1) { - /* find a 2 channel format and emulate mono */ - par->channels = 2; - i = azalia_match_format(codec, mode, par); - if (i != codec->nformats) { - par->factor = 2; - if (mode == AUMODE_RECORD) - swcode = linear16_decimator; - else - swcode = noswap_bytes_mts; - par->channels = 1; - } - } - par->channels = ochan; if (i == codec->nformats && par->channels != 2) { /* try with default channels */ par->encoding = oenc; @@ -4045,7 +4013,6 @@ azalia_set_params_sub(codec_t *codec, int mode, audio_params_t *par) return EINVAL; } } - par->sw_code = swcode; par->bps = AUDIO_BPS(par->precision); par->msb = 1; @@ -4328,11 +4295,8 @@ azalia_params2fmt(const audio_params_t *param, uint16_t *fmt) DPRINTFN(1, ("%s: prec=%d, chan=%d, rate=%ld\n", __func__, param->precision, param->channels, param->sample_rate)); - /* Only mono is emulated, and it is emulated from stereo. */ - if (param->sw_code != NULL) - ret |= 1; - else - ret |= param->channels - 1; + /* XXX: can channels be >2 ? */ + ret |= param->channels - 1; switch (param->precision) { case 8: diff --git a/sys/dev/pci/cmpci.c b/sys/dev/pci/cmpci.c index cb84442f414..d4e4d9940ad 100644 --- a/sys/dev/pci/cmpci.c +++ b/sys/dev/pci/cmpci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmpci.c,v 1.38 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: cmpci.c,v 1.39 2015/05/11 06:46:21 ratchov Exp $ */ /* $NetBSD: cmpci.c,v 1.25 2004/10/26 06:32:20 xtraeme Exp $ */ /* @@ -62,8 +62,6 @@ int cmpcidebug = 0; #include <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> @@ -654,47 +652,11 @@ cmpci_query_encoding(void *handle, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return EINVAL; } @@ -713,8 +675,6 @@ cmpci_get_default_params(void *addr, int mode, struct audio_params *params) params->bps = 2; params->msb = 1; params->channels = 2; - params->sw_code = NULL; - params->factor = 1; } int @@ -778,7 +738,6 @@ cmpci_set_params(void *handle, int setmode, int usemode, /* format */ if (p->precision > 16) p->precision = 16; - p->sw_code = NULL; switch (p->channels) { case 1: md_format = CMPCI_REG_FORMAT_MONO; @@ -851,83 +810,16 @@ cmpci_set_params(void *handle, int setmode, int usemode, return (EINVAL); } switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - if (mode & AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - md_format |= CMPCI_REG_FORMAT_16BIT; - } else { - p->sw_code = ulinear8_to_mulaw; - md_format |= CMPCI_REG_FORMAT_8BIT; - } - break; - case AUDIO_ENCODING_ALAW: - if (mode & AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - md_format |= CMPCI_REG_FORMAT_16BIT; - } else { - p->sw_code = ulinear8_to_alaw; - md_format |= CMPCI_REG_FORMAT_8BIT; - } - break; case AUDIO_ENCODING_SLINEAR_LE: - switch (p->precision) { - case 8: - p->sw_code = change_sign8; - md_format |= CMPCI_REG_FORMAT_8BIT; - break; - case 16: - md_format |= CMPCI_REG_FORMAT_16BIT; - break; - default: - return (EINVAL); - } - break; - case AUDIO_ENCODING_SLINEAR_BE: - switch (p->precision) { - case 8: - md_format |= CMPCI_REG_FORMAT_8BIT; - p->sw_code = change_sign8; - break; - case 16: - md_format |= CMPCI_REG_FORMAT_16BIT; - p->sw_code = swap_bytes; - break; - default: + if (p->precision != 16) return (EINVAL); - } + md_format |= CMPCI_REG_FORMAT_16BIT; break; case AUDIO_ENCODING_ULINEAR_LE: - switch (p->precision) { - case 8: - md_format |= CMPCI_REG_FORMAT_8BIT; - break; - case 16: - md_format |= CMPCI_REG_FORMAT_16BIT; - p->sw_code = change_sign16_le; - break; - default: - return (EINVAL); - } - break; case AUDIO_ENCODING_ULINEAR_BE: - switch (p->precision) { - case 8: - md_format |= CMPCI_REG_FORMAT_8BIT; - break; - case 16: - md_format |= CMPCI_REG_FORMAT_16BIT; - if (mode & AUMODE_PLAY) - p->sw_code = - swap_bytes_change_sign16_le; - else - p->sw_code = - change_sign16_swap_bytes_le; - break; - default: + if (p->precision != 8) return (EINVAL); - } + md_format |= CMPCI_REG_FORMAT_8BIT; break; default: return (EINVAL); @@ -2015,7 +1907,7 @@ cmpci_trigger_output(void *handle, void *start, void *end, int blksize, reg_enable = CMPCI_REG_CH0_ENABLE; } - chan->bps = (param->channels > 1 ? 2 : 1) * param->bps * param->factor; + chan->bps = (param->channels > 1 ? 2 : 1) * param->bps; if (!chan->bps) return EINVAL; @@ -2060,7 +1952,7 @@ cmpci_trigger_input(void *handle, void *start, void *end, int blksize, cmpci_set_in_ports(sc); - chan->bps = param->channels * param->bps * param->factor; + chan->bps = param->channels * param->bps; if (!chan->bps) return EINVAL; diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 266079dca8f..8a4cf871614 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4280.c,v 1.46 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: cs4280.c,v 1.47 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */ /* @@ -78,8 +78,6 @@ int cs4280debug = 0; #include <sys/audioio.h> #include <dev/audio_if.h> -#include <dev/mulaw.h> -#include <dev/auconv.h> #include <dev/ic/ac97.h> @@ -1020,53 +1018,11 @@ cs4280_query_encoding(void *addr, struct audio_encoding *fp) { switch (fp->index) { case 0: - strlcpy(fp->name, AudioEulinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR; - fp->precision = 8; - fp->flags = 0; - break; - case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = 0; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = 0; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = 0; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = 0; - break; default: return (EINVAL); } @@ -1116,51 +1072,11 @@ cs4280_set_params(void *addr, int setmode, int usemode, p->precision = 16; if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; /* capturing data is slinear */ switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (mode == AUMODE_RECORD) { - if (p->precision == 16) - p->sw_code = swap_bytes; - } - break; case AUDIO_ENCODING_SLINEAR_LE: break; - case AUDIO_ENCODING_ULINEAR_BE: - if (mode == AUMODE_RECORD) { - if (p->precision == 16) - p->sw_code = change_sign16_swap_bytes_le; - else - p->sw_code = change_sign8; - } - break; - case AUDIO_ENCODING_ULINEAR_LE: - if (mode == AUMODE_RECORD) { - if (p->precision == 16) - p->sw_code = change_sign16_le; - else - p->sw_code = change_sign8; - } - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else { - p->sw_code = slinear8_to_mulaw; - } - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else { - p->sw_code = slinear8_to_alaw; - } - break; default: return (EINVAL); } @@ -1445,8 +1361,8 @@ cs4280_trigger_output(void *addr, void *start, void *end, int blksize, pdtc |= CS4280_MK_PDTC(param->precision * param->channels); BA1WRITE4(sc, CS4280_PDTC, pdtc); - DPRINTF(("param: precision=%d factor=%d channels=%d encoding=%d\n", - param->precision, param->factor, param->channels, + DPRINTF(("param: precision=%d channels=%d encoding=%d\n", + param->precision, param->channels, param->encoding)); for (p = sc->sc_dmas; p != NULL && BUFADDR(p) != start; p = p->next) ; @@ -1483,7 +1399,7 @@ cs4280_trigger_output(void *addr, void *start, void *end, int blksize, /* set PFIE */ pfie = BA1READ4(sc, CS4280_PFIE) & ~PFIE_MASK; - if (param->precision * param->factor == 8) + if (param->precision == 8) pfie |= PFIE_8BIT; if (param->channels == 1) pfie |= PFIE_MONO; diff --git a/sys/dev/pci/cs4281.c b/sys/dev/pci/cs4281.c index a78944334fe..0d2b8cd9a7e 100644 --- a/sys/dev/pci/cs4281.c +++ b/sys/dev/pci/cs4281.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4281.c,v 1.31 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: cs4281.c,v 1.32 2015/05/11 06:46:22 ratchov Exp $ */ /* $Tera: cs4281.c,v 1.18 2000/12/27 14:24:45 tacha Exp $ */ /* @@ -55,8 +55,6 @@ #include <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> @@ -448,42 +446,30 @@ cs4281_query_encoding(addr, fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; - case 4: + case 2: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: + case 3: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 6: + case 4: strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_BE; fp->precision = 16; fp->flags = 0; break; - case 7: + case 5: strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_BE; fp->precision = 16; @@ -530,8 +516,6 @@ cs4281_set_params(addr, setmode, usemode, play, rec) p->precision = 16; if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_BE: @@ -542,20 +526,6 @@ cs4281_set_params(addr, setmode, usemode, play, rec) break; case AUDIO_ENCODING_ULINEAR_LE: break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->sw_code = mulaw_to_slinear8; - } else { - p->sw_code = slinear8_to_mulaw; - } - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->sw_code = alaw_to_slinear8; - } else { - p->sw_code = slinear8_to_alaw; - } - break; default: return (EINVAL); } @@ -634,8 +604,8 @@ cs4281_trigger_output(addr, start, end, blksize, intr, arg, param) /* stop playback DMA */ BA0WRITE4(sc, CS4281_DCR0, BA0READ4(sc, CS4281_DCR0) | DCRn_MSK); - DPRINTF(("param: precision=%d factor=%d channels=%d encoding=%d\n", - param->precision, param->factor, param->channels, + DPRINTF(("param: precision=%d channels=%d encoding=%d\n", + param->precision, param->channels, param->encoding)); for (p = sc->sc_dmas; p != NULL && BUFADDR(p) != start; p = p->next) ; @@ -662,7 +632,7 @@ cs4281_trigger_output(addr, start, end, blksize, intr, arg, param) } dma_count = sc->dma_size; - if (param->precision * param->factor != 8) + if (param->precision != 8) dma_count /= 2; /* 16 bit */ if (param->channels > 1) dma_count /= 2; /* Stereo */ @@ -674,7 +644,7 @@ cs4281_trigger_output(addr, start, end, blksize, intr, arg, param) /* set playback format */ fmt = BA0READ4(sc, CS4281_DMR0) & ~DMRn_FMTMSK; - if (param->precision * param->factor == 8) + if (param->precision == 8) fmt |= DMRn_SIZE8; if (param->channels == 1) fmt |= DMRn_MONO; @@ -756,7 +726,7 @@ cs4281_trigger_input(addr, start, end, blksize, intr, arg, param) sc->sc_rn = sc->sc_rs; dma_count = sc->dma_size; - if (param->precision * param->factor == 8) + if (param->precision == 8) dma_count /= 2; if (param->channels > 1) dma_count /= 2; @@ -768,7 +738,7 @@ cs4281_trigger_input(addr, start, end, blksize, intr, arg, param) /* set recording format */ fmt = BA0READ4(sc, CS4281_DMR1) & ~DMRn_FMTMSK; - if (param->precision * param->factor == 8) + if (param->precision == 8) fmt |= DMRn_SIZE8; if (param->channels == 1) fmt |= DMRn_MONO; diff --git a/sys/dev/pci/eap.c b/sys/dev/pci/eap.c index 1c77404505b..872e674ff41 100644 --- a/sys/dev/pci/eap.c +++ b/sys/dev/pci/eap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eap.c,v 1.50 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: eap.c,v 1.51 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: eap.c,v 1.46 2001/09/03 15:07:37 reinoud Exp $ */ /* @@ -61,8 +61,6 @@ #include <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> @@ -875,47 +873,11 @@ eap_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -974,45 +936,15 @@ eap_set_params(void *addr, int setmode, int usemode, p->precision = 16; if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = swap_bytes_change_sign16_le; - else - p->sw_code = change_sign16_swap_bytes_le; - } + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; - break; + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; default: return (EINVAL); } @@ -1079,9 +1011,9 @@ eap_trigger_output( mtx_enter(&audio_lock); sic = EREAD4(sc, EAP_SIC); sic &= ~(EAP_P2_S_EB | EAP_P2_S_MB | EAP_INC_BITS); - sic |= EAP_SET_P2_ST_INC(0) | EAP_SET_P2_END_INC(param->precision * param->factor / 8); + sic |= EAP_SET_P2_ST_INC(0) | EAP_SET_P2_END_INC(param->precision / 8); sampshift = 0; - if (param->precision * param->factor == 16) { + if (param->precision == 16) { sic |= EAP_P2_S_EB; sampshift++; } @@ -1150,7 +1082,7 @@ eap_trigger_input( sic = EREAD4(sc, EAP_SIC); sic &= ~(EAP_R1_S_EB | EAP_R1_S_MB); sampshift = 0; - if (param->precision * param->factor == 16) { + if (param->precision == 16) { sic |= EAP_R1_S_EB; sampshift++; } diff --git a/sys/dev/pci/emuxki.c b/sys/dev/pci/emuxki.c index 63cc9235f6c..3abce7857e3 100644 --- a/sys/dev/pci/emuxki.c +++ b/sys/dev/pci/emuxki.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emuxki.c,v 1.47 2015/03/14 03:38:48 jsg Exp $ */ +/* $OpenBSD: emuxki.c,v 1.48 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: emuxki.c,v 1.1 2001/10/17 18:39:41 jdolecek Exp $ */ /*- @@ -63,15 +63,11 @@ #include <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 *); @@ -2098,47 +2094,11 @@ emuxki_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -2155,8 +2115,6 @@ emuxki_set_vparms(struct emuxki_voice *voice, struct audio_params *p) mode = (voice->use & EMU_VOICE_USE_PLAY) ? AUMODE_PLAY : AUMODE_RECORD; - p->factor = 1; - p->sw_code = NULL; if (p->channels > 2) p->channels = 2; if (p->precision > 16) @@ -2171,64 +2129,19 @@ emuxki_set_vparms(struct emuxki_voice *voice, struct audio_params *p) b16 = (p->precision == 16); else { b16 = 1; - if (p->precision == 8) - p->factor *= 2; + p->precision = 16; } switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - b16 = 1; - } else - p->sw_code = slinear16_to_mulaw_le; - break; - - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - b16 = 1; - } else - p->sw_code = slinear16_to_alaw_le; - break; - case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision == 8) { - if (mode == AUMODE_PLAY) - p->sw_code = change_sign8; - else - p->sw_code = linear16_to_linear8_le; - } + if (p->precision != 16) + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - else if (mode == AUMODE_RECORD) - p->sw_code = slinear16_to_ulinear8_le; - break; - - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else { - if (mode == AUMODE_PLAY) - p->sw_code = change_sign8; - else - p->sw_code = linear16_to_linear8_le; - } - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = swap_bytes_change_sign16_le; - else - p->sw_code = change_sign16_swap_bytes_le; - } else if (mode == AUMODE_RECORD) - p->sw_code = slinear16_to_ulinear8_le; + if (p->precision != 8) + return EINVAL; break; default: diff --git a/sys/dev/pci/esa.c b/sys/dev/pci/esa.c index 0c590636bee..0dc5db2bbed 100644 --- a/sys/dev/pci/esa.c +++ b/sys/dev/pci/esa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esa.c,v 1.28 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: esa.c,v 1.29 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: esa.c,v 1.12 2002/03/24 14:17:35 jmcneill Exp $ */ /* @@ -61,8 +61,6 @@ #include <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> @@ -166,19 +164,7 @@ int esa_resume(struct esa_softc *); static audio_encoding_t esa_encoding[] = { { 0, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 1, 1, 0 }, - { 1, AudioEmulaw, AUDIO_ENCODING_ULAW, 8, 1, 1, - AUDIO_ENCODINGFLAG_EMULATED }, - { 2, AudioEalaw, AUDIO_ENCODING_ALAW, 8, 1, 1, - AUDIO_ENCODINGFLAG_EMULATED }, - { 3, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, 1, 1, - AUDIO_ENCODINGFLAG_EMULATED }, - { 4, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 2, 1, 0 }, - { 5, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16, 2, 1, - AUDIO_ENCODINGFLAG_EMULATED }, - { 6, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16, 2, 1, - AUDIO_ENCODINGFLAG_EMULATED }, - { 7, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16, 2, 1, - AUDIO_ENCODINGFLAG_EMULATED } + { 1, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 2, 1, 0 } }; #define ESA_NENCODINGS 8 @@ -292,47 +278,15 @@ esa_set_params(void *hdl, int setmode, int usemode, struct audio_params *play, if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; - switch(p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = - swap_bytes_change_sign16_le; - else - p->sw_code = - change_sign16_swap_bytes_le; - } + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; break; default: return (EINVAL); @@ -369,7 +323,7 @@ esa_commit_settings(void *hdl) esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_DATA, vc->play.data_offset + ESA_SRC3_MODE_OFFSET, data); - if (p->precision * p->factor == 8) + if (p->precision == 8) data = 1; else data = 0; @@ -392,7 +346,7 @@ esa_commit_settings(void *hdl) esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_DATA, vc->rec.data_offset + ESA_SRC3_MODE_OFFSET, data); - if (r->precision * r->factor == 8) + if (r->precision == 8) data = 1; else data = 0; diff --git a/sys/dev/pci/eso.c b/sys/dev/pci/eso.c index cf78cb92cb7..73aa1b2a3cf 100644 --- a/sys/dev/pci/eso.c +++ b/sys/dev/pci/eso.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eso.c,v 1.39 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: eso.c,v 1.40 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: eso.c,v 1.48 2006/12/18 23:13:39 kleink Exp $ */ /* @@ -46,9 +46,6 @@ #include <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> @@ -672,47 +669,23 @@ eso_query_encoding(void *hdl, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: strlcpy(fp->name, AudioEslinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR; fp->precision = 8; fp->flags = 0; break; - case 4: + case 2: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: + case 3: strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -731,8 +704,6 @@ eso_get_default_params(void *addr, int mode, struct audio_params *params) params->bps = 2; params->msb = 1; params->channels = 2; - params->sw_code = NULL; - params->factor = 1; } int @@ -760,33 +731,15 @@ eso_set_params(void *hdl, int setmode, int usemode, if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = NULL; switch (p->encoding) { case AUDIO_ENCODING_SLINEAR_BE: case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; + if (p->precision != 8) + return EINVAL; break; case AUDIO_ENCODING_SLINEAR_LE: case AUDIO_ENCODING_ULINEAR_LE: break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_ulinear16_le; - } else { - p->sw_code = ulinear8_to_mulaw; - } - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_ulinear16_le; - } else { - p->sw_code = ulinear8_to_alaw; - } - break; default: return (EINVAL); } @@ -1726,9 +1679,9 @@ eso_trigger_output(void *hdl, void *start, void *end, int blksize, DPRINTF(( "%s: trigger_output: start %p, end %p, blksize %d, intr %p(%p)\n", sc->sc_dev.dv_xname, start, end, blksize, intr, arg)); - DPRINTF(("%s: param: rate %lu, encoding %u, precision %u, channels %u, sw_code %p, factor %d\n", + DPRINTF(("%s: param: rate %lu, encoding %u, precision %u, channels %u\n", sc->sc_dev.dv_xname, param->sample_rate, param->encoding, - param->precision, param->channels, param->sw_code, param->factor)); + param->precision, param->channels)); /* Find DMA buffer. */ for (ed = sc->sc_dmas; ed != NULL && KVADDR(ed) != start; @@ -1747,7 +1700,7 @@ eso_trigger_output(void *hdl, void *start, void *end, int blksize, /* Compute drain timeout. */ sc->sc_pdrain = hz * (blksize * 3 / 2) / - (param->sample_rate * param->channels * param->bps * param->factor); + (param->sample_rate * param->channels * param->bps); /* DMA transfer count (in `words'!) reload using 2's complement. */ blksize = -(blksize >> 1); @@ -1756,7 +1709,7 @@ eso_trigger_output(void *hdl, void *start, void *end, int blksize, /* Update DAC to reflect DMA count and audio parameters. */ /* Note: we cache A2C2 in order to avoid r/m/w at interrupt time. */ - if (param->precision * param->factor == 16) + if (param->precision == 16) sc->sc_a2c2 |= ESO_MIXREG_A2C2_16BIT; else sc->sc_a2c2 &= ~ESO_MIXREG_A2C2_16BIT; @@ -1802,9 +1755,9 @@ eso_trigger_input(void *hdl, void *start, void *end, int blksize, DPRINTF(( "%s: trigger_input: start %p, end %p, blksize %d, intr %p(%p)\n", sc->sc_dev.dv_xname, start, end, blksize, intr, arg)); - DPRINTF(("%s: param: rate %lu, encoding %u, precision %u, channels %u, sw_code %p, factor %d\n", + DPRINTF(("%s: param: rate %lu, encoding %u, precision %u, channels %u\n", sc->sc_dev.dv_xname, param->sample_rate, param->encoding, - param->precision, param->channels, param->sw_code, param->factor)); + param->precision, param->channels)); /* * If we failed to configure the Audio 1 DMA controller, bail here @@ -1830,7 +1783,7 @@ eso_trigger_input(void *hdl, void *start, void *end, int blksize, /* Compute drain timeout. */ sc->sc_rdrain = hz * (blksize * 3 / 2) / - (param->sample_rate * param->channels * param->bps * param->factor); + (param->sample_rate * param->channels * param->bps); /* Set up ADC DMA converter parameters. */ actl = eso_read_ctlreg(sc, ESO_CTLREG_ACTL); @@ -1853,7 +1806,7 @@ eso_trigger_input(void *hdl, void *start, void *end, int blksize, /* Set up and enable Audio 1 DMA FIFO. */ a1c1 = ESO_CTLREG_A1C1_RESV1 | ESO_CTLREG_A1C1_FIFOENB; - if (param->precision * param->factor == 16) + if (param->precision == 16) a1c1 |= ESO_CTLREG_A1C1_16BIT; if (param->channels == 2) a1c1 |= ESO_CTLREG_A1C1_STEREO; diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci index 33391cc0002..2483a060a24 100644 --- a/sys/dev/pci/files.pci +++ b/sys/dev/pci/files.pci @@ -1,4 +1,4 @@ -# $OpenBSD: files.pci,v 1.314 2015/04/09 18:58:22 deraadt Exp $ +# $OpenBSD: files.pci,v 1.315 2015/05/11 06:46:22 ratchov Exp $ # $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $ # # Config file and device description for machine-independent PCI code. @@ -112,27 +112,27 @@ attach ips at pci file dev/pci/ips.c ips # Ensoniq AudioPCI S5016, 1371 -device eap: audio, auconv, mulaw, ac97, midibus +device eap: audio, ac97, midibus attach eap at pci file dev/pci/eap.c eap # ESS Solo-1 PCI AudioDrive -device eso {}: audio, auconv, mulaw, midibus +device eso {}: audio, midibus attach eso at pci file dev/pci/eso.c eso # Acer Labs M5455 -device auacer: audio, auconv, mulaw, ac97 +device auacer: audio, ac97 attach auacer at pci file dev/pci/auacer.c auacer # Intel 810/820/440MX ICH audio with AC'97 -device auich: audio, auconv, mulaw, ac97 +device auich: audio, ac97 attach auich at pci file dev/pci/auich.c auich # Intel 82801 HDA -device azalia: audio, auconv, mulaw, ac97 +device azalia: audio, ac97 attach azalia at pci file dev/pci/azalia.c azalia file dev/pci/azalia_codec.c azalia @@ -143,53 +143,53 @@ attach envy at pci file dev/pci/envy.c envy # Creative Labs EMU10k1 (SBLive! series and PCI512) -device emu: audio, auconv, mulaw, ac97 +device emu: audio, ac97 attach emu at pci file dev/pci/emuxki.c emu # Trident 4DWAVE based PCI audio (including SiS 7018, ALi M5451) -device autri: audio, auconv, mulaw, ac97, midibus +device autri: audio, ac97, midibus attach autri at pci file dev/pci/autri.c autri # ATI SB200/300/400 series AC'97 Audio -device auixp: audio, auconv, mulaw, ac97 +device auixp: audio, ac97 attach auixp at pci file dev/pci/auixp.c auixp # CS4280 CrystalClear Audio -device clcs: audio, auconv, mulaw, ac97, firmload +device clcs: audio, ac97, firmload attach clcs at pci file dev/pci/cs4280.c clcs # CS4281 CrystalClear Audio -device clct: audio, auconv, mulaw, ac97 +device clct: audio, ac97 attach clct at pci file dev/pci/cs4281.c clct # ESS Maestro -device maestro: audio, auconv, mulaw, ac97 +device maestro: audio, ac97 attach maestro at pci file dev/pci/maestro.c maestro # ESS Maestro3 -device esa: audio, auconv, mulaw, ac97 +device esa: audio, ac97 attach esa at pci file dev/pci/esa.c esa # Yamaha YMF Audio -device yds {}: audio, auconv, mulaw, ac97, firmload +device yds {}: audio, ac97, firmload attach yds at pci file dev/pci/yds.c yds # Forte Media FM801 -device fms: audio, auconv, mulaw, ac97, midibus, tea5757, radiobus +device fms: audio, ac97, midibus, tea5757, radiobus attach fms at pci file dev/pci/fms.c fms file dev/pci/fmsradio.c fms & radio # VIA VT82C686A AC'97 Audio -device auvia: audio, auconv, mulaw, ac97 +device auvia: audio, ac97 attach auvia at pci file dev/pci/auvia.c auvia @@ -272,7 +272,7 @@ attach siop at pci with siop_pci: siop_pci_common file dev/pci/siop_pci.c siop_pci # NeoMagic 256AV and 256ZX -device neo: audio, auconv, mulaw, ac97, firmload +device neo: audio, ac97, firmload attach neo at pci file dev/pci/neo.c neo @@ -324,7 +324,7 @@ attach txp at pci file dev/pci/if_txp.c txp # S3 SonicVibes (S3 617) -device sv: audio, auconv, mulaw +device sv: audio attach sv at pci file dev/pci/sv.c sv @@ -575,7 +575,7 @@ attach iwm at pci file dev/pci/if_iwm.c iwm # C-Media CMI8x38 Audio Chip -device cmpci {}: audio, auconv, mulaw +device cmpci {}: audio attach cmpci at pci file dev/pci/cmpci.c cmpci diff --git a/sys/dev/pci/fms.c b/sys/dev/pci/fms.c index 25b6885f7fd..58cef866471 100644 --- a/sys/dev/pci/fms.c +++ b/sys/dev/pci/fms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fms.c,v 1.26 2014/07/12 18:48:51 tedu Exp $ */ +/* $OpenBSD: fms.c,v 1.27 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: fms.c,v 1.5.4.1 2000/06/30 16:27:50 simonb Exp $ */ /*- @@ -50,9 +50,6 @@ #include <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> @@ -439,53 +436,17 @@ fms_query_encoding(void *addr, struct audio_encoding *fp) switch (fp->index) { case 0: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 1: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 2: + case 1: strlcpy(fp->name, AudioEulinear, sizeof fp->name); fp->encoding = AUDIO_ENCODING_ULINEAR; fp->precision = 8; fp->flags = 0; break; - case 3: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 5: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return EINVAL; } @@ -532,34 +493,15 @@ fms_set_params(void *addr, int setmode, int usemode, struct audio_params *play, int i; if (setmode & AUMODE_PLAY) { - play->factor = 1; - play->sw_code = 0; switch(play->encoding) { - case AUDIO_ENCODING_ULAW: - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - break; case AUDIO_ENCODING_SLINEAR_LE: - if (play->precision == 8) - play->sw_code = change_sign8; + if (play->precision != 16) + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (play->precision == 16) - play->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ALAW: - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (play->precision == 16) - play->sw_code = swap_bytes; - else - play->sw_code = change_sign8; - break; case AUDIO_ENCODING_ULINEAR_BE: - if (play->precision == 16) - play->sw_code = change_sign16_swap_bytes_le; + if (play->precision != 8) + return EINVAL; break; default: return EINVAL; @@ -572,38 +514,21 @@ fms_set_params(void *addr, int setmode, int usemode, struct audio_params *play, ; play->sample_rate = fms_rates[i].rate; sc->sc_play_reg = (play->channels == 2 ? FM_PLAY_STEREO : 0) | - (play->precision * play->factor == 16 ? FM_PLAY_16BIT : 0) | + (play->precision == 16 ? FM_PLAY_16BIT : 0) | (i << 8); } if (setmode & AUMODE_RECORD) { - rec->factor = 1; - rec->sw_code = 0; switch(rec->encoding) { - case AUDIO_ENCODING_ULAW: - rec->sw_code = ulinear8_to_mulaw; - break; case AUDIO_ENCODING_SLINEAR_LE: - if (rec->precision == 8) - rec->sw_code = change_sign8; + if (rec->precision != 16) + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (rec->precision == 16) - rec->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ALAW: - rec->sw_code = ulinear8_to_alaw; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes; - else - rec->sw_code = change_sign8; - break; case AUDIO_ENCODING_ULINEAR_BE: - if (rec->precision == 16) - rec->sw_code = swap_bytes_change_sign16_le; + if (rec->precision != 8) + return EINVAL; break; default: return EINVAL; @@ -617,7 +542,7 @@ fms_set_params(void *addr, int setmode, int usemode, struct audio_params *play, rec->sample_rate = fms_rates[i].rate; sc->sc_rec_reg = (rec->channels == 2 ? FM_REC_STEREO : 0) | - (rec->precision * rec->factor == 16 ? FM_REC_16BIT : 0) | + (rec->precision == 16 ? FM_REC_16BIT : 0) | (i << 8); } diff --git a/sys/dev/pci/maestro.c b/sys/dev/pci/maestro.c index 890eae1a4b0..54434d5ac10 100644 --- a/sys/dev/pci/maestro.c +++ b/sys/dev/pci/maestro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: maestro.c,v 1.38 2014/09/13 16:06:37 doug Exp $ */ +/* $OpenBSD: maestro.c,v 1.39 2015/05/11 06:46:22 ratchov Exp $ */ /* $FreeBSD: /c/ncvs/src/sys/dev/sound/pci/maestro.c,v 1.3 2000/11/21 12:22:11 julian Exp $ */ /* * FreeBSD's ESS Agogo/Maestro driver @@ -59,8 +59,6 @@ #include <sys/audioio.h> #include <dev/audio_if.h> -#include <dev/mulaw.h> -#include <dev/auconv.h> #include <dev/ic/ac97.h> @@ -943,17 +941,7 @@ maestro_query_devinfo(void *self, mixer_devinfo_t *cp) struct audio_encoding maestro_tab[] = { {0, AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16, 2, 1, 0}, {1, AudioEslinear, AUDIO_ENCODING_SLINEAR, 8, 1, 1, 0}, - {2, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 1, 1, 0}, - {3, AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16, 2, 1, - AUDIO_ENCODINGFLAG_EMULATED}, - {4, AudioEulinear_le, AUDIO_ENCODING_ULINEAR_LE, 16, 2, 1, - AUDIO_ENCODINGFLAG_EMULATED}, - {5, AudioEulinear_be, AUDIO_ENCODING_ULINEAR_BE, 16, 2, 1, - AUDIO_ENCODINGFLAG_EMULATED}, - {6, AudioEmulaw, AUDIO_ENCODING_ULAW, 8, 1, 1, - AUDIO_ENCODINGFLAG_EMULATED}, - {7, AudioEalaw, AUDIO_ENCODING_ALAW, 8, 1, 1, - AUDIO_ENCODINGFLAG_EMULATED} + {2, AudioEulinear, AUDIO_ENCODING_ULINEAR, 8, 1, 1, 0} }; int @@ -1046,8 +1034,6 @@ maestro_set_params(void *hdl, int setmode, int usemode, else if (play->sample_rate > 48000) play->sample_rate = 48000; - play->factor = 1; - play->sw_code = NULL; if (play->channels > 2) play->channels = 2; @@ -1055,24 +1041,12 @@ maestro_set_params(void *hdl, int setmode, int usemode, if (play->channels == 2) sc->play.mode |= MAESTRO_STEREO; - if (play->encoding == AUDIO_ENCODING_ULAW) { - play->factor = 2; - play->sw_code = mulaw_to_slinear16_le; - } else if (play->encoding == AUDIO_ENCODING_ALAW) { - play->factor = 2; - play->sw_code = alaw_to_slinear16_le; - } else if (play->precision == 8) { + if (play->precision == 8) { sc->play.mode |= MAESTRO_8BIT; if (play->encoding == AUDIO_ENCODING_ULINEAR_LE || play->encoding == AUDIO_ENCODING_ULINEAR_BE) sc->play.mode |= MAESTRO_UNSIGNED; } - else if (play->encoding == AUDIO_ENCODING_ULINEAR_LE) - play->sw_code = change_sign16_le; - else if (play->encoding == AUDIO_ENCODING_SLINEAR_BE) - play->sw_code = swap_bytes; - else if (play->encoding == AUDIO_ENCODING_ULINEAR_BE) - play->sw_code = change_sign16_swap_bytes_le; else if (play->encoding != AUDIO_ENCODING_SLINEAR_LE) return (EINVAL); diff --git a/sys/dev/pci/neo.c b/sys/dev/pci/neo.c index 503eb352ab1..cfd183a26ee 100644 --- a/sys/dev/pci/neo.c +++ b/sys/dev/pci/neo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neo.c,v 1.29 2013/11/15 16:46:27 brad Exp $ */ +/* $OpenBSD: neo.c,v 1.30 2015/05/11 06:46:22 ratchov Exp $ */ /* * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> @@ -43,8 +43,6 @@ #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> @@ -761,47 +759,11 @@ neo_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -853,44 +815,15 @@ neo_set_params(void *addr, int setmode, int usemode, NM_PLAYBACK_REG_OFFSET : NM_RECORD_REG_OFFSET; nm_wr(sc, base + NM_RATE_REG_OFFSET, x, 1); - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = swap_bytes_change_sign16_le; - else - p->sw_code = change_sign16_swap_bytes_le; - } + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; break; default: return (EINVAL); @@ -919,7 +852,7 @@ neo_trigger_output(void *addr, void *start, void *end, int blksize, sc->pintr = intr; sc->parg = arg; - ssz = (param->precision * param->factor == 16)? 2 : 1; + ssz = (param->precision == 16) ? 2 : 1; if (param->channels == 2) ssz <<= 1; @@ -950,7 +883,7 @@ neo_trigger_input(void *addr, void *start, void *end, int blksize, sc->rintr = intr; sc->rarg = arg; - ssz = (param->precision * param->factor == 16)? 2 : 1; + ssz = (param->precision == 16) ? 2 : 1; if (param->channels == 2) ssz <<= 1; diff --git a/sys/dev/pci/sv.c b/sys/dev/pci/sv.c index 5fef1c652cb..a7da7cf8b18 100644 --- a/sys/dev/pci/sv.c +++ b/sys/dev/pci/sv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sv.c,v 1.31 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: sv.c,v 1.32 2015/05/11 06:46:22 ratchov Exp $ */ /* * Copyright (c) 1998 Constantine Paul Sapuntzakis @@ -48,8 +48,6 @@ #include <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> @@ -587,48 +585,12 @@ sv_query_encoding(void *addr, struct audio_encoding *fp) fp->precision = 8; fp->flags = 0; break; - case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: + case 1: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -643,41 +605,19 @@ sv_set_params(void *addr, int setmode, int usemode, struct audio_params *p, struct audio_params *r) { struct sv_softc *sc = addr; - void (*pswcode)(void *, u_char *buf, int cnt); - void (*rswcode)(void *, u_char *buf, int cnt); u_int32_t mode, val; u_int8_t reg; - pswcode = rswcode = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - rswcode = pswcode = swap_bytes; - else - pswcode = rswcode = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - pswcode = rswcode = change_sign8; + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - pswcode = swap_bytes_change_sign16_le; - rswcode = change_sign16_swap_bytes_le; - } - break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - pswcode = rswcode = change_sign16_le; + if (p->precision != 8) + return EINVAL; break; - case AUDIO_ENCODING_ULAW: - pswcode = mulaw_to_ulinear8; - rswcode = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - pswcode = alaw_to_ulinear8; - rswcode = ulinear8_to_alaw; - break; default: return (EINVAL); } @@ -695,8 +635,6 @@ sv_set_params(void *addr, int setmode, int usemode, if (p->sample_rate > 48000) p->sample_rate = 48000; - p->sw_code = pswcode; - r->sw_code = rswcode; p->bps = AUDIO_BPS(p->precision); r->bps = AUDIO_BPS(r->precision); p->msb = r->msb = 1; diff --git a/sys/dev/pci/yds.c b/sys/dev/pci/yds.c index fdb3aa991c8..b63db724c69 100644 --- a/sys/dev/pci/yds.c +++ b/sys/dev/pci/yds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yds.c,v 1.49 2015/03/14 03:38:49 jsg Exp $ */ +/* $OpenBSD: yds.c,v 1.50 2015/05/11 06:46:22 ratchov Exp $ */ /* $NetBSD: yds.c,v 1.5 2001/05/21 23:55:04 minoura Exp $ */ /* @@ -54,8 +54,6 @@ #include <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> @@ -943,7 +941,7 @@ yds_intr(void *p) N_PLAY_SLOT_CTRL_BANK, BUS_DMASYNC_POSTWRITE| BUS_DMASYNC_POSTREAD); - dma = sc->pbankp[nbank]->pgstart * sc->sc_play.factor; + dma = sc->pbankp[nbank]->pgstart; cpu = sc->sc_play.offset; blk = sc->sc_play.blksize; len = sc->sc_play.length; @@ -1106,47 +1104,11 @@ yds_query_encoding(void *addr, struct audio_encoding *fp) fp->flags = 0; break; case 1: - strlcpy(fp->name, AudioEmulaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 2: - strlcpy(fp->name, AudioEalaw, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ALAW; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 3: - strlcpy(fp->name, AudioEslinear, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR; - fp->precision = 8; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 4: strlcpy(fp->name, AudioEslinear_le, sizeof fp->name); fp->encoding = AUDIO_ENCODING_SLINEAR_LE; fp->precision = 16; fp->flags = 0; break; - case 5: - strlcpy(fp->name, AudioEulinear_le, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_LE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 6: - strlcpy(fp->name, AudioEslinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_SLINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; - case 7: - strlcpy(fp->name, AudioEulinear_be, sizeof fp->name); - fp->encoding = AUDIO_ENCODING_ULINEAR_BE; - fp->precision = 16; - fp->flags = AUDIO_ENCODINGFLAG_EMULATED; - break; default: return (EINVAL); } @@ -1185,46 +1147,15 @@ yds_set_params(void *addr, int setmode, int usemode, if (p->channels > 2) p->channels = 2; - p->factor = 1; - p->sw_code = 0; switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) - p->sw_code = swap_bytes; - else - p->sw_code = change_sign8; - break; case AUDIO_ENCODING_SLINEAR_LE: if (p->precision != 16) - p->sw_code = change_sign8; - break; - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 16) { - if (mode == AUMODE_PLAY) - p->sw_code = swap_bytes_change_sign16_le; - else - p->sw_code = change_sign16_swap_bytes_le; - } + return EINVAL; break; case AUDIO_ENCODING_ULINEAR_LE: - if (p->precision == 16) - p->sw_code = change_sign16_le; - break; - case AUDIO_ENCODING_ULAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->precision = 16; - p->sw_code = mulaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_mulaw; - break; - case AUDIO_ENCODING_ALAW: - if (mode == AUMODE_PLAY) { - p->factor = 2; - p->precision = 16; - p->sw_code = alaw_to_slinear16_le; - } else - p->sw_code = ulinear8_to_alaw; + case AUDIO_ENCODING_ULINEAR_BE: + if (p->precision != 8) + return EINVAL; break; default: return (EINVAL); @@ -1366,13 +1297,6 @@ yds_trigger_output(void *addr, void *start, void *end, int blksize, *sc->ptbl = channels; /* Num of play */ - sc->sc_play.factor = 1; - if (param->channels == 2) - sc->sc_play.factor *= 2; - if (param->precision != 8) - sc->sc_play.factor *= 2; - l /= sc->sc_play.factor; - psb = sc->pbankp[0]; memset(psb, 0, sizeof(*psb)); psb->format = ((channels == 2 ? PSLT_FORMAT_STEREO : 0) | @@ -1479,12 +1403,6 @@ yds_trigger_input(void *addr, void *start, void *end, int blksize, l = ((char *)end - (char *)start); sc->sc_rec.length = l; - sc->sc_rec.factor = 1; - if (param->channels == 2) - sc->sc_rec.factor *= 2; - if (param->precision != 8) - sc->sc_rec.factor *= 2; - rsb = &sc->rbank[0]; memset(rsb, 0, sizeof(*rsb)); rsb->pgbase = s; |