Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, "Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	broonie@kernel.org,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
Subject: [PATCH 12/18] ASoC: SOF: topology: make sof_route_load() IPC agnostic
Date: Mon,  7 Mar 2022 10:11:05 -0800	[thread overview]
Message-ID: <20220307181111.49392-13-ranjani.sridharan@linux.intel.com> (raw)
In-Reply-To: <20220307181111.49392-1-ranjani.sridharan@linux.intel.com>

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@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>
---
 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


  parent reply	other threads:[~2022-03-07 18:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 18:10 [PATCH 00/18] Clean ups and preparation for IPC abstraction in the SOF driver Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 01/18] ASoC: SOF: remove snd_sof_pipeline_find() Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 02/18] ASoC: SOF: simplify snd_sof_device_remove() Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 03/18] ASoC: SOF: set swidget's core for scheduler widget Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 04/18] ASoC: SOF: sof-audio: removed unused function Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 05/18] ASoC: SOF: topology: remove redundant code Ranjani Sridharan
2022-03-07 18:10 ` [PATCH 06/18] ASoC: SOF: topology: remove redundant code in sof_link_afe_load() Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 07/18] ASoC: SOF: topology: Drop the size parameter from struct sof_topology_token Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 08/18] ASoC: SOF: topology: Modify the get_token op for string tokens Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 09/18] ASoC: SOF: topology: expose some get_token ops Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 10/18] ASoC: SOF: change comp_dai to a pointer in struct snd_sof_dai Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 11/18] ASoC: SOF: make struct snd_sof_widget IPC agnostic Ranjani Sridharan
2022-03-07 18:55   ` Amadeusz Sławiński
2022-03-07 19:51     ` Ranjani Sridharan
2022-03-07 18:11 ` Ranjani Sridharan [this message]
2022-03-07 18:11 ` [PATCH 13/18] ASoC: SOF: Add a tuples array to struct snd_sof_widget Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 14/18] ASoC: SOF: topology: Modify signature for token parsing functions Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 15/18] ASoC: SOF: topology: Rename arguments in sof_parse_token_sets() Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 16/18] ASoC: SOF: topology: Rename arguments in sof_parse_tokens() Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 17/18] ASoC: SOF: make struct snd_sof_dai IPC agnostic Ranjani Sridharan
2022-03-07 18:11 ` [PATCH 18/18] ASoC: SOF: move definition of snd_sof_ipc to header file Ranjani Sridharan
2022-03-08 17:20 ` [PATCH 00/18] Clean ups and preparation for IPC abstraction in the SOF driver Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220307181111.49392-13-ranjani.sridharan@linux.intel.com \
    --to=ranjani.sridharan@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox