aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-05-07 16:11:40 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-05-10 05:36:48 -0400
commit1547aba993c990e5a316751431328145b38e1fea (patch)
treed9e549fa2d6bb67a632a0cfeefd39e3a077cac5d
parent9949788b793826f2d19e929ac0219ad0e0891e2d (diff)
ASoC: Support leaving paths enabled over system suspend
Some devices can usefully run audio while the Linux system is suspended. One of the most common examples is smartphone systems, which are normally designed to allow audio to be run between the baseband and the CODEC without passing through the CPU and so can suspend the CPU when on a voice call for additional power savings. Support such systems by providing an API snd_soc_dapm_ignore_suspend(). This can be used to mark DAPM endpoints as not being sensitive to system suspend. When the system is being suspended paths between endpoints which are marked as ignoring suspend will be kept active. Both source and sink must be marked, and there must already be an active path between the two endpoints prior to suspend. When paths are active over suspend the bias management will hold the device bias in the ON state. This is used to avoid suspending the CODEC while it is still in use. Tested-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--include/sound/soc-dapm.h2
-rw-r--r--sound/soc/soc-core.c32
-rw-r--r--sound/soc/soc-dapm.c31
3 files changed, 60 insertions, 5 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 55c6d3d1894f..66ff4c124dbd 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -341,6 +341,7 @@ int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, const char *pin);
341int snd_soc_dapm_sync(struct snd_soc_codec *codec); 341int snd_soc_dapm_sync(struct snd_soc_codec *codec);
342int snd_soc_dapm_force_enable_pin(struct snd_soc_codec *codec, 342int snd_soc_dapm_force_enable_pin(struct snd_soc_codec *codec,
343 const char *pin); 343 const char *pin);
344int snd_soc_dapm_ignore_suspend(struct snd_soc_codec *codec, const char *pin);
344 345
345/* dapm widget types */ 346/* dapm widget types */
346enum snd_soc_dapm_type { 347enum snd_soc_dapm_type {
@@ -428,6 +429,7 @@ struct snd_soc_dapm_widget {
428 unsigned char new:1; /* cnew complete */ 429 unsigned char new:1; /* cnew complete */
429 unsigned char ext:1; /* has external widgets */ 430 unsigned char ext:1; /* has external widgets */
430 unsigned char force:1; /* force state */ 431 unsigned char force:1; /* force state */
432 unsigned char ignore_suspend:1; /* kept enabled over suspend */
431 433
432 int (*power_check)(struct snd_soc_dapm_widget *w); 434 int (*power_check)(struct snd_soc_dapm_widget *w);
433 435
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 95739767ec45..8661e5b4adb1 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -927,8 +927,19 @@ static int soc_suspend(struct device *dev)
927 SND_SOC_DAPM_STREAM_SUSPEND); 927 SND_SOC_DAPM_STREAM_SUSPEND);
928 } 928 }
929 929
930 if (codec_dev->suspend) 930 /* If there are paths active then the CODEC will be held with
931 codec_dev->suspend(pdev, PMSG_SUSPEND); 931 * bias _ON and should not be suspended. */
932 if (codec_dev->suspend) {
933 switch (codec->bias_level) {
934 case SND_SOC_BIAS_STANDBY:
935 case SND_SOC_BIAS_OFF:
936 codec_dev->suspend(pdev, PMSG_SUSPEND);
937 break;
938 default:
939 dev_dbg(socdev->dev, "CODEC is on over suspend\n");
940 break;
941 }
942 }
932 943
933 for (i = 0; i < card->num_links; i++) { 944 for (i = 0; i < card->num_links; i++) {
934 struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai; 945 struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
@@ -975,8 +986,21 @@ static void soc_resume_deferred(struct work_struct *work)
975 cpu_dai->resume(cpu_dai); 986 cpu_dai->resume(cpu_dai);
976 } 987 }
977 988
978 if (codec_dev->resume) 989 /* If the CODEC was idle over suspend then it will have been
979 codec_dev->resume(pdev); 990 * left with bias OFF or STANDBY and suspended so we must now
991 * resume. Otherwise the suspend was suppressed.
992 */
993 if (codec_dev->resume) {
994 switch (codec->bias_level) {
995 case SND_SOC_BIAS_STANDBY:
996 case SND_SOC_BIAS_OFF:
997 codec_dev->resume(pdev);
998 break;
999 default:
1000 dev_dbg(socdev->dev, "CODEC was on over suspend\n");
1001 break;
1002 }
1003 }
980 1004
981 for (i = 0; i < codec->num_dai; i++) { 1005 for (i = 0; i < codec->num_dai; i++) {
982 char *stream = codec->dai[i].playback.stream_name; 1006 char *stream = codec->dai[i].playback.stream_name;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 8c8b291320a8..fefb6c44fc81 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -441,7 +441,9 @@ static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget)
441 switch (snd_power_get_state(codec->card)) { 441 switch (snd_power_get_state(codec->card)) {
442 case SNDRV_CTL_POWER_D3hot: 442 case SNDRV_CTL_POWER_D3hot:
443 case SNDRV_CTL_POWER_D3cold: 443 case SNDRV_CTL_POWER_D3cold:
444 return 0; 444 if (widget->ignore_suspend)
445 pr_debug("%s ignoring suspend\n", widget->name);
446 return widget->ignore_suspend;
445 default: 447 default:
446 return 1; 448 return 1;
447 } 449 }
@@ -2137,6 +2139,33 @@ int snd_soc_dapm_get_pin_status(struct snd_soc_codec *codec, const char *pin)
2137EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status); 2139EXPORT_SYMBOL_GPL(snd_soc_dapm_get_pin_status);
2138 2140
2139/** 2141/**
2142 * snd_soc_dapm_ignore_suspend - ignore suspend status for DAPM endpoint
2143 * @codec: audio codec
2144 * @pin: audio signal pin endpoint (or start point)
2145 *
2146 * Mark the given endpoint or pin as ignoring suspend. When the
2147 * system is disabled a path between two endpoints flagged as ignoring
2148 * suspend will not be disabled. The path must already be enabled via
2149 * normal means at suspend time, it will not be turned on if it was not
2150 * already enabled.
2151 */
2152int snd_soc_dapm_ignore_suspend(struct snd_soc_codec *codec, const char *pin)
2153{
2154 struct snd_soc_dapm_widget *w;
2155
2156 list_for_each_entry(w, &codec->dapm_widgets, list) {
2157 if (!strcmp(w->name, pin)) {
2158 w->ignore_suspend = 1;
2159 return 0;
2160 }
2161 }
2162
2163 pr_err("Unknown DAPM pin: %s\n", pin);
2164 return -EINVAL;
2165}
2166EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
2167
2168/**
2140 * snd_soc_dapm_free - free dapm resources 2169 * snd_soc_dapm_free - free dapm resources
2141 * @socdev: SoC device 2170 * @socdev: SoC device
2142 * 2171 *