diff options
author | Sakari Ailus <sakari.ailus@iki.fi> | 2011-10-14 19:05:33 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-10-22 10:48:49 +0200 |
commit | 36a1357c9c879092fe2e36c82187f1d35b1efe13 (patch) | |
tree | ad7c9b6943da94705b62b1ebce5bee2d21995979 /src | |
parent | 07f0d83095c5ca26de9031946ebeec05f24a18e7 (diff) |
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 <sakari.ailus@iki.fi>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 32 |
1 files changed, 24 insertions, 8 deletions
@@ -27,6 +27,7 @@ #include <ctype.h> #include <errno.h> #include <fcntl.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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"); } |