From a753dba7ed68896912f291f7ca01edb85a66db75 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 11 Aug 2010 09:28:09 +0200 Subject: Add a --get-format option The option takes a pad name as argument and returns the active format (and optional crop settings if available) for that pad. Signed-off-by: Laurent Pinchart --- main.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 15ccfb2..e143b8c 100644 --- a/main.c +++ b/main.c @@ -81,7 +81,8 @@ static struct media_entity_pad *parse_pad(struct media_device *media, const char return NULL; for (p = end; isspace(*p); ++p); - *endp = (char *)p; + if (endp) + *endp = (char *)p; return &entity->pads[pad]; } @@ -443,6 +444,7 @@ static int setup_formats(struct media_device *media, const char *p) int main(int argc, char **argv) { struct media_device *media; + int ret = -1; if (parse_cmdline(argc, argv)) return EXIT_FAILURE; @@ -457,10 +459,26 @@ int main(int argc, char **argv) entity = media_get_entity_by_name(media, media_opts.entity, strlen(media_opts.entity)); - if (entity != NULL) - printf("%s\n", entity->devname); - else + if (entity == NULL) { printf("Entity '%s' not found\n", media_opts.entity); + goto out; + } + + printf("%s\n", entity->devname); + } + + if (media_opts.pad) { + struct media_entity_pad *pad; + + pad = parse_pad(media, media_opts.pad, NULL); + if (pad == NULL) { + printf("Pad '%s' not found\n", media_opts.pad); + goto out; + } + + v4l2_subdev_print_format(pad->entity, pad->index, + V4L2_SUBDEV_FORMAT_ACTIVE); + printf("\n"); } if (media_opts.print || media_opts.print_dot) { @@ -495,10 +513,12 @@ int main(int argc, char **argv) } } + ret = 0; + out: if (media) media_close(media); - exit(EXIT_SUCCESS); + return ret ? EXIT_FAILURE : EXIT_SUCCESS; } -- cgit v1.2.3