All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
To: linux-mips@linux-mips.org, James.Hogan@imgtec.com,
	Paul.Burton@imgtec.com
Cc: Raghu.Gandham@imgtec.com, Leonid.Yegoshin@imgtec.com,
	Douglas.Leung@imgtec.com, Petar.Jovanovic@imgtec.com,
	Miodrag.Dinic@imgtec.com, Goran.Ferenc@imgtec.com
Subject: [PATCH 6/8] input: goldfish: Fix multitouch event handling
Date: Mon, 19 Jun 2017 17:50:13 +0200	[thread overview]
Message-ID: <1497887415-13825-7-git-send-email-aleksandar.markovic@rt-rk.com> (raw)
In-Reply-To: <1497887415-13825-1-git-send-email-aleksandar.markovic@rt-rk.com>

From: Lingfeng Yang <lfy@google.com>

Register Goldfish Events device properly as a multitouch device,
and send SYN_REPORT event in appropriate cases only.

If SYN_REPORT is sent on every single multitouch event, it breaks
the multitouch. The multitouch becomes janky and having to click
2-3 times to do stuff (plus randomly activating notification bars
when not clicking). If these SYN_REPORT events are supressed,
multitouch will work fine, plus the events will have a protocol
that looks nice.

In addition, Goldfish Events device needs to be registerd as a
multitouch 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, casusing touches with more than one finger
not to work properly.

Signed-off-by: Lingfeng Yang <lfy@google.com>
Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
---
 drivers/input/keyboard/goldfish_events.c | 33 +++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/goldfish_events.c b/drivers/input/keyboard/goldfish_events.c
index f6e643b..6e0b8bb 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,22 @@ 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;
 }
 
@@ -155,6 +173,19 @@ 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 multitouch.
+	 *
+	 * In the Ranchu kernel, there is multitouch-specific code
+	 * for handling ABS_MT_SLOT events (see
+	 * drivers/input/input.c:input_handle_abs_event).
+	 * 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 multitouch with
+	 * more than one finger from working.
+	 */
+	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);
 	events_import_bits(edev, input_dev->relbit, EV_REL, REL_MAX);
-- 
2.7.4

  parent reply	other threads:[~2017-06-19 15:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19 15:50 [PATCH 0/8] MIPS: Miscellaneous fixes related to Android Mips emulator Aleksandar Markovic
2017-06-19 15:50 ` [PATCH 1/8] MIPS: cmdline: Add support for 'memmap' parameter Aleksandar Markovic
2017-06-19 15:50 ` [PATCH 2/8] MIPS: build: Fix "-modd-spreg" switch usage when compiling for mips32r6 Aleksandar Markovic
2017-06-19 15:50 ` [PATCH 3/8] MIPS: R6: Fix PREF instruction usage by memcpy for MIPS R6 Aleksandar Markovic
2017-06-20  8:04   ` Matt Redfearn
2017-06-20  8:04     ` Matt Redfearn
2017-06-28  0:58     ` Ralf Baechle
2017-06-28  1:35       ` Maciej W. Rozycki
2017-06-28  1:35         ` Maciej W. Rozycki
     [not found]         ` <9915e476-70fe-4281-a1e4-85ca2e8683b3@imgtec.com>
2017-06-28  2:36           ` Maciej W. Rozycki
2017-06-28  8:34             ` Ralf Baechle
2017-06-28 11:23               ` Maciej W. Rozycki
2017-06-19 15:50 ` [PATCH 4/8] MIPS: unaligned: Add DSP lwx & lhx missaligned access support Aleksandar Markovic
2017-06-19 15:50 ` [PATCH 5/8] MIPS: math-emu: Handle zero accumulator case in MADDF and MSUBF separately Aleksandar Markovic
2017-06-19 15:50 ` Aleksandar Markovic [this message]
2017-06-19 15:50 ` [PATCH 7/8] tty: goldfish: Use streaming DMA for r/w operations on Ranchu platforms Aleksandar Markovic
2017-06-19 15:50 ` [PATCH 8/8] tty: goldfish: Implement support for kernel 'earlycon' parameter Aleksandar Markovic

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=1497887415-13825-7-git-send-email-aleksandar.markovic@rt-rk.com \
    --to=aleksandar.markovic@rt-rk.com \
    --cc=Douglas.Leung@imgtec.com \
    --cc=Goran.Ferenc@imgtec.com \
    --cc=James.Hogan@imgtec.com \
    --cc=Leonid.Yegoshin@imgtec.com \
    --cc=Miodrag.Dinic@imgtec.com \
    --cc=Paul.Burton@imgtec.com \
    --cc=Petar.Jovanovic@imgtec.com \
    --cc=Raghu.Gandham@imgtec.com \
    --cc=linux-mips@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.