summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorGary Zhang <b13634@freescale.com>2012-11-28 14:00:34 +0800
committerJason Liu <r64343@freescale.com>2012-11-28 17:05:05 +0800
commit0caf2bf739cea88fcc63482e3d61bac394ba2dbf (patch)
tree3c473835659840b9821a0096a0fe5452d1fa487b /sound
parentbf8e0bdac511ef72e2bc88094eae6f7e634b26ec (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>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/imx/imx-wm8962.c18
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) {