blob: 7bdd15ccc11f98102db735085d13e265343bf91b [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From d40566a2e9aa3c40be313b1fba9d5435c58ffd79 Mon Sep 17 00:00:00 2001
2From: Shengjiu Wang <shengjiu.wang@nxp.com>
3Date: Thu, 23 Nov 2017 13:32:13 +0800
4Subject: [PATCH] MLK-16929-1: ASoC: fsl_sai: add bitclk_freq
5
6Allow set SAI bit clock frequency trough snd_soc_dai_set_sysclk
7function call on machine sound drivers.
8
9Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
10Signed-off-by: Adrian Alonso <adrian.alonso@nxp.com>
11---
12 sound/soc/fsl/fsl_sai.c | 9 ++++++++-
13 sound/soc/fsl/fsl_sai.h | 1 +
14 2 files changed, 9 insertions(+), 1 deletion(-)
15
16--- a/sound/soc/fsl/fsl_sai.c
17+++ b/sound/soc/fsl/fsl_sai.c
18@@ -233,11 +233,14 @@ static int fsl_sai_set_dai_sysclk_tr(str
19 static int fsl_sai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
20 int clk_id, unsigned int freq, int dir)
21 {
22+ struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
23 int ret;
24
25 if (dir == SND_SOC_CLOCK_IN)
26 return 0;
27
28+ sai->bitclk_freq = freq;
29+
30 ret = fsl_sai_set_dai_sysclk_tr(cpu_dai, clk_id, freq,
31 FSL_FMT_TRANSMITTER);
32 if (ret) {
33@@ -500,7 +503,11 @@ static int fsl_sai_hw_params(struct snd_
34 slot_width = sai->slot_width;
35
36 if (!sai->slave_mode[tx]) {
37- ret = fsl_sai_set_bclk(cpu_dai, tx,
38+ if (sai->bitclk_freq)
39+ ret = fsl_sai_set_bclk(cpu_dai, tx,
40+ sai->bitclk_freq);
41+ else
42+ ret = fsl_sai_set_bclk(cpu_dai, tx,
43 slots * slot_width * params_rate(params));
44 if (ret)
45 return ret;
46--- a/sound/soc/fsl/fsl_sai.h
47+++ b/sound/soc/fsl/fsl_sai.h
48@@ -181,6 +181,7 @@ struct fsl_sai {
49 unsigned int mclk_streams;
50 unsigned int slots;
51 unsigned int slot_width;
52+ unsigned int bitclk_freq;
53
54 struct snd_soc_dai_driver cpu_dai_drv;
55 struct snd_dmaengine_dai_dma_data dma_params_rx;