All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
@ 2014-10-01 21:25 Dylan Reid
       [not found] ` <1412198720-2326-1-git-send-email-dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Dylan Reid @ 2014-10-01 21:25 UTC (permalink / raw)
  To: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A, jay.xu-TNX95d0MmH7DzftRWevZcw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	sonnyrao-F7+t8E8rja9g9hUCZPvPmw, Dylan Reid

Allow Headphone and Microphone jack detect gpios to be specified in
device tree.  This will allow a few systems including rk3288_max98090
to use simple-card instead of having their own board file.

Signed-off-by: Dylan Reid <dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 .../devicetree/bindings/sound/simple-card.txt      |  4 ++
 sound/soc/generic/simple-card.c                    | 73 ++++++++++++++++++++++
 2 files changed, 77 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index c2e9841..72d94b7 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -17,6 +17,10 @@ Optional properties:
 					  source.
 - simple-audio-card,mclk-fs             : Multiplication factor between stream rate and codec
   					  mclk.
+- simple-audio-card,hp_det_gpio		: Reference to GPIO that signals when
+					  headphones are attached.
+- simple-audio-card,mic_det_gpio	: Reference to GPIO that signals when
+					  a microphone is attached.
 
 Optional subnodes:
 
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 709ce67..fcb431f 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -10,10 +10,13 @@
  */
 #include <linux/clk.h>
 #include <linux/device.h>
+#include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
+#include <sound/jack.h>
 #include <sound/simple_card.h>
 #include <sound/soc-dai.h>
 #include <sound/soc.h>
@@ -25,6 +28,8 @@ struct simple_card_data {
 		struct asoc_simple_dai codec_dai;
 	} *dai_props;
 	unsigned int mclk_fs;
+	int gpio_hp_det;
+	int gpio_mic_det;
 	struct snd_soc_dai_link dai_link[];	/* dynamically allocated */
 };
 
@@ -54,6 +59,32 @@ static struct snd_soc_ops asoc_simple_card_ops = {
 	.hw_params = asoc_simple_card_hw_params,
 };
 
+static struct snd_soc_jack simple_card_hp_jack;
+static struct snd_soc_jack_pin simple_card_hp_jack_pins[] = {
+	{
+		.pin = "Headphones",
+		.mask = SND_JACK_HEADPHONE,
+	},
+};
+static struct snd_soc_jack_gpio simple_card_hp_jack_gpio = {
+	.name = "Headphone detection",
+	.report = SND_JACK_HEADPHONE,
+	.debounce_time = 150,
+};
+
+static struct snd_soc_jack simple_card_mic_jack;
+static struct snd_soc_jack_pin simple_card_mic_jack_pins[] = {
+	{
+		.pin = "Mic Jack",
+		.mask = SND_JACK_MICROPHONE,
+	},
+};
+static struct snd_soc_jack_gpio simple_card_mic_jack_gpio = {
+	.name = "Mic detection",
+	.report = SND_JACK_MICROPHONE,
+	.debounce_time = 150,
+};
+
 static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
 				       struct asoc_simple_dai *set)
 {
@@ -109,6 +140,28 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 	if (ret < 0)
 		return ret;
 
+	if (gpio_is_valid(priv->gpio_hp_det)) {
+		snd_soc_jack_new(codec->codec, "Headphones", SND_JACK_HEADPHONE,
+				 &simple_card_hp_jack);
+		snd_soc_jack_add_pins(&simple_card_hp_jack,
+				      ARRAY_SIZE(simple_card_hp_jack_pins),
+				      simple_card_hp_jack_pins);
+
+		simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det;
+		snd_soc_jack_add_gpios(&simple_card_hp_jack, 1,
+				       &simple_card_hp_jack_gpio);
+	}
+
+	if (gpio_is_valid(priv->gpio_mic_det)) {
+		snd_soc_jack_new(codec->codec, "Mic Jack", SND_JACK_MICROPHONE,
+				 &simple_card_mic_jack);
+		snd_soc_jack_add_pins(&simple_card_mic_jack,
+				      ARRAY_SIZE(simple_card_mic_jack_pins),
+				      simple_card_mic_jack_pins);
+		simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det;
+		snd_soc_jack_add_gpios(&simple_card_mic_jack, 1,
+				       &simple_card_mic_jack_gpio);
+	}
 	return 0;
 }
 
@@ -383,6 +436,16 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 			return ret;
 	}
 
+	priv->gpio_hp_det = of_get_named_gpio(node,
+				"simple-audio-card,hp-det-gpio", 0);
+	if (priv->gpio_hp_det == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
+	priv->gpio_mic_det = of_get_named_gpio(node,
+				"simple-audio-card,mic-det-gpio", 0);
+	if (priv->gpio_mic_det == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
 	if (!priv->snd_card.name)
 		priv->snd_card.name = priv->snd_card.dai_link->name;
 
@@ -502,6 +565,16 @@ err:
 
 static int asoc_simple_card_remove(struct platform_device *pdev)
 {
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct simple_card_data *priv = snd_soc_card_get_drvdata(card);
+
+	if (gpio_is_valid(priv->gpio_hp_det))
+		snd_soc_jack_free_gpios(&simple_card_hp_jack, 1,
+					&simple_card_hp_jack_gpio);
+	if (gpio_is_valid(priv->gpio_mic_det))
+		snd_soc_jack_free_gpios(&simple_card_mic_jack, 1,
+					&simple_card_mic_jack_gpio);
+
 	return asoc_simple_card_unref(pdev);
 }
 
-- 
2.1.0.rc2.206.gedb03e5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
       [not found] ` <1412198720-2326-1-git-send-email-dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2014-10-02 15:53   ` Mark Brown
  2014-10-07 12:32       ` Geert Uytterhoeven
  2014-10-02 16:25   ` [alsa-devel] " Lars-Peter Clausen
  2014-10-22  6:44   ` Jianqun
  2 siblings, 1 reply; 19+ messages in thread
