add incalling cannot suspend interface
author邱建斌 <qjb@rock-chips.com>
Sat, 11 Feb 2012 08:18:12 +0000 (16:18 +0800)
committer邱建斌 <qjb@rock-chips.com>
Sat, 11 Feb 2012 08:18:12 +0000 (16:18 +0800)
drivers/mfd/wm8994-core.c
include/linux/mfd/wm8994/pdata.h
include/sound/soc.h
sound/soc/codecs/wm8994.c
sound/soc/rk29/Kconfig
sound/soc/soc-core.c

index 040d9b4552f98e2bb0a846b30567e9dbeea994b8..1dce22260ded57f8d68769f7b1a37ebe4ff4a26e 100755 (executable)
 #include <mach/gpio.h>
 #include <mach/iomux.h>
 
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND
+#include <sound/soc.h>
+#endif
+
 #if 0
 #define DBG(x...) printk(KERN_DEBUG x)
 #else
@@ -275,16 +279,16 @@ static const char *wm8958_main_supplies[] = {
 #ifdef CONFIG_PM
 static int wm8994_suspend(struct device *dev)
 {
-       struct wm8994 *wm8994 = dev_get_drvdata(dev);
-       struct wm8994_pdata *pdata = wm8994->dev->platform_data;        
+       struct wm8994 *wm8994 = dev_get_drvdata(dev);   
        int ret;
-       
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND  
        printk("on wm8994-core.c wm8994_suspend\n");
-       if(pdata->lineout_status)
+       if(snd_soc_incall_status(0,0))
        {
-               printk("lineout is work cannot suspend\n");
+               DBG("incalling  cannot suspend\n");
                return 0;
        }
+#endif
        /* 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);
@@ -329,16 +333,16 @@ 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;                
+       struct wm8994 *wm8994 = dev_get_drvdata(dev);           
        int ret;
-       
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND  
        printk("on wm8994-core.c wm8994_resume\n");
-       if(pdata->lineout_status)
+       if(snd_soc_incall_status(0,0))
        {
-               printk("lineout is work cannot suspend\n");
+               DBG("incalling cannot resume\n");
                return 0;
-       }       
+       }
+#endif
        /* We may have lied to the PM core about suspending */
        if (!wm8994->suspended)
                return 0;
index fc697fd61dca131138f8b8d85c40320a7899e582..8f9411d572f1d38c7e6ee0dbbd5d2292d403f8c5 100755 (executable)
@@ -177,8 +177,6 @@ struct wm8994_pdata {
 
        /* WM8958 microphone bias configuration */
        int micbias[2];
-
-       unsigned int lineout_status:1;
 };
 
 #endif
index 0cf11ec0ff3bcd47728070a9ff5826a6037f1d66..d52d36fce6b619d6a8f3755cf2278b0181985f98 100755 (executable)
@@ -258,6 +258,11 @@ enum snd_soc_compress_type {
        SND_SOC_RBTREE_COMPRESSION
 };
 
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND
+int snd_soc_incall_status(int read_or_write, int status);
+#endif 
+
+
 int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
                             unsigned int freq, int dir);
 int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
index 700a1f1e3f57360cb75acb57683c0b2949e666b3..2322ac47b789c36678dce185dd260890905861d6 100755 (executable)
@@ -912,29 +912,28 @@ static int wm8994_PA_event(struct snd_soc_dapm_widget *w,
 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;
+//     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__);
-       
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND  
        switch (event) {
        case SND_SOC_DAPM_POST_PMU:
                printk("wm8994 is incall status\n");
-               pdata->lineout_status = 1;
-               
+               snd_soc_incall_status(1,1);
                break;
 
        case SND_SOC_DAPM_PRE_PMD:
                printk("wm8994 exit incall status\n");
-               pdata->lineout_status = 0;
+               snd_soc_incall_status(1,0);
                break;
 
        default:
                BUG();
                break;
        }
-
+#endif
        return 0;
 }
 
@@ -2630,15 +2629,16 @@ 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;
        
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND  
        DBG("on wm8994.c wm8994_suspend\n");
-       if(pdata->lineout_status)
+       if(snd_soc_incall_status(0,0))
        {
-               DBG("lineout is work cannot suspend\n");
+               DBG("incalling  cannot suspend\n");
                return 0;
        }
+#endif
        switch (control->type) {
        case WM8994:
                snd_soc_update_bits(codec, WM8994_MICBIAS, WM8994_MICD_ENA, 0);
@@ -2667,16 +2667,18 @@ 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;
        
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND  
        printk("on wm8994.c wm8994_resume\n");
-       if(pdata->lineout_status)
+       if(snd_soc_incall_status(0,0))
        {
-               DBG("lineout is work cannot resume\n");
+               DBG("incalling cannot resume\n");
                return 0;
        }
+#endif
+
        if (wm8994->revision < 4) {
                /* force a HW read */
                val = wm8994_reg_read(codec->control_data,
@@ -3395,7 +3397,6 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
                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, 
index d2772c079bb10045c1a83966622d1b54a2e4f49a..16a990c0174bc54bfc5c9e0efe0ee60de92dd715 100755 (executable)
@@ -129,5 +129,11 @@ config ADJUST_VOL_BY_CODEC
     default n
     help
          adjust volume by codec
-                 
+
+config PHONE_INCALL_IS_SUSPEND
+       bool "Incalling Whether suspend codec"
+    default n
+    help
+               set "y" phone incall status cannot into suspend codec
+               
 endif
index 493ae7c4c0414deee8355a7e31134cd90b23ed4f..4610963ae48f6ce81a2604d5f08af314263cb193 100644 (file)
@@ -1031,6 +1031,21 @@ static struct snd_pcm_ops soc_pcm_ops = {
        .pointer        = soc_pcm_pointer,
 };
 
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND
+int snd_soc_incall_status(int read_or_write, int status)
+{
+       static int now_status = 0;
+       if(read_or_write == 1)
+       {//write
+               now_status = status;
+       }
+
+       return now_status;
+}
+EXPORT_SYMBOL_GPL(snd_soc_incall_status);
+#endif
+
+
 #ifdef CONFIG_PM_SLEEP
 /* powers down audio subsystem for suspend */
 int snd_soc_suspend(struct device *dev)
@@ -1038,7 +1053,14 @@ int snd_soc_suspend(struct device *dev)
        struct snd_soc_card *card = dev_get_drvdata(dev);
        struct snd_soc_codec *codec;
        int i;
-
+       
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND
+       if(snd_soc_incall_status(0,0))
+       {
+               printk("card is incall cannot into suspend\n");
+               return 0;
+       }
+#endif 
        /* If the initialization of this soc device failed, there is no codec
         * associated with it. Just bail out in this case.
         */
@@ -1188,6 +1210,7 @@ static void soc_resume_deferred(struct work_struct *work)
                 * left with bias OFF or STANDBY and suspended so we must now
                 * resume.  Otherwise the suspend was suppressed.
                 */
+
                if (codec->driver->resume && codec->suspended) {
                        switch (codec->dapm.bias_level) {
                        case SND_SOC_BIAS_STANDBY:
@@ -1258,7 +1281,14 @@ int snd_soc_resume(struct device *dev)
 {
        struct snd_soc_card *card = dev_get_drvdata(dev);
        int i, ac97_control = 0;
-
+       
+#ifdef CONFIG_PHONE_INCALL_IS_SUSPEND
+       if(snd_soc_incall_status(0,0))
+       {
+               printk("card is incall cannot into suspend\n");
+               return 0;
+       }
+#endif
        /* AC97 devices might have other drivers hanging off them so
         * need to resume immediately.  Other drivers don't have that
         * problem and may take a substantial amount of time to resume