v4l2-compliance: Add version command
PATCH v2 1/6 v4l2-compliance: Add version command
Add a --version option to v4l2-compliance to retrieve the version of v4l2-compliance. While at it, factor out and reorder printing the SHA to after argument parsing.
--- utils/v4l2-compliance/v4l2-compliance.cpp | 40 ++++++++++++++++------- 1 file changed, 29 insertions(+), 11 deletions(-)
utils/v4l2-compliance/v4l2-compliance.cpp +29 -11
@@ -79,6 +79,7 @@ enum Option { OptMediaBusInfo = 'z', OptStreamFrom = 128, OptStreamFromHdr, + OptVersion, OptLast = 256 };
@@ -153,9 +154,29 @@ static struct option long_options[] = { {"stream-all-formats", optional_argument, 0, OptStreamAllFormats}, {"stream-all-io", no_argument, 0, OptStreamAllIO}, {"stream-all-color", required_argument, 0, OptStreamAllColorTest}, + {"version", no_argument, 0, OptVersion}, {0, 0, 0, 0} }; +static void print_sha() +{ +#ifdef SHA +#define STR(x) #x +#define STRING(x) STR(x) + printf("v4l2-compliance SHA: %s", STRING(SHA)); +#else + printf("v4l2-compliance SHA: not available\n"); +#endif + + printf(", %zd bits, %zd-bit time_t\n", sizeof(void *) * 8, sizeof(time_t) * 8); + printf("\n"); +} + +static void version() +{ + printf("v4l2-compliance " PACKAGE_VERSION "\n"); +} + static void usage() { printf("Usage:\n");
@@ -244,6 +265,7 @@ static void usage() printf(" -P, --no-progress Turn off progress messages.\n"); printf(" -T, --trace Trace all called ioctls.\n"); printf(" -v, --verbose Turn on verbose reporting.\n"); + printf(" --version Show version information.\n"); #ifndef NO_LIBV4L2 printf(" -w, --wrapper Use the libv4l2 wrapper library.\n"); #endif
@@ -1485,17 +1507,6 @@ int main(int argc, char **argv) char *value, *subs; int idx = 0; -#ifdef SHA -#define STR(x) #x -#define STRING(x) STR(x) - printf("v4l2-compliance SHA: %s", STRING(SHA)); -#else - printf("v4l2-compliance SHA: not available\n"); -#endif - - printf(", %zd bits, %zd-bit time_t\n", sizeof(void *) * 8, sizeof(time_t) * 8); - printf("\n"); - if (!env_media_apps_color || !strcmp(env_media_apps_color, "auto")) show_colors = isatty(STDOUT_FILENO); else if (!strcmp(env_media_apps_color, "always"))
@@ -1664,6 +1675,10 @@ int main(int argc, char **argv) case OptNoProgress: no_progress = true; break; + case OptVersion: + version(); + print_sha(); + std::exit(EXIT_SUCCESS); case ':': fprintf(stderr, "Option `%s' requires a value\n", argv[optind]);
@@ -1685,6 +1700,9 @@ int main(int argc, char **argv) usage(); std::exit(EXIT_FAILURE); } + + print_sha(); + bool direct = !options[OptUseWrapper]; int fd;
Signature · 1 line
2.27.0
PATCH v2 2/6 v4l2-ctl: Add version command
Add a --version option to v4l2-ctl to retrieve the version of v4l2-ctl.
--- utils/v4l2-ctl/v4l2-ctl-common.cpp | 1 + utils/v4l2-ctl/v4l2-ctl.cpp | 9 +++++++++ utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 11 insertions(+)
utils/v4l2-ctl/v4l2-ctl-common.cpp +1 -0
@@ -121,6 +121,7 @@ void common_usage() " --silent only set the result code, do not print any messages\n" " --sleep <secs> sleep <secs>, call QUERYCAP and close the file handle\n" " --verbose turn on verbose ioctl status reporting\n" + " --version show version information\n" ); }
utils/v4l2-ctl/v4l2-ctl.cpp +9 -0
@@ -284,6 +284,7 @@ static struct option long_options[] = { {"stream-out-user", optional_argument, 0, OptStreamOutUser}, {"stream-out-dmabuf", no_argument, 0, OptStreamOutDmaBuf}, {"list-patterns", no_argument, 0, OptListPatterns}, + {"version", no_argument, 0, OptVersion}, {0, 0, 0, 0} };
@@ -306,6 +307,11 @@ static void usage_all() edid_usage(); } +static void version() +{ + printf("v4l2-ctl " PACKAGE_VERSION "\n"); +} + int test_ioctl(int fd, unsigned long cmd, void *arg) { return options[OptUseWrapper] ? v4l2_ioctl(fd, cmd, arg) : ioctl(fd, cmd, arg);
@@ -1245,6 +1251,9 @@ int main(int argc, char **argv) case OptSleep: secs = strtoul(optarg, 0L, 0); break; + case OptVersion: + version(); + return 0; case ':': fprintf(stderr, "Option '%s' requires a value\n", argv[optind]);
utils/v4l2-ctl/v4l2-ctl.h +1 -0
@@ -263,6 +263,7 @@ enum Option { OptHelpStreaming, OptHelpEdid, OptHelpAll, + OptVersion, OptLast = 512 };
Signature · 1 line
2.27.0
Re: [PATCH v2 2/6] v4l2-ctl: Add version command
Hi Paul,
Thank you for the patch.
Quoted 34 lines · Paul Elder
Add a --version option to v4l2-ctl to retrieve the version of v4l2-ctl.
Signed-off-by Paul Elder <[email protected]>--- utils/v4l2-ctl/v4l2-ctl-common.cpp | 1 + utils/v4l2-ctl/v4l2-ctl.cpp | 9 +++++++++ utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 11 insertions(+)utils/v4l2-ctl/v4l2-ctl-common.cpp +1
-0@@ -121,6 +121,7 @@ void common_usage() " --silent only set the result code, do not print any messages\n" " --sleep <secs> sleep <secs>, call QUERYCAP and close the file handle\n" " --verbose turn on verbose ioctl status reporting\n" + " --version show version information\n" ); }utils/v4l2-ctl/v4l2-ctl.cpp +1
-0@@ -284,6 +284,7 @@ static struct option long_options[] = { {"stream-out-user", optional_argument, 0, OptStreamOutUser}, {"stream-out-dmabuf", no_argument, 0, OptStreamOutDmaBuf}, {"list-patterns", no_argument, 0, OptListPatterns}, + {"version", no_argument, 0, OptVersion}, {0, 0, 0, 0} };
utils/v4l2-ctl/v4l2-ctl.cpp static void usage_all() · line 312
Quoted 6 lines
utils/v4l2-ctl/v4l2-ctl.cpp +3
-0@@ -306,6 +307,11 @@ static void usage_all() edid_usage(); } +static void version() +{ + printf("v4l2-ctl " PACKAGE_VERSION "\n");
I'd write
printf("v4l2-ctl %s\n", PACKAGE_VERSION);in case PACKAGE_VERSION would get a % in the future.
Same for the other patches in this series.
Quoted 27 lines
utils/v4l2-ctl/v4l2-ctl.cpp +5
-0+} + int test_ioctl(int fd, unsigned long cmd, void *arg) { return options[OptUseWrapper] ? v4l2_ioctl(fd, cmd, arg) : ioctl(fd, cmd, arg);@@ -1245,6 +1251,9 @@ int main(int argc, char **argv) case OptSleep: secs = strtoul(optarg, 0L, 0); break; + case OptVersion: + version(); + return 0; case ':': fprintf(stderr, "Option '%s' requires a value\n", argv[optind]);utils/v4l2-ctl/v4l2-ctl.h +1
-0@@ -263,6 +263,7 @@ enum Option { OptHelpStreaming, OptHelpEdid, OptHelpAll, + OptVersion, OptLast = 512 };
Signature · 3 lines
Regards, Laurent Pinchart
PATCH v2 3/6 cec-compliance: Add version command
In reply to Paul ElderAdd a --version option to cec-compliance to retrieve the version of cec-compliance. While at it, factor out printing the SHA.
--- utils/cec-compliance/cec-compliance.cpp | 33 +++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-)
utils/cec-compliance/cec-compliance.cpp +26 -7
@@ -96,6 +96,8 @@ enum Option { OptSkipTestTunerControl, OptSkipTestVendorSpecificCommands, OptSkipTestStandbyResume, + + OptVersion, OptLast = 256 };
@@ -177,9 +179,27 @@ static struct option long_options[] = { {"skip-test-tuner-control", no_argument, 0, OptSkipTestTunerControl}, {"skip-test-vendor-specific-commands", no_argument, 0, OptSkipTestVendorSpecificCommands}, {"skip-test-standby-resume", no_argument, 0, OptSkipTestStandbyResume}, + {"version", no_argument, 0, OptVersion}, {0, 0, 0, 0} }; +static void print_sha() +{ +#ifdef SHA +#define STR(x) #x +#define STRING(x) STR(x) + printf("cec-compliance SHA : %s\n", STRING(SHA)); +#else + printf("cec-compliance SHA : not available\n"); +#endif + +} + +static void version() +{ + printf("cec-compliance " PACKAGE_VERSION "\n"); +} + static void usage() { printf("Usage:\n"
@@ -234,6 +254,7 @@ static void usage() " -s, --skip-info Skip Driver Info output\n" " -T, --trace Trace all called ioctls\n" " -v, --verbose Turn on verbose reporting\n" + " --version Show version information\n" " -w, --wall-clock Show timestamps as wall-clock time (implies -v)\n" " -W, --exit-on-warn Exit on the first warning.\n" );
@@ -1261,6 +1282,10 @@ int main(int argc, char **argv) case OptVerbose: show_info = true; break; + case OptVersion: + version(); + print_sha(); + std::exit(EXIT_SUCCESS); case ':': fprintf(stderr, "Option '%s' requires a value\n", argv[optind]);
@@ -1395,13 +1420,7 @@ int main(int argc, char **argv) if (options[OptInteractive]) test_tags |= TAG_INTERACTIVE; -#ifdef SHA -#define STR(x) #x -#define STRING(x) STR(x) - printf("cec-compliance SHA : %s\n", STRING(SHA)); -#else - printf("cec-compliance SHA : not available\n"); -#endif + print_sha(); node.phys_addr = CEC_PHYS_ADDR_INVALID; doioctl(&node, CEC_ADAP_G_PHYS_ADDR, &node.phys_addr);
Signature · 1 line
2.27.0
PATCH v2 4/6 cec-ctl: Add version command
In reply to Paul ElderAdd a --version option to cec-ctl to retrieve the version of cec-ctl.
--- utils/cec-ctl/cec-ctl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+)
utils/cec-ctl/cec-ctl.cpp +13 -0
@@ -133,6 +133,7 @@ enum Option { OptVendorCommandWithID, OptVendorRemoteButtonDown, OptCustomCommand, + OptVersion, }; struct node {
@@ -218,6 +219,8 @@ static struct option long_options[] = { { "unregistered", no_argument, 0, OptUnregistered }, { "help-all", no_argument, 0, OptHelpAll }, + { "version", no_argument, 0, OptVersion }, + CEC_PARSE_LONG_OPTS { "vendor-remote-button-down", required_argument, 0, OptVendorRemoteButtonDown }, \
@@ -231,6 +234,11 @@ static struct option long_options[] = { { 0, 0, 0, 0 } }; +static void version() +{ + printf("cec-ctl " PACKAGE_VERSION "\n"); +} + static void usage() { printf("Usage:\n"
@@ -262,6 +270,7 @@ static void usage() " --help-all Show all help messages\n" " -T, --trace Trace all called ioctls\n" " -v, --verbose Turn on verbose reporting\n" + " --version Show version information\n" " -w, --wall-clock Show timestamps as wall-clock time (implies -v)\n" " -W, --wait-for-msgs Wait for messages and events for up to --monitor-time secs.\n" " --cec-version-1.4 Use CEC Version 1.4 instead of 2.0\n"
@@ -2296,6 +2305,10 @@ int main(int argc, char **argv) break; } + case OptVersion: + version(); + std::exit(EXIT_SUCCESS); + default: if (ch >= OptHelpAll) { cec_parse_usage_options(options);
Signature · 1 line
2.27.0
PATCH v2 5/6 cec-follower: Add version command
In reply to Paul ElderAdd a --version option to cec-follower to retrieve the version of cec-follower.
--- utils/cec-follower/cec-follower.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+)
utils/cec-follower/cec-follower.cpp +11 -0
@@ -46,6 +46,7 @@ enum Option { OptShowState = 's', OptWallClock = 'w', OptServiceByDigID = 128, + OptVersion, OptLast = 256 };
@@ -70,10 +71,16 @@ static struct option long_options[] = { { "wall-clock", no_argument, 0, OptWallClock }, { "service-by-dig-id", no_argument, 0, OptServiceByDigID }, { "ignore", required_argument, 0, OptIgnore }, + { "version", no_argument, 0, OptVersion }, { 0, 0, 0, 0 } }; +static void version() +{ + printf("cec-follower " PACKAGE_VERSION "\n"); +} + static void usage() { printf("Usage:\n"
@@ -93,6 +100,7 @@ static void usage() " Ignore messages from logical address <la> and opcode\n" " <opcode>. 'all' can be used for <la> or <opcode> to match\n" " all logical addresses or opcodes.\n" + " --version Show version information\n" ); }
@@ -427,6 +435,9 @@ int main(int argc, char **argv) show_msgs = true; show_state = true; break; + case OptVersion: + version(); + std::exit(EXIT_SUCCESS); case ':': fprintf(stderr, "Option '%s' requires a value\n", argv[optind]);
Signature · 1 line
2.27.0
PATCH v2 6/6 media-ctl: Add version command
In reply to Paul ElderAdd a --version option to media-ctl to retrieve the version of media-ctl.
--- utils/media-ctl/options.c | 12 ++++++++++++ utils/media-ctl/options.h | 2 ++ 2 files changed, 14 insertions(+)
utils/media-ctl/options.c +12 -0
@@ -42,6 +42,11 @@ struct media_options media_opts = { .devname = MEDIA_DEVNAME_DEFAULT, }; +static void version () +{ +printf ("media-ctl " PACKAGE_VERSION "\n" ); +} +static void usage (const char *argv0) {unsigned int i;
@@ -66,6 +71,7 @@ static void usage(const char *argv0)printf (" --print-dot Print the device topology as a dot graph\n" );printf ("-r, --reset Reset all links to inactive\n" );printf ("-v, --verbose Be verbose\n" ); +printf (" --version Show version information\n" );printf ("\n" );printf ("Links and formats are defined as\n" );printf ("\tlinks = link { ',' link } ;\n" );
@@ -127,6 +133,7 @@ static void usage(const char *argv0)#define OPT_SET_DV 258#define OPT_LIST_KNOWN_MBUS_FMTS 259#define OPT_GET_DV 260 +#define OPT_VERSION 261static struct option opts[] = { {"device" ,1 ,0 ,'d' },
@@ -145,6 +152,7 @@ static struct option opts[] = { {"print-topology", 0, 0, 'p'}, {"reset", 0, 0, 'r'}, {"verbose", 0, 0, 'v'}, + {"version", 0, 0, OPT_VERSION}, { }, };
@@ -287,6 +295,10 @@ int parse_cmdline(int argc, char **argv)list_known_mbus_formats ();exit (0 ); +case OPT_VERSION : +version (); +exit (0 ); +default :printf ("Invalid option -%c\n" , opt);printf ("Run %s -h for help.\n" , argv[0 ]);
utils/media-ctl/options.h +2 -0
@@ -22,6 +22,8 @@ #ifndef __OPTIONS_H #define __OPTIONS_H +#include <config.h> + struct media_options { const char *devname;
Signature · 1 line
2.27.0