Skip to contentSkip to conversation

ASoC: Add data based control initialisation for CODECs and cards

PATCH In review Mark Brown 2 participants 2 messages Apr 7, 2011 – Apr 8, 2011

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 ASoC: Add data based control initialisation for CODECs and cards

Allow CODEC and card drivers to point to an array of controls from their driver structure rather than explicitly calling snd_soc_add_controls().

---
 include/sound/soc.h  |    7 ++++++-
 sound/soc/soc-core.c |   11 +++++++++++
 2 files changed, 17 insertions(+), 1 deletions(-)
include/sound/soc.h +6 -1
index 2720a9f..435cb83 100644
@@ -577,7 +577,9 @@ struct snd_soc_codec_driver {
 			pm_message_t state);
 	int (*resume)(struct snd_soc_codec *);
 
-	/* Default DAPM setup, added after probe() is run */
+	/* Default control and setup, added after probe() is run */
+	const struct snd_kcontrol_new *controls;
+	int num_controls;
 	const struct snd_soc_dapm_widget *dapm_widgets;
 	int num_dapm_widgets;
 	const struct snd_soc_dapm_route *dapm_routes;
@@ -747,6 +749,9 @@ struct snd_soc_card {
 	struct snd_soc_pcm_runtime *rtd_aux;
 	int num_aux_rtd;
 
+	const struct snd_kcontrol_new *controls;
+	int num_controls;
+
 	/*
 	 * Card-specific routes and widgets.
 	 */
sound/soc/soc-core.c +11 -0
index 0cf6997..d95ff2a 100644
@@ -1491,6 +1491,9 @@ static int soc_probe_codec(struct snd_soc_card *card,
 		}
 	}
 
+	if (driver->controls)
+		snd_soc_add_controls(codec, driver->controls,
+				     driver->num_controls);
 	if (driver->dapm_widgets)
 		snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets,
 					  driver->num_dapm_widgets);
@@ -1888,6 +1891,14 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 		}
 	}
 
+	/* We should have a non-codec control add function but we don't */
+	if (card->controls)
+		snd_soc_add_controls(list_first_entry(&card->codec_dev_list,
+						      struct snd_soc_codec,
+						      card_list),
+				     card->controls,
+				     card->num_controls);
+
 	if (card->dapm_widgets)
 		snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
 					  card->num_dapm_widgets);
Signature · 1 line
1.7.4.1