From patchwork Mon Apr 1 15:13:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 10880151 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 5CF3613B5 for ; Mon, 1 Apr 2019 15:21:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43D7F28786 for ; Mon, 1 Apr 2019 15:21:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3611028793; Mon, 1 Apr 2019 15:21:50 +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 07D9F28786 for ; Mon, 1 Apr 2019 15:21:48 +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 9F1DA15D5; Mon, 1 Apr 2019 17:14:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9F1DA15D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554131723; bh=coRlg3syYcFSF5PN29HQNt7ZlRbVWXVp822/vfowvtE=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EwTt7r5C9baLe1r0I6+S29L1K9wx5Z7Tvf9U2UuXJhXaY85p6V8sYk0xTdClh2faz BWWssYIbLwBxOvPm56gvkcVybWS9pd8kgs6vRbw0j9B+QqPQxQNuP/0jVuY/l4e9i6 dd6uTkRLNff78dBT3VJPkffy3zm7Wnwm6XE4XgFI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 319CBF89615; Mon, 1 Apr 2019 17:13:38 +0200 (CEST) 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 A8EF4F89612; Mon, 1 Apr 2019 17:13:35 +0200 (CEST) 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 A05FFF8075C for ; Mon, 1 Apr 2019 17:13:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A05FFF8075C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="vu1hCDRI" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x31FDU8e099972; Mon, 1 Apr 2019 10:13:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1554131610; bh=4hwlGYonBT8FCPQuSLM0CtnMDugJ7z5m9a/76xZyKTQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=vu1hCDRI03nq28HHefS+GnYImalnUwfG0t2C1t89KWgahHd0FoGgkHAubi25ow1I8 lggEUaC9VwlJRiiTRZ7BMWf+RwH6RtZHU9AiEApWWaiWP9PBo26D+c/0CvnHQkLfKc fyLdUJzs/2GegO1DSs1rjpqtNavdnhb9R3yH5G7Q= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x31FDUM8031302 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 1 Apr 2019 10:13:30 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 1 Apr 2019 10:13:29 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE101.ent.ti.com (157.170.170.31) 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; Mon, 1 Apr 2019 10:13:29 -0500 Received: from legion.dal.desgin.ti.com (legion.dal.design.ti.com [128.247.22.53]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x31FDTsX075981; Mon, 1 Apr 2019 10:13:29 -0500 Received: from localhost ([10.250.67.168]) by legion.dal.desgin.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id x31FDTU10487; Mon, 1 Apr 2019 10:13:29 -0500 (CDT) From: "Andrew F. Davis" To: Liam Girdwood , Mark Brown Date: Mon, 1 Apr 2019 10:13:29 -0500 Message-ID: <20190401151329.29075-2-afd@ti.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401151329.29075-1-afd@ti.com> References: <20190401151329.29075-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 v4 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 v3: - Rebase on broonie/for-next 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 a60cd8c08a14..fa47bfcb93e9 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -1423,10 +1423,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); @@ -1451,7 +1462,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: @@ -1564,6 +1576,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,