Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1695978 > unrolled thread
| Started by | Damien Riegel <damien.riegel@savoirfairelinux.com> |
|---|---|
| First post | 2017-07-25 20:00 +0200 |
| Last post | 2017-07-26 21:50 +0200 |
| Articles | 9 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v1 0/3] add jack detection to MSM8916 analog Damien Riegel <damien.riegel@savoirfairelinux.com> - 2017-07-25 20:00 +0200
[PATCH v1 1/3] ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define Damien Riegel <damien.riegel@savoirfairelinux.com> - 2017-07-25 20:00 +0200
Re: [PATCH v1 1/3] ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-07-25 21:30 +0200
Applied "ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define" to the asoc tree Mark Brown <broonie@kernel.org> - 2017-07-27 21:10 +0200
[PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection Damien Riegel <damien.riegel@savoirfairelinux.com> - 2017-07-25 20:00 +0200
Re: [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection Mark Brown <broonie@kernel.org> - 2017-07-26 18:30 +0200
Re: [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection Mark Brown <broonie@kernel.org> - 2017-07-26 18:30 +0200
Re: [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-07-26 18:50 +0200
Re: [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection Damien Riegel <damien.riegel@savoirfairelinux.com> - 2017-07-26 21:50 +0200
| From | Damien Riegel <damien.riegel@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-25 20:00 +0200 |
| Subject | [PATCH v1 0/3] add jack detection to MSM8916 analog |
| Message-ID | <u7chH-5RB-3@gated-at.bofh.it> |
This series adds support for the MBHC (Multi-Button Headset Control) of the PM8916's analog codec. This IP is capable to identify up to five buttons on a headset, but for now only the jack detection is supported. A complete implementation exists in the Android kernel, but it's quite complex and I'd rather go step by step. First patch fixes a define that is squatting a bit used by the MBHC. Second patch is the actual implementation of the jack detection, and third patch plugs the jack detection in the sound card driver. Damien Riegel (3): ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define ASoC: codecs: msm8916-analog: support jack detection ASoC: qcom: apq8016-sbc: enable jack detection sound/soc/codecs/msm8916-wcd-analog.c | 105 +++++++++++++++++++++++++++++++++- sound/soc/codecs/msm8916-wcd-analog.h | 18 ++++++ sound/soc/qcom/apq8016_sbc.c | 16 ++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 sound/soc/codecs/msm8916-wcd-analog.h -- 2.13.3
[toc] | [next] | [standalone]
| From | Damien Riegel <damien.riegel@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-25 20:00 +0200 |
| Subject | [PATCH v1 1/3] ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define |
| Message-ID | <u7chI-5RB-19@gated-at.bofh.it> |
| In reply to | #1695978 |
The wrong bit is assigned to DIG_CLK_CTL_RXD3_CLK_EN, change it for the correct one. Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com> --- sound/soc/codecs/msm8916-wcd-analog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index aec1e1626993..0c351700044a 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -36,7 +36,7 @@ #define CDC_D_CDC_DIG_CLK_CTL (0xf04A) #define DIG_CLK_CTL_RXD1_CLK_EN BIT(0) #define DIG_CLK_CTL_RXD2_CLK_EN BIT(1) -#define DIG_CLK_CTL_RXD3_CLK_EN BIT(3) +#define DIG_CLK_CTL_RXD3_CLK_EN BIT(2) #define DIG_CLK_CTL_TXD_CLK_EN BIT(4) #define DIG_CLK_CTL_NCP_CLK_EN_MASK BIT(6) #define DIG_CLK_CTL_NCP_CLK_EN BIT(6) -- 2.13.3
[toc] | [prev] | [next] | [standalone]
| From | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> |
|---|---|
| Date | 2017-07-25 21:30 +0200 |
| Subject | Re: [PATCH v1 1/3] ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define |
| Message-ID | <u7dGN-6Sz-5@gated-at.bofh.it> |
| In reply to | #1695981 |
On 25/07/17 18:51, Damien Riegel wrote: > The wrong bit is assigned to DIG_CLK_CTL_RXD3_CLK_EN, change it for the > correct one. > > Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com> > --- > sound/soc/codecs/msm8916-wcd-analog.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c > index aec1e1626993..0c351700044a 100644 > --- a/sound/soc/codecs/msm8916-wcd-analog.c > +++ b/sound/soc/codecs/msm8916-wcd-analog.c > @@ -36,7 +36,7 @@ > #define CDC_D_CDC_DIG_CLK_CTL (0xf04A) > #define DIG_CLK_CTL_RXD1_CLK_EN BIT(0) > #define DIG_CLK_CTL_RXD2_CLK_EN BIT(1) > -#define DIG_CLK_CTL_RXD3_CLK_EN BIT(3) > +#define DIG_CLK_CTL_RXD3_CLK_EN BIT(2) > #define DIG_CLK_CTL_TXD_CLK_EN BIT(4) > #define DIG_CLK_CTL_NCP_CLK_EN_MASK BIT(6) > #define DIG_CLK_CTL_NCP_CLK_EN BIT(6) > Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2017-07-27 21:10 +0200 |
| Subject | Applied "ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define" to the asoc tree |
| Message-ID | <u7Wkx-1Bk-5@gated-at.bofh.it> |
| In reply to | #1695981 |
The patch ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define has been applied to the asoc tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From deab4563ad6a7f4668024455fa61b87f1d25ff73 Mon Sep 17 00:00:00 2001 From: Damien Riegel <damien.riegel@savoirfairelinux.com> Date: Tue, 25 Jul 2017 13:51:24 -0400 Subject: [PATCH] ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define The wrong bit is assigned to DIG_CLK_CTL_RXD3_CLK_EN, change it for the correct one. Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com> Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org> --- sound/soc/codecs/msm8916-wcd-analog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index a78802920c3c..5710fd440bcd 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -36,7 +36,7 @@ #define CDC_D_CDC_DIG_CLK_CTL (0xf04A) #define DIG_CLK_CTL_RXD1_CLK_EN BIT(0) #define DIG_CLK_CTL_RXD2_CLK_EN BIT(1) -#define DIG_CLK_CTL_RXD3_CLK_EN BIT(3) +#define DIG_CLK_CTL_RXD3_CLK_EN BIT(2) #define DIG_CLK_CTL_TXD_CLK_EN BIT(4) #define DIG_CLK_CTL_NCP_CLK_EN_MASK BIT(6) #define DIG_CLK_CTL_NCP_CLK_EN BIT(6) -- 2.13.2
[toc] | [prev] | [next] | [standalone]
| From | Damien Riegel <damien.riegel@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-25 20:00 +0200 |
| Subject | [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection |
| Message-ID | <u7chJ-5RB-37@gated-at.bofh.it> |
| In reply to | #1695978 |
The audio codec in the PM8916 has a feature called Multi-Button Headset
Control (MBHC). It can support of up to five buttons on a headset, and
jack insertion/removal detection.
This patch only supports the jack detection. A complete implementation
is available in the Android kernel [1] for reference.
[1] https://source.codeaurora.org/quic/la/kernel/msm-4.4/tree/sound/soc/codecs/wcd-mbhc-v2.c?h=LA.BR.1.2.4-00310-8x16.0
Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
sound/soc/codecs/msm8916-wcd-analog.c | 103 ++++++++++++++++++++++++++++++++++
sound/soc/codecs/msm8916-wcd-analog.h | 18 ++++++
2 files changed, 121 insertions(+)
create mode 100644 sound/soc/codecs/msm8916-wcd-analog.h
diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
index 0c351700044a..b9e11012f763 100644
--- a/sound/soc/codecs/msm8916-wcd-analog.c
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
@@ -8,6 +8,7 @@
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
+#include <sound/jack.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -37,6 +38,8 @@
#define DIG_CLK_CTL_RXD1_CLK_EN BIT(0)
#define DIG_CLK_CTL_RXD2_CLK_EN BIT(1)
#define DIG_CLK_CTL_RXD3_CLK_EN BIT(2)
+#define DIG_CLK_CTL_MBHC_EN_MASK BIT(3)
+#define DIG_CLK_CTL_MBHC_EN BIT(3)
#define DIG_CLK_CTL_TXD_CLK_EN BIT(4)
#define DIG_CLK_CTL_NCP_CLK_EN_MASK BIT(6)
#define DIG_CLK_CTL_NCP_CLK_EN BIT(6)
@@ -130,6 +133,10 @@
#define CDC_A_MICB_2_EN (0xf144)
#define CDC_A_TX_1_2_ATEST_CTL_2 (0xf145)
#define CDC_A_MASTER_BIAS_CTL (0xf146)
+#define CDC_A_MBHC_DET_CTL_1 (0xf147)
+#define MHBC_DET_CTL_1_DET_TYPE BIT(5)
+#define CDC_A_MBHC_DET_CTL_2 (0xf150)
+#define CDC_A_MBHC_DBNC_TIMER (0xf152)
#define CDC_A_TX_1_EN (0xf160)
#define CDC_A_TX_2_EN (0xf161)
#define CDC_A_TX_1_2_TEST_CTL_1 (0xf162)
@@ -221,8 +228,10 @@ static const char * const supply_names[] = {
struct pm8916_wcd_analog_priv {
u16 pmic_rev;
u16 codec_version;
+ struct snd_soc_codec *codec;
struct clk *mclk;
struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
+ struct snd_soc_jack *jack;
unsigned int micbias1_cap_mode;
unsigned int micbias2_cap_mode;
};
@@ -522,6 +531,7 @@ static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec)
return err;
}
+ priv->codec = codec;
snd_soc_codec_set_drvdata(codec, priv);
priv->pmic_rev = snd_soc_read(codec, CDC_D_REVISION1);
priv->codec_version = snd_soc_read(codec, CDC_D_PERPH_SUBTYPE);
@@ -547,6 +557,70 @@ static int pm8916_wcd_analog_remove(struct snd_soc_codec *codec)
priv->supplies);
}
+static irqreturn_t pm8916_wcd_analog_mbhc_switch_handler(int irq, void *data)
+{
+ struct pm8916_wcd_analog_priv *priv = data;
+ struct snd_soc_codec *codec = priv->codec;
+ unsigned int reg;
+ int mask, status;
+ bool insert;
+
+ if (!codec || !priv->jack)
+ return IRQ_HANDLED;
+
+ reg = snd_soc_read(codec, CDC_A_MBHC_DET_CTL_1);
+ insert = reg & MHBC_DET_CTL_1_DET_TYPE;
+ mask = SND_JACK_MECHANICAL;
+
+ dev_dbg(codec->dev, "detected jack %s\n",
+ insert ? "insertion" : "removal");
+
+ /* switch between insertion and removal detection */
+ snd_soc_update_bits(codec, CDC_A_MBHC_DET_CTL_1,
+ MHBC_DET_CTL_1_DET_TYPE,
+ reg ^ MHBC_DET_CTL_1_DET_TYPE);
+
+ if (insert)
+ status = SND_JACK_MECHANICAL;
+ else
+ status = 0;
+
+ snd_soc_jack_report(priv->jack, status, mask);
+
+ return IRQ_HANDLED;
+}
+
+
+/**
+ * pm8916_wcd_analog_jack_detect - Enable jack detection.
+ *
+ * @codec: msm8916 codec
+ * @jack: jack to report detection events on
+ *
+ * Enables jack detection of the pm8916-analog. It is capable of reporting
+ * mechanical insertion.
+ */
+int pm8916_wcd_analog_jack_detect(struct snd_soc_codec *codec,
+ struct snd_soc_jack *jack)
+{
+ struct pm8916_wcd_analog_priv *priv = snd_soc_codec_get_drvdata(codec);
+
+ priv->jack = jack;
+
+ snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL,
+ RST_CTL_DIG_SW_RST_N_MASK,
+ RST_CTL_DIG_SW_RST_N_REMOVE_RESET);
+ snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1, 0xB5);
+ snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2, 0xE1);
+ snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER, 0x98);
+ snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
+ DIG_CLK_CTL_MBHC_EN_MASK,
+ DIG_CLK_CTL_MBHC_EN);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(pm8916_wcd_analog_jack_detect);
+
static const struct snd_soc_dapm_route pm8916_wcd_analog_audio_map[] = {
{"PDM_RX1", NULL, "PDM Playback"},
@@ -799,6 +873,14 @@ static struct snd_soc_codec_driver pm8916_wcd_analog = {
},
};
+static struct jack_detect_irq {
+ const char *name;
+ irqreturn_t (*handler)(int, void *);
+} jack_detect_irqs[] = {
+ { "mbhc_switch_int", pm8916_wcd_analog_mbhc_switch_handler },
+ /* other MBHC related interrupts are not handled yet */
+};
+
static int pm8916_wcd_analog_parse_dt(struct device *dev,
struct pm8916_wcd_analog_priv *priv)
{
@@ -846,6 +928,27 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev)
return ret;
}
+ for (i = 0; i < ARRAY_SIZE(jack_detect_irqs); i++) {
+ int irq;
+
+ irq = platform_get_irq_byname(pdev, jack_detect_irqs[i].name);
+ if (irq < 0) {
+ dev_warn(dev, "failed to get irq '%s', jack insertion detection disabled\n",
+ jack_detect_irqs[i].name);
+ break;
+ }
+
+ ret = devm_request_threaded_irq(dev, irq, NULL,
+ jack_detect_irqs[i].handler,
+ IRQF_ONESHOT,
+ jack_detect_irqs[i].name, priv);
+ if (ret) {
+ dev_err(dev, "failed to request irq '%s': %d\n",
+ jack_detect_irqs[i].name, ret);
+ return ret;
+ }
+ }
+
ret = clk_prepare_enable(priv->mclk);
if (ret < 0) {
dev_err(dev, "failed to enable mclk %d\n", ret);
diff --git a/sound/soc/codecs/msm8916-wcd-analog.h b/sound/soc/codecs/msm8916-wcd-analog.h
new file mode 100644
index 000000000000..5cd00bb5f34a
--- /dev/null
+++ b/sound/soc/codecs/msm8916-wcd-analog.h
@@ -0,0 +1,18 @@
+/*
+ * msm8916-wcd-analog.h - MSM8916 analog audio codec interface
+ *
+ * Copyright 2017 - Savoir-faire Linux, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#ifndef _MSM8916_WCD_ANALOG_H
+#define _MSM8916_WCD_ANALOG_H
+
+int pm8916_wcd_analog_jack_detect(struct snd_soc_codec *codec,
+ struct snd_soc_jack *jack);
+
+#endif
--
2.13.3
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2017-07-26 18:30 +0200 |
| Subject | Re: [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection |
| Message-ID | <u7xm9-2CU-17@gated-at.bofh.it> |
| In reply to | #1695987 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jul 25, 2017 at 01:51:25PM -0400, Damien Riegel wrote:
> +int pm8916_wcd_analog_jack_detect(struct snd_soc_codec *codec,
> + struct snd_soc_jack *jack)
> +{
Sorry, also meant to mention: use the set_jack() operation to make it
easier to use with generic cards.
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2017-07-26 18:30 +0200 |
| Subject | Re: [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection |
| Message-ID | <u7xma-2CU-25@gated-at.bofh.it> |
| In reply to | #1695987 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jul 25, 2017 at 01:51:25PM -0400, Damien Riegel wrote:
> + for (i = 0; i < ARRAY_SIZE(jack_detect_irqs); i++) {
> + int irq;
> +
> + irq = platform_get_irq_byname(pdev, jack_detect_irqs[i].name);
> + if (irq < 0) {
> + dev_warn(dev, "failed to get irq '%s', jack insertion detection disabled\n",
> + jack_detect_irqs[i].name);
> + break;
> + }
> +
> + ret = devm_request_threaded_irq(dev, irq, NULL,
Don't put the loop in when there's only one IRQ, wait till it's needed.
This is an unusual pattern and it's not clear that just bombing out of
the loop with interrupts half requested is a good idea.
[toc] | [prev] | [next] | [standalone]
| From | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> |
|---|---|
| Date | 2017-07-26 18:50 +0200 |
| Subject | Re: [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection |
| Message-ID | <u7xFw-2JL-23@gated-at.bofh.it> |
| In reply to | #1695987 |
On 25/07/17 18:51, Damien Riegel wrote:
> The audio codec in the PM8916 has a feature called Multi-Button Headset
> Control (MBHC). It can support of up to five buttons on a headset, and
> jack insertion/removal detection.
>
> This patch only supports the jack detection. A complete implementation
> is available in the Android kernel [1] for reference.
>
> [1] https://source.codeaurora.org/quic/la/kernel/msm-4.4/tree/sound/soc/codecs/wcd-mbhc-v2.c?h=LA.BR.1.2.4-00310-8x16.0
>
> Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
If you have noticed it or not, but in the dai_shutdown patch the codec
is put in reset state, so this code only works for one time.
Once you do a playback session and end it this code will stop working.
> ---
> sound/soc/codecs/msm8916-wcd-analog.c | 103 ++++++++++++++++++++++++++++++++++
> sound/soc/codecs/msm8916-wcd-analog.h | 18 ++++++
> 2 files changed, 121 insertions(+)
> create mode 100644 sound/soc/codecs/msm8916-wcd-analog.h
>
> diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
>
...
> +
> +
> +/**
> + * pm8916_wcd_analog_jack_detect - Enable jack detection.
> + *
> + * @codec: msm8916 codec
> + * @jack: jack to report detection events on
> + *
> + * Enables jack detection of the pm8916-analog. It is capable of reporting
> + * mechanical insertion.
> + */
> +int pm8916_wcd_analog_jack_detect(struct snd_soc_codec *codec,
> + struct snd_soc_jack *jack)
> +{
> + struct pm8916_wcd_analog_priv *priv = snd_soc_codec_get_drvdata(codec);
> +
> + priv->jack = jack;
> +
> + snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL,
> + RST_CTL_DIG_SW_RST_N_MASK,
> + RST_CTL_DIG_SW_RST_N_REMOVE_RESET);
Why do you need this?
> + snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1, 0xB5);
> + snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2, 0xE1);
> + snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER, 0x98);
What do these values mean?
> + snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
> + DIG_CLK_CTL_MBHC_EN_MASK,
> + DIG_CLK_CTL_MBHC_EN);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(pm8916_wcd_analog_jack_detect);
> +
> static const struct snd_soc_dapm_route pm8916_wcd_analog_audio_map[] = {
>
> {"PDM_RX1", NULL, "PDM Playback"},
> @@ -799,6 +873,14 @@ static struct snd_soc_codec_driver pm8916_wcd_analog = {
> },
> };
>
> +static struct jack_detect_irq {
> + const char *name;
> + irqreturn_t (*handler)(int, void *);
> +} jack_detect_irqs[] = {
> + { "mbhc_switch_int", pm8916_wcd_analog_mbhc_switch_handler },
> + /* other MBHC related interrupts are not handled yet */
> +};
> +
> static int pm8916_wcd_analog_parse_dt(struct device *dev,
> struct pm8916_wcd_analog_priv *priv)
> {
> @@ -846,6 +928,27 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev)
> return ret;
> }
>
> + for (i = 0; i < ARRAY_SIZE(jack_detect_irqs); i++) {
> + int irq;
> +
> + irq = platform_get_irq_byname(pdev, jack_detect_irqs[i].name);
> + if (irq < 0) {
> + dev_warn(dev, "failed to get irq '%s', jack insertion detection disabled\n",
> + jack_detect_irqs[i].name);
> + break;
> + }
> +
> + ret = devm_request_threaded_irq(dev, irq, NULL,
> + jack_detect_irqs[i].handler,
> + IRQF_ONESHOT,
> + jack_detect_irqs[i].name, priv);
> + if (ret) {
> + dev_err(dev, "failed to request irq '%s': %d\n",
> + jack_detect_irqs[i].name, ret);
> + return ret;
> + }
> + }
> +
Not sure how it would work, Where are these interrupts enabled in the pmic?
> ret = clk_prepare_enable(priv->mclk);
[toc] | [prev] | [next] | [standalone]
| From | Damien Riegel <damien.riegel@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-26 21:50 +0200 |
| Subject | Re: [PATCH v1 2/3] ASoC: codecs: msm8916-analog: support jack detection |
| Message-ID | <u7AtH-4y2-1@gated-at.bofh.it> |
| In reply to | #1697353 |
On Wed, Jul 26, 2017 at 05:44:14PM +0100, Srinivas Kandagatla wrote:
>
>
> On 25/07/17 18:51, Damien Riegel wrote:
> > The audio codec in the PM8916 has a feature called Multi-Button Headset
> > Control (MBHC). It can support of up to five buttons on a headset, and
> > jack insertion/removal detection.
> >
> > This patch only supports the jack detection. A complete implementation
> > is available in the Android kernel [1] for reference.
> >
> > [1] https://source.codeaurora.org/quic/la/kernel/msm-4.4/tree/sound/soc/codecs/wcd-mbhc-v2.c?h=LA.BR.1.2.4-00310-8x16.0
> >
> > Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
>
> If you have noticed it or not, but in the dai_shutdown patch the codec is
> put in reset state, so this code only works for one time.
> Once you do a playback session and end it this code will stop working.
Right, I haven't tested that workflow, thanks.
>
>
> > ---
> > sound/soc/codecs/msm8916-wcd-analog.c | 103 ++++++++++++++++++++++++++++++++++
> > sound/soc/codecs/msm8916-wcd-analog.h | 18 ++++++
> > 2 files changed, 121 insertions(+)
> > create mode 100644 sound/soc/codecs/msm8916-wcd-analog.h
> >
> > diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
> >
> ...
> > +
> > +
> > +/**
> > + * pm8916_wcd_analog_jack_detect - Enable jack detection.
> > + *
> > + * @codec: msm8916 codec
> > + * @jack: jack to report detection events on
> > + *
> > + * Enables jack detection of the pm8916-analog. It is capable of reporting
> > + * mechanical insertion.
> > + */
> > +int pm8916_wcd_analog_jack_detect(struct snd_soc_codec *codec,
> > + struct snd_soc_jack *jack)
> > +{
> > + struct pm8916_wcd_analog_priv *priv = snd_soc_codec_get_drvdata(codec);
> > +
> > + priv->jack = jack;
> > +
> > + snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL,
> > + RST_CTL_DIG_SW_RST_N_MASK,
> > + RST_CTL_DIG_SW_RST_N_REMOVE_RESET);
> Why do you need this?
>
> > + snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1, 0xB5);
>
> > + snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2, 0xE1);
>
> > + snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER, 0x98);
> What do these values mean?
Right, define would definitely be better.
> > + snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL,
> > + DIG_CLK_CTL_MBHC_EN_MASK,
> > + DIG_CLK_CTL_MBHC_EN);
> > +
> > + return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(pm8916_wcd_analog_jack_detect);
> > +
> > static const struct snd_soc_dapm_route pm8916_wcd_analog_audio_map[] = {
> > {"PDM_RX1", NULL, "PDM Playback"},
> > @@ -799,6 +873,14 @@ static struct snd_soc_codec_driver pm8916_wcd_analog = {
> > },
> > };
> > +static struct jack_detect_irq {
> > + const char *name;
> > + irqreturn_t (*handler)(int, void *);
> > +} jack_detect_irqs[] = {
> > + { "mbhc_switch_int", pm8916_wcd_analog_mbhc_switch_handler },
> > + /* other MBHC related interrupts are not handled yet */
> > +};
> > +
> > static int pm8916_wcd_analog_parse_dt(struct device *dev,
> > struct pm8916_wcd_analog_priv *priv)
> > {
> > @@ -846,6 +928,27 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev)
> > return ret;
> > }
> > + for (i = 0; i < ARRAY_SIZE(jack_detect_irqs); i++) {
> > + int irq;
> > +
> > + irq = platform_get_irq_byname(pdev, jack_detect_irqs[i].name);
> > + if (irq < 0) {
> > + dev_warn(dev, "failed to get irq '%s', jack insertion detection disabled\n",
> > + jack_detect_irqs[i].name);
> > + break;
> > + }
> > +
> > + ret = devm_request_threaded_irq(dev, irq, NULL,
> > + jack_detect_irqs[i].handler,
> > + IRQF_ONESHOT,
> > + jack_detect_irqs[i].name, priv);
> > + if (ret) {
> > + dev_err(dev, "failed to request irq '%s': %d\n",
> > + jack_detect_irqs[i].name, ret);
> > + return ret;
> > + }
> > + }
> > +
> Not sure how it would work, Where are these interrupts enabled in the pmic?
Not sure I understand the question as this is very similar to what you
did in your patches. Anyway, as you sent a version that is more feature
complete than mine, I don't think there is much value in reviewing my
series of patches.
Regards,
--
Damien
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web