Skip to content

Commit 1bc13b2

Browse files
Peter UjfalusiLiam Girdwood
authored andcommitted
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 <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Liam Girdwood <[email protected]>
1 parent d54e1f4 commit 1bc13b2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sound/soc/codecs/tlv320dac33.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,9 @@ static void dac33_calculate_times(struct snd_pcm_substream *substream)
10821082
/* Number of samples under i2c latency */
10831083
dac33->alarm_threshold = US_TO_SAMPLES(rate,
10841084
dac33->mode1_latency);
1085+
nsample_limit = DAC33_BUFFER_SIZE_SAMPLES -
1086+
dac33->alarm_threshold;
1087+
10851088
if (dac33->auto_fifo_config) {
10861089
if (period_size <= dac33->alarm_threshold)
10871090
/*
@@ -1092,6 +1095,8 @@ static void dac33_calculate_times(struct snd_pcm_substream *substream)
10921095
((dac33->alarm_threshold / period_size) +
10931096
(dac33->alarm_threshold % period_size ?
10941097
1 : 0));
1098+
else if (period_size > nsample_limit)
1099+
dac33->nsample = nsample_limit;
10951100
else
10961101
dac33->nsample = period_size;
10971102
} else {
@@ -1103,8 +1108,7 @@ static void dac33_calculate_times(struct snd_pcm_substream *substream)
11031108
*/
11041109
dac33->nsample_max = substream->runtime->buffer_size -
11051110
period_size;
1106-
nsample_limit = DAC33_BUFFER_SIZE_SAMPLES -
1107-
dac33->alarm_threshold;
1111+
11081112
if (dac33->nsample_max > nsample_limit)
11091113
dac33->nsample_max = nsample_limit;
11101114

0 commit comments

Comments
 (0)