diff options
author | Gary Zhang <b13634@freescale.com> | 2012-11-28 14:00:34 +0800 |
---|---|---|
committer | Terry Lv <r65388@freescale.com> | 2012-11-29 11:42:34 +0800 |
commit | 00db9e70fe297551e3119b3b3a27b30ccbadbfe4 (patch) | |
tree | 6956bdc55e268a202e8a88ed31a981ae6675e8b5 | |
parent | 73e61d60c41f69a2061bd7baecc19494580b60d5 (diff) |
ENGR00234111 wm8962: switch automatically between speaker and hp
when detect hp inserted, disable speaker; when hp is plugout,
enable speaker.
Signed-off-by: Gary Zhang <b13634@freescale.com>
-rw-r--r-- | sound/soc/imx/imx-wm8962.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sound/soc/imx/imx-wm8962.c b/sound/soc/imx/imx-wm8962.c index 04aca39ab2d5..a224518e305a 100644 --- a/sound/soc/imx/imx-wm8962.c +++ b/sound/soc/imx/imx-wm8962.c @@ -184,6 +184,14 @@ static void headphone_detect_handler(struct work_struct *wor) /*sysfs_notify(&pdev->dev.kobj, NULL, "headphone");*/ priv->hp_status = gpio_get_value(plat->hp_gpio); + /* if headphone is inserted, disable speaker */ + if (priv->hp_status != plat->hp_active_low) + snd_soc_dapm_nc_pin(&gcodec->dapm, "Ext Spk"); + else + snd_soc_dapm_enable_pin(&gcodec->dapm, "Ext Spk"); + + snd_soc_dapm_sync(&gcodec->dapm); + /* setup a message for userspace headphone in */ buf = kmalloc(32, GFP_ATOMIC); if (!buf) { @@ -252,6 +260,8 @@ static void amic_detect_handler(struct work_struct *work) else snd_soc_dapm_enable_pin(&gcodec->dapm, "DMIC"); + snd_soc_dapm_sync(&gcodec->dapm); + /* setup a message for userspace headphone in */ buf = kmalloc(32, GFP_ATOMIC); if (!buf) { @@ -341,6 +351,14 @@ static int imx_wm8962_init(struct snd_soc_pcm_runtime *rtd) ret = -EINVAL; return ret; } + + priv->hp_status = gpio_get_value(plat->hp_gpio); + + /* if headphone is inserted, disable speaker */ + if (priv->hp_status != plat->hp_active_low) + snd_soc_dapm_nc_pin(&codec->dapm, "Ext Spk"); + else + snd_soc_dapm_enable_pin(&codec->dapm, "Ext Spk"); } if (plat->mic_gpio != -1) { |