From: Mark Brown @ 2014-10-02 15:53 UTC (permalink / raw)
  To: Dylan Reid
  Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw, jay.xu-TNX95d0MmH7DzftRWevZcw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	sonnyrao-F7+t8E8rja9g9hUCZPvPmw

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

On Wed, Oct 01, 2014 at 02:25:20PM -0700, Dylan Reid wrote:
> Allow Headphone and Microphone jack detect gpios to be specified in
> device tree.  This will allow a few systems including rk3288_max98090
> to use simple-card instead of having their own board file.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
       [not found] ` <1412198720-2326-1-git-send-email-dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2014-10-02 15:53   ` Mark Brown
@ 2014-10-02 16:25   ` Lars-Peter Clausen
       [not found]     ` <542D7C73.20801-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
  2014-10-22  6:44   ` Jianqun
  2 siblings, 1 reply; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-10-02 16:25 UTC (permalink / raw)
  To: Dylan Reid, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw
  Cc: sonnyrao-F7+t8E8rja9g9hUCZPvPmw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, jay.xu-TNX95d0MmH7DzftRWevZcw

On 10/01/2014 11:25 PM, Dylan Reid wrote:
> diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
> index c2e9841..72d94b7 100644
> --- a/Documentation/devicetree/bindings/sound/simple-card.txt
> +++ b/Documentation/devicetree/bindings/sound/simple-card.txt
> @@ -17,6 +17,10 @@ Optional properties:
>   					  source.
>   - simple-audio-card,mclk-fs             : Multiplication factor between stream rate and codec
>     					  mclk.
> +- simple-audio-card,hp_det_gpio		: Reference to GPIO that signals when
> +					  headphones are attached.
> +- simple-audio-card,mic_det_gpio	: Reference to GPIO that signals when

The code has this correct, the "_"s should be "-"s.

- Lars

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
       [not found]     ` <542D7C73.20801-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
@ 2014-10-02 16:57       ` Dylan Reid
  0 siblings, 0 replies; 19+ messages in thread
From: Dylan Reid @ 2014-10-02 16:57 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw, Sonny Rao,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Brown,
	jay.xu-TNX95d0MmH7DzftRWevZcw

On Thu, Oct 2, 2014 at 9:25 AM, Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org> wrote:
> On 10/01/2014 11:25 PM, Dylan Reid wrote:
>>
>> diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt
>> b/Documentation/devicetree/bindings/sound/simple-card.txt
>> index c2e9841..72d94b7 100644
>> --- a/Documentation/devicetree/bindings/sound/simple-card.txt
>> +++ b/Documentation/devicetree/bindings/sound/simple-card.txt
>> @@ -17,6 +17,10 @@ Optional properties:
>>                                           source.
>>   - simple-audio-card,mclk-fs             : Multiplication factor between
>> stream rate and codec
>>                                           mclk.
>> +- simple-audio-card,hp_det_gpio                : Reference to GPIO that
>> signals when
>> +                                         headphones are attached.
>> +- simple-audio-card,mic_det_gpio       : Reference to GPIO that signals
>> when
>
>
> The code has this correct, the "_"s should be "-"s.

Indeed, my fault.  Sorry about that.  I will post a patch once the
first one propagates.

>
> - Lars
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
  2014-10-02 15:53   ` Mark Brown
@ 2014-10-07 12:32       ` Geert Uytterhoeven
  0 siblings, 0 replies; 19+ messages in thread
From: Geert Uytterhoeven @ 2014-10-07 12:32 UTC (permalink / raw)
  To: Mark Brown, Dylan Reid
  Cc: ALSA Development Mailing List, jay.xu, devicetree, sonnyrao,
	Kuninori Morimoto, Linux-sh list

Hi Mark, Dylan,

On Thu, Oct 2, 2014 at 5:53 PM, Mark Brown <broonie@kernel.org> wrote:
> On Wed, Oct 01, 2014 at 02:25:20PM -0700, Dylan Reid wrote:
>> Allow Headphone and Microphone jack detect gpios to be specified in
>> device tree.  This will allow a few systems including rk3288_max98090
>> to use simple-card instead of having their own board file.
>
> Applied, thanks.

Unfortunately there's no equivalent code for platform data, and the
uninitialized default of 0 for gpio_hp_det and gpio_mic_det doesn't
play well with asm-generic's gpio_is_valid():

static inline bool gpio_is_valid(int number)
{
        return number >= 0 && number < ARCH_NR_GPIOS;
}

Hence on r8a7740/armadillo-legacy, which uses platform devices instead of DT:

    sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec
    sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones
    sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Mic Jack

After that the kernel log is spammed ca. 7 times per second with:

    sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones

Reverting commit 3fe240326cc395c66 ("ASoC: simple-card: Add mic and
hp detect gpios.") fixes this.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
@ 2014-10-07 12:32       ` Geert Uytterhoeven
  0 siblings, 0 replies; 19+ messages in thread
