Skip to content

Commit 54fc4b7

Browse files
claudiubezneabroonie
authored andcommitted
ASoC: soc-pcm: add option to start DMA after DAI
Add option to start DMA component after DAI trigger. This is done by filling the new struct snd_soc_component_driver::start_dma_last. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lore.kernel.org/r/20230228110145.3770525-2-claudiu.beznea@microchip.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent fb1847c commit 54fc4b7

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

include/sound/soc-component.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ struct snd_soc_component_driver {
190190
bool use_dai_pcm_id; /* use DAI link PCM ID as PCM device number */
191191
int be_pcm_base; /* base device ID for all BE PCMs */
192192

193+
unsigned int start_dma_last;
194+
193195
#ifdef CONFIG_DEBUG_FS
194196
const char *debugfs_prefix;
195197
#endif

sound/soc/soc-pcm.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,22 +1088,39 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
10881088
static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
10891089
{
10901090
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1091-
int ret = -EINVAL, _ret = 0;
1091+
struct snd_soc_component *component;
1092+
int ret = -EINVAL, _ret = 0, start_dma_last = 0, i;
10921093
int rollback = 0;
10931094

10941095
switch (cmd) {
10951096
case SNDRV_PCM_TRIGGER_START:
10961097
case SNDRV_PCM_TRIGGER_RESUME:
10971098
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1099+
/* Do we need to start dma last? */
1100+
for_each_rtd_components(rtd, i, component) {
1101+
if (component->driver->start_dma_last) {
1102+
start_dma_last = 1;
1103+
break;
1104+
}
1105+
}
1106+
10981107
ret = snd_soc_link_trigger(substream, cmd, 0);
10991108
if (ret < 0)
11001109
goto start_err;
11011110

1102-
ret = snd_soc_pcm_component_trigger(substream, cmd, 0);
1103-
if (ret < 0)
1104-
goto start_err;
1111+
if (start_dma_last) {
1112+
ret = snd_soc_pcm_dai_trigger(substream, cmd, 0);
1113+
if (ret < 0)
1114+
goto start_err;
1115+
1116+
ret = snd_soc_pcm_component_trigger(substream, cmd, 0);
1117+
} else {
1118+
ret = snd_soc_pcm_component_trigger(substream, cmd, 0);
1119+
if (ret < 0)
1120+
goto start_err;
11051121

1106-
ret = snd_soc_pcm_dai_trigger(substream, cmd, 0);
1122+
ret = snd_soc_pcm_dai_trigger(substream, cmd, 0);
1123+
}
11071124
start_err:
11081125
if (ret < 0)
11091126
rollback = 1;

0 commit comments

Comments
 (0)