ASoC: core - Add convenience register for platform kcontrol and DAPM
authorLiam Girdwood <lrg@ti.com>
Mon, 4 Jul 2011 21:10:53 +0000 (22:10 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 5 Jul 2011 18:07:41 +0000 (11:07 -0700)
Allow platform probe to register platform kcontrols and DAPM just like
the CODEC probe().

Signed-off-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
include/sound/soc.h
sound/soc/soc-core.c

index 6ce8dc32a3dbcea6c741d989f7af3192cf6ccec1..aa19f5a32ba8774a085a085d52866ede8d63fd3f 100644 (file)
@@ -651,6 +651,14 @@ struct snd_soc_platform_driver {
        int (*pcm_new)(struct snd_soc_pcm_runtime *);
        void (*pcm_free)(struct snd_pcm *);
 
+       /* 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;
+       int num_dapm_routes;
+
        /*
         * For platform caused delay reporting.
         * Optional.
index 38f954af7bb564618750796edc3277aab5765ffb..3049c37b14e0e50f7d1eb60b80ad45af3b98ff70 100644 (file)
@@ -998,6 +998,10 @@ static int soc_probe_platform(struct snd_soc_card *card,
        if (!try_module_get(platform->dev->driver->owner))
                return -ENODEV;
 
+       if (driver->dapm_widgets)
+               snd_soc_dapm_new_controls(&platform->dapm,
+                       driver->dapm_widgets, driver->num_dapm_widgets);
+
        if (driver->probe) {
                ret = driver->probe(platform);
                if (ret < 0) {
@@ -1008,6 +1012,13 @@ static int soc_probe_platform(struct snd_soc_card *card,
                }
        }
 
+       if (driver->controls)
+               snd_soc_add_platform_controls(platform, driver->controls,
+                                    driver->num_controls);
+       if (driver->dapm_routes)
+               snd_soc_dapm_add_routes(&platform->dapm, driver->dapm_routes,
+                                       driver->num_dapm_routes);
+
        /* mark platform as probed and add to card platform list */
        platform->probed = 1;
        list_add(&platform->card_list, &card->platform_dev_list);