summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/rt298.c
diff options
context:
space:
mode:
authorAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>2022-07-07 14:56:58 +0200
committerMark Brown <broonie@kernel.org>2022-07-11 14:59:07 +0100
commitc0c5a242bba878b4d34f7c9612fd6cd6c404d414 (patch)
treeb45fea2c4b407ea9226a5efb6de7bceea1e6dc36 /sound/soc/codecs/rt298.c
parent9b6803ec1fe0f10942b9297d2d60ec46f2999323 (diff)
ASoC: codecs: rt298: Fix jack detection
On our RVP platforms using rt298 with combojack we've seen issues with controls being in incorrect state after suspend/resume cycle. This is caused by codec driver not setting pins to correct state and causing codec suspend method to not be called. Which on resume caused codec registers to be in undefined state. Fix this by setting pins correctly in jack detect function. Above problem is caused by the fact that when jack == NULL code doesn't reach rt298_jack_detect() function which sets pins. Alternatively problem could be fixed by just moving rt298_jack_detect, but as rt298 codec is similar to rt286, align the code by setting pins explicitly. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220707125701.3518263-3-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt298.c')
-rw-r--r--sound/soc/codecs/rt298.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c
index 6a615943f983..e1d94f128fd9 100644
--- a/sound/soc/codecs/rt298.c
+++ b/sound/soc/codecs/rt298.c
@@ -329,34 +329,31 @@ static void rt298_jack_detect_work(struct work_struct *work)
static int rt298_mic_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack, void *data)
{
+ struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component);
- struct snd_soc_dapm_context *dapm;
- bool hp = false;
- bool mic = false;
- int status = 0;
rt298->jack = jack;
- /* If jack in NULL, disable HS jack */
- if (!jack) {
+ if (jack) {
+ /* Enable IRQ */
+ if (rt298->jack->status & SND_JACK_HEADPHONE)
+ snd_soc_dapm_force_enable_pin(dapm, "LDO1");
+ if (rt298->jack->status & SND_JACK_MICROPHONE) {
+ snd_soc_dapm_force_enable_pin(dapm, "HV");
+ snd_soc_dapm_force_enable_pin(dapm, "VREF");
+ }
+ regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x2);
+ /* Send an initial empty report */
+ snd_soc_jack_report(rt298->jack, rt298->jack->status,
+ SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
+ } else {
+ /* Disable IRQ */
regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0);
- dapm = snd_soc_component_get_dapm(component);
+ snd_soc_dapm_disable_pin(dapm, "HV");
+ snd_soc_dapm_disable_pin(dapm, "VREF");
snd_soc_dapm_disable_pin(dapm, "LDO1");
- snd_soc_dapm_sync(dapm);
- return 0;
}
-
- regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x2);
-
- rt298_jack_detect(rt298, &hp, &mic);
- if (hp)
- status |= SND_JACK_HEADPHONE;
-
- if (mic)
- status |= SND_JACK_MICROPHONE;
-
- snd_soc_jack_report(rt298->jack, status,
- SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
+ snd_soc_dapm_sync(dapm);
return 0;
}