diff options
author | Ranjani Sridharan <ranjani.sridharan@linux.intel.com> | 2022-03-14 23:05:16 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2022-03-16 19:39:09 +0300 |
commit | 85ec8560893cb9aae2728dd12f59537b6247d91f (patch) | |
tree | 9658f7c2cb6bd854537541a4202d0325a4ecae8f /sound/soc | |
parent | f2cf24a1afa836be44dd2abdf7896b236df8d9a2 (diff) | |
download | linux-85ec8560893cb9aae2728dd12f59537b6247d91f.tar.xz |
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>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/sof/ipc3-topology.c | 26 | ||||
-rw-r--r-- | sound/soc/sof/sof-audio.c | 48 |
2 files changed, 40 insertions, 34 deletions
diff --git a/sound/soc/sof/ipc3-topology.c b/sound/soc/sof/ipc3-topology.c index b710129374c8..a9d55c1d1f84 100644 --- a/sound/soc/sof/ipc3-topology.c +++ b/sound/soc/sof/ipc3-topology.c @@ -797,6 +797,31 @@ static int sof_widget_update_ipc_comp_process(struct snd_sof_widget *swidget) return sof_process_load(scomp, swidget, find_process_comp_type(config.type)); } +static int sof_ipc3_route_setup(struct snd_sof_dev *sdev, struct snd_sof_route *sroute) +{ + struct sof_ipc_pipe_comp_connect connect; + struct sof_ipc_reply reply; + int ret; + + connect.hdr.size = sizeof(connect); + connect.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT; + connect.source_id = sroute->src_widget->comp_id; + connect.sink_id = sroute->sink_widget->comp_id; + + dev_dbg(sdev->dev, "setting up route %s -> %s\n", + sroute->src_widget->widget->name, + sroute->sink_widget->widget->name); + + /* send ipc */ + ret = sof_ipc_tx_message(sdev->ipc, connect.hdr.cmd, &connect, sizeof(connect), + &reply, sizeof(reply)); + if (ret < 0) + dev_err(sdev->dev, "%s: route %s -> %s failed\n", __func__, + sroute->src_widget->widget->name, sroute->sink_widget->widget->name); + + return ret; +} + /* token list for each topology object */ static enum sof_tokens host_token_list[] = { SOF_CORE_TOKENS, @@ -882,6 +907,7 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc3_widget_ops[SND_SOC_DAPM_TY static const struct sof_ipc_tplg_ops ipc3_tplg_ops = { .widget = tplg_ipc3_widget_ops, + .route_setup = sof_ipc3_route_setup, .token_list = ipc3_token_list, }; diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 15c36a51f89f..c02dcad03b23 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -263,45 +263,15 @@ use_count_dec: } EXPORT_SYMBOL(sof_widget_setup); -static int sof_route_setup_ipc(struct snd_sof_dev *sdev, struct snd_sof_route *sroute) -{ - struct sof_ipc_pipe_comp_connect connect; - struct sof_ipc_reply reply; - int ret; - - /* nothing to do if route is already set up */ - if (sroute->setup) - return 0; - - connect.hdr.size = sizeof(connect); - connect.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT; - connect.source_id = sroute->src_widget->comp_id; - connect.sink_id = sroute->sink_widget->comp_id; - - dev_dbg(sdev->dev, "setting up route %s -> %s\n", - sroute->src_widget->widget->name, - sroute->sink_widget->widget->name); - - /* send ipc */ - ret = sof_ipc_tx_message(sdev->ipc, connect.hdr.cmd, &connect, sizeof(connect), - &reply, sizeof(reply)); - if (ret < 0) { - dev_err(sdev->dev, "%s: route setup failed %d\n", __func__, ret); - return ret; - } - - sroute->setup = true; - - return 0; -} - static int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsource, struct snd_soc_dapm_widget *wsink) { + const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg; struct snd_sof_widget *src_widget = wsource->dobj.private; struct snd_sof_widget *sink_widget = wsink->dobj.private; struct snd_sof_route *sroute; bool route_found = false; + int ret; /* ignore routes involving virtual widgets in topology */ switch (src_widget->id) { @@ -335,7 +305,16 @@ static int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget return -EINVAL; } - return sof_route_setup_ipc(sdev, sroute); + /* nothing to do if route is already set up */ + if (sroute->setup) + return 0; + + ret = ipc_tplg_ops->route_setup(sdev, sroute); + if (ret < 0) + return ret; + + sroute->setup = true; + return 0; } 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) int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify) { + const struct sof_ipc_tplg_ops *ipc_tplg_ops = sdev->ipc->ops->tplg; struct sof_ipc_fw_version *v = &sdev->fw_ready.version; struct snd_sof_widget *swidget; struct snd_sof_route *sroute; @@ -656,7 +636,7 @@ int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify) sroute->sink_widget->dynamic_pipeline_widget)) continue; - ret = sof_route_setup_ipc(sdev, sroute); + ret = ipc_tplg_ops->route_setup(sdev, sroute); if (ret < 0) { dev_err(sdev->dev, "%s: restore pipeline connections failed\n", __func__); return ret; |