From patchwork Fri Mar 29 15:47:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 10877497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E87514DE for ; Fri, 29 Mar 2019 15:49:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33FFB289F0 for ; Fri, 29 Mar 2019 15:49:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27D9928A19; Fri, 29 Mar 2019 15:49:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 687A2289F0 for ; Fri, 29 Mar 2019 15:49:45 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8CBE115D2; Fri, 29 Mar 2019 16:48:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8CBE115D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1553874583; bh=EccAv16BdqLWyjhGsheFrSc2mtaBG5zKJ2nwn1fA4sg=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gWIgHsQvPXaHvakScJMjO8ScclHIEJ1SYFQNZQnYlxuGoSyxHiwLyqyz8kIuERGQF z/qH5g/SG2zhTPGd52DG2WptT0MljbAgSQ0bgYgTCikI8QWt8ohyeJl6C4gJQIxckK o/ui+vYKgWAuVgRJx0DmXmTH0l2OtxY4q++JF7lE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A3F35F8963E; Fri, 29 Mar 2019 16:47:24 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6457FF8071D; Fri, 29 Mar 2019 16:47:21 +0100 (CET) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2AAEAF89618 for ; Fri, 29 Mar 2019 16:47:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2AAEAF89618 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="LRagdDwq" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x2TFlGIC000368; Fri, 29 Mar 2019 10:47:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1553874436; bh=AmbVrhxS9g/ZR6yBKcKLqSqDLiYJR2GhKSi862P1jss=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LRagdDwqJAoRKgvHtDRiaDVSkA4zcImvgSZrqyNCC7XsLaQkMrewEq2EjMxc8kPuI 9PdcCqGlPrcY6Jp374YEQwUB/xiU5LPgHUxrfH2vBL773tE09A1JZc7ZxhM5fhvx2r A1K1VYMregcObjf5P7U814u/H+3SPXYqpBm/T4iA= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x2TFlGoh040859 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 29 Mar 2019 10:47:16 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 29 Mar 2019 10:47:15 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Fri, 29 Mar 2019 10:47:15 -0500 Received: from legion.dal.desgin.ti.com (legion.dal.design.ti.com [128.247.22.53]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x2TFlF28074385; Fri, 29 Mar 2019 10:47:15 -0500 Received: from localhost ([10.250.67.168]) by legion.dal.desgin.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id x2TFlFU27657; Fri, 29 Mar 2019 10:47:15 -0500 (CDT) From: "Andrew F. Davis" To: Liam Girdwood , Mark Brown Date: Fri, 29 Mar 2019 10:47:04 -0500 Message-ID: <20190329154704.4922-2-afd@ti.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190329154704.4922-1-afd@ti.com> References: <20190329154704.4922-1-afd@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, "Andrew F . Davis" Subject: [alsa-devel] [PATCH v3 2/2] ASoC: tlv320aic31xx: Add button press detection X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP This device can optionally detect headset or microphone button presses. Add support for this by passing this event to the jack layer. Signed-off-by: Andrew F. Davis --- Changes from v1: - Rebase Changes from v2: - Rebase sound/soc/codecs/tlv320aic31xx.c | 17 +++++++++++++++-- sound/soc/codecs/tlv320aic31xx.h | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index 3e11b3d41f3d..f59632ed2230 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -1380,10 +1380,21 @@ static irqreturn_t aic31xx_irq(int irq, void *data) dev_err(dev, "Short circuit on Left output is detected\n"); if (value & AIC31XX_HPRSCDETECT) dev_err(dev, "Short circuit on Right output is detected\n"); - if (value & AIC31XX_HSPLUG) { + if (value & (AIC31XX_HSPLUG | AIC31XX_BUTTONPRESS)) { unsigned int val; int status = 0; + ret = regmap_read(aic31xx->regmap, AIC31XX_INTRDACFLAG2, + &val); + if (ret) { + dev_err(dev, "Failed to read interrupt mask: %d\n", + ret); + goto exit; + } + + if (val & AIC31XX_BUTTONPRESS) + status |= SND_JACK_BTN_0; + ret = regmap_read(aic31xx->regmap, AIC31XX_HSDETECT, &val); if (ret) { dev_err(dev, "Failed to read headset type: %d\n", ret); @@ -1408,7 +1419,8 @@ static irqreturn_t aic31xx_irq(int irq, void *data) } if (value & ~(AIC31XX_HPLSCDETECT | AIC31XX_HPRSCDETECT | - AIC31XX_HSPLUG)) + AIC31XX_HSPLUG | + AIC31XX_BUTTONPRESS)) dev_err(dev, "Unknown DAC interrupt flags: 0x%08x\n", value); read_overflow: @@ -1522,6 +1534,7 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c, regmap_write(aic31xx->regmap, AIC31XX_INT1CTRL, AIC31XX_HSPLUGDET | + AIC31XX_BUTTONPRESSDET | AIC31XX_SC | AIC31XX_ENGINE); diff --git a/sound/soc/codecs/tlv320aic31xx.h b/sound/soc/codecs/tlv320aic31xx.h index 9985ceed97ae..cb024955c978 100644 --- a/sound/soc/codecs/tlv320aic31xx.h +++ b/sound/soc/codecs/tlv320aic31xx.h @@ -21,7 +21,8 @@ #define DAC31XX_BIT BIT(3) #define AIC31XX_JACK_MASK (SND_JACK_HEADPHONE | \ - SND_JACK_HEADSET) + SND_JACK_HEADSET | \ + SND_JACK_BTN_0) enum aic31xx_type { AIC3100 = 0,