]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00238943 wm8962: add judgement for no det_pin case
authorGary Zhang <b13634@freescale.com>
Sat, 5 Jan 2013 02:28:59 +0000 (10:28 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:49 +0000 (08:35 +0200)
add judgement to avoid no detect pin case

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

index e7b60df131809e280e9529bcfcccaff2b6e572e0..23f9a17588cb3f7eb2a33cd157ce12472e624664 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * imx-wm8962.c
  *
- * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2012-2013 Freescale Semiconductor, Inc. All Rights Reserved.
  */
 
 /*
@@ -225,23 +225,26 @@ static int imx_event_hp(struct snd_soc_dapm_widget *w,
        char *envp[3];
        char *buf;
 
-       buf = kmalloc(32, GFP_ATOMIC);
-       if (!buf) {
-               pr_err("%s kmalloc failed\n", __func__);
-               return -ENOMEM;
-       }
-       priv->hp_status = gpio_get_value(plat->hp_gpio);
+       if (plat->hp_gpio != -1) {
+               priv->hp_status = gpio_get_value(plat->hp_gpio);
 
-       if (priv->hp_status != plat->hp_active_low)
-               snprintf(buf, 32, "STATE=%d", 2);
-       else
-               snprintf(buf, 32, "STATE=%d", 0);
+               buf = kmalloc(32, GFP_ATOMIC);
+               if (!buf) {
+                       pr_err("%s kmalloc failed\n", __func__);
+                       return -ENOMEM;
+               }
 
-       envp[0] = "NAME=headphone";
-       envp[1] = buf;
-       envp[2] = NULL;
-       kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, envp);
-       kfree(buf);
+               if (priv->hp_status != plat->hp_active_low)
+                       snprintf(buf, 32, "STATE=%d", 2);
+               else
+                       snprintf(buf, 32, "STATE=%d", 0);
+
+               envp[0] = "NAME=headphone";
+               envp[1] = buf;
+               envp[2] = NULL;
+               kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, envp);
+               kfree(buf);
+       }
 
        return 0;
 }
@@ -255,24 +258,26 @@ static int imx_event_mic(struct snd_soc_dapm_widget *w,
        char *envp[3];
        char *buf;
 
-       priv->amic_status = gpio_get_value(plat->mic_gpio);
+       if (plat->mic_gpio != -1) {
+               priv->amic_status = gpio_get_value(plat->mic_gpio);
 
-       buf = kmalloc(32, GFP_ATOMIC);
-       if (!buf) {
-               pr_err("%s kmalloc failed\n", __func__);
-               return -ENOMEM;
-       }
+               buf = kmalloc(32, GFP_ATOMIC);
+               if (!buf) {
+                       pr_err("%s kmalloc failed\n", __func__);
+                       return -ENOMEM;
+               }
 
-       if (priv->amic_status == 0)
-               snprintf(buf, 32, "STATE=%d", 2);
-       else
-               snprintf(buf, 32, "STATE=%d", 0);
+               if (priv->amic_status == 0)
+                       snprintf(buf, 32, "STATE=%d", 2);
+               else
+                       snprintf(buf, 32, "STATE=%d", 0);
 
-       envp[0] = "NAME=amic";
-       envp[1] = buf;
-       envp[2] = NULL;
-       kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, envp);
-       kfree(buf);
+               envp[0] = "NAME=amic";
+               envp[1] = buf;
+               envp[2] = NULL;
+               kobject_uevent_env(&pdev->dev.kobj, KOBJ_CHANGE, envp);
+               kfree(buf);
+       }
 
        return 0;
 }
@@ -381,8 +386,6 @@ static int imx_wm8962_init(struct snd_soc_pcm_runtime *rtd)
        snd_soc_dapm_enable_pin(&codec->dapm, "Headphone Jack");
        snd_soc_dapm_enable_pin(&codec->dapm, "AMIC");
 
-       snd_soc_dapm_sync(&codec->dapm);
-
        if (plat->hp_gpio != -1) {
                imx_hp_jack_gpio.gpio = plat->hp_gpio;
                snd_soc_jack_new(codec, "Ext Spk", SND_JACK_LINEOUT,
@@ -417,8 +420,12 @@ static int imx_wm8962_init(struct snd_soc_pcm_runtime *rtd)
                        ret = -EINVAL;
                        return ret;
                }
+       } else {
+               snd_soc_dapm_nc_pin(&codec->dapm, "DMIC");
        }
 
+       snd_soc_dapm_sync(&codec->dapm);
+
        return 0;
 }