summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorViorel Suman <viorel.suman@nxp.com>2018-08-16 14:40:34 +0300
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commitdbaa0fc89cf8c6515cee47782ca721b81574ac31 (patch)
treeb0a57ee73aa1933bb27b0ff07282f4cc44069a8e /sound
parent24b9c73e611d185d41a0e3f2f6a28cc2787a9539 (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>
Diffstat (limited to 'sound')
-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 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;