Skip to content

Commit c50535e

Browse files
Akshu Agrawalbroonie
authored andcommitted
ASoC: AMD: Fix capture unstable in beginning for some runs
alsa_conformance_test -C hw:0,4 -p 1024 --debug would sometime show: TIME_DIFF(s) HW_LEVEL READ RATE 0.000095970 1024 1024 10670001.041992 0.042609555 1024 2048 24032.168372 0.021330364 1024 3072 48006.681930 0.021339559 1024 4096 47985.996337 The issue is that in dma pointer function we can have stale value of the register for current descriptor of channel. The register retains the number of the last descriptor that was transferred. Fix ensures that we report position, 0, till the one period worth of data is transferred. After one period of data, in handler of period completion interrupt we update the config and correct value of descriptor starts reflecting. Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 3f24f37 commit c50535e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

sound/soc/amd/acp-pcm-dma.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,16 +1036,22 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream)
10361036

10371037
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
10381038
period_bytes = frames_to_bytes(runtime, runtime->period_size);
1039-
dscr = acp_reg_read(rtd->acp_mmio, rtd->dma_curr_dscr);
1040-
if (dscr == rtd->dma_dscr_idx_1)
1041-
pos = period_bytes;
1042-
else
1043-
pos = 0;
10441039
bytescount = acp_get_byte_count(rtd);
1045-
if (bytescount > rtd->bytescount)
1040+
if (bytescount >= rtd->bytescount)
10461041
bytescount -= rtd->bytescount;
1047-
delay = do_div(bytescount, period_bytes);
1048-
runtime->delay = bytes_to_frames(runtime, delay);
1042+
if (bytescount < period_bytes) {
1043+
pos = 0;
1044+
} else {
1045+
dscr = acp_reg_read(rtd->acp_mmio, rtd->dma_curr_dscr);
1046+
if (dscr == rtd->dma_dscr_idx_1)
1047+
pos = period_bytes;
1048+
else
1049+
pos = 0;
1050+
}
1051+
if (bytescount > 0) {
1052+
delay = do_div(bytescount, period_bytes);
1053+
runtime->delay = bytes_to_frames(runtime, delay);
1054+
}
10491055
} else {
10501056
buffersize = frames_to_bytes(runtime, runtime->buffer_size);
10511057
bytescount = acp_get_byte_count(rtd);

0 commit comments

Comments
 (0)