From patchwork Wed Aug 2 17:09:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 109268 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp6475545obm; Wed, 2 Aug 2017 10:12:15 -0700 (PDT) X-Received: by 10.98.152.77 with SMTP id q74mr23179614pfd.40.1501693934935; Wed, 02 Aug 2017 10:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501693934; cv=none; d=google.com; s=arc-20160816; b=HxIvxyGitegmXKWDGcLpqfnMJijKbyLPFli344amLHLx/T/7lC44ep0ELDg1+hMqmR FEeRQw2qwItqTbK02D88ncz9u7VWY09VX9/IyhvnVbTx8SpAOGGjD9E1FYIYW6/TwAWi PgJB201WMewTMPU1LGrE9HR+g8CGEi7n4zeBdvdfqvii4ZEgupBYiORbFxmG6ALQDs+H +5+n5uknTtXTlhmN08v4QR39TI7ApfVdnFz4TIRBdCXmzLmn1XB6XYcaan0IWKJb0f49 6jOQ+gVUNYoIgdWYXQnEiZX4+o/b0Y5xHASGu96RJEeuBPIiuSy++P+psVEW3V8WCNKx e2uQ== 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=eLO9TD13+DIv+pffdeYzcd0xCXNQk7n+4yA/fXc0XX3/BsZWdrZMdxkjH6vuvQwYw3 9u8mcE5PXkiJ8tzlzvENkYYNsU/9xbcDa614BR9dspmIsiJiAU6lUg4nGEEEEKfD23+x u+5HDEecPDQCPu1+zNHZbfNxuvJAmDEybnKC1lVPNGqX6znEZkdx/O7ecF+5NXguDNNq bmeOv6R78EbWlYc3WTQkgo7B/dHbAa6YPcsV80frteUhmqzkTBUtozeHtxOwtSIsQbK+ rdQrzIjQJJQXg89FuFtc7dyj7RvOsChTJgR+NE3eNgUS6dwY+sKFsvWxAjCy4kBSi+9j tgLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=iYXFvBwb; 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 d10si21545008pln.796.2017.08.02.10.12.14; Wed, 02 Aug 2017 10:12:14 -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.b=iYXFvBwb; 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 S1752516AbdHBRKG (ORCPT + 25 others); Wed, 2 Aug 2017 13:10:06 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:37609 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752173AbdHBRJx (ORCPT ); Wed, 2 Aug 2017 13:09:53 -0400 Received: by mail-io0-f179.google.com with SMTP id c74so22868531iod.4 for ; Wed, 02 Aug 2017 10:09:53 -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=iYXFvBwbZF8by6usUjz1e/F0BiZJexok+nbYQTrWlBb0d9cxxVI0MaTRp0zn0aHFQc 3edBLhYNKiLD0fcVrf5f6F8rTfpOY2xbBT2Z1NQfwIF0UVKqi4jTXkpb4SFcDrg0QeGL FhdbXivJaMpVRQGHLpy7WPGrjod57hIdxzWMk= 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=I2DzC4FB6egWI3KBSPyxRuprl5T9AY85ah1Z7fOjNsdSLgM/hN5Kv+GJcpj+IXC4am MW3fdQrW4JAbPDdpqnJhfvAonZAWREttO6hfwiJu//yGsG74Eh+IQxNRvmBGMAFK/Hxa LOkUXgVw4acrMY/hbBZ2xJm/IiZYVeJ+beVd3dmX15/fglVV78itzd9cNnz4CoVgkcPm Wz16FG7NiaX1zyicBK/yXk/uC93/J3qztv60ggMz+4jbQZQiQExwPnBNOxQPWpaMzuh+ a2PzwCoNyTQ0fnk7q+UTq9XbqnCPdUdKdWCqeRjnDRPCebwSarS4+vQSmXzw2+pyJXwm YO/g== X-Gm-Message-State: AIVw110VWEEC1VWzOOnqo1I+RNzfAwHQagOO1IigaFzuVnH0YxX3IQ91 Nad3l1VvKU+cS9/L X-Received: by 10.107.26.130 with SMTP id a124mr26257982ioa.120.1501693793215; Wed, 02 Aug 2017 10:09:53 -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 u79sm2291222ita.24.2017.08.02.10.09.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Aug 2017 10:09:52 -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 v2 5/6] ASoC: qcom: apq8016-sbc: Add support to Headset JACK Date: Wed, 2 Aug 2017 19:09:29 +0200 Message-Id: <20170802170930.26083-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170802170930.26083-1-srinivas.kandagatla@linaro.org> References: <20170802170930.26083-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;