add incalling cannot suspend interface

This commit is contained in:
邱建斌 2012-02-11 16:18:12 +08:00
parent 4a1d41b0aa
commit fc7d65d156
6 changed files with 75 additions and 31 deletions

View File

@ -28,6 +28,10 @@
#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;

View File

@ -177,8 +177,6 @@ struct wm8994_pdata {
/* WM8958 microphone bias configuration */
int micbias[2];
unsigned int lineout_status:1;
};
#endif

View File

@ -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,

View File

@ -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,

View File

@ -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

View 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