All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Boichat <drinkcat@chromium.org>
To: Mark Brown <broonie@kernel.org>
Cc: Oder Chiou <oder_chiou@realtek.com>,
	alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>,
	Liam Girdwood <lgirdwood@gmail.com>,
	koro.chen@mediatek.com, Bard Liao <bardliao@realtek.com>
Subject: [PATCH v2 1/3] ASoC: rt5645: Simplify rt5645_enable_push_button_irq
Date: Tue, 14 Jul 2015 14:51:25 +0800	[thread overview]
Message-ID: <1436856687-31550-2-git-send-email-drinkcat@chromium.org> (raw)
In-Reply-To: <1436856687-31550-1-git-send-email-drinkcat@chromium.org>

LDO2/Mic Det Power pins are already enabled/disabled in rt5645_jack_detect
(the jack out code path previously did not disable those: modify it to make
it so).

Also, provide an alternative if dapm is not ready yet.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
---
 sound/soc/codecs/rt5645.c | 55 +++++++++++++++++++++++++----------------------
 1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 9dfa431..45651f4 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -2766,13 +2766,15 @@ static void rt5645_enable_push_button_irq(struct snd_soc_codec *codec,
 	struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec);
 
 	if (enable) {
-		snd_soc_dapm_mutex_lock(dapm);
-		snd_soc_dapm_force_enable_pin_unlocked(dapm, "ADC L power");
-		snd_soc_dapm_force_enable_pin_unlocked(dapm, "ADC R power");
-		snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO2");
-		snd_soc_dapm_force_enable_pin_unlocked(dapm, "Mic Det Power");
-		snd_soc_dapm_sync_unlocked(dapm);
-		snd_soc_dapm_mutex_unlock(dapm);
+		if (codec->component.card->instantiated) {
+			snd_soc_dapm_force_enable_pin(dapm, "ADC L power");
+			snd_soc_dapm_force_enable_pin(dapm, "ADC R power");
+			snd_soc_dapm_sync(dapm);
+		} else {
+			regmap_update_bits(rt5645->regmap, RT5645_PWR_DIG1,
+				RT5645_PWR_ADC_L_BIT | RT5645_PWR_ADC_R_BIT,
+				RT5645_PWR_ADC_L_BIT | RT5645_PWR_ADC_R_BIT);
+		}
 
 		snd_soc_update_bits(codec,
 					RT5645_INT_IRQ_ST, 0x8, 0x8);
@@ -2785,14 +2787,15 @@ static void rt5645_enable_push_button_irq(struct snd_soc_codec *codec,
 		snd_soc_update_bits(codec, RT5650_4BTN_IL_CMD2, 0x8000, 0x0);
 		snd_soc_update_bits(codec, RT5645_INT_IRQ_ST, 0x8, 0x0);
 
-		snd_soc_dapm_mutex_lock(dapm);
-		snd_soc_dapm_disable_pin_unlocked(dapm, "ADC L power");
-		snd_soc_dapm_disable_pin_unlocked(dapm, "ADC R power");
-		if (rt5645->pdata.jd_mode == 0)
-			snd_soc_dapm_disable_pin_unlocked(dapm, "LDO2");
-		snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Det Power");
-		snd_soc_dapm_sync_unlocked(dapm);
-		snd_soc_dapm_mutex_unlock(dapm);
+		if (codec->component.card->instantiated) {
+			snd_soc_dapm_disable_pin(dapm, "ADC L power");
+			snd_soc_dapm_disable_pin(dapm, "ADC R power");
+			snd_soc_dapm_sync(dapm);
+		} else {
+			regmap_update_bits(rt5645->regmap, RT5645_PWR_DIG1,
+				RT5645_PWR_ADC_L_BIT | RT5645_PWR_ADC_R_BIT,
+				0);
+		}
 	}
 }
 
@@ -2852,22 +2855,22 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert)
 
 	} else { /* jack out */
 		rt5645->jack_type = 0;
+
 		if (rt5645->en_button_func)
 			rt5645_enable_push_button_irq(codec, false);
-		else {
-			if (codec->component.card->instantiated) {
-				if (rt5645->pdata.jd_mode == 0)
-					snd_soc_dapm_disable_pin(dapm, "LDO2");
-				snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
-				snd_soc_dapm_sync(dapm);
-			} else {
-				if (rt5645->pdata.jd_mode == 0)
-					regmap_update_bits(rt5645->regmap,
+
+		if (codec->component.card->instantiated) {
+			if (rt5645->pdata.jd_mode == 0)
+				snd_soc_dapm_disable_pin(dapm, "LDO2");
+			snd_soc_dapm_disable_pin(dapm, "Mic Det Power");
+			snd_soc_dapm_sync(dapm);
+		} else {
+			if (rt5645->pdata.jd_mode == 0)
+				regmap_update_bits(rt5645->regmap,
 						RT5645_PWR_MIXER,
 						RT5645_PWR_LDO2, 0);
-				regmap_update_bits(rt5645->regmap,
+			regmap_update_bits(rt5645->regmap,
 					RT5645_PWR_VOL, RT5645_PWR_MIC_DET, 0);
-			}
 		}
 	}
 
-- 
2.4.3.573.g4eafbef

  reply	other threads:[~2015-07-14  6:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-14  6:51 [PATCH v2 0/3] ASoC: rt5645: Remove codec dependency in workqueue handler Nicolas Boichat
2015-07-14  6:51 ` Nicolas Boichat [this message]
2015-07-14  9:48   ` [PATCH v2 1/3] ASoC: rt5645: Simplify rt5645_enable_push_button_irq Bard Liao
2015-07-14  9:52   ` Mark Brown
2015-07-14 10:09     ` Bard Liao
2015-07-14 10:28       ` Mark Brown
2015-07-15  1:05         ` Nicolas Boichat
2015-07-15  8:50           ` Mark Brown
2015-07-15 11:50       ` Nicolas Boichat
2015-07-15 11:56         ` Mark Brown
2015-07-15 13:03           ` Bard Liao
2015-07-16  3:05             ` Nicolas Boichat
2015-07-14  6:51 ` [PATCH v2 2/3] ASoC: rt5645: Remove irq_jack_detection function Nicolas Boichat
2015-07-15 11:55   ` Applied "ASoC: rt5645: Remove irq_jack_detection function" to the asoc tree Mark Brown
2015-07-14  6:51 ` [PATCH v2 3/3] ASoC: rt5645: Remove codec dependency in workqueue handler Nicolas Boichat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436856687-31550-2-git-send-email-drinkcat@chromium.org \
    --to=drinkcat@chromium.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bardliao@realtek.com \
    --cc=broonie@kernel.org \
    --cc=koro.chen@mediatek.com \
    --cc=lgirdwood@gmail.com \
    --cc=oder_chiou@realtek.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.