From 2940c7e49775ea2d83c9a8c1ea1e37c4f584ee6c Mon Sep 17 00:00:00 2001 From: Sean Young Date: Fri, 2 Dec 2016 15:16:11 -0200 Subject: [PATCH] [media] serial_ir: generate timeout No timeout is generated by serial_ir since the port only generates interrupts on edges. Some IR protocols like rc6 and rc5 need a trailing space or timeout so they know there are no more bits coming. Without it, the current key will only be reported once some more IR occurs. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/rc/serial_ir.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c index 436bd58b5f05..2cb6471641bd 100644 --- a/drivers/media/rc/serial_ir.c +++ b/drivers/media/rc/serial_ir.c @@ -137,6 +137,7 @@ struct serial_ir { ktime_t lastkt; struct rc_dev *rcdev; struct platform_device *pdev; + struct timer_list timeout_timer; unsigned int freq; unsigned int duty_cycle; @@ -395,9 +396,14 @@ static irqreturn_t serial_ir_irq_handler(int i, void *blah) frbwrite(data, !(dcd ^ sense)); serial_ir.lastkt = kt; last_dcd = dcd; - ir_raw_event_handle(serial_ir.rcdev); } } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */ + + mod_timer(&serial_ir.timeout_timer, + jiffies + nsecs_to_jiffies(serial_ir.rcdev->timeout)); + + ir_raw_event_handle(serial_ir.rcdev); + return IRQ_HANDLED; } @@ -471,6 +477,16 @@ static int hardware_init_port(void) return 0; } +static void serial_ir_timeout(unsigned long arg) +{ + DEFINE_IR_RAW_EVENT(ev); + + ev.timeout = true; + ev.duration = serial_ir.rcdev->timeout; + ir_raw_event_store_with_filter(serial_ir.rcdev, &ev); + ir_raw_event_handle(serial_ir.rcdev); +} + static int serial_ir_probe(struct platform_device *dev) { int i, nlow, nhigh, result; @@ -500,6 +516,9 @@ static int serial_ir_probe(struct platform_device *dev) return -EBUSY; } + setup_timer(&serial_ir.timeout_timer, serial_ir_timeout, + (unsigned long)&serial_ir); + result = hardware_init_port(); if (result < 0) return result; @@ -781,7 +800,9 @@ static int __init serial_ir_init_module(void) rcdev->allowed_protocols = RC_BIT_ALL; rcdev->driver_name = KBUILD_MODNAME; rcdev->map_name = RC_MAP_RC6_MCE; + rcdev->min_timeout = 1; rcdev->timeout = IR_DEFAULT_TIMEOUT; + rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT; rcdev->rx_resolution = 250000; serial_ir.rcdev = rcdev; @@ -797,6 +818,7 @@ serial_cleanup: static void __exit serial_ir_exit_module(void) { + del_timer_sync(&serial_ir.timeout_timer); rc_unregister_device(serial_ir.rcdev); serial_ir_exit(); } -- 2.20.1