Skip to content

Commit ab55937

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: Intel: hda: Always clean up link DMA during stop
This is required to reset the DMA read/write pointers when the stream is prepared and restarted after a call to snd_pcm_drain()/snd_pcm_drop(). Also, now that the stream is reset during stop, do not save LLP registers in the case of STOP/suspend to avoid erroneous delay reporting. Link: https://github.com/thesofproject/sof/issues/9502 Signed-off-by: Ranjani Sridharan <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Signed-off-by: Bard Liao <[email protected]> All: [email protected] # 6.10.x 6.11.x Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c78f1e1 commit ab55937

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

sound/soc/sof/intel/hda-dai-ops.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,21 @@ static int hda_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
346346
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
347347
snd_hdac_ext_stream_start(hext_stream);
348348
break;
349-
case SNDRV_PCM_TRIGGER_SUSPEND:
350-
case SNDRV_PCM_TRIGGER_STOP:
351349
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
352-
snd_hdac_ext_stream_clear(hext_stream);
353-
354350
/*
355-
* Save the LLP registers in case the stream is
356-
* restarting due PAUSE_RELEASE, or START without a pcm
357-
* close/open since in this case the LLP register is not reset
358-
* to 0 and the delay calculation will return with invalid
359-
* results.
351+
* Save the LLP registers since in case of PAUSE the LLP
352+
* register are not reset to 0, the delay calculation will use
353+
* the saved offsets for compensating the delay calculation.
360354
*/
361355
hext_stream->pplcllpl = readl(hext_stream->pplc_addr + AZX_REG_PPLCLLPL);
362356
hext_stream->pplcllpu = readl(hext_stream->pplc_addr + AZX_REG_PPLCLLPU);
357+
snd_hdac_ext_stream_clear(hext_stream);
358+
break;
359+
case SNDRV_PCM_TRIGGER_SUSPEND:
360+
case SNDRV_PCM_TRIGGER_STOP:
361+
hext_stream->pplcllpl = 0;
362+
hext_stream->pplcllpu = 0;
363+
snd_hdac_ext_stream_clear(hext_stream);
363364
break;
364365
default:
365366
dev_err(sdev->dev, "unknown trigger command %d\n", cmd);
@@ -512,7 +513,6 @@ static const struct hda_dai_widget_dma_ops sdw_ipc4_chain_dma_ops = {
512513
static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
513514
struct snd_pcm_substream *substream, int cmd)
514515
{
515-
struct hdac_ext_stream *hext_stream = hda_get_hext_stream(sdev, cpu_dai, substream);
516516
struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(cpu_dai, substream->stream);
517517

518518
switch (cmd) {
@@ -527,9 +527,6 @@ static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c
527527
if (ret < 0)
528528
return ret;
529529

530-
if (cmd == SNDRV_PCM_TRIGGER_STOP)
531-
return hda_link_dma_cleanup(substream, hext_stream, cpu_dai);
532-
533530
break;
534531
}
535532
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:

sound/soc/sof/intel/hda-dai.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i
302302
}
303303

304304
switch (cmd) {
305+
case SNDRV_PCM_TRIGGER_STOP:
305306
case SNDRV_PCM_TRIGGER_SUSPEND:
306307
ret = hda_link_dma_cleanup(substream, hext_stream, dai);
307308
if (ret < 0) {

0 commit comments

Comments
 (0)