2 * Media controller test application
4 * Copyright (C) 2010 Ideas on board SPRL <laurent.pinchart@ideasonboard.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
27 #define MEDIA_DEVNAME_DEFAULT "/dev/media0"
29 struct media_options media_opts = {
30 .devname = MEDIA_DEVNAME_DEFAULT,
33 static void usage(const char *argv0, int verbose)
35 printf("%s [options] device\n", argv0);
36 printf("-d, --device dev Media device name (default: %s)\n", MEDIA_DEVNAME_DEFAULT);
37 printf("-e, --entity name Print the device name associated with the given entity\n");
38 printf("-f, --set-format Comma-separated list of formats to setup\n");
39 printf(" --get-format pad Print the active format on a given pad\n");
40 printf("-h, --help Show verbose help and exit\n");
41 printf("-i, --interactive Modify links interactively\n");
42 printf("-l, --links Comma-separated list of links descriptors to setup\n");
43 printf("-p, --print-topology Print the device topology (implies -v)\n");
44 printf(" --print-dot Print the device topology as a dot graph (implies -v)\n");
45 printf("-r, --reset Reset all links to inactive\n");
46 printf("-v, --verbose Be verbose\n");
52 printf("Links and formats are defined as\n");
53 printf("\tlink = pad, '->', pad, '[', flags, ']' ;\n");
54 printf("\tformat = pad, '[', fcc, ' ', size, [ ' ', crop ], [ ' ', '@', frame interval ], ']' ;\n");
55 printf("\tpad = entity, ':', pad number ;\n");
56 printf("\tentity = entity number | ( '\"', entity name, '\"' ) ;\n");
57 printf("\tsize = width, 'x', height ;\n");
58 printf("\tcrop = '(', left, ',', top, ')', '/', size ;\n");
59 printf("\tframe interval = numerator, '/', denominator ;\n");
60 printf("where the fields are\n");
61 printf("\tentity number Entity numeric identifier\n");
62 printf("\tentity name Entity name (string) \n");
63 printf("\tpad number Pad numeric identifier\n");
64 printf("\tflags Link flags (0: inactive, 1: active)\n");
65 printf("\tfcc Format FourCC\n");
66 printf("\twidth Image width in pixels\n");
67 printf("\theight Image height in pixels\n");
68 printf("\tnumerator Frame interval numerator\n");
69 printf("\tdenominator Frame interval denominator\n");
72 #define OPT_PRINT_DOT 256
73 #define OPT_GET_FORMAT 257
75 static struct option opts[] = {
76 {"device", 1, 0, 'd'},
77 {"entity", 1, 0, 'e'},
78 {"set-format", 1, 0, 'f'},
79 {"get-format", 1, 0, OPT_GET_FORMAT},
81 {"interactive", 0, 0, 'i'},
83 {"print-dot", 0, 0, OPT_PRINT_DOT},
84 {"print-topology", 0, 0, 'p'},
86 {"verbose", 0, 0, 'v'},
89 int parse_cmdline(int argc, char **argv)
99 while ((opt = getopt_long(argc, argv, "d:e:f:hil:prv", opts, NULL)) != -1) {
102 media_opts.devname = optarg;
106 media_opts.entity = optarg;
110 media_opts.formats = optarg;
118 media_opts.interactive = 1;
122 media_opts.links = optarg;
126 media_opts.print = 1;
127 media_opts.verbose = 1;
131 media_opts.reset = 1;
135 media_opts.verbose = 1;
139 media_opts.print_dot = 1;
143 media_opts.pad = optarg;
147 printf("Invalid option -%c\n", opt);
148 printf("Run %s -h for help.\n", argv[0]);