libv4l: add an option for IR BPF based decoders
PATCH v2 1/1 libv4l: add an option for IR BPF based decoders
Bump to version 1.61.1 added BPF based protocols support:
https://git.linuxtv.org/v4l-utils.git/commit/?id=d6025b0e8c7f57b0f9390f987acc5eed57360d80
However, this dependency needs BPF support in kernel. On old kernels (before 3.18), __NR_BPF is not defined for all architectures. So retrieve upstream patch and add an option to enable BPF only if headers are above 3.18.
Also drop patch to add bpf_common.h on old kernels (not needed anymore)
Fixes:
- http://autobuild.buildroot.org/results/442de57cb76a7b38d71d690490faadc641036374
---
Changes v1 -> v2 (after review of Peter Seiderer):
- Add an option to enable BPF if headers >= 3.18 instead of disabling it as it seems that risc-v support BPF
- Drop patch to add bpf_common.h
...d-without-BPF-support-in-ir-keytable.patch | 124 ++++++++++++++++++ .../0005-Add-missing-linux-bpf_common.h.patch | 80 ----------- package/libv4l/Config.in | 15 +++ package/libv4l/libv4l.mk | 7 + 4 files changed, 146 insertions(+), 80 deletions(-) create mode 100644 package/libv4l/0004-configure-build-without-BPF-support-in-ir-keytable.patch delete mode 100644 package/libv4l/0005-Add-missing-linux-bpf_common.h.patch
package/libv4l/0004-configure-build-without-BPF-support-in-ir-keytable.patch new file +124 -0
@@ -0,0 +1,124 @@ +From 5c213ee065ebd7a388f153a402851be8dfcfc960 Mon Sep 17 00:00:00 2001 +From: Sean Young <[email protected]> +Date: Tue, 6 Nov 2018 09:58:32 +0000 +Subject: configure: build without BPF support in ir-keytable + +It currently does not build on mips and some platforms do not have +BPF support yet (risc-v, for example). + +Signed-off-by: Sean Young <[email protected]> +Signed-off-by: Fabrice Fontaine <[email protected]> +[Retrieved from: +https://git.linuxtv.org/v4l-utils.git/commit/configure.ac?id=5c213ee065ebd7a388f153a402851be8dfcfc960] + +diff --git a/configure.ac b/configure.ac +index 387f853..5cc34c2 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -173,16 +173,12 @@ AM_CONDITIONAL([HAVE_X11], [test x$x11_pkgconfig = xyes]) + PKG_CHECK_MODULES([LIBELF], [libelf], [libelf_pkgconfig=yes], [libelf_pkgconfig=no]) + AC_SUBST([LIBELF_CFLAGS]) + AC_SUBST([LIBELF_LIBS]) +-AM_CONDITIONAL([HAVE_LIBELF], [test x$libelf_pkgconfig = xyes]) + if test "x$libelf_pkgconfig" = "xyes"; then + AC_CHECK_PROG([CLANG], clang, clang) +- AC_DEFINE([HAVE_LIBELF], [1], [libelf library is present]) + else + AC_MSG_WARN(libelf library not available) + fi + +-AM_CONDITIONAL([BPF_PROTOCOLS], [test x$CLANG = xclang]) +- + AS_IF([test "x$x11_pkgconfig" = xyes], + [PKG_CHECK_MODULES(GL, [gl], [gl_pkgconfig=yes], [gl_pkgconfig=no])], [gl_pkgconfig=no]) + AC_SUBST([GL_CFLAGS]) +@@ -453,6 +449,14 @@ AC_ARG_ENABLE(gconv, + esac] + ) + ++AC_ARG_ENABLE(bpf, ++ AS_HELP_STRING([--disable-bpf], [disable IR BPF decoders]), ++ [case "${enableval}" in ++ yes | no ) ;; ++ *) AC_MSG_ERROR(bad value ${enableval} for --enable-bpf) ;; ++ esac] ++) ++ + PKG_CHECK_MODULES([SDL2], [sdl2 SDL2_image], [sdl_pc=yes], [sdl_pc=no]) + AM_CONDITIONAL([HAVE_SDL], [test x$sdl_pc = xyes]) + +@@ -475,6 +479,7 @@ AM_CONDITIONAL([WITH_GCONV], [test x$enable_gconv = xyes -a x$enable_shar + AM_CONDITIONAL([WITH_V4L2_CTL_LIBV4L], [test x${enable_v4l2_ctl_libv4l} != xno]) + AM_CONDITIONAL([WITH_V4L2_CTL_STREAM_TO], [test x${enable_v4l2_ctl_stream_to} != xno]) + AM_CONDITIONAL([WITH_V4L2_COMPLIANCE_LIBV4L], [test x${enable_v4l2_compliance_libv4l} != xno]) ++AM_CONDITIONAL([WITH_BPF], [test x$enable_bpf != xno -a x$libelf_pkgconfig = xyes -a x$CLANG = xclang]) + + # append -static to libtool compile and link command to enforce static libs + AS_IF([test x$enable_libdvbv5 = xno], [AC_SUBST([ENFORCE_LIBDVBV5_STATIC], ["-static"])]) +@@ -505,6 +510,9 @@ AM_COND_IF([WITH_V4L_WRAPPERS], [USE_V4L_WRAPPERS="yes"], [USE_V4L_WRAPPERS="no" + AM_COND_IF([WITH_GCONV], [USE_GCONV="yes"], [USE_GCONV="no"]) + AM_COND_IF([WITH_V4L2_CTL_LIBV4L], [USE_V4L2_CTL_LIBV4L="yes"], [USE_V4L2_CTL_LIBV4L="no"]) + AM_COND_IF([WITH_V4L2_COMPLIANCE_LIBV4L], [USE_V4L2_COMPLIANCE_LIBV4L="yes"], [USE_V4L2_COMPLIANCE_LIBV4L="no"]) ++AM_COND_IF([WITH_BPF], [USE_BPF="yes" ++ AC_DEFINE([HAVE_BPF], [1], [BPF IR decoder support enabled])], ++ [USE_BPF="no"]) + AS_IF([test "x$alsa_pkgconfig" = "xtrue"], [USE_ALSA="yes"], [USE_ALSA="no"]) + + AC_OUTPUT +@@ -549,4 +557,5 @@ compile time options summary + qvidcap : $USE_QVIDCAP + v4l2-ctl uses libv4l : $USE_V4L2_CTL_LIBV4L + v4l2-compliance uses libv4l: $USE_V4L2_COMPLIANCE_LIBV4L ++ BPF IR Decoders: : $USE_BPF + EOF +diff --git a/utils/keytable/Makefile.am b/utils/keytable/Makefile.am +index 90e4c8c..ddbab0f 100644 +--- a/utils/keytable/Makefile.am ++++ b/utils/keytable/Makefile.am +@@ -6,14 +6,15 @@ udevrules_DATA = 70-infrared.rules + + ir_keytable_SOURCES = keytable.c parse.h ir-encode.c ir-encode.h toml.c toml.h + +-if HAVE_LIBELF ++if WITH_BPF + ir_keytable_SOURCES += bpf.c bpf_load.c bpf.h bpf_load.h + endif + + ir_keytable_LDADD = @LIBINTL@ +-ir_keytable_LDFLAGS = $(ARGP_LIBS) $(LIBELF_LIBS) ++ir_keytable_LDFLAGS = $(ARGP_LIBS) + +-if BPF_PROTOCOLS ++if WITH_BPF ++ir_keytable_LDFLAGS += $(LIBELF_LIBS) + SUBDIRS = bpf_protocols + endif + +diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c +index a7ed436..6fc2235 100644 +--- a/utils/keytable/keytable.c ++++ b/utils/keytable/keytable.c +@@ -34,8 +34,11 @@ + #include "ir-encode.h" + #include "parse.h" + #include "toml.h" ++ ++#ifdef HAVE_BPF + #include "bpf.h" + #include "bpf_load.h" ++#endif + + #ifdef ENABLE_NLS + # define _(string) gettext(string) +@@ -1847,7 +1850,7 @@ static void device_info(int fd, char *prepend) + perror ("EVIOCGID"); + } + +-#ifdef HAVE_LIBELF ++#ifdef HAVE_BPF + #define MAX_PROGS 64 + static void attach_bpf(const char *lirc_name, const char *bpf_prog, struct toml_table_t *toml) + { +-- +cgit v0.10.2 +
package/libv4l/0005-Add-missing-linux-bpf_common.h.patch deleted +0 -80
80 lines not on this page · raw message
package/libv4l/Config.in +15 -0
@@ -35,6 +35,21 @@ config BR2_PACKAGE_LIBV4L_UTILS - rds-ctl - qv4l2 (if Qt is enabled) +config BR2_PACKAGE_LIBV4L_UTILS_IR_BPF_BASED_DECODERS + bool "IR BPF based decoders" + depends on BR2_PACKAGE_LIBV4L_UTILS + depends on BR2_USE_WCHAR # elfutils + depends on !BR2_STATIC_LIBS # elfutils + depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC # elfutils + depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_18 + select BR2_PACKAGE_ELFUTILS + +comment "IR BPF based decoders needs a uclibc or glibc toolchain w/ dynamic library, wchar, headers >= 3.18" + depends on BR2_PACKAGE_LIBV4L_UTILS + depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS \ + || !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC) \ + || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_18 + endif comment "libv4l needs a toolchain w/ threads, C++ and headers >= 3.0"
package/libv4l/libv4l.mk +7 -0
@@ -56,8 +56,15 @@ ifeq ($(BR2_PACKAGE_LIBV4L_UTILS),y) LIBV4L_CONF_OPTS += --enable-v4l-utils LIBV4L_DEPENDENCIES += $(TARGET_NLS_DEPENDENCIES) +ifeq ($(BR2_PACKAGE_LIBV4L_UTILS_IR_BPF_BASED_DECODERS),y) +LIBV4L_CONF_OPTS += --enable-bpf +LIBV4L_DEPENDENCIES += elfutils + # Disable clang that is used to build BPF (in-kernel bytecode machine) protocols LIBV4L_CONF_ENV += ac_cv_prog_CLANG="" +else +LIBV4L_CONF_OPTS += --disable-bpf +endif ifeq ($(BR2_PACKAGE_QT5BASE)$(BR2_PACKAGE_QT5BASE_GUI)$(BR2_PACKAGE_QT5BASE_WIDGETS),yyy) LIBV4L_CONF_OPTS += --enable-qv4l2
Signature · 1 line
2.17.1
PATCH v2 1/1 libv4l: add an option for IR BPF based decoders
Hello,
Quoted 8 lines · Fabrice Fontaine
Bump to version 1.61.1 added BPF based protocols support:
https://git.linuxtv.org/v4l-utils.git/commit/?id=d6025b0e8c7f57b0f9390f987acc5eed57360d80However, this dependency needs BPF support in kernel. On old kernels (before 3.18),
__NR_BPFis not defined for all architectures. So retrieve upstream patch and add an option to enable BPF only if headers are above 3.18.
Quoted 6 lines
Also drop patch to add
bpf_common.hon old kernels (not needed anymore)Fixes:
- http://autobuild.buildroot.org/results/442de57cb76a7b38d71d690490faadc641036374Signed-off-by Fabrice Fontaine <[email protected]>
Thanks for working on this!
package/libv4l/libv4l.mk ifeq ($(BR2_PACKAGE_LIBV4L_UTILS),y) · line 64
Quoted 6 lines
package/libv4l/libv4l.mk +4
-0+ifeq ($(BR2_PACKAGE_LIBV4L_UTILS_IR_BPF_BASED_DECODERS),y) +LIBV4L_CONF_OPTS += --enable-bpf +LIBV4L_DEPENDENCIES += elfutils + # Disable clang that is used to build BPF (in-kernel bytecode machine) protocols LIBV4L_CONF_ENV += ac_cv_prog_CLANG=""
So without clang, how are BPF protocols being built ?
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 1/1 libv4l: add an option for IR BPF based decoders
Hello Fabrice,
Quoted 21 lines · Thomas Petazzoni
Hello,
Quoted 8 lines · Fabrice Fontaine
Bump to version 1.61.1 added BPF based protocols support:
https://git.linuxtv.org/v4l-utils.git/commit/?id=d6025b0e8c7f57b0f9390f987acc5eed57360d80However, this dependency needs BPF support in kernel. On old kernels (before 3.18),
__NR_BPFis not defined for all architectures. So retrieve upstream patch and add an option to enable BPF only if headers are above 3.18.Quoted 6 lines
Also drop patch to add
bpf_common.hon old kernels (not needed anymore)Fixes:
- http://autobuild.buildroot.org/results/442de57cb76a7b38d71d690490faadc641036374Signed-off-by Fabrice Fontaine <[email protected]>Thanks for working on this!
Quoted 8 lines
package/libv4l/libv4l.mk ifeq ($(BR2_PACKAGE_LIBV4L_UTILS),y) · line 64
Quoted 6 lines
package/libv4l/libv4l.mk +4
-0+ifeq ($(BR2_PACKAGE_LIBV4L_UTILS_IR_BPF_BASED_DECODERS),y) +LIBV4L_CONF_OPTS += --enable-bpf +LIBV4L_DEPENDENCIES += elfutils + # Disable clang that is used to build BPF (in-kernel bytecode machine) protocols LIBV4L_CONF_ENV += ac_cv_prog_CLANG=""So without clang, how are BPF protocols being built ?
Or split the patch into first disabling bpf support unconditionally, and second enabling bpf (with or without clang support)...and I think it is a matter of taste if bpf support without the clang generated files is justifiable (maybe special bpf files could be provided from external source etc.)....
Regards,
Peter
Quoted 4 lines
Best regards,
Thomas
PATCH v2 1/1 libv4l: add an option for IR BPF based decoders
In reply to Fabrice FontaineHi Fabrice,
Quoted 8 lines · Fabrice Fontaine
Bump to version 1.61.1 added BPF based protocols support:
https://git.linuxtv.org/v4l-utils.git/commit/?id=d6025b0e8c7f57b0f9390f987acc5eed57360d80However, this dependency needs BPF support in kernel. On old kernels (before 3.18),
__NR_BPFis not defined for all architectures. So retrieve upstream patch and add an option to enable BPF only if headers are above 3.18.
Quoted 4 lines
Also drop patch to add
bpf_common.hon old kernels (not needed anymore)Fixes:
- http://autobuild.buildroot.org/results/442de57cb76a7b38d71d690490faadc641036374
This problem apparently went away with the bump to 1.16.2 (without needing to
give the --disable-bpf config argument) so I've marked this patch as Superseded.
Please respin if you think it is still needed.
Regards,
Arnout