From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: alsa-devel@alsa-project.org,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Stephen Warren <swarren@nvidia.com>
Subject: [PATCH 3/3] ASoC: Export card PM callbacks for use in direct registered cards
Date: Wed, 26 Jan 2011 17:08:29 +0000 [thread overview]
Message-ID: <1296061709-12494-3-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1296061709-12494-1-git-send-email-broonie@opensource.wolfsonmicro.com>
Allow hookup of cards registered directly with the core to the PM
operations by exporting the device power management operations to
modules, also exporting the default PM operations since it is
expected that most cards will end up using exactly the same setup.
Note that the callbacks require that the driver data for the card be
the snd_soc_card.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
include/sound/soc.h | 5 +++++
sound/soc/soc-core.c | 34 +++++++++++++++++-----------------
2 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index a6a9013..4fd79e0 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -261,6 +261,9 @@ enum snd_soc_compress_type {
int snd_soc_register_card(struct snd_soc_card *card);
int snd_soc_unregister_card(struct snd_soc_card *card);
+int snd_soc_suspend(struct device *dev);
+int snd_soc_resume(struct device *dev);
+int snd_soc_poweroff(struct device *dev);
int snd_soc_register_platform(struct device *dev,
struct snd_soc_platform_driver *platform_drv);
void snd_soc_unregister_platform(struct device *dev);
@@ -803,4 +806,6 @@ static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
extern struct dentry *snd_soc_debugfs_root;
#endif
+extern const struct dev_pm_ops snd_soc_pm_ops;
+
#endif
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4bc2365..5dffc7a4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -965,12 +965,11 @@ static struct snd_pcm_ops soc_pcm_ops = {
.pointer = soc_pcm_pointer,
};
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
/* powers down audio subsystem for suspend */
-static int soc_suspend(struct device *dev)
+int snd_soc_suspend(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct snd_soc_card *card = platform_get_drvdata(pdev);
+ struct snd_soc_card *card = dev_get_drvdata(dev);
struct snd_soc_codec *codec;
int i;
@@ -1082,6 +1081,7 @@ static int soc_suspend(struct device *dev)
return 0;
}
+EXPORT_SYMBOL_GPL(snd_soc_suspend);
/* deferred resume work, so resume can complete before we finished
* setting our codec back up, which can be very slow on I2C
@@ -1187,10 +1187,9 @@ static void soc_resume_deferred(struct work_struct *work)
}
/* powers up audio subsystem after a suspend */
-static int soc_resume(struct device *dev)
+int snd_soc_resume(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct snd_soc_card *card = platform_get_drvdata(pdev);
+ struct snd_soc_card *card = dev_get_drvdata(dev);
int i;
/* AC97 devices might have other drivers hanging off them so
@@ -1212,9 +1211,10 @@ static int soc_resume(struct device *dev)
return 0;
}
+EXPORT_SYMBOL_GPL(snd_soc_resume);
#else
-#define soc_suspend NULL
-#define soc_resume NULL
+#define snd_soc_suspend NULL
+#define snd_soc_resume NULL
#endif
static struct snd_soc_dai_ops null_dai_ops = {
@@ -1924,10 +1924,9 @@ static int soc_remove(struct platform_device *pdev)
return 0;
}
-static int soc_poweroff(struct device *dev)
+int snd_soc_poweroff(struct device *dev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct snd_soc_card *card = platform_get_drvdata(pdev);
+ struct snd_soc_card *card = dev_get_drvdata(dev);
int i;
if (!card->instantiated)
@@ -1944,11 +1943,12 @@ static int soc_poweroff(struct device *dev)
return 0;
}
+EXPORT_SYMBOL_GPL(snd_soc_poweroff);
-static const struct dev_pm_ops soc_pm_ops = {
- .suspend = soc_suspend,
- .resume = soc_resume,
- .poweroff = soc_poweroff,
+const struct dev_pm_ops snd_soc_pm_ops = {
+ .suspend = snd_soc_suspend,
+ .resume = snd_soc_resume,
+ .poweroff = snd_soc_poweroff,
};
/* ASoC platform driver */
@@ -1956,7 +1956,7 @@ static struct platform_driver soc_driver = {
.driver = {
.name = "soc-audio",
.owner = THIS_MODULE,
- .pm = &soc_pm_ops,
+ .pm = &snd_soc_pm_ops,
},
.probe = soc_probe,
.remove = soc_remove,
--
1.7.2.3
next prev parent reply other threads:[~2011-01-26 17:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-26 17:08 [PATCH 1/3] ASoC: Use card rather than soc-audio device to card PM functions Mark Brown
2011-01-26 17:08 ` [PATCH 2/3] ASoC: Replace pdev with card in machine driver probe and remove Mark Brown
2011-01-26 17:08 ` Mark Brown [this message]
2011-01-26 20:12 ` [PATCH 1/3] ASoC: Use card rather than soc-audio device to card PM functions Liam Girdwood
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=1296061709-12494-3-git-send-email-broonie@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=lrg@slimlogic.co.uk \
--cc=swarren@nvidia.com \
/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;
as well as URLs for NNTP newsgroup(s).