Fixed a problem that /dev/sound can not be opened in some cases.

auich_set_rate() modified audio_params::sample_rate to actual
sample rate though auich_set_params() rejected sample rates
other than some specific rates.  For example, setting 8000Hz
with auich_set_params() modified sample_rate to 7998Hz in the
case of overclocked AC97 codec, and calling auich_set_params()
again returned with EINVAL because sample_rate was 7998Hz and
auich_set_params() rejected 7998Hz.

For now, auich_set_params() never modify audio_params::sample_rate.
This commit is contained in:
kent 2003-01-15 04:49:35 +00:00
parent 001300d84b
commit f22fb7c9b8
1 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: auich.c,v 1.30 2002/10/12 19:45:54 wiz Exp $ */
/* $NetBSD: auich.c,v 1.31 2003/01/15 04:49:35 kent Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -110,7 +110,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.30 2002/10/12 19:45:54 wiz Exp $");
__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.31 2003/01/15 04:49:35 kent Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -265,7 +265,7 @@ int auich_allocmem(struct auich_softc *, size_t, size_t,
int auich_freemem(struct auich_softc *, struct auich_dma *);
void auich_powerhook(int, void *);
int auich_set_rate(struct auich_softc *, int, u_long*);
int auich_set_rate(struct auich_softc *, int, u_long);
void auich_calibrate(struct device *);
@ -649,13 +649,15 @@ auich_query_encoding(void *v, struct audio_encoding *aep)
}
int
auich_set_rate(struct auich_softc *sc, int mode, u_long* srate)
auich_set_rate(struct auich_softc *sc, int mode, u_long srate)
{
int reg;
u_long ratetmp;
ratetmp = srate;
reg = mode == AUMODE_PLAY
? AC97_REG_PCM_FRONT_DAC_RATE : AC97_REG_PCM_LR_ADC_RATE;
return sc->codec_if->vtbl->set_rate(sc->codec_if, reg, srate);
return sc->codec_if->vtbl->set_rate(sc->codec_if, reg, &ratetmp);
}
int
@ -774,7 +776,7 @@ auich_set_params(void *v, int setmode, int usemode, struct audio_params *play,
p->hw_sample_rate = AC97_SINGLE_RATE;
/* If hw_sample_rate is changed, aurateconv works. */
} else {
if (auich_set_rate(sc, mode, &p->sample_rate))
if (auich_set_rate(sc, mode, p->sample_rate))
return EINVAL;
}
}