diff options
author | Viorel Suman <viorel.suman@nxp.com> | 2018-08-16 14:40:34 +0300 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:33:28 +0800 |
commit | 446bed3151164159f9165745180886393e58a053 (patch) | |
tree | e8b0f429383103ca51d7ad6f37a8326df34b2879 /sound | |
parent | b02d8c0e5d2778f1645373a31e87330f54d4d74f (diff) |
MLK-19154-4: ASoC: imx_spdif: set SPDIF ROOT clock freq as function of rate
Set SPDIF master clock frequency as function of rate.
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
(cherry picked from commit 407430a03994e4acff508afe8c9772680558c1c5)
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/fsl/imx-spdif.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sound/soc/fsl/imx-spdif.c b/sound/soc/fsl/imx-spdif.c index 79942430eb94..440f7cd72d42 100644 --- a/sound/soc/fsl/imx-spdif.c +++ b/sound/soc/fsl/imx-spdif.c @@ -12,12 +12,38 @@ #include <linux/module.h> #include <linux/of_platform.h> #include <sound/soc.h> +#include "fsl_spdif.h" struct imx_spdif_data { struct snd_soc_dai_link dai; struct snd_soc_card card; }; +#define CLK_8K_FREQ 24576000 +#define CLK_11K_FREQ 22579200 + +static int imx_spdif_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct device *dev = rtd->card->dev; + int ret; + u64 rate = params_rate(params); + unsigned int freq; + + freq = do_div(rate, 8000) ? CLK_11K_FREQ : CLK_8K_FREQ; + ret = snd_soc_dai_set_sysclk(rtd->cpu_dai, STC_TXCLK_SPDIF_ROOT, + freq, SND_SOC_CLOCK_OUT); + if (ret) + dev_err(dev, "failed to set cpu sysclk: %d\n", ret); + + return ret; +} + +static struct snd_soc_ops imx_spdif_ops = { + .hw_params = imx_spdif_hw_params, +}; + static int imx_spdif_audio_probe(struct platform_device *pdev) { struct device_node *spdif_np, *np = pdev->dev.of_node; @@ -45,6 +71,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev) data->dai.platform_of_node = spdif_np; data->dai.playback_only = true; data->dai.capture_only = true; + data->dai.ops = &imx_spdif_ops; if (of_property_read_bool(np, "spdif-out")) data->dai.capture_only = false; |