Commit 00db9e70 authored by Gary Zhang's avatar Gary Zhang Committed by Terry Lv

ENGR00234111 wm8962: switch automatically between speaker and hp

when detect hp inserted, disable speaker; when hp is plugout,
enable speaker.
Signed-off-by: 's avatarGary Zhang <b13634@freescale.com>
parent 73e61d60
...@@ -184,6 +184,14 @@ static void headphone_detect_handler(struct work_struct *wor) ...@@ -184,6 +184,14 @@ static void headphone_detect_handler(struct work_struct *wor)
/*sysfs_notify(&pdev->dev.kobj, NULL, "headphone");*/ /*sysfs_notify(&pdev->dev.kobj, NULL, "headphone");*/
priv->hp_status = gpio_get_value(plat->hp_gpio); 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 */ /* setup a message for userspace headphone in */
buf = kmalloc(32, GFP_ATOMIC); buf = kmalloc(32, GFP_ATOMIC);
if (!buf) { if (!buf) {
...@@ -252,6 +260,8 @@ static void amic_detect_handler(struct work_struct *work) ...@@ -252,6 +260,8 @@ static void amic_detect_handler(struct work_struct *work)
else else
snd_soc_dapm_enable_pin(&gcodec->dapm, "DMIC"); snd_soc_dapm_enable_pin(&gcodec->dapm, "DMIC");
snd_soc_dapm_sync(&gcodec->dapm);
/* setup a message for userspace headphone in */ /* setup a message for userspace headphone in */
buf = kmalloc(32, GFP_ATOMIC); buf = kmalloc(32, GFP_ATOMIC);
if (!buf) { if (!buf) {
...@@ -341,6 +351,14 @@ static int imx_wm8962_init(struct snd_soc_pcm_runtime *rtd) ...@@ -341,6 +351,14 @@ static int imx_wm8962_init(struct snd_soc_pcm_runtime *rtd)
ret = -EINVAL; ret = -EINVAL;
return ret; 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) { if (plat->mic_gpio != -1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment