linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Hans Verkuil <hverkuil@xs4all.nl>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-input@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 2/3] input: handle case whether first repeated key triggers repeat
Date: Fri, 24 Nov 2017 11:44:00 +0000	[thread overview]
Message-ID: <e00a5bd5e87f011c92f7af5aac7e1654bf455cfb.1511523174.git.sean@mess.org> (raw)
In-Reply-To: <cover.1511523174.git.sean@mess.org>
In-Reply-To: <cover.1511523174.git.sean@mess.org>

In the CEC protocol, as soon as the first repeated key is received,
the autorepeat should start. We introduce a special value 3 for this
situation.

Signed-off-by: Sean Young <sean@mess.org>
---
 Documentation/input/input.rst |  4 +++-
 drivers/input/input.c         | 17 +++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/Documentation/input/input.rst b/Documentation/input/input.rst
index 47f86a4bf16c..31cea9026193 100644
--- a/Documentation/input/input.rst
+++ b/Documentation/input/input.rst
@@ -276,6 +276,8 @@ list is in include/uapi/linux/input-event-codes.h.
 
 ``value`` is the value the event carries. Either a relative change for
 EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
-release, 1 for keypress and 2 for autorepeat.
+release, 1 for keypress and 2 for autorepeat, and 3 for autorepeat where
+the repeats should start immediately, rather than waiting REP_DELAY
+milliseconds.
 
 See :ref:`input-event-codes` for more information about various even codes.
diff --git a/drivers/input/input.c b/drivers/input/input.c
index ecc41d65b82a..84182d7e5a6b 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -72,6 +72,16 @@ static int input_defuzz_abs_event(int value, int old_val, int fuzz)
 	return value;
 }
 
+static void input_start_autorepeat_now(struct input_dev *dev, int code)
+{
+	if (dev->rep[REP_PERIOD] && dev->timer.data &&
+	    !timer_pending(&dev->timer)) {
+		dev->repeat_key = code;
+		mod_timer(&dev->timer,
+			  jiffies + msecs_to_jiffies(dev->rep[REP_PERIOD]));
+	}
+}
+
 static void input_start_autorepeat(struct input_dev *dev, int code)
 {
 	if (dev->rep[REP_PERIOD] && dev->rep[REP_DELAY] && dev->timer.data) {
@@ -155,7 +165,10 @@ static void input_pass_values(struct input_dev *dev,
 	if (test_bit(EV_REP, dev->evbit) && test_bit(EV_KEY, dev->evbit)) {
 		for (v = vals; v != vals + count; v++) {
 			if (v->type == EV_KEY && v->value != 2) {
-				if (v->value)
+				if (v->value == 3)
+					input_start_autorepeat_now(dev,
+								   v->code);
+				else if (v->value)
 					input_start_autorepeat(dev, v->code);
 				else
 					input_stop_autorepeat(dev);
@@ -285,7 +298,7 @@ static int input_get_disposition(struct input_dev *dev,
 		if (is_event_supported(code, dev->keybit, KEY_MAX)) {
 
 			/* auto-repeat bypasses state updates */
-			if (value == 2) {
+			if (value == 2 || value == 3) {
 				disposition = INPUT_PASS_TO_HANDLERS;
 				break;
 			}
-- 
2.14.3

  parent reply	other threads:[~2017-11-24 11:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24 11:43 [PATCH 0/3] Improve CEC autorepeat handling Sean Young
2017-11-24 11:43 ` [PATCH 1/3] input: remove redundant check for EV_REP Sean Young
2017-11-24 11:44 ` Sean Young [this message]
2017-11-24 11:44 ` [PATCH 3/3] media: cec: move cec autorepeat handling to rc-core Sean Young
2017-11-25 23:47 ` [PATCH 0/3] Improve CEC autorepeat handling Dmitry Torokhov
2017-11-27  9:13   ` Hans Verkuil
2017-11-27  9:47     ` Sean Young
2017-11-27 10:01       ` Hans Verkuil
2017-11-27 10:11       ` Dmitry Torokhov
2017-11-27 15:43       ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e00a5bd5e87f011c92f7af5aac7e1654bf455cfb.1511523174.git.sean@mess.org \
    --to=sean@mess.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).