From patchwork Wed Jul 26 00:35:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 9864073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4021A6038F for ; Wed, 26 Jul 2017 00:37:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30A74286FE for ; Wed, 26 Jul 2017 00:37:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 253952872C; Wed, 26 Jul 2017 00:37:03 +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=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AC9B286FE for ; Wed, 26 Jul 2017 00:37:02 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 57E4226739A; Wed, 26 Jul 2017 02:35:42 +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 6D26B26739A; Wed, 26 Jul 2017 02:35:39 +0200 (CEST) Received: from mail-it0-f53.google.com (mail-it0-f53.google.com [209.85.214.53]) by alsa0.perex.cz (Postfix) with ESMTP id E4A05267354 for ; Wed, 26 Jul 2017 02:35:36 +0200 (CEST) Received: by mail-it0-f53.google.com with SMTP id v127so60229562itd.0 for ; Tue, 25 Jul 2017 17:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zh4eHiChyDJuxqsYA8yde9ls/Smrn98yB6Ap/L/1oyw=; b=JJDhsqUvN7ieQwoKGtddONu/kdTT9tpNY8zRD7E1POVGuRXZ70htpkxbPPIh7MJZ7R z0NRPxqhqz3zs0w6oHLh1/TV9A/VaNKZBwHD9RMyO2KKglWgE7g6xsrM8WOrdRsLkEge N86ZxD4Qj26gZQ8yEO4tu3wMUpGYZJtLWRhAc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zh4eHiChyDJuxqsYA8yde9ls/Smrn98yB6Ap/L/1oyw=; b=C97TzI+aM2XLoMH39cFH8WOULVwaMU/bwLNZuVPAJNh3q8TQcVFD5T8i1rvMz5z6lG SgNRly5SL60YJAQpdcKaQ5U/Nkv/lh6UJtLGoXPWoqPE9u/Tl2SpnAPRV9CZe28h1rGh Bk8U9QdIqU5pmc4Hytz3Nzca/CyW1hSZMf4oGCceUSUpPJFZJVAgYHmpbe/5vF3zULHS 6WGhLTlZbj4UAZMKAeMxdGV8librsvPeSuof5w12siwyB3Yq8ibozVdMkS94+l9Svccl GCtHjc/yDbQOIclp2EGtTCXk8Du90sVO039FtdXAfjgC08OKOwbxQzTtI+J2pTrUmdvi xTSg== X-Gm-Message-State: AIVw110HG28RgLNAnlJTBFTRz5tkCuIBfZ5JzfMULxBLVtCG/y3YGooF DP9Q4fa5nax7KFIjeknSOA== X-Received: by 10.36.55.145 with SMTP id r139mr13195807itr.117.1501029335533; Tue, 25 Jul 2017 17:35:35 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id l69sm5097373ioi.49.2017.07.25.17.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:35:35 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Date: Wed, 26 Jul 2017 02:35:12 +0200 Message-Id: <20170726003512.18965-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> References: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> Cc: linux-kernel@vger.kernel.org, Patrick Lai , Srinivas Kandagatla , Takashi Iwai Subject: [alsa-devel] [PATCH v1 6/6] ASoC: qcom: apq8016-sbc: Add support to Headset JACK 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 From: Srinivas Kandagatla This patch adds support to Headset JACK, also provides board specific vref ranges for mbhc buttons to be detected. This headset supports both 3 pole and 5 pole headset type and 5 buttons. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/apq8016_sbc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index f07aa1e..ccb3620 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -21,12 +21,18 @@ #include #include #include +#include #include +#include #include +#include "../codecs/msm8916-wcd.h" struct apq8016_sbc_data { void __iomem *mic_iomux; void __iomem *spkr_iomux; + struct snd_soc_jack jack; + struct msm8916_wcd_mbhc_data mbhc_data; + bool jack_setup; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ }; @@ -43,6 +49,7 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_card *card = rtd->card; struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card); + struct msm8916_wcd_mbhc_data *data; int i, rval; switch (cpu_dai->id) { @@ -70,6 +77,45 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) } + if (!pdata->jack_setup) { + struct snd_jack *jack; + + rval = snd_soc_card_jack_new(card, "Headset Jack", + SND_JACK_HEADSET | + SND_JACK_HEADPHONE | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3 | + SND_JACK_BTN_4, + &pdata->jack, NULL, 0); + + if (rval < 0) { + dev_err(card->dev, "Unable to add Headphone Jack\n"); + return rval; + } + + jack = pdata->jack.jack; + + snd_jack_set_key(jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); + + /* board specific vref thresholds in mv */ + data = &pdata->mbhc_data; + data->vref_btn_cs[0] = 75; + data->vref_btn_micb[0] = 75; + data->vref_btn_cs[1] = 150; + data->vref_btn_micb[1] = 150; + data->vref_btn_cs[2] = 237; + data->vref_btn_micb[2] = 237; + data->vref_btn_cs[3] = 450; + data->vref_btn_micb[3] = 450; + data->vref_btn_cs[4] = 500; + data->vref_btn_micb[4] = 500; + + pdata->jack_setup = true; + } + for (i = 0 ; i < dai_link->num_codecs; i++) { struct snd_soc_dai *dai = rtd->codec_dais[i]; @@ -81,6 +127,12 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) dev_warn(card->dev, "Failed to set mclk: %d\n", rval); return rval; } + rval = snd_soc_codec_set_jack(codec, &pdata->jack, + &pdata->mbhc_data); + if (rval != 0 && rval != -ENOTSUPP) { + dev_warn(card->dev, "Failed to set jack: %d\n", rval); + return rval; + } } return 0;