From patchwork Mon Oct 12 19:04:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Gynther X-Patchwork-Id: 7378561 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 1C259BEEA4 for ; Mon, 12 Oct 2015 19:05:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 431CD20656 for ; Mon, 12 Oct 2015 19:05:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5338C205EF for ; Mon, 12 Oct 2015 19:05:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751049AbbJLTFf (ORCPT ); Mon, 12 Oct 2015 15:05:35 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:34453 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751677AbbJLTFe (ORCPT ); Mon, 12 Oct 2015 15:05:34 -0400 Received: by padhy16 with SMTP id hy16so160885438pad.1 for ; Mon, 12 Oct 2015 12:05:34 -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=muWKWBmKpT+xP4uVxt6H4i1GKI1Qf/5ZhymzumgvmF0=; b=RnOQwh6CfBgKnlpSFbX2YjhVyCqDLAdL5OuVY+zm7THaVGlCZdu9NQTjlX+RJeVkgl q6yGX/AZJZqyieP6K7JDPPKD3BjcSnIvp7gHueExPNfUfF3TQeIFtkrkgYgsBX+Ysmb9 A/qamcgKpmzsr71MpP/NKj14euwn6ibE5JK5sVOrIWWwNsGwxu324zlM3MzyF+3wm2uM nUHMCDphZhk0n7TTGv4wBhuX5t/ohMs/Ugf+Uyy/XUcwvLsQx1W7QpshixZk8cpAtgwE K0y1fPhSRGF+CgH1pqqz/PAcITVXTDMl7xXoYcbjokSSTY66Na+5eaCoZfyRHU6rfiJV 2tEg== 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=muWKWBmKpT+xP4uVxt6H4i1GKI1Qf/5ZhymzumgvmF0=; b=T2VsTadXLXdGg3QxfLLkV/OZDuvKaKH6z1k4DKl/rVN9Ar4z3GBD+QHOTrhrDFlatz ISVNqm8SPrGOWf9DppdKZ77VqgphX3F4IxHk/8pdX30eE0cK6N4HQhehFG8mo4WZ2DxV csWfm92BqR9YwuoqB7dLiuJIKp1OkVFxheFt/2NV4hUV1sUjbmfXOe5QPxymYIkdsIMb BVNyrU5of0RDGPe//B42F2DsZqKb2ER46B7/BdjEKq8CCXX5zO7tELkKzL0PD9atAOGW HwxOhIsfPcxUbUUujEGuYWaaObA/LqmBlFHVQ4cZ1MXeqtjYAZMal5+5dyGs8eNpkbb4 8uVQ== X-Gm-Message-State: ALoCoQnTD6nJrXKkHtFKeAYTyYW41Plb9gQR/ZOKawEx+8qfJtZA6f8lm7kKANnwT/ppp1vdZd+u X-Received: by 10.67.30.136 with SMTP id ke8mr36411429pad.16.1444676734338; Mon, 12 Oct 2015 12:05:34 -0700 (PDT) Received: from pgynther-desktop.mtv.corp.google.com ([172.27.88.51]) by smtp.gmail.com with ESMTPSA id yz3sm9522660pbb.37.2015.10.12.12.05.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 12:05:32 -0700 (PDT) From: Petri Gynther To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Petri Gynther Subject: [PATCH v2] Input: improve autorepeat initialization Date: Mon, 12 Oct 2015 12:04:46 -0700 Message-Id: <1444676686-26900-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 Allow driver to initialize its 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) { hidinput->input->rep[REP_DELAY] = 400; hidinput->input->rep[REP_PERIOD] = 100; hidinput->input->softrepeat = true; } static struct hid_driver xyz_driver = { .input_configured = xyz_input_configured, } Signed-off-by: Petri Gynther --- drivers/input/input.c | 9 +++++++-- include/linux/input.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index 5391abd..a6f65c7 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -2106,13 +2106,18 @@ 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. + * is handled by the driver itself and we don't do it in input.c + * unless the driver also requests softrepeat. */ if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD]) { - dev->timer.data = (long) dev; + dev->softrepeat = true; + dev->timer.data = (unsigned long) dev; dev->timer.function = input_repeat_key; dev->rep[REP_DELAY] = 250; dev->rep[REP_PERIOD] = 33; + } else if (dev->softrepeat) { + dev->timer.data = (unsigned long) dev; + dev->timer.function = input_repeat_key; } if (!dev->getkeycode) diff --git a/include/linux/input.h b/include/linux/input.h index 82ce323..2535948 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -150,6 +150,7 @@ struct input_dev { struct ff_device *ff; + bool softrepeat; unsigned int repeat_key; struct timer_list timer;