From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
Cc: linux-mips@linux-mips.org, Lingfeng Yang <lfy@google.com>,
Miodrag Dinic <miodrag.dinic@imgtec.com>,
Goran Ferenc <goran.ferenc@imgtec.com>,
Aleksandar Markovic <aleksandar.markovic@imgtec.com>,
Douglas Leung <douglas.leung@imgtec.com>,
Henrik Rydberg <rydberg@bitmath.org>,
James Hogan <james.hogan@imgtec.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Paul Burton <paul.burton@imgtec.com>,
Petar Jovanovic <petar.jovanovic@imgtec.com>,
Raghu Gandham <raghu.gandham@imgtec.com>
Subject: Re: [PATCH v2 5/7] input: goldfish: Fix multitouch event handling
Date: Thu, 29 Jun 2017 11:58:35 -0700 [thread overview]
Message-ID: <20170629185835.GB38388@dtor-ws> (raw)
In-Reply-To: <1498665399-29007-6-git-send-email-aleksandar.markovic@rt-rk.com>
On Wed, Jun 28, 2017 at 05:56:29PM +0200, Aleksandar Markovic wrote:
> 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).
This sounds like a deficiency in protocol handling in userspace. Given
that input core can suppress duplicate events userpsace mught very well
only see one ABS_X followed by SYN_REPORT if Y coordinate did not change
or was suppressed by jitter detection.
> 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.
Can they be fixed?
> + *
> + * 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);
Ideally we would not be sending synthetic EV_SYN at all...
> 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);
This needs error handling. Also, can the backend communicate number of
slots so the userspace has better idea about the capabilities of the
device?
> +
> 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
>
Thanks.
--
Dmitry
next prev parent reply other threads:[~2017-06-29 18:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1498665399-29007-1-git-send-email-aleksandar.markovic@rt-rk.com>
2017-06-28 15:56 ` [PATCH v2 5/7] input: goldfish: Fix multitouch event handling Aleksandar Markovic
2017-06-29 18:58 ` Dmitry Torokhov [this message]
2017-07-21 10:51 ` 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=20170629185835.GB38388@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=aleksandar.markovic@imgtec.com \
--cc=aleksandar.markovic@rt-rk.com \
--cc=douglas.leung@imgtec.com \
--cc=goran.ferenc@imgtec.com \
--cc=james.hogan@imgtec.com \
--cc=lfy@google.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=miodrag.dinic@imgtec.com \
--cc=paul.burton@imgtec.com \
--cc=petar.jovanovic@imgtec.com \
--cc=raghu.gandham@imgtec.com \
--cc=rydberg@bitmath.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).