auvia_set_params:

For a fixed-rate codec, when AUMODE_RECORD and AUDIO_ENCODING_MULAW or
AUDIO_ENCODING_ALAW, use AUDIO_ENCODING_SLINEAR_LE/16bit for native encoding
instead of AUDIO_ENCODING_ULINEAR/8bit because aurateconv does not support
sampling rate conversion for 8 bit PCM.
This change fixes PR kern/18834.
This commit is contained in:
kent 2002-11-04 16:38:49 +00:00
parent acfba287f0
commit 22d0e4bb85

View File

@ -1,4 +1,4 @@
/* $NetBSD: auvia.c,v 1.27 2002/10/16 15:27:28 kent Exp $ */
/* $NetBSD: auvia.c,v 1.28 2002/11/04 16:38:49 kent Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.27 2002/10/16 15:27:28 kent Exp $");
__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.28 2002/11/04 16:38:49 kent Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -594,12 +594,14 @@ auvia_set_params(void *addr, int setmode, int usemode,
if (mode == AUMODE_PLAY ) {
p = play;
ch = &sc->sc_play;
reg = AC97_REG_PCM_FRONT_DAC_RATE;
} else {
p = rec;
ch = &sc->sc_record;
reg = AC97_REG_PCM_LR_ADC_RATE;
}
if (ch->sc_base == VIA8233_MP_BASE) {
if (ch->sc_base == VIA8233_MP_BASE && mode == AUMODE_PLAY) {
ext_id = codec->vtbl->get_extcaps(codec);
if (p->channels == 1) {
/* ok */
@ -623,9 +625,6 @@ auvia_set_params(void *addr, int setmode, int usemode,
(p->precision != 8 && p->precision != 16))
return (EINVAL);
reg = mode == AUMODE_PLAY ?
AC97_REG_PCM_FRONT_DAC_RATE : AC97_REG_PCM_LR_ADC_RATE;
if (IS_FIXED_RATE(codec)) {
/* Enable aurateconv */
p->hw_sample_rate = AC97_SINGLE_RATE;
@ -685,9 +684,15 @@ auvia_set_params(void *addr, int setmode, int usemode,
p->sw_code = mulaw_to_slinear16_le;
p->hw_encoding = AUDIO_ENCODING_SLINEAR_LE;
p->hw_precision = 16;
} else {
} else if (!IS_FIXED_RATE(codec)) {
p->sw_code = ulinear8_to_mulaw;
p->hw_encoding = AUDIO_ENCODING_ULINEAR;
} else {
/* aurateconv supports no 8 bit PCM */
p->factor = 2;
p->sw_code = slinear16_to_mulaw_le;
p->hw_encoding = AUDIO_ENCODING_SLINEAR_LE;
p->hw_precision = 16;
}
break;
case AUDIO_ENCODING_ALAW:
@ -698,9 +703,15 @@ auvia_set_params(void *addr, int setmode, int usemode,
p->sw_code = alaw_to_slinear16_le;
p->hw_encoding = AUDIO_ENCODING_SLINEAR_LE;
p->hw_precision = 16;
} else {
} else if (!IS_FIXED_RATE(codec)) {
p->sw_code = ulinear8_to_alaw;
p->hw_encoding = AUDIO_ENCODING_ULINEAR;
} else {
/* aurateconv supports no 8 bit PCM */
p->factor = 2;
p->sw_code = slinear16_to_alaw_le;
p->hw_encoding = AUDIO_ENCODING_SLINEAR_LE;
p->hw_precision = 16;
}
break;
default: