Skip to content

Commit eed4872

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: ipc4-topology: Advertise passthrough capable PCMs (using ChainDMA)
If a PCM is set to use ChainDMA then add it to the card->components string after a marker of iec61937-pcm:, for example on current HDA platforms where HDMI is set to use ChainDMA: iec61937-pcm:5,4,3 (the order of the PCM ids can differ) UCM is expected to parse and use this property to allow applications to use bytestream passthrough in a standard way. Reviewed-by: Ranjani Sridharan <[email protected]> Signed-off-by: Peter Ujfalusi <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 7ff01ca commit eed4872

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,52 @@ static void sof_ipc4_widget_update_kcontrol_module_id(struct snd_sof_widget *swi
407407
}
408408
}
409409

410+
static int
411+
sof_ipc4_update_card_components_string(struct snd_sof_widget *swidget,
412+
struct snd_sof_pcm *spcm, int dir)
413+
{
414+
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
415+
struct sof_ipc4_pipeline *pipeline = pipe_widget->private;
416+
struct snd_soc_component *scomp = spcm->scomp;
417+
struct snd_soc_card *card = scomp->card;
418+
const char *pt_marker = "iec61937-pcm";
419+
420+
/*
421+
* Update the card's components list with iec61937-pcm and a list of PCM
422+
* ids where ChainDMA is enabled.
423+
* These PCMs can be used for bytestream passthrough.
424+
*/
425+
if (!pipeline->use_chain_dma)
426+
return 0;
427+
428+
if (card->components) {
429+
const char *tmp = card->components;
430+
431+
if (strstr(card->components, pt_marker))
432+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
433+
"%s,%d",
434+
card->components,
435+
spcm->pcm.pcm_id);
436+
else
437+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
438+
"%s %s:%d",
439+
card->components,
440+
pt_marker,
441+
spcm->pcm.pcm_id);
442+
443+
devm_kfree(card->dev, tmp);
444+
} else {
445+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
446+
"%s:%d", pt_marker,
447+
spcm->pcm.pcm_id);
448+
}
449+
450+
if (!card->components)
451+
return -ENOMEM;
452+
453+
return 0;
454+
}
455+
410456
static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
411457
{
412458
struct sof_ipc4_available_audio_format *available_fmt;
@@ -452,6 +498,10 @@ static int sof_ipc4_widget_setup_pcm(struct snd_sof_widget *swidget)
452498
if (!spcm)
453499
goto skip_gtw_cfg;
454500

501+
ret = sof_ipc4_update_card_components_string(swidget, spcm, dir);
502+
if (ret)
503+
goto free_available_fmt;
504+
455505
if (dir == SNDRV_PCM_STREAM_PLAYBACK) {
456506
struct snd_sof_pcm_stream *sps = &spcm->stream[dir];
457507

0 commit comments

Comments
 (0)