From: Barry Song <21cnbao@gmail.com>
To: broonie@opensource.wolfsonmicro.com
Cc: uclinux-dist-devel@blackfin.uclinux.org,
alsa-devel@alsa-project.org, Barry Song <21cnbao@gmail.com>
Subject: [PATCH] add support to reorder CPU and Codec DAI suspend/resume
Date: Wed, 11 Nov 2009 15:10:57 +0800 [thread overview]
Message-ID: <1257923457-31470-1-git-send-email-21cnbao@gmail.com> (raw)
Due to some hardware dependence issues, some devices maybe require
different suspend/resume execution order for CPU and Codec DAI to
make sure the hardware can work normally after executing sleep and
wakeup.
In old ALSA driver, people include all suspend/resume operations of
both CPU and Codec in same entries. Then they change order according
to actual require. But in ASoC, we should give a chance to users to
reorder CPU/Codec DAI suspend/resume instead of defining the fixed
order if there are some strange hardware dependence problems.
Signed-off-by: Barry Song <21cnbao@gmail.com>
---
include/sound/soc.h | 4 ++++
sound/soc/soc-core.c | 48 ++++++++++++++++++++++++++++++++++++------------
2 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index b1245e3..701c362 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -494,6 +494,10 @@ struct snd_soc_card {
struct snd_soc_dai_link *dai_link;
int num_links;
+ /* CPU <--> Codec DAI suspend/resume order */
+ int cpu_suspend_earlier; /* CPU DAI and platform suspend will be called earlier than Codec */
+ int cpu_resume_earlier; /* CPU DAI and platform resume will be called earlier than Codec */
+
struct snd_soc_device *socdev;
struct snd_soc_codec *codec;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2d190df..a1cc855 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -660,12 +660,14 @@ static int soc_suspend(struct device *dev)
if (card->suspend_pre)
card->suspend_pre(pdev, PMSG_SUSPEND);
- for (i = 0; i < card->num_links; i++) {
- struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
- if (cpu_dai->suspend && !cpu_dai->ac97_control)
- cpu_dai->suspend(cpu_dai);
- if (platform->suspend)
- platform->suspend(cpu_dai);
+ if (card->cpu_suspend_earlier) {
+ for (i = 0; i < card->num_links; i++) {
+ struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
+ if (cpu_dai->suspend && !cpu_dai->ac97_control)
+ cpu_dai->suspend(cpu_dai);
+ if (platform->suspend)
+ platform->suspend(cpu_dai);
+ }
}
/* close any waiting streams and save state */
@@ -692,6 +694,16 @@ static int soc_suspend(struct device *dev)
cpu_dai->suspend(cpu_dai);
}
+ if (!card->cpu_suspend_earlier) {
+ for (i = 0; i < card->num_links; i++) {
+ struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
+ if (cpu_dai->suspend && !cpu_dai->ac97_control)
+ cpu_dai->suspend(cpu_dai);
+ if (platform->suspend)
+ platform->suspend(cpu_dai);
+ }
+ }
+
if (card->suspend_post)
card->suspend_post(pdev, PMSG_SUSPEND);
@@ -728,6 +740,16 @@ static void soc_resume_deferred(struct work_struct *work)
cpu_dai->resume(cpu_dai);
}
+ if (card->cpu_resume_earlier) {
+ for (i = 0; i < card->num_links; i++) {
+ struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
+ if (cpu_dai->resume && !cpu_dai->ac97_control)
+ cpu_dai->resume(cpu_dai);
+ if (platform->resume)
+ platform->resume(cpu_dai);
+ }
+ }
+
if (codec_dev->resume)
codec_dev->resume(pdev);
@@ -749,12 +771,14 @@ static void soc_resume_deferred(struct work_struct *work)
dai->ops->digital_mute(dai, 0);
}
- for (i = 0; i < card->num_links; i++) {
- struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
- if (cpu_dai->resume && !cpu_dai->ac97_control)
- cpu_dai->resume(cpu_dai);
- if (platform->resume)
- platform->resume(cpu_dai);
+ if (!card->cpu_resume_earlier) {
+ for (i = 0; i < card->num_links; i++) {
+ struct snd_soc_dai *cpu_dai = card->dai_link[i].cpu_dai;
+ if (cpu_dai->resume && !cpu_dai->ac97_control)
+ cpu_dai->resume(cpu_dai);
+ if (platform->resume)
+ platform->resume(cpu_dai);
+ }
}
if (card->resume_post)
--
1.5.6.3
next reply other threads:[~2009-11-11 7:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-11 7:10 Barry Song [this message]
2009-11-11 11:24 ` [PATCH] add support to reorder CPU and Codec DAI suspend/resume Mark Brown
2009-11-11 12:48 ` Barry Song
2009-11-11 14:20 ` Mark Brown
2009-11-11 14:34 ` Barry Song
2009-11-11 14:42 ` Mark Brown
2009-11-12 5:47 ` Barry Song
2009-11-12 10:46 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1257923457-31470-1-git-send-email-21cnbao@gmail.com \
--to=21cnbao@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=uclinux-dist-devel@blackfin.uclinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox