Skip to content
Snippets Groups Projects
Commit 9b1ffffa authored by Laurent Pinchart's avatar Laurent Pinchart
Browse files

utils: media-ctl: Support accessing the subdev TRY state


Add a -W/--which argument to media-ctl to select which state to operate
on. Default to the ACTIVE state to preserve the current behaviour.

Despite the fact that all values set on the TRY state are lost when
media-ctl terminates, support for the TRY state is useful in order to
retrieve the default configuration of subdevs, or to try configurations.

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
parent df1afc77
No related branches found
No related tags found
No related merge requests found
...@@ -600,7 +600,6 @@ static void media_print_topology_text(struct media_device *media, ...@@ -600,7 +600,6 @@ static void media_print_topology_text(struct media_device *media,
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const enum v4l2_subdev_format_whence which = V4L2_SUBDEV_FORMAT_ACTIVE;
struct media_device *media; struct media_device *media;
struct media_entity *entity = NULL; struct media_entity *entity = NULL;
int ret = -1; int ret = -1;
...@@ -667,7 +666,8 @@ int main(int argc, char **argv) ...@@ -667,7 +666,8 @@ int main(int argc, char **argv)
goto out; goto out;
} }
v4l2_subdev_print_format(pad->entity, pad->index, stream, which); v4l2_subdev_print_format(pad->entity, pad->index, stream,
media_opts.which);
} }
if (media_opts.get_dv_pad) { if (media_opts.get_dv_pad) {
...@@ -709,9 +709,10 @@ int main(int argc, char **argv) ...@@ -709,9 +709,10 @@ int main(int argc, char **argv)
media_print_topology_dot(media); media_print_topology_dot(media);
} else if (media_opts.print) { } else if (media_opts.print) {
if (entity) if (entity)
media_print_topology_text_entity(media, entity, which); media_print_topology_text_entity(media, entity,
media_opts.which);
else else
media_print_topology_text(media, which); media_print_topology_text(media, media_opts.which);
} else if (entity) { } else if (entity) {
const char *devname; const char *devname;
...@@ -741,7 +742,7 @@ int main(int argc, char **argv) ...@@ -741,7 +742,7 @@ int main(int argc, char **argv)
} }
if (media_opts.routes) { if (media_opts.routes) {
ret = v4l2_subdev_parse_setup_routes(media, which, ret = v4l2_subdev_parse_setup_routes(media, media_opts.which,
media_opts.routes); media_opts.routes);
if (ret) { if (ret) {
printf("Unable to setup routes: %s (%d)\n", printf("Unable to setup routes: %s (%d)\n",
...@@ -751,7 +752,7 @@ int main(int argc, char **argv) ...@@ -751,7 +752,7 @@ int main(int argc, char **argv)
} }
if (media_opts.formats) { if (media_opts.formats) {
ret = v4l2_subdev_parse_setup_formats(media, which, ret = v4l2_subdev_parse_setup_formats(media, media_opts.which,
media_opts.formats); media_opts.formats);
if (ret) { if (ret) {
printf("Unable to setup formats: %s (%d)\n", printf("Unable to setup formats: %s (%d)\n",
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
struct media_options media_opts = { struct media_options media_opts = {
.devname = MEDIA_DEVNAME_DEFAULT, .devname = MEDIA_DEVNAME_DEFAULT,
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
}; };
static void print_version() static void print_version()
...@@ -75,6 +76,7 @@ static void usage(const char *argv0) ...@@ -75,6 +76,7 @@ static void usage(const char *argv0)
printf("-r, --reset Reset all links to inactive\n"); printf("-r, --reset Reset all links to inactive\n");
printf("-v, --verbose Be verbose\n"); printf("-v, --verbose Be verbose\n");
printf(" --version Show version information\n"); printf(" --version Show version information\n");
printf("-W, --which which Select the subdev state to operate on\n");
printf("\n"); printf("\n");
printf("Links and formats are defined as\n"); printf("Links and formats are defined as\n");
printf("\tlinks = link { ',' link } ;\n"); printf("\tlinks = link { ',' link } ;\n");
...@@ -140,6 +142,8 @@ static void usage(const char *argv0) ...@@ -140,6 +142,8 @@ static void usage(const char *argv0)
for (i = V4L2_YCBCR_ENC_DEFAULT; i <= V4L2_YCBCR_ENC_SMPTE240M; i++) for (i = V4L2_YCBCR_ENC_DEFAULT; i <= V4L2_YCBCR_ENC_SMPTE240M; i++)
printf("\t %s\n", printf("\t %s\n",
v4l2_subdev_ycbcr_encoding_to_string(i)); v4l2_subdev_ycbcr_encoding_to_string(i));
printf("\twhich Subdev state ('active' or 'try')\n");
} }
#define OPT_PRINT_DOT 256 #define OPT_PRINT_DOT 256
...@@ -168,6 +172,7 @@ static struct option opts[] = { ...@@ -168,6 +172,7 @@ static struct option opts[] = {
{"reset", 0, 0, 'r'}, {"reset", 0, 0, 'r'},
{"verbose", 0, 0, 'v'}, {"verbose", 0, 0, 'v'},
{"version", 0, 0, OPT_VERSION}, {"version", 0, 0, OPT_VERSION},
{"which", 1, 0, 'W'},
{ }, { },
}; };
...@@ -244,7 +249,7 @@ int parse_cmdline(int argc, char **argv) ...@@ -244,7 +249,7 @@ int parse_cmdline(int argc, char **argv)
} }
/* parse options */ /* parse options */
while ((opt = getopt_long(argc, argv, "d:e:f:hil:prvV:R:", while ((opt = getopt_long(argc, argv, "d:e:f:hil:prvV:R:W:",
opts, NULL)) != -1) { opts, NULL)) != -1) {
switch (opt) { switch (opt) {
case 'd': case 'd':
...@@ -294,6 +299,17 @@ int parse_cmdline(int argc, char **argv) ...@@ -294,6 +299,17 @@ int parse_cmdline(int argc, char **argv)
media_opts.routes = optarg; media_opts.routes = optarg;
break; break;
case 'W':
if (!strcmp(optarg, "active"))
media_opts.which = V4L2_SUBDEV_FORMAT_ACTIVE;
else if (!strcmp(optarg, "try"))
media_opts.which = V4L2_SUBDEV_FORMAT_TRY;
else {
printf("Invalid 'which' value '%s'\n", optarg);
return 1;
}
break;
case OPT_PRINT_DOT: case OPT_PRINT_DOT:
media_opts.print_dot = 1; media_opts.print_dot = 1;
break; break;
......
...@@ -37,6 +37,7 @@ struct media_options ...@@ -37,6 +37,7 @@ struct media_options
const char *get_dv_pad; const char *get_dv_pad;
const char *dv_pad; const char *dv_pad;
const char *routes; const char *routes;
enum v4l2_subdev_format_whence which;
}; };
extern struct media_options media_opts; extern struct media_options media_opts;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment