[PATCH 12/18] ASoC: SOF: topology: make sof_route_load() IPC agnostic
Ranjani Sridharan
ranjani.sridharan at linux.intel.com
Mon Mar 7 19:11:05 CET 2022
The IPC structure can be set up using the fields in struct snd_sof_route
when the pipeline connections are established.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao at linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi at linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
---
sound/soc/sof/sof-audio.c | 15 ++++++---------
sound/soc/sof/topology.c | 17 -----------------
2 files changed, 6 insertions(+), 26 deletions(-)
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index b49d8e348077..8fccfbb339a3 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -259,28 +259,25 @@ 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_pipe_comp_connect connect;
struct sof_ipc_reply reply;
int ret;
- /* skip if there's no private data */
- if (!sroute->private)
- return 0;
-
/* nothing to do if route is already set up */
if (sroute->setup)
return 0;
- connect = sroute->private;
+ 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),
+ 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);
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 45bac1ac9fdd..bc32302f71c9 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -3323,7 +3323,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
struct snd_soc_dapm_route *route)
{
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
- struct sof_ipc_pipe_comp_connect *connect;
struct snd_sof_widget *source_swidget, *sink_swidget;
struct snd_soc_dobj *dobj = &route->dobj;
struct snd_sof_route *sroute;
@@ -3335,16 +3334,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
return -ENOMEM;
sroute->scomp = scomp;
-
- connect = kzalloc(sizeof(*connect), GFP_KERNEL);
- if (!connect) {
- kfree(sroute);
- return -ENOMEM;
- }
-
- connect->hdr.size = sizeof(*connect);
- connect->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_CONNECT;
-
dev_dbg(scomp->dev, "sink %s control %s source %s\n",
route->sink, route->control ? route->control : "none",
route->source);
@@ -3368,8 +3357,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
source_swidget->id == snd_soc_dapm_output)
goto err;
- connect->source_id = source_swidget->comp_id;
-
/* sink component */
sink_swidget = snd_sof_find_swidget(scomp, (char *)route->sink);
if (!sink_swidget) {
@@ -3387,8 +3374,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
sink_swidget->id == snd_soc_dapm_output)
goto err;
- connect->sink_id = sink_swidget->comp_id;
-
/*
* For virtual routes, both sink and source are not
* buffer. Since only buffer linked to component is supported by
@@ -3403,7 +3388,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
} else {
sroute->route = route;
dobj->private = sroute;
- sroute->private = connect;
sroute->src_widget = source_swidget;
sroute->sink_widget = sink_swidget;
@@ -3414,7 +3398,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
}
err:
- kfree(connect);
kfree(sroute);
return ret;
}
--
2.25.1
More information about the Alsa-devel
mailing list