From patchwork Thu Mar 1 19:25:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 130393 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp3189378edc; Thu, 1 Mar 2018 11:26:13 -0800 (PST) X-Google-Smtp-Source: AG47ELsGTjcCl8qtZl3T1vfaG3CTMlyW7qWuhRmYrCNJ2T/UwCWvyyuqzXsHf28ddQqJrPwf9hJ1 X-Received: by 10.28.138.143 with SMTP id m137mr2965579wmd.85.1519932373424; Thu, 01 Mar 2018 11:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519932373; cv=none; d=google.com; s=arc-20160816; b=Ra142l/qTu8YmKpr/LcurUPQ9LlXuv9nbjogutrmKnU4fFxqfV5ZxGf7wjtAyZu9s+ 7fASDO0GklEwCwopwYnE8x24+snBtr+SuIB4K39uCF01IWzEVsztLaE0EF2DSWyOOVqx XoW9uICCxFhk4w1pDnWxnud4Q7U6t9i6P4Wy4+yv3LNoZefHk27CofWjqOSSHYIwXagm npJcb/DncJ2bQ8pQaVTkhh9JsgUsb/dWiscMqQ75OCMn8eEm3f1DFTOOcxeCS/uh9XSE nm0cwqm92T7fE/gIyLI4ANa0GFf9JVmSK5sQ6zHEHupPQuBUK3mGSaf4M1pV8B074Tln Pxhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=u4OyuAouHdcgp1mSTSbfsEGxU1NZb96jIq3Iu6VkuQ4=; b=hBUjsphg+f1yvtD4T41TU5Arq6G/tg9Ehohor1KSCPTsEhzbqify5nIIp3ldSNM1M9 hqNrhW3A9hBXR6OqngHDP+QtMENFhf7LDBBzGYA3ZslDiiEh/v0yvNFjy5xRJPZV3syP iMWS2renEbvS7odUYsI80h5rJ4RdmQJhiLZzzhYhUQVSHXyNZZ26q5x1syioBZUi43iH OvGhKczl6RpMqEzfUnk6E7OANNJ4s2KY9pO181jEeqZcJgqDu/6/d5uG14yfw7aZoT6f pAAgp4cw0JwI5caBngkVBVAAAzOF932tBYQ2I+4E+q/ZgPAWs3VJP+Xz7xlnBWscxKFE 7MJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=v6qE5sxX; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id r16si3127446wmg.181.2018.03.01.11.26.13; Thu, 01 Mar 2018 11:26:13 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=v6qE5sxX; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 28168267B93; Thu, 1 Mar 2018 20:26:04 +0100 (CET) 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 A94EC267190; Thu, 1 Mar 2018 20:26:01 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id 041EB267190 for ; Thu, 1 Mar 2018 20:25:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=SQqNPW1TArQ3vSinoQHliEtmhTJQNeAI95YYRkhBzDg=; b=v6qE5sxXQ7XQ yBg5IWN8VVtSMOa2Z4pduuQeXwWrZ2+kfp/1ofPMQLKskuFnz8QskToanlv39bfAtaI7OPtWsrR6/ /SV+DjwWrcNTa3o0oXwp8jaDByWUeKvgdy+akX8v0Ji7CO7xLE77tfx7iEWh5A9D2SPaqU3mzMLle SD5eA=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1erTpz-0005ic-SX; Thu, 01 Mar 2018 19:25:55 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1erTpz-0001T0-EI; Thu, 01 Mar 2018 19:25:55 +0000 From: Mark Brown To: Hans de Goede In-Reply-To: Message-Id: Date: Thu, 01 Mar 2018 19:25:55 +0000 Cc: alsa-devel@alsa-project.org, Mark Brown , Carlo Caione Subject: [alsa-devel] Applied "ASoC: rt5651: Enable LDO and micbias1 supplies for jack-type detection" to the asoc tree 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 The patch ASoC: rt5651: Enable LDO and micbias1 supplies for jack-type detection has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 1310e737a68741c9b06cf63be0084bae6018b308 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:55 +0100 Subject: [PATCH] ASoC: rt5651: Enable LDO and micbias1 supplies for jack-type detection To determine if a plugged in jack is a headset (speakers + mic) or headphones (mic contact shorted to ground) we use the micbias1 OVer Current Detect (OVCD) functionality. For this to work we need to have a micbias current to actually cause an overcurrent condition when headphones are plugged in, so jack-type detection requires both the LDO and micbias1 supplies to be on. Before this commit there were 2 issues with the handling of this: 1) The LDO supply was force-enabled twice and never disabled again even though it only needs to be forced on when doing jack-type detection 2) micbias1 was not force-enabled, and thus may be off when doing jack-type detection This commit fixes both by force-enabling the LDO and micbias1 supplies before checking for an overcurrent condition and disabling them afterwards. Note that both supplies will still get turned on normally (and OVCD will protect against overcurrent) when the micbias1 is enabled normally because the user has activated a sound stream recording from the mic. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) -- 2.16.2 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index cbf9f56ecb14..be942886700d 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1561,6 +1561,28 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, return 0; } +static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + + snd_soc_dapm_mutex_lock(dapm); + snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO"); + snd_soc_dapm_force_enable_pin_unlocked(dapm, "micbias1"); + snd_soc_dapm_sync_unlocked(dapm); + snd_soc_dapm_mutex_unlock(dapm); +} + +static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + + snd_soc_dapm_mutex_lock(dapm); + snd_soc_dapm_disable_pin_unlocked(dapm, "micbias1"); + snd_soc_dapm_disable_pin_unlocked(dapm, "LDO"); + snd_soc_dapm_sync_unlocked(dapm); + snd_soc_dapm_mutex_unlock(dapm); +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1574,7 +1596,6 @@ static irqreturn_t rt5651_irq(int irq, void *data) static int rt5651_set_jack(struct snd_soc_component *component, struct snd_soc_jack *hp_jack, void *data) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); int ret; @@ -1616,9 +1637,6 @@ static int rt5651_set_jack(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_JD_M, RT5651_PWR_JD_M); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); rt5651->hp_jack = hp_jack; @@ -1819,13 +1837,10 @@ static const struct dmi_system_id rt5651_quirk_table[] = { static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int jack_type; if (jack_insert) { - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - + rt5651_enable_micbias1_for_ovcd(component); snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK | RT5651_MIC1_OVTH_MASK | @@ -1842,6 +1857,7 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse jack_type = SND_JACK_HEADSET; snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, RT5651_MB1_OC_CLR, 0); + rt5651_disable_micbias1_for_ovcd(component); } else { /* jack out */ jack_type = 0;