ASoC: core: Add extra dapm properties for Device Tree
authorNicolin Chen <nicoleotsuka@gmail.com>
Sun, 15 Feb 2015 01:22:49 +0000 (17:22 -0800)
committerMark Brown <broonie@kernel.org>
Tue, 24 Feb 2015 14:46:13 +0000 (23:46 +0900)
The current helper functions, snd_soc_of_parse_audio_simple_widgets()
and snd_soc_of_parse_audio_routing(), set dapm_widgets and dapm_routes
without caring if they are already set by using build-in widgets and
routes in the card driver. So there could be one of them, build-in one
or Device Tree one, overrided by the other depending on which one was
assigned later.

This patch adds an extra pair of dapm_widgets and dapm_routes for DT
use only so as to prevent unexpected overriding.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/soc-core.c

index 0d1ade19562857c7b65157636ac37b2f0222e202..f66a1ef98a40bdf98f6d89b12e95147f846cb57d 100644 (file)
@@ -1071,11 +1071,16 @@ struct snd_soc_card {
 
        /*
         * Card-specific routes and widgets.
+        * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
         */
        const struct snd_soc_dapm_widget *dapm_widgets;
        int num_dapm_widgets;
        const struct snd_soc_dapm_route *dapm_routes;
        int num_dapm_routes;
+       const struct snd_soc_dapm_widget *of_dapm_widgets;
+       int num_of_dapm_widgets;
+       const struct snd_soc_dapm_route *of_dapm_routes;
+       int num_of_dapm_routes;
        bool fully_routed;
 
        struct work_struct deferred_resume_work;
index 30579ca5bacb985c7dfa9b9ad30f58cee45d6e1a..5c0658d49609d016c3f6240e97cae6a22508f260 100644 (file)
@@ -1561,6 +1561,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
                snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
                                          card->num_dapm_widgets);
 
+       if (card->of_dapm_widgets)
+               snd_soc_dapm_new_controls(&card->dapm, card->of_dapm_widgets,
+                                         card->num_of_dapm_widgets);
+
        /* initialise the sound card only once */
        if (card->probe) {
                ret = card->probe(card);
@@ -1616,6 +1620,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
                snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
                                        card->num_dapm_routes);
 
+       if (card->of_dapm_routes)
+               snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
+                                       card->num_of_dapm_routes);
+
        for (i = 0; i < card->num_links; i++) {
                if (card->dai_link[i].dai_fmt)
                        snd_soc_runtime_set_dai_fmt(&card->rtd[i],
@@ -3223,8 +3231,8 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
                widgets[i].name = wname;
        }
 
-       card->dapm_widgets = widgets;
-       card->num_dapm_widgets = num_widgets;
+       card->of_dapm_widgets = widgets;
+       card->num_of_dapm_widgets = num_widgets;
 
        return 0;
 }
@@ -3308,8 +3316,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
                }
        }
 
-       card->num_dapm_routes = num_routes;
-       card->dapm_routes = routes;
+       card->num_of_dapm_routes = num_routes;
+       card->of_dapm_routes = routes;
 
        return 0;
 }