linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan <alan@linux.intel.com>
To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: [PATCH 3/3] goldfish: multitouch: no extra EV_SYN
Date: Fri, 26 Feb 2016 18:50:21 +0000	[thread overview]
Message-ID: <20160226185007.3539.83946.stgit@localhost.localdomain> (raw)
In-Reply-To: <20160226184908.3539.48691.stgit@localhost.localdomain>

From: Lingfeng Yang <lfy@google.com>

If we send SYN_REPORT on every single multi-touch event, it breaks the
multi-touch.

The multi-touch becomes jerky and you have to click 2-3 times to do things
while randomly activating notification bars when not clicking.

If we suppress these SYN_REPORTS, multi-touch will work fine and the events
will have a protocol that looks nice.

We need to register Goldfish Events as a multi-touch device by issuing
input_mt_init_slots, otherwise input_handle_abs_event in drivers/input/input.c
will silently drop all ABS_MT_SLOT events, causing touches of more than one
finger to fail.

Signed-off-by: Lingfeng Yang <lfy@google.com>
Signed-off-by: Jin Qian <jinqian@android.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
 drivers/input/keyboard/goldfish_events.c |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/goldfish_events.c b/drivers/input/keyboard/goldfish_events.c
index c7e308a..c0d77b7 100644
--- a/drivers/input/keyboard/goldfish_events.c
+++ b/drivers/input/keyboard/goldfish_events.c
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/types.h>
 #include <linux/input.h>
+#include <linux/input/mt.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
@@ -24,6 +25,8 @@
 #include <linux/io.h>
 #include <linux/acpi.h>
 
+#define GOLDFISH_MAX_FINGERS 5
+
 enum {
 	REG_READ        = 0x00,
 	REG_SET_PAGE    = 0x00,
@@ -52,7 +55,23 @@ static irqreturn_t events_interrupt(int irq, void *dev_id)
 	value = __raw_readl(edev->addr + REG_READ);
 
 	input_event(edev->input, type, code, value);
-	input_sync(edev->input);
+	/*
+	 * Send an extra (EV_SYN, SYN_REPORT, 0x0) event
+	 * if a key was pressed. Some keyboard device
+	 * drivers may only send the EV_KEY event and
+	 * not EV_SYN.
+	 * Note that sending an extra SYN_REPORT is not
+	 * necessary nor correct protocol with other
+	 * devices such as touchscreens, which will send
+	 * their own SYN_REPORT's when sufficient event
+	 * information has been collected (e.g., for
+	 * touchscreens, when pressure and X/Y coordinates
+	 * have been received). Hence, we will only send
+	 * this extra SYN_REPORT if type == EV_KEY.
+	 */
+	if (type == EV_KEY)
+		input_sync(edev->input);
+
 	return IRQ_HANDLED;
 }
 
@@ -154,6 +173,15 @@ static int events_probe(struct platform_device *pdev)
 
 	input_dev->name = edev->name;
 	input_dev->id.bustype = BUS_HOST;
+	/*
+	 * Set the Goldfish Device to be multi-touch.
+	 * If we do not issue input_mt_init_slots,
+	 * the kernel will filter out needed ABS_MT_SLOT
+	 * events when we touch the screen in more than one place,
+	 * preventing multi-touch with more than one finger from working.
+	 * See drivers/input/input.c:input_handle_abs_event.
+	 */
+	input_mt_init_slots(input_dev, GOLDFISH_MAX_FINGERS, 0);
 
 	events_import_bits(edev, input_dev->evbit, EV_SYN, EV_MAX);
 	events_import_bits(edev, input_dev->keybit, EV_KEY, KEY_MAX);


  parent reply	other threads:[~2016-02-26 18:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26 18:49 [PATCH 1/3] input: goldfish_events: add devicetree bindings Alan
2016-02-26 18:49 ` [PATCH 2/3] goldfish: Enable ACPI-based enumeration for goldfish events Alan
2016-02-26 20:06   ` Dmitry Torokhov
2016-02-26 18:50 ` Alan [this message]
2016-02-26 19:57   ` [PATCH 3/3] goldfish: multitouch: no extra EV_SYN Dmitry Torokhov
2016-03-01 23:27     ` Alan Cox
2016-02-26 20:05 ` [PATCH 1/3] input: goldfish_events: add devicetree bindings Dmitry Torokhov

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=20160226185007.3539.83946.stgit@localhost.localdomain \
    --to=alan@linux.intel.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.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).