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>
This commit is contained in:
Родитель
52cdb01303
Коммит
d49a14a946
|
@ -60,32 +60,25 @@ void lirc_raw_event(struct rc_dev *dev, struct ir_raw_event ev)
|
||||||
|
|
||||||
/* Packet end */
|
/* Packet end */
|
||||||
} else if (ev.timeout) {
|
} else if (ev.timeout) {
|
||||||
if (dev->gap)
|
|
||||||
return;
|
|
||||||
|
|
||||||
dev->gap_start = ktime_get();
|
dev->gap_start = ktime_get();
|
||||||
dev->gap = true;
|
|
||||||
dev->gap_duration = ev.duration;
|
|
||||||
|
|
||||||
sample = LIRC_TIMEOUT(ev.duration);
|
sample = LIRC_TIMEOUT(ev.duration);
|
||||||
dev_dbg(&dev->dev, "timeout report (duration: %d)\n", sample);
|
dev_dbg(&dev->dev, "timeout report (duration: %d)\n", sample);
|
||||||
|
|
||||||
/* Normal sample */
|
/* Normal sample */
|
||||||
} else {
|
} else {
|
||||||
if (dev->gap) {
|
if (dev->gap_start) {
|
||||||
dev->gap_duration += ktime_to_us(ktime_sub(ktime_get(),
|
u64 duration = ktime_us_delta(ktime_get(),
|
||||||
dev->gap_start));
|
dev->gap_start);
|
||||||
|
|
||||||
/* Cap by LIRC_VALUE_MASK */
|
/* Cap by LIRC_VALUE_MASK */
|
||||||
dev->gap_duration = min_t(u64, dev->gap_duration,
|
duration = min_t(u64, duration, LIRC_VALUE_MASK);
|
||||||
LIRC_VALUE_MASK);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->lirc_fh_lock, flags);
|
spin_lock_irqsave(&dev->lirc_fh_lock, flags);
|
||||||
list_for_each_entry(fh, &dev->lirc_fh, list)
|
list_for_each_entry(fh, &dev->lirc_fh, list)
|
||||||
kfifo_put(&fh->rawir,
|
kfifo_put(&fh->rawir, LIRC_SPACE(duration));
|
||||||
LIRC_SPACE(dev->gap_duration));
|
|
||||||
spin_unlock_irqrestore(&dev->lirc_fh_lock, flags);
|
spin_unlock_irqrestore(&dev->lirc_fh_lock, flags);
|
||||||
dev->gap = false;
|
dev->gap_start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sample = ev.pulse ? LIRC_PULSE(ev.duration) :
|
sample = ev.pulse ? LIRC_PULSE(ev.duration) :
|
||||||
|
|
|
@ -130,9 +130,7 @@ struct lirc_fh {
|
||||||
* @tx_resolution: resolution (in us) of output sampler
|
* @tx_resolution: resolution (in us) of output sampler
|
||||||
* @lirc_dev: lirc device
|
* @lirc_dev: lirc device
|
||||||
* @lirc_cdev: lirc char cdev
|
* @lirc_cdev: lirc char cdev
|
||||||
* @gap_start: time when gap starts
|
* @gap_start: start time for gap after timeout if non-zero
|
||||||
* @gap_duration: duration of initial gap
|
|
||||||
* @gap: true if we're in a gap
|
|
||||||
* @lirc_fh_lock: protects lirc_fh list
|
* @lirc_fh_lock: protects lirc_fh list
|
||||||
* @lirc_fh: list of open files
|
* @lirc_fh: list of open files
|
||||||
* @registered: set to true by rc_register_device(), false by
|
* @registered: set to true by rc_register_device(), false by
|
||||||
|
@ -201,8 +199,6 @@ struct rc_dev {
|
||||||
struct device lirc_dev;
|
struct device lirc_dev;
|
||||||
struct cdev lirc_cdev;
|
struct cdev lirc_cdev;
|
||||||
ktime_t gap_start;
|
ktime_t gap_start;
|
||||||
u64 gap_duration;
|
|
||||||
bool gap;
|
|
||||||
spinlock_t lirc_fh_lock;
|
spinlock_t lirc_fh_lock;
|
||||||
struct list_head lirc_fh;
|
struct list_head lirc_fh;
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче