[packages] Add the libv4l package which adds a generally uniform abstraction layer...
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 14 Sep 2009 17:04:34 +0000 (17:04 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 14 Sep 2009 17:04:34 +0000 (17:04 +0000)
SVN-Revision: 17584

libs/libv4l/Makefile [new file with mode: 0644]
libs/libv4l/patches/001-no-shm_open-fix.patch [new file with mode: 0644]

diff --git a/libs/libv4l/Makefile b/libs/libv4l/Makefile
new file mode 100644 (file)
index 0000000..454aa41
--- /dev/null
@@ -0,0 +1,75 @@
+# 
+# Copyright (C) 2009 David Cooper <dave@kupesoft.com>
+# Copyright (C) 2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libv4l
+PKG_VERSION:=0.6.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://people.atrpms.net/~hdegoede/
+PKG_MD5SUM:=db389fdf02cabd57f289f0faa37f4060
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libv4l
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Video 4 Linux wrapper libraries
+  URL:=http://people.atrpms.net/~hdegoede/
+  DEPENDS:=+libpthread
+endef
+
+define Package/libv4l/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
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Compile
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               DESTDIR="$(PKG_INSTALL_DIR)" PREFIX="/usr" \
+               $(CONFIGURE_VARS) \
+               all install
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               DESTDIR="$(PKG_INSTALL_DIR)" PREFIX="/usr" \
+               $(CONFIGURE_VARS) \
+               LINKTYPE="static" \
+               all install
+endef
+
+define Build/InstallDev
+       mkdir -p $(1)/usr/include
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/libv4l{1,2,convert}.h $(1)/usr/include/
+       mkdir -p $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libv4l{1,2,convert}.{a,so*} $(1)/usr/lib/
+       mkdir -p $(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
+
+$(eval $(call BuildPackage,libv4l))
+
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..816626e
--- /dev/null
@@ -0,0 +1,43 @@
+diff -ruN libv4l-0.6.0.orig/libv4lconvert/control/libv4lcontrol.c libv4l-0.6.0/libv4lconvert/control/libv4lcontrol.c
+--- libv4l-0.6.0.orig/libv4lconvert/control/libv4lcontrol.c    2009-07-09 04:59:01.000000000 -0400
++++ libv4l-0.6.0/libv4lconvert/control/libv4lcontrol.c 2009-08-29 03:23:06.000000000 -0400
+@@ -265,7 +265,7 @@
+ struct v4lcontrol_data *v4lcontrol_create(int fd, int always_needs_conversion)
+ {
+-  int shm_fd;
++  int shm_fd, fdflags;
+   int i, rc, init = 0;
+   char *s, shm_name[256];
+   struct v4l2_capability cap;
+@@ -311,19 +311,26 @@
+     return data; /* No need to create a shared memory segment */
+   SYS_IOCTL(fd, VIDIOC_QUERYCAP, &cap);
+-  snprintf(shm_name, 256, "/%s:%s", cap.bus_info, cap.card);
++  snprintf(shm_name, 256, "/dev/shm/%s:%s", 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 */
+-  if ((shm_fd = shm_open(shm_name, (O_CREAT | O_EXCL | O_RDWR),
++  if ((shm_fd = open(shm_name, (O_CREAT | O_EXCL | O_RDWR),
+                        (S_IREAD | S_IWRITE))) >= 0)
+     init = 1;
+-  else if ((shm_fd = shm_open(shm_name, O_RDWR, (S_IREAD | S_IWRITE))) < 0)
++  else if ((shm_fd = open(shm_name, O_RDWR, (S_IREAD | S_IWRITE))) < 0)
+     goto error;
++  
++  /* 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);
++  }
+   /* Set the shared memory size */
+   ftruncate(shm_fd, V4LCONTROL_SHM_SIZE);