Source
dev_info(&dev->dev, "lirc_dev: driver %s registered at minor = %d, %s receiver, %s transmitter",
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* LIRC base driver
*
* by Artur Lipowski <alipowski@interia.pl>
*/
static dev_t lirc_base_dev;
/* Used to keep track of allocated lirc devices */
static DEFINE_IDA(lirc_ida);
/* Only used for sysfs but defined to void otherwise */
static struct class *lirc_class;
/**
* ir_lirc_raw_event() - Send raw IR data to lirc to be relayed to userspace
*
* @dev: the struct rc_dev descriptor of the device
* @ev: the struct ir_raw_event descriptor of the pulse/space
*/
void ir_lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev)
{
unsigned long flags;
struct lirc_fh *fh;
int sample;
/* Packet start */
if (ev.reset) {
/*
* Userspace expects a long space event before the start of
* the signal to use as a sync. This may be done with repeat
* packets and normal samples. But if a reset has been sent
* then we assume that a long time has passed, so we send a
* space with the maximum time value.
*/
sample = LIRC_SPACE(LIRC_VALUE_MASK);
dev_dbg(&dev->dev, "delivering reset sync space to lirc_dev\n");
/* Carrier reports */
} else if (ev.carrier_report) {
sample = LIRC_FREQUENCY(ev.carrier);
dev_dbg(&dev->dev, "carrier report (freq: %d)\n", sample);
/* Packet end */
} else if (ev.timeout) {
if (dev->gap)
return;
dev->gap_start = ktime_get();
dev->gap = true;
dev->gap_duration = ev.duration;
sample = LIRC_TIMEOUT(ev.duration / 1000);
dev_dbg(&dev->dev, "timeout report (duration: %d)\n", sample);
/* Normal sample */
} else {
if (dev->gap) {
dev->gap_duration += ktime_to_ns(ktime_sub(ktime_get(),
dev->gap_start));
/* Convert to ms and cap by LIRC_VALUE_MASK */
do_div(dev->gap_duration, 1000);
dev->gap_duration = min_t(u64, dev->gap_duration,
LIRC_VALUE_MASK);
spin_lock_irqsave(&dev->lirc_fh_lock, flags);
list_for_each_entry(fh, &dev->lirc_fh, list)
kfifo_put(&fh->rawir,
LIRC_SPACE(dev->gap_duration));
spin_unlock_irqrestore(&dev->lirc_fh_lock, flags);
dev->gap = false;
}
sample = ev.pulse ? LIRC_PULSE(ev.duration / 1000) :