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

Klaus 'mrmoku' Kurzmann mok at mnet-online.de
Thu Jul 1 14:59:50 CEST 2010


Am Donnerstag, 1. Juli 2010, 14:28:52 schrieb Mark Brown:
> On Wed, Jun 30, 2010 at 05:13:24PM +0200, mok at mnet-online.de wrote:
> > From: Klaus Kurzmann <mok at fluxnetz.de>
> > 
> > This makes it report headset insert/pull events via
> > the gpio-keys input device again.
> > 
> > Signed-off-by: Klaus Kurzmann <mok at fluxnetz.de>
> 
> 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



More information about the openmoko-kernel mailing list