Skip to contentSkip to conversation

ASoC: rt5670: add set_bclk_ratio in dai ops

PATCH Superseded Bard Liao 2 participants 2 messages Sep 12, 2017

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Bard Liao

author
#0 lore raw

PATCH 1/1 ASoC: rt5670: add set_bclk_ratio in dai ops

We need to set a specific bit for 50 bclk rate. So add set_bclk_ratio function to set the bit.

---
 sound/soc/codecs/rt5670.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
sound/soc/codecs/rt5670.c +17 -0
index 9545764..dbdd01c 100644
@@ -2582,6 +2582,22 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
 	return 0;
 }
 
+static int rt5670_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
+{
+	struct snd_soc_codec *codec = dai->codec;
+
+	dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio);
+	if (dai->id != RT5670_AIF1)
+		return 0;
+
+	if (ratio == 50)
+		snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x0800, 0x0800);
+	else
+		snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x0800, 0x0);
+
+	return 0;
+}
+
 static int rt5670_set_bias_level(struct snd_soc_codec *codec,
 			enum snd_soc_bias_level level)
 {
@@ -2712,6 +2728,7 @@ static const struct snd_soc_dai_ops rt5670_aif_dai_ops = {
 	.set_fmt = rt5670_set_dai_fmt,
 	.set_tdm_slot = rt5670_set_tdm_slot,
 	.set_pll = rt5670_set_dai_pll,
+	.set_bclk_ratio = rt5670_set_bclk_ratio,
 };
 
 static struct snd_soc_dai_driver rt5670_dai[] = {
Signature · 1 line
2.7.4
#1 lore raw
Quoted 19 lines · Bard Liao

We need to set a specific bit for 50 bclk rate. So add set_bclk_ratio function to set the bit.

---
 sound/soc/codecs/rt5670.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
sound/soc/codecs/rt5670.c +2 -0
index 9545764..dbdd01c 100644
@@ -2582,6 +2582,22 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
 	return 0;
 }
 
+static int rt5670_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
+{

sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, · line 2596

Quoted 10 lines
sound/soc/codecs/rt5670.c +10 -0
+	struct snd_soc_codec *codec = dai->codec;
+
+	dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio);
+	if (dai->id != RT5670_AIF1)
+		return 0;
+
+	if (ratio == 50)
+		snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x0800, 0x0800);
+	else
+		snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x0800, 0x0);

Better to define some proper constant for 0x0800 bit.

thanks,

Takashi