[Buildroot] Building the Rockchip libv4l plugin

Baruch Siach baruch at tkos.co.il
Wed Jul 4 04:16:46 UTC 2018


Hi Peter,

On Tue, Jul 03, 2018 at 10:37:43PM +0200, Peter Seiderer wrote:
> On Tue, 3 Jul 2018 06:37:09 +0300, Baruch Siach <baruch at tkos.co.il> wrote:
> > On Mon, Jul 02, 2018 at 09:16:35PM +0200, Peter Seiderer wrote:
> > > On Mon, 2 Jul 2018 11:22:11 +0300, Baruch Siach <baruch at tkos.co.il> wrote:  
> > > > I'm trying to build the Rockchip libv4l2 plugin in Buildroot. The source 
> > > > is at
> > > > 
> > > >   https://chromium.googlesource.com/chromiumos/third_party/libv4lplugins/+/master/libv4l-rockchip_v2/
> > > > 
> > > > As upstream indicated[1], the code is meant to build as part of libv4l, not as 
> > > > a standalone library. ChromiumOS sees to copy the code into the libv4l source 
> > > > tree, and modify the relevant build configuration files[2].
> > > > 
> > > > What would be the best way to do that in Buildroot? A symlink to the plugin 
> > > > source tree? Copy of the code to libv4l?  
> > > 
> > > ...or add a configure.ac/configure file to the source?  
> > 
> > Unfortunately the plugin really needs internal libv4l headers, so this is not 
> > possible.
> 
> Something like the following (quick hack) patch, done the following first (should be added to libv4l):

Thanks for doing that. You can see my solution below. The libv4l patch fixes 
the build issue that you encountered. Not sure which solution is cleaner. The 
libv4l patch looks problematic, unless we apply it conditionally. Not good.

I'm not sure I'll continue pursuing this path. Upstream response[1] means that 
some non trivial kernel change are required to make it work with anything 
other than ChromeOS kernels.

baruch

[1] http://lists.infradead.org/pipermail/linux-rockchip/2018-July/021133.html

>From f1bd7d3fe5341d29749d89d71c506d404eb0d541 Mon Sep 17 00:00:00 2001
From: Baruch Siach <baruch at tkos.co.il>
Date: Tue, 3 Jul 2018 06:46:49 +0300
Subject: [PATCH] WIP: rockchip-libv4lplugin: new package

The libv4l part should split out of this patch.

Signed-off-by: Baruch Siach <baruch at tkos.co.il>
---
 package/Config.in                             |  1 +
 package/libv4l/0005-fix-rockchip.patch        | 43 +++++++++++++++++++
 package/libv4l/libv4l.mk                      | 12 ++++++
 package/rockchip-libv4lplugin/Config.in       | 10 +++++
 .../rockchip-libv4lplugin.mk                  | 11 +++++
 5 files changed, 77 insertions(+)
 create mode 100644 package/libv4l/0005-fix-rockchip.patch
 create mode 100644 package/rockchip-libv4lplugin/Config.in
 create mode 100644 package/rockchip-libv4lplugin/rockchip-libv4lplugin.mk

diff --git a/package/Config.in b/package/Config.in
index e94a6a8c12c4..db1f1b4eb21a 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1377,6 +1377,7 @@ menu "Multimedia"
 	source "package/libyuv/Config.in"
 	source "package/live555/Config.in"
 	source "package/mediastreamer/Config.in"
+	source "package/rockchip-libv4lplugin/Config.in"
 	source "package/x264/Config.in"
 	source "package/x265/Config.in"
 endmenu
