diff options
| author | Sean Young <sean@mess.org> | 2018-05-27 07:24:09 -0400 |
|---|---|---|
| committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-05-30 06:38:40 -0400 |
| commit | f4364dcfc86df7c1ca47b256eaf6b6d0cdd0d936 (patch) | |
| tree | aa0d09b48734429acec8d26b703db839fcc655de /include/uapi/linux | |
| parent | 170a7e3ea0709eae12c8f944b9f33c54fe80c6c1 (diff) | |
media: rc: introduce BPF_PROG_LIRC_MODE2
Add support for BPF_PROG_LIRC_MODE2. This type of BPF program can call
rc_keydown() to reported decoded IR scancodes, or rc_repeat() to report
that the last key should be repeated.
The bpf program can be attached to using the bpf(BPF_PROG_ATTACH) syscall;
the target_fd must be the /dev/lircN device.
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/bpf.h | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 33f37eb0b6bf..64ac0f7a689e 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h | |||
| @@ -143,6 +143,7 @@ enum bpf_prog_type { | |||
| 143 | BPF_PROG_TYPE_RAW_TRACEPOINT, | 143 | BPF_PROG_TYPE_RAW_TRACEPOINT, |
| 144 | BPF_PROG_TYPE_CGROUP_SOCK_ADDR, | 144 | BPF_PROG_TYPE_CGROUP_SOCK_ADDR, |
| 145 | BPF_PROG_TYPE_LWT_SEG6LOCAL, | 145 | BPF_PROG_TYPE_LWT_SEG6LOCAL, |
| 146 | BPF_PROG_TYPE_LIRC_MODE2, | ||
| 146 | }; | 147 | }; |
| 147 | 148 | ||
| 148 | enum bpf_attach_type { | 149 | enum bpf_attach_type { |
| @@ -162,6 +163,7 @@ enum bpf_attach_type { | |||
| 162 | BPF_CGROUP_INET6_POST_BIND, | 163 | BPF_CGROUP_INET6_POST_BIND, |
| 163 | BPF_CGROUP_UDP4_SENDMSG, | 164 | BPF_CGROUP_UDP4_SENDMSG, |
| 164 | BPF_CGROUP_UDP6_SENDMSG, | 165 | BPF_CGROUP_UDP6_SENDMSG, |
| 166 | BPF_LIRC_MODE2, | ||
| 165 | __MAX_BPF_ATTACH_TYPE | 167 | __MAX_BPF_ATTACH_TYPE |
| 166 | }; | 168 | }; |
| 167 | 169 | ||
| @@ -2005,6 +2007,53 @@ union bpf_attr { | |||
| 2005 | * direct packet access. | 2007 | * direct packet access. |
| 2006 | * Return | 2008 | * Return |
| 2007 | * 0 on success, or a negative error in case of failure. | 2009 | * 0 on success, or a negative error in case of failure. |
| 2010 | * | ||
| 2011 | * int bpf_rc_keydown(void *ctx, u32 protocol, u64 scancode, u32 toggle) | ||
| 2012 | * Description | ||
| 2013 | * This helper is used in programs implementing IR decoding, to | ||
| 2014 | * report a successfully decoded key press with *scancode*, | ||
| 2015 | * *toggle* value in the given *protocol*. The scancode will be | ||
| 2016 | * translated to a keycode using the rc keymap, and reported as | ||
| 2017 | * an input key down event. After a period a key up event is | ||
| 2018 | * generated. This period can be extended by calling either | ||
| 2019 | * **bpf_rc_keydown** () again with the same values, or calling | ||
| 2020 | * **bpf_rc_repeat** (). | ||
| 2021 | * | ||
| 2022 | * Some protocols include a toggle bit, in case the button was | ||
| 2023 | * released and pressed again between consecutive scancodes. | ||
| 2024 | * | ||
| 2025 | * The *ctx* should point to the lirc sample as passed into | ||
| 2026 | * the program. | ||
| 2027 | * | ||
| 2028 | * The *protocol* is the decoded protocol number (see | ||
| 2029 | * **enum rc_proto** for some predefined values). | ||
| 2030 | * | ||
| 2031 | * This helper is only available is the kernel was compiled with | ||
| 2032 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to | ||
| 2033 | * "**y**". | ||
| 2034 | * | ||
| 2035 | * Return | ||
| 2036 | * 0 | ||
| 2037 | * | ||
| 2038 | * int bpf_rc_repeat(void *ctx) | ||
| 2039 | * Description | ||
| 2040 | * This helper is used in programs implementing IR decoding, to | ||
| 2041 | * report a successfully decoded repeat key message. This delays | ||
| 2042 | * the generation of a key up event for previously generated | ||
| 2043 | * key down event. | ||
| 2044 | * | ||
| 2045 | * Some IR protocols like NEC have a special IR message for | ||
| 2046 | * repeating last button, for when a button is held down. | ||
| 2047 | * | ||
| 2048 | * The *ctx* should point to the lirc sample as passed into | ||
| 2049 | * the program. | ||
| 2050 | * | ||
| 2051 | * This helper is only available is the kernel was compiled with | ||
| 2052 | * the **CONFIG_BPF_LIRC_MODE2** configuration option set to | ||
| 2053 | * "**y**". | ||
| 2054 | * | ||
| 2055 | * Return | ||
| 2056 | * 0 | ||
| 2008 | */ | 2057 | */ |
| 2009 | #define __BPF_FUNC_MAPPER(FN) \ | 2058 | #define __BPF_FUNC_MAPPER(FN) \ |
| 2010 | FN(unspec), \ | 2059 | FN(unspec), \ |
| @@ -2083,7 +2132,9 @@ union bpf_attr { | |||
| 2083 | FN(lwt_push_encap), \ | 2132 | FN(lwt_push_encap), \ |
| 2084 | FN(lwt_seg6_store_bytes), \ | 2133 | FN(lwt_seg6_store_bytes), \ |
| 2085 | FN(lwt_seg6_adjust_srh), \ | 2134 | FN(lwt_seg6_adjust_srh), \ |
| 2086 | FN(lwt_seg6_action), | 2135 | FN(lwt_seg6_action), \ |
| 2136 | FN(rc_repeat), \ | ||
| 2137 | FN(rc_keydown), | ||
| 2087 | 2138 | ||
| 2088 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 2139 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 2089 | * function eBPF program intends to call | 2140 | * function eBPF program intends to call |
