meta-raspberrypi: subtree update:39cf54c3cb..a6f1233d52

Jon Magnuson (1):
      packagegroup-rpi-test: resolve `wireless-regdb` conflict

Khem Raj (1):
      linux-raspberrypi_5.4.bb: Upgrade to 5.4.47

Leon Anavi (7):
      lirc_%.bbappend: Fix for gpio-ir
      lirc: Move to dynamic-layers
      rpi-config: Add ENABLE_IR variable for infrared
      rpi-base.inc: Include modules if IR is enabled
      lirc_%.bbappend: Use lircd.service as in Raspbian
      docs/extra-build-config.md: Infrared
      lirc: Rename bbappend to match only version 0.10.1

M. ter Woord (1):
      Update layer-contents.md to include pi4

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I6f20c20dec1dd2fdab9e4e52dea1cdd54be4fffc
diff --git a/meta-raspberrypi/conf/machine/include/rpi-base.inc b/meta-raspberrypi/conf/machine/include/rpi-base.inc
index a8ede4c..044f09d 100644
--- a/meta-raspberrypi/conf/machine/include/rpi-base.inc
+++ b/meta-raspberrypi/conf/machine/include/rpi-base.inc
@@ -80,6 +80,7 @@
 
 MACHINE_EXTRA_RRECOMMENDS += "kernel-modules udev-rules-rpi"
 MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "${@oe.utils.conditional('ENABLE_I2C', '1', 'kernel-module-i2c-dev kernel-module-i2c-bcm2708', '', d)}"
+MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "${@oe.utils.conditional('ENABLE_IR', '1', 'kernel-module-gpio-ir kernel-module-gpio-ir-tx', '', d)}"
 
 
 # Set Raspberrypi splash image
diff --git a/meta-raspberrypi/docs/extra-build-config.md b/meta-raspberrypi/docs/extra-build-config.md
index 843247a..d92cf4e 100644
--- a/meta-raspberrypi/docs/extra-build-config.md
+++ b/meta-raspberrypi/docs/extra-build-config.md
@@ -261,6 +261,18 @@
 
 See: <http://skpang.co.uk/catalog/pican2-canbus-board-for-raspberry-pi-23-p-1475.html>
 
+## Enable infrared
+
+Users who want to enable infrared support, for example for using LIRC (Linux
+Infrared Remote Control), have to explicitly set in local.conf:
+
+    ENABLE_IR = "1"
+
+This will add device tree overlays gpio-ir and gpio-ir-tx to config.txt.
+Appropriate kernel modules will be also included in the image. By default the
+GPIO pin for gpio-ir is set to 18 and the pin for gpio-ir-tx is 17. Both pins
+can be easily changed by modifying variables `GPIO_IR` and `GPIO_IR_TX`.
+
 ## Manual additions to config.txt
 
 The `RPI_EXTRA_CONFIG` variable can be used to manually add additional lines to
diff --git a/meta-raspberrypi/docs/layer-contents.md b/meta-raspberrypi/docs/layer-contents.md
index 14e6b99..5483708 100644
--- a/meta-raspberrypi/docs/layer-contents.md
+++ b/meta-raspberrypi/docs/layer-contents.md
@@ -8,6 +8,8 @@
 * raspberrypi2
 * raspberrypi3
 * raspberrypi3-64 (64 bit kernel & userspace)
+* raspberrypi4
+* raspberrypi4-64 (64 bit kernel & userspace)
 * raspberrypi-cm (dummy alias for raspberrypi)
 * raspberrypi-cm3
 
