Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1695977 > unrolled thread

[PATCH v1 3/3] ASoC: qcom: apq8016-sbc: enable jack detection

Started byDamien Riegel <damien.riegel@savoirfairelinux.com>
First post2017-07-25 20:00 +0200
Last post2017-07-26 18:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v1 3/3] ASoC: qcom: apq8016-sbc: enable jack detection Damien Riegel <damien.riegel@savoirfairelinux.com> - 2017-07-25 20:00 +0200
    Re: [PATCH v1 3/3] ASoC: qcom: apq8016-sbc: enable jack detection Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-07-26 18:40 +0200

#1695977 — [PATCH v1 3/3] ASoC: qcom: apq8016-sbc: enable jack detection

FromDamien Riegel <damien.riegel@savoirfairelinux.com>
Date2017-07-25 20:00 +0200
Subject[PATCH v1 3/3] ASoC: qcom: apq8016-sbc: enable jack detection
Message-ID<u7chH-5RB-1@gated-at.bofh.it>
Now that the pm8916 audio codec has support for jack detection, let the
sound card driver use it.

Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
---
 sound/soc/qcom/apq8016_sbc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c
index d084d7468299..5f03f6249397 100644
--- a/sound/soc/qcom/apq8016_sbc.c
+++ b/sound/soc/qcom/apq8016_sbc.c
@@ -19,11 +19,14 @@
 #include <linux/of.h>
 #include <linux/clk.h>
 #include <linux/platform_device.h>
+#include <sound/jack.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
 #include <dt-bindings/sound/apq8016-lpass.h>
 
+#include "../codecs/msm8916-wcd-analog.h"
+
 struct apq8016_sbc_data {
 	void __iomem *mic_iomux;
 	void __iomem *spkr_iomux;
@@ -35,13 +38,26 @@ struct apq8016_sbc_data {
 #define MIC_CTRL_TLMM_SCLK_EN		BIT(1)
 #define	SPKR_CTL_PRI_WS_SLAVE_SEL_11	(BIT(17) | BIT(16))
 
+static struct snd_soc_jack apq8016_jack;
+
 static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_card *card = rtd->card;
+	struct snd_soc_codec *codec = rtd->codec;
 	struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card);
 	int rval = 0;
 
+	if (!apq8016_jack.jack) {
+		rval = snd_soc_card_jack_new(card, "headset",
+					     SND_JACK_MECHANICAL,
+					     &apq8016_jack, NULL, 0);
+		if (rval)
+			return rval;
+
+		pm8916_wcd_analog_jack_detect(codec, &apq8016_jack);
+	}
+
 	switch (cpu_dai->id) {
 	case MI2S_PRIMARY:
 		writel(readl(pdata->spkr_iomux) | SPKR_CTL_PRI_WS_SLAVE_SEL_11,
-- 
2.13.3

[toc] | [next] | [standalone]


#1697343

FromSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Date2017-07-26 18:40 +0200
Message-ID<u7xvP-2Ga-13@gated-at.bofh.it>
In reply to#1695977

On 25/07/17 18:51, Damien Riegel wrote:
> Now that the pm8916 audio codec has support for jack detection, let the
> sound card driver use it.

> 
> Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
> ---
>   sound/soc/qcom/apq8016_sbc.c | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
> 
> diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c
> index d084d7468299..5f03f6249397 100644
> --- a/sound/soc/qcom/apq8016_sbc.c
> +++ b/sound/soc/qcom/apq8016_sbc.c
> @@ -19,11 +19,14 @@
>   #include <linux/of.h>
>   #include <linux/clk.h>
>   #include <linux/platform_device.h>
> +#include <sound/jack.h>
>   #include <sound/pcm.h>
>   #include <sound/pcm_params.h>
>   #include <sound/soc.h>
>   #include <dt-bindings/sound/apq8016-lpass.h>
>   
> +#include "../codecs/msm8916-wcd-analog.h"
> +
>   struct apq8016_sbc_data {
>   	void __iomem *mic_iomux;
>   	void __iomem *spkr_iomux;
> @@ -35,13 +38,26 @@ struct apq8016_sbc_data {
>   #define MIC_CTRL_TLMM_SCLK_EN		BIT(1)
>   #define	SPKR_CTL_PRI_WS_SLAVE_SEL_11	(BIT(17) | BIT(16))
>   
> +static struct snd_soc_jack apq8016_jack;
> +
>   static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd)
>   {
>   	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
>   	struct snd_soc_card *card = rtd->card;
> +	struct snd_soc_codec *codec = rtd->codec;

This driver uses multicodec, so this will not work to start with.
Also this function is used for different codec devices on the SOC, so we 
should take care that we are might be talking to 3 different possible 
codecs.

>   	struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card);
>   	int rval = 0;
>   
> +	if (!apq8016_jack.jack) {
> +		rval = snd_soc_card_jack_new(card, "headset",
> +					     SND_JACK_MECHANICAL,
> +					     &apq8016_jack, NULL, 0);
> +		if (rval)
> +			return rval;
> +
> +		pm8916_wcd_analog_jack_detect(codec, &apq8016_jack);
We already have an api to do this snd_soc_codec_set_jack()

> +	}
> +
>   	switch (cpu_dai->id) {
>   	case MI2S_PRIMARY:
>   		writel(readl(pdata->spkr_iomux) | SPKR_CTL_PRI_WS_SLAVE_SEL_11,
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web