[PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

Klaus 'mrmoku' Kurzmann
From: Klaus Kurzmann <[hidden email]>

This makes it report headset insert/pull events via
the gpio-keys input device again.

Signed-off-by: Klaus Kurzmann <[hidden email]>
---
 arch/arm/mach-s3c2442/mach-gta02.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c
index 7965cad..abcd08b 100644
--- a/arch/arm/mach-s3c2442/mach-gta02.c
+++ b/arch/arm/mach-s3c2442/mach-gta02.c
@@ -963,6 +963,13 @@ static struct gpio_keys_button gta02_buttons[] = {
  .type = EV_KEY,
  .debounce_interval = 100,
  },
+ {
+ .gpio = GTA02_GPIO_JACK_INSERT,
+ .code = SW_HEADPHONE_INSERT,
+ .desc = "Jack Insert",
+ .type = EV_SW,
+ .debounce_interval = 100,
+ },
 };
 
 static struct gpio_keys_platform_data gta02_buttons_pdata = {
--
1.7.0.1


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

Vasily Khoruzhick
В сообщении от 30 июня 2010 18:13:24 автор [hidden email] написал:
> From: Klaus Kurzmann <[hidden email]>
>
> This makes it report headset insert/pull events via
> the gpio-keys input device again.

You should use soc-jack API in your sound driver and jack input device will be
exported automagically :)

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

Klaus 'mrmoku' Kurzmann
Am Mittwoch, 30. Juni 2010, 17:31:24 schrieb Vasily Khoruzhick:
> В сообщении от 30 июня 2010 18:13:24 автор [hidden email] написал:
> > From: Klaus Kurzmann <[hidden email]>
> >
> > This makes it report headset insert/pull events via
> > the gpio-keys input device again.
>
> You should use soc-jack API in your sound driver and jack input device will
> be exported automagically :)

Thanks for the pointer :)

Looks like Lars even has a patch for it already.

--
Klaus 'mrmoku' Kurzmann

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

Vasily Khoruzhick
В сообщении от 30 июня 2010 18:56:48 автор Klaus 'mrmoku' Kurzmann написал:
> Thanks for the pointer :)

You're welcome :)

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

Mark Brown-3
In reply to this post by Klaus 'mrmoku' Kurzmann
On Wed, Jun 30, 2010 at 05:13:24PM +0200, [hidden email] wrote:
> From: Klaus Kurzmann <[hidden email]>
>
> This makes it report headset insert/pull events via
> the gpio-keys input device again.

> Signed-off-by: Klaus Kurzmann <[hidden email]>

This should probably be being done by the audio driver using the ASoC
jack detection framework.

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

Klaus 'mrmoku' Kurzmann
Am Donnerstag, 1. Juli 2010, 14:28:52 schrieb Mark Brown:

> On Wed, Jun 30, 2010 at 05:13:24PM +0200, [hidden email] wrote:
> > From: Klaus Kurzmann <[hidden email]>
> >
> > This makes it report headset insert/pull events via
> > the gpio-keys input device again.
> >
> > Signed-off-by: Klaus Kurzmann <[hidden email]>
>
> This should probably be being done by the audio driver using the ASoC
> jack detection framework.

yeah thanks. Somebody else pointed that out too... and it turned out that there
already was a patch for that - which did not find it's way in the openmoko
kernel repository yet.

I took that patch and adjusted it to apply to 2.6.32...
Does the following look better? :-)


diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c
index 5cc1ef2..643dae3 100644
--- a/sound/soc/s3c24xx/neo1973_wm8753.c
+++ b/sound/soc/s3c24xx/neo1973_wm8753.c
@@ -23,6 +23,7 @@
 #include <sound/pcm.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
+#include <sound/jack.h>
 #include <sound/tlv.h>
 
 #include <asm/mach-types.h>
@@ -38,6 +39,9 @@
 #include "lm4857.h"
 #include <linux/i2c.h>
 
