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: 110303 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1858884qge; Thu, 17 Aug 2017 01:02:57 -0700 (PDT) X-Received: by 10.84.232.143 with SMTP id i15mr4889859plk.248.1502956976925; Thu, 17 Aug 2017 01:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502956976; cv=none; d=google.com; s=arc-20160816; b=UKYxZtb/Qn+W2k8rsbCGgn4fAEYy3hCLVv7QmSJAtc8DT83weurNG/HCsTjgQuihES hUVMqrDESEdroECdp7LnHeUEw6od/3euQnd0GRiOyXE/86NWKQdWW837IVN/NW2SjT/i 61uiIjK0XO5ZAeLVMuFj+OAVmS7Xwi0uVFv/ZAA0wbRfK2t6U2/Fr6vDfbmM26HADxjJ fZvdwB6EBCMu6tBygbwr+o0Q+F/upCxFaKAEL287T+fB8Nymjuj+jXiZens/24LLIb18 cMhMee7NT4ZCeBLrm3jGHhOCB2zadwP7ihlli4ZgcXAvYS9rj+W9DQxnD/CT48Ii7/0o zDtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=DHAUDnxqGt0c7hPTVX/pOY1qCOu37kYuP0Iltd18Ug8=; b=tibZ0PwcZ8MBzgh56EJ+4TH/XslaS9RMeM7yUaPKEpQLS/nSUQp5lS45HXl6/qx6/v Y4E+cje3eRv2Nd80JPxmCMGqmvqIukd748ZTXSHR3sxF5iYrMOqR/MH4LY06Q2w/3Hjf KYO/KvhrDx+2b97gEASg4+NvW6PXvYJ26SVrZ7hw+EhgmsThYphq+dU0akL6d9wiT1Ox 0EeHY+SwJSm5/9IuOoqjhjzKTZ1F0p8nOOPh20ZOFEW77E+nOSv+3JUClXjnavVzPOnY TlM9ObXz8I8tz0T5bqEuCJ1Ng0tDBUWC+8p6/w08RoBMEVIWoX0FuLWUpY9O+Z2oGP09 /fgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ce1e5bqX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si1391403plw.653.2017.08.17.01.02.56; Thu, 17 Aug 2017 01:02:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ce1e5bqX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483AbdHQICy (ORCPT + 26 others); Thu, 17 Aug 2017 04:02:54 -0400 Received: from mail-it0-f53.google.com ([209.85.214.53]:35659 "EHLO mail-it0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751848AbdHQICY (ORCPT ); Thu, 17 Aug 2017 04:02:24 -0400 Received: by mail-it0-f53.google.com with SMTP id 76so27824557ith.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=njqTjq9lOt7CWiH8vOjWOm7GvcnRCQ01WcgdtPoi9FeYoZeHDW6WeMDAdl/8aX6bsK Lx3/gipWBV6X7ZRyvIJE/lIJEF9YPt7K1kOBiRQZmhacEeeJUYWjK4CMtvAeMRmJmvPI 52Xc9U1cLUS4Gjn9Jm7R6vQvUFvMrmz3eEBL9ScYWw7C3b4B0tAcl1Vw+JpAIaodFMGm t8PW0z5t9C4CbG71f+nEOzY3xkTNTWTxzlNManX2M+Wca/8nygMZ7DjWiFvUbcou/noN FFsbp+XBuL3WSdUx35RbxVZgjuv537J73vJY9LdXNIWBsjrLdtoYaDILwMD2oIKxuywF 0J2w== X-Gm-Message-State: AHYfb5id/vmGlDmXvxw6QL0ixp6K/5ABmNo97IhKWaGhxb1oo5zraXAC 9jJiZnM31Jh7beuR 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 Cc: damien.riegel@savoirfairelinux.com, Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v4 3/3] ASoC: qcom: apq8016-sbc: Add support to Headset JACK 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 2.11.0 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;