IR decoding using BPF
Status from this message: Applied to bpf-next, thanks Sean!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest3 patches 4 repliesApplied
- v43 patches 10 repliesSuperseded
- v32 patches 10 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 2 patches | 1 reply | Superseded | |
| v1 | 4 patches | 8 replies | Superseded |
Changes in v5 from the cover letter
- Renamed rc_dev_bpf_{attach,detach,query} to lirc_bpf_{attach,detach,query}
- Fixed error path in lirc_bpf_query
- Rebased on bpf-next
Patches in v5 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | bpf: bpf_prog_array_copy() should return -ENOENT if exclude_prog not foundkernel/ kernel/ | +11 | 0 replies | |
| 2/3 | media: rc: introduce BPF_PROG_LIRC_MODE2drivers/ drivers/ drivers/ +7 more | +479 | 13 replies | |
| 3/3 | bpf: add selftest for lirc_mode2 type programtools/ tools/ tools/ +7 more | +481 | 0 replies |
Reviews trailers per patch
All 3 patches have a Reviewed-by or Acked-by.
| Patch | Yonghong Song |
|---|---|
| 1/3 | A-b |
| 2/3 | A-b |
| 3/3 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v5 0/3] IR decoding using BPF
The kernel IR decoders (drivers/media/rc/ir-*-decoder.c) support the most widely used IR protocols, but there are many protocols which are not supported[1]. For example, the lirc-remotes[2] repo has over 2700 remotes, many of which are not supported by rc-core. There is a "long tail" of unsupported IR protocols, for which lircd is need to decode the IR .
IR encoding is done in such a way that some simple circuit can decode it; therefore, bpf is ideal.
In order to support all these protocols, here we have bpf based IR decoding. The idea is that user-space can define a decoder in bpf, attach it to the rc device through the lirc chardev.
Separate work is underway to extend ir-keytable to have an extensive library of bpf-based decoders, and a much expanded library of rc keymaps.
Another future application would be to compile IRP[3] to a IR BPF program, and so support virtually every remote without having to write a decoder for each. It might also be possible to support non-button devices such as analog directional pads or air conditioning remote controls and decode the target temperature in bpf, and pass that to an input device.
Thanks,
Sean Young
[1] http://www.hifi-remote.com/wiki/index.php?title=DecodeIR
[2] https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/
[3] http://www.hifi-remote.com/wiki/index.php?title=IRP_Notation
Changes since v4:
- Renamed rc_dev_bpf_{attach,detach,query} to lirc_bpf_{attach,detach,query}
- Fixed error path in lirc_bpf_query
- Rebased on bpf-next
Changes since v3:
- Implemented review comments from Quentin Monnet and Y Song (thanks!)
- More helpful and better formatted bpf helper documentation
- Changed back to bpf_prog_array rather than open-coded implementation
- scancodes can be 64 bit
- bpf gets passed values in microseconds, not nanoseconds. microseconds is more than than enough (IR receivers support carriers upto 70kHz, at which point a single period is already 14 microseconds). Also, this makes it much more consistent with lirc mode2.
- Since it looks much more like lirc mode2, rename the program type to BPF_PROG_TYPE_LIRC_MODE2.
- Rebased on bpf-next
Changes since v2:
- Fixed locking issues
- Improved self-test to cover more cases
- Rebased on bpf-next again
Changes since v1:
- Code review comments from Y Song <[email protected]> and Randy Dunlap <[email protected]>
- Re-wrote sample bpf to be selftest
- Renamed RAWIR_DECODER -> RAWIR_EVENT (Kconfig, context, bpf prog type)
- Rebase on bpf-next
- Introduced bpf_rawir_event context structure with simpler access checking
Sean Young (3):
bpf: bpf_prog_array_copy() should return -ENOENT if exclude_prog not
found
media: rc: introduce BPF_PROG_LIRC_MODE2
bpf: add selftest for lirc_mode2 type program
drivers/media/rc/Kconfig | 13 + drivers/media/rc/Makefile | 1 + drivers/media/rc/bpf-lirc.c | 313 ++++++++++++++++++ drivers/media/rc/lirc_dev.c | 30 ++ drivers/media/rc/rc-core-priv.h | 21 ++ drivers/media/rc/rc-ir-raw.c | 12 +- include/linux/bpf_lirc.h | 29 ++ include/linux/bpf_types.h | 3 + include/uapi/linux/bpf.h | 53 ++- kernel/bpf/core.c | 11 +- kernel/bpf/syscall.c | 7 + kernel/trace/bpf_trace.c | 2 + tools/bpf/bpftool/prog.c | 1 + tools/include/uapi/linux/bpf.h | 53 ++- tools/include/uapi/linux/lirc.h | 217 ++++++++++++ tools/lib/bpf/libbpf.c | 1 + tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/Makefile | 7 +- tools/testing/selftests/bpf/bpf_helpers.h | 5 + .../testing/selftests/bpf/test_lirc_mode2.sh | 28 ++ .../selftests/bpf/test_lirc_mode2_kern.c | 23 ++ .../selftests/bpf/test_lirc_mode2_user.c | 149 +++++++++ 22 files changed, 971 insertions(+), 9 deletions(-) create mode 100644 drivers/media/rc/bpf-lirc.c create mode 100644 include/linux/bpf_lirc.h create mode 100644 tools/include/uapi/linux/lirc.h create mode 100755 tools/testing/selftests/bpf/test_lirc_mode2.sh create mode 100644 tools/testing/selftests/bpf/test_lirc_mode2_kern.c create mode 100644 tools/testing/selftests/bpf/test_lirc_mode2_user.c
Signature · 1 line
2.17.0