From 36a1357c9c879092fe2e36c82187f1d35b1efe13 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Fri, 14 Oct 2011 19:05:33 +0300 Subject: Several printout fixes. - There are sink and source pads, not input and output. - Print also DYNAMIC flag. - Don't print "pad" before pad number in some cases. The strings are more usable for link parsing now. - Don't print extra commas afterlink flags. Signed-off-by: Sakari Ailus Signed-off-by: Laurent Pinchart --- src/main.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index d8bd150..4f3271c 100644 --- a/src/main.c +++ b/src/main.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -129,8 +130,8 @@ static const char *media_pad_type_to_string(unsigned flag) __u32 flag; const char *name; } flags[] = { - { MEDIA_PAD_FL_SINK, "Input" }, - { MEDIA_PAD_FL_SOURCE, "Output" }, + { MEDIA_PAD_FL_SINK, "Sink" }, + { MEDIA_PAD_FL_SOURCE, "Source" }, }; unsigned int i; @@ -219,6 +220,15 @@ static void media_print_topology_dot(struct media_device *media) static void media_print_topology_text(struct media_device *media) { + static const struct { + __u32 flag; + char *name; + } link_flags[] = { + { MEDIA_LNK_FL_ENABLED, "ENABLED" }, + { MEDIA_LNK_FL_IMMUTABLE, "IMMUTABLE" }, + { MEDIA_LNK_FL_DYNAMIC, "DYNAMIC" }, + }; + unsigned int i, j, k; unsigned int padding; @@ -251,20 +261,26 @@ static void media_print_topology_text(struct media_device *media) struct media_link *link = &entity->links[k]; struct media_pad *source = link->source; struct media_pad *sink = link->sink; + bool first = true; + unsigned int i; if (source->entity == entity && source->index == j) - printf("\t\t-> '%s':pad%u [", + printf("\t\t-> \"%s\":%u [", sink->entity->info.name, sink->index); else if (sink->entity == entity && sink->index == j) - printf("\t\t<- '%s':pad%u [", + printf("\t\t<- \"%s\":%u [", source->entity->info.name, source->index); else continue; - if (link->flags & MEDIA_LNK_FL_IMMUTABLE) - printf("IMMUTABLE,"); - if (link->flags & MEDIA_LNK_FL_ENABLED) - printf("ACTIVE"); + for (i = 0; i < ARRAY_SIZE(link_flags); i++) { + if (!(link->flags & link_flags[i].flag)) + continue; + if (!first) + printf(","); + printf("%s", link_flags[i].name); + first = false; + } printf("]\n"); } -- cgit v1.2.3