Commit f8ee6c9f authored by Keyon Jie's avatar Keyon Jie Committed by Mark Brown

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: default avatarKeyon Jie <yang.jie@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200904132744.1699575-8-kai.vehmanen@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a905bb01
......@@ -165,8 +165,9 @@ int sof_restore_pipelines(struct device *dev)
struct snd_sof_route *sroute;
struct sof_ipc_pipe_new *pipeline;
struct snd_sof_dai *dai;
struct sof_ipc_comp_dai *comp_dai;
struct sof_ipc_cmd_hdr *hdr;
struct sof_ipc_comp *comp;
size_t ipc_size;
int ret;
/* restore pipeline components */
......@@ -189,12 +190,24 @@ int sof_restore_pipelines(struct device *dev)
switch (swidget->id) {
case snd_soc_dapm_dai_in:
case snd_soc_dapm_dai_out:
ipc_size = sizeof(struct sof_ipc_comp_dai) +
sizeof(struct sof_ipc_comp_ext);
comp = kzalloc(ipc_size, GFP_KERNEL);
if (!comp)
return -ENOMEM;
dai = swidget->private;
comp_dai = &dai->comp_dai;
ret = sof_ipc_tx_message(sdev->ipc,
comp_dai->comp.hdr.cmd,
comp_dai, sizeof(*comp_dai),
memcpy(comp, &dai->comp_dai,
sizeof(struct sof_ipc_comp_dai));
/* append extended data to the end of the component */
memcpy((u8 *)comp + sizeof(struct sof_ipc_comp_dai),
&swidget->comp_ext, sizeof(swidget->comp_ext));
ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd,
comp, ipc_size,
&r, sizeof(r));
kfree(comp);
break;
case snd_soc_dapm_scheduler:
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment