Commit 689614ce authored by Ajit Kumar Pandey's avatar Ajit Kumar Pandey Committed by Mark Brown

ASoC: SOF: topology: add code to parse config params for ACPDMIC dai

Add sof_ipc_dai_acpdmic_params and tokens to parse dmic channels and
rate params from topology file
Signed-off-by: default avatarAjit Kumar Pandey <AjitKumar.Pandey@amd.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220614075251.21499-1-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f7309dbe
...@@ -18,4 +18,11 @@ struct sof_ipc_dai_acp_params { ...@@ -18,4 +18,11 @@ struct sof_ipc_dai_acp_params {
uint32_t fsync_rate; /* FSYNC frequency in Hz */ uint32_t fsync_rate; /* FSYNC frequency in Hz */
uint32_t tdm_slots; uint32_t tdm_slots;
} __packed; } __packed;
/* ACPDMIC Configuration Request - SOF_IPC_DAI_AMD_CONFIG */
struct sof_ipc_dai_acpdmic_params {
uint32_t pdm_rate;
uint32_t pdm_ch;
} __packed;
#endif #endif
...@@ -111,7 +111,7 @@ struct sof_ipc_dai_config { ...@@ -111,7 +111,7 @@ struct sof_ipc_dai_config {
struct sof_ipc_dai_sai_params sai; struct sof_ipc_dai_sai_params sai;
struct sof_ipc_dai_acp_params acpbt; struct sof_ipc_dai_acp_params acpbt;
struct sof_ipc_dai_acp_params acpsp; struct sof_ipc_dai_acp_params acpsp;
struct sof_ipc_dai_acp_params acpdmic; struct sof_ipc_dai_acpdmic_params acpdmic;
struct sof_ipc_dai_mtk_afe_params afe; struct sof_ipc_dai_mtk_afe_params afe;
}; };
} __packed; } __packed;
......
...@@ -157,6 +157,10 @@ ...@@ -157,6 +157,10 @@
/* MIXER */ /* MIXER */
#define SOF_TKN_MIXER_TYPE 1700 #define SOF_TKN_MIXER_TYPE 1700
/* ACPDMIC */
#define SOF_TKN_AMD_ACPDMIC_RATE 1800
#define SOF_TKN_AMD_ACPDMIC_CH 1801
/* CAVS AUDIO FORMAT */ /* CAVS AUDIO FORMAT */
#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_RATE 1900 #define SOF_TKN_CAVS_AUDIO_FORMAT_IN_RATE 1900
#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_BIT_DEPTH 1901 #define SOF_TKN_CAVS_AUDIO_FORMAT_IN_BIT_DEPTH 1901
......
...@@ -344,10 +344,10 @@ static int sof_ipc3_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, ...@@ -344,10 +344,10 @@ static int sof_ipc3_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
channels->min, channels->max); channels->min, channels->max);
break; break;
case SOF_DAI_AMD_DMIC: case SOF_DAI_AMD_DMIC:
rate->min = private->dai_config->acpdmic.fsync_rate; rate->min = private->dai_config->acpdmic.pdm_rate;
rate->max = private->dai_config->acpdmic.fsync_rate; rate->max = private->dai_config->acpdmic.pdm_rate;
channels->min = private->dai_config->acpdmic.tdm_slots; channels->min = private->dai_config->acpdmic.pdm_ch;
channels->max = private->dai_config->acpdmic.tdm_slots; channels->max = private->dai_config->acpdmic.pdm_ch;
dev_dbg(component->dev, dev_dbg(component->dev,
"AMD_DMIC rate_min: %d rate_max: %d\n", rate->min, rate->max); "AMD_DMIC rate_min: %d rate_max: %d\n", rate->min, rate->max);
......
...@@ -266,6 +266,16 @@ static const struct sof_topology_token afe_tokens[] = { ...@@ -266,6 +266,16 @@ static const struct sof_topology_token afe_tokens[] = {
offsetof(struct sof_ipc_dai_mtk_afe_params, format)}, offsetof(struct sof_ipc_dai_mtk_afe_params, format)},
}; };
/* ACPDMIC */
static const struct sof_topology_token acpdmic_tokens[] = {
{SOF_TKN_AMD_ACPDMIC_RATE,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct sof_ipc_dai_acpdmic_params, pdm_rate)},
{SOF_TKN_AMD_ACPDMIC_CH,
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
offsetof(struct sof_ipc_dai_acpdmic_params, pdm_ch)},
};
/* Core tokens */ /* Core tokens */
static const struct sof_topology_token core_tokens[] = { static const struct sof_topology_token core_tokens[] = {
{SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, {SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
...@@ -300,6 +310,7 @@ static const struct sof_token_info ipc3_token_list[SOF_TOKEN_COUNT] = { ...@@ -300,6 +310,7 @@ static const struct sof_token_info ipc3_token_list[SOF_TOKEN_COUNT] = {
[SOF_ESAI_TOKENS] = {"ESAI tokens", esai_tokens, ARRAY_SIZE(esai_tokens)}, [SOF_ESAI_TOKENS] = {"ESAI tokens", esai_tokens, ARRAY_SIZE(esai_tokens)},
[SOF_SAI_TOKENS] = {"SAI tokens", sai_tokens, ARRAY_SIZE(sai_tokens)}, [SOF_SAI_TOKENS] = {"SAI tokens", sai_tokens, ARRAY_SIZE(sai_tokens)},
[SOF_AFE_TOKENS] = {"AFE tokens", afe_tokens, ARRAY_SIZE(afe_tokens)}, [SOF_AFE_TOKENS] = {"AFE tokens", afe_tokens, ARRAY_SIZE(afe_tokens)},
[SOF_ACPDMIC_TOKENS] = {"ACPDMIC tokens", acpdmic_tokens, ARRAY_SIZE(acpdmic_tokens)},
}; };
/** /**
...@@ -1120,20 +1131,22 @@ static int sof_link_acp_dmic_load(struct snd_soc_component *scomp, struct snd_so ...@@ -1120,20 +1131,22 @@ static int sof_link_acp_dmic_load(struct snd_soc_component *scomp, struct snd_so
struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
struct sof_dai_private_data *private = dai->private; struct sof_dai_private_data *private = dai->private;
u32 size = sizeof(*config); u32 size = sizeof(*config);
int ret;
/* handle master/slave and inverted clocks */ /* handle master/slave and inverted clocks */
sof_dai_set_format(hw_config, config); sof_dai_set_format(hw_config, config);
/* init IPC */
memset(&config->acpdmic, 0, sizeof(config->acpdmic));
config->hdr.size = size; config->hdr.size = size;
config->acpdmic.fsync_rate = le32_to_cpu(hw_config->fsync_rate); /* parse the required set of ACPDMIC tokens based on num_hw_cfgs */
config->acpdmic.tdm_slots = le32_to_cpu(hw_config->tdm_slots); ret = sof_update_ipc_object(scomp, &config->acpdmic, SOF_ACPDMIC_TOKENS, slink->tuples,
slink->num_tuples, size, slink->num_hw_configs);
if (ret < 0)
return ret;
dev_info(scomp->dev, "ACP_DMIC config ACP%d channel %d rate %d\n", dev_info(scomp->dev, "ACP_DMIC config ACP%d channel %d rate %d\n",
config->dai_index, config->acpdmic.tdm_slots, config->dai_index, config->acpdmic.pdm_ch,
config->acpdmic.fsync_rate); config->acpdmic.pdm_rate);
dai->number_configs = 1; dai->number_configs = 1;
dai->current_config = 0; dai->current_config = 0;
......
...@@ -236,6 +236,7 @@ enum sof_tokens { ...@@ -236,6 +236,7 @@ enum sof_tokens {
SOF_AUDIO_FMT_NUM_TOKENS, SOF_AUDIO_FMT_NUM_TOKENS,
SOF_COPIER_FORMAT_TOKENS, SOF_COPIER_FORMAT_TOKENS,
SOF_GAIN_TOKENS, SOF_GAIN_TOKENS,
SOF_ACPDMIC_TOKENS,
/* this should be the last */ /* this should be the last */
SOF_TOKEN_COUNT, SOF_TOKEN_COUNT,
......
...@@ -1739,6 +1739,10 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, struct snd_ ...@@ -1739,6 +1739,10 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, struct snd_
token_id = SOF_AFE_TOKENS; token_id = SOF_AFE_TOKENS;
num_tuples += token_list[SOF_AFE_TOKENS].count; num_tuples += token_list[SOF_AFE_TOKENS].count;
break; break;
case SOF_DAI_AMD_DMIC:
token_id = SOF_ACPDMIC_TOKENS;
num_tuples += token_list[SOF_ACPDMIC_TOKENS].count;
break;
default: default:
break; break;
} }
......
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