summaryrefslogtreecommitdiffstats
path: root/sound/soc/sof/topology.c
diff options
context:
space:
mode:
authorKeyon Jie <yang.jie@linux.intel.com>2020-09-04 16:27:35 +0300
committerMark Brown <broonie@kernel.org>2020-09-07 15:16:39 +0100
commitf8ee6c9f5258ce0f7e342d7ecc63d81e45a607fe (patch)
tree64d18b5e97c5083d9c48e7608ff6fa33a0053e88 /sound/soc/sof/topology.c
parenta905bb0193e7d637bc6b6c86e87f7f9976363d07 (diff)
downloadlinux-f8ee6c9f5258ce0f7e342d7ecc63d81e45a607fe.tar.bz2
ASoC: SOF: append extended data to sof_ipc_comp_dai
Append the extended data to the end of the struct sof_ipc_comp_dai, and update the ext_data_offset, to construct the IPC for the topology load and runtime restore. 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> Link: https://lore.kernel.org/r/20200904132744.1699575-8-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/topology.c')
-rw-r--r--sound/soc/sof/topology.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 836da1a6f7cc..d8732cc5cdeb 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1506,49 +1506,57 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
{
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &tw->priv;
- struct sof_ipc_comp_dai comp_dai;
+ struct sof_ipc_comp_dai *comp_dai;
+ size_t ipc_size = sizeof(*comp_dai);
int ret;
+ comp_dai = (struct sof_ipc_comp_dai *)
+ sof_comp_alloc(swidget, &ipc_size, index, core);
+ if (!comp_dai)
+ return -ENOMEM;
+
/* configure dai IPC message */
- memset(&comp_dai, 0, sizeof(comp_dai));
- comp_dai.comp.hdr.size = sizeof(comp_dai);
- comp_dai.comp.hdr.cmd = SOF_IPC_GLB_TPLG_MSG | SOF_IPC_TPLG_COMP_NEW;
- comp_dai.comp.id = swidget->comp_id;
- comp_dai.comp.type = SOF_COMP_DAI;
- comp_dai.comp.pipeline_id = index;
- comp_dai.comp.core = core;
- comp_dai.config.hdr.size = sizeof(comp_dai.config);
-
- ret = sof_parse_tokens(scomp, &comp_dai, dai_tokens,
+ comp_dai->comp.type = SOF_COMP_DAI;
+ comp_dai->config.hdr.size = sizeof(comp_dai->config);
+
+ ret = sof_parse_tokens(scomp, comp_dai, dai_tokens,
ARRAY_SIZE(dai_tokens), private->array,
le32_to_cpu(private->size));
if (ret != 0) {
dev_err(scomp->dev, "error: parse dai tokens failed %d\n",
le32_to_cpu(private->size));
- return ret;
+ goto finish;
}
- ret = sof_parse_tokens(scomp, &comp_dai.config, comp_tokens,
+ ret = sof_parse_tokens(scomp, &comp_dai->config, comp_tokens,
ARRAY_SIZE(comp_tokens), private->array,
le32_to_cpu(private->size));
if (ret != 0) {
dev_err(scomp->dev, "error: parse dai.cfg tokens failed %d\n",
private->size);
- return ret;
+ goto finish;
}
dev_dbg(scomp->dev, "dai %s: type %d index %d\n",
- swidget->widget->name, comp_dai.type, comp_dai.dai_index);
- sof_dbg_comp_config(scomp, &comp_dai.config);
+ swidget->widget->name, comp_dai->type, comp_dai->dai_index);
+ sof_dbg_comp_config(scomp, &comp_dai->config);
- ret = sof_ipc_tx_message(sdev->ipc, comp_dai.comp.hdr.cmd,
- &comp_dai, sizeof(comp_dai), r, sizeof(*r));
+ ret = sof_ipc_tx_message(sdev->ipc, comp_dai->comp.hdr.cmd,
+ comp_dai, ipc_size, r, sizeof(*r));
if (ret == 0 && dai) {
dai->scomp = scomp;
- memcpy(&dai->comp_dai, &comp_dai, sizeof(comp_dai));
+
+ /*
+ * copy only the sof_ipc_comp_dai to avoid collapsing
+ * the snd_sof_dai, the extended data is kept in the
+ * snd_sof_widget.
+ */
+ memcpy(&dai->comp_dai, comp_dai, sizeof(*comp_dai));
}
+finish:
+ kfree(comp_dai);
return ret;
}