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

Subject: v4l2-compliance/ctl: drop libv4l2 dependency if NO_LIBV4L2 is defined
Author:  Hans-Christian Egtvedt <hegtv...@cisco.com>
Date:    Fri Apr 11 16:26:26 2014 +0200

This patch introduces a check for a NO_LIBV4L2 symbol in v4l2-compliance
and v4l2-ctl, which, when defined, will let the utility be built without
linking with libv4l2.

The wrapper functionality libv4l2 provides is obviously lost when
building with NO_LIBV4L2 defined.

Signed-off-by: Hans-Christian Egtvedt <hegtv...@cisco.com>
[hans.verk...@cisco.com: modified to reduce number of #ifdefs]
Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>

 utils/v4l2-compliance/v4l2-compliance.cpp   |    4 ++++
 utils/v4l2-compliance/v4l2-compliance.h     |   22 ++++++++++++++++++++++
 utils/v4l2-compliance/v4l2-test-buffers.cpp |    4 ++--
 utils/v4l2-ctl/v4l2-ctl-common.cpp          |    3 ++-
 utils/v4l2-ctl/v4l2-ctl-streaming.cpp       |    2 +-
 utils/v4l2-ctl/v4l2-ctl.cpp                 |    3 ++-
 utils/v4l2-ctl/v4l2-ctl.h                   |   10 ++++++++++
 7 files changed, 43 insertions(+), 5 deletions(-)

---

http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=bb28f870e062b2dcafa694c81b39cd467fb2626a

diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp 
b/utils/v4l2-compliance/v4l2-compliance.cpp
index 8c40fd6..0d23ae9 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -87,7 +87,9 @@ static struct option long_options[] = {
        {"verbose", no_argument, 0, OptVerbose},
        {"no-warnings", no_argument, 0, OptNoWarnings},
        {"trace", no_argument, 0, OptTrace},
+#ifndef NO_LIBV4L2
        {"wrapper", no_argument, 0, OptUseWrapper},
+#endif
        {"set-input", required_argument, 0, OptSetInput},
        {"set-output", required_argument, 0, OptSetOutput},
        {"set-freq", required_argument, 0, OptSetFreq},
@@ -121,7 +123,9 @@ static void usage(void)
        printf("  -n, --no-warnings  turn off warning messages.\n");
        printf("  -T, --trace        trace all called ioctls.\n");
        printf("  -v, --verbose      turn on verbose reporting.\n");
+#ifndef NO_LIBV4L2
        printf("  -w, --wrapper      use the libv4l2 wrapper library.\n");
+#endif
        exit(0);
 }
 
diff --git a/utils/v4l2-compliance/v4l2-compliance.h 
b/utils/v4l2-compliance/v4l2-compliance.h
index f2f7072..72393b4 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -27,7 +27,19 @@
 #include <list>
 #include <set>
 #include <linux/videodev2.h>
+
+#ifndef NO_LIBV4L2
 #include <libv4l2.h>
+#else
+#define v4l2_open(file, oflag, ...) (-1)
+#define v4l2_close(fd) (-1)
+#define v4l2_read(fd, buffer, n) (-1)
+#define v4l2_write(fd, buffer, n) (-1)
+#define v4l2_ioctl(fd, request, ...) (-1)
+#define v4l2_mmap(start, length, prot, flags, fd, offset) (MAP_FAILED)
+#define v4l2_munmap(_start, length) (-1)
+#endif
+
 #include <cv4l-helpers.h>
 
 #if !defined(ENODATA) && (defined(__FreeBSD__) || defined(__FreeBSD_kernel__))
@@ -125,6 +137,16 @@ static inline void reopen(struct node *node)
        }
 }
 
+static inline ssize_t test_read(int fd, void *buffer, size_t n)
+{
+       return wrapper ? v4l2_read(fd, buffer, n) : read(fd, buffer, n);
+}
+
+static inline ssize_t test_write(int fd, const void *buffer, size_t n)
+{
+       return wrapper ? v4l2_write(fd, buffer, n) : write(fd, buffer, n);
+}
+
 static inline int test_ioctl(int fd, unsigned long cmd, ...)
 {
        void *arg;
diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp 
b/utils/v4l2-compliance/v4l2-test-buffers.cpp
index 3ea5fd1..c509a88 100644
--- a/utils/v4l2-compliance/v4l2-test-buffers.cpp
+++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp
@@ -453,9 +453,9 @@ int testReqBufs(struct node *node)
                        char buf = 0;
 
                        if (node->can_capture)
-                               ret = read(node->vfd.fd, &buf, 1);
+                               ret = test_read(node->vfd.fd, &buf, 1);
                        else
-                               ret = write(node->vfd.fd, &buf, 1);
+                               ret = test_write(node->vfd.fd, &buf, 1);
                        if (ret != -1)
                                return fail("Expected -1, got %d\n", ret);
                        if (errno != EBUSY)
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp 
b/utils/v4l2-ctl/v4l2-ctl-common.cpp
index 8d7c7a2..5dafd91 100644
--- a/utils/v4l2-ctl/v4l2-ctl-common.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp
@@ -20,7 +20,6 @@
 #endif
 
 #include <linux/videodev2.h>
-#include <libv4l2.h>
 
 #include <list>
 #include <vector>
@@ -80,7 +79,9 @@ void common_usage(void)
               "  -l, --list-ctrls   display all controls and their values 
[VIDIOC_QUERYCTRL]\n"
               "  -L, --list-ctrls-menus\n"
               "                     display all controls and their menus 
[VIDIOC_QUERYMENU]\n"
+#ifndef NO_LIBV4L2
               "  -w, --wrapper      use the libv4l2 wrapper library.\n"
+#endif
               "  --list-devices     list all v4l devices\n"
               "  --log-status       log the board status in the kernel log 
[VIDIOC_LOG_STATUS]\n"
               "  --get-priority     query the current access priority 
[VIDIOC_G_PRIORITY]\n"
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp 
b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index cf063e6..656e132 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -17,7 +17,7 @@
 #include <config.h>
 
 #include <linux/videodev2.h>
-#include <libv4l2.h>
+
 #include <string>
 
 #include "v4l2-ctl.h"
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index a5fe2a8..d5dd82a 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -42,7 +42,6 @@
 #endif
 
 #include <linux/videodev2.h>
-#include <libv4l2.h>
 
 #include <list>
 #include <vector>
@@ -90,7 +89,9 @@ static struct option long_options[] = {
        {"help-streaming", no_argument, 0, OptHelpStreaming},
        {"help-edid", no_argument, 0, OptHelpEdid},
        {"help-all", no_argument, 0, OptHelpAll},
+#ifndef NO_LIBV4L2
        {"wrapper", no_argument, 0, OptUseWrapper},
+#endif
        {"concise", no_argument, 0, OptConcise},
        {"get-output", no_argument, 0, OptGetOutput},
        {"set-output", required_argument, 0, OptSetOutput},
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index a2cc35d..4b188d9 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -1,6 +1,16 @@
 #ifndef _V4L2_CTL_H
 #define _V4L2_CTL_H
 
+#ifndef NO_LIBV4L2
+#include <libv4l2.h>
+#else
+#define v4l2_open(file, oflag, ...) (-1)
+#define v4l2_close(fd) (-1)
+#define v4l2_ioctl(fd, request, ...) (-1)
+#define v4l2_mmap(start, length, prot, flags, fd, offset) (MAP_FAILED)
+#define v4l2_munmap(_start, length) (-1)
+#endif
+
 /* Available options.
 
    Please keep the first part (options < 128) in alphabetical order.

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

Reply via email to