summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/da7219.c
diff options
context:
space:
mode:
authorAdam Thomson <Adam.Thomson.Opensource@diasemi.com>2017-06-19 10:56:33 +0100
committerMark Brown <broonie@kernel.org>2017-06-19 16:39:15 +0100
commit2a0c2189d8170d52da64543cbf955f0908c15e70 (patch)
treebc4dbaf82523eaa0f01a92f74f3e41eac04fe7b3 /sound/soc/codecs/da7219.c
parent2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff)
downloadlinux-2a0c2189d8170d52da64543cbf955f0908c15e70.tar.bz2
ASoC: da7219: Fix HP detection procedure for all MCLK frequencies
Currently when HP detection procedure runs for certain MCLK frequencies, when PLL is bypassed, the procedure will incorrectly report Lineout instead of Headphones due to timing incosistencies. To avoid this problem, the PLL is temporarily enabled (if currently bypassed and MCLK present) to provide consistent timings for the procedure, regardless of MCLK frequency. Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> Acked-by: Sathyanarayana Nujella <sathyanarayana.nujella@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/da7219.c')
-rw-r--r--sound/soc/codecs/da7219.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index 99601627f83c..f71d72c22bfc 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -260,9 +260,9 @@ static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol,
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
int ret;
- mutex_lock(&da7219->lock);
+ mutex_lock(&da7219->ctrl_lock);
ret = snd_soc_get_volsw(kcontrol, ucontrol);
- mutex_unlock(&da7219->lock);
+ mutex_unlock(&da7219->ctrl_lock);
return ret;
}
@@ -274,9 +274,9 @@ static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol,
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
int ret;
- mutex_lock(&da7219->lock);
+ mutex_lock(&da7219->ctrl_lock);
ret = snd_soc_put_volsw(kcontrol, ucontrol);
- mutex_unlock(&da7219->lock);
+ mutex_unlock(&da7219->ctrl_lock);
return ret;
}
@@ -288,9 +288,9 @@ static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol,
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
int ret;
- mutex_lock(&da7219->lock);
+ mutex_lock(&da7219->ctrl_lock);
ret = snd_soc_get_enum_double(kcontrol, ucontrol);
- mutex_unlock(&da7219->lock);
+ mutex_unlock(&da7219->ctrl_lock);
return ret;
}
@@ -302,9 +302,9 @@ static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol,
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
int ret;
- mutex_lock(&da7219->lock);
+ mutex_lock(&da7219->ctrl_lock);
ret = snd_soc_put_enum_double(kcontrol, ucontrol);
- mutex_unlock(&da7219->lock);
+ mutex_unlock(&da7219->ctrl_lock);
return ret;
}
@@ -424,9 +424,9 @@ static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol,
u16 val;
int ret;
- mutex_lock(&da7219->lock);
+ mutex_lock(&da7219->ctrl_lock);
ret = regmap_raw_read(da7219->regmap, reg, &val, sizeof(val));
- mutex_unlock(&da7219->lock);
+ mutex_unlock(&da7219->ctrl_lock);
if (ret)
return ret;
@@ -458,9 +458,9 @@ static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol,
*/
val = cpu_to_le16(ucontrol->value.integer.value[0]);
- mutex_lock(&da7219->lock);
+ mutex_lock(&da7219->ctrl_lock);
ret = regmap_raw_write(da7219->regmap, reg, &val, sizeof(val));
- mutex_unlock(&da7219->lock);
+ mutex_unlock(&da7219->ctrl_lock);
return ret;
}
@@ -801,7 +801,7 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w,
++i;
msleep(50);
}
- } while ((i < DA7219_SRM_CHECK_RETRIES) && (!srm_lock));
+ } while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock));
if (!srm_lock)
dev_warn(codec->dev, "SRM failed to lock\n");
@@ -1129,6 +1129,8 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
return -EINVAL;
}
+ mutex_lock(&da7219->pll_lock);
+
switch (clk_id) {
case DA7219_CLKSRC_MCLK_SQR:
snd_soc_update_bits(codec, DA7219_PLL_CTRL,
@@ -1141,6 +1143,7 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
break;
default:
dev_err(codec_dai->dev, "Unknown clock source %d\n", clk_id);
+ mutex_unlock(&da7219->pll_lock);
return -EINVAL;
}
@@ -1152,19 +1155,20 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
if (ret) {
dev_err(codec_dai->dev, "Failed to set clock rate %d\n",
freq);
+ mutex_unlock(&da7219->pll_lock);
return ret;
}
}
da7219->mclk_rate = freq;
+ mutex_unlock(&da7219->pll_lock);
+
return 0;
}
-static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
- int source, unsigned int fref, unsigned int fout)
+int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout)
{
- struct snd_soc_codec *codec = codec_dai->codec;
struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
u8 pll_ctrl, indiv_bits, indiv;
@@ -1237,6 +1241,20 @@ static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
return 0;
}
+static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
+ int source, unsigned int fref, unsigned int fout)
+{
+ struct snd_soc_codec *codec = codec_dai->codec;
+ struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec);
+ int ret;
+
+ mutex_lock(&da7219->pll_lock);
+ ret = da7219_set_pll(codec, source, fout);
+ mutex_unlock(&da7219->pll_lock);
+
+ return ret;
+}
+
static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{
struct snd_soc_codec *codec = codec_dai->codec;
@@ -1741,7 +1759,8 @@ static int da7219_probe(struct snd_soc_codec *codec)
unsigned int rev;
int ret;
- mutex_init(&da7219->lock);
+ mutex_init(&da7219->ctrl_lock);
+ mutex_init(&da7219->pll_lock);
/* Regulator configuration */
ret = da7219_handle_supplies(codec);