]> git.alsa-project.org Git - alsa-lib.git/commitdiff
topology: dapm - merge identical index blocks like for other elems
authorJaroslav Kysela <perex@perex.cz>
Fri, 13 Dec 2019 20:56:58 +0000 (21:56 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 13 Dec 2019 20:56:58 +0000 (21:56 +0100)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/topology/dapm.c
src/topology/elem.c
src/topology/tplg_local.h

index cd80a4c03d92718d9193bd1aee5aa62eb30e8be8..ce46913192df3ee2c30b3dce989a95c28854240b 100644 (file)
@@ -313,7 +313,7 @@ int tplg_build_routes(snd_tplg_t *tplg)
        return 0;
 }
 
-struct tplg_elem *tplg_elem_new_route(snd_tplg_t *tplg)
+struct tplg_elem *tplg_elem_new_route(snd_tplg_t *tplg, int index)
 {
        struct tplg_elem *elem;
        struct snd_soc_tplg_dapm_graph_elem *line;
@@ -322,7 +322,8 @@ struct tplg_elem *tplg_elem_new_route(snd_tplg_t *tplg)
        if (!elem)
                return NULL;
 
-       list_add_tail(&elem->list, &tplg->route_list);
+       elem->index = index;
+       tplg_elem_insert(elem, &tplg->route_list);
        strcpy(elem->id, "line");
        elem->type = SND_TPLG_TYPE_DAPM_GRAPH;
        elem->size = sizeof(*line);
@@ -403,10 +404,9 @@ static int tplg_parse_routes(snd_tplg_t *tplg, snd_config_t *cfg, int index)
                if (snd_config_get_string(n, &val) < 0)
                        continue;
 
-               elem = tplg_elem_new_route(tplg);
+               elem = tplg_elem_new_route(tplg, index);
                if (!elem)
                        return -ENOMEM;
-               elem->index = index;
                line = elem->route;
 
                err = tplg_parse_line(val, line);
@@ -628,7 +628,7 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg,
        return 0;
 }
 
-int tplg_add_route(snd_tplg_t *tplg, struct snd_tplg_graph_elem *t)
+int tplg_add_route(snd_tplg_t *tplg, struct snd_tplg_graph_elem *t, int index)
 {
        struct tplg_elem *elem;
        struct snd_soc_tplg_dapm_graph_elem *line;
@@ -636,7 +636,7 @@ int tplg_add_route(snd_tplg_t *tplg, struct snd_tplg_graph_elem *t)
        if (!t->src || !t->sink)
                return -EINVAL;
 
-       elem = tplg_elem_new_route(tplg);
+       elem = tplg_elem_new_route(tplg, index);
        if (!elem)
                return -ENOMEM;
 
@@ -656,7 +656,7 @@ int tplg_add_graph_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t)
        int i, ret;
 
        for (i = 0; i < gt->count; i++) {
-               ret = tplg_add_route(tplg, gt->elem + i);
+               ret = tplg_add_route(tplg, gt->elem + i, t->index);
                if (ret < 0)
                        return ret;
        }
index 2066fad8377457517d577228681f4b0f61ff8066..140cdd32799405477e2c2bf5c19851f37715271e 100644 (file)
@@ -132,7 +132,7 @@ struct tplg_elem *tplg_elem_lookup(struct list_head *base, const char* id,
 }
 
 /* insert a new element into list in the ascending order of index value */
-static void tplg_elem_insert(struct tplg_elem *elem_p, struct list_head *list)
+void tplg_elem_insert(struct tplg_elem *elem_p, struct list_head *list)
 {
        struct list_head *pos, *p = &(elem_p->list);
        struct tplg_elem *elem;
index 7b8abcdefbcf34e0390f3169ef63e042866ae2cf..11efce6d580c1d202b2127e60d030b7b8a23bae1 100644 (file)
@@ -273,6 +273,7 @@ int tplg_ref_add_elem(struct tplg_elem *elem, struct tplg_elem *elem_ref);
 struct tplg_elem *tplg_elem_new(void);
 void tplg_elem_free(struct tplg_elem *elem);
 void tplg_elem_free_list(struct list_head *base);
+void tplg_elem_insert(struct tplg_elem *elem_p, struct list_head *list);
 struct tplg_elem *tplg_elem_lookup(struct list_head *base,
                                const char* id,
                                unsigned int type,