Commit d88cbd6f authored by Guido Roncarolo's avatar Guido Roncarolo Committed by Mark Brown

ASoC: SOF: imx: Read SAI parameters and send them to DSP

Follow example from Intel SSP.
Signed-off-by: default avatarGuido Roncarolo <guido.roncarolo@nxp.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191218002616.7652-9-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9c1d4cf6
......@@ -693,6 +693,14 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
channels->min = dai->dai_config->esai.tdm_slots;
channels->max = dai->dai_config->esai.tdm_slots;
dev_dbg(component->dev,
"channels_min: %d channels_max: %d\n",
channels->min, channels->max);
break;
case SOF_DAI_IMX_SAI:
channels->min = dai->dai_config->sai.tdm_slots;
channels->max = dai->dai_config->sai.tdm_slots;
dev_dbg(component->dev,
"channels_min: %d channels_max: %d\n",
channels->min, channels->max);
......
......@@ -695,6 +695,13 @@ static const struct sof_topology_token esai_tokens[] = {
offsetof(struct sof_ipc_dai_esai_params, mclk_id), 0},
};
/* SAI */
static const struct sof_topology_token sai_tokens[] = {
{SOF_TKN_IMX_SAI_MCLK_ID,
SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
offsetof(struct sof_ipc_dai_sai_params, mclk_id), 0},
};
/*
* DMIC PDM Tokens
* SOF_TKN_INTEL_DMIC_PDM_CTRL_ID should be the first token
......@@ -2704,8 +2711,66 @@ static int sof_link_sai_load(struct snd_soc_component *scomp, int index,
struct snd_soc_tplg_hw_config *hw_config,
struct sof_ipc_dai_config *config)
{
/*TODO: Add implementation */
return 0;
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_soc_tplg_private *private = &cfg->priv;
struct sof_ipc_reply reply;
u32 size = sizeof(*config);
int ret;
/* handle master/slave and inverted clocks */
sof_dai_set_format(hw_config, config);
/* init IPC */
memset(&config->sai, 0, sizeof(struct sof_ipc_dai_sai_params));
config->hdr.size = size;
ret = sof_parse_tokens(scomp, &config->sai, sai_tokens,
ARRAY_SIZE(sai_tokens), private->array,
le32_to_cpu(private->size));
if (ret != 0) {
dev_err(scomp->dev, "error: parse sai tokens failed %d\n",
le32_to_cpu(private->size));
return ret;
}
config->sai.mclk_rate = le32_to_cpu(hw_config->mclk_rate);
config->sai.mclk_direction = hw_config->mclk_direction;
config->sai.tdm_slots = le32_to_cpu(hw_config->tdm_slots);
config->sai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width);
config->sai.rx_slots = le32_to_cpu(hw_config->rx_slots);
config->sai.tx_slots = le32_to_cpu(hw_config->tx_slots);
dev_info(scomp->dev,
"tplg: config SAI%d fmt 0x%x mclk %d width %d slots %d mclk id %d\n",
config->dai_index, config->format,
config->sai.mclk_rate, config->sai.tdm_slot_width,
config->sai.tdm_slots, config->sai.mclk_id);
if (config->sai.tdm_slots < 1 || config->sai.tdm_slots > 8) {
dev_err(scomp->dev, "error: invalid channel count for SAI%d\n",
config->dai_index);
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 */
ret = sof_set_dai_config(sdev, size, link, config);
if (ret < 0)
dev_err(scomp->dev, "error: failed to save DAI config for SAI%d\n",
config->dai_index);
return ret;
}
static int sof_link_esai_load(struct snd_soc_component *scomp, int index,
......
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