1 // SPDX-License-Identifier: GPL-2.0 2 // test ir decoder 3 // 4 // Copyright (C) 2018 Sean Young <sean@mess.org> 5 6 #include <linux/bpf.h> 7 #include <linux/lirc.h> 8 #include <bpf/bpf_helpers.h> 9 10 SEC("lirc_mode2") bpf_decoder(unsigned int * sample)11int bpf_decoder(unsigned int *sample) 12 { 13 if (LIRC_IS_PULSE(*sample)) { 14 unsigned int duration = LIRC_VALUE(*sample); 15 16 if (duration & 0x10000) 17 bpf_rc_keydown(sample, 0x40, duration & 0xffff, 0); 18 if (duration & 0x20000) 19 bpf_rc_pointer_rel(sample, (duration >> 8) & 0xff, 20 duration & 0xff); 21 } 22 23 return 0; 24 } 25 26 char _license[] SEC("license") = "GPL"; 27