diff mbox series

ASoC: rt1015: Add condition to prevent SoC providing bclk in ratio of 50 times of sample rate.

Message ID 20200504112013.2499-1-jack.yu@realtek.com (mailing list archive)
State Accepted
Commit d696a61413b405a13bbe04f31e6f4531a426fee7
Headers show
Series ASoC: rt1015: Add condition to prevent SoC providing bclk in ratio of 50 times of sample rate. | expand

Commit Message

Jack Yu May 4, 2020, 11:20 a.m. UTC
From: Jack Yu <jack.yu@realtek.com>

Add condition to prevent SoC providing bclk in ratio of 50 times of sample rate.

Signed-off-by: Jack Yu <jack.yu@realtek.com>
---
 sound/soc/codecs/rt1015.c | 27 +++++++++++++++++++++++++++
 sound/soc/codecs/rt1015.h |  1 +
 2 files changed, 28 insertions(+)

Comments

Mark Brown May 4, 2020, 3:23 p.m. UTC | #1
On Mon, 4 May 2020 19:20:13 +0800, jack.yu@realtek.com wrote:
> From: Jack Yu <jack.yu@realtek.com>
> 
> Add condition to prevent SoC providing bclk in ratio of 50 times of sample rate.
> 
> Signed-off-by: Jack Yu <jack.yu@realtek.com>
> ---
>  sound/soc/codecs/rt1015.c | 27 +++++++++++++++++++++++++++
>  sound/soc/codecs/rt1015.h |  1 +
>  2 files changed, 28 insertions(+)
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.8

Thanks!

[1/1] ASoC: rt1015: Add condition to prevent SoC providing bclk in ratio of 50 times of sample rate.
      commit: d696a61413b405a13bbe04f31e6f4531a426fee7

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index bb310bc7febd..5eb07a430ae3 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -780,6 +780,14 @@  static int rt1015_set_component_pll(struct snd_soc_component *component,
 		freq_out == rt1015->pll_out)
 		return 0;
 
+	if (source == RT1015_PLL_S_BCLK) {
+		if (rt1015->bclk_ratio == 0) {
+			dev_err(component->dev,
+				"Can not support bclk ratio as 0.\n");
+			return -EINVAL;
+		}
+	}
+
 	switch (source) {
 	case RT1015_PLL_S_MCLK:
 		snd_soc_component_update_bits(component, RT1015_CLK2,
@@ -819,12 +827,30 @@  static int rt1015_set_component_pll(struct snd_soc_component *component,
 	return 0;
 }
 
+static int rt1015_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
+{
+	struct snd_soc_component *component = dai->component;
+	struct rt1015_priv *rt1015 = snd_soc_component_get_drvdata(component);
+
+	dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio);
+
+	rt1015->bclk_ratio = ratio;
+
+	if (ratio == 50) {
+		dev_dbg(component->dev, "Unsupport bclk ratio\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int rt1015_probe(struct snd_soc_component *component)
 {
 	struct rt1015_priv *rt1015 =
 		snd_soc_component_get_drvdata(component);
 
 	rt1015->component = component;
+	rt1015->bclk_ratio = 0;
 	snd_soc_component_write(component, RT1015_BAT_RPO_STEP1, 0x061c);
 
 	return 0;
@@ -844,6 +870,7 @@  static void rt1015_remove(struct snd_soc_component *component)
 static struct snd_soc_dai_ops rt1015_aif_dai_ops = {
 	.hw_params = rt1015_hw_params,
 	.set_fmt = rt1015_set_dai_fmt,
+	.set_bclk_ratio = rt1015_set_bclk_ratio,
 };
 
 static struct snd_soc_dai_driver rt1015_dai[] = {
diff --git a/sound/soc/codecs/rt1015.h b/sound/soc/codecs/rt1015.h
index ef3745a4faae..6fbe802082c4 100644
--- a/sound/soc/codecs/rt1015.h
+++ b/sound/soc/codecs/rt1015.h
@@ -362,6 +362,7 @@  struct rt1015_priv {
 	int sysclk_src;
 	int lrck;
 	int bclk;
+	int bclk_ratio;
 	int id;
 	int pll_src;
 	int pll_in;