This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-ctl/v4l2-compliance: reuse v4l2 info code
Author:  Hans Verkuil <hans.verk...@cisco.com>
Date:    Sun Feb 4 12:31:28 2018 +0100

Create v4l2-info.cpp/h to centralize the code used by
v4l2-ctl and v4l2-compliance to log V4L2 data structs.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>

 utils/common/v4l2-info.cpp                | 109 ++++++++++++++++++++++++++++++
 utils/common/v4l2-info.h                  |  24 +++++++
 utils/v4l2-compliance/Makefile.am         |   2 +-
 utils/v4l2-compliance/v4l2-compliance.cpp |  78 +--------------------
 utils/v4l2-compliance/v4l2-compliance.h   |   1 -
 utils/v4l2-compliance/v4l2-info.cpp       |   1 +
 utils/v4l2-compliance/v4l2-info.h         |   1 +
 utils/v4l2-ctl/Makefile.am                |   2 +-
 utils/v4l2-ctl/v4l2-ctl.cpp               |  82 ++--------------------
 utils/v4l2-ctl/v4l2-info.cpp              |   1 +
 utils/v4l2-ctl/v4l2-info.h                |   1 +
 11 files changed, 145 insertions(+), 157 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=88846496c3a98c2926f224095c33ed807d3ff1e7
diff --git a/utils/common/v4l2-info.cpp b/utils/common/v4l2-info.cpp
new file mode 100644
index 000000000000..566ce1a06093
--- /dev/null
+++ b/utils/common/v4l2-info.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2018 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+
+#include <linux/videodev2.h>
+
+#include <string>
+
+static std::string cap2s(unsigned cap)
+{
+       std::string s;
+
+       if (cap & V4L2_CAP_VIDEO_CAPTURE)
+               s += "\t\tVideo Capture\n";
+       if (cap & V4L2_CAP_VIDEO_CAPTURE_MPLANE)
+               s += "\t\tVideo Capture Multiplanar\n";
+       if (cap & V4L2_CAP_VIDEO_OUTPUT)
+               s += "\t\tVideo Output\n";
+       if (cap & V4L2_CAP_VIDEO_OUTPUT_MPLANE)
+               s += "\t\tVideo Output Multiplanar\n";
+       if (cap & V4L2_CAP_VIDEO_M2M)
+               s += "\t\tVideo Memory-to-Memory\n";
+       if (cap & V4L2_CAP_VIDEO_M2M_MPLANE)
+               s += "\t\tVideo Memory-to-Memory Multiplanar\n";
+       if (cap & V4L2_CAP_VIDEO_OVERLAY)
+               s += "\t\tVideo Overlay\n";
+       if (cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)
+               s += "\t\tVideo Output Overlay\n";
+       if (cap & V4L2_CAP_VBI_CAPTURE)
+               s += "\t\tVBI Capture\n";
+       if (cap & V4L2_CAP_VBI_OUTPUT)
+               s += "\t\tVBI Output\n";
+       if (cap & V4L2_CAP_SLICED_VBI_CAPTURE)
+               s += "\t\tSliced VBI Capture\n";
+       if (cap & V4L2_CAP_SLICED_VBI_OUTPUT)
+               s += "\t\tSliced VBI Output\n";
+       if (cap & V4L2_CAP_RDS_CAPTURE)
+               s += "\t\tRDS Capture\n";
+       if (cap & V4L2_CAP_RDS_OUTPUT)
+               s += "\t\tRDS Output\n";
+       if (cap & V4L2_CAP_SDR_CAPTURE)
+               s += "\t\tSDR Capture\n";
+       if (cap & V4L2_CAP_SDR_OUTPUT)
+               s += "\t\tSDR Output\n";
+       if (cap & V4L2_CAP_META_CAPTURE)
+               s += "\t\tMetadata Capture\n";
+       if (cap & V4L2_CAP_TUNER)
+               s += "\t\tTuner\n";
+       if (cap & V4L2_CAP_TOUCH)
+               s += "\t\tTouch Device\n";
+       if (cap & V4L2_CAP_HW_FREQ_SEEK)
+               s += "\t\tHW Frequency Seek\n";
+       if (cap & V4L2_CAP_MODULATOR)
+               s += "\t\tModulator\n";
+       if (cap & V4L2_CAP_AUDIO)
+               s += "\t\tAudio\n";
+       if (cap & V4L2_CAP_RADIO)
+               s += "\t\tRadio\n";
+       if (cap & V4L2_CAP_READWRITE)
+               s += "\t\tRead/Write\n";
+       if (cap & V4L2_CAP_ASYNCIO)
+               s += "\t\tAsync I/O\n";
+       if (cap & V4L2_CAP_STREAMING)
+               s += "\t\tStreaming\n";
+       if (cap & V4L2_CAP_EXT_PIX_FORMAT)
+               s += "\t\tExtended Pix Format\n";
+       if (cap & V4L2_CAP_DEVICE_CAPS)
+               s += "\t\tDevice Capabilities\n";
+       return s;
+}
+
+void v4l2_info_capability(const v4l2_capability &vcap)
+{
+       printf("\tDriver name      : %s\n", vcap.driver);
+       printf("\tCard type        : %s\n", vcap.card);
+       printf("\tBus info         : %s\n", vcap.bus_info);
+       printf("\tDriver version   : %d.%d.%d\n",
+              vcap.version >> 16,
+              (vcap.version >> 8) & 0xff,
+              vcap.version & 0xff);
+       printf("\tCapabilities     : 0x%08x\n", vcap.capabilities);
+       printf("%s", cap2s(vcap.capabilities).c_str());
+       if (vcap.capabilities & V4L2_CAP_DEVICE_CAPS) {
+               printf("\tDevice Caps      : 0x%08x\n", vcap.device_caps);
+               printf("%s", cap2s(vcap.device_caps).c_str());
+       }
+}
diff --git a/utils/common/v4l2-info.h b/utils/common/v4l2-info.h
new file mode 100644
index 000000000000..e33332a3dbe6
--- /dev/null
+++ b/utils/common/v4l2-info.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2018 Cisco Systems, Inc. and/or its affiliates. All rights 
reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _V4L2_INFO_H
+#define _V4L2_INFO_H
+
+/* Print capability information */
+void v4l2_info_capability(const v4l2_capability &cap);
+
+#endif
diff --git a/utils/v4l2-compliance/Makefile.am 
b/utils/v4l2-compliance/Makefile.am
index 07f4cef71119..6f0421d379c0 100644
--- a/utils/v4l2-compliance/Makefile.am
+++ b/utils/v4l2-compliance/Makefile.am
@@ -5,7 +5,7 @@ DEFS :=
 v4l2_compliance_SOURCES = v4l2-compliance.cpp v4l2-test-debug.cpp 
