Commit d696a614 authored by Jack Yu's avatar Jack Yu Committed by Mark Brown

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

Add condition to prevent SoC providing bclk in ratio of 50 times of sample rate.
Signed-off-by: default avatarJack Yu <jack.yu@realtek.com>
Link: https://lore.kernel.org/r/20200504112013.2499-1-jack.yu@realtek.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent c25504ad
...@@ -780,6 +780,14 @@ static int rt1015_set_component_pll(struct snd_soc_component *component, ...@@ -780,6 +780,14 @@ static int rt1015_set_component_pll(struct snd_soc_component *component,
freq_out == rt1015->pll_out) freq_out == rt1015->pll_out)
return 0; 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) { switch (source) {
case RT1015_PLL_S_MCLK: case RT1015_PLL_S_MCLK:
snd_soc_component_update_bits(component, RT1015_CLK2, snd_soc_component_update_bits(component, RT1015_CLK2,
...@@ -819,12 +827,30 @@ static int rt1015_set_component_pll(struct snd_soc_component *component, ...@@ -819,12 +827,30 @@ static int rt1015_set_component_pll(struct snd_soc_component *component,
return 0; 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) static int rt1015_probe(struct snd_soc_component *component)
{ {
struct rt1015_priv *rt1015 = struct rt1015_priv *rt1015 =
snd_soc_component_get_drvdata(component); snd_soc_component_get_drvdata(component);
rt1015->component = component; rt1015->component = component;
rt1015->bclk_ratio = 0;
snd_soc_component_write(component, RT1015_BAT_RPO_STEP1, 0x061c); snd_soc_component_write(component, RT1015_BAT_RPO_STEP1, 0x061c);
return 0; return 0;
...@@ -844,6 +870,7 @@ static void rt1015_remove(struct snd_soc_component *component) ...@@ -844,6 +870,7 @@ static void rt1015_remove(struct snd_soc_component *component)
static struct snd_soc_dai_ops rt1015_aif_dai_ops = { static struct snd_soc_dai_ops rt1015_aif_dai_ops = {
.hw_params = rt1015_hw_params, .hw_params = rt1015_hw_params,
.set_fmt = rt1015_set_dai_fmt, .set_fmt = rt1015_set_dai_fmt,
.set_bclk_ratio = rt1015_set_bclk_ratio,
}; };
static struct snd_soc_dai_driver rt1015_dai[] = { static struct snd_soc_dai_driver rt1015_dai[] = {
......
...@@ -362,6 +362,7 @@ struct rt1015_priv { ...@@ -362,6 +362,7 @@ struct rt1015_priv {
int sysclk_src; int sysclk_src;
int lrck; int lrck;
int bclk; int bclk;
int bclk_ratio;
int id; int id;
int pll_src; int pll_src;
int pll_in; int pll_in;
......
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