diff options
author | Viorel Suman <viorel.suman@nxp.com> | 2019-08-30 17:59:10 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-09-13 05:39:27 -0400 |
commit | 63d1a3488ff58e094a7f517cf93c0250f0a3f6be (patch) | |
tree | e42acbeb943177f256d2b62c83a42765da180abd /sound/soc/fsl | |
parent | d1c9e44a858d706ce0b496f559b25732e6697b0c (diff) |
ASoC: fsl_sai: Implement set_bclk_ratio
This is to allow machine drivers to set a certain bitclk rate
which might not be exactly rate * frame size.
Cc: NXP Linux Team <linux-imx@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/20190830215910.31590-1-daniel.baluta@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r-- | sound/soc/fsl/fsl_sai.c | 21 | ||||
-rw-r--r-- | sound/soc/fsl/fsl_sai.h | 1 |
2 files changed, 20 insertions, 2 deletions
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 728307acab90..ef0b74693093 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c | |||
@@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, | |||
137 | return 0; | 137 | return 0; |
138 | } | 138 | } |
139 | 139 | ||
140 | static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai, | ||
141 | unsigned int ratio) | ||
142 | { | ||
143 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai); | ||
144 | |||
145 | sai->bclk_ratio = ratio; | ||
146 | |||
147 | return 0; | ||
148 | } | ||
149 | |||
140 | static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, | 150 | static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, |
141 | int clk_id, unsigned int freq, int fsl_dir) | 151 | int clk_id, unsigned int freq, int fsl_dir) |
142 | { | 152 | { |
@@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, | |||
423 | slot_width = sai->slot_width; | 433 | slot_width = sai->slot_width; |
424 | 434 | ||
425 | if (!sai->is_slave_mode) { | 435 | if (!sai->is_slave_mode) { |
426 | ret = fsl_sai_set_bclk(cpu_dai, tx, | 436 | if (sai->bclk_ratio) |
427 | slots * slot_width * params_rate(params)); | 437 | ret = fsl_sai_set_bclk(cpu_dai, tx, |
438 | sai->bclk_ratio * | ||
439 | params_rate(params)); | ||
440 | else | ||
441 | ret = fsl_sai_set_bclk(cpu_dai, tx, | ||
442 | slots * slot_width * | ||
443 | params_rate(params)); | ||
428 | if (ret) | 444 | if (ret) |
429 | return ret; | 445 | return ret; |
430 | 446 | ||
@@ -630,6 +646,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream, | |||
630 | } | 646 | } |
631 | 647 | ||
632 | static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = { | 648 | static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = { |
649 | .set_bclk_ratio = fsl_sai_set_dai_bclk_ratio, | ||
633 | .set_sysclk = fsl_sai_set_dai_sysclk, | 650 | .set_sysclk = fsl_sai_set_dai_sysclk, |
634 | .set_fmt = fsl_sai_set_dai_fmt, | 651 | .set_fmt = fsl_sai_set_dai_fmt, |
635 | .set_tdm_slot = fsl_sai_set_dai_tdm_slot, | 652 | .set_tdm_slot = fsl_sai_set_dai_tdm_slot, |
diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index b89b0ca26053..b12cb578f6d0 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h | |||
@@ -176,6 +176,7 @@ struct fsl_sai { | |||
176 | unsigned int mclk_streams; | 176 | unsigned int mclk_streams; |
177 | unsigned int slots; | 177 | unsigned int slots; |
178 | unsigned int slot_width; | 178 | unsigned int slot_width; |
179 | unsigned int bclk_ratio; | ||
179 | 180 | ||
180 | const struct fsl_sai_soc_data *soc_data; | 181 | const struct fsl_sai_soc_data *soc_data; |
181 | struct snd_dmaengine_dai_dma_data dma_params_rx; | 182 | struct snd_dmaengine_dai_dma_data dma_params_rx; |