ASoC: Define add/remove_dai_link ops for a soc card
authorMengdong Lin <mengdong.lin@linux.intel.com>
Wed, 2 Dec 2015 06:11:32 +0000 (14:11 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 8 Dec 2015 18:05:09 +0000 (18:05 +0000)
A machine driver can register the two ops.

When a DAI link is added or removed by a component's topology, the
ASoC core can call the ops to notify the machine driver for extra
intialization or destruction.

E.g. topology can create FE DAI links from a cpu DAI component, and
the machine driver may define an add_dai_link ops to set machine-specific
.init ops for the DAI link.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/soc-core.c

index 410cb0b422be1a3a648f9dca1442c1f265c85ae8..af347bcdc2f642722f6d595adbbe8731cd6dd4fe 100644 (file)
@@ -1104,6 +1104,11 @@ struct snd_soc_card {
                                   struct snd_soc_dapm_context *dapm,
                                   enum snd_soc_bias_level level);
 
+       int (*add_dai_link)(struct snd_soc_card *,
+                           struct snd_soc_dai_link *link);
+       void (*remove_dai_link)(struct snd_soc_card *,
+                           struct snd_soc_dai_link *link);
+
        long pmdown_time;
 
        /* CPU <--> Codec DAI links  */
index bf4bccfc4b91a8d7fc1d6a0704f8da60b8796269..094856fa8cecc3f729b1e0f10f22409aefadac34 100644 (file)
@@ -1260,6 +1260,12 @@ int snd_soc_add_dai_link(struct snd_soc_card *card,
        }
 
        lockdep_assert_held(&client_mutex);
+       /* Notify the machine driver for extra initialization
+        * on the link created by topology.
+        */
+       if (dai_link->dobj.type && card->add_dai_link)
+               card->add_dai_link(card, dai_link);
+
        list_add_tail(&dai_link->list, &card->dai_link_list);
        card->num_dai_links++;
 
@@ -1290,6 +1296,12 @@ void snd_soc_remove_dai_link(struct snd_soc_card *card,
        }
 
        lockdep_assert_held(&client_mutex);
+       /* Notify the machine driver for extra destruction
+        * on the link created by topology.
+        */
+       if (dai_link->dobj.type && card->remove_dai_link)
+               card->remove_dai_link(card, dai_link);
+
        list_for_each_entry_safe(link, _link, &card->dai_link_list, list) {
                if (link == dai_link) {
                        list_del(&link->list);