Lines Matching +full:static +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Loopback driver for rc-core,
8 * which is useful for (scripted) debugging of rc-core without
16 #include <media/rc-core.h>
18 #define DRIVER_NAME "rc-loopback"
23 static bool debug;
37 static struct loopback_dev loopdev;
39 static int loop_set_tx_mask(struct rc_dev *dev, u32 mask) in loop_set_tx_mask()
41 struct loopback_dev *lodev = dev->priv; in loop_set_tx_mask()
45 return -EINVAL; in loop_set_tx_mask()
49 lodev->txmask = mask; in loop_set_tx_mask()
53 static int loop_set_tx_carrier(struct rc_dev *dev, u32 carrier) in loop_set_tx_carrier()
55 struct loopback_dev *lodev = dev->priv; in loop_set_tx_carrier()
58 lodev->txcarrier = carrier; in loop_set_tx_carrier()
62 static int loop_set_tx_duty_cycle(struct rc_dev *dev, u32 duty_cycle) in loop_set_tx_duty_cycle()
64 struct loopback_dev *lodev = dev->priv; in loop_set_tx_duty_cycle()
68 return -EINVAL; in loop_set_tx_duty_cycle()
72 lodev->txduty = duty_cycle; in loop_set_tx_duty_cycle()
76 static int loop_set_rx_carrier_range(struct rc_dev *dev, u32 min, u32 max) in loop_set_rx_carrier_range()
78 struct loopback_dev *lodev = dev->priv; in loop_set_rx_carrier_range()
82 return -EINVAL; in loop_set_rx_carrier_range()
86 lodev->rxcarriermin = min; in loop_set_rx_carrier_range()
87 lodev->rxcarriermax = max; in loop_set_rx_carrier_range()
91 static int loop_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned count) in loop_tx_ir()
93 struct loopback_dev *lodev = dev->priv; in loop_tx_ir()
98 if (lodev->txcarrier < lodev->rxcarriermin || in loop_tx_ir()
99 lodev->txcarrier > lodev->rxcarriermax) { in loop_tx_ir()
104 if (lodev->learning) in loop_tx_ir()
109 if (!(rxmask & lodev->txmask)) { in loop_tx_ir()
123 rawir.duration = dev->timeout; in loop_tx_ir()
132 static void loop_set_idle(struct rc_dev *dev, bool enable) in loop_set_idle() argument
134 struct loopback_dev *lodev = dev->priv; in loop_set_idle()
136 if (lodev->idle != enable) { in loop_set_idle()
137 dprintk("%sing idle mode\n", enable ? "enter" : "exit"); in loop_set_idle()
138 lodev->idle = enable; in loop_set_idle()
142 static int loop_set_learning_mode(struct rc_dev *dev, int enable) in loop_set_learning_mode() argument
144 struct loopback_dev *lodev = dev->priv; in loop_set_learning_mode()
146 if (lodev->learning != enable) { in loop_set_learning_mode()
147 dprintk("%sing learning mode\n", enable ? "enter" : "exit"); in loop_set_learning_mode()
148 lodev->learning = !!enable; in loop_set_learning_mode()
154 static int loop_set_carrier_report(struct rc_dev *dev, int enable) in loop_set_carrier_report() argument
156 struct loopback_dev *lodev = dev->priv; in loop_set_carrier_report()
158 if (lodev->carrierreport != enable) { in loop_set_carrier_report()
159 dprintk("%sabling carrier reports\n", enable ? "en" : "dis"); in loop_set_carrier_report()
160 lodev->carrierreport = !!enable; in loop_set_carrier_report()
166 static int loop_set_wakeup_filter(struct rc_dev *dev, in loop_set_wakeup_filter()
169 static const unsigned int max = 512; in loop_set_wakeup_filter()
175 if (!sc->mask) in loop_set_wakeup_filter()
181 return -ENOMEM; in loop_set_wakeup_filter()
183 ret = ir_raw_encode_scancode(dev->wakeup_protocol, sc->data, raw, max); in loop_set_wakeup_filter()
185 if (ret == -ENOBUFS) in loop_set_wakeup_filter()
201 static int __init loop_init(void) in loop_init()
209 return -ENOMEM; in loop_init()
212 rc->device_name = "rc-core loopback device"; in loop_init()
213 rc->input_phys = "rc-core/virtual"; in loop_init()
214 rc->input_id.bustype = BUS_VIRTUAL; in loop_init()
215 rc->input_id.version = 1; in loop_init()
216 rc->driver_name = DRIVER_NAME; in loop_init()
217 rc->map_name = RC_MAP_EMPTY; in loop_init()
218 rc->priv = &loopdev; in loop_init()
219 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; in loop_init()
220 rc->allowed_wakeup_protocols = RC_PROTO_BIT_ALL_IR_ENCODER; in loop_init()
221 rc->encode_wakeup = true; in loop_init()
222 rc->timeout = MS_TO_US(100); /* 100 ms */ in loop_init()
223 rc->min_timeout = 1; in loop_init()
224 rc->max_timeout = UINT_MAX; in loop_init()
225 rc->rx_resolution = 1; in loop_init()
226 rc->tx_resolution = 1; in loop_init()
227 rc->s_tx_mask = loop_set_tx_mask; in loop_init()
228 rc->s_tx_carrier = loop_set_tx_carrier; in loop_init()
229 rc->s_tx_duty_cycle = loop_set_tx_duty_cycle; in loop_init()
230 rc->s_rx_carrier_range = loop_set_rx_carrier_range; in loop_init()
231 rc->tx_ir = loop_tx_ir; in loop_init()
232 rc->s_idle = loop_set_idle; in loop_init()
233 rc->s_learning_mode = loop_set_learning_mode; in loop_init()
234 rc->s_carrier_report = loop_set_carrier_report; in loop_init()
235 rc->s_wakeup_filter = loop_set_wakeup_filter; in loop_init()
257 static void __exit loop_exit(void) in loop_exit()
266 MODULE_PARM_DESC(debug, "Enable debug messages");
268 MODULE_DESCRIPTION("Loopback device for rc-core debugging");