From patchwork Thu Jul 16 05:42:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 6804071 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 15D139F2F0 for ; Thu, 16 Jul 2015 05:43:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D3162052D for ; Thu, 16 Jul 2015 05:43:01 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E951A20527 for ; Thu, 16 Jul 2015 05:42:59 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0F9D526619F; Thu, 16 Jul 2015 07:42:57 +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, RCVD_IN_DNSWL_NONE, 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 DF7A52660B3; Thu, 16 Jul 2015 07:42:49 +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 046E32660BB; Thu, 16 Jul 2015 07:42:47 +0200 (CEST) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by alsa0.perex.cz (Postfix) with ESMTP id B5D6926607E for ; Thu, 16 Jul 2015 07:42:41 +0200 (CEST) Received: by pachj5 with SMTP id hj5so36747442pac.3 for ; Wed, 15 Jul 2015 22:42:40 -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; bh=PQqPMX/S1LTKydWGLsL7XonevcgXc/ONHDSWu5VTO7k=; b=mC7qnyPl0U1ucIv/PvLBowZDnbcyRNT8MDzcCgCe6AHyvSeCR9EWTbctd0TevyYfOF 5YtSn58rUeqkF3q/ADc61ymNN9Pz0zfCvf9MndBRecP29vJA9ceINIBdt5lH0tEpwVlJ XqehV08eTO3uYpF0lWi45dXLwzVPP/pCroqn8= 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; bh=PQqPMX/S1LTKydWGLsL7XonevcgXc/ONHDSWu5VTO7k=; b=Ig4a9DyD0MQsqLdD6lgQH6QuImFvAZafn4Hkcrppg2HUjW5Giug7paNG0bVOYtugBX U5f0c6HhgjnVpdQMvni8QlXoEI8knmLyLnEplfBeXfa/E+67kcH6++riEcm3pOWstQME jXur7MkL28KQ/sWU+htuj7kMusxKpksUZv3hj08Kn5j2eL1YefootdD1l836F51oRoLe qEXAOyOQiyflA3XGhw2arP9u8kyGBivWKrW766t2bRpN78Z4qw7fsqKygt+6RwRMzB+q 7IXGVSPnNauXhcK2aumyO0AYBi9DZ93P0o8CDHr9v1AajLVmgo89Nu31+3lWx0KcxCNj 0aMg== X-Gm-Message-State: ALoCoQly4URGehZ+ylai053QEgTLOa2EPZySscaarmFKAuqdFAEJg3Dk1izVvHCW9A9mJbKDsy3h X-Received: by 10.70.23.98 with SMTP id l2mr15256993pdf.74.1437025360313; Wed, 15 Jul 2015 22:42:40 -0700 (PDT) Received: from drinkcat.tpe.corp.google.com ([172.30.210.53]) by smtp.gmail.com with ESMTPSA id mb4sm6478767pdb.63.2015.07.15.22.42.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Jul 2015 22:42:39 -0700 (PDT) From: Nicolas Boichat To: Mark Brown Date: Thu, 16 Jul 2015 13:42:33 +0800 Message-Id: <1437025354-22678-1-git-send-email-drinkcat@chromium.org> X-Mailer: git-send-email 2.4.3.573.g4eafbef Cc: Oder Chiou , alsa-devel@alsa-project.org, Takashi Iwai , Liam Girdwood , Bard Liao Subject: [alsa-devel] [PATCH 1/2] ASoC: rt5645: Update dapm pins when the card is not instantiated yet 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 This makes sure the dapm state is consistent when the card is instantiated. However, if the card is not instantiated yet, we still update the registers manually in the "jack in" case, so that we can immediately report if a mic is present or not. Disabling "Mic Det Power" after detection, and on jack out, can wait until the card gets instantiated. Signed-off-by: Nicolas Boichat --- sound/soc/codecs/rt5645.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 093a41d..a56bca6 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -2805,12 +2805,11 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) if (jack_insert) { regmap_write(rt5645->regmap, RT5645_CHARGE_PUMP, 0x0006); - if (codec->component.card->instantiated) { - /* for jack type detect */ - snd_soc_dapm_force_enable_pin(dapm, "LDO2"); - snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); - snd_soc_dapm_sync(dapm); - } else { + /* for jack type detect */ + snd_soc_dapm_force_enable_pin(dapm, "LDO2"); + snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); + snd_soc_dapm_sync(dapm); + if (!dapm->card->instantiated) { /* Power up necessary bits for JD if dapm is not ready yet */ regmap_update_bits(rt5645->regmap, RT5645_PWR_ANLG1, @@ -2841,12 +2840,8 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) rt5645_enable_push_button_irq(codec, true); } } else { - if (codec->component.card->instantiated) { - snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); - snd_soc_dapm_sync(dapm); - } else - regmap_update_bits(rt5645->regmap, - RT5645_PWR_VOL, RT5645_PWR_MIC_DET, 0); + snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); + snd_soc_dapm_sync(dapm); rt5645->jack_type = SND_JACK_HEADPHONE; } @@ -2855,19 +2850,10 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) 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, - RT5645_PWR_MIXER, - RT5645_PWR_LDO2, 0); - regmap_update_bits(rt5645->regmap, - RT5645_PWR_VOL, RT5645_PWR_MIC_DET, 0); - } + 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); } }