aboutsummaryrefslogtreecommitdiffstats
path: root/utils/keytable/bpf_protocols/bitmap.h
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2019-07-30 14:58:28 +0900
committerSean Young <sean@mess.org>2019-08-08 22:28:24 +0100
commit73f8f2f0acdce9f9ad91da9aa5390c5c7a6ddfd2 (patch)
tree81843410ad7837ed373aef3af1afb66a736adbb8 /utils/keytable/bpf_protocols/bitmap.h
parent6aa15f7447d4aeca6af1ed7ee9644a0c7e891ece (diff)
keytable: add support for keymap with raw literals
These rc keymaps look like: [[protocols]] name = 'Beon_Colour_TV' protocol = 'raw' [[protocols.raw]] keycode = 'KEY_POWER' raw = [ 1324, 842, 6697, 26400, 1324, 842, 6697 ] [[protocols.raw]] keycode = 'KEY_MUTE' raw = [ 1305, 865, 2357, 931, 3411, 26400, 1305, 865, 2357, 931, 3411 ] So the incoming IR will be literally compared against the IR given, and only if the entire array matches with no leading or trailing IR will the keycode be reported. This is analogous to lircd raw_codes support, so lircd2toml.py can also convert raw_codes lircd.conf files. This means that the vast majority of lircd files can now be converted. This feature requires loops in BPF programs so this is only supported in kernel 5.3 onwards. Signed-off-by: Sean Young <sean@mess.org>
Diffstat (limited to 'utils/keytable/bpf_protocols/bitmap.h')
-rw-r--r--utils/keytable/bpf_protocols/bitmap.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/keytable/bpf_protocols/bitmap.h b/utils/keytable/bpf_protocols/bitmap.h
new file mode 100644
index 00000000..e3d731ad
--- /dev/null
+++ b/utils/keytable/bpf_protocols/bitmap.h
@@ -0,0 +1,36 @@
+
+#ifndef __BITMAP_H__
+#define __BITMAP_H__
+
+#include "string.h"
+
+#define BITS_PER_LONG 64
+#define BITS_TO_LONG(n) \
+ (((n) + BITS_PER_LONG - 1) / BITS_PER_LONG)
+
+
+#define DECLARE_BITMAP(name, bits) \
+ unsigned long name[BITS_TO_LONG(bits)]
+
+static void inline bitmap_zero(unsigned long *bitmap, int bits)
+{
+ for (int i = 0; i < BITS_TO_LONG(bits); i++)
+ bitmap[i] = 0;
+}
+
+static void inline bitmap_fill(unsigned long *bitmap, int bits)
+{
+ for (int i = 0; i < BITS_TO_LONG(bits); i++)
+ bitmap[i] = ~0;
+}
+
+#define bitmap_set(b, n) \
+ b[n / BITS_PER_LONG] |= 1 << (n % BITS_PER_LONG)
+
+#define bitmap_clear(b, n) \
+ b[n / BITS_PER_LONG] &= ~(1 << (n % BITS_PER_LONG))
+
+#define bitmap_test(b, n) \
+ (b[n / BITS_PER_LONG] & (1 << (n % BITS_PER_LONG))) != 0
+
+#endif

Privacy Policy