LKML Archive on lore.kernel.org
 help / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Joey Pabalinas <joeypabalinas@gmail.com>
Cc: "open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Jiri Kosina <jikos@kernel.org>,
	Daniel Martin <consume.noise@gmail.com>
Subject: Re: [PATCH 3/4] HID: multitouch: drop reports containing invalid values
Date: Tue, 3 Jul 2018 10:13:54 +0200
Message-ID: <CAO-hwJLPm2UgqYU7CgsqX1CNp5JjHu0mZJp-kZnPmZ2qhi1CxQ@mail.gmail.com> (raw)
In-Reply-To: <29ad484c1b357fd7fd670a6f252d097677b808f8.1530402641.git.joeypabalinas@gmail.com>

Hi Joey,

On Sun, Jul 1, 2018 at 2:19 AM, Joey Pabalinas <joeypabalinas@gmail.com> wrote:
> Avoid processing reports containing invalid values to reduce
> multitouch input stutter.
>
> Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
>
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index c0654db0b736543ca0..08b50e5908cecdda66 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -694,10 +694,19 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
>  {
>         if ((td->mtclass.quirks & MT_QUIRK_CONTACT_CNT_ACCURATE) &&
>             td->num_received >= td->num_expected)
>                 return;
>
> +       /* drop invalid values after counting them */
> +       if (td->curdata.x == 0xffff &&
> +                       td->curdata.y == 0xffff &&
> +                       td->curdata.w == 0xffff &&
> +                       td->curdata.h == 0xffff) {

You can't really use plain values like that. There is a tiny chance
these values are valid on an other device.
IIRC, MS spec says that we should ignore out of band values if they
are tagged as such. Such input are tagged with NULL values
(http://www.usb.org/developers/hidpage/HID1_11.pdf page 31) and MS
spec mentioned this.

All in all, if you have this bit set, you need to compare the value
with the logical_max/min for each field.

I never encountered a device that required this, so you are probably
the lucky one :)

Cheers,
Benjamin

> +               td->num_received++;
> +               return;
> +       }
> +
>         if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) {
>                 int active;
>                 int slotnum = mt_compute_slot(td, input);
>                 struct mt_slot *s = &td->curdata;
>                 struct input_mt *mt = input->mt;
> --
> 2.18.0
>

  reply index

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-01  0:19 [PATCH 0/4] reduce Surface Pro 3 multitouch jitter Joey Pabalinas
2018-07-01  0:19 ` [PATCH 1/4] HID: multitouch: add MT_QUIRK_NOT_SEEN_MEANS_UP to MT_CLS_WIN_8 quirks Joey Pabalinas
2018-07-03  7:53   ` Benjamin Tissoires
2018-08-09 23:57     ` Joey Pabalinas
2018-08-09 23:39   ` [PATCH RESEND " Joey Pabalinas
2018-08-10  3:54   ` Joey Pabalinas
2018-07-01  0:19 ` [PATCH 2/4] HID: multitouch: don't check HID_GROUP_MULTITOUCH_WIN_8 for serial protocol Joey Pabalinas
2018-07-03  8:16   ` Benjamin Tissoires
2018-08-10  3:50     ` Joey Pabalinas
2018-08-09 23:39   ` [PATCH RESEND " Joey Pabalinas
2018-07-01  0:19 ` [PATCH 3/4] HID: multitouch: drop reports containing invalid values Joey Pabalinas
2018-07-03  8:13   ` Benjamin Tissoires [this message]
2018-08-10  3:27     ` Joey Pabalinas
2018-08-09 23:39   ` [PATCH RESEND " Joey Pabalinas
2018-07-01  0:19 ` [PATCH 4/4] HID: multitouch: remove unneeded else conditional cases Joey Pabalinas
2018-07-03  8:17   ` Benjamin Tissoires
2018-08-10  0:03     ` Joey Pabalinas
2018-08-09 23:39   ` [PATCH RESEND " Joey Pabalinas
2018-08-09 23:39 ` [PATCH RESEND 0/4] reduce Surface Pro 3 multitouch jitter Joey Pabalinas

Reply instructions:

You may reply publically 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=CAO-hwJLPm2UgqYU7CgsqX1CNp5JjHu0mZJp-kZnPmZ2qhi1CxQ@mail.gmail.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=consume.noise@gmail.com \
    --cc=jikos@kernel.org \
    --cc=joeypabalinas@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox