Return-Path: Received: from mail-co1nam03on0110.outbound.protection.outlook.com ([104.47.40.110]:19475 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933057AbeCCW2F (ORCPT ); Sat, 3 Mar 2018 17:28:05 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Hans de Goede , Jiri Kosina , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 04/84] HID: multitouch: Only look at non touch fields in first packet of a frame Date: Sat, 3 Mar 2018 22:26:02 +0000 Message-ID: <20180303222518.26271-4-alexander.levin@microsoft.com> References: <20180303222518.26271-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222518.26271-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Hans de Goede [ Upstream commit 55746d28d66860bccaae20a67b55b9d5db7c14af ] Devices in "single finger hybrid mode" will send one report per finger, on some devices only the first report of such a multi-packet frame will contain a value for BTN_LEFT, in subsequent reports (if multiple fingers are down) the value is always 0, causing hid-mt to report BTN_LEFT going 1 - 0 - 1 - 0 when pressing a clickpad and putting down a second finger. This happens for example on USB 0603:0002 mt touchpads. This commit fixes this by only reporting non touch fields for the first packet of a (possibly) multi-packet frame. Signed-off-by: Hans de Goede Reviewed-by: Benjamin Tissoires Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-multitouch.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 9e8c4d2ba11d..6598501c1ad0 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -738,9 +738,11 @@ static int mt_touch_event(struct hid_device *hid, stru= ct hid_field *field, } =20 static void mt_process_mt_event(struct hid_device *hid, struct hid_field *= field, - struct hid_usage *usage, __s32 value) + struct hid_usage *usage, __s32 value, + bool first_packet) { struct mt_device *td =3D hid_get_drvdata(hid); + __s32 cls =3D td->mtclass.name; __s32 quirks =3D td->mtclass.quirks; struct input_dev *input =3D field->hidinput->input; =20 @@ -794,6 +796,15 @@ static void mt_process_mt_event(struct hid_device *hid= , struct hid_field *field, break; =20 default: + /* + * For Win8 PTP touchpads we should only look at + * non finger/touch events in the first_packet of + * a (possible) multi-packet frame. + */ + if ((cls =3D=3D MT_CLS_WIN_8 || cls =3D=3D MT_CLS_WIN_8_DUAL) && + !first_packet) + return; + if (usage->type) input_event(input, usage->type, usage->code, value); @@ -813,6 +824,7 @@ static void mt_touch_report(struct hid_device *hid, str= uct hid_report *report) { struct mt_device *td =3D hid_get_drvdata(hid); struct hid_field *field; + bool first_packet; unsigned count; int r, n; =20 @@ -831,6 +843,7 @@ static void mt_touch_report(struct hid_device *hid, str= uct hid_report *report) td->num_expected =3D value; } =20 + first_packet =3D td->num_received =3D=3D 0; for (r =3D 0; r < report->maxfield; r++) { field =3D report->field[r]; count =3D field->report_count; @@ -840,7 +853,7 @@ static void mt_touch_report(struct hid_device *hid, str= uct hid_report *report) =20 for (n =3D 0; n < count; n++) mt_process_mt_event(hid, field, &field->usage[n], - field->value[n]); + field->value[n], first_packet); } =20 if (td->num_received >=3D td->num_expected) --=20 2.14.1