libv4l: Import from oldpackages, upgrade to 1.2.1, fix build
authorTed Hess <thess@kitschensync.net>
Tue, 22 Jul 2014 19:23:25 +0000 (15:23 -0400)
committerTed Hess <thess@kitschensync.net>
Tue, 22 Jul 2014 19:23:25 +0000 (15:23 -0400)
    Update copyright, license info, add myself as pkg maintainer

Signed-off-by: Ted Hess <thess@kitschensync.net>
libs/libv4l/Makefile [new file with mode: 0644]
libs/libv4l/patches/001-no-shm_open-fix.patch [new file with mode: 0644]
libs/libv4l/patches/020-add-missing-includes.patch [new file with mode: 0644]

diff --git a/libs/libv4l/Makefile b/libs/libv4l/Makefile
new file mode 100644 (file)
index 0000000..25b67ed
--- /dev/null
@@ -0,0 +1,120 @@
+#
+# Copyright (C) 2009-2014 OpenWrt.org
+# Copyright (C) 2009 David Cooper <dave@kupesoft.com>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=v4l-utils
+PKG_VERSION:=1.2.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://www.linuxtv.org/downloads/v4l-utils
+PKG_MD5SUM:=4cc0fb4ded302ea9e89e5e1b56a7252b
+
+PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
+
+PKG_LICENSE:=GPL-2.0 LGPL-2.1
+PKG_LICENSE_FILE:=COPYING COPYING.libv4l
+
+PKG_BUILD_DEPENDS:=argp-standalone
+
+include $(INCLUDE_DIR)/uclibc++.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libv4l/Default
+  TITLE:=Video 4 Linux
+  URL:=http://www.linuxtv.org/
+endef
+
+define Package/libv4l/Default/description
+  libv4l is a collection of libraries which adds a thin abstraction layer on
+  top of video4linux2 devices. The purpose of this (thin) layer is to make it
+  easy for application writers to support a wide variety of devices without
+  having to write separate code for different devices in the same class. libv4l
+  consists of 3 different libraries: libv4lconvert, libv4l1 and libv4l2.
+
+  libv4l1 offers the (deprecated) v4l1 API on top of v4l2 devices, independent
+  of the drivers for those devices supporting v4l1 compatibility (which many
+  v4l2 drivers do not).
+
+  libv4l2 offers the v4l2 API on top of v4l2 devices, while adding for the
+  application transparent libv4lconvert conversion where necessary.
+endef
+
+define Package/libv4l
+  $(call Package/libv4l/Default)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE+= wrapper libraries
+  DEPENDS := +libpthread +librt
+endef
+
+define Package/libv4l/description
+  $(call Package/libv4l/Default/description)
+endef
+
+define Package/v4l-utils
+  $(call Package/libv4l/Default)
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE+= utilities
+  DEPENDS := +libv4l $(CXX_DEPENDS)
+endef
+
+define Package/v4l-utils/description
+  $(call Package/libv4l/Default/description)
+  This package contains the video4linux utilities.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+TARGET_LDFLAGS += -largp
+
+CONFIGURE_ARGS+= \
+       --disable-libdvbv5 \
+       --disable-qv4l2 \
+       --without-jpeg \
+
+define Build/Compile
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               DESTDIR="$(PKG_INSTALL_DIR)" \
+               all install
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               DESTDIR="$(PKG_INSTALL_DIR)" \
+               LINKTYPE="static" \
+               all install
+endef
+
+define Build/InstallDev
+       $(INSTALL_DIR) $(1)/usr/include
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libv4l{1,2,convert}.{a,so*} $(1)/usr/lib/
+       $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libv4l{1,2,convert}.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libv4l/install
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libv4l{1,2,convert}.so.* $(1)/usr/lib/
+       $(INSTALL_DIR) $(1)/usr/lib/libv4l
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libv4l/v4l{1compat,2convert}.so $(1)/usr/lib/libv4l/
+endef
+
+define Package/v4l-utils/install
+       $(INSTALL_DIR) $(1)/etc
+       $(CP) $(PKG_INSTALL_DIR)/etc/rc_maps.cfg $(1)/etc/
+       $(CP) $(PKG_INSTALL_DIR)/etc/rc_keymaps $(1)/etc/
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(CP) $(PKG_INSTALL_DIR)/usr/bin/{cx18,ivtv}-ctl $(1)/usr/bin/
+       $(CP) $(PKG_INSTALL_DIR)/usr/bin/decode_tm6000 $(1)/usr/bin/
+       $(CP) $(PKG_INSTALL_DIR)/usr/bin/ir-keytable $(1)/usr/bin/
+       $(CP) $(PKG_INSTALL_DIR)/usr/bin/v4l2-{compliance,ctl,sysfs-path} $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libv4l))
+$(eval $(call BuildPackage,v4l-utils))
diff --git a/libs/libv4l/patches/001-no-shm_open-fix.patch b/libs/libv4l/patches/001-no-shm_open-fix.patch
new file mode 100644 (file)
index 0000000..382f5c7
--- /dev/null
@@ -0,0 +1,57 @@
+--- a/lib/libv4lconvert/control/libv4lcontrol.c
++++ b/lib/libv4lconvert/control/libv4lcontrol.c
+@@ -570,7 +570,7 @@ static void v4lcontrol_get_flags_from_db
+ struct v4lcontrol_data *v4lcontrol_create(int fd, void *dev_ops_priv,
+       const struct libv4l_dev_ops *dev_ops, int always_needs_conversion)
+ {
+-      int shm_fd;
++      int shm_fd, fdflags;
+       int i, rc, got_usb_info, speed, init = 0;
+       char *s, shm_name[256], pwd_buf[1024];
+       struct v4l2_capability cap;
+@@ -695,33 +695,38 @@ struct v4lcontrol_data *v4lcontrol_creat
+       if (getpwuid_r(geteuid(), &pwd, pwd_buf, sizeof(pwd_buf), &pwd_p) == 0) {
+               if (got_usb_info)
+-                      snprintf(shm_name, 256, "/libv4l-%s:%s:%04x:%04x:%s", pwd.pw_name,
++                      snprintf(shm_name, 256, "/dev/shm/libv4l-%s:%s:%04x:%04x:%s", pwd.pw_name,
+                                       cap.bus_info, (int)vendor_id, (int)product_id, cap.card);
+               else
+-                      snprintf(shm_name, 256, "/libv4l-%s:%s:%s", pwd.pw_name,
++                      snprintf(shm_name, 256, "/dev/shm/libv4l-%s:%s:%s", pwd.pw_name,
+                                       cap.bus_info, cap.card);
+       } else {
+               perror("libv4lcontrol: error getting username using uid instead");
+               if (got_usb_info)
+-                      snprintf(shm_name, 256, "/libv4l-%lu:%s:%04x:%04x:%s",
++                      snprintf(shm_name, 256, "/dev/shm/libv4l-%lu:%s:%04x:%04x:%s",
+                                       (unsigned long)geteuid(), cap.bus_info,
+                                       (int)vendor_id, (int)product_id, cap.card);
+               else
+-                      snprintf(shm_name, 256, "/libv4l-%lu:%s:%s", (unsigned long)geteuid(),
++                      snprintf(shm_name, 256, "/dev/shm/libv4l-%lu:%s:%s", (unsigned long)geteuid(),
+                                       cap.bus_info, cap.card);
+       }
+       /* / is not allowed inside shm names */
+-      for (i = 1; shm_name[i]; i++)
++      for (i = 9; shm_name[i]; i++) /* start after "/dev/shm", i = 9 */
+               if (shm_name[i] == '/')
+                       shm_name[i] = '-';
+       /* Open the shared memory object identified by shm_name */
+-      shm_fd = shm_open(shm_name, (O_CREAT | O_EXCL | O_RDWR), (S_IREAD | S_IWRITE));
++      shm_fd = open(shm_name, (O_CREAT | O_EXCL | O_RDWR), (S_IREAD | S_IWRITE));
+       if (shm_fd >= 0)
+               init = 1;
+       else
+-              shm_fd = shm_open(shm_name, O_RDWR, (S_IREAD | S_IWRITE));
++              shm_fd = open(shm_name, O_RDWR, (S_IREAD | S_IWRITE));
++
++      /* This is all uClibc > 0.9.30 seems to do for shm_open() in librt/shm.c */
++      fdflags = fcntl(shm_fd, F_GETFD, 0);
++      if (fdflags >= 0)
++              fdflags = fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
+       if (shm_fd >= 0) {
+               /* Set the shared memory size */
diff --git a/libs/libv4l/patches/020-add-missing-includes.patch b/libs/libv4l/patches/020-add-missing-includes.patch
new file mode 100644 (file)
index 0000000..70107d3
--- /dev/null
@@ -0,0 +1,10 @@
+--- a/utils/rds-ctl/rds-ctl.cpp
++++ b/utils/rds-ctl/rds-ctl.cpp
+@@ -29,6 +29,7 @@
+ #include <inttypes.h>
+ #include <getopt.h>
+ #include <sys/types.h>
++#include <ctype.h>
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <sys/ioctl.h>