From: srinivas.kandagatla@linaro.org
To: Mark Brown <broonie@kernel.org>,
Banajit Goswami <bgoswami@codeaurora.org>,
alsa-devel@alsa-project.org
Cc: damien.riegel@savoirfairelinux.com,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Patrick Lai <plai@codeaurora.org>,
linux-kernel@vger.kernel.org,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Subject: [PATCH v3 4/5] ASoC: qcom: apq8016-sbc: Add support to Headset JACK
Date: Wed, 9 Aug 2017 18:49:26 +0200 [thread overview]
Message-ID: <20170809164927.19663-5-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20170809164927.19663-1-srinivas.kandagatla@linaro.org>
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
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 <srinivas.kandagatla@linaro.org>
---
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 <linux/platform_device.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
+#include <sound/jack.h>
#include <sound/soc.h>
+#include <uapi/linux/input-event-codes.h>
#include <dt-bindings/sound/apq8016-lpass.h>
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;
--
2.9.3
next prev parent reply other threads:[~2017-08-09 16:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 16:49 [PATCH v3 0/5] ASoC: codecs: msm8916-wcd-analog: Add support to MBHC srinivas.kandagatla
2017-08-09 16:49 ` [PATCH v3 1/5] ASoC: codecs: msm8916-wcd-analog: move codec reset to probe srinivas.kandagatla
2017-08-09 16:49 ` [PATCH v3 2/5] ASoC: codecs: msm8916-wcd-analog: get micbias voltage from dt srinivas.kandagatla
2017-08-10 15:24 ` Mark Brown
2017-08-11 15:15 ` Srinivas Kandagatla
2017-08-09 16:49 ` [PATCH v3 3/5] ASoC: codecs: msm8916-wcd-analog: add MBHC support srinivas.kandagatla
2017-08-09 21:10 ` Damien Riegel
2017-08-10 10:02 ` Srinivas Kandagatla
2017-08-10 13:33 ` Damien Riegel
2017-08-14 14:12 ` [alsa-devel] " Damien Riegel
2017-08-14 16:34 ` Srinivas Kandagatla
2017-08-16 17:48 ` Damien Riegel
2017-08-17 10:15 ` Srinivas Kandagatla
2017-08-09 16:49 ` srinivas.kandagatla [this message]
2017-08-09 16:49 ` [PATCH v3 5/5] arm64: dts: apq8016-sbc: add mbhc buttons support srinivas.kandagatla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170809164927.19663-5-srinivas.kandagatla@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@codeaurora.org \
--cc=broonie@kernel.org \
--cc=damien.riegel@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=plai@codeaurora.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®