From 01810822c56591c22a11870573211af2b8b8b46e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 24 Feb 2013 08:46:49 +0100 Subject: v4l2-drm-example: Sort options alphabetically and by category Sort the options alphabetically in the code, and by category in the help message. Signed-off-by: Laurent Pinchart --- v4l2-drm-example/dmabuf-sharing.c | 75 +++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/v4l2-drm-example/dmabuf-sharing.c b/v4l2-drm-example/dmabuf-sharing.c index 0483f27..6f21de2 100644 --- a/v4l2-drm-example/dmabuf-sharing.c +++ b/v4l2-drm-example/dmabuf-sharing.c @@ -123,18 +123,23 @@ struct stream { static void usage(char *name) { - fprintf(stderr, "usage: %s [-Moisth]\n", name); - fprintf(stderr, "\t-M \tset DRM module\n"); - fprintf(stderr, "\t-o ::\tset a mode\n"); + fprintf(stderr, "usage: %s [-bFfhiMoSst]\n", name); + + fprintf(stderr, "\nCapture options:\n\n"); fprintf(stderr, "\t-i \tset video node like /dev/video*\n"); - fprintf(stderr, "\t-S \tset input resolution\n"); fprintf(stderr, "\t-f \tset input format using 4cc\n"); - fprintf(stderr, "\t-F \tset output format using 4cc\n"); + fprintf(stderr, "\t-S \tset input resolution\n"); fprintf(stderr, "\t-s @\tset crop area\n"); + + fprintf(stderr, "\nDisplay options:\n\n"); + fprintf(stderr, "\t-M \tset DRM module\n"); + fprintf(stderr, "\t-o ::\tset a mode\n"); + fprintf(stderr, "\t-F \tset output format using 4cc\n"); fprintf(stderr, "\t-t @\tset compose area\n"); + + fprintf(stderr, "\nGeneric options:\n\n"); fprintf(stderr, "\t-b buffer_count\tset number of buffers\n"); fprintf(stderr, "\t-h\tshow this help\n"); - fprintf(stderr, "\n\tDefault is to dump all info.\n"); } static inline int parse_rect(char *s, struct v4l2_rect *r) @@ -151,8 +156,36 @@ static int parse_args(int argc, char *argv[], struct setup *s) int c, ret; memset(s, 0, sizeof(*s)); - while ((c = getopt(argc, argv, "M:o:i:S:f:F:s:t:b:h")) != -1) { + while ((c = getopt(argc, argv, "b:F:f:hi:M:o:S:s:t:")) != -1) { switch (c) { + case 'b': + ret = sscanf(optarg, "%u", &s->buffer_count); + if (WARN_ON(ret != 1, "incorrect buffer count\n")) + return -1; + break; + case 'F': + if (WARN_ON(strlen(optarg) != 4, "invalid fourcc\n")) + return -1; + s->out_fourcc = ((unsigned)optarg[0] << 0) | + ((unsigned)optarg[1] << 8) | + ((unsigned)optarg[2] << 16) | + ((unsigned)optarg[3] << 24); + break; + case 'f': + if (WARN_ON(strlen(optarg) != 4, "invalid fourcc\n")) + return -1; + s->in_fourcc = ((unsigned)optarg[0] << 0) | + ((unsigned)optarg[1] << 8) | + ((unsigned)optarg[2] << 16) | + ((unsigned)optarg[3] << 24); + break; + case '?': + case 'h': + usage(argv[0]); + return -1; + case 'i': + strncpy(s->video, optarg, 31); + break; case 'M': strncpy(s->module, optarg, 31); break; @@ -162,31 +195,12 @@ static int parse_args(int argc, char *argv[], struct setup *s) if (WARN_ON(ret != 3, "incorrect mode description\n")) return -1; break; - case 'i': - strncpy(s->video, optarg, 31); - break; case 'S': ret = sscanf(optarg, "%u,%u", &s->w, &s->h); if (WARN_ON(ret != 2, "incorrect input size\n")) return -1; s->use_wh = 1; break; - case 'f': - if (WARN_ON(strlen(optarg) != 4, "invalid fourcc\n")) - return -1; - s->in_fourcc = ((unsigned)optarg[0] << 0) | - ((unsigned)optarg[1] << 8) | - ((unsigned)optarg[2] << 16) | - ((unsigned)optarg[3] << 24); - break; - case 'F': - if (WARN_ON(strlen(optarg) != 4, "invalid fourcc\n")) - return -1; - s->out_fourcc = ((unsigned)optarg[0] << 0) | - ((unsigned)optarg[1] << 8) | - ((unsigned)optarg[2] << 16) | - ((unsigned)optarg[3] << 24); - break; case 's': ret = parse_rect(optarg, &s->crop); if (WARN_ON(ret, "incorrect crop area\n")) @@ -199,15 +213,6 @@ static int parse_args(int argc, char *argv[], struct setup *s) return -1; s->use_compose = 1; break; - case 'b': - ret = sscanf(optarg, "%u", &s->buffer_count); - if (WARN_ON(ret != 1, "incorrect buffer count\n")) - return -1; - break; - case '?': - case 'h': - usage(argv[0]); - return -1; } } -- cgit v1.2.3