All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: kai.vehmanen@linux.intel.com,
	Keyon Jie <yang.jie@linux.intel.com>,
	lgirdwood@gmail.com, pierre-louis.bossart@linux.intel.com,
	ranjani.sridharan@linux.intel.com, daniel.baluta@nxp.com
Subject: [PATCH 06/16] ASoC: SOF: topology: add helper for setting up IPC component
Date: Fri,  4 Sep 2020 16:27:34 +0300	[thread overview]
Message-ID: <20200904132744.1699575-7-kai.vehmanen@linux.intel.com> (raw)
In-Reply-To: <20200904132744.1699575-1-kai.vehmanen@linux.intel.com>

From: Keyon Jie <yang.jie@linux.intel.com>

Add helper to allocate buffer for IPC component, configure the basic
settings, and set up the extended data for the subsequent IPC sending.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/soc/sof/topology.c | 45 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 7d1013e315fc..836da1a6f7cc 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1453,6 +1453,51 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
 	return 0;
 }
 
+/**
+ * sof_comp_alloc - allocate and initialize buffer for a new component
+ * @swidget: pointer to struct snd_sof_widget containing extended data
+ * @ipc_size: IPC payload size that will be updated depending on valid
+ *  extended data.
+ * @index: ID of the pipeline the component belongs to
+ * @core: index of the DSP core that the component should run on
+ *
+ * Return: The pointer to the new allocated component, NULL if failed.
+ */
+static struct sof_ipc_comp *sof_comp_alloc(struct snd_sof_widget *swidget,
+					   size_t *ipc_size, int index,
+					   int core)
+{
+	u8 nil_uuid[SOF_UUID_SIZE] = {0};
+	struct sof_ipc_comp *comp;
+	size_t total_size = *ipc_size;
+
+	/* only non-zero UUID is valid */
+	if (memcmp(&swidget->comp_ext, nil_uuid, SOF_UUID_SIZE))
+		total_size += sizeof(swidget->comp_ext);
+
+	comp = kzalloc(total_size, GFP_KERNEL);
+	if (!comp)
+		return NULL;
+
+	/* configure comp new IPC message */
+	comp->hdr.size = total_size;
+	comp->hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_NEW;
+	comp->id = swidget->comp_id;
+	comp->pipeline_id = index;
+	comp->core = core;
+
+	/* handle the extended data if needed */
+	if (total_size > *ipc_size) {
+		/* append extended data to the end of the component */
+		memcpy((u8 *)comp + *ipc_size, &swidget->comp_ext, sizeof(swidget->comp_ext));
+		comp->ext_data_length = sizeof(swidget->comp_ext);
+	}
+
+	/* update ipc_size and return */
+	*ipc_size = total_size;
+	return comp;
+}
+
 static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
 			       struct snd_sof_widget *swidget, int core,
 			       struct snd_soc_tplg_dapm_widget *tw,
-- 
2.27.0


  parent reply	other threads:[~2020-09-04 13:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 13:27 [PATCH 00/16] ASoC: SOF: component UUID support for 5.10 Kai Vehmanen
2020-09-04 13:27 ` [PATCH 01/16] ASoC: SOF: tokens: add token for component UUID Kai Vehmanen
2020-09-04 13:27 ` [PATCH 02/16] ASoC: SOF: add comp_ext to struct snd_sof_widget Kai Vehmanen
2020-09-04 13:27 ` [PATCH 03/16] ASoC: SOF: topology: create component extended tokens Kai Vehmanen
2020-09-04 13:27 ` [PATCH 04/16] ASoC: SOF: topology: parse comp_ext_tokens for all widgets Kai Vehmanen
2020-09-04 13:27 ` [PATCH 05/16] ASoC: SOF: use the sof_ipc_comp reserved bytes for extended data Kai Vehmanen
2020-09-04 13:27 ` Kai Vehmanen [this message]
2020-09-04 13:27 ` [PATCH 07/16] ASoC: SOF: append extended data to sof_ipc_comp_dai Kai Vehmanen
2020-09-04 13:27 ` [PATCH 08/16] ASoC: SOF: append extended data to sof_ipc_comp_mixer Kai Vehmanen
2020-09-04 13:27 ` [PATCH 09/16] ASoC: SOF: append extended data to sof_ipc_comp_volume Kai Vehmanen
2020-09-04 13:27 ` [PATCH 10/16] ASoC: SOF: append extended data to sof_ipc_comp_host Kai Vehmanen
2020-09-04 13:27 ` [PATCH 11/16] ASoC: SOF: append extended data to sof_ipc_comp_src Kai Vehmanen
2020-09-04 13:27 ` [PATCH 12/16] ASoC: SOF: append extended data to sof_ipc_comp_asrc Kai Vehmanen
2020-09-04 13:27 ` [PATCH 13/16] ASoC: SOF: append extended data to sof_ipc_comp_tone Kai Vehmanen
2020-09-04 13:27 ` [PATCH 14/16] ASoC: SOF: append extended data to sof_ipc_comp_process Kai Vehmanen
2020-09-04 13:27 ` [PATCH 15/16] ASoC: SOF: append extended data to sof_ipc_comp_mux Kai Vehmanen
2020-09-04 13:27 ` [PATCH 16/16] ASoC: SOF: topology: make process type optional Kai Vehmanen
2020-09-07 18:05 ` [PATCH 00/16] ASoC: SOF: component UUID support for 5.10 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=20200904132744.1699575-7-kai.vehmanen@linux.intel.com \
    --to=kai.vehmanen@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=lgirdwood@gmail.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=yang.jie@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.