]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00234111 wm8962: switch automatically between speaker and hp
authorGary Zhang <b13634@freescale.com>
Wed, 28 Nov 2012 06:00:34 +0000 (14:00 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:46 +0000 (08:35 +0200)
when detect hp inserted, disable speaker; when hp is plugout,
enable speaker.

Signed-off-by: Gary Zhang <b13634@freescale.com>
sound/soc/imx/imx-wm8962.c

index 04aca39ab2d57205768097d91130730f93fbf732..a224518e305a5f6b97de87f779dfda0bdb509c73 100644 (file)
@@ -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) {