diff --git a/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc/lirc-gpio-ir-0.10.patch b/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc/lirc-gpio-ir-0.10.patch
new file mode 100644
index 0000000..c0fdd18
--- /dev/null
+++ b/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc/lirc-gpio-ir-0.10.patch
@@ -0,0 +1,175 @@
+diff -ruN lirc-0.10.1.orig/lib/config_file.c lirc-0.10.1/lib/config_file.c
+--- lirc-0.10.1.orig/lib/config_file.c	2017-09-10 17:52:19.000000000 +0900
++++ lirc-0.10.1/lib/config_file.c	2019-06-26 00:39:45.734320696 +0900
+@@ -71,7 +71,7 @@
+ typedef void* (*array_guest_func)(void* item, void* arg);
+ 
+ 
+-#define LINE_LEN 1024
++#define LINE_LEN 4096
+ #define MAX_INCLUDES 10
+ 
+ const char* whitespace = " \t";
+diff -ruN lirc-0.10.1.orig/lib/ir_remote.h lirc-0.10.1/lib/ir_remote.h
+--- lirc-0.10.1.orig/lib/ir_remote.h	2017-09-10 17:52:19.000000000 +0900
++++ lirc-0.10.1/lib/ir_remote.h	2019-06-26 00:39:45.714321224 +0900
+@@ -110,12 +110,17 @@
+ 
+ static inline int is_pulse(lirc_t data)
+ {
+-	return data & PULSE_BIT ? 1 : 0;
++	return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_PULSE) ? 1 : 0;
+ }
+ 
+ static inline int is_space(lirc_t data)
+ {
+-	return !is_pulse(data);
++	return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_SPACE) ? 1 : 0;
++}
++
++static inline int is_timeout(lirc_t data)
++{
++	return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_TIMEOUT) ? 1 : 0;
+ }
+ 
+ static inline int has_repeat(const struct ir_remote* remote)
+diff -ruN lirc-0.10.1.orig/lib/irrecord.c lirc-0.10.1/lib/irrecord.c
+--- lirc-0.10.1.orig/lib/irrecord.c	2017-09-10 17:52:19.000000000 +0900
++++ lirc-0.10.1/lib/irrecord.c	2019-06-26 00:39:45.724320960 +0900
+@@ -1398,9 +1398,16 @@
+ 		state->retval = 0;
+ 		return STS_LEN_TIMEOUT;
+ 	}
++	if (is_timeout(state->data)) {
++		return STS_LEN_AGAIN;
++	}
+ 	state->count++;
+ 	if (state->mode == MODE_GET_GAP) {
+-		state->sum += state->data & PULSE_MASK;
++		if (state->sum != 0 || is_pulse(state->data)) {
++			state->sum += state->data & PULSE_MASK;
++		}else{
++			return STS_LEN_AGAIN;
++		}
+ 		if (state->average == 0 && is_space(state->data)) {
+ 			if (state->data > 100000) {
+ 				state->sum = 0;
+@@ -1472,6 +1479,10 @@
+ 		state->keypresses = lastmaxcount;
+ 		return STS_LEN_AGAIN;
+ 	} else if (state->mode == MODE_HAVE_GAP) {
++		if (state->count==1 && is_space(state->data))  {
++			state->count = 0;
++			return STS_LEN_AGAIN;
++		}
+ 		if (state->count <= MAX_SIGNALS) {
+ 			signals[state->count - 1] = state->data & PULSE_MASK;
+ 		} else {
+@@ -1510,7 +1521,7 @@
+ 			/* such long pulses may appear with
+ 			 * crappy hardware (receiver? / remote?)
+ 			 */
+-			else {
++			else if(is_pulse(state->data)) {
+ 				remote->gap = 0;
+ 				return STS_LEN_NO_GAP_FOUND;
+ 			}
+@@ -1811,22 +1822,24 @@
+ 
+ static int raw_data_ok(struct button_state* btn_state)
+ {
+-	int r;
++	int r = 0;
+ 	int ref;
+ 
+-	if (!is_space(btn_state->data)) {
++	if (is_pulse(btn_state->data)) {
+ 		r = 0;
+-	} else if (is_const(&remote)) {
+-		if (remote.gap > btn_state->sum) {
+-			ref = (remote.gap - btn_state->sum);
+-			ref *= (100 - remote.eps);
+-			ref /= 100;
++	} else if (is_space(btn_state->data)) {
++		if (is_const(&remote)) {
++			if (remote.gap > btn_state->sum) {
++				ref = (remote.gap - btn_state->sum);
++				ref *= (100 - remote.eps);
++				ref /= 100;
++			} else {
++				ref = 0;
++			}
++			r = btn_state->data > ref;
+ 		} else {
+-			ref = 0;
++			r = btn_state->data > (remote.gap * (100 - remote.eps)) / 100;
+ 		}
+-		r = btn_state->data > ref;
+-	} else {
+-		r = btn_state->data > (remote.gap * (100 - remote.eps)) / 100;
+ 	}
+ 	return r;
+ }
+@@ -1970,7 +1983,7 @@
+ 				btn_state->data = remote.gap;
+ 			}
+ 			if (btn_state->count == 0) {
+-				if (!is_space(btn_state->data)
++				if (is_pulse(btn_state->data)
+ 				    || btn_state->data <
+ 				    remote.gap - remote.gap * remote.eps /
+ 				    100) {
+diff -ruN lirc-0.10.1.orig/lib/lirc/ir_remote.h lirc-0.10.1/lib/lirc/ir_remote.h
+--- lirc-0.10.1.orig/lib/lirc/ir_remote.h	2017-09-10 17:52:58.000000000 +0900
++++ lirc-0.10.1/lib/lirc/ir_remote.h	2019-06-26 00:39:45.724320960 +0900
+@@ -110,12 +110,17 @@
+ 
+ static inline int is_pulse(lirc_t data)
+ {
+-	return data & PULSE_BIT ? 1 : 0;
++	return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_PULSE) ? 1 : 0;
+ }
+ 
+ static inline int is_space(lirc_t data)
+ {
+-	return !is_pulse(data);
++	return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_SPACE) ? 1 : 0;
++}
++
++static inline int is_timeout(lirc_t data)
++{
++	return ((data & LIRC_MODE2_MASK)==LIRC_MODE2_TIMEOUT) ? 1 : 0;
+ }
+ 
+ static inline int has_repeat(const struct ir_remote* remote)
+diff -ruN lirc-0.10.1.orig/tools/mode2.cpp lirc-0.10.1/tools/mode2.cpp
+--- lirc-0.10.1.orig/tools/mode2.cpp	2017-09-10 17:52:19.000000000 +0900
++++ lirc-0.10.1/tools/mode2.cpp	2019-06-26 00:45:38.840404976 +0900
+@@ -326,12 +326,24 @@
+ void print_mode2_data(unsigned int data)
+ {
+ 	static int bitno = 1;
++	static bool leading_space = true;
++	unsigned int msg = data & LIRC_MODE2_MASK;
+ 
+ 	switch (opt_dmode) {
+ 	case 0:
+-		printf("%s %u\n", (
+-			       data & PULSE_BIT) ? "pulse" : "space",
+-		       (uint32_t)(data & PULSE_MASK));
++		if (leading_space && msg == LIRC_MODE2_SPACE ) {
++			break;
++		} else {
++			leading_space = false;
++		}
++		if (msg == LIRC_MODE2_PULSE) {
++			printf("pulse %u\n", (__u32)(data & PULSE_MASK));
++		} else if (msg == LIRC_MODE2_SPACE) {
++			printf("space %u\n", (__u32)(data & PULSE_MASK));
++		} else if (msg == LIRC_MODE2_TIMEOUT) {
++			printf("timeout %u\n", (__u32)(data & PULSE_MASK));
++			leading_space = true;
++		}
+ 		break;
+ 	case 1: {
+ 		/* print output like irrecord raw config file data */
diff --git a/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc/lircd.service b/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc/lircd.service
new file mode 100644
index 0000000..03ecbb0
--- /dev/null
+++ b/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc/lircd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=LIRC Infrared Signal Decoder
+Wants=lircd-setup.service
+After=network.target lircd-setup.service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/lircd --nodaemon
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc_0.10.1.bbappend b/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc_0.10.1.bbappend
new file mode 100644
index 0000000..5d3ab4d
--- /dev/null
+++ b/meta-raspberrypi/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc_0.10.1.bbappend
@@ -0,0 +1,6 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append_rpi = " \
+	file://lirc-gpio-ir-0.10.patch \
+        file://lircd.service \
+"
diff --git a/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bb b/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bb
index 5315676..d964de5 100644
--- a/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bb
+++ b/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bb
@@ -25,6 +25,8 @@
 
 VC4GRAPHICS="${@bb.utils.contains("MACHINE_FEATURES", "vc4graphics", "1", "0", d)}"
 VC4DTBO ?= "vc4-kms-v3d"
+GPIO_IR ?= "18"
+GPIO_IR_TX ?= "17"
 
 inherit deploy nopackages
 
@@ -161,6 +163,13 @@
         echo "enable_uart=1" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
     fi
 
+    # Infrared support
+    if [ "${ENABLE_IR}" = "1" ]; then
+        echo "# Enable infrared" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
+        echo "dtoverlay=gpio-ir,gpio_pin=${GPIO_IR}" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
+        echo "dtoverlay=gpio-ir-tx,gpio_pin=${GPIO_IR_TX}" >>${DEPLOYDIR}/bcm2835-bootfiles/config.txt
+    fi
+
     # VC4 Graphics support
     if [ "${VC4GRAPHICS}" = "1" ]; then
         echo "# Enable VC4 Graphics" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
diff --git a/meta-raspberrypi/recipes-core/packagegroups/packagegroup-rpi-test.bb b/meta-raspberrypi/recipes-core/packagegroups/packagegroup-rpi-test.bb
index 3dbe96d..87de355 100644
--- a/meta-raspberrypi/recipes-core/packagegroups/packagegroup-rpi-test.bb
+++ b/meta-raspberrypi/recipes-core/packagegroups/packagegroup-rpi-test.bb
@@ -20,7 +20,7 @@
     python3-sense-hat \
     connman \
     connman-client \
-    wireless-regdb \
+    wireless-regdb-static \
     bluez5 \
 "
 
diff --git a/meta-raspberrypi/recipes-kernel/linux/files/0001-Revert-selftests-bpf-Skip-perf-hw-events-test-if-the.patch b/meta-raspberrypi/recipes-kernel/linux/files/0001-Revert-selftests-bpf-Skip-perf-hw-events-test-if-the.patch
index 59183dc..66efde1 100644
--- a/meta-raspberrypi/recipes-kernel/linux/files/0001-Revert-selftests-bpf-Skip-perf-hw-events-test-if-the.patch
+++ b/meta-raspberrypi/recipes-kernel/linux/files/0001-Revert-selftests-bpf-Skip-perf-hw-events-test-if-the.patch
@@ -1,16 +1,18 @@
-From a7783676c60dd90a6f4c26bcb9be03dc5703b74e Mon Sep 17 00:00:00 2001
+From 754e3030788702c1f013a88a4fc8546742d84e27 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
-Date: Mon, 13 Apr 2020 11:25:32 -0700
-Subject: [PATCH 1/2] Revert "selftests/bpf: Skip perf hw events test if the
- setup disabled it"
+Date: Thu, 18 Jun 2020 13:45:04 -0700
+Subject: [PATCH] Revert "selftests/bpf: Skip perf hw events test if the setup
+ disabled it"
 
 This reverts commit da43712a7262891317883d4b3a909fb18dac4b1d.
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
  .../selftests/bpf/prog_tests/stacktrace_build_id_nmi.c    | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
 
 diff --git a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
-index 1735faf17536..f62aa0eb959b 100644
+index 437cb93e72ac..f62aa0eb959b 100644
 --- a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
 +++ b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c
 @@ -49,12 +49,8 @@ void test_stacktrace_build_id_nmi(void)
@@ -20,7 +22,7 @@
 -	if (pmu_fd < 0 && errno == ENOENT) {
 -		printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n", __func__);
 -		test__skip();
--		goto cleanup;
+-		goto close_prog;
 -	}
 -	if (CHECK(pmu_fd < 0, "perf_event_open", "err %d errno %d\n",
 +	if (CHECK(pmu_fd < 0, "perf_event_open",
@@ -29,5 +31,5 @@
  		goto close_prog;
  
 -- 
-2.26.0
+2.27.0
 
diff --git a/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_5.4.bb b/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_5.4.bb
index b1881a2..aaf228e 100644
--- a/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_5.4.bb
+++ b/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_5.4.bb
@@ -1,13 +1,11 @@
-LINUX_VERSION ?= "5.4.45"
+LINUX_VERSION ?= "5.4.47"
 LINUX_RPI_BRANCH ?= "rpi-5.4.y"
 
-SRCREV = "d00cdd80abb2a8c201cae2f6bd80e27eb2f7d347"
+SRCREV = "dec0ddc506ab5d93a7de4b8a7c8dc98e0a96f85c"
 
 require linux-raspberrypi_5.4.inc
 
-SRC_URI += "file://0001-perf-Make-perf-able-to-build-with-latest-libbfd.patch \
-            file://0001-Revert-selftests-bpf-Skip-perf-hw-events-test-if-the.patch \
+SRC_URI += "file://0001-Revert-selftests-bpf-Skip-perf-hw-events-test-if-the.patch \
             file://0002-Revert-selftests-bpf-Fix-perf_buffer-test-on-systems.patch \
-            file://0001-selftest-bpf-Use-CHECK-macro-instead-of-RET_IF.patch \
             file://powersave.cfg \
            "