// SPDX-License-Identifier: GPL-2.0+ // ir-imon-decoder.c - handle iMon protocol // // Copyright (C) 2018 by Sean Young <[email protected]> #define pr_fmt(fmt) … #include <linux/module.h> #include "rc-core-priv.h" #define IMON_UNIT … #define IMON_BITS … #define IMON_CHKBITS … /* * This protocol has 30 bits. The format is one IMON_UNIT header pulse, * followed by 30 bits. Each bit is one IMON_UNIT check field, and then * one IMON_UNIT field with the actual bit (1=space, 0=pulse). * The check field is always space for some bits, for others it is pulse if * both the preceding and current bit are zero, else space. IMON_CHKBITS * defines which bits are of type check. * * There is no way to distinguish an incomplete message from one where * the lower bits are all set, iow. the last pulse is for the lowest * bit which is 0. */ enum imon_state { … }; static void ir_imon_decode_scancode(struct rc_dev *dev) { … } /** * ir_imon_decode() - Decode one iMON pulse or space * @dev: the struct rc_dev descriptor of the device * @ev: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ static int ir_imon_decode(struct rc_dev *dev, struct ir_raw_event ev) { … } /** * ir_imon_encode() - Encode a scancode as a stream of raw events * * @protocol: protocol to encode * @scancode: scancode to encode * @events: array of raw ir events to write into * @max: maximum size of @events * * Returns: The number of events written. * -ENOBUFS if there isn't enough space in the array to fit the * encoding. In this case all @max events will have been written. */ static int ir_imon_encode(enum rc_proto protocol, u32 scancode, struct ir_raw_event *events, unsigned int max) { … } static int ir_imon_register(struct rc_dev *dev) { … } static struct ir_raw_handler imon_handler = …; static int __init ir_imon_decode_init(void) { … } static void __exit ir_imon_decode_exit(void) { … } module_init(…) …; module_exit(ir_imon_decode_exit); MODULE_LICENSE(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …;