ASoC: SOF: add a helper to get topology configured bclk
Add helper function sof_dai_ssp_bclk() to get the BCLK frequency configured by topology. Reviewed-by: Bard Liao <bard.liao@intel.com> Signed-off-by: Brent Lu <brent.lu@intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20210625205042.65181-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
f99acc259f
Коммит
bc619cfc62
|
@ -101,5 +101,6 @@ struct sof_dev_desc {
|
|||
};
|
||||
|
||||
int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
|
||||
int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -433,11 +433,10 @@ struct snd_sof_dai *snd_sof_find_dai(struct snd_soc_component *scomp,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper to get SSP MCLK from a pcm_runtime.
|
||||
* Return 0 if not exist.
|
||||
*/
|
||||
int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd)
|
||||
#define SOF_DAI_CLK_INTEL_SSP_MCLK 0
|
||||
#define SOF_DAI_CLK_INTEL_SSP_BCLK 1
|
||||
|
||||
static int sof_dai_get_clk(struct snd_soc_pcm_runtime *rtd, int clk_type)
|
||||
{
|
||||
struct snd_soc_component *component =
|
||||
snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
|
||||
|
@ -450,16 +449,45 @@ int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd)
|
|||
|
||||
switch (dai->dai_config->type) {
|
||||
case SOF_DAI_INTEL_SSP:
|
||||
return dai->dai_config->ssp.mclk_rate;
|
||||
switch (clk_type) {
|
||||
case SOF_DAI_CLK_INTEL_SSP_MCLK:
|
||||
return dai->dai_config->ssp.mclk_rate;
|
||||
case SOF_DAI_CLK_INTEL_SSP_BCLK:
|
||||
return dai->dai_config->ssp.bclk_rate;
|
||||
default:
|
||||
dev_err(rtd->dev, "fail to get SSP clk %d rate\n",
|
||||
clk_type);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* not yet implemented for platforms other than the above */
|
||||
dev_err(rtd->dev, "mclk for dai_config->type %d not supported yet!\n",
|
||||
dev_err(rtd->dev, "DAI type %d not supported yet!\n",
|
||||
dai->dai_config->type);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper to get SSP MCLK from a pcm_runtime.
|
||||
* Return 0 if not exist.
|
||||
*/
|
||||
int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
return sof_dai_get_clk(rtd, SOF_DAI_CLK_INTEL_SSP_MCLK);
|
||||
}
|
||||
EXPORT_SYMBOL(sof_dai_get_mclk);
|
||||
|
||||
/*
|
||||
* Helper to get SSP BCLK from a pcm_runtime.
|
||||
* Return 0 if not exist.
|
||||
*/
|
||||
int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
return sof_dai_get_clk(rtd, SOF_DAI_CLK_INTEL_SSP_BCLK);
|
||||
}
|
||||
EXPORT_SYMBOL(sof_dai_get_bclk);
|
||||
|
||||
/*
|
||||
* SOF Driver enumeration.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче