From patchwork Thu Aug 17 08:02:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 9905255 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 D19D160386 for ; Thu, 17 Aug 2017 08:03:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C377E285AB for ; Thu, 17 Aug 2017 08:03:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B853F28ABE; Thu, 17 Aug 2017 08:03:22 +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 08EC6285AB for ; Thu, 17 Aug 2017 08:03:21 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 47C8F2675A6; Thu, 17 Aug 2017 10:02:32 +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 AC169267615; Thu, 17 Aug 2017 10:02:31 +0200 (CEST) Received: from mail-it0-f45.google.com (mail-it0-f45.google.com [209.85.214.45]) by alsa0.perex.cz (Postfix) with ESMTP id C37872675A6 for ; Thu, 17 Aug 2017 10:02:24 +0200 (CEST) Received: by mail-it0-f45.google.com with SMTP id f16so1504217itb.0 for ; Thu, 17 Aug 2017 01:02:24 -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=DHAUDnxqGt0c7hPTVX/pOY1qCOu37kYuP0Iltd18Ug8=; b=Ce1e5bqXk0z2/0AvhDo+zniOqfn5Fxfjih7IB1eNNrtfWpWuunJ4RaTCvu0kyn8ILu /EpcVFlD7TMhqvNJ8gJRXs4vRzph/wlP7AuS2HZgaNlla2wdswZOpcXZtiO8VxhODkWU 4fSHiphvThI3RV2KOPV8zi53z0uumEpHTVaCE= 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=DHAUDnxqGt0c7hPTVX/pOY1qCOu37kYuP0Iltd18Ug8=; b=IK6gK2vDHD7iHir8JKCY02JD2xEyitXxRygwjvAYxI9cGLrRks0GmJUle5lR4rfmlX pqivg7bLT2y+e3bZo2ec35o0IZ2K59y2JFg1eiMY55ViD4oA298aRlTmxO3NfMhC1Ewr vVcPgACQiKEI4EHCrntaugZxW6jjrPRC0OpQM6aA0Y6Vc+zx/I9wF3t3FeSM1EU8O25d D1i+/4C2Y/BNTfWg3ed1as+K16lGAPhOUd7ownBuwRBgg7pY80izbrTPA58S9zdxvSXo rrQ0pO+9MzBgIxiQZFdnAs3CoLzna/JUey6iOsApGtWe3pRjBBmT7jwexvdtiQGZI/kJ HeIA== X-Gm-Message-State: AHYfb5iy+/PQDz0GOKw7uCpVpXwedwzt02LlutMA3w7WA0r5AkgoSyoT 0Nw2hEF69HBsnz/T X-Received: by 10.36.150.68 with SMTP id z65mr955026itd.106.1502956943846; Thu, 17 Aug 2017 01:02:23 -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 o10sm1235777ioe.27.2017.08.17.01.02.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Aug 2017 01:02:23 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Date: Thu, 17 Aug 2017 10:02:11 +0200 Message-Id: <20170817080211.11453-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170817080211.11453-1-srinivas.kandagatla@linaro.org> References: <20170817080211.11453-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 v4 3/3] 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 f07aa1e1cdfe..e6e632aa0fab 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;