v4l-utils: replace streamzap fix with proposed upstream patch

See http://www.mail-archive.com/linux-media@vger.kernel.org/msg108483.html

Signed-off-by: Matthias Reichl <hias@horus.com>
This commit is contained in:
Matthias Reichl 2017-03-12 12:58:50 +01:00
parent 7948131c88
commit 65bd18949d
2 changed files with 79 additions and 10 deletions

View File

@ -0,0 +1,79 @@
From 52a487063684299c20a27ba8b1028aeaaa08ddc6 Mon Sep 17 00:00:00 2001
From: Matthias Reichl <hias@horus.com>
Date: Sun, 12 Mar 2017 12:53:50 +0100
Subject: [PATCH] ir-keytable: be more permissive on protocol name
Allowed the protocol to be specified with or without underscores or
dashes. This also solves the problem of not being able to load
the streamzap keymap.
./ir-keytable -w rc_keymaps/streamzap
Protocol RC5_SZ invalid
Reported-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Matthias Reichl <hias@horus.com>
---
utils/keytable/keytable.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index a6ecc9e..f61a1d5 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -120,9 +120,7 @@ const struct protocol_map_entry protocol_map[] = {
{ "other", NULL, SYSFS_OTHER },
{ "lirc", NULL, SYSFS_LIRC },
{ "rc-5", "/rc5_decoder", SYSFS_RC5 },
- { "rc5", NULL, SYSFS_RC5 },
{ "rc-5x", NULL, SYSFS_INVALID },
- { "rc5x", NULL, SYSFS_INVALID },
{ "rc-5-sz", NULL, SYSFS_RC5_SZ },
{ "jvc", "/jvc_decoder", SYSFS_JVC },
{ "sony", "/sony_decoder",SYSFS_SONY },
@@ -134,7 +132,6 @@ const struct protocol_map_entry protocol_map[] = {
{ "mce_kbd", NULL, SYSFS_MCE_KBD },
{ "mce-kbd", NULL, SYSFS_MCE_KBD },
{ "rc-6", "/rc6_decoder", SYSFS_RC6 },
- { "rc6", NULL, SYSFS_RC6 },
{ "rc-6-0", NULL, SYSFS_INVALID },
{ "rc-6-6a-20", NULL, SYSFS_INVALID },
{ "rc-6-6a-24", NULL, SYSFS_INVALID },
@@ -145,6 +142,25 @@ const struct protocol_map_entry protocol_map[] = {
{ NULL, NULL, SYSFS_INVALID },
};
+static bool str_like(const char *a, const char *b)
+{
+ while (*a && *b) {
+ if (*a == '-' || *a == '_') {
+ a++;
+ continue;
+ }
+ if (*b == '-' || *b == '_') {
+ b++;
+ continue;
+ }
+ if (tolower(*a) != tolower(*b))
+ return false;
+ a++; b++;
+ }
+
+ return !*a && !*b;
+}
+
static enum sysfs_protocols parse_sysfs_protocol(const char *name, bool all_allowed)
{
const struct protocol_map_entry *pme;
@@ -156,7 +172,7 @@ static enum sysfs_protocols parse_sysfs_protocol(const char *name, bool all_allo
return ~0;
for (pme = protocol_map; pme->name; pme++) {
- if (!strcasecmp(name, pme->name))
+ if (str_like(name, pme->name))
return pme->sysfs_protocol;
}
--
2.1.4

View File

@ -1,10 +0,0 @@
diff --git a/utils/keytable/rc_keymaps/streamzap b/utils/keytable/rc_keymaps/streamzap
index 3512cd8..1619459 100644
--- a/utils/keytable/rc_keymaps/streamzap
+++ b/utils/keytable/rc_keymaps/streamzap
@@ -1,4 +1,4 @@
-# table streamzap, type: RC5_SZ
+# table streamzap, type: rc-5-sz
0x28c0 KEY_NUMERIC_0
0x28c1 KEY_NUMERIC_1
0x28c2 KEY_NUMERIC_2