Skip to content

Commit 776678a

Browse files
ujfalusilgirdwood
authored andcommitted
ASoC: soc-compress: Implement trigger FE-BE sequencing as with normal PCMs
The FE-BE trigger sequence should be dynamic, similarly how soc-pcm.c dpcm_fe_dai_do_trigger() does it. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent 89a7244 commit 776678a

1 file changed

Lines changed: 62 additions & 9 deletions

File tree

sound/soc/soc-compress.c

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,31 +273,84 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
273273
return ret;
274274
}
275275

276-
static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
276+
static int soc_compr_trigger_fe_be(struct snd_compr_stream *cstream, int cmd,
277+
bool fe_first)
277278
{
278279
struct snd_soc_pcm_runtime *fe = cstream->private_data;
279280
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(fe, 0);
281+
int ret;
282+
283+
if (fe_first) {
284+
dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n",
285+
fe->dai_link->name, cmd);
286+
287+
ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
288+
if (ret < 0)
289+
goto out;
290+
291+
ret = snd_soc_component_compr_trigger(cstream, cmd);
292+
if (ret < 0)
293+
goto out;
294+
295+
ret = dpcm_be_dai_trigger(fe, cstream->direction, cmd);
296+
} else {
297+
dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n",
298+
fe->dai_link->name, cmd);
299+
300+
ret = dpcm_be_dai_trigger(fe, cstream->direction, cmd);
301+
if (ret < 0)
302+
goto out;
303+
304+
ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
305+
if (ret < 0)
306+
goto out;
307+
308+
ret = snd_soc_component_compr_trigger(cstream, cmd);
309+
}
310+
311+
out:
312+
return snd_soc_ret(fe->dev, ret, "trigger FE cmd: %d failed\n", cmd);
313+
}
314+
315+
static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
316+
{
317+
struct snd_soc_pcm_runtime *fe = cstream->private_data;
280318
int stream = cstream->direction; /* SND_COMPRESS_xxx is same as SNDRV_PCM_STREAM_xxx */
319+
bool fe_first;
281320
int ret;
282321

283322
if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
284323
cmd == SND_COMPR_TRIGGER_DRAIN)
285324
return snd_soc_component_compr_trigger(cstream, cmd);
286325

326+
if (fe->dai_link->trigger[stream] == SND_SOC_DPCM_TRIGGER_POST)
327+
fe_first = false;
328+
else
329+
fe_first = true;
330+
287331
snd_soc_card_mutex_lock(fe->card);
288332

289-
ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
290-
if (ret < 0)
291-
goto out;
333+
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
334+
335+
switch (cmd) {
336+
case SNDRV_PCM_TRIGGER_START:
337+
case SNDRV_PCM_TRIGGER_RESUME:
338+
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
339+
ret = soc_compr_trigger_fe_be(cstream, cmd, fe_first);
340+
break;
341+
case SNDRV_PCM_TRIGGER_STOP:
342+
case SNDRV_PCM_TRIGGER_SUSPEND:
343+
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
344+
ret = soc_compr_trigger_fe_be(cstream, cmd, !fe_first);
345+
break;
346+
default:
347+
ret = -EINVAL;
348+
break;
349+
}
292350

293-
ret = snd_soc_component_compr_trigger(cstream, cmd);
294351
if (ret < 0)
295352
goto out;
296353

297-
fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
298-
299-
ret = dpcm_be_dai_trigger(fe, stream, cmd);
300-
301354
switch (cmd) {
302355
case SNDRV_PCM_TRIGGER_START:
303356
case SNDRV_PCM_TRIGGER_RESUME:

0 commit comments

Comments
 (0)