linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 1/5] v4l2-compliance: Add version command
@ 2020-07-15 10:26 Paul Elder
  2020-07-15 10:26 ` [PATCH v5 2/5] v4l2-ctl: " Paul Elder
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Paul Elder @ 2020-07-15 10:26 UTC (permalink / raw)
  To: linux-media; +Cc: Paul Elder, laurent.pinchart, hverkuil

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.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v5:
- update manpage
- move STR macros to before print_sha()

Changes in v4:
- add git commit count to version

Changes in v3:
- embed PACKAGE_VERSION instead of string concatenation
---
 utils/v4l2-compliance/v4l2-compliance.1.in |  3 +++
 utils/v4l2-compliance/v4l2-compliance.cpp  | 31 +++++++++++++++++-----
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/utils/v4l2-compliance/v4l2-compliance.1.in b/utils/v4l2-compliance/v4l2-compliance.1.in
index 39f0229d..89d7e482 100644
--- a/utils/v4l2-compliance/v4l2-compliance.1.in
+++ b/utils/v4l2-compliance/v4l2-compliance.1.in
@@ -184,6 +184,9 @@ Trace all called ioctls.
 \fB\-v\fR, \fB\-\-verbose\fR
 Turn on verbose reporting.
 .TP
+\fB\-\-version\fR
+Show version information.
+.TP
 \fB\-w\fR, \fB\-\-wrapper\fR
 Use the libv4l2 wrapper library for all V4L2 device accesses. Note that doing this will
 cause some tests to fail because the libv4l2 library isn't fully V4L2 compliant. By
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 825f2aa6..92b4e995 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -76,6 +76,7 @@ enum Option {
 	OptMediaBusInfo = 'z',
 	OptStreamFrom = 128,
 	OptStreamFromHdr,
+	OptVersion,
 	OptLast = 256
 };
 
@@ -150,9 +151,25 @@ 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}
 };
 
+#define STR(x) #x
+#define STRING(x) STR(x)
+
+static void print_sha()
+{
+	printf("v4l2-compliance SHA: %s", STRING(GIT_SHA));
+	printf(", %zd bits, %zd-bit time_t\n", sizeof(void *) * 8, sizeof(time_t) * 8);
+	printf("\n");
+}
+
+static void print_version()
+{
+	printf("v4l2-compliance %s%s\n", PACKAGE_VERSION, STRING(GIT_COMMIT_CNT));
+}
+
 static void usage()
 {
 	printf("Usage:\n");
@@ -241,6 +258,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
@@ -1482,12 +1500,6 @@ int main(int argc, char **argv)
 	char *value, *subs;
 	int idx = 0;
 
-#define STR(x) #x
-#define STRING(x) STR(x)
-	printf("v4l2-compliance SHA: %s", STRING(GIT_SHA));
-	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"))
@@ -1656,6 +1668,10 @@ int main(int argc, char **argv)
 		case OptNoProgress:
 			no_progress = true;
 			break;
+		case OptVersion:
+			print_version();
+			print_sha();
+			std::exit(EXIT_SUCCESS);
 		case ':':
 			fprintf(stderr, "Option `%s' requires a value\n",
 				argv[optind]);
@@ -1677,6 +1693,9 @@ int main(int argc, char **argv)
 		usage();
 		std::exit(EXIT_FAILURE);
 	}
+
+	print_sha();
+
 	bool direct = !options[OptUseWrapper];
 	int fd;
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v5 2/5] v4l2-ctl: Add version command
  2020-07-15 10:26 [PATCH v5 1/5] v4l2-compliance: Add version command Paul Elder
@ 2020-07-15 10:26 ` Paul Elder
  2020-07-15 10:26 ` [PATCH v5 3/5] cec-compliance: " Paul Elder
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Elder @ 2020-07-15 10:26 UTC (permalink / raw)
  To: linux-media; +Cc: Paul Elder, laurent.pinchart, hverkuil

Add a --version option to v4l2-ctl to retrieve the version of v4l2-ctl.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---
Changes in v5:
- update manpage

Changes in v4:
- add git commit count to version

