From patchwork Mon Apr 21 20:00:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Gynther X-Patchwork-Id: 4026091 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B7A879F1F4 for ; Mon, 21 Apr 2014 20:00:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0057202B8 for ; Mon, 21 Apr 2014 20:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D28D620270 for ; Mon, 21 Apr 2014 20:00:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754467AbaDUUAY (ORCPT ); Mon, 21 Apr 2014 16:00:24 -0400 Received: from mail-qc0-f202.google.com ([209.85.216.202]:62570 "EHLO mail-qc0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754435AbaDUUAK (ORCPT ); Mon, 21 Apr 2014 16:00:10 -0400 Received: by mail-qc0-f202.google.com with SMTP id m20so790054qcx.1 for ; Mon, 21 Apr 2014 13:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:message-id:date; bh=cZT/n2wMOuSTzbwdehF6XyqU0AxmH8QGFUOhKw5+S6Q=; b=QhnspQxj3riS12AxQdHxqKqQIyBKlQ2obslkPYOM+qADGfFKaygNY0VZORbVrToPvp SwGqxShF0sTwrqdCtffogVmkvEy5Rt76qVX0eBVlbk3438KpvVZGbEGV2VwDrYfM/JZM izjiVzmGhDt3MPKrC8VAROYGCu8UeyH75iYgYi41BtqZeMbhZp8bv82ARASuccSnNY6g R/CZPwVavT/Q8CbUxri6y3tzzJn1Uy/V6/S4+Gr4c2Gqs3eemsCwAv7sNt1G2KhMionJ rQju82H2rkAYFzWpXyO7QlydDk+/KNC+dqjSMdDbbbE8WrnuQSFaQMPNw5ZZE1M3mURB 0Xog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:message-id:date; bh=cZT/n2wMOuSTzbwdehF6XyqU0AxmH8QGFUOhKw5+S6Q=; b=lmZVxax03zxq3QwBC3ZrRKrfhboiwbyNL0ncK4UQGT/zJBPyhd787xUFnn8v8a6mi3 LRHWKRQB3W7lZbISlIXaxGrDRJJhcfglhNIbz23t3VC340J8UUmmjd1Ml+vOj6SFSmCd U/UtznBRMhHTeF/wfohsmLV7eY11xqFn5xDnE0D1miKMgylVVpLeT/j4qcY+rPJWQn5+ mZGjB3MBYSKPZRpesQdgJPT318Hljbq6j4eoZjygDIIm2hPr2SDeZ94JqlNEC68mdMui 64JD3oVpE6Ct9nXBJbk92jT3MltHreN9Y6yBJEOVuG1D0EB9uMQ9o+4UsA6KE6j8IHba 7XQQ== X-Gm-Message-State: ALoCoQkE3nbhM7UPLIEYw8KGE8FG5g4QWQpGrCcaZAEH4V7O15Xjk2OMrcP8MBN5lL5LfkUQvjPQrQ7PaRl7w0DXo44DjtkHzdeeczzCkol5JWGYXo5XojvFwxL06S1vdOikL/2T9dbyG+RnjUELgTKrTW83V+QaChtz+zJhvdV8YKz+aYlrV29tt151BQnjW+k0ClrjL/5tpxwm0doNW8MhsdlbRSBQuQ== X-Received: by 10.58.141.200 with SMTP id rq8mr20524716veb.31.1398110409698; Mon, 21 Apr 2014 13:00:09 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id g21si5307043yhe.3.2014.04.21.13.00.09 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Apr 2014 13:00:09 -0700 (PDT) Received: from puck.mtv.corp.google.com (puck.mtv.corp.google.com [172.27.88.166]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 3BDF85A4121; Mon, 21 Apr 2014 13:00:09 -0700 (PDT) Received: by puck.mtv.corp.google.com (Postfix, from userid 68020) id CBC0F1007B4; Mon, 21 Apr 2014 13:00:08 -0700 (PDT) From: Petri Gynther To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com Subject: [PATCH] Input: Add REP_MAX_COUNT to autorepeat parameters Message-Id: <20140421200008.CBC0F1007B4@puck.mtv.corp.google.com> Date: Mon, 21 Apr 2014 13:00:08 -0700 (PDT) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add REP_MAX_COUNT to autorepeat parameters. This enables an input device to be configured for maximum autorepeat count, so that a keypress is not repeated forever. This is important for Bluetooth keyboards and remote controls that may lose the Bluetooth link at any time, e.g. right after sending a key-down event but before sending the corresponding key-up event. Signed-off-by: Petri Gynther --- drivers/input/evdev.c | 11 ++++++++++- drivers/input/input.c | 6 +++++- include/linux/input.h | 1 + include/uapi/linux/input.h | 5 ++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index a06e125..be1887e 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -847,25 +847,34 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, return 0; case EVIOCGREP: + case EVIOCGREP_V2: if (!test_bit(EV_REP, dev->evbit)) return -ENOSYS; if (put_user(dev->rep[REP_DELAY], ip)) return -EFAULT; if (put_user(dev->rep[REP_PERIOD], ip + 1)) return -EFAULT; + if (cmd == EVIOCGREP_V2 && + put_user(dev->rep[REP_MAX_COUNT], ip + 2)) + return -EFAULT; return 0; case EVIOCSREP: + case EVIOCSREP_V2: if (!test_bit(EV_REP, dev->evbit)) return -ENOSYS; if (get_user(u, ip)) return -EFAULT; if (get_user(v, ip + 1)) return -EFAULT; + if (cmd == EVIOCSREP_V2 && get_user(t, ip + 2)) + return -EFAULT; input_inject_event(&evdev->handle, EV_REP, REP_DELAY, u); input_inject_event(&evdev->handle, EV_REP, REP_PERIOD, v); - + if (cmd == EVIOCSREP_V2) + input_inject_event(&evdev->handle, EV_REP, + REP_MAX_COUNT, t); return 0; case EVIOCRMFF: diff --git a/drivers/input/input.c b/drivers/input/input.c index 1c4c0db..a5314c5 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -78,6 +78,7 @@ static void input_start_autorepeat(struct input_dev *dev, int code) dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && dev->timer.data) { dev->repeat_key = code; + dev->repeat_count = 0; mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_DELAY])); } @@ -191,7 +192,8 @@ static void input_repeat_key(unsigned long data) input_pass_values(dev, vals, ARRAY_SIZE(vals)); - if (dev->rep[REP_PERIOD]) + if (dev->rep[REP_PERIOD] && (dev->rep[REP_MAX_COUNT] == 0 || + ++dev->repeat_count <= dev->rep[REP_MAX_COUNT])) mod_timer(&dev->timer, jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD])); } @@ -1640,6 +1642,7 @@ static void input_dev_toggle(struct input_dev *dev, bool activate) if (activate && test_bit(EV_REP, dev->evbit)) { dev->event(dev, EV_REP, REP_PERIOD, dev->rep[REP_PERIOD]); dev->event(dev, EV_REP, REP_DELAY, dev->rep[REP_DELAY]); + dev->event(dev, EV_REP, REP_MAX_COUNT, dev->rep[REP_MAX_COUNT]); } } @@ -2110,6 +2113,7 @@ int input_register_device(struct input_dev *dev) dev->timer.function = input_repeat_key; dev->rep[REP_DELAY] = 250; dev->rep[REP_PERIOD] = 33; + dev->rep[REP_MAX_COUNT] = 0; } if (!dev->getkeycode) diff --git a/include/linux/input.h b/include/linux/input.h index 82ce323..5f98714 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -151,6 +151,7 @@ struct input_dev { struct ff_device *ff; unsigned int repeat_key; + unsigned int repeat_count; struct timer_list timer; int rep[REP_CNT]; diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index bd24470..d7e08ff 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -100,7 +100,9 @@ struct input_keymap_entry { #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ #define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ +#define EVIOCGREP_V2 _IOR('E', 0x03, unsigned int[3]) #define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */ +#define EVIOCSREP_V2 _IOW('E', 0x03, unsigned int[3]) #define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */ #define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry) @@ -900,7 +902,8 @@ struct input_keymap_entry { #define REP_DELAY 0x00 #define REP_PERIOD 0x01 -#define REP_MAX 0x01 +#define REP_MAX_COUNT 0x02 +#define REP_MAX 0x02 #define REP_CNT (REP_MAX+1) /*