aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-04-07 06:18:44 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-04-07 20:18:11 -0400
commitb7af1dafdfaf8419065399d07fb7cbae14b286ef (patch)
tree1b7a97fdc716edeed1b236e65d8afd3c3cbd03d3
parentd9b3e4c5156476a4baf0d7e0f47ba2816b4fff8e (diff)
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(). Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--include/sound/soc.h7
-rw-r--r--sound/soc/soc-core.c11
2 files changed, 17 insertions, 1 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 2720a9f3780b..435cb83c7f48 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -577,7 +577,9 @@ struct snd_soc_codec_driver {
577 pm_message_t state); 577 pm_message_t state);
578 int (*resume)(struct snd_soc_codec *); 578 int (*resume)(struct snd_soc_codec *);
579 579
580 /* Default DAPM setup, added after probe() is run */ 580 /* Default control and setup, added after probe() is run */
581 const struct snd_kcontrol_new *controls;
582 int num_controls;
581 const struct snd_soc_dapm_widget *dapm_widgets; 583 const struct snd_soc_dapm_widget *dapm_widgets;
582 int num_dapm_widgets; 584 int num_dapm_widgets;
583 const struct snd_soc_dapm_route *dapm_routes; 585 const struct snd_soc_dapm_route *dapm_routes;
@@ -747,6 +749,9 @@ struct snd_soc_card {
747 struct snd_soc_pcm_runtime *rtd_aux; 749 struct snd_soc_pcm_runtime *rtd_aux;
748 int num_aux_rtd; 750 int num_aux_rtd;
749 751
752 const struct snd_kcontrol_new *controls;
753 int num_controls;
754
750 /* 755 /*
751 * Card-specific routes and widgets. 756 * Card-specific routes and widgets.
752 */ 757 */
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f31afe9d4edd..f75f13926049 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1493,6 +1493,9 @@ static int soc_probe_codec(struct snd_soc_card *card,
1493 } 1493 }
1494 } 1494 }
1495 1495
1496 if (driver->controls)
1497 snd_soc_add_controls(codec, driver->controls,
1498 driver->num_controls);
1496 if (driver->dapm_widgets) 1499 if (driver->dapm_widgets)
1497 snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets, 1500 snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets,
1498 driver->num_dapm_widgets); 1501 driver->num_dapm_widgets);
@@ -1890,6 +1893,14 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
1890 } 1893 }
1891 } 1894 }
1892 1895
1896 /* We should have a non-codec control add function but we don't */
1897 if (card->controls)
1898 snd_soc_add_controls(list_first_entry(&card->codec_dev_list,
1899 struct snd_soc_codec,
1900 card_list),
1901 card->controls,
1902 card->num_controls);
1903
1893 if (card->dapm_widgets) 1904 if (card->dapm_widgets)
1894 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets, 1905 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
1895 card->num_dapm_widgets); 1906 card->num_dapm_widgets);