Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1731850 > unrolled thread
| Started by | Damien Riegel <damien.riegel@savoirfairelinux.com> |
|---|---|
| First post | 2017-09-13 22:50 +0200 |
| Last post | 2017-09-19 15:30 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[RFC] ASoC: codecs: msm8916-wcd-analog: use btn0 released detection Damien Riegel <damien.riegel@savoirfairelinux.com> - 2017-09-13 22:50 +0200
Re: [RFC] ASoC: codecs: msm8916-wcd-analog: use btn0 released detection Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-09-18 11:10 +0200
Re: [RFC] ASoC: codecs: msm8916-wcd-analog: use btn0 released detection Mark Brown <broonie@kernel.org> - 2017-09-19 14:20 +0200
Re: [RFC] ASoC: codecs: msm8916-wcd-analog: use btn0 released detection Damien Riegel <damien.riegel@savoirfairelinux.com> - 2017-09-19 15:30 +0200
| From | Damien Riegel <damien.riegel@savoirfairelinux.com> |
|---|---|
| Date | 2017-09-13 22:50 +0200 |
| Subject | [RFC] ASoC: codecs: msm8916-wcd-analog: use btn0 released detection |
| Message-ID | <upmLE-3Lv-13@gated-at.bofh.it> |
msm8916-wcd-analog uses button0 to differentiate between headphone and
headset. Under some circumstances, button pressed and released
interrupts are not fired as the driver expects it.
For instance, with some connectors, there are spurious button-pressed
interrupts when unplugging a headphone, without the corresponding
button-released interrupt. But the codec always alternates between
button pressed and released interrupts, it cannot fire two interrupts of
the same kind in a row. That means that when the headphone is plugged
back, only a button-released interrupt will be fired instead of pressed
then released. This causes the driver to report headphone as headset.
By changing the logic and relying on button 0 release interrupt, the
driver could be made more robust for connectors that differ from the one
used on the Dragonboard's audio mezzanine.
Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
sound/soc/codecs/msm8916-wcd-analog.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
index 549c269acc7d..f562f2d86907 100644
--- a/sound/soc/codecs/msm8916-wcd-analog.c
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
@@ -285,7 +285,7 @@ struct pm8916_wcd_analog_priv {
u16 codec_version;
bool mbhc_btn_enabled;
/* special event to detect accessory type */
- bool mbhc_btn0_pressed;
+ int mbhc_btn0_released;
bool detect_accessory_type;
struct clk *mclk;
struct snd_soc_codec *codec;
@@ -483,7 +483,7 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
- wcd->mbhc_btn0_pressed = false;
+ wcd->mbhc_btn0_released = false;
wcd->detect_accessory_type = true;
}
@@ -950,7 +950,7 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg)
/* check if its BTN0 thats released */
if ((val != -1) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK))
- priv->mbhc_btn0_pressed = false;
+ priv->mbhc_btn0_released = true;
} else {
snd_soc_jack_report(priv->jack, 0, btn_mask);
@@ -983,9 +983,7 @@ static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg)
break;
case 0x0:
/* handle BTN_0 specially for type detection */
- if (priv->detect_accessory_type)
- priv->mbhc_btn0_pressed = true;
- else
+ if (!priv->detect_accessory_type)
snd_soc_jack_report(priv->jack,
SND_JACK_BTN_0, btn_mask);
break;
@@ -1029,19 +1027,19 @@ static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg)
* both press and release event received then its
* a headset.
*/
- if (priv->mbhc_btn0_pressed)
+ if (priv->mbhc_btn0_released)
snd_soc_jack_report(priv->jack,
- SND_JACK_HEADPHONE, hs_jack_mask);
+ SND_JACK_HEADSET, hs_jack_mask);
else
snd_soc_jack_report(priv->jack,
- SND_JACK_HEADSET, hs_jack_mask);
+ SND_JACK_HEADPHONE, hs_jack_mask);
priv->detect_accessory_type = false;
} else { /* removal */
snd_soc_jack_report(priv->jack, 0, hs_jack_mask);
priv->detect_accessory_type = true;
- priv->mbhc_btn0_pressed = false;
+ priv->mbhc_btn0_released = false;
}
return IRQ_HANDLED;
--
2.14.1
[toc] | [next] | [standalone]
| From | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> |
|---|---|
| Date | 2017-09-18 11:10 +0200 |
| Subject | Re: [RFC] ASoC: codecs: msm8916-wcd-analog: use btn0 released detection |
| Message-ID | <ur0dX-47N-1@gated-at.bofh.it> |
| In reply to | #1731850 |
On 13/09/17 21:43, Damien Riegel wrote:
> msm8916-wcd-analog uses button0 to differentiate between headphone and
> headset. Under some circumstances, button pressed and released
> interrupts are not fired as the driver expects it.
>
This is what we need to understand to find a right solution,
I would like to understand on what is the difference in the hw layout.
To start with could you share the schematics/connections differences of
this area on how the lines are wired up, I would like to compare it with
https://www.dropbox.com/s/zqqrqhd9d2yw7pr/Audio%C2%A0Mezzanine%C2%A0Board-SCH-0113.pdf?dl=0
thanks,
srini
> For instance, with some connectors, there are spurious button-pressed
> interrupts when unplugging a headphone, without the corresponding
> button-released interrupt.
But the codec always alternates between
> button pressed and released interrupts, it cannot fire two interrupts of
> the same kind in a row. That means that when the headphone is plugged
> back, only a button-released interrupt will be fired instead of pressed
> then released. This causes the driver to report headphone as headset.
>
> By changing the logic and relying on button 0 release interrupt, the
> driver could be made more robust for connectors that differ from the one
> used on the Dragonboard's audio mezzanine.
>
> Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
> ---
> sound/soc/codecs/msm8916-wcd-analog.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
> index 549c269acc7d..f562f2d86907 100644
> --- a/sound/soc/codecs/msm8916-wcd-analog.c
> +++ b/sound/soc/codecs/msm8916-wcd-analog.c
> @@ -285,7 +285,7 @@ struct pm8916_wcd_analog_priv {
> u16 codec_version;
> bool mbhc_btn_enabled;
> /* special event to detect accessory type */
> - bool mbhc_btn0_pressed;
> + int mbhc_btn0_released;
> bool detect_accessory_type;
> struct clk *mclk;
> struct snd_soc_codec *codec;
> @@ -483,7 +483,7 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
>
> snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0);
> snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask);
> - wcd->mbhc_btn0_pressed = false;
> + wcd->mbhc_btn0_released = false;
> wcd->detect_accessory_type = true;
> }
>
> @@ -950,7 +950,7 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg)
>
> /* check if its BTN0 thats released */
> if ((val != -1) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK))
> - priv->mbhc_btn0_pressed = false;
> + priv->mbhc_btn0_released = true;
>
> } else {
> snd_soc_jack_report(priv->jack, 0, btn_mask);
> @@ -983,9 +983,7 @@ static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg)
> break;
> case 0x0:
> /* handle BTN_0 specially for type detection */
> - if (priv->detect_accessory_type)
> - priv->mbhc_btn0_pressed = true;
> - else
> + if (!priv->detect_accessory_type)
> snd_soc_jack_report(priv->jack,
> SND_JACK_BTN_0, btn_mask);
> break;
> @@ -1029,19 +1027,19 @@ static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg)
> * both press and release event received then its
> * a headset.
> */
> - if (priv->mbhc_btn0_pressed)
> + if (priv->mbhc_btn0_released)
> snd_soc_jack_report(priv->jack,
> - SND_JACK_HEADPHONE, hs_jack_mask);
> + SND_JACK_HEADSET, hs_jack_mask);
> else
> snd_soc_jack_report(priv->jack,
> - SND_JACK_HEADSET, hs_jack_mask);
> + SND_JACK_HEADPHONE, hs_jack_mask);
>
> priv->detect_accessory_type = false;
>
> } else { /* removal */
> snd_soc_jack_report(priv->jack, 0, hs_jack_mask);
> priv->detect_accessory_type = true;
> - priv->mbhc_btn0_pressed = false;
> + priv->mbhc_btn0_released = false;
> }
>
> return IRQ_HANDLED;
>
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2017-09-19 14:20 +0200 |
| Subject | Re: [RFC] ASoC: codecs: msm8916-wcd-analog: use btn0 released detection |
| Message-ID | <urpFo-5m4-25@gated-at.bofh.it> |
| In reply to | #1733770 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, Sep 18, 2017 at 10:08:04AM +0100, Srinivas Kandagatla wrote: > On 13/09/17 21:43, Damien Riegel wrote: > > msm8916-wcd-analog uses button0 to differentiate between headphone and > > headset. Under some circumstances, button pressed and released > > interrupts are not fired as the driver expects it. > This is what we need to understand to find a right solution, > I would like to understand on what is the difference in the hw layout. These sorts of problems can also occur because of differences in test process - pressure at different angles, different speeds of insertion and a million other things.
[toc] | [prev] | [next] | [standalone]
| From | Damien Riegel <damien.riegel@savoirfairelinux.com> |
|---|---|
| Date | 2017-09-19 15:30 +0200 |
| Subject | Re: [RFC] ASoC: codecs: msm8916-wcd-analog: use btn0 released detection |
| Message-ID | <urqL7-5ZC-3@gated-at.bofh.it> |
| In reply to | #1734858 |
On Tue, Sep 19, 2017 at 01:11:47PM +0100, Mark Brown wrote:
> On Mon, Sep 18, 2017 at 10:08:04AM +0100, Srinivas Kandagatla wrote:
> > On 13/09/17 21:43, Damien Riegel wrote:
> > > msm8916-wcd-analog uses button0 to differentiate between headphone and
> > > headset. Under some circumstances, button pressed and released
> > > interrupts are not fired as the driver expects it.
>
> > This is what we need to understand to find a right solution,
> > I would like to understand on what is the difference in the hw layout.
I asked the hardware team and the design is exactly the same, but we use
different mechanical parts (ie. the jack connector).
We've started comparing electrical signals between "Android on
Intrinsyc's eval kit" vs. "Linux on our device", just to get a broad
idea of what might be happening, and today we'll compare the two
hardware with the same software on it. I'll get back to you as soon as I
have more information.
> These sorts of problems can also occur because of differences in test
> process - pressure at different angles, different speeds of insertion
> and a million other things.
Definitely. I also noticed an issue with the first very detection
because the micbias will only be set the first time the driver gets a
mechanical insertion interrupt. Following snippet seems to solve the
problem:
diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c
index f562f2d86907..5045dabd9ea9 100644
--- a/sound/soc/codecs/msm8916-wcd-analog.c
+++ b/sound/soc/codecs/msm8916-wcd-analog.c
@@ -446,6 +446,7 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct
static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
{
struct snd_soc_codec *codec = wcd->codec;
+ bool micbias_enabled = false;
u32 plug_type = 0;
u32 int_en_mask;
@@ -477,6 +478,11 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd)
DIG_CLK_CTL_D_MBHC_CLK_EN_MASK,
DIG_CLK_CTL_D_MBHC_CLK_EN);
+ if (snd_soc_read(codec, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE)
+ micbias_enabled = true;
+
+ pm8916_mbhc_configure_bias(priv, micbias_enabled);
+
int_en_mask = MBHC_SWITCH_INT;
if (wcd->mbhc_btn_enabled)
int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web