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: 109743 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1130890qge; Wed, 9 Aug 2017 09:49:54 -0700 (PDT) X-Received: by 10.99.240.69 with SMTP id s5mr8117748pgj.23.1502297394557; Wed, 09 Aug 2017 09:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502297394; cv=none; d=google.com; s=arc-20160816; b=yuv1Y3IPCviVf6DUQ6AtJJldxWocXgjTdN8efdBTsRrFg7jMjziXwzXaHImVT9IdO5 9wJBBlNjNoPB0w8dVd57JzuMma2qvrR7UliLkHobep5vgCTBnrU1aOjX8d35zsuYJgcU iGek3yJrqjYMYOID09iB4Ne9oIeoZn2NHX4/DTp6WKOzatHBU7EPo4qooQG5ZMzf3cMN 8YMFVsN8VDmJyULxM+6mgfJftY8XrlBV2ASiQAdX5xXPFxCxglS61ic/ySB2D6hmzHtZ A0C8wke2WcDuHwbLbJaDrJQR3ZHfXDOxF3v0xqPoI3Xk2lzt15HC/Qp87DgkHvOw7OVb pwoA== 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=Lshfogmfijij6O57DmllPOsjMOttJSpSLxb50SN98+M=; b=hrEeq0gCNTrL2kkDzQOr9WB6q//O/gxY7J1ZCGUgE+JNpA8FaC3+kztT2mbEuOYMWS 28H0XoWMsocn3pRp7QtB8a5mkrP3ecd6Q2wSyqRjh8t02n/ODKGDOwVXdRhGOu6rAEkl NlB9VbMjc7bT2rTJHyIgRHQt+93GfFLNvnXO+mHczZtGeZY6bMfY4wOMu/sY+Fo2jUNj 7Nb3jnmSjOocJ0wGXYlk9iPQDq9qpEl09HWEFVEQ4r7NTcBOsFkEKTksApy1XUmZR/PD VRxTXHm4/0Sw4tBNCvJgOdOgShIH+4yCnc56lkwCOIsJV8hvcNipS6hCfQF9KXnx0d7+ 50xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pbl71Tsb; 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 205si2773597pfy.264.2017.08.09.09.49.54; Wed, 09 Aug 2017 09:49:54 -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=Pbl71Tsb; 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 S1753494AbdHIQtu (ORCPT + 25 others); Wed, 9 Aug 2017 12:49:50 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:38328 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752741AbdHIQtm (ORCPT ); Wed, 9 Aug 2017 12:49:42 -0400 Received: by mail-io0-f170.google.com with SMTP id g71so341140ioe.5 for ; Wed, 09 Aug 2017 09:49:41 -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=pbDoXuJ2BIMwhcdj38z27I1Fbc8Nk+DRfE8cbwJaAXjB2oQQ/52F/OS7wmeClFwslc eL0WXgGMOsMN6BvYIkuUN3p/uvxFyZj7S6zOzR1LQpb+VGFbzx7WwzcVMr49/OsqbbQx 1J9dcAaXXOqGxVdGh5mIWjc0QRFpEtoGop6EGmApzVmauSiUY9PGqo4WgRGenlWMKy6H NLHsd+lpIX0YKMm0KUWuZqCQnTsZHzwipGZsLRTQG7XQRMkM+e8yzcBuEjeoCLcj/2UE KqkMrLDYb8Wd90RoYrY77c4o/4tBCR/t/8HfsrLs+NOXx9wKrXbsOz8PbE81y/CgFd2M tL5Q== X-Gm-Message-State: AIVw110dPUkY77Vr/hcMcJwwECO0WYe5yKgQaeBFxh0RlWXIHxcx3EXZ CKMp29FE1wxoOJy/ 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 Cc: damien.riegel@savoirfairelinux.com, Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v3 4/5] ASoC: qcom: apq8016-sbc: Add support to Headset JACK 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> 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.9.3 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;