Skip to content

Commit 683b54e

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: topology: Make mux/demux widget parsing IPC agnostic
Define the list of tokens pertaining to the mux/demux widgets, parse and save them as part of the swidget tuples array. Once topology parsing is complete, these tokens will be applied to create the IPC structure for the mux/demux component based on the topology widget_setup op in ipc3_tplg_ops. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20220314200520.1233427-11-ranjani.sridharan@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 30f4168 commit 683b54e

2 files changed

Lines changed: 42 additions & 42 deletions

File tree

sound/soc/sof/ipc3-topology.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,41 @@ static int sof_ipc3_widget_setup_comp_buffer(struct snd_sof_widget *swidget)
324324
return 0;
325325
}
326326

327+
/*
328+
* Mux topology
329+
*/
330+
static int sof_ipc3_widget_setup_comp_mux(struct snd_sof_widget *swidget)
331+
{
332+
struct snd_soc_component *scomp = swidget->scomp;
333+
struct sof_ipc_comp_mux *mux;
334+
size_t ipc_size = sizeof(*mux);
335+
int ret;
336+
337+
mux = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
338+
if (!mux)
339+
return -ENOMEM;
340+
341+
swidget->private = mux;
342+
343+
/* configure mux IPC message */
344+
mux->comp.type = SOF_COMP_MUX;
345+
mux->config.hdr.size = sizeof(mux->config);
346+
347+
/* parse one set of comp tokens */
348+
ret = sof_update_ipc_object(scomp, &mux->config, SOF_COMP_TOKENS,
349+
swidget->tuples, swidget->num_tuples, sizeof(mux->config), 1);
350+
if (ret < 0) {
351+
kfree(swidget->private);
352+
swidget->private = NULL;
353+
return ret;
354+
}
355+
356+
dev_dbg(scomp->dev, "loaded mux %s\n", swidget->widget->name);
357+
sof_dbg_comp_config(scomp, &mux->config);
358+
359+
return 0;
360+
}
361+
327362
/*
328363
* PGA Topology
329364
*/
@@ -430,6 +465,11 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc3_widget_ops[SND_SOC_DAPM_TY
430465
pipeline_token_list, ARRAY_SIZE(pipeline_token_list), NULL},
431466
[snd_soc_dapm_pga] = {sof_ipc3_widget_setup_comp_pga, sof_ipc3_widget_free_comp,
432467
pga_token_list, ARRAY_SIZE(pga_token_list), NULL},
468+
[snd_soc_dapm_mux] = {sof_ipc3_widget_setup_comp_mux, sof_ipc3_widget_free_comp,
469+
comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list), NULL},
470+
[snd_soc_dapm_demux] = {sof_ipc3_widget_setup_comp_mux, sof_ipc3_widget_free_comp,
471+
comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list),
472+
NULL},
433473
};
434474

435475
static const struct sof_ipc_tplg_ops ipc3_tplg_ops = {

sound/soc/sof/topology.c

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,44 +1792,6 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_s
17921792
return ret;
17931793
}
17941794

1795-
/*
1796-
* Mux topology
1797-
*/
1798-
static int sof_widget_load_mux(struct snd_soc_component *scomp, int index,
1799-
struct snd_sof_widget *swidget,
1800-
struct snd_soc_tplg_dapm_widget *tw)
1801-
{
1802-
struct snd_soc_tplg_private *private = &tw->priv;
1803-
struct sof_ipc_comp_mux *mux;
1804-
size_t ipc_size = sizeof(*mux);
1805-
int ret;
1806-
1807-
mux = (struct sof_ipc_comp_mux *)
1808-
sof_comp_alloc(swidget, &ipc_size, index);
1809-
if (!mux)
1810-
return -ENOMEM;
1811-
1812-
/* configure mux IPC message */
1813-
mux->comp.type = SOF_COMP_MUX;
1814-
mux->config.hdr.size = sizeof(mux->config);
1815-
1816-
ret = sof_parse_tokens(scomp, &mux->config, comp_tokens,
1817-
ARRAY_SIZE(comp_tokens), private->array,
1818-
le32_to_cpu(private->size));
1819-
if (ret != 0) {
1820-
dev_err(scomp->dev, "error: parse mux.cfg tokens failed %d\n",
1821-
private->size);
1822-
kfree(mux);
1823-
return ret;
1824-
}
1825-
1826-
sof_dbg_comp_config(scomp, &mux->config);
1827-
1828-
swidget->private = mux;
1829-
1830-
return 0;
1831-
}
1832-
18331795
/*
18341796
* SRC Topology
18351797
*/
@@ -2316,6 +2278,8 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
23162278
case snd_soc_dapm_scheduler:
23172279
case snd_soc_dapm_aif_out:
23182280
case snd_soc_dapm_aif_in:
2281+
case snd_soc_dapm_mux:
2282+
case snd_soc_dapm_demux:
23192283
ret = sof_widget_parse_tokens(scomp, swidget, tw, token_list, token_list_size);
23202284
break;
23212285
case snd_soc_dapm_src:
@@ -2330,10 +2294,6 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
23302294
case snd_soc_dapm_effect:
23312295
ret = sof_widget_load_process(scomp, index, swidget, tw);
23322296
break;
2333-
case snd_soc_dapm_mux:
2334-
case snd_soc_dapm_demux:
2335-
ret = sof_widget_load_mux(scomp, index, swidget, tw);
2336-
break;
23372297
case snd_soc_dapm_switch:
23382298
case snd_soc_dapm_dai_link:
23392299
case snd_soc_dapm_kcontrol:

0 commit comments

Comments
 (0)