v4l2-test-input-output.cpp \
        v4l2-test-controls.cpp v4l2-test-io-config.cpp v4l2-test-formats.cpp 
v4l2-test-buffers.cpp \
        v4l2-test-codecs.cpp v4l2-test-subdevs.cpp v4l2-test-media.cpp 
v4l2-test-colors.cpp \
-       media-info.cpp
+       media-info.cpp v4l2-info.cpp
 v4l2_compliance_CPPFLAGS = -I$(top_srcdir)/utils/common
 
 if WITH_V4L2_COMPLIANCE_LIBV4L
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp 
b/utils/v4l2-compliance/v4l2-compliance.cpp
index 7747bdcaaf8d..f5f128a12f99 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -39,6 +39,7 @@
 #include <vector>
 
 #include "v4l2-compliance.h"
+#include <v4l2-info.h>
 #include <media-info.h>
 #ifndef ANDROID
 #include "version.h"
@@ -193,69 +194,6 @@ static void usage(void)
        exit(0);
 }
 
-std::string cap2s(unsigned cap)
-{
-       std::string s;
-
-       if (cap & V4L2_CAP_VIDEO_CAPTURE)
-               s += "\t\tVideo Capture\n";
-       if (cap & V4L2_CAP_VIDEO_CAPTURE_MPLANE)
-               s += "\t\tVideo Capture Multiplanar\n";
-       if (cap & V4L2_CAP_VIDEO_OUTPUT)
-               s += "\t\tVideo Output\n";
-       if (cap & V4L2_CAP_VIDEO_OUTPUT_MPLANE)
-               s += "\t\tVideo Output Multiplanar\n";
-       if (cap & V4L2_CAP_VIDEO_M2M)
-               s += "\t\tVideo Memory-to-Memory\n";
-       if (cap & V4L2_CAP_VIDEO_M2M_MPLANE)
-               s += "\t\tVideo Memory-to-Memory Multiplanar\n";
-       if (cap & V4L2_CAP_VIDEO_OVERLAY)
-               s += "\t\tVideo Overlay\n";
-       if (cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)
-               s += "\t\tVideo Output Overlay\n";
-       if (cap & V4L2_CAP_VBI_CAPTURE)
-               s += "\t\tVBI Capture\n";
-       if (cap & V4L2_CAP_VBI_OUTPUT)
-               s += "\t\tVBI Output\n";
-       if (cap & V4L2_CAP_SLICED_VBI_CAPTURE)
-               s += "\t\tSliced VBI Capture\n";
-       if (cap & V4L2_CAP_SLICED_VBI_OUTPUT)
-               s += "\t\tSliced VBI Output\n";
-       if (cap & V4L2_CAP_RDS_CAPTURE)
-               s += "\t\tRDS Capture\n";
-       if (cap & V4L2_CAP_RDS_OUTPUT)
-               s += "\t\tRDS Output\n";
-       if (cap & V4L2_CAP_SDR_CAPTURE)
-               s += "\t\tSDR Capture\n";
-       if (cap & V4L2_CAP_SDR_OUTPUT)
-               s += "\t\tSDR Output\n";
-       if (cap & V4L2_CAP_META_CAPTURE)
-               s += "\t\tMetadata Capture\n";
-       if (cap & V4L2_CAP_TOUCH)
-               s += "\t\tTouch Device\n";
-       if (cap & V4L2_CAP_TUNER)
-               s += "\t\tTuner\n";
-       if (cap & V4L2_CAP_HW_FREQ_SEEK)
-               s += "\t\tHW Frequency Seek\n";
-       if (cap & V4L2_CAP_MODULATOR)
-               s += "\t\tModulator\n";
-       if (cap & V4L2_CAP_AUDIO)
-               s += "\t\tAudio\n";
-       if (cap & V4L2_CAP_RADIO)
-               s += "\t\tRadio\n";
-       if (cap & V4L2_CAP_READWRITE)
-               s += "\t\tRead/Write\n";
-       if (cap & V4L2_CAP_ASYNCIO)
-               s += "\t\tAsync I/O\n";
-       if (cap & V4L2_CAP_STREAMING)
-               s += "\t\tStreaming\n";
-       if (cap & V4L2_CAP_EXT_PIX_FORMAT)
-               s += "\t\tExtended Pix Format\n";
-       if (cap & V4L2_CAP_DEVICE_CAPS)
-               s += "\t\tDevice Capabilities\n";
-       return s;
-}
-
 std::string fcc2s(unsigned int val)
 {
        std::string s;
@@ -1142,19 +1080,7 @@ int main(int argc, char **argv)
 
        if (node.is_v4l2()) {
                printf("\nDriver Info:\n");
-               printf("\tDriver name   : %s\n", vcap.driver);
-               printf("\tCard type     : %s\n", vcap.card);
-               printf("\tBus info      : %s\n", vcap.bus_info);
-               printf("\tDriver version: %d.%d.%d\n",
-                      vcap.version >> 16,
-                      (vcap.version >> 8) & 0xff,
-                      vcap.version & 0xff);
-               printf("\tCapabilities  : 0x%08X\n", vcap.capabilities);
-               printf("%s", cap2s(vcap.capabilities).c_str());
-               if (vcap.capabilities & V4L2_CAP_DEVICE_CAPS) {
-                       printf("\tDevice Caps   : 0x%08X\n", vcap.device_caps);
-                       printf("%s", cap2s(vcap.device_caps).c_str());
-               }
+               v4l2_info_capability(vcap);
        }
        if (node.is_media())
                mi_media_info_for_fd(node.g_fd(), -1);
diff --git a/utils/v4l2-compliance/v4l2-compliance.h 
b/utils/v4l2-compliance/v4l2-compliance.h
index 837bcfbb8175..2223df5964f8 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -174,7 +174,6 @@ static inline double fract2f(const struct v4l2_fract *f)
 
 #define doioctl(n, r, p) v4l_named_ioctl((n)->g_v4l_fd(), #r, r, p)
 
-std::string cap2s(unsigned cap);
 std::string buftype2s(int type);
 std::string fcc2s(unsigned int val);
 
diff --git a/utils/v4l2-compliance/v4l2-info.cpp 
b/utils/v4l2-compliance/v4l2-info.cpp
new file mode 120000
index 000000000000..c87caf75bbfd
--- /dev/null
+++ b/utils/v4l2-compliance/v4l2-info.cpp
@@ -0,0 +1 @@
+../common/v4l2-info.cpp
\ No newline at end of file
diff --git a/utils/v4l2-compliance/v4l2-info.h 
b/utils/v4l2-compliance/v4l2-info.h
new file mode 120000
index 000000000000..ecd1867b4183
--- /dev/null
+++ b/utils/v4l2-compliance/v4l2-info.h
@@ -0,0 +1 @@
+../common/v4l2-info.h
\ No newline at end of file
diff --git a/utils/v4l2-ctl/Makefile.am b/utils/v4l2-ctl/Makefile.am
index 819e35fcf051..5bddef746783 100644
--- a/utils/v4l2-ctl/Makefile.am
+++ b/utils/v4l2-ctl/Makefile.am
@@ -7,7 +7,7 @@ v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp 
v4l2-ctl-tuner.cp
        v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp 
v4l2-ctl-misc.cpp \
        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
+       media-info.cpp v4l2-info.cpp
 v4l2_ctl_CPPFLAGS = -I$(top_srcdir)/utils/common
 
 media-bus-format-names.h: ../../include/linux/media-bus-format.h
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 83408de306a8..a269297986b9 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -39,10 +39,11 @@
 
 #include <linux/media.h>
 
-#include <media-info.h>
-
 #include "v4l2-ctl.h"
 
+#include <v4l2-info.h>
+#include <media-info.h>
+
 #ifdef HAVE_SYS_KLOG_H
 #include <sys/klog.h>
 #endif
@@ -762,69 +763,6 @@ void print_video_formats(int fd, __u32 type)
        }
 }
 
