]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: rc: mce_kbd decoder: low timeout values cause double keydowns
authorSean Young <sean@mess.org>
Sun, 25 Mar 2018 15:45:40 +0000 (11:45 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Aug 2018 05:48:00 +0000 (07:48 +0200)
[ Upstream commit c421c62a4a08aba220ad7176ef4aa4b0ced9480a ]

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 <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/rc/ir-mce_kbd-decoder.c

index 5478fe08f9d321eda20876ca1d05ca5c3706c2c2..d94f1c190f62f44a2a2cae4477df913e0f4c61c0 100644 (file)
@@ -324,11 +324,13 @@ again:
                        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;