+static struct snd_soc_card neo1973;
+static struct snd_soc_jack hs_jack;
+
 #ifdef CONFIG_MACH_NEO1973_GTA01
 
 static struct lm4857 {
@@ -495,6 +499,29 @@ static const struct snd_kcontrol_new wm8753_neo1973_gta02_controls[] = {};
 static const struct snd_soc_dapm_widget wm8753_dapm_widgets_gta02[] = {};
 #endif
 
+static struct snd_soc_jack_pin hs_jack_pins[] = {
+ {
+ .pin = "Headset Mic",
+ .mask = SND_JACK_MICROPHONE,
+ },
+ {
+ .pin = "Stereo Out",
+ .mask = SND_JACK_HEADPHONE,
+ .invert = 1,
+ },
+};
+
+static struct snd_soc_jack_gpio hs_jack_gpios[] = {
+ {
+ .gpio = GTA02_GPIO_JACK_INSERT,
+ .name = "headset-gpio",
+ .report = SND_JACK_HEADSET,
+ .debounce_time = 100,
+ },
+};
+
+
+
 static int neo1973_wm8753_init(struct snd_soc_codec *codec)
 {
  int err;
@@ -566,6 +593,24 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec)
 
  snd_soc_dapm_sync(codec);
 
+ err = snd_soc_jack_new(&neo1973, "Headset Jack", SND_JACK_HEADSET, &hs_jack);
+ if (err) {
+ dev_err(codec->card->dev, "failed to alloc headset jack\n");
+ return err;
+ }
+
+ err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), hs_jack_pins);
+ if (err) {
+ dev_err(codec->card->dev, "failed to add headset jack pins\n");
+ return err;
+ }
+
+ err = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), hs_jack_gpios);
+ if (err) {
+ dev_err(codec->card->dev, "failed to add headset jack gpios\n");
+ return err;
+ }
+
  return 0;
 }
 
@@ -740,6 +785,7 @@ static inline void neo1973_gta02_exit(void) {}
 static void __exit neo1973_exit(void)
 {
  snd_soc_unregister_dai(&bt_dai);
+ snd_soc_jack_free_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), hs_jack_gpios);
  platform_device_unregister(neo1973_snd_device);
 
  if (machine_is_neo1973_gta01())


--
Klaus 'mrmoku' Kurzmann

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

Mark Brown-3
On Thu, Jul 01, 2010 at 02:59:50PM +0200, Klaus 'mrmoku' Kurzmann wrote:
> Am Donnerstag, 1. Juli 2010, 14:28:52 schrieb Mark Brown:

> > This should probably be being done by the audio driver using the ASoC
> > jack detection framework.
>
> yeah thanks. Somebody else pointed that out too... and it turned out that there
> already was a patch for that - which did not find it's way in the openmoko
> kernel repository yet.
>
> I took that patch and adjusted it to apply to 2.6.32...
> Does the following look better? :-)

Yes.  Please do try to remember to contribute stuff to mainline, though.
The audio driver is already in mainline and the idea was to reduce
rather than increase the diff.

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] mach-gta02: add GTA02_GPIO_JACK_INSERT to the gpio_keys

Lars-Peter Clausen
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark Brown wrote:

> On Thu, Jul 01, 2010 at 02:59:50PM +0200, Klaus 'mrmoku' Kurzmann wrote:
>> Am Donnerstag, 1. Juli 2010, 14:28:52 schrieb Mark Brown:
>
>>> This should probably be being done by the audio driver using the ASoC
>>> jack detection framework.
>> yeah thanks. Somebody else pointed that out too... and it turned out that there
>> already was a patch for that - which did not find it's way in the openmoko
>> kernel repository yet.
>>
>> I took that patch and adjusted it to apply to 2.6.32...
>> Does the following look better? :-)
>
> Yes.  Please do try to remember to contribute stuff to mainline, though.
> The audio driver is already in mainline and the idea was to reduce
> rather than increase the diff.
>

Hi

It's on my radar, but I wanted to wait until the multi-platform branch has been merged.

- - Lars
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkws+YUACgkQBX4mSR26RiMrOACfWHopzTUsbEhUYlsiPYCjXJXu
yB0An0Ue+PLopQc1eRRffOBACSJl4Rkv
=/CLK
-----END PGP SIGNATURE-----