Skip to content

Commit 0d51efc

Browse files
committed
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 fadeee4 commit 0d51efc

1 file changed

Lines changed: 68 additions & 9 deletions

File tree

sound/soc/soc-compress.c

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,31 +273,90 @@ 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 ret;
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 = true;
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+
switch (fe->dai_link->trigger[stream]) {
327+
case SND_SOC_DPCM_TRIGGER_PRE:
328+
fe_first = true;
329+
break;
330+
case SND_SOC_DPCM_TRIGGER_POST:
331+
fe_first = false;
332+
break;
333+
default:
334+
break;
335+
}
336+
287337
snd_soc_card_mutex_lock(fe->card);
288338

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

293-
ret = snd_soc_component_compr_trigger(cstream, cmd);
294357
if (ret < 0)
295358
goto out;
296359

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

0 commit comments

Comments
 (0)