diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2010-08-11 09:28:09 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2010-08-11 10:51:10 +0200 |
commit | a753dba7ed68896912f291f7ca01edb85a66db75 (patch) | |
tree | fc4e03efbbcfde0c876df896513cdfd387d22ef6 /main.c | |
parent | 74004e698ba7479d2cab0ecb5c2259d44072f6e0 (diff) |
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 <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 30 |
1 files changed, 25 insertions, 5 deletions
@@ -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; } |