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>
This commit is contained in:
Ranjani Sridharan 2023-08-08 12:24:58 -07:00 committed by Kai Vehmanen
parent 81bccef08d
commit 34518568f7
2 changed files with 48 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include <string.h>
#include <ipc/topology.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
#include <sof/ipc/topology.h>
#include <kernel/header.h>
#include <tplg_parser/topology.h>
@ -73,3 +74,42 @@ int tplg_create_graph(struct tplg_context *ctx, int count, int pipeline_id,
return 0;
}
/* parse and save the route information for IPC4 */
int tplg_parse_graph(struct tplg_context *ctx, struct list_item *widget_list,
struct list_item *route_list)
{
struct snd_soc_tplg_dapm_graph_elem *graph_elem;
struct tplg_route_info *route;
struct list_item *item;
route = calloc(sizeof(struct tplg_route_info), 1);
if (!route)
return -ENOMEM;
graph_elem = tplg_get_graph(ctx);
/* look up from the widget list and populate the route info */
list_for_item(item, widget_list) {
struct tplg_comp_info *comp_info = container_of(item, struct tplg_comp_info, item);
if (!strcmp(comp_info->name, graph_elem->source))
route->source = comp_info;
if (!strcmp(comp_info->name, graph_elem->sink))
route->sink = comp_info;
}
if (!route->source || !route->sink) {
fprintf(stderr, "%s() error loading route: source=%s, sink=%s\n",
__func__, graph_elem->source, graph_elem->sink);
free(route);
return -EINVAL;
}
list_item_append(&route->item, route_list);
printf("loading route %s -> %s\n", route->source->name, route->sink->name);
return 0;
}

View File

@ -87,6 +87,12 @@ struct tplg_comp_info {
struct sof_ipc4_available_audio_format available_fmt; /* available formats in tplg */
};
struct tplg_route_info {
struct tplg_comp_info *source;
struct tplg_comp_info *sink;
struct list_item item; /* item in a list */
};
/*
* Per topology data.
*
@ -253,4 +259,6 @@ int sof_parse_token_sets(void *object, const struct sof_topology_token *tokens,
int count, struct snd_soc_tplg_vendor_array *array,
int priv_size, int num_sets, int object_size);
int tplg_parse_widget_audio_formats(struct tplg_context *ctx);
int tplg_parse_graph(struct tplg_context *ctx, struct list_item *widget_list,
struct list_item *route_list);
#endif