Skip to content

Commit 3451856

Browse files
ranj063kv2019i
authored andcommitted
tplg_parser: Add support for parsing and saving route
Add an option to parse and save the routes from topology so that the IPCs can be sent at a later time. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 81bccef commit 3451856

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

tools/tplg_parser/graph.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <string.h>
1515
#include <ipc/topology.h>
1616
#include <sof/lib/uuid.h>
17+
#include <sof/list.h>
1718
#include <sof/ipc/topology.h>
1819
#include <kernel/header.h>
1920
#include <tplg_parser/topology.h>
@@ -73,3 +74,42 @@ int tplg_create_graph(struct tplg_context *ctx, int count, int pipeline_id,
7374

7475
return 0;
7576
}
77+
78+
/* parse and save the route information for IPC4 */
79+
int tplg_parse_graph(struct tplg_context *ctx, struct list_item *widget_list,
80+
struct list_item *route_list)
81+
{
82+
struct snd_soc_tplg_dapm_graph_elem *graph_elem;
83+
struct tplg_route_info *route;
84+
struct list_item *item;
85+
86+
route = calloc(sizeof(struct tplg_route_info), 1);
87+
if (!route)
88+
return -ENOMEM;
89+
90+
graph_elem = tplg_get_graph(ctx);
91+
92+
/* look up from the widget list and populate the route info */
93+
list_for_item(item, widget_list) {
94+
struct tplg_comp_info *comp_info = container_of(item, struct tplg_comp_info, item);
95+
96+
if (!strcmp(comp_info->name, graph_elem->source))
97+
route->source = comp_info;
98+
99+
if (!strcmp(comp_info->name, graph_elem->sink))
100+
route->sink = comp_info;
101+
}
102+
103+
if (!route->source || !route->sink) {
104+
fprintf(stderr, "%s() error loading route: source=%s, sink=%s\n",
105+
__func__, graph_elem->source, graph_elem->sink);
106+
free(route);
107+
return -EINVAL;
108+
}
109+
110+
list_item_append(&route->item, route_list);
111+
112+
printf("loading route %s -> %s\n", route->source->name, route->sink->name);
113+
114+
return 0;
115+
}

tools/tplg_parser/include/tplg_parser/topology.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ struct tplg_comp_info {
8787
struct sof_ipc4_available_audio_format available_fmt; /* available formats in tplg */
8888
};
8989

90+
struct tplg_route_info {
91+
struct tplg_comp_info *source;
92+
struct tplg_comp_info *sink;
93+
struct list_item item; /* item in a list */
94+
};
95+
9096
/*
9197
* Per topology data.
9298
*
@@ -253,4 +259,6 @@ int sof_parse_token_sets(void *object, const struct sof_topology_token *tokens,
253259
int count, struct snd_soc_tplg_vendor_array *array,
254260
int priv_size, int num_sets, int object_size);
255261
int tplg_parse_widget_audio_formats(struct tplg_context *ctx);
262+
int tplg_parse_graph(struct tplg_context *ctx, struct list_item *widget_list,
263+
struct list_item *route_list);
256264
#endif

0 commit comments

Comments
 (0)