From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 05/11] ASoC: Add helper functions to cast from DAPM context to CODEC/platform
Date: Sun, 18 May 2014 14:24:12 +0200 [thread overview]
Message-ID: <1400415858-11025-6-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1400415858-11025-1-git-send-email-lars@metafoo.de>
This is useful if we have a pointer to a DAPM context and know that it is a
CODEC or platform DAPM context and want to get a pointer to the CODEC or
platform.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
include/sound/soc.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9b335d8..aa9acaf 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1142,6 +1142,33 @@ static inline struct snd_soc_platform *snd_soc_component_to_platform(
return container_of(component, struct snd_soc_platform, component);
}
+/**
+ * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in
+ * @dapm: The DAPM context to cast to the CODEC
+ *
+ * This function must only be used on DAPM contexts that are known to be part of
+ * a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined.
+ */
+static inline struct snd_soc_codec *snd_soc_dapm_to_codec(
+ struct snd_soc_dapm_context *dapm)
+{
+ return container_of(dapm, struct snd_soc_codec, dapm);
+}
+
+/**
+ * snd_soc_dapm_to_platform() - Casts a DAPM context to the platform it is
+ * embedded in
+ * @dapm: The DAPM context to cast to the platform.
+ *
+ * This function must only be used on DAPM contexts that are known to be part of
+ * a platform (e.g. in a platform driver). Otherwise the behavior is undefined.
+ */
+static inline struct snd_soc_platform *snd_soc_dapm_to_platform(
+ struct snd_soc_dapm_context *dapm)
+{
+ return container_of(dapm, struct snd_soc_platform, dapm);
+}
+
/* codec IO */
unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
--
1.8.0
next prev parent reply other threads:[~2014-05-18 12:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-18 12:24 [PATCH 00/11] ASoC: Add support for DAPM at the component level Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 01/11] ASoC: Move name_prefix from CODEC to component Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 02/11] ASoC: Move name and id from CODEC/platform " Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 03/11] ASoC: Split component registration into two steps Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 04/11] ASoC: Auto disconnect pins from all DAPM contexts Lars-Peter Clausen
2014-05-18 12:24 ` Lars-Peter Clausen [this message]
2014-05-26 19:36 ` [PATCH 05/11] ASoC: Add helper functions to cast from DAPM context to CODEC/platform Lars-Peter Clausen
2014-06-01 18:18 ` Mark Brown
2014-06-06 5:47 ` Vinod Koul
2014-06-06 6:20 ` Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 06/11] ASoC: Add a set_bias_level() callback to the DAPM context struct Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 07/11] ASoC: Add DAPM support at the component level Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 08/11] ASoC: Use component DAPM context for platforms Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 09/11] ASoC: Add component level stream_event() and seq_notifier() support Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 10/11] ASoC: Add component level set_bias_level() support Lars-Peter Clausen
2014-05-18 12:24 ` [PATCH 11/11] ASoC: dapm: Remove DAI DAPM context Lars-Peter Clausen
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=1400415858-11025-6-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.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