From patchwork Fri Dec 2 17:16:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 9458903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8831460515 for ; Fri, 2 Dec 2016 17:17:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 709A72858E for ; Fri, 2 Dec 2016 17:17:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62A6428590; Fri, 2 Dec 2016 17:17:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD2242858E for ; Fri, 2 Dec 2016 17:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751990AbcLBRRK (ORCPT ); Fri, 2 Dec 2016 12:17:10 -0500 Received: from gofer.mess.org ([80.229.237.210]:45609 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282AbcLBRRJ (ORCPT ); Fri, 2 Dec 2016 12:17:09 -0500 Received: by gofer.mess.org (Postfix, from userid 1000) id 305CF60A75; Fri, 2 Dec 2016 17:16:15 +0000 (GMT) From: Sean Young To: linux-media@vger.kernel.org Subject: [PATCH 5/8] [media] serial_ir: generate timeout Date: Fri, 2 Dec 2016 17:16:11 +0000 Message-Id: <1480698974-9093-5-git-send-email-sean@mess.org> X-Mailer: git-send-email 2.1.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 436bd58..2cb6471 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 @@ static int __init serial_ir_init_module(void) static void __exit serial_ir_exit_module(void) { + del_timer_sync(&serial_ir.timeout_timer); rc_unregister_device(serial_ir.rcdev); serial_ir_exit(); }