wm8994: incall status wm8994 cannot into suspend
author邱建斌 <qjb@rock-chips.com>
Fri, 10 Feb 2012 10:47:51 +0000 (18:47 +0800)
committer邱建斌 <qjb@rock-chips.com>
Fri, 10 Feb 2012 10:47:51 +0000 (18:47 +0800)
drivers/mfd/wm8994-core.c
include/linux/mfd/wm8994/pdata.h
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm8994.h
sound/soc/codecs/wm_hubs.c

index 1005847fbb14e9dd6eeae8ea8c42872fdfd9cae5..040d9b4552f98e2bb0a846b30567e9dbeea994b8 100755 (executable)
@@ -276,9 +276,15 @@ static const char *wm8958_main_supplies[] = {
 static int wm8994_suspend(struct device *dev)
 {
        struct wm8994 *wm8994 = dev_get_drvdata(dev);
+       struct wm8994_pdata *pdata = wm8994->dev->platform_data;        
        int ret;
        
-//     printk("on wm8994-core.c wm8994_suspend\n");
+       printk("on wm8994-core.c wm8994_suspend\n");
+       if(pdata->lineout_status)
+       {
+               printk("lineout is work cannot suspend\n");
+               return 0;
+       }
        /* Don't actually go through with the suspend if the CODEC is
         * still active (eg, for audio passthrough from CP. */
        ret = wm8994_reg_read(wm8994, WM8994_POWER_MANAGEMENT_1);
@@ -324,9 +330,15 @@ static int wm8994_suspend(struct device *dev)
 static int wm8994_resume(struct device *dev)
 {
        struct wm8994 *wm8994 = dev_get_drvdata(dev);
+       struct wm8994_pdata *pdata = wm8994->dev->platform_data;                
        int ret;
        
-//     printk("on wm8994-core.c wm8994_resume\n");
+       printk("on wm8994-core.c wm8994_resume\n");
+       if(pdata->lineout_status)
+       {
+               printk("lineout is work cannot suspend\n");
+               return 0;
+       }       
        /* We may have lied to the PM core about suspending */
        if (!wm8994->suspended)
                return 0;
index 0e0855a94edc90133a1d1658260b8d275b5b7287..fc697fd61dca131138f8b8d85c40320a7899e582 100755 (executable)
@@ -177,7 +177,8 @@ struct wm8994_pdata {
 
        /* WM8958 microphone bias configuration */
        int micbias[2];
-       
+
+       unsigned int lineout_status:1;
 };
 
 #endif
index 1a7ead6c3e8551e4ea834eff9fbad066633195ef..700a1f1e3f57360cb75acb57683c0b2949e666b3 100755 (executable)
@@ -909,6 +909,35 @@ static int wm8994_PA_event(struct snd_soc_dapm_widget *w,
        return 0;
 }
 
+int lineout_event(struct snd_soc_dapm_widget *w,
+                         struct snd_kcontrol *control, int event)
+{
+       struct snd_soc_codec *codec = w->codec;
+       struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
+       struct wm8994_pdata *pdata = wm8994->pdata;
+       
+//     printk("Enter %s::%s---%d\n",__FILE__,__FUNCTION__,__LINE__);
+       
+       switch (event) {
+       case SND_SOC_DAPM_POST_PMU:
+               printk("wm8994 is incall status\n");
+               pdata->lineout_status = 1;
+               
+               break;
+
+       case SND_SOC_DAPM_PRE_PMD:
+               printk("wm8994 exit incall status\n");
+               pdata->lineout_status = 0;
+               break;
+
+       default:
+               BUG();
+               break;
+       }
+
+       return 0;
+}
+
 static int aif1clk_ev(struct snd_soc_dapm_widget *w,
                      struct snd_kcontrol *kcontrol, int event)
 {
@@ -1666,8 +1695,20 @@ static const struct snd_soc_dapm_route wm8994_PA_intercon[] = {
 static const struct snd_soc_dapm_widget wm8994_PA_dapm_widgets[] = {
 SND_SOC_DAPM_SPK("PA Driver", wm8994_PA_event),
 };
+/*
+static const struct snd_soc_dapm_route wm8994_lineout_status_intercon[] = {
+       { "LINEOUT1N STATUS", NULL,"LINEOUT1N Driver"},
+       { "LINEOUT1P STATUS", NULL,"LINEOUT1P Driver"}, 
 
+       { "LINEOUT1N", NULL, "LINEOUT1N STATUS" },
+       { "LINEOUT1P", NULL, "LINEOUT1P STATUS" },
+};
 
+static const struct snd_soc_dapm_widget wm8994_lineout_status_dapm_widgets[] = {
+SND_SOC_DAPM_LINE("LINEOUT1N Driver", lineout_event),
+SND_SOC_DAPM_LINE("LINEOUT1P Driver", lineout_event),  
+};
+*/
 /* The size in bits of the FLL divide multiplied by 10
  * to allow rounding later */
 #define FIXED_FLL_SIZE ((1 << 16) * 10)
@@ -2589,9 +2630,15 @@ static int wm8994_suspend(struct snd_soc_codec *codec, pm_message_t state)
 {
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = codec->control_data;
+       struct wm8994_pdata *pdata = wm8994->pdata;
        int i, ret;
        
-//     printk("on wm8994.c wm8994_suspend\n");
+       DBG("on wm8994.c wm8994_suspend\n");
+       if(pdata->lineout_status)
+       {
+               DBG("lineout is work cannot suspend\n");
+               return 0;
+       }
        switch (control->type) {
        case WM8994:
                snd_soc_update_bits(codec, WM8994_MICBIAS, WM8994_MICD_ENA, 0);
@@ -2620,10 +2667,16 @@ static int wm8994_resume(struct snd_soc_codec *codec)
 {
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = codec->control_data;
+       struct wm8994_pdata *pdata = wm8994->pdata;
        int i, ret;
        unsigned int val, mask;
        
-//     printk("on wm8994.c wm8994_resume\n");
+       printk("on wm8994.c wm8994_resume\n");
+       if(pdata->lineout_status)
+       {
+               DBG("lineout is work cannot resume\n");
+               return 0;
+       }
        if (wm8994->revision < 4) {
                /* force a HW read */
                val = wm8994_reg_read(codec->control_data,
@@ -3340,7 +3393,14 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
        }
        else
                dev_info(codec->dev, "have not pa control\n");  
-       
+
+       //lineout off
+       pdata->lineout_status = 0;
+//     snd_soc_dapm_new_controls(dapm, wm8994_lineout_status_dapm_widgets,
+//                              ARRAY_SIZE(wm8994_lineout_status_dapm_widgets));       
+//     snd_soc_dapm_add_routes(dapm, wm8994_lineout_status_intercon, 
+//                             ARRAY_SIZE(wm8994_lineout_status_intercon));
+               
        return 0;
 
 err_irq:
index 0a1db04b73bd7e97e20f61349528c108fa831a3c..1eef4d3d18bc9f8685d69428e925b26c958d22ee 100755 (executable)
@@ -140,6 +140,11 @@ struct wm8994_priv {
        const struct firmware *mbc;
        const struct firmware *mbc_vss;
        const struct firmware *enh_eq;
+
+       unsigned int lineout_status:1;
 };
 
+int lineout_event(struct snd_soc_dapm_widget *w,
+                         struct snd_kcontrol *control, int event);
+
 #endif
index aef36262cf44438dde35043f071d5a4465abbe9f..e57d1d5c1dbc890e1d204ea22f32839cfd854f19 100755 (executable)
@@ -26,6 +26,7 @@
 #include <sound/tlv.h>
 
 #include "wm8993.h"
+#include "wm8994.h"
 #include "wm_hubs.h"
 
 const DECLARE_TLV_DB_SCALE(wm_hubs_spkmix_tlv, -300, 300, 0);
@@ -653,10 +654,17 @@ SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM, 0, 0,
 SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM, 0, 0,
                   line2p_mix, ARRAY_SIZE(line2p_mix)),
 
-SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0,
-                NULL, 0),
-SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0,
-                NULL, 0),
+//SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0,
+//              NULL, 0),
+//SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0,
+//              NULL, 0),
+SND_SOC_DAPM_PGA_E("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0,
+                NULL, 0,
+                lineout_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+SND_SOC_DAPM_PGA_E("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0,
+                NULL, 0,
+                lineout_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+                
 SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3, 11, 0,
                 NULL, 0),
 SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3, 10, 0,