Skip to contentSkip to conversation

ASoC: dapm - Add methods to retrieve snd_card and soc_card from dapm context.

PATCH Applied Liam Girdwood 2 participants 2 messages Jul 20, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: dapm - Add methods to retrieve snd_card and soc_card from dapm context.

In preparation for ASoC Dynamic PCM (AKA DSP) support.

Provide convenience methods to retrieve the soc_card or snd_card from a DAPM context.

---
 sound/soc/soc-dapm.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
sound/soc/soc-dapm.c +30 -0
index 4205a97..aaef0ef 100644
@@ -124,6 +124,36 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
 	return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL);
 }
 
+/* get snd_card from DAPM context */
+static inline struct snd_card *dapm_get_snd_card(
+	struct snd_soc_dapm_context *dapm)
+{
+	if (dapm->codec)
+		return dapm->codec->card->snd_card;
+	else if (dapm->platform)
+		return dapm->platform->card->snd_card;
+	else
+		BUG();
+
+	/* unreachable */
+	return NULL;
+}
+
+/* get soc_card from DAPM context */
+static inline struct snd_soc_card *dapm_get_soc_card(
+		struct snd_soc_dapm_context *dapm)
+{
+	if (dapm->codec)
+		return dapm->codec->card;
+	else if (dapm->platform)
+		return dapm->platform->card;
+	else
+		BUG();
+
+	/* unreachable */
+	return NULL;
+}
+
 static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg)
 {
 	if (w->codec)
Signature · 1 line
1.7.4.1
Applied
#1 lore raw
Quoted 3 lines · Liam Girdwood

In preparation for ASoC Dynamic PCM (AKA DSP) support.

Provide convenience methods to retrieve the soc_card or snd_card from a DAPM context.

Applied, thanks.