All of 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.com,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
	broonie@kernel.org, "Bard Liao" <yung-chuan.liao@linux.intel.com>
Subject: [PATCH 09/18] ASoC: SOF: topology: Make mux/demux widget parsing IPC agnostic
Date: Mon, 14 Mar 2022 13:05:11 -0700	[thread overview]
Message-ID: <20220314200520.1233427-11-ranjani.sridharan@linux.intel.com> (raw)
In-Reply-To: <20220314200520.1233427-1-ranjani.sridharan@linux.intel.com>

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>
---
 sound/soc/sof/ipc3-topology.c | 40 +++++++++++++++++++++++++++++++
 sound/soc/sof/topology.c      | 44 ++---------------------------------
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/sound/soc/sof/ipc3-topology.c b/sound/soc/sof/ipc3-topology.c
index d8a91f461bf9..5501a18babaf 100644
--- a/sound/soc/sof/ipc3-topology.c
+++ b/sound/soc/sof/ipc3-topology.c
@@ -324,6 +324,41 @@ static int sof_ipc3_widget_setup_comp_buffer(struct snd_sof_widget *swidget)
 	return 0;
 }
 
+/*
+ * Mux topology
+ */
+static int sof_ipc3_widget_setup_comp_mux(struct snd_sof_widget *swidget)
+{
+	struct snd_soc_component *scomp = swidget->scomp;
+	struct sof_ipc_comp_mux *mux;
+	size_t ipc_size = sizeof(*mux);
+	int ret;
+
+	mux = sof_comp_alloc(swidget, &ipc_size, swidget->pipeline_id);
+	if (!mux)
+		return -ENOMEM;
+
+	swidget->private = mux;
+
+	/* configure mux IPC message */
+	mux->comp.type = SOF_COMP_MUX;
+	mux->config.hdr.size = sizeof(mux->config);
+
+	/* parse one set of comp tokens */
+	ret = sof_update_ipc_object(scomp, &mux->config, SOF_COMP_TOKENS,
+				    swidget->tuples, swidget->num_tuples, sizeof(mux->config), 1);
+	if (ret < 0) {
+		kfree(swidget->private);
+		swidget->private = NULL;
+		return ret;
+	}
+
+	dev_dbg(scomp->dev, "loaded mux %s\n", swidget->widget->name);
+	sof_dbg_comp_config(scomp, &mux->config);
+
+	return 0;
+}
+
 /*
  * PGA Topology
  */
@@ -430,6 +465,11 @@ static const struct sof_ipc_tplg_widget_ops tplg_ipc3_widget_ops[SND_SOC_DAPM_TY
 				    pipeline_token_list, ARRAY_SIZE(pipeline_token_list), NULL},
 	[snd_soc_dapm_pga] = {sof_ipc3_widget_setup_comp_pga, sof_ipc3_widget_free_comp,
 			      pga_token_list, ARRAY_SIZE(pga_token_list), NULL},
+	[snd_soc_dapm_mux] = {sof_ipc3_widget_setup_comp_mux, sof_ipc3_widget_free_comp,
+			      comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list), NULL},
+	[snd_soc_dapm_demux] = {sof_ipc3_widget_setup_comp_mux, sof_ipc3_widget_free_comp,
+				 comp_generic_token_list, ARRAY_SIZE(comp_generic_token_list),
+				 NULL},
 };
 
 static const struct sof_ipc_tplg_ops ipc3_tplg_ops = {
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 9e9a41018458..42da7b8e7180 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1792,44 +1792,6 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_s
 	return ret;
 }
 