Changes in v3:
- embed PACKAGE_VERSION instead of string concatenation
---
 utils/v4l2-ctl/Makefile.am         |  2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp |  1 +
 utils/v4l2-ctl/v4l2-ctl.1.in       |  3 +++
 utils/v4l2-ctl/v4l2-ctl.cpp        | 11 +++++++++++
 utils/v4l2-ctl/v4l2-ctl.h          |  1 +
 5 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/utils/v4l2-ctl/Makefile.am b/utils/v4l2-ctl/Makefile.am
index 3ba3c96b..04d30894 100644
--- a/utils/v4l2-ctl/Makefile.am
+++ b/utils/v4l2-ctl/Makefile.am
@@ -14,7 +14,7 @@ v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cp
 	v4l2-ctl-streaming.cpp v4l2-ctl-sdr.cpp v4l2-ctl-edid.cpp v4l2-ctl-modes.cpp \
 	v4l2-ctl-subdev.cpp v4l2-tpg-colors.c v4l2-tpg-core.c v4l-stream.c v4l2-ctl-meta.cpp \
 	media-info.cpp v4l2-info.cpp codec-fwht.c codec-v4l2-fwht.c
-v4l2_ctl_CPPFLAGS = -I$(top_srcdir)/utils/common
+v4l2_ctl_CPPFLAGS = -I$(top_srcdir)/utils/common $(GIT_COMMIT_CNT)
 
 media-bus-format-names.h: $(top_srcdir)/include/linux/media-bus-format.h
 	sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index 47f5da1a..9b785cbf 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -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"
 	       );
 }
 
diff --git a/utils/v4l2-ctl/v4l2-ctl.1.in b/utils/v4l2-ctl/v4l2-ctl.1.in
index e9fff788..b8cbe6d2 100644
--- a/utils/v4l2-ctl/v4l2-ctl.1.in
+++ b/utils/v4l2-ctl/v4l2-ctl.1.in
@@ -21,6 +21,9 @@ with the bus info string as specified by the \fB-z\fR option.
 \fB\-v\fR, \fB\-\-verbose\fR
 Turn on verbose reporting.
 .TP
+\fB\-\-version\fR
+Show version information.
+.TP
 \fB\-w\fR, \fB\-\-wrapper\fR
 Use the libv4l2 wrapper library for all V4L2 device accesses. By default v4l2-ctl will
 directly access the V4L2 device, but with this option all access will go via this
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 4972591e..321d2d1c 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -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,13 @@ static void usage_all()
        edid_usage();
 }
 
+static void print_version()
+{
+#define STR(x) #x
+#define STRING(x) STR(x)
+	printf("v4l2-ctl %s%s\n", PACKAGE_VERSION, STRING(GIT_COMMIT_CNT));
+}
+
 int test_ioctl(int fd, unsigned long cmd, void *arg)
 {
 	return options[OptUseWrapper] ? v4l2_ioctl(fd, cmd, arg) : ioctl(fd, cmd, arg);
@@ -1245,6 +1253,9 @@ int main(int argc, char **argv)
 		case OptSleep:
 			secs = strtoul(optarg, 0L, 0);
 			break;
+		case OptVersion:
+			print_version();
+			return 0;
 		case ':':
 			fprintf(stderr, "Option '%s' requires a value\n",
 					argv[optind]);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index 28e50471..27a3ca35 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -263,6 +263,7 @@ enum Option {
 	OptHelpStreaming,
 	OptHelpEdid,
 	OptHelpAll,
+	OptVersion,
 	OptLast = 512
 };
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v5 3/5] cec-compliance: Add version command
  2020-07-15 10:26 [PATCH v5 1/5] v4l2-compliance: Add version command Paul Elder
  2020-07-15 10:26 ` [PATCH v5 2/5] v4l2-ctl: " Paul Elder
@ 2020-07-15 10:26 ` Paul Elder
  2020-07-15 10:26 ` [PATCH v5 4/5] cec-ctl: " Paul Elder
  2020-07-15 10:26 ` [PATCH v5 5/5] cec-follower: " Paul Elder
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Elder @ 2020-07-15 10:26 UTC (permalink / raw)
  To: linux-media; +Cc: Paul Elder, laurent.pinchart, hverkuil

