Commit 63d1a348 authored by Viorel Suman's avatar Viorel Suman Committed by Mark Brown

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: default avatarViorel Suman <viorel.suman@nxp.com>
Signed-off-by: default avatarDaniel Baluta <daniel.baluta@nxp.com>
Acked-by: default avatarNicolin Chen <nicoleotsuka@gmail.com>
Link: https://lore.kernel.org/r/20190830215910.31590-1-daniel.baluta@nxp.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d1c9e44a
...@@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, ...@@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask,
return 0; return 0;
} }
static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai,
unsigned int ratio)
{
struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai);
sai->bclk_ratio = ratio;
return 0;
}
static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai,
int clk_id, unsigned int freq, int fsl_dir) int clk_id, unsigned int freq, int fsl_dir)
{ {
...@@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, ...@@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
slot_width = sai->slot_width; slot_width = sai->slot_width;
if (!sai->is_slave_mode) { if (!sai->is_slave_mode) {
ret = fsl_sai_set_bclk(cpu_dai, tx, if (sai->bclk_ratio)
slots * slot_width * params_rate(params)); ret = fsl_sai_set_bclk(cpu_dai, tx,
sai->bclk_ratio *
params_rate(params));
else
ret = fsl_sai_set_bclk(cpu_dai, tx,
slots * slot_width *
params_rate(params));
if (ret) if (ret)
return ret; return ret;
...@@ -630,6 +646,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream, ...@@ -630,6 +646,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream,
} }
static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = { static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = {
.set_bclk_ratio = fsl_sai_set_dai_bclk_ratio,
.set_sysclk = fsl_sai_set_dai_sysclk, .set_sysclk = fsl_sai_set_dai_sysclk,
.set_fmt = fsl_sai_set_dai_fmt, .set_fmt = fsl_sai_set_dai_fmt,
.set_tdm_slot = fsl_sai_set_dai_tdm_slot, .set_tdm_slot = fsl_sai_set_dai_tdm_slot,
......
...@@ -176,6 +176,7 @@ struct fsl_sai { ...@@ -176,6 +176,7 @@ struct fsl_sai {
unsigned int mclk_streams; unsigned int mclk_streams;
unsigned int slots; unsigned int slots;
unsigned int slot_width; unsigned int slot_width;
unsigned int bclk_ratio;
const struct fsl_sai_soc_data *soc_data; const struct fsl_sai_soc_data *soc_data;
struct snd_dmaengine_dai_dma_data dma_params_rx; struct snd_dmaengine_dai_dma_data dma_params_rx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment