Commit b059ca72 authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: rt5665: calibration should be done before jack detection

We will set some volatile registers in jack detection function. But
those volatile registers will be clear in rt5665_calibrate function
because we set cache bypass and reset codec in rt5665_calibrate function.
This patch add a flag to make sure that rt5665_calibrate is done
before starting jack detection.
Signed-off-by: default avatarBard Liao <bardliao@realtek.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 18fe7869
...@@ -70,6 +70,7 @@ struct rt5665_priv { ...@@ -70,6 +70,7 @@ struct rt5665_priv {
int jack_type; int jack_type;
int irq_work_delay_time; int irq_work_delay_time;
unsigned int sar_adc_value; unsigned int sar_adc_value;
bool calibration_done;
}; };
static const struct reg_default rt5665_reg[] = { static const struct reg_default rt5665_reg[] = {
...@@ -1305,6 +1306,11 @@ static void rt5665_jack_detect_handler(struct work_struct *work) ...@@ -1305,6 +1306,11 @@ static void rt5665_jack_detect_handler(struct work_struct *work)
usleep_range(10000, 15000); usleep_range(10000, 15000);
} }
while (!rt5665->calibration_done) {
pr_debug("%s calibration not ready\n", __func__);
usleep_range(10000, 15000);
}
mutex_lock(&rt5665->calibrate_mutex); mutex_lock(&rt5665->calibrate_mutex);
val = snd_soc_read(rt5665->codec, RT5665_AJD1_CTRL) & 0x0010; val = snd_soc_read(rt5665->codec, RT5665_AJD1_CTRL) & 0x0010;
...@@ -4695,6 +4701,7 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665) ...@@ -4695,6 +4701,7 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665)
regmap_write(rt5665->regmap, RT5665_ASRC_8, 0x0120); regmap_write(rt5665->regmap, RT5665_ASRC_8, 0x0120);
out_unlock: out_unlock:
rt5665->calibration_done = true;
mutex_unlock(&rt5665->calibrate_mutex); mutex_unlock(&rt5665->calibrate_mutex);
} }
......
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