Add a --version option to cec-compliance to retrieve the version of
cec-compliance. While at it, factor out printing the SHA.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v5:
- update manpage
- move STR macros to before print_sha()

Changes in v4:
- add git commit count to version

Changes in v3:
- embed PACKAGE_VERSION instead of string concatenation
---
 utils/cec-compliance/Makefile.am         |  2 +-
 utils/cec-compliance/cec-compliance.1.in |  3 +++
 utils/cec-compliance/cec-compliance.cpp  | 25 +++++++++++++++++++++---
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/utils/cec-compliance/Makefile.am b/utils/cec-compliance/Makefile.am
index 57ed7b37..a9c59ca6 100644
--- a/utils/cec-compliance/Makefile.am
+++ b/utils/cec-compliance/Makefile.am
@@ -2,7 +2,7 @@ bin_PROGRAMS = cec-compliance
 man_MANS = cec-compliance.1
 
 cec_compliance_SOURCES = cec-compliance.cpp cec-compliance.h cec-test.cpp cec-test-adapter.cpp cec-test-audio.cpp cec-test-power.cpp cec-test-fuzzing.cpp
-cec_compliance_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil $(GIT_SHA)
+cec_compliance_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil $(GIT_SHA) $(GIT_COMMIT_CNT)
 cec_compliance_LDADD = -lrt ../libcecutil/libcecutil.la
 
 EXTRA_DIST = cec-compliance.1
diff --git a/utils/cec-compliance/cec-compliance.1.in b/utils/cec-compliance/cec-compliance.1.in
index 3f9c7d8b..94654858 100644
--- a/utils/cec-compliance/cec-compliance.1.in
+++ b/utils/cec-compliance/cec-compliance.1.in
@@ -119,6 +119,9 @@ check that the test produced no warnings.
 \fB\-v\fR, \fB\-\-verbose\fR
 Turn on verbose reporting.
 .TP
+\fB\-\-version\fR
+Show version information.
+.TP
 \fB\-w\fR, \fB\-\-wall\-clock\fR
 Show timestamps as wall-clock time. This also turns on verbose reporting.
 .TP
diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp
index bfd82af7..618e3160 100644
--- a/utils/cec-compliance/cec-compliance.cpp
+++ b/utils/cec-compliance/cec-compliance.cpp
@@ -93,6 +93,8 @@ enum Option {
 	OptSkipTestTunerControl,
 	OptSkipTestVendorSpecificCommands,
 	OptSkipTestStandbyResume,
+
+	OptVersion,
 	OptLast = 256
 };
 
@@ -174,9 +176,23 @@ 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}
 };
 
+#define STR(x) #x
+#define STRING(x) STR(x)
+
+static void print_sha()
+{
+	printf("cec-compliance SHA                 : %s\n", STRING(GIT_SHA));
+}
+
+static void print_version()
+{
+	printf("cec-compliance %s%s\n", PACKAGE_VERSION, STRING(GIT_COMMIT_CNT));
+}
+
 static void usage()
 {
 	printf("Usage:\n"
@@ -231,6 +247,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"
 	       );
@@ -1258,6 +1275,10 @@ int main(int argc, char **argv)
 		case OptVerbose:
 			show_info = true;
 			break;
+		case OptVersion:
+			print_version();
+			print_sha();
+			std::exit(EXIT_SUCCESS);
 		case ':':
 			fprintf(stderr, "Option '%s' requires a value\n",
 				argv[optind]);
@@ -1392,9 +1413,7 @@ int main(int argc, char **argv)
 	if (options[OptInteractive])
 		test_tags |= TAG_INTERACTIVE;
 
-#define STR(x) #x
-#define STRING(x) STR(x)
-	printf("cec-compliance SHA                 : %s\n", STRING(GIT_SHA));
+	print_sha();
 
 	node.phys_addr = CEC_PHYS_ADDR_INVALID;
 	doioctl(&node, CEC_ADAP_G_PHYS_ADDR, &node.phys_addr);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v5 4/5] cec-ctl: Add version command
  2020-07-15 10:26 [PATCH v5 1/5] v4l2-compliance: Add version command Paul Elder
  2020-07-15 10:26 ` [PATCH v5 2/5] v4l2-ctl: " Paul Elder
  2020-07-15 10:26 ` [PATCH v5 3/5] cec-compliance: " Paul Elder