diff --git a/package/libv4l/0005-fix-rockchip.patch b/package/libv4l/0005-fix-rockchip.patch
new file mode 100644
index 000000000000..ef2da5a97aaf
--- /dev/null
+++ b/package/libv4l/0005-fix-rockchip.patch
@@ -0,0 +1,43 @@
+diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
+index 489433edd3d1..a6fc1f290e28 100644
+--- a/include/linux/videodev2.h
++++ b/include/linux/videodev2.h
+@@ -921,7 +921,7 @@ struct v4l2_buffer {
+ 		__s32		fd;
+ 	} m;
+ 	__u32			length;
+-	__u32			reserved2;
++	__u32			config_store;
+ 	__u32			reserved;
+ };
+ 
+@@ -1575,6 +1575,7 @@ struct v4l2_ext_controls {
+ 	union {
+ 		__u32 ctrl_class;
+ 		__u32 which;
++		__u32 config_store;
+ 	};
+ 	__u32 count;
+ 	__u32 error_idx;
+diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
+index 2db25d1c76c9..7904c9e4e44a 100644
+--- a/lib/libv4l2/libv4l2.c
++++ b/lib/libv4l2/libv4l2.c
+@@ -190,7 +190,7 @@ static int v4l2_map_buffers(int index)
+ 		buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ 		buf.memory = V4L2_MEMORY_MMAP;
+ 		buf.index = i;
+-		buf.reserved = buf.reserved2 = 0;
++		buf.reserved = 0;
+ 		result = devices[index].dev_ops->ioctl(
+ 				devices[index].dev_ops_priv,
+ 				devices[index].fd, VIDIOC_QUERYBUF, &buf);
+@@ -579,7 +579,7 @@ static int v4l2_buffers_mapped(int index)
+ 			buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ 			buf.memory = V4L2_MEMORY_MMAP;
+ 			buf.index = i;
+-			buf.reserved = buf.reserved2 = 0;
++			buf.reserved = 0;
+ 			if (devices[index].dev_ops->ioctl(
+ 					devices[index].dev_ops_priv,
+ 					devices[index].fd, VIDIOC_QUERYBUF,
diff --git a/package/libv4l/libv4l.mk b/package/libv4l/libv4l.mk
index 55f02b7e8e4c..d63bf09f6246 100644
--- a/package/libv4l/libv4l.mk
+++ b/package/libv4l/libv4l.mk
@@ -52,6 +52,18 @@ ifeq ($(BR2_PACKAGE_LIBGLU),y)
 LIBV4L_DEPENDENCIES += libglu
 endif
 
+ifeq ($(BR2_PACKAGE_ROCKCHIP_LIBV4LPLUGIN),y)
+LIBV4L_DEPENDENCIES += rockchip-libv4lplugin
+# Modify Makefile.am and configure.ac
+LIBV4L_AUTORECONF = YES
+define LIBV4L_ROCKCHIP_LIBV4LPLUGIN_INTEGRATE
+	cp -a $(ROCKCHIP_LIBV4LPLUGIN_DIR)/libv4l-rockchip_v2 $(@D)/lib/
+	echo 'SUBDIRS += libv4l-rockchip_v2' >> $(@D)/lib/Makefile.am
+	$(SED) 's%libv4l2rds/Makefile%&\n\tlib/libv4l-rockchip_v2/Makefile%' $(@D)/configure.ac
+endef
+LIBV4L_POST_PATCH_HOOKS += LIBV4L_ROCKCHIP_LIBV4LPLUGIN_INTEGRATE
+endif
+
 ifeq ($(BR2_PACKAGE_LIBV4L_UTILS),y)
 LIBV4L_CONF_OPTS += --enable-v4l-utils
 LIBV4L_DEPENDENCIES += $(TARGET_NLS_DEPENDENCIES)
diff --git a/package/rockchip-libv4lplugin/Config.in b/package/rockchip-libv4lplugin/Config.in
new file mode 100644
index 000000000000..d604787deef3
--- /dev/null
+++ b/package/rockchip-libv4lplugin/Config.in
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_ROCKCHIP_LIBV4LPLUGIN
+	bool "rockchip-libv4lplugin"
+	depends on !BR2_STATIC_LIBS
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	help
+	  libv4l plugin for the Rockchip RK3288 and RK3399 SoC. For use with the
+	  rockchip-vpu driver for the video encoder/decoder.
+
+comment "rockchip-libv4lplugin needs a toolchain w/ dynamic library, threads"
+	depends on BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/rockchip-libv4lplugin/rockchip-libv4lplugin.mk b/package/rockchip-libv4lplugin/rockchip-libv4lplugin.mk
new file mode 100644
index 000000000000..2ef030d6a2f8
--- /dev/null
+++ b/package/rockchip-libv4lplugin/rockchip-libv4lplugin.mk
@@ -0,0 +1,11 @@
+################################################################################
+#
+# rockchip-libv4lplugin
+#
+################################################################################
+
+ROCKCHIP_LIBV4LPLUGIN_VERSION = 5e6034258146af6be973fb6a5bb6b9d6e7489437
+ROCKCHIP_LIBV4LPLUGIN_SITE = https://chromium.googlesource.com/chromiumos/third_party/libv4lplugins
+ROCKCHIP_LIBV4LPLUGIN_SITE_METHOD = git
+
+$(eval $(generic-package))

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -


More information about the buildroot mailing list