From b3f60f3ed24f503bda64aabf94b62053379c9ca9 Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen <lars@metafoo.de>
Date: Fri, 7 Jan 2011 16:39:43 +0100
Subject: [PATCH 58/69] wm8753: use snd_soc_jack on neo1973

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 sound/soc/samsung/neo1973_wm8753.c |   43 ++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/sound/soc/samsung/neo1973_wm8753.c b/sound/soc/samsung/neo1973_wm8753.c
index 4f845fe..a3a1cc8 100644
--- a/sound/soc/samsung/neo1973_wm8753.c
+++ b/sound/soc/samsung/neo1973_wm8753.c
@@ -19,6 +19,7 @@
 #include <linux/gpio.h>
 
 #include <sound/soc.h>
+#include <sound/jack.h>
 
 #include <asm/mach-types.h>
 #include <plat/regs-iis.h>
@@ -204,6 +205,29 @@ static const struct snd_soc_dapm_widget neo1973_wm8753_dapm_widgets[] = {
 	SND_SOC_DAPM_MIC("Handset Mic", NULL),
 };
 
+static struct snd_soc_jack hs_jack;
+
+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 const struct snd_soc_dapm_route neo1973_wm8753_routes[] = {
 	/* Connections to the GSM Module */
 	{"GSM Line Out", NULL, "MONO1"},
@@ -311,6 +335,24 @@ static int neo1973_gta02_wm8753_init(struct snd_soc_codec *codec)
 	snd_soc_dapm_ignore_suspend(dapm, "Stereo Out");
 	snd_soc_dapm_ignore_suspend(dapm, "Handset Spk");
 
+	ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, &hs_jack);
+	if (ret) {
+		dev_err(codec->card->dev, "failed to alloc headset jack\n");
+		return ret;
+	}
+
+	ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), hs_jack_pins);
+	if (ret) {
+		dev_err(codec->card->dev, "failed to add headset jack pins\n");
+		return ret;
+	}
+
+	ret = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios), hs_jack_gpios);
+	if (ret) {
+		dev_err(codec->card->dev, "failed to add headset jack gpios\n");
+		return ret;
+	}
+
 	return 0;
 }
 
@@ -527,6 +569,7 @@ module_init(neo1973_init);
 
 static void __exit neo1973_exit(void)
 {
+	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_gta02()) {
-- 
1.7.2.5

