summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/fsl_devices.h4
-rw-r--r--sound/soc/imx/imx-sgtl5000.c47
2 files changed, 47 insertions, 4 deletions
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 7a3279f46e9e..9f4b8bff14b8 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -266,8 +266,8 @@ struct mxc_audio_platform_data {
int ext_ram;
struct clk *ssi_clk[2];
- int hp_irq;
- int (*hp_status) (void);
+ int hp_gpio;
+ int hp_active_low; /* headphone irq is active loaw */
int sysclk;
diff --git a/sound/soc/imx/imx-sgtl5000.c b/sound/soc/imx/imx-sgtl5000.c
index 3ccf26368039..4da55ad781bf 100644
--- a/sound/soc/imx/imx-sgtl5000.c
+++ b/sound/soc/imx/imx-sgtl5000.c
@@ -15,13 +15,15 @@
#include <linux/moduleparam.h>
#include <linux/device.h>
#include <linux/i2c.h>
+#include <linux/fsl_devices.h>
+#include <linux/gpio.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
+#include <sound/jack.h>
#include <sound/soc-dapm.h>
#include <asm/mach-types.h>
#include <mach/audmux.h>
-#include <linux/fsl_devices.h>
#include "../codecs/sgtl5000.h"
#include "imx-ssi.h"
@@ -32,8 +34,27 @@ static struct imx_sgtl5000_priv {
struct platform_device *pdev;
} card_priv;
+static struct snd_soc_jack hs_jack;
static struct snd_soc_card imx_sgtl5000;
+/* Headphones jack detection DAPM pins */
+static struct snd_soc_jack_pin hs_jack_pins[] = {
+ {
+ .pin = "Headphone Jack",
+ .mask = SND_JACK_HEADPHONE,
+ },
+};
+
+/* Headphones jack detection gpios */
+static struct snd_soc_jack_gpio hs_jack_gpios[] = {
+ [0] = {
+ /* gpio is set on per-platform basis */
+ .name = "hp-gpio",
+ .report = SND_JACK_HEADPHONE,
+ .debounce_time = 200,
+ },
+};
+
static int sgtl5000_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
@@ -226,9 +247,28 @@ static int imx_3stack_sgtl5000_init(struct snd_soc_pcm_runtime *rtd)
snd_soc_dapm_disable_pin(&codec->dapm, "Line In Jack");
snd_soc_dapm_enable_pin(&codec->dapm, "Headphone Jack");
-
snd_soc_dapm_sync(&codec->dapm);
+ /* Jack detection API stuff */
+ ret = snd_soc_jack_new(codec, "Headphone Jack",
+ SND_JACK_HEADPHONE, &hs_jack);
+ if (ret)
+ return ret;
+
+ ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
+ hs_jack_pins);
+ if (ret) {
+ printk(KERN_ERR "failed to call snd_soc_jack_add_pins\n");
+ return ret;
+ }
+
+ ret = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios),
+ hs_jack_gpios);
+ if (ret) {
+ printk(KERN_ERR "failed to call snd_soc_jack_add_gpios\n");
+ return ret;
+ }
+
return 0;
}
@@ -291,6 +331,9 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev)
card_priv.sysclk = plat->sysclk;
+ hs_jack_gpios[0].gpio = plat->hp_gpio;
+ hs_jack_gpios[0].invert = plat->hp_active_low;
+
return 0;
}