From patchwork Tue Mar 6 17:41:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Reichl X-Patchwork-Id: 10262347 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 BF7336055D for ; Tue, 6 Mar 2018 17:49:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF6D828B53 for ; Tue, 6 Mar 2018 17:49:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A21FD290B1; Tue, 6 Mar 2018 17:49:56 +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=unavailable 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 A50FE28B53 for ; Tue, 6 Mar 2018 17:49:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753504AbeCFRty (ORCPT ); Tue, 6 Mar 2018 12:49:54 -0500 Received: from mail.horus.com ([78.46.148.228]:47665 "EHLO mail.horus.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753243AbeCFRtx (ORCPT ); Tue, 6 Mar 2018 12:49:53 -0500 X-Greylist: delayed 508 seconds by postgrey-1.27 at vger.kernel.org; Tue, 06 Mar 2018 12:49:53 EST Received: from [192.168.1.20] (194-118-234-107.adsl.highway.telekom.at [194.118.234.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "E-Mail Matthias Reichl", Issuer "HiassofT CA 2014" (verified OK)) by mail.horus.com (Postfix) with ESMTPS id 7A1376408F; Tue, 6 Mar 2018 18:41:23 +0100 (CET) Received: by camel2.lan (Postfix, from userid 1000) id 4A4FF1C767A; Tue, 6 Mar 2018 18:41:22 +0100 (CET) From: Matthias Reichl To: Sean Young , Mauro Carvalho Chehab , Carlo Caione , Kevin Hilman Cc: Heiner Kallweit , Neil Armstrong , Alex Deryskyba , Jonas Karlman , linux-media@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH] media: rc: meson-ir: add timeout on idle Date: Tue, 6 Mar 2018 18:41:22 +0100 Message-Id: <20180306174122.6017-1-hias@horus.com> X-Mailer: git-send-email 2.11.0 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 Meson doesn't seem to be able to generate timeout events in hardware. So install a software timer to generate the timeout events required by the decoders to prevent "ghost keypresses". Signed-off-by: Matthias Reichl --- drivers/media/rc/meson-ir.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c index f2204eb77e2a..f34c5836412b 100644 --- a/drivers/media/rc/meson-ir.c +++ b/drivers/media/rc/meson-ir.c @@ -69,6 +69,7 @@ struct meson_ir { void __iomem *reg; struct rc_dev *rc; spinlock_t lock; + struct timer_list timeout_timer; }; static void meson_ir_set_mask(struct meson_ir *ir, unsigned int reg, @@ -98,6 +99,10 @@ static irqreturn_t meson_ir_irq(int irqno, void *dev_id) rawir.pulse = !!(status & STATUS_IR_DEC_IN); ir_raw_event_store(ir->rc, &rawir); + + mod_timer(&ir->timeout_timer, + jiffies + nsecs_to_jiffies(ir->rc->timeout)); + ir_raw_event_handle(ir->rc); spin_unlock(&ir->lock); @@ -105,6 +110,17 @@ static irqreturn_t meson_ir_irq(int irqno, void *dev_id) return IRQ_HANDLED; } +static void meson_ir_timeout_timer(struct timer_list *t) +{ + struct meson_ir *ir = from_timer(ir, t, timeout_timer); + DEFINE_IR_RAW_EVENT(rawir); + + rawir.timeout = true; + rawir.duration = ir->rc->timeout; + ir_raw_event_store(ir->rc, &rawir); + ir_raw_event_handle(ir->rc); +} + static int meson_ir_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -145,7 +161,9 @@ static int meson_ir_probe(struct platform_device *pdev) ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY; ir->rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; ir->rc->rx_resolution = US_TO_NS(MESON_TRATE); + ir->rc->min_timeout = 1; ir->rc->timeout = MS_TO_NS(200); + ir->rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT; ir->rc->driver_name = DRIVER_NAME; spin_lock_init(&ir->lock); @@ -157,6 +175,8 @@ static int meson_ir_probe(struct platform_device *pdev) return ret; } + timer_setup(&ir->timeout_timer, meson_ir_timeout_timer, 0); + ret = devm_request_irq(dev, irq, meson_ir_irq, 0, NULL, ir); if (ret) { dev_err(dev, "failed to request irq\n"); @@ -198,6 +218,8 @@ static int meson_ir_remove(struct platform_device *pdev) meson_ir_set_mask(ir, IR_DEC_REG1, REG1_ENABLE, 0); spin_unlock_irqrestore(&ir->lock, flags); + del_timer_sync(&ir->timeout_timer); + return 0; }