Skip to content

Commit 85ec856

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: topology: Make route setup IPC agnostic
Define and set the route_setup op for IPC3 topology ops and use it for setting up routes. 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-16-ranjani.sridharan@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f2cf24a commit 85ec856

File tree

2 files changed

+40
-34
lines changed

2 files changed

+40
-34
lines changed

sound/soc/sof/ipc3-topology.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,31 @@ static int sof_widget_update_ipc_comp_process(struct snd_sof_widget *swidget)
797797
return sof_process_load(scomp, swidget, find_process_comp_type(config.type));
798798
}
799799

800+
static int sof_ipc3_route_setup(struct snd_sof_dev *sdev, struct snd_sof_route *sroute)
801+
{
802+
struct sof_ipc_pipe_comp_connect connect;
803+
struct sof_ipc_reply reply;
804+
int ret;
805+
806+
connect.hdr.size = sizeof(connect);
807+
connect.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT;
808+
connect.source_id = sroute->src_widget->comp_id;
809+
connect.sink_id = sroute->sink_widget->comp_id;
810+
811+
dev_dbg(sdev->dev, "setting up route %s -> %s\n",
812+
sroute->src_widget->widget->name,
813+
sroute->sink_widget->widget->name);
814+
815+
/* send ipc */
816+
ret = sof_ipc_tx_message(sdev->ipc, connect.hdr.cmd, &connect, sizeof(connect),
817+
&reply, sizeof(reply));
818+
if (ret < 0)
819+
dev_err(sdev->dev, "%s: route %s -> %s failed\n", __func__,
820+
sroute->src_widget->widget->name, sroute->sink_widget->widget->name);
821+
822+
return ret;
823+
}
824+
800825
/* token list for each topology object */
801826
static enum sof_tokens host_token_list[] = {
802827
SOF_CORE_TOKENS,
@@ -882,6 +907,7 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc3_widget_ops[SND_SOC_DAPM_TY
882907

883908
static const struct sof_ipc_tplg_ops ipc3_tplg_ops = {
884909
.widget = tplg_ipc3_widget_ops,
910+
.route_setup = sof_ipc3_route_setup,
885911
.token_list = ipc3_token_list,
886912
};
887913

sound/soc/sof/sof-audio.c

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -263,45 +263,15 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
263263
}
264264
EXPORT_SYMBOL(sof_widget_setup);
265265

266-
static int sof_route_setup_ipc(struct snd_sof_dev *sdev, struct snd_sof_route *sroute)
267-
{
268-
struct sof_ipc_pipe_comp_connect connect;
269-
struct sof_ipc_reply reply;
270-
int ret;
271-
272-
/* nothing to do if route is already set up */
273-
if (sroute->setup)
274-
return 0;
275-
276-
connect.hdr.size = sizeof(connect);
277-
connect.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT;
278-
connect.source_id = sroute->src_widget->comp_id;
279-
connect.sink_id = sroute->sink_widget->comp_id;
280-
281-
dev_dbg(sdev->dev, "setting up route %s -> %s\n",
282-
sroute->src_widget->widget->name,
283-
sroute->sink_widget->widget->name);
284-
285-
/* send ipc */
286-
ret = sof_ipc_tx_message(sdev->ipc, connect.hdr.cmd, &connect, sizeof(connect),
287-
&reply, sizeof(reply));
288-
if (ret < 0) {
289-
dev_err(sdev->dev, "%s: route setup failed %d\n", __func__, ret);
290-
return ret;
291-
}
292-
293-
sroute->setup = true;
294-
295-
return 0;
296-
}
297-
298266
static int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsource,
299267
struct snd_soc_dapm_widget *wsink)
300268
{
269+
const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg;
301270
struct snd_sof_widget *src_widget = wsource->dobj.private;
302271
struct snd_sof_widget *sink_widget = wsink->dobj.private;
303272
struct snd_sof_route *sroute;
304273
bool route_found = false;
274+
int ret;
305275

306276
/* ignore routes involving virtual widgets in topology */
307277
switch (src_widget->id) {
@@ -335,7 +305,16 @@ static int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget
335305
return -EINVAL;
336306
}
337307

338-
return sof_route_setup_ipc(sdev, sroute);
308+
/* nothing to do if route is already set up */
309+
if (sroute->setup)
310+
return 0;
311+
312+
ret = ipc_tplg_ops->route_setup(sdev, sroute);
313+
if (ret < 0)
314+
return ret;
315+
316+
sroute->setup = true;
317+
return 0;
339318
}
340319

341320
static int sof_setup_pipeline_connections(struct snd_sof_dev *sdev,
@@ -604,6 +583,7 @@ int sof_set_hw_params_upon_resume(struct device *dev)
604583

605584
int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)
606585
{
586+
const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg;
607587
struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
608588
struct snd_sof_widget *swidget;
609589
struct snd_sof_route *sroute;
@@ -656,7 +636,7 @@ int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)
656636
sroute->sink_widget->dynamic_pipeline_widget))
657637
continue;
658638

659-
ret = sof_route_setup_ipc(sdev, sroute);
639+
ret = ipc_tplg_ops->route_setup(sdev, sroute);
660640
if (ret < 0) {
661641
dev_err(sdev->dev, "%s: restore pipeline connections failed\n", __func__);
662642
return ret;

0 commit comments

Comments
 (0)