@ 2020-07-15 10:26 ` Paul Elder
  2020-07-15 10:26 ` [PATCH v5 5/5] cec-follower: " Paul Elder
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Elder @ 2020-07-15 10:26 UTC (permalink / raw)
  To: linux-media; +Cc: Paul Elder, laurent.pinchart, hverkuil

Add a --version option to cec-ctl to retrieve the version of cec-ctl.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v5:
- update manpage

Changes in v4:
- add git commit count to version

Changes in v3:
- embed PACKAGE_VERSION instead of string concatenation
---
 utils/cec-ctl/Makefile.am  |  2 +-
 utils/cec-ctl/cec-ctl.1.in |  3 +++
 utils/cec-ctl/cec-ctl.cpp  | 15 +++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/utils/cec-ctl/Makefile.am b/utils/cec-ctl/Makefile.am
index 24341ed7..278fcc47 100644
--- a/utils/cec-ctl/Makefile.am
+++ b/utils/cec-ctl/Makefile.am
@@ -2,7 +2,7 @@ bin_PROGRAMS = cec-ctl
 man_MANS = cec-ctl.1
 
 cec_ctl_SOURCES = cec-ctl.cpp cec-pin.cpp cec-ctl.h
-cec_ctl_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil
+cec_ctl_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil $(GIT_COMMIT_CNT)
 cec_ctl_LDADD = -lrt ../libcecutil/libcecutil.la
 
 EXTRA_DIST = cec-ctl.1
diff --git a/utils/cec-ctl/cec-ctl.1.in b/utils/cec-ctl/cec-ctl.1.in
index f767b479..fac3a92e 100644
--- a/utils/cec-ctl/cec-ctl.1.in
+++ b/utils/cec-ctl/cec-ctl.1.in
@@ -52,6 +52,9 @@ having to rely on the device node number.
 \fB\-v\fR, \fB\-\-verbose\fR
 Turn on verbose reporting.
 .TP
+\fB\-\-version\fR
+Show version information.
+.TP
 \fB\-w\fR, \fB\-\-wall\-clock\fR
 Show timestamps as wall-clock time. This also turns on verbose reporting. 
 .TP
diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp
index 455cdaeb..47867f87 100644
--- a/utils/cec-ctl/cec-ctl.cpp
+++ b/utils/cec-ctl/cec-ctl.cpp
@@ -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,13 @@ static struct option long_options[] = {
 	{ 0, 0, 0, 0 }
 };
 
