summaryrefslogtreecommitdiff
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2022-01-13 12:29:01 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-01-24 01:38:32 +0100
commitd49a14a946db0a8e0713aa43034879f967ab75e2 (patch)
tree24ed3ba39f0c1b81e6b0b3afedcaa6763c8115ec /drivers/media/rc
parent52cdb013036391d9d87aba5b4fc49cdfc6ea4b23 (diff)
media: lirc: simplify gap calculation
When a driver reports a timeout, no more IR activity will be reported until the next pulse. A space is inserted between the timeout and the next pulse, based on ktime. The timeout reports already a duration, so this duration should not be added to the gap. Otherwise there is no change to the functionality. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/lirc_dev.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index c7c5157725f8..a080291c4b06 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -60,32 +60,25 @@ void lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev)
/* 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);
dev_dbg(&dev->dev, "timeout report (duration: %d)\n", sample);
/* Normal sample */
} else {
- if (dev->gap) {
- dev->gap_duration += ktime_to_us(ktime_sub(ktime_get(),
- dev->gap_start));
+ if (dev->gap_start) {
+ u64 duration = ktime_us_delta(ktime_get(),
+ dev->gap_start);
/* Cap by LIRC_VALUE_MASK */
- dev->gap_duration = min_t(u64, dev->gap_duration,
- LIRC_VALUE_MASK);
+ duration = min_t(u64, 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));
+ kfifo_put(&fh->rawir, LIRC_SPACE(duration));
spin_unlock_irqrestore(&dev->lirc_fh_lock, flags);
- dev->gap = false;
+ dev->gap_start = 0;
}
sample = ev.pulse ? LIRC_PULSE(ev.duration) :