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;
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);
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);
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;
if (!t->src || !t->sink)
return -EINVAL;
- elem = tplg_elem_new_route(tplg);
+ elem = tplg_elem_new_route(tplg, index);
if (!elem)
return -ENOMEM;
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;
}
}
/* 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;
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,