-static std::string cap2s(unsigned cap)
-{
-       std::string s;
-
-       if (cap & V4L2_CAP_VIDEO_CAPTURE)
-               s += "\t\tVideo Capture\n";
-       if (cap & V4L2_CAP_VIDEO_CAPTURE_MPLANE)
-               s += "\t\tVideo Capture Multiplanar\n";
-       if (cap & V4L2_CAP_VIDEO_OUTPUT)
-               s += "\t\tVideo Output\n";
-       if (cap & V4L2_CAP_VIDEO_OUTPUT_MPLANE)
-               s += "\t\tVideo Output Multiplanar\n";
-       if (cap & V4L2_CAP_VIDEO_M2M)
-               s += "\t\tVideo Memory-to-Memory\n";
-       if (cap & V4L2_CAP_VIDEO_M2M_MPLANE)
-               s += "\t\tVideo Memory-to-Memory Multiplanar\n";
-       if (cap & V4L2_CAP_VIDEO_OVERLAY)
-               s += "\t\tVideo Overlay\n";
-       if (cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)
-               s += "\t\tVideo Output Overlay\n";
-       if (cap & V4L2_CAP_VBI_CAPTURE)
-               s += "\t\tVBI Capture\n";
-       if (cap & V4L2_CAP_VBI_OUTPUT)
-               s += "\t\tVBI Output\n";
-       if (cap & V4L2_CAP_SLICED_VBI_CAPTURE)
-               s += "\t\tSliced VBI Capture\n";
-       if (cap & V4L2_CAP_SLICED_VBI_OUTPUT)
-               s += "\t\tSliced VBI Output\n";
-       if (cap & V4L2_CAP_RDS_CAPTURE)
-               s += "\t\tRDS Capture\n";
-       if (cap & V4L2_CAP_RDS_OUTPUT)
-               s += "\t\tRDS Output\n";
-       if (cap & V4L2_CAP_SDR_CAPTURE)
-               s += "\t\tSDR Capture\n";
-       if (cap & V4L2_CAP_SDR_OUTPUT)
-               s += "\t\tSDR Output\n";
-       if (cap & V4L2_CAP_META_CAPTURE)
-               s += "\t\tMetadata Capture\n";
-       if (cap & V4L2_CAP_TUNER)
-               s += "\t\tTuner\n";
-       if (cap & V4L2_CAP_TOUCH)
-               s += "\t\tTouch Device\n";
-       if (cap & V4L2_CAP_HW_FREQ_SEEK)
-               s += "\t\tHW Frequency Seek\n";
-       if (cap & V4L2_CAP_MODULATOR)
-               s += "\t\tModulator\n";
-       if (cap & V4L2_CAP_AUDIO)
-               s += "\t\tAudio\n";
-       if (cap & V4L2_CAP_RADIO)
-               s += "\t\tRadio\n";
-       if (cap & V4L2_CAP_READWRITE)
-               s += "\t\tRead/Write\n";
-       if (cap & V4L2_CAP_ASYNCIO)
-               s += "\t\tAsync I/O\n";
-       if (cap & V4L2_CAP_STREAMING)
-               s += "\t\tStreaming\n";
-       if (cap & V4L2_CAP_EXT_PIX_FORMAT)
-               s += "\t\tExtended Pix Format\n";
-       if (cap & V4L2_CAP_DEVICE_CAPS)
-               s += "\t\tDevice Capabilities\n";
-       return s;
-}
-
 int parse_subopt(char **subs, const char * const *subopts, char **value)
 {
        int opt = getsubopt(subs, (char * const *)subopts, value);
@@ -1503,19 +1441,7 @@ int main(int argc, char **argv)
        if (!is_subdev && options[OptGetDriverInfo]) {
                printf("Driver Info%s:\n",
                                options[OptUseWrapper] ? " (using libv4l2)" : 
"");
-               printf("\tDriver name   : %s\n", vcap.driver);
-               printf("\tCard type     : %s\n", vcap.card);
-               printf("\tBus info      : %s\n", vcap.bus_info);
-               printf("\tDriver version: %d.%d.%d\n",
-                               vcap.version >> 16,
-                               (vcap.version >> 8) & 0xff,
-                               vcap.version & 0xff);
-               printf("\tCapabilities  : 0x%08X\n", vcap.capabilities);
-               printf("%s", cap2s(vcap.capabilities).c_str());
-               if (vcap.capabilities & V4L2_CAP_DEVICE_CAPS) {
-                       printf("\tDevice Caps   : 0x%08X\n", vcap.device_caps);
-                       printf("%s", cap2s(vcap.device_caps).c_str());
-               }
+               v4l2_info_capability(vcap);
        }
        if (options[OptGetDriverInfo] && media_fd >= 0)
                mi_media_info_for_fd(media_fd, fd);
diff --git a/utils/v4l2-ctl/v4l2-info.cpp b/utils/v4l2-ctl/v4l2-info.cpp
new file mode 120000
index 000000000000..c87caf75bbfd
--- /dev/null
+++ b/utils/v4l2-ctl/v4l2-info.cpp
@@ -0,0 +1 @@
+../common/v4l2-info.cpp
\ No newline at end of file
diff --git a/utils/v4l2-ctl/v4l2-info.h b/utils/v4l2-ctl/v4l2-info.h
new file mode 120000
index 000000000000..ecd1867b4183
--- /dev/null
+++ b/utils/v4l2-ctl/v4l2-info.h
@@ -0,0 +1 @@
+../common/v4l2-info.h
\ No newline at end of file

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to