+static void print_version()
+{
+#define STR(x) #x
+#define STRING(x) STR(x)
+	printf("cec-ctl %s%s\n", PACKAGE_VERSION, STRING(GIT_COMMIT_CNT));
+}
+
 static void usage()
 {
 	printf("Usage:\n"
@@ -262,6 +272,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 +2307,10 @@ int main(int argc, char **argv)
 			break;
 		}
 
+		case OptVersion:
+			print_version();
+			std::exit(EXIT_SUCCESS);
+
 		default:
 			if (ch >= OptHelpAll) {
 				cec_parse_usage_options(options);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v5 5/5] cec-follower: Add version command
  2020-07-15 10:26 [PATCH v5 1/5] v4l2-compliance: Add version command Paul Elder
                   ` (2 preceding siblings ...)
  2020-07-15 10:26 ` [PATCH v5 4/5] cec-ctl: " Paul Elder
@ 2020-07-15 10:26 ` Paul Elder
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Elder @ 2020-07-15 10:26 UTC (permalink / raw)
  To: linux-media; +Cc: Paul Elder, laurent.pinchart, hverkuil

Add a --version option to cec-follower to retrieve the version of
cec-follower. Whilte at it, factor out printing the SHA.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v5:
- update manpage

Changes in v4:
- add git commit count to version
- move printing sha into print_sha()

Changes in v3:
- embed PACKAGE_VERSION instead of string concatenation
---
 utils/cec-follower/Makefile.am       |  2 +-
 utils/cec-follower/cec-follower.1.in |  3 +++
 utils/cec-follower/cec-follower.cpp  | 30 +++++++++++++++++++++-------
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/utils/cec-follower/Makefile.am b/utils/cec-follower/Makefile.am
index a550cd1d..96e0f890 100644
--- a/utils/cec-follower/Makefile.am
+++ b/utils/cec-follower/Makefile.am
@@ -2,7 +2,7 @@ bin_PROGRAMS = cec-follower
 man_MANS = cec-follower.1
 
 cec_follower_SOURCES = cec-follower.cpp cec-follower.h cec-processing.cpp cec-tuner.cpp
-cec_follower_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil
+cec_follower_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil $(GIT_COMMIT_CNT)
 cec_follower_LDADD = -lrt ../libcecutil/libcecutil.la
 
 cec-follower.cpp: version.h
diff --git a/utils/cec-follower/cec-follower.1.in b/utils/cec-follower/cec-follower.1.in
index 2836d6dd..61c591b3 100644
--- a/utils/cec-follower/cec-follower.1.in
+++ b/utils/cec-follower/cec-follower.1.in
@@ -61,6 +61,9 @@ having to rely on the device node number.
 \fB\-v\fR, \fB\-\-verbose\fR
 Turn on verbose reporting.
 .TP
+\fB\-\-version\fR
+Show version information.
+.TP
 \fB\-w\fR, \fB\-\-wall\-clock\fR
 Show timestamps as wall-clock time. This also turns on verbose reporting. 
 .TP
diff --git a/utils/cec-follower/cec-follower.cpp b/utils/cec-follower/cec-follower.cpp
index 9cead57a..b3f9d615 100644
--- a/utils/cec-follower/cec-follower.cpp
+++ b/utils/cec-follower/cec-follower.cpp
@@ -46,6 +46,7 @@ enum Option {
 	OptShowState = 's',
 	OptWallClock = 'w',
 	OptServiceByDigID = 128,
+	OptVersion,
 	OptLast = 256
 };
 
@@ -70,10 +71,27 @@ 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 print_sha()
+{
+#ifdef SHA
+#define STR(x) #x
+#define STRING(x) STR(x)
+	printf("cec-follower SHA                   : %s\n", STRING(SHA));
+#else
+	printf("cec-follower SHA                   : not available\n");
+#endif
+}
+
+static void print_version()
+{
+	printf("cec-follower %s%s\n", PACKAGE_VERSION, STRING(GIT_COMMIT_CNT));
+}
+
 static void usage()
 {
 	printf("Usage:\n"
@@ -93,6 +111,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 +446,9 @@ int main(int argc, char **argv)
 			show_msgs = true;
 			show_state = true;
 			break;
+		case OptVersion:
+			print_version();
+			std::exit(EXIT_SUCCESS);
 		case ':':
 			fprintf(stderr, "Option '%s' requires a value\n",
 				argv[optind]);
@@ -475,13 +497,7 @@ int main(int argc, char **argv)
 	node.state.service_by_dig_id = options[OptServiceByDigID];
 	state_init(node);
 
-#ifdef SHA
-#define STR(x) #x
-#define STRING(x) STR(x)
-	printf("cec-follower SHA                   : %s\n", STRING(SHA));
-#else
-	printf("cec-follower SHA                   : not available\n");
-#endif
+	print_sha();
 
 	doioctl(&node, CEC_ADAP_G_PHYS_ADDR, &node.phys_addr);
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-15 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 10:26 [PATCH v5 1/5] v4l2-compliance: Add version command Paul Elder
2020-07-15 10:26 ` [PATCH v5 2/5] v4l2-ctl: " Paul Elder
2020-07-15 10:26 ` [PATCH v5 3/5] cec-compliance: " Paul Elder
2020-07-15 10:26 ` [PATCH v5 4/5] cec-ctl: " Paul Elder
2020-07-15 10:26 ` [PATCH v5 5/5] cec-follower: " Paul Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).