From patchwork Tue Oct 13 23:34:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Gynther X-Patchwork-Id: 7389561 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 617BCBEEA4 for ; Tue, 13 Oct 2015 23:35:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 554032098D for ; Tue, 13 Oct 2015 23:35:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 659A420987 for ; Tue, 13 Oct 2015 23:35:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751924AbbJMXfE (ORCPT ); Tue, 13 Oct 2015 19:35:04 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34185 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751476AbbJMXfC (ORCPT ); Tue, 13 Oct 2015 19:35:02 -0400 Received: by pabws5 with SMTP id ws5so3860726pab.1 for ; Tue, 13 Oct 2015 16:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Bbhkvdys+vEuMTENJWbvPVAzlJBDwhGQ5vKoTj+2flI=; b=ZTYE8JEtZ8YvnR9gJKP1xfu5LeumVzaNslSpePo6alJZweuuRrmcCnca00l+qsod8E V6GXo0Wb2mIpMwVE5ZsXyQEoJiPOsZNS7e4+kyTTvcYZ7hKpgEzzqslZ7ZTGIttAJjYd YCdAOWsvOp2HPrMxQ4XVGS3+399dlKwVNgGeZ+dh9pqFz/IBy6TeZ4FggHGocFpnkbNX 3rMFdccx48rLUakyG3fBLiIDPy0/zMzu445xHU3P5wIsrVHlU4ak/xy0GKza2wcw9xhm 4O/WwKYeO4+W0vsxD2WoGSbVaW3/cdkodSj07ufGDRMAtT2Kz3845rmmYvRjYo+zW8gP tQ1A== 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:date:message-id; bh=Bbhkvdys+vEuMTENJWbvPVAzlJBDwhGQ5vKoTj+2flI=; b=kpnh4Btjlo6saBn69Gl68OwqQW2ERAE/Wx60h4Vu/iQw7k56ANDS1l06k+yTeKbio0 958OCAtkcO82SQJzb8EzmWKYiCdi74ceLn9hHe8tZzBJDhIS6KG6y/Fp57U1tsFp9nCt zR1T0X5iQMXI6uMfkd1QxwVySvPU9DaG+CjuZDHMGOvQArobWrJ4BCJXP422gc4t6Mae 8pEzRn9XG4vBO61wp+bmmX6QjaQ7jkp8ag/s7KyL5Xp4LEvpi+2ArnWAD3Eup4tr9xWy R6CHv8/6wEhriLnWpxYSqclZvW34nTUz0eANchE+GpLQRantiT6+SXXIExHGk2XHWaiu 4+uw== X-Gm-Message-State: ALoCoQlOH7T48eEK7C/AgY/7Z5hREgNrgE2bquuXCviAFRzmUX4tScxF8jA6Nng7lTE9OM+4lAnR X-Received: by 10.66.119.201 with SMTP id kw9mr137382pab.64.1444779302430; Tue, 13 Oct 2015 16:35:02 -0700 (PDT) Received: from pgynther-desktop.mtv.corp.google.com ([172.27.88.51]) by smtp.gmail.com with ESMTPSA id w8sm5847501pbs.87.2015.10.13.16.35.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Oct 2015 16:35:01 -0700 (PDT) From: Petri Gynther To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Petri Gynther Subject: [PATCH v3] Input: improve autorepeat initialization Date: Tue, 13 Oct 2015 16:34:37 -0700 Message-Id: <1444779277-13216-1-git-send-email-pgynther@google.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, 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 new function input_enable_softrepeat() that allows drivers to initialize their own values for input_dev->rep[REP_DELAY] and input_dev->rep[REP_PERIOD], but also use the software autorepeat functionality from input.c. For example, a HID driver could do: static void xyz_input_configured(struct hid_device *hid, struct hid_input *hidinput) { input_enable_softrepeat(hidinput->input, 400, 100); } static struct hid_driver xyz_driver = { .input_configured = xyz_input_configured, } Signed-off-by: Petri Gynther --- drivers/input/input.c | 25 +++++++++++++++++++------ include/linux/input.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index 5391abd..8806059 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -2045,6 +2045,23 @@ static void devm_input_device_unregister(struct device *dev, void *res) } /** + * input_enable_softrepeat - enable software autorepeat + * @dev: input device + * @delay: repeat delay + * @period: repeat period + * + * Enable software autorepeat on the input device. + */ +void input_enable_softrepeat(struct input_dev *dev, int delay, int period) +{ + dev->timer.data = (unsigned long) dev; + dev->timer.function = input_repeat_key; + dev->rep[REP_DELAY] = delay; + dev->rep[REP_PERIOD] = period; +} +EXPORT_SYMBOL(input_enable_softrepeat); + +/** * input_register_device - register device with input core * @dev: device to be registered * @@ -2108,12 +2125,8 @@ int input_register_device(struct input_dev *dev) * If delay and period are pre-set by the driver, then autorepeating * is handled by the driver itself and we don't do it in input.c. */ - if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) { - dev->timer.data = (long) dev; - dev->timer.function = input_repeat_key; - dev->rep[REP_DELAY] = 250; - dev->rep[REP_PERIOD] = 33; - } + if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) + input_enable_softrepeat(dev, 250, 33); if (!dev->getkeycode) dev->getkeycode = input_default_getkeycode; diff --git a/include/linux/input.h b/include/linux/input.h index 82ce323..1e96769 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -469,6 +469,8 @@ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke); int input_set_keycode(struct input_dev *dev, const struct input_keymap_entry *ke); +void input_enable_softrepeat(struct input_dev *dev, int delay, int period); + extern struct class input_class; /**