summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/imx-spdif.c
diff options
context:
space:
mode:
authorViorel Suman <viorel.suman@nxp.com>2018-08-16 14:40:34 +0300
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:54:22 +0800
commit084c2ca345337bc4a260f33b4561f5c860413381 (patch)
treeee616e309513680153c0727804123c555db954ce /sound/soc/fsl/imx-spdif.c
parent960f3f4848db6e2b0b83407e053dd0fed920e60a (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/soc/fsl/imx-spdif.c')
-rw-r--r--sound/soc/fsl/imx-spdif.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sound/soc/fsl/imx-spdif.c b/sound/soc/fsl/imx-spdif.c
index 70bcbf7cf43c..f2d0c6f6193f 100644
--- a/sound/soc/fsl/imx-spdif.c
+++ b/sound/soc/fsl/imx-spdif.c
@@ -5,12 +5,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;
@@ -48,6 +74,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev)
data->dai.platforms->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;