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.
Showing the changes to include/uapi/linux (1 of 10 files). Show all
Unified · Split
| @@ -143,6 +143,7 @@ enum bpf_prog_type { · 142 unmodified lines | ||
| 143 | 143 | BPF_PROG_TYPE_RAW_TRACEPOINT, |
| 144 | 144 | BPF_PROG_TYPE_CGROUP_SOCK_ADDR, |
| 145 | 145 | BPF_PROG_TYPE_LWT_SEG6LOCAL, |
| 146 | + BPF_PROG_TYPE_LIRC_MODE2, | |
| 146 | 147 | }; |
| 147 | 148 | |
| 148 | 149 | enum bpf_attach_type { |
| @@ -162,6 +163,7 @@ enum bpf_attach_type { · 13 unmodified lines | ||
| 162 | 163 | BPF_CGROUP_INET6_POST_BIND, |
| 163 | 164 | BPF_CGROUP_UDP4_SENDMSG, |
| 164 | 165 | BPF_CGROUP_UDP6_SENDMSG, |
| 166 | + BPF_LIRC_MODE2, | |
| 165 | 167 | __MAX_BPF_ATTACH_TYPE |
| 166 | 168 | }; |
| 167 | 169 | |
| @@ -2005,6 +2007,53 @@ union bpf_attr { · 1837 unmodified lines | ||
| 2005 | 2007 | * direct packet access. |
| 2006 | 2008 | * Return |
| 2007 | 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 | 2058 | #define __BPF_FUNC_MAPPER(FN) \ |
| 2010 | 2059 | FN(unspec), \ |
| @@ -2083,7 +2132,9 @@ union bpf_attr { · 72 unmodified lines | ||
| 2083 | 2132 | FN(lwt_push_encap), \ |
| 2084 | 2133 | FN(lwt_seg6_store_bytes), \ |
| 2085 | 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 | 2139 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 2089 | 2140 | * function eBPF program intends to call |