From patchwork Sun Apr 8 21:19:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 10328583 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 86F2C6053D for ; Sun, 8 Apr 2018 21:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7644028A24 for ; Sun, 8 Apr 2018 21:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 687B828A25; Sun, 8 Apr 2018 21:20:29 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F54B28A24 for ; Sun, 8 Apr 2018 21:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Q53E8uNEhebky9MXnRCQaG1ihZNBMjIWrg2IuWLa3pM=; b=Sx26vcvn6tO3qhdjgG3QLuJSGQ v6hIyddvtUHEd7xEQpJL3GM53QEGYhh3x20C8z27aEaAcCJxwOWEMVoRlcq99WVNDd6RyYPQJc15/ 9gYR5Cdrz+qXQkfHcTff1DMhxQlX6g4NGNcsABcSV4Y5RwO6YjYUS00OPabbshoGEJIpYevtGPd2x xL0xS3oA/xSZ+xIt/7ZLNfWTS+6feNtMi0co68jGu57XMdqbcjWVFG8p88FvsHz+bW4moH6xwmuxY xtbc7n90Nb8QsVQjk9p8o05OZ2mWHsiGEnJpjr7zzinVqBO64VhpUjFmHfjA/w/4EBi5rzooUHFuw n8/d5Njg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f5HjO-00038o-19; Sun, 08 Apr 2018 21:20:10 +0000 Received: from gofer.mess.org ([88.97.38.141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f5HjG-0002C9-II for linux-amlogic@lists.infradead.org; Sun, 08 Apr 2018 21:20:04 +0000 Received: by gofer.mess.org (Postfix, from userid 1000) id A9B0A60AC5; Sun, 8 Apr 2018 22:19:43 +0100 (BST) From: Sean Young To: linux-media@vger.kernel.org, Matthias Reichl Subject: [PATCH v2 4/7] media: rc: mce_kbd decoder: low timeout values cause double keydowns Date: Sun, 8 Apr 2018 22:19:39 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180408_142002_779515_DC5B993D X-CRM114-Status: GOOD ( 11.24 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonas Karlman , Kevin Hilman , Neil Armstrong , Carlo Caione , linux-amlogic@lists.infradead.org, Alex Deryskyba , Heiner Kallweit MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The mce keyboard repeats pressed keys every 100ms. If the IR timeout is set to less than that, we send key up events before the repeat arrives, so we have key up/key down for each IR repeat. The keyboard ends any sequence with a 0 scancode, in which case all keys are cleared so there is no need to run the timeout timer: it only exists for the case that the final 0 was not received. Signed-off-by: Sean Young --- drivers/media/rc/ir-mce_kbd-decoder.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c index ae4b980c4a16..230b9397aa11 100644 --- a/drivers/media/rc/ir-mce_kbd-decoder.c +++ b/drivers/media/rc/ir-mce_kbd-decoder.c @@ -322,11 +322,13 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev) scancode = data->body & 0xffff; dev_dbg(&dev->dev, "keyboard data 0x%08x\n", data->body); - if (dev->timeout) - delay = usecs_to_jiffies(dev->timeout / 1000); - else - delay = msecs_to_jiffies(100); - mod_timer(&data->rx_timeout, jiffies + delay); + if (scancode) { + delay = nsecs_to_jiffies(dev->timeout) + + msecs_to_jiffies(100); + mod_timer(&data->rx_timeout, jiffies + delay); + } else { + del_timer(&data->rx_timeout); + } /* Pass data to keyboard buffer parser */ ir_mce_kbd_process_keyboard_data(dev, scancode); lsc.rc_proto = RC_PROTO_MCIR2_KBD;