diff options
author | Zhang Jiejing <jiejing.zhang@freescale.com> | 2011-04-15 09:59:03 +0800 |
---|---|---|
committer | Jason Liu <r64343@freescale.com> | 2012-01-09 20:08:15 +0800 |
commit | c53b966d4d933644cc1be198c6335a135a1c23b7 (patch) | |
tree | 27b3b37e961eccda831ceee9e3052c2842c538db /sound/soc | |
parent | 85128ee03c81e98ccee54f1a931d1b5719e423a4 (diff) |
ENGR00137340-1 ASOC: add headphone detection support for imx-sgtl5000.c
add a asoc headphone detection, it's a generic way using by asoc area.
Signed-off-by: Zhang Jiejing <jiejing.zhang@freescale.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/imx/imx-sgtl5000.c | 47 |
1 files changed, 45 insertions, 2 deletions
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; } |