-/*
- * Mux topology
- */
-static int sof_widget_load_mux(struct snd_soc_component *scomp, int index,
-			       struct snd_sof_widget *swidget,
-			       struct snd_soc_tplg_dapm_widget *tw)
-{
-	struct snd_soc_tplg_private *private = &tw->priv;
-	struct sof_ipc_comp_mux *mux;
-	size_t ipc_size = sizeof(*mux);
-	int ret;
-
-	mux = (struct sof_ipc_comp_mux *)
-	      sof_comp_alloc(swidget, &ipc_size, index);
-	if (!mux)
-		return -ENOMEM;
-
-	/* configure mux IPC message */
-	mux->comp.type = SOF_COMP_MUX;
-	mux->config.hdr.size = sizeof(mux->config);
-
-	ret = sof_parse_tokens(scomp, &mux->config, comp_tokens,
-			       ARRAY_SIZE(comp_tokens), private->array,
-			       le32_to_cpu(private->size));
-	if (ret != 0) {
-		dev_err(scomp->dev, "error: parse mux.cfg tokens failed %d\n",
-			private->size);
-		kfree(mux);
-		return ret;
-	}
-
-	sof_dbg_comp_config(scomp, &mux->config);
-
-	swidget->private = mux;
-
-	return 0;
-}
-
 /*
  * SRC Topology
  */
@@ -2316,6 +2278,8 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
 	case snd_soc_dapm_scheduler:
 	case snd_soc_dapm_aif_out:
 	case snd_soc_dapm_aif_in:
+	case snd_soc_dapm_mux:
+	case snd_soc_dapm_demux:
 		ret = sof_widget_parse_tokens(scomp, swidget, tw,  token_list, token_list_size);
 		break;
 	case snd_soc_dapm_src:
@@ -2330,10 +2294,6 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
 	case snd_soc_dapm_effect:
 		ret = sof_widget_load_process(scomp, index, swidget, tw);
 		break;
-	case snd_soc_dapm_mux:
-	case snd_soc_dapm_demux:
-		ret = sof_widget_load_mux(scomp, index, swidget, tw);
-		break;
 	case snd_soc_dapm_switch:
 	case snd_soc_dapm_dai_link:
 	case snd_soc_dapm_kcontrol:
-- 
2.25.1


  parent reply	other threads:[~2022-03-14 20:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 20:05 [PATCH 00/18] Introduce IPC abstraction for SOF topology parsing Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 01/18] ASoC: SOF: Introduce struct snd_sof_dai_link Ranjani Sridharan
2022-03-14 20:05 ` [PATCH] ASoC: SOF: IPC4-tooplogy: Add ccore tokens Ranjani Sridharan
2022-03-14 20:07   ` Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 02/18] ASoC: SOF: IPC: Introduce IPC ops Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 03/18] ASoC: SOF: topology: Add helper function for processing tuple arrays Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 04/18] ASoC: SOF: Introduce IPC3 ops Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 05/18] ASoC: SOF: topology: Make scheduler widget parsing IPC agnostic Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 06/18] ASoC: SOF: topology: Make buffer " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 07/18] ASoC: SOF: topology: Make pga " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 08/18] ASoC: SOF: topology: Make mixer " Ranjani Sridharan
2022-03-14 20:05 ` Ranjani Sridharan [this message]
2022-03-14 20:05 ` [PATCH 10/18] ASoC: SOF: topology: Make src " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 11/18] ASoC: SOF: topology: Make asrc " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 12/18] ASoC: SOF: topology: Make siggen " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 13/18] ASoC: SOF: topology: Make effect " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 14/18] ASoC: SOF: topology: Make route setup " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 15/18] ASoC: SOF: topology: Make DAI widget parsing " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 16/18] ASoC: SOF: topology: Make control " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 17/18] ASoC: SOF: topology: Make widget binding " Ranjani Sridharan
2022-03-14 20:05 ` [PATCH 18/18] ASoC: SOF: topology: remove snd_sof_complete_pipeline() Ranjani Sridharan
2022-03-16 20:36 ` [PATCH 00/18] Introduce IPC abstraction for SOF topology parsing 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=20220314200520.1233427-11-ranjani.sridharan@linux.intel.com \
    --to=ranjani.sridharan@linux.intel.com \
    --cc==tiwai@suse.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.