From: Geert Uytterhoeven @ 2014-10-07 12:32 UTC (permalink / raw)
  To: Mark Brown, Dylan Reid
  Cc: ALSA Development Mailing List, jay.xu, devicetree, sonnyrao,
	Kuninori Morimoto, Linux-sh list

Hi Mark, Dylan,

On Thu, Oct 2, 2014 at 5:53 PM, Mark Brown <broonie@kernel.org> wrote:
> On Wed, Oct 01, 2014 at 02:25:20PM -0700, Dylan Reid wrote:
>> Allow Headphone and Microphone jack detect gpios to be specified in
>> device tree.  This will allow a few systems including rk3288_max98090
>> to use simple-card instead of having their own board file.
>
> Applied, thanks.

Unfortunately there's no equivalent code for platform data, and the
uninitialized default of 0 for gpio_hp_det and gpio_mic_det doesn't
play well with asm-generic's gpio_is_valid():

static inline bool gpio_is_valid(int number)
{
        return number >= 0 && number < ARCH_NR_GPIOS;
}

Hence on r8a7740/armadillo-legacy, which uses platform devices instead of DT:

    sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec
    sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones
    sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Mic Jack

After that the kernel log is spammed ca. 7 times per second with:

    sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones

Reverting commit 3fe240326cc395c66 ("ASoC: simple-card: Add mic and
hp detect gpios.") fixes this.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
  2014-10-07 12:32       ` Geert Uytterhoeven
@ 2014-10-07 12:38         ` Mark Brown
  -1 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2014-10-07 12:38 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Dylan Reid, ALSA Development Mailing List, jay.xu, devicetree,
	sonnyrao, Kuninori Morimoto, Linux-sh list

[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

On Tue, Oct 07, 2014 at 02:32:57PM +0200, Geert Uytterhoeven wrote:

> Hence on r8a7740/armadillo-legacy, which uses platform devices instead of DT:

>     sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec
>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones
>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Mic Jack

> After that the kernel log is spammed ca. 7 times per second with:

>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones

> Reverting commit 3fe240326cc395c66 ("ASoC: simple-card: Add mic and
> hp detect gpios.") fixes this.

The fix here is to not allow 0 as a GPIO in the core code (which
should've been there already).

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
@ 2014-10-07 12:38         ` Mark Brown
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2014-10-07 12:38 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Dylan Reid, ALSA Development Mailing List, jay.xu, devicetree,
	sonnyrao, Kuninori Morimoto, Linux-sh list

[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

On Tue, Oct 07, 2014 at 02:32:57PM +0200, Geert Uytterhoeven wrote:

> Hence on r8a7740/armadillo-legacy, which uses platform devices instead of DT:

>     sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec
>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones
>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Mic Jack

> After that the kernel log is spammed ca. 7 times per second with:

>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones

> Reverting commit 3fe240326cc395c66 ("ASoC: simple-card: Add mic and
> hp detect gpios.") fixes this.

The fix here is to not allow 0 as a GPIO in the core code (which
should've been there already).

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
  2014-10-07 12:38         ` Mark Brown
@ 2014-10-07 13:10           ` Geert Uytterhoeven
  -1 siblings, 0 replies; 19+ messages in thread
From: Geert Uytterhoeven @ 2014-10-07 13:10 UTC (permalink / raw)
  To: Mark Brown, Linus Walleij, Alexandre Courbot
  Cc: Dylan Reid, ALSA Development Mailing List, jay.xu, devicetree,
	sonnyrao, Kuninori Morimoto, Linux-sh list, linux-gpio

(re-added some context, CC Linus, Alexandre, linux-gpio)

On Tue, Oct 7, 2014 at 2:38 PM, Mark Brown <broonie@kernel.org> wrote:
> On Tue, Oct 07, 2014 at 02:32:57PM +0200, Geert Uytterhoeven wrote:
>> Unfortunately there's no equivalent code for platform data, and the
>> uninitialized default of 0 for gpio_hp_det and gpio_mic_det doesn't
>> play well with asm-generic's gpio_is_valid():
>>
>> static inline bool gpio_is_valid(int number)
>> {
>>         return number >= 0 && number < ARCH_NR_GPIOS;
>> }
>>
>> Hence on r8a7740/armadillo-legacy, which uses platform devices instead of DT:
>
>>     sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec
>>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones
>>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Mic Jack
>
>> After that the kernel log is spammed ca. 7 times per second with:
>
>>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones
>
>> Reverting commit 3fe240326cc395c66 ("ASoC: simple-card: Add mic and
>> hp detect gpios.") fixes this.
>
> The fix here is to not allow 0 as a GPIO in the core code (which
> should've been there already).

Unfortunately it's not there.

And it's not as simple as changing the definition of gpio_is_valid()
(crash in gpio_get_value()):

    gpiochip_add: GPIOs 0..211 (r8a7740_pfc) failed to register
    sh-pfc pfc-r8a7740: failed to init GPIO chip, ignoring...
    sh-pfc pfc-r8a7740: r8a7740_pfc support registered
    Unable to handle kernel NULL pointer dereference at virtual address 0000004c

Quoting Linus (https://lkml.org/lkml/2014/9/4/464):
"Fixing the old global GPIO numberspace API is a waste of time IMO".

Hence I've just sent a patch to initialize the GPIO numbers with -ENOENT.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
@ 2014-10-07 13:10           ` Geert Uytterhoeven
  0 siblings, 0 replies; 19+ messages in thread
From: Geert Uytterhoeven @ 2014-10-07 13:10 UTC (permalink / raw)
  To: Mark Brown, Linus Walleij, Alexandre Courbot
  Cc: Dylan Reid, ALSA Development Mailing List, jay.xu, devicetree,
	sonnyrao, Kuninori Morimoto, Linux-sh list, linux-gpio

(re-added some context, CC Linus, Alexandre, linux-gpio)

On Tue, Oct 7, 2014 at 2:38 PM, Mark Brown <broonie@kernel.org> wrote:
> On Tue, Oct 07, 2014 at 02:32:57PM +0200, Geert Uytterhoeven wrote:
>> Unfortunately there's no equivalent code for platform data, and the
>> uninitialized default of 0 for gpio_hp_det and gpio_mic_det doesn't
>> play well with asm-generic's gpio_is_valid():
>>
>> static inline bool gpio_is_valid(int number)
>> {
>>         return number >= 0 && number < ARCH_NR_GPIOS;
>> }
>>
>> Hence on r8a7740/armadillo-legacy, which uses platform devices instead of DT:
>
>>     sh-mobile-hdmi sh-mobile-hdmi: SH Mobile HDMI Audio Codec
>>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones
>>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Mic Jack
>
>> After that the kernel log is spammed ca. 7 times per second with:
>
>>     sh-mobile-hdmi sh-mobile-hdmi: ASoC: DAPM unknown pin Headphones
>
>> Reverting commit 3fe240326cc395c66 ("ASoC: simple-card: Add mic and
>> hp detect gpios.") fixes this.
>
> The fix here is to not allow 0 as a GPIO in the core code (which
> should've been there already).

Unfortunately it's not there.

And it's not as simple as changing the definition of gpio_is_valid()
(crash in gpio_get_value()):

    gpiochip_add: GPIOs 0..211 (r8a7740_pfc) failed to register
    sh-pfc pfc-r8a7740: failed to init GPIO chip, ignoring...
    sh-pfc pfc-r8a7740: r8a7740_pfc support registered
    Unable to handle kernel NULL pointer dereference at virtual address 0000004c

Quoting Linus (https://lkml.org/lkml/2014/9/4/464):
"Fixing the old global GPIO numberspace API is a waste of time IMO".

Hence I've just sent a patch to initialize the GPIO numbers with -ENOENT.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
  2014-10-07 13:10           ` Geert Uytterhoeven
@ 2014-10-07 16:36             ` Mark Brown
  -1 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2014-10-07 16:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Alexandre Courbot, Dylan Reid,
	ALSA Development Mailing List, jay.xu, devicetree, sonnyrao,
	Kuninori Morimoto, Linux-sh list, linux-gpio

[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]

On Tue, Oct 07, 2014 at 03:10:01PM +0200, Geert Uytterhoeven wrote:
> On Tue, Oct 7, 2014 at 2:38 PM, Mark Brown <broonie@kernel.org> wrote:

> > The fix here is to not allow 0 as a GPIO in the core code (which
> > should've been there already).

> Unfortunately it's not there.

> And it's not as simple as changing the definition of gpio_is_valid()
> (crash in gpio_get_value()):

>     gpiochip_add: GPIOs 0..211 (r8a7740_pfc) failed to register
>     sh-pfc pfc-r8a7740: failed to init GPIO chip, ignoring...
>     sh-pfc pfc-r8a7740: r8a7740_pfc support registered
>     Unable to handle kernel NULL pointer dereference at virtual address 0000004c

Right, obviously it's not going to work if the platform actually uses 0
as a valid GPIO.

> Quoting Linus (https://lkml.org/lkml/2014/9/4/464):
> "Fixing the old global GPIO numberspace API is a waste of time IMO".

> Hence I've just sent a patch to initialize the GPIO numbers with -ENOENT.

I do think it's worth renumbering the platforms since it's *relatively*
little work per platform compared to completing the gpiod transition.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
@ 2014-10-07 16:36             ` Mark Brown
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2014-10-07 16:36 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linus Walleij, Alexandre Courbot, Dylan Reid,
	ALSA Development Mailing List, jay.xu, devicetree, sonnyrao,
	Kuninori Morimoto, Linux-sh list, linux-gpio

[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]

On Tue, Oct 07, 2014 at 03:10:01PM +0200, Geert Uytterhoeven wrote:
> On Tue, Oct 7, 2014 at 2:38 PM, Mark Brown <broonie@kernel.org> wrote:

> > The fix here is to not allow 0 as a GPIO in the core code (which
> > should've been there already).

> Unfortunately it's not there.

> And it's not as simple as changing the definition of gpio_is_valid()
> (crash in gpio_get_value()):

>     gpiochip_add: GPIOs 0..211 (r8a7740_pfc) failed to register
>     sh-pfc pfc-r8a7740: failed to init GPIO chip, ignoring...
>     sh-pfc pfc-r8a7740: r8a7740_pfc support registered
>     Unable to handle kernel NULL pointer dereference at virtual address 0000004c

Right, obviously it's not going to work if the platform actually uses 0
as a valid GPIO.

> Quoting Linus (https://lkml.org/lkml/2014/9/4/464):
> "Fixing the old global GPIO numberspace API is a waste of time IMO".

> Hence I've just sent a patch to initialize the GPIO numbers with -ENOENT.

I do think it's worth renumbering the platforms since it's *relatively*
little work per platform compared to completing the gpiod transition.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
  2014-10-07 16:36             ` Mark Brown
@ 2014-10-08  7:05               ` Alexandre Courbot
  -1 siblings, 0 replies; 19+ messages in thread
From: Alexandre Courbot @ 2014-10-08  7:05 UTC (permalink / raw)
  To: Mark Brown
  Cc: Geert Uytterhoeven, Linus Walleij, Dylan Reid,
	ALSA Development Mailing List, jay.xu, devicetree, sonnyrao,
	Kuninori Morimoto, Linux-sh list, linux-gpio

On Wed, Oct 8, 2014 at 1:36 AM, Mark Brown <broonie@kernel.org> wrote:
> On Tue, Oct 07, 2014 at 03:10:01PM +0200, Geert Uytterhoeven wrote:
>> On Tue, Oct 7, 2014 at 2:38 PM, Mark Brown <broonie@kernel.org> wrote:
>
>> > The fix here is to not allow 0 as a GPIO in the core code (which
>> > should've been there already).
>
>> Unfortunately it's not there.
>
>> And it's not as simple as changing the definition of gpio_is_valid()
>> (crash in gpio_get_value()):
>
>>     gpiochip_add: GPIOs 0..211 (r8a7740_pfc) failed to register
>>     sh-pfc pfc-r8a7740: failed to init GPIO chip, ignoring...
>>     sh-pfc pfc-r8a7740: r8a7740_pfc support registered
>>     Unable to handle kernel NULL pointer dereference at virtual address 0000004c
>
> Right, obviously it's not going to work if the platform actually uses 0
> as a valid GPIO.
>
>> Quoting Linus (https://lkml.org/lkml/2014/9/4/464):
>> "Fixing the old global GPIO numberspace API is a waste of time IMO".
>
>> Hence I've just sent a patch to initialize the GPIO numbers with -ENOENT.
>
> I do think it's worth renumbering the platforms since it's *relatively*
> little work per platform compared to completing the gpiod transition.

But transition to gpiod is the way to ultimately fix this issue, as
well as many others. Not to mention that renumbering GPIOs will
certainly make a few users of the GPIO sysfs (another abomination,
agreed) unhappy. I can only recommend switching drivers to gpiod when
such issues are spotted.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
@ 2014-10-08  7:05               ` Alexandre Courbot
  0 siblings, 0 replies; 19+ messages in thread
From: Alexandre Courbot @ 2014-10-08  7:05 UTC (permalink / raw)
  To: Mark Brown
  Cc: Geert Uytterhoeven, Linus Walleij, Dylan Reid,
	ALSA Development Mailing List, jay.xu, devicetree, sonnyrao,
	Kuninori Morimoto, Linux-sh list, linux-gpio

On Wed, Oct 8, 2014 at 1:36 AM, Mark Brown <broonie@kernel.org> wrote:
> On Tue, Oct 07, 2014 at 03:10:01PM +0200, Geert Uytterhoeven wrote:
>> On Tue, Oct 7, 2014 at 2:38 PM, Mark Brown <broonie@kernel.org> wrote:
>
>> > The fix here is to not allow 0 as a GPIO in the core code (which
>> > should've been there already).
>
>> Unfortunately it's not there.
>
>> And it's not as simple as changing the definition of gpio_is_valid()
>> (crash in gpio_get_value()):
>
>>     gpiochip_add: GPIOs 0..211 (r8a7740_pfc) failed to register
>>     sh-pfc pfc-r8a7740: failed to init GPIO chip, ignoring...
>>     sh-pfc pfc-r8a7740: r8a7740_pfc support registered
>>     Unable to handle kernel NULL pointer dereference at virtual address 0000004c
>
> Right, obviously it's not going to work if the platform actually uses 0
> as a valid GPIO.
>
>> Quoting Linus (https://lkml.org/lkml/2014/9/4/464):
>> "Fixing the old global GPIO numberspace API is a waste of time IMO".
>
>> Hence I've just sent a patch to initialize the GPIO numbers with -ENOENT.
>
> I do think it's worth renumbering the platforms since it's *relatively*
> little work per platform compared to completing the gpiod transition.

But transition to gpiod is the way to ultimately fix this issue, as
well as many others. Not to mention that renumbering GPIOs will
certainly make a few users of the GPIO sysfs (another abomination,
agreed) unhappy. I can only recommend switching drivers to gpiod when
such issues are spotted.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
  2014-10-08  7:05               ` Alexandre Courbot
@ 2014-10-08  8:50                 ` Linus Walleij
  -1 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2014-10-08  8:50 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: devicetree, ALSA Development Mailing List, Linux-sh list,
	Sonny Rao, linux-gpio, Mark Brown, Geert Uytterhoeven,
	Dylan Reid, jay.xu, Kuninori Morimoto

On Wed, Oct 8, 2014 at 9:05 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
> On Wed, Oct 8, 2014 at 1:36 AM, Mark Brown <broonie@kernel.org> wrote:
>> On Tue, Oct 07, 2014 at 03:10:01PM +0200, Geert Uytterhoeven wrote:

>> Right, obviously it's not going to work if the platform actually uses 0
>> as a valid GPIO.
>>
>>> Quoting Linus (https://lkml.org/lkml/2014/9/4/464):
>>> "Fixing the old global GPIO numberspace API is a waste of time IMO".
>>
>>> Hence I've just sent a patch to initialize the GPIO numbers with -ENOENT.
>>
>> I do think it's worth renumbering the platforms since it's *relatively*
>> little work per platform compared to completing the gpiod transition.
>
> But transition to gpiod is the way to ultimately fix this issue, as
> well as many others. Not to mention that renumbering GPIOs will
> certainly make a few users of the GPIO sysfs (another abomination,
> agreed) unhappy. I can only recommend switching drivers to gpiod when
> such issues are spotted.

Yeah that is another issue ... we end up in catch 22 situations like
that, renumber the GPIOs, OK, then we break the ABI.

Admittedly that "ABI" is something people break all the time,
/sys/*gpioN just isnt what it should be, not stable at all.

I'm not against renumbering GPIO if it's minor effort, but if it
start to consume hundreds of hours and regressions and what not,
that time is better spent focusing on the gpiod transition.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
@ 2014-10-08  8:50                 ` Linus Walleij
  0 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2014-10-08  8:50 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: devicetree, ALSA Development Mailing List, Linux-sh list,
	Sonny Rao, linux-gpio, Mark Brown, Geert Uytterhoeven,
	Dylan Reid, jay.xu, Kuninori Morimoto

On Wed, Oct 8, 2014 at 9:05 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
> On Wed, Oct 8, 2014 at 1:36 AM, Mark Brown <broonie@kernel.org> wrote:
>> On Tue, Oct 07, 2014 at 03:10:01PM +0200, Geert Uytterhoeven wrote:

>> Right, obviously it's not going to work if the platform actually uses 0
>> as a valid GPIO.
>>
>>> Quoting Linus (https://lkml.org/lkml/2014/9/4/464):
>>> "Fixing the old global GPIO numberspace API is a waste of time IMO".
>>
>>> Hence I've just sent a patch to initialize the GPIO numbers with -ENOENT.
>>
>> I do think it's worth renumbering the platforms since it's *relatively*
>> little work per platform compared to completing the gpiod transition.
>
> But transition to gpiod is the way to ultimately fix this issue, as
> well as many others. Not to mention that renumbering GPIOs will
> certainly make a few users of the GPIO sysfs (another abomination,
> agreed) unhappy. I can only recommend switching drivers to gpiod when
> such issues are spotted.

Yeah that is another issue ... we end up in catch 22 situations like
that, renumber the GPIOs, OK, then we break the ABI.

Admittedly that "ABI" is something people break all the time,
/sys/*gpioN just isnt what it should be, not stable at all.

I'm not against renumbering GPIO if it's minor effort, but if it
start to consume hundreds of hours and regressions and what not,
that time is better spent focusing on the gpiod transition.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
  2014-10-08  8:50                 ` Linus Walleij
@ 2014-10-08 11:40                   ` Mark Brown
  -1 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2014-10-08 11:40 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Alexandre Courbot, ALSA Development Mailing List, devicetree,
	Sonny Rao, Linux-sh list, linux-gpio, Geert Uytterhoeven,
	Dylan Reid, jay.xu, Kuninori Morimoto

[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]

On Wed, Oct 08, 2014 at 10:50:00AM +0200, Linus Walleij wrote:
> On Wed, Oct 8, 2014 at 9:05 AM, Alexandre Courbot <gnurou@gmail.com> wrote:

> > But transition to gpiod is the way to ultimately fix this issue, as
> > well as many others. Not to mention that renumbering GPIOs will
> > certainly make a few users of the GPIO sysfs (another abomination,
> > agreed) unhappy. I can only recommend switching drivers to gpiod when
> > such issues are spotted.

> Yeah that is another issue ... we end up in catch 22 situations like
> that, renumber the GPIOs, OK, then we break the ABI.

> Admittedly that "ABI" is something people break all the time,
> /sys/*gpioN just isnt what it should be, not stable at all.

> I'm not against renumbering GPIO if it's minor effort, but if it
> start to consume hundreds of hours and regressions and what not,
> that time is better spent focusing on the gpiod transition.

My guess is that it's relatively little work for most platforms - with
the systems I've done enough work on to notice everything is keyed off a
few defines in the header file.  Things tend to be worse in out of tree
code but mainline's generally been pretty good.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
@ 2014-10-08 11:40                   ` Mark Brown
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2014-10-08 11:40 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Alexandre Courbot, ALSA Development Mailing List, devicetree,
	Sonny Rao, Linux-sh list, linux-gpio, Geert Uytterhoeven,
	Dylan Reid, jay.xu, Kuninori Morimoto


[-- Attachment #1.1: Type: text/plain, Size: 1172 bytes --]

On Wed, Oct 08, 2014 at 10:50:00AM +0200, Linus Walleij wrote:
> On Wed, Oct 8, 2014 at 9:05 AM, Alexandre Courbot <gnurou@gmail.com> wrote:

> > But transition to gpiod is the way to ultimately fix this issue, as
> > well as many others. Not to mention that renumbering GPIOs will
> > certainly make a few users of the GPIO sysfs (another abomination,
> > agreed) unhappy. I can only recommend switching drivers to gpiod when
> > such issues are spotted.

> Yeah that is another issue ... we end up in catch 22 situations like
> that, renumber the GPIOs, OK, then we break the ABI.

> Admittedly that "ABI" is something people break all the time,
> /sys/*gpioN just isnt what it should be, not stable at all.

> I'm not against renumbering GPIO if it's minor effort, but if it
> start to consume hundreds of hours and regressions and what not,
> that time is better spent focusing on the gpiod transition.

My guess is that it's relatively little work for most platforms - with
the systems I've done enough work on to notice everything is keyed off a
few defines in the header file.  Things tend to be worse in out of tree
code but mainline's generally been pretty good.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] ASoC: simple-card: Add mic and hp detect gpios.
       [not found] ` <1412198720-2326-1-git-send-email-dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2014-10-02 15:53   ` Mark Brown
  2014-10-02 16:25   ` [alsa-devel] " Lars-Peter Clausen
@ 2014-10-22  6:44   ` Jianqun
  2 siblings, 0 replies; 19+ messages in thread
From: Jianqun @ 2014-10-22  6:44 UTC (permalink / raw)
  To: Dylan Reid, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A, jay.xu-TNX95d0MmH7DzftRWevZcw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	sonnyrao-F7+t8E8rja9g9hUCZPvPmw


在 10/02/2014 05:25 AM, Dylan Reid 写道:
> Allow Headphone and Microphone jack detect gpios to be specified in
> device tree.  This will allow a few systems including rk3288_max98090
> to use simple-card instead of having their own board file.
>
> Signed-off-by: Dylan Reid <dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> ---
>  .../devicetree/bindings/sound/simple-card.txt      |  4 ++
>  sound/soc/generic/simple-card.c                    | 73 ++++++++++++++++++++++
>  2 files changed, 77 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
> index c2e9841..72d94b7 100644
> --- a/Documentation/devicetree/bindings/sound/simple-card.txt
> +++ b/Documentation/devicetree/bindings/sound/simple-card.txt
> @@ -17,6 +17,10 @@ Optional properties:
>  					  source.
>  - simple-audio-card,mclk-fs             : Multiplication factor between stream rate and codec
>    					  mclk.
> +- simple-audio-card,hp_det_gpio		: Reference to GPIO that signals when
> +					  headphones are attached.
> +- simple-audio-card,mic_det_gpio	: Reference to GPIO that signals when
> +					  a microphone is attached.
>  
>  Optional subnodes:
>  
> diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
> index 709ce67..fcb431f 100644
> --- a/sound/soc/generic/simple-card.c
> +++ b/sound/soc/generic/simple-card.c
> @@ -10,10 +10,13 @@
>   */
>  #include <linux/clk.h>
>  #include <linux/device.h>
> +#include <linux/gpio.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_gpio.h>
>  #include <linux/platform_device.h>
>  #include <linux/string.h>
> +#include <sound/jack.h>
>  #include <sound/simple_card.h>
>  #include <sound/soc-dai.h>
>  #include <sound/soc.h>
> @@ -25,6 +28,8 @@ struct simple_card_data {
>  		struct asoc_simple_dai codec_dai;
>  	} *dai_props;
>  	unsigned int mclk_fs;
> +	int gpio_hp_det;
> +	int gpio_mic_det;
>  	struct snd_soc_dai_link dai_link[];	/* dynamically allocated */
>  };
>  
> @@ -54,6 +59,32 @@ static struct snd_soc_ops asoc_simple_card_ops = {
>  	.hw_params = asoc_simple_card_hw_params,
>  };
>  
> +static struct snd_soc_jack simple_card_hp_jack;
> +static struct snd_soc_jack_pin simple_card_hp_jack_pins[] = {
> +	{
> +		.pin = "Headphones",
> +		.mask = SND_JACK_HEADPHONE,
> +	},
> +};
> +static struct snd_soc_jack_gpio simple_card_hp_jack_gpio = {
> +	.name = "Headphone detection",
> +	.report = SND_JACK_HEADPHONE,
> +	.debounce_time = 150,
I think some board needs "invert" trigger level, i.e need to add "invert" property in dt ?
Pinky board do need it.
> +};
> +
> +static struct snd_soc_jack simple_card_mic_jack;
> +static struct snd_soc_jack_pin simple_card_mic_jack_pins[] = {
> +	{
> +		.pin = "Mic Jack",
> +		.mask = SND_JACK_MICROPHONE,
> +	},
> +};
> +static struct snd_soc_jack_gpio simple_card_mic_jack_gpio = {
> +	.name = "Mic detection",
> +	.report = SND_JACK_MICROPHONE,
> +	.debounce_time = 150,
> +};
> +
>  static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
>  				       struct asoc_simple_dai *set)
>  {
> @@ -109,6 +140,28 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
>  	if (ret < 0)
>  		return ret;
>  
> +	if (gpio_is_valid(priv->gpio_hp_det)) {
> +		snd_soc_jack_new(codec->codec, "Headphones", SND_JACK_HEADPHONE,
> +				 &simple_card_hp_jack);
> +		snd_soc_jack_add_pins(&simple_card_hp_jack,
> +				      ARRAY_SIZE(simple_card_hp_jack_pins),
> +				      simple_card_hp_jack_pins);
> +
> +		simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det;
> +		snd_soc_jack_add_gpios(&simple_card_hp_jack, 1,
> +				       &simple_card_hp_jack_gpio);
> +	}
> +
> +	if (gpio_is_valid(priv->gpio_mic_det)) {
> +		snd_soc_jack_new(codec->codec, "Mic Jack", SND_JACK_MICROPHONE,
> +				 &simple_card_mic_jack);
> +		snd_soc_jack_add_pins(&simple_card_mic_jack,
> +				      ARRAY_SIZE(simple_card_mic_jack_pins),
> +				      simple_card_mic_jack_pins);
> +		simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det;
> +		snd_soc_jack_add_gpios(&simple_card_mic_jack, 1,
> +				       &simple_card_mic_jack_gpio);
> +	}
>  	return 0;
>  }
>  
> @@ -383,6 +436,16 @@ static int asoc_simple_card_parse_of(struct device_node *node,
>  			return ret;
>  	}
>  
> +	priv->gpio_hp_det = of_get_named_gpio(node,
> +				"simple-audio-card,hp-det-gpio", 0);
> +	if (priv->gpio_hp_det == -EPROBE_DEFER)
> +		return -EPROBE_DEFER;
> +
> +	priv->gpio_mic_det = of_get_named_gpio(node,
> +				"simple-audio-card,mic-det-gpio", 0);
> +	if (priv->gpio_mic_det == -EPROBE_DEFER)
> +		return -EPROBE_DEFER;
> +
>  	if (!priv->snd_card.name)
>  		priv->snd_card.name = priv->snd_card.dai_link->name;
>  
> @@ -502,6 +565,16 @@ err:
>  
>  static int asoc_simple_card_remove(struct platform_device *pdev)
>  {
> +	struct snd_soc_card *card = platform_get_drvdata(pdev);
> +	struct simple_card_data *priv = snd_soc_card_get_drvdata(card);
> +
> +	if (gpio_is_valid(priv->gpio_hp_det))
> +		snd_soc_jack_free_gpios(&simple_card_hp_jack, 1,
> +					&simple_card_hp_jack_gpio);
> +	if (gpio_is_valid(priv->gpio_mic_det))
> +		snd_soc_jack_free_gpios(&simple_card_mic_jack, 1,
> +					&simple_card_mic_jack_gpio);
> +
>  	return asoc_simple_card_unref(pdev);
>  }
>  

-- 
Jianqun Xu

****************************************************************************
*IMPORTANT NOTICE:*This email is from Fuzhou Rockchip Electronics Co.,
Ltd .The contents of this email and any attachments may contain
information that is privileged, confidential and/or exempt from
disclosure under applicable law and relevant NDA. If you are not the
intended recipient, you are hereby notified that any disclosure,
copying, distribution, or use of the information is STRICTLY PROHIBITED.
Please immediately contact the sender as soon as possible and destroy
the material in its entirety in any format. Thank you.
****************************************************************************


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-10-22  6:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-01 21:25 [PATCH] ASoC: simple-card: Add mic and hp detect gpios Dylan Reid
     [not found] ` <1412198720-2326-1-git-send-email-dgreid-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2014-10-02 15:53   ` Mark Brown
2014-10-07 12:32     ` Geert Uytterhoeven
2014-10-07 12:32       ` Geert Uytterhoeven
2014-10-07 12:38       ` Mark Brown
2014-10-07 12:38         ` Mark Brown
2014-10-07 13:10         ` Geert Uytterhoeven
2014-10-07 13:10           ` Geert Uytterhoeven
2014-10-07 16:36           ` Mark Brown
2014-10-07 16:36             ` Mark Brown
2014-10-08  7:05             ` Alexandre Courbot
2014-10-08  7:05               ` Alexandre Courbot
2014-10-08  8:50               ` Linus Walleij
2014-10-08  8:50                 ` Linus Walleij
2014-10-08 11:40                 ` Mark Brown
2014-10-08 11:40                   ` Mark Brown
2014-10-02 16:25   ` [alsa-devel] " Lars-Peter Clausen
     [not found]     ` <542D7C73.20801-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2014-10-02 16:57       ` Dylan Reid
2014-10-22  6:44   ` Jianqun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.