From patchwork Tue Jul 14 06:51:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 6783941 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 23D679F380 for ; Tue, 14 Jul 2015 06:53:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3828D20555 for ; Tue, 14 Jul 2015 06:53:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id CC9E720499 for ; Tue, 14 Jul 2015 06:53:13 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id CE4132650DA; Tue, 14 Jul 2015 08:53:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 22C272651D3; Tue, 14 Jul 2015 08:52:43 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1F69A2651D5; Tue, 14 Jul 2015 08:52:41 +0200 (CEST) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by alsa0.perex.cz (Postfix) with ESMTP id B81C22606DD for ; Tue, 14 Jul 2015 08:52:07 +0200 (CEST) Received: by pachj5 with SMTP id hj5so581282pac.3 for ; Mon, 13 Jul 2015 23:52:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2OJ+EhUt8Ll9mp8HOc1tOIiQLOWitwtaBRi75YqX9h4=; b=COkmMgdSgvxJ5raeosFVBOXH8RbWh2omQwDv0Kz6bBjai9qWjVxcec5HwlMNrljBE2 bAZ9w3mFqS4rJP1uFRcIl1STUcaT2BiIvtUvsSwwF74JcDtERmb9BycB1ZnKSKK0RTc3 ch5V5RDg0HuElzXU/su6diFolOk/RfVcObso4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2OJ+EhUt8Ll9mp8HOc1tOIiQLOWitwtaBRi75YqX9h4=; b=iUl6CM2WpFPTIMBHd5NeqtmY5BxZsY8jxu0HMYqLPTKmWFkIYRLT+ZHBOwTx0lm1mA nOhhutRpRDZpfVJillERo/+q5jJXeJK11vNE9HbgI3ppZGttJ+XyEBTtSg11XvxSVqNy yI4li7+TjYn2PlnH2jqK7J8P+47Xy4Q5lvIC3IFLHEtma8hxrZ8yRP7GUgwd95LNJKBC 1K+mdIwDrOx7mZxqbj7JGM5e70ZIsVWHZBbLVlcQlxlTMLbqqBXFj51hgrzwLtFnF/jO W21i5ERp0HEC6ky6STS5iqhydP+eWKj5iAEO9wfpinkj1bqP9iCwmGZ8Iq0KkFrgCWea leJw== X-Gm-Message-State: ALoCoQlDNPkcNcD1mD1UQ8WVQHyNs8Vpzb1Uw8VT+gSAii4gCwctQFm9+GQlnd9Mg/rjlIBBDTZv X-Received: by 10.70.50.3 with SMTP id y3mr70710796pdn.90.1436856725441; Mon, 13 Jul 2015 23:52:05 -0700 (PDT) Received: from drinkcat.tpe.corp.google.com ([172.30.210.53]) by smtp.gmail.com with ESMTPSA id uk6sm108265pac.27.2015.07.13.23.52.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jul 2015 23:52:04 -0700 (PDT) From: Nicolas Boichat To: Mark Brown Date: Tue, 14 Jul 2015 14:51:25 +0800 Message-Id: <1436856687-31550-2-git-send-email-drinkcat@chromium.org> X-Mailer: git-send-email 2.4.3.573.g4eafbef In-Reply-To: <1436856687-31550-1-git-send-email-drinkcat@chromium.org> References: <1436856687-31550-1-git-send-email-drinkcat@chromium.org> Cc: Oder Chiou , alsa-devel@alsa-project.org, Takashi Iwai , Liam Girdwood , koro.chen@mediatek.com, Bard Liao Subject: [alsa-devel] [PATCH v2 1/3] ASoC: rt5645: Simplify rt5645_enable_push_button_irq X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Bard Liao --- 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); - } } }