* [PATCH v4l-utils] keytable: "-p all" should not attempt BPF decodes that don't exist
@ 2020-05-16 13:09 Sean Young
0 siblings, 0 replies; only message in thread
From: Sean Young @ 2020-05-16 13:09 UTC (permalink / raw)
To: linux-media; +Cc: Ralf Schmidt
Currently we only have a BPF decoder for xbox_dvd. Other decoders
should not be attempted.
Reported-by: Ralf Schmidt <rds2@gmx.de>
Signed-off-by: Sean Young <sean@mess.org>
---
utils/keytable/keytable.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c
index 4db91267..3df5fcf2 100644
--- a/utils/keytable/keytable.c
+++ b/utils/keytable/keytable.c
@@ -945,12 +945,21 @@ static struct sysfs_names *find_device(char *name)
return names;
}
+/*
+ * If an rcdev does not have a decoder for a protocol, try to load a bpf
+ * replacement.
+ */
static enum sysfs_protocols load_bpf_for_unsupported(enum sysfs_protocols protocols, enum sysfs_protocols supported)
{
const struct protocol_map_entry *pme;
struct bpf_protocol *b;
for (pme = protocol_map; pme->name; pme++) {
+ // So far, we only have a replacement for the xbox_dvd
+ // protocol
+ if (pme->sysfs_protocol != SYSFS_XBOX_DVD)
+ continue;
+
if (!(protocols & pme->sysfs_protocol) ||
(supported & pme->sysfs_protocol))
continue;
@@ -1156,7 +1165,7 @@ static int v2_set_protocols(struct rc_device *rc_dev)
if (!stat(name, &st) && !(st.st_mode & 0222)) {
fprintf(stderr, _("Protocols for device can not be changed\n"));
- return 0;
+ return EINVAL;
}
fp = fopen(name, "w");
@@ -1323,8 +1332,7 @@ static int set_proto(struct rc_device *rc_dev)
int rc = 0;
if (rc_dev->version == VERSION_2) {
- rc = v2_set_protocols(rc_dev);
- return rc;
+ return v2_set_protocols(rc_dev);
}
rc_dev->current &= rc_dev->supported;
@@ -2151,9 +2159,7 @@ int main(int argc, char *argv[])
rc_dev.current = load_bpf_for_unsupported(ch_proto, rc_dev.supported);
- if (set_proto(&rc_dev))
- fprintf(stderr, _("Couldn't change the IR protocols\n"));
- else {
+ if (!set_proto(&rc_dev)) {
fprintf(stderr, _("Protocols changed to "));
write_sysfs_protocols(rc_dev.current, stderr, "%s ");
fprintf(stderr, "\n");
--
2.26.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-16 13:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 13:09 [PATCH v4l-utils] keytable: "-p all" should not attempt BPF decodes that don't exist Sean Young
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).