From e619f04ef809ffa0bf5ebd2bdab48ed2f641a527 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=82=B1=E5=BB=BA=E6=96=8C?= Date: Fri, 10 Feb 2012 18:47:51 +0800 Subject: [PATCH] wm8994: incall status wm8994 cannot into suspend --- drivers/mfd/wm8994-core.c | 16 +++++++- include/linux/mfd/wm8994/pdata.h | 3 +- sound/soc/codecs/wm8994.c | 66 ++++++++++++++++++++++++++++++-- sound/soc/codecs/wm8994.h | 5 +++ sound/soc/codecs/wm_hubs.c | 16 ++++++-- 5 files changed, 96 insertions(+), 10 deletions(-) diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 1005847fbb14..040d9b4552f9 100755 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -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; diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h index 0e0855a94edc..fc697fd61dca 100755 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -177,7 +177,8 @@ struct wm8994_pdata { /* WM8958 microphone bias configuration */ int micbias[2]; - + + unsigned int lineout_status:1; }; #endif diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 1a7ead6c3e85..700a1f1e3f57 100755 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -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: diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h index 0a1db04b73bd..1eef4d3d18bc 100755 --- a/sound/soc/codecs/wm8994.h +++ b/sound/soc/codecs/wm8994.h @@ -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 diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index aef36262cf44..e57d1d5c1dbc 100755 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c @@ -26,6 +26,7 @@ #include #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, -- 2.34.1