Commit 726e6142 authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: SOF: topology: send ipc for all found DAIs in sof_set_dai_config

We may find more than one DAIs in sof_set_dai_config() and we should
send message to DSP for each DAI we found.
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200427172939.25848-2-ranjani.sridharan@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 79149fb8
...@@ -2673,7 +2673,11 @@ static void sof_dai_set_format(struct snd_soc_tplg_hw_config *hw_config, ...@@ -2673,7 +2673,11 @@ static void sof_dai_set_format(struct snd_soc_tplg_hw_config *hw_config,
} }
} }
/* set config for all DAI's with name matching the link name */ /*
* Send IPC and set the same config for all DAIs with name matching the link
* name. Note that the function can only be used for the case that all DAIs
* have a common DAI config for now.
*/
static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size,
struct snd_soc_dai_link *link, struct snd_soc_dai_link *link,
struct sof_ipc_dai_config *config) struct sof_ipc_dai_config *config)
...@@ -2686,6 +2690,19 @@ static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size, ...@@ -2686,6 +2690,19 @@ static int sof_set_dai_config(struct snd_sof_dev *sdev, u32 size,
continue; continue;
if (strcmp(link->name, dai->name) == 0) { if (strcmp(link->name, dai->name) == 0) {
struct sof_ipc_reply reply;
int ret;
/* send message to DSP */
ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd, config, size,
&reply, sizeof(reply));
if (ret < 0) {
dev_err(sdev->dev, "error: failed to set DAI config for %s index %d\n",
dai->name, config->dai_index);
return ret;
}
dai->dai_config = kmemdup(config, size, GFP_KERNEL); dai->dai_config = kmemdup(config, size, GFP_KERNEL);
if (!dai->dai_config) if (!dai->dai_config)
return -ENOMEM; return -ENOMEM;
...@@ -2718,7 +2735,6 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, ...@@ -2718,7 +2735,6 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index,
{ {
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv; struct snd_soc_tplg_private *private = &cfg->priv;
struct sof_ipc_reply reply;
u32 size = sizeof(*config); u32 size = sizeof(*config);
int ret; int ret;
...@@ -2767,17 +2783,6 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index, ...@@ -2767,17 +2783,6 @@ static int sof_link_ssp_load(struct snd_soc_component *scomp, int index,
return -EINVAL; return -EINVAL;
} }
/* send message to DSP */
ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd, config, size, &reply,
sizeof(reply));
if (ret < 0) {
dev_err(scomp->dev, "error: failed to set DAI config for SSP%d\n",
config->dai_index);
return ret;
}
/* set config for all DAI's with name matching the link name */ /* set config for all DAI's with name matching the link name */
ret = sof_set_dai_config(sdev, size, link, config); ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0) if (ret < 0)
...@@ -2795,7 +2800,6 @@ static int sof_link_sai_load(struct snd_soc_component *scomp, int index, ...@@ -2795,7 +2800,6 @@ static int sof_link_sai_load(struct snd_soc_component *scomp, int index,
{ {
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv; struct snd_soc_tplg_private *private = &cfg->priv;
struct sof_ipc_reply reply;
u32 size = sizeof(*config); u32 size = sizeof(*config);
int ret; int ret;
...@@ -2835,17 +2839,6 @@ static int sof_link_sai_load(struct snd_soc_component *scomp, int index, ...@@ -2835,17 +2839,6 @@ static int sof_link_sai_load(struct snd_soc_component *scomp, int index,
return -EINVAL; return -EINVAL;
} }
/* send message to DSP */
ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd, config, size, &reply,
sizeof(reply));
if (ret < 0) {
dev_err(scomp->dev, "error: failed to set DAI config for SAI%d\n",
config->dai_index);
return ret;
}
/* set config for all DAI's with name matching the link name */ /* set config for all DAI's with name matching the link name */
ret = sof_set_dai_config(sdev, size, link, config); ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0) if (ret < 0)
...@@ -2863,7 +2856,6 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, ...@@ -2863,7 +2856,6 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index,
{ {
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv; struct snd_soc_tplg_private *private = &cfg->priv;
struct sof_ipc_reply reply;
u32 size = sizeof(*config); u32 size = sizeof(*config);
int ret; int ret;
...@@ -2904,16 +2896,6 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index, ...@@ -2904,16 +2896,6 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index,
return -EINVAL; return -EINVAL;
} }
/* send message to DSP */
ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd, config, size, &reply,
sizeof(reply));
if (ret < 0) {
dev_err(scomp->dev, "error: failed to set DAI config for ESAI%d\n",
config->dai_index);
return ret;
}
/* set config for all DAI's with name matching the link name */ /* set config for all DAI's with name matching the link name */
ret = sof_set_dai_config(sdev, size, link, config); ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0) if (ret < 0)
...@@ -2931,7 +2913,6 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, ...@@ -2931,7 +2913,6 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index,
{ {
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv; struct snd_soc_tplg_private *private = &cfg->priv;
struct sof_ipc_reply reply;
struct sof_ipc_fw_ready *ready = &sdev->fw_ready; struct sof_ipc_fw_ready *ready = &sdev->fw_ready;
struct sof_ipc_fw_version *v = &ready->version; struct sof_ipc_fw_version *v = &ready->version;
size_t size = sizeof(*config); size_t size = sizeof(*config);
...@@ -3007,17 +2988,6 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, ...@@ -3007,17 +2988,6 @@ static int sof_link_dmic_load(struct snd_soc_component *scomp, int index,
if (SOF_ABI_VER(v->major, v->minor, v->micro) < SOF_ABI_VER(3, 0, 1)) if (SOF_ABI_VER(v->major, v->minor, v->micro) < SOF_ABI_VER(3, 0, 1))
config->dmic.fifo_bits_b = config->dmic.fifo_bits; config->dmic.fifo_bits_b = config->dmic.fifo_bits;
/* send message to DSP */
ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, size,
&reply, sizeof(reply));
if (ret < 0) {
dev_err(scomp->dev,
"error: failed to set DAI config for DMIC%d\n",
config->dai_index);
goto err;
}
/* set config for all DAI's with name matching the link name */ /* set config for all DAI's with name matching the link name */
ret = sof_set_dai_config(sdev, size, link, config); ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0) if (ret < 0)
...@@ -3142,7 +3112,6 @@ static int sof_link_alh_load(struct snd_soc_component *scomp, int index, ...@@ -3142,7 +3112,6 @@ static int sof_link_alh_load(struct snd_soc_component *scomp, int index,
{ {
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv; struct snd_soc_tplg_private *private = &cfg->priv;
struct sof_ipc_reply reply;
u32 size = sizeof(*config); u32 size = sizeof(*config);
int ret; int ret;
...@@ -3158,20 +3127,6 @@ static int sof_link_alh_load(struct snd_soc_component *scomp, int index, ...@@ -3158,20 +3127,6 @@ static int sof_link_alh_load(struct snd_soc_component *scomp, int index,
/* init IPC */ /* init IPC */
config->hdr.size = size; config->hdr.size = size;
dev_dbg(scomp->dev, "ALH config rate %d channels %d\n",
config->alh.rate, config->alh.channels);
/* send message to DSP */
ret = sof_ipc_tx_message(sdev->ipc,
config->hdr.cmd, config, size, &reply,
sizeof(reply));
if (ret < 0) {
dev_err(scomp->dev, "error: failed to set DAI config for ALH %d\n",
config->dai_index);
return ret;
}
/* set config for all DAI's with name matching the link name */ /* set config for all DAI's with name matching the link name */
ret = sof_set_dai_config(sdev, size, link, config); ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0) if (ret < 0)
......
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