Several printout fixes.
authorSakari Ailus <sakari.ailus@iki.fi>
Fri, 14 Oct 2011 16:05:33 +0000 (19:05 +0300)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sat, 22 Oct 2011 08:48:49 +0000 (10:48 +0200)
- 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>
src/main.c

index d8bd150..4f3271c 100644 (file)
@@ -27,6 +27,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.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[] = {
                __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;
        };
 
        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 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;
 
        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;
                                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)
 
                                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)
                                                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;
 
                                                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");
                        }
 
                                printf("]\n");
                        }