From patchwork Wed Mar 7 14:14:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 130899 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp5232779lja; Wed, 7 Mar 2018 06:14:32 -0800 (PST) X-Google-Smtp-Source: AG47ELvGtLcYtRusavZ8N5SBI4D4I92WtRnNjjxZPxKn/6YYocFND27Td3JeEKhhCuclYjUFRdrD X-Received: by 10.223.164.158 with SMTP id g30mr3516341wrb.62.1520432072416; Wed, 07 Mar 2018 06:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520432072; cv=none; d=google.com; s=arc-20160816; b=x5G2zlCKm+t3e62MXfDsauQPadd1cLRoftHAB5E4rIxqIgbXFo1H+Gktx0F+I5Cs3M JOqe9c7ZazBVhdAJNZU92Pd/kAw+zpKhdetcX8DGuRZRMoxIlSvsCuHEfOuqJRGUawGn ZKmbPl/rS5I4SeEKjtv3z+l3re71emnioW7YltbqUKZpBYC42iN4z2xHgs/pEl+dyK11 P4iQwyWBdHE+q/MnKsW9yAnKWGxXC+7vd/qUbNfBbiLZxkkWwCOpE7fudr3kMeaTPfdD 8a0NcD4TQFq/x79OMDzoP3m5mY30HiuRC46AoJHcK0sR7GmqLnnpnUAarPNOfdQ/Cv2w eOTw== 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=Hyk7tJbvbPGGuSus1C7Mj18ywaUIQSIQwhNDFDrCj4o=; b=n1w7WT73tqNJ4NJagxVHlJGjhE2SzM7H7JvP4tMiZycLVCX6Th2kHzyA5qWlh3rTPa rkp3+vSxyccYGMI7K8kRqF3kEd2ss9S2hMctJkzUDE3vy5OsHOnBZGhmciP2SfpCyh9o 6uotvWQD7K58Z5IulbWLhTVuhWPHdc8t7tq0kPQpuazdz8Cz+3KGJOhFUZoimeIdzdKo QeQyZP9FYVqAgVaXhyrP9nFViDxlz8m+3QDxG6OF5RNlH1YPYgUIsarMotA7F+G+ohTk oZivneq1nEA9kLdVjXmJf+lk7MiKNL8kA/lVcPo23fBrca0rV4nuojVlYvyJDY2ikIfn TtoA== 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=jkciAVpR; 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 k86si7952585wmi.263.2018.03.07.06.14.32; Wed, 07 Mar 2018 06:14:32 -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=jkciAVpR; 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 811882673D8; Wed, 7 Mar 2018 15:14:16 +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 380642673D3; Wed, 7 Mar 2018 15:14:12 +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 591E42673D6 for ; Wed, 7 Mar 2018 15:14:09 +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=MAMUEYxq+1k2GhNN9Y1zGZUnL3LBPifbLeBpPXc4RvA=; b=jkciAVpRjY5T erMeBj9i48JTmPaQrHatak6xv3/lgD4Zqm+aghpWtvVn7TXnWouiRj+o897gV6dl489yUCcHTqwj+ UhvSgLJKGQns+iTzsY7Cvc5Moc7W20tvy01XIzQzdmpOPrxcdK5uTkuJLZIk+jjzJV/H6dtJ2ksQf l7Bf0=; 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 1etZpT-0000Am-Pm; Wed, 07 Mar 2018 14:14:03 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1etZpT-0001Pu-AE; Wed, 07 Mar 2018 14:14:03 +0000 From: Mark Brown To: Hans de Goede In-Reply-To: <20180225104713.4745-19-hdegoede@redhat.com> Message-Id: Date: Wed, 07 Mar 2018 14:14:03 +0000 Cc: Oder Chiou , alsa-devel@alsa-project.org, Pierre-Louis Bossart , Takashi Iwai , Mark Brown , Carlo Caione , Bard Liao Subject: [alsa-devel] Applied "ASoC: rt5651: Enable sticky mode for OVCD" 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 sticky mode for OVCD 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 1b1ad83539a701a6bdcb25dc9160386e71f6016e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:54 +0100 Subject: [PATCH] ASoC: rt5651: Enable sticky mode for OVCD When the mic-gnd contacts are short-circuited by a headphones plug, the hardware periodically retries if it can apply the bias-current leading to the OVCD status flip-flopping 1-0-1 with it being 0 about 10% of the time. This commit enables the sticky bit for the OVCD status to deal with this. This commit also introduces 2 helper functions to deal with the OVCD status bit, this may seem a bit overkill now, but these will also be used in future patches. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 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 486817809b7b..62918f7e8270 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1578,6 +1578,22 @@ static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component snd_soc_dapm_mutex_unlock(dapm); } +static void rt5651_clear_micbias1_ovcd(struct snd_soc_component *component) +{ + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, + RT5651_MB1_OC_CLR, 0); +} + +static bool rt5651_micbias1_ovcd(struct snd_soc_component *component) +{ + int val; + + val = snd_soc_component_read32(component, RT5651_IRQ_CTRL2); + dev_dbg(component->dev, "irq ctrl2 %#04x\n", val); + + return (val & RT5651_MB1_OC_CLR); +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1646,6 +1662,18 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); + /* + * The over-current-detect is only reliable in detecting the absence + * of over-current, when the mic-contact in the jack is short-circuited, + * the hardware periodically retries if it can apply the bias-current + * leading to the ovcd status flip-flopping 1-0-1 with it being 0 about + * 10% of the time, as we poll the ovcd status bit we might hit that + * 10%, so we enable sticky mode and when checking OVCD we clear the + * status, msleep() a bit and then check to get a reliable reading. + */ + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, + RT5651_MB1_OC_STKY_MASK, RT5651_MB1_OC_STKY_EN); + rt5651->hp_jack = hp_jack; ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, @@ -1878,13 +1906,12 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse if (jack_insert) { rt5651_enable_micbias1_for_ovcd(component); + rt5651_clear_micbias1_ovcd(component); msleep(100); - if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) + if (rt5651_micbias1_ovcd(component)) jack_type = SND_JACK_HEADPHONE; else 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;