26 #include <linux/device.h>
27 #include <linux/module.h>
28 #include <linux/sched.h>
31 #define DRIVER_NAME "rc-loopback"
32 #define dprintk(x...) if (debug) printk(KERN_INFO DRIVER_NAME ": " x)
33 #define RXMASK_REGULAR 0x1
34 #define RXMASK_LEARNING 0x2
57 dprintk(
"invalid tx mask: %u\n", mask);
61 dprintk(
"setting tx mask: %u\n", mask);
66 static int loop_set_tx_carrier(
struct rc_dev *dev,
u32 carrier)
70 dprintk(
"setting tx carrier: %u\n", carrier);
75 static int loop_set_tx_duty_cycle(
struct rc_dev *dev,
u32 duty_cycle)
79 if (duty_cycle < 1 || duty_cycle > 99) {
80 dprintk(
"invalid duty cycle: %u\n", duty_cycle);
84 dprintk(
"setting duty cycle: %u\n", duty_cycle);
85 lodev->
txduty = duty_cycle;
93 if (min < 1 || min > max) {
94 dprintk(
"invalid rx carrier range %u to %u\n", min, max);
98 dprintk(
"setting rx carrier range %u to %u\n", min, max);
104 static int loop_tx_ir(
struct rc_dev *dev,
unsigned *txbuf,
unsigned count)
113 dprintk(
"ignoring tx, carrier out of range\n");
122 if (!(rxmask & lodev->
txmask)) {
123 dprintk(
"ignoring tx, rx mask mismatch\n");
127 for (i = 0; i <
count; i++) {
128 rawir.pulse = i % 2 ?
false :
true;
129 rawir.duration = txbuf[
i] * 1000;
145 static void loop_set_idle(
struct rc_dev *dev,
bool enable)
149 if (lodev->
idle != enable) {
150 dprintk(
"%sing idle mode\n", enable ?
"enter" :
"exit");
155 static int loop_set_learning_mode(
struct rc_dev *dev,
int enable)
160 dprintk(
"%sing learning mode\n", enable ?
"enter" :
"exit");
167 static int loop_set_carrier_report(
struct rc_dev *dev,
int enable)
172 dprintk(
"%sabling carrier reports\n", enable ?
"en" :
"dis");
179 static int __init loop_init(
void)
199 rc->
timeout = 100 * 1000 * 1000;
208 rc->
tx_ir = loop_tx_ir;
209 rc->
s_idle = loop_set_idle;
214 loopdev.txcarrier = 36000;
216 loopdev.rxcarriermin = 1;
217 loopdev.rxcarriermax = ~0;
219 loopdev.learning =
false;
220 loopdev.carrierreport =
false;
233 static void __exit loop_exit(
void)