From patchwork Wed Aug 9 16:49:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 9891105 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 6A3AA601EB for ; Wed, 9 Aug 2017 16:51:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5849328A64 for ; Wed, 9 Aug 2017 16:51:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AC7C28A3D; Wed, 9 Aug 2017 16:51:02 +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 86D0628A3D for ; Wed, 9 Aug 2017 16:51:01 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EC59226742C; Wed, 9 Aug 2017 18:49:49 +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 40F16267414; Wed, 9 Aug 2017 18:49:45 +0200 (CEST) Received: from mail-io0-f177.google.com (mail-io0-f177.google.com [209.85.223.177]) by alsa0.perex.cz (Postfix) with ESMTP id 5191E266D7D for ; Wed, 9 Aug 2017 18:49:42 +0200 (CEST) Received: by mail-io0-f177.google.com with SMTP id o9so524663iod.1 for ; Wed, 09 Aug 2017 09:49:42 -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=Lshfogmfijij6O57DmllPOsjMOttJSpSLxb50SN98+M=; b=Pbl71TsbL8uk0XpVdbuhAs2ebtNKmXA/GnyROgLChIpte7pcdR/1fxag9mzR5JVEQq N5gTVYxBNYntaqTPq06rDFG+qDpj5J4fQWpsX/8gYns5wTRBMO7w+w+VLZm2KO96Uuq9 2ipnnp15QJJz/S05BA7Kqkp8uf1XuChBsokHI= 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=Lshfogmfijij6O57DmllPOsjMOttJSpSLxb50SN98+M=; b=IgfcqbBLsCQ9MHjTe26tTeOXbIO+OG1SoCeQ+e4ifSJIHxip+79k8yRpij1DKhOpKB 1qfb7Ghc+a/ivE5H3enpxgXQGKFQc7HZieANzQkhA7ZZKA35eL4mS/oZsmBUTS6jRMLz Ma167sClT2sRq6HuFyHnQhUbj6OEO46Sk/AQpaB+HzZ+kifua4CLhZlglvS9Je0QP5/C jOCzhfgaa3tdSJVtzs8iq5fe90mq/RhbU2/yi0tQ2FeQr/ynhQvXB1fPcMhX620wyGwy 6qbsRt/bg6RrP0bRZA0X5LJmD+AN9mbrdH0MfqEpv/AAgpYi7Sn68JcldoLyQjA/YgQ5 urZA== X-Gm-Message-State: AIVw110e12WeCW9C9nvdcHECGy2Jewx3LcSkVuWVInoEA8Cz1AbpX3Ab 51DH+qNSdblmH3G7 X-Received: by 10.107.30.144 with SMTP id e138mr8252071ioe.206.1502297381355; Wed, 09 Aug 2017 09:49:41 -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 r20sm2246012itb.19.2017.08.09.09.49.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Aug 2017 09:49:40 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Date: Wed, 9 Aug 2017 18:49:26 +0200 Message-Id: <20170809164927.19663-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170809164927.19663-1-srinivas.kandagatla@linaro.org> References: <20170809164927.19663-1-srinivas.kandagatla@linaro.org> Cc: damien.riegel@savoirfairelinux.com, Patrick Lai , linux-kernel@vger.kernel.org, Takashi Iwai , Srinivas Kandagatla Subject: [alsa-devel] [PATCH v3 4/5] 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 4 pole headset type and 5 buttons. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/apq8016_sbc.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index f07aa1e..e6e632a 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -21,12 +21,16 @@ #include #include #include +#include #include +#include #include struct apq8016_sbc_data { void __iomem *mic_iomux; void __iomem *spkr_iomux; + struct snd_soc_jack jack; + bool jack_setup; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ }; @@ -70,6 +74,31 @@ 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); + pdata->jack_setup = true; + } + for (i = 0 ; i < dai_link->num_codecs; i++) { struct snd_soc_dai *dai = rtd->codec_dais[i]; @@ -81,6 +110,11 @@ 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, NULL); + if (rval != 0 && rval != -ENOTSUPP) { + dev_warn(card->dev, "Failed to set jack: %d\n", rval); + return rval; + } } return 0;