ASoC: tlv320dac33: Mode1 FIFO auto configuration fix

Do not allow invalid (too big) nSample value, when FIFO Mode1
and automatic fifo configuration has been selected.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
This commit is contained in:
Peter Ujfalusi 2010-10-29 09:49:37 +03:00 committed by Liam Girdwood
parent d54e1f4fdf
commit 1bc13b2e35

View file

@ -1082,6 +1082,9 @@ static void dac33_calculate_times(struct snd_pcm_substream *substream)
/* Number of samples under i2c latency */ /* Number of samples under i2c latency */
dac33->alarm_threshold = US_TO_SAMPLES(rate, dac33->alarm_threshold = US_TO_SAMPLES(rate,
dac33->mode1_latency); dac33->mode1_latency);
nsample_limit = DAC33_BUFFER_SIZE_SAMPLES -
dac33->alarm_threshold;
if (dac33->auto_fifo_config) { if (dac33->auto_fifo_config) {
if (period_size <= dac33->alarm_threshold) if (period_size <= dac33->alarm_threshold)
/* /*
@ -1092,6 +1095,8 @@ static void dac33_calculate_times(struct snd_pcm_substream *substream)
((dac33->alarm_threshold / period_size) + ((dac33->alarm_threshold / period_size) +
(dac33->alarm_threshold % period_size ? (dac33->alarm_threshold % period_size ?
1 : 0)); 1 : 0));
else if (period_size > nsample_limit)
dac33->nsample = nsample_limit;
else else
dac33->nsample = period_size; dac33->nsample = period_size;
} else { } else {
@ -1103,8 +1108,7 @@ static void dac33_calculate_times(struct snd_pcm_substream *substream)
*/ */
dac33->nsample_max = substream->runtime->buffer_size - dac33->nsample_max = substream->runtime->buffer_size -
period_size; period_size;
nsample_limit = DAC33_BUFFER_SIZE_SAMPLES -
dac33->alarm_threshold;
if (dac33->nsample_max > nsample_limit) if (dac33->nsample_max > nsample_limit)
dac33->nsample_max = nsample_limit; dac33->nsample_max = nsample_limit;