Initial commit of libv4l2 plugin for rockchip
BUG=chromium:405861
TEST=emerge-${BOARD} chromeos-v4lplugins-${BOARD} passed and install
libv4l-encplugin-rockchip.so
Change-Id: I1dae4aea876376720667f125e7d4a90767fef08b
Reviewed-on: https://chromium-review.googlesource.com/226470
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Pawel Osciak <posciak@chromium.org>
Commit-Queue: Heng-ruey Hsu <henryhsu@chromium.org>
Tested-by: Heng-ruey Hsu <henryhsu@chromium.org>
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..639c725
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+henryhsu@chromium.org
diff --git a/libv4l-rockchip/Makefile.am b/libv4l-rockchip/Makefile.am
new file mode 100644
index 0000000..dac5dcd
--- /dev/null
+++ b/libv4l-rockchip/Makefile.am
@@ -0,0 +1,12 @@
+# Copyright 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if WITH_V4L_PLUGINS
+libv4l2plugin_LTLIBRARIES = libv4l-encplugin-rockchip.la
+endif
+
+libv4l_encplugin_rockchip_la_SOURCES = libv4l-encplugin-rockchip.c
+libv4l_encplugin_rockchip_la_CPPFLAGS = $(CFLAG_VISIBILITY)
+libv4l_encplugin_rockchip_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
+libv4l_encplugin_rockchip_la_LIBADD = -lpthread
diff --git a/libv4l-rockchip/libv4l-encplugin-rockchip.c b/libv4l-rockchip/libv4l-encplugin-rockchip.c
new file mode 100644
index 0000000..a37cf33
--- /dev/null
+++ b/libv4l-rockchip/libv4l-encplugin-rockchip.c
@@ -0,0 +1,42 @@
+/* Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#include "libv4l-plugin.h"
+
+#define SYS_IOCTL(fd, cmd, arg) \
+ syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg))
+#define SYS_READ(fd, buf, len) \
+ syscall(SYS_read, (int)(fd), (void *)(buf), (size_t)(len));
+#define SYS_WRITE(fd, buf, len) \
+ syscall(SYS_write, (int)(fd), (const void *)(buf), (size_t)(len));
+
+#if HAVE_VISIBILITY
+#define PLUGIN_PUBLIC __attribute__ ((__visibility__("default")))
+#else
+#define PLUGIN_PUBLIC
+#endif
+
+static void *plugin_init(int fd)
+{
+ return NULL;
+}
+
+static void plugin_close(void *dev_ops_priv)
+{
+}
+
+static int plugin_ioctl(void *dev_ops_priv, int fd,
+ unsigned long int cmd, void *arg)
+{
+ return SYS_IOCTL(fd, cmd, arg);
+}
+
+PLUGIN_PUBLIC const struct libv4l_dev_ops libv4l2_plugin = {
+ .init = &plugin_init,
+ .close = &plugin_close,
+ .ioctl = &plugin_ioctl,
+};