test_lirc_mode2_kern.c 457 B

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