From patchwork Wed Feb 17 17:22:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 12091965 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E84EEC433E6 for ; Wed, 17 Feb 2021 17:33:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C22A464DCF for ; Wed, 17 Feb 2021 17:33:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233782AbhBQRcx (ORCPT ); Wed, 17 Feb 2021 12:32:53 -0500 Received: from [139.28.40.42] ([139.28.40.42]:46874 "EHLO tarta.nabijaczleweli.xyz" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S234141AbhBQRcl (ORCPT ); Wed, 17 Feb 2021 12:32:41 -0500 X-Greylist: delayed 563 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 Feb 2021 12:32:26 EST Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 838B3360135; Wed, 17 Feb 2021 18:22:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nabijaczleweli.xyz; s=202006; t=1613582551; bh=Hf4nKRB8+MGr3EN3mWaLIlVmQ4/HMM8ISiBIcOu0J2s=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=TuSDx0HPyiuDxVlHcQJD4nnMUgLXHlBEizchqtaG25OUAe22XxQWtUOSD8hV+L5YV C57GZyr8gdXCJOqXv/r1m4DPRblI2bedTggIWAg0EAjRbDxgrt/ZFD50+za9l1HyKq jfO8MrYK9UqvR5aIc/LRLpsx75TZcDzLRymPx6iUdUHdltxycu1Gnt0kLHDnfzatW7 ZfGPjNI4zLdU/ZZT92PLsXl9tWQdFUw+10LkaagL9x0WKtd6g/rMFsnCxC4VBgL49T P663JFO/6fJl9tL382KzuAEfnhGQs20OTHg6WFCexhhI/h2kcbT2qQSW+3dQmcbuwQ 71p01ntMqa+Pw== Date: Wed, 17 Feb 2021 18:22:30 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Benjamin Tissoires , Peter Hutterer , Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] HID: multitouch: require Finger field to mark Win8 reports as MT Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20210205 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This effectively changes collection_is_mt from contact ID in report->field to (device is Win8 => collection is finger) && contact ID in report->field Some devices erroneously report Pen for fingers, and Win8 stylus-on-touchscreen devices report contact ID, but mark the accompanying touchscreen device's collection correctly Signed-off-by: Ahelenia Ziemiańska --- drivers/hid/hid-multitouch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 8429ebe7097e..8580ace596c2 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -604,9 +604,13 @@ static struct mt_report_data *mt_allocate_report_data(struct mt_device *td, if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) continue; - for (n = 0; n < field->report_count; n++) { - if (field->usage[n].hid == HID_DG_CONTACTID) - rdata->is_mt_collection = true; + if (field->logical == HID_DG_FINGER || td->hdev->group != HID_GROUP_MULTITOUCH_WIN_8) { + for (n = 0; n < field->report_count; n++) { + if (field->usage[n].hid == HID_DG_CONTACTID) { + rdata->is_mt_collection = true; + break; + } + } } } From patchwork Wed Feb 17 17:22:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 12091963 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05084C433E9 for ; Wed, 17 Feb 2021 17:33:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D545A64E45 for ; Wed, 17 Feb 2021 17:33:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234460AbhBQRcz (ORCPT ); Wed, 17 Feb 2021 12:32:55 -0500 Received: from [139.28.40.42] ([139.28.40.42]:46876 "EHLO tarta.nabijaczleweli.xyz" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S234199AbhBQRcq (ORCPT ); Wed, 17 Feb 2021 12:32:46 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id CCF3C360145; Wed, 17 Feb 2021 18:22:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nabijaczleweli.xyz; s=202006; t=1613582558; bh=b15Rm9F+Q8HK8S3bxl9+1GFx0SJ2qQ2WbsdlEjo8Ln8=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=jgvYsIZSqzKYyyroDahGpmA2ElYaCk8ow6rxR3yV5q7Rdhl4LNha7tsYcsSzx5Do1 FLdHtMIm02myizRYwHm2CSMPHzzLsX0Vgy1WpvuMGG142kV19FfuNW5d56xhBkzBPu lLvxqalDuZGEtaOV22JOLM5r7WtEOP5HycbVhrJ3nZtdef/vJJfyCgax4MnRV4k4+d qRwMdpteJn+fDQgNaRkJdkGACLVF48TDpJUolzgvy5gIPTq2nNkY/lbvODupZJRWmQ bi0bGMSzK3e3WYdU89Ix2oqiVjhLHzMJ3RP16egIUBEnWAhqSW6kkbyeBm37+bgVCY NZ65WnZUlk5CA== Date: Wed, 17 Feb 2021 18:22:37 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Benjamin Tissoires , Peter Hutterer , Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] HID: multitouch: set Stylus suffix for Stylus-application devices, too Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20210205 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This re-adds the suffix to Win8 stylus-on-touchscreen devices, now that they aren't erroneously marked as MT Signed-off-by: Ahelenia Ziemiańska --- drivers/hid/hid-multitouch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 8580ace596c2..e5a3704b9fe8 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -1580,13 +1580,13 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) /* we do not set suffix = "Touchscreen" */ hi->input->name = hdev->name; break; - case HID_DG_STYLUS: - /* force BTN_STYLUS to allow tablet matching in udev */ - __set_bit(BTN_STYLUS, hi->input->keybit); - break; case HID_VD_ASUS_CUSTOM_MEDIA_KEYS: suffix = "Custom Media Keys"; break; + case HID_DG_STYLUS: + /* force BTN_STYLUS to allow tablet matching in udev */ + __set_bit(BTN_STYLUS, hi->input->keybit); + fallthrough; case HID_DG_PEN: suffix = "Stylus"; break; From patchwork Wed Feb 17 17:22:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 12091969 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78865C4332E for ; Wed, 17 Feb 2021 17:33:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51C8664DCF for ; Wed, 17 Feb 2021 17:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234467AbhBQRdD (ORCPT ); Wed, 17 Feb 2021 12:33:03 -0500 Received: from [139.28.40.42] ([139.28.40.42]:46860 "EHLO tarta.nabijaczleweli.xyz" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S234397AbhBQRcs (ORCPT ); Wed, 17 Feb 2021 12:32:48 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 4CB7136015E; Wed, 17 Feb 2021 18:22:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nabijaczleweli.xyz; s=202006; t=1613582564; bh=dwHu+sdeHIKyUfCS/scRSx02f3iaHYUimdvjlNSpccM=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=evr3z80W83GUYD2f9mLHoZBgTi/kkMo+NJwI8ez2dQGpQKCU3HtMoqicGg4LTtKSx I/Fk42oy7dQI1vj9B0tXm93jZmRwhkLO40gfzT4Nbxeq+sulKoPtFzlb2g71HsXcZc jEoj5QNgbDRRyDUNpIdpEBTtWiOSLU+NlYPUYrXM8gxP9bQNSAhtcdkG6uorKkO8hX 9BgGJ3NBrYZJTbK7CkgSZVxKl0jK0/tdExCMzTAD2CPjRl15Snoy+sLnO8XFxfRClV jKWswq5f2iVR2EW73Sf9UH6bT+NXrYrYvIz9LQ3N+Pv8zhh4cSzRTVXv/qDXmWwjyK N6eXk54ZiahWw== Date: Wed, 17 Feb 2021 18:22:43 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Benjamin Tissoires , Peter Hutterer , Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] HID: input: replace outdated HID numbers+comments with macros Message-ID: <394d6b11ae029c64a0bb44a00bef902069087d03.1613582014.git.nabijaczleweli@nabijaczleweli.xyz> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20210205 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org These were untouched since 2.3.99-pre3, and the explanatory comment for HID_DG_TIPPRESSURE is TipPressure on other places Signed-off-by: Ahelenia Ziemiańska --- drivers/hid/hid-input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index f23027d2795b..a5ba92978473 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1301,12 +1301,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct return; } - if (usage->hid == (HID_UP_DIGITIZER | 0x003c)) { /* Invert */ + if (usage->hid == HID_DG_INVERT) { *quirks = value ? (*quirks | HID_QUIRK_INVERT) : (*quirks & ~HID_QUIRK_INVERT); return; } - if (usage->hid == (HID_UP_DIGITIZER | 0x0032)) { /* InRange */ + if (usage->hid == HID_DG_INRANGE) { if (value) { input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1); return; @@ -1316,7 +1316,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct return; } - if (usage->hid == (HID_UP_DIGITIZER | 0x0030) && (*quirks & HID_QUIRK_NOTOUCH)) { /* Pressure */ + if (usage->hid == HID_DG_TIPPRESSURE && (*quirks & HID_QUIRK_NOTOUCH)) { int a = field->logical_minimum; int b = field->logical_maximum; input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3)); From patchwork Wed Feb 17 17:22:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 12091961 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 236F4C43381 for ; Wed, 17 Feb 2021 17:33:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC69564E4B for ; Wed, 17 Feb 2021 17:33:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234462AbhBQRc7 (ORCPT ); Wed, 17 Feb 2021 12:32:59 -0500 Received: from [139.28.40.42] ([139.28.40.42]:46858 "EHLO tarta.nabijaczleweli.xyz" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S233885AbhBQRcq (ORCPT ); Wed, 17 Feb 2021 12:32:46 -0500 Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 3CCEE3601D2; Wed, 17 Feb 2021 18:22:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=nabijaczleweli.xyz; s=202006; t=1613582569; bh=ziY0iXdxwSWXFOzoXNDOFn5JohGhP3IMScquKcj790E=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=dBtD6W7ffddYH3UpRpeMSIBASbBvDE0f49x3J5KBtcCW6VsP4BcwMFuR6FL1oFJxa bqy4Kh7A5puaWJgQ8kP2TKCLApSB4rerNuVZ4gMfWmndAyFpk3d334E71H9rjJzRl5 kQWbdinoT448hsAqOqRcfuC3JfpZjslvphls0uDvUvLu5Mx/RVHjPqF4lqqnsDjrUb 2Qo/pEWxJ9ftZzVYC0HTmnGc+kfwQMV6SsCE236BBZA2i1yrD9Ze42LrOeMxjUtqfE 50x014EZIDuKlnOIH7k5GyTSo1HNe+F9IIeCSLXik4PDut/m/NHDuIIlfTTzkxhr8w ZhTU12bo9duHQ== Date: Wed, 17 Feb 2021 18:22:48 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Benjamin Tissoires , Peter Hutterer , Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] HID: input: work around Win8 stylus-on-touchscreen reporting Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20210205 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org With this, these devices now behave as tablets as expected by userspace Signed-off-by: Ahelenia Ziemiańska --- drivers/hid/hid-input.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index a5ba92978473..b8813fc3e9d2 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1273,6 +1273,41 @@ static void hidinput_handle_scroll(struct hid_usage *usage, input_event(input, EV_REL, usage->code, hi_res); } +/* + * Win8 tablet stylus devices send, in order: + * HID_DG_TIPSWITCH (BTN_TOUCH) + * HID_DG_INVERT (BTN_TOOL_RUBBER) + * HID_DG_ERASER (BTN_TOUCH) + * HID_DG_INRANGE (BTN_TOOL_PEN) + * + * For each of these states: + * hover : INRANGE + * touching : TIPSWITCH + * hover+2 : INVERT INRANGE + * touching+2: ERASER INRANGE + * + * Which means we'd send BTN_TOUCH=0 + BTN_TOOL_PEN=1 on proximity, + * then BTN_TOUCH=1 and BTN_TOOL_PEN=0 in consecutive groups when touched, + * indicating the stylus leaving the screen as soon as the two meet. + */ +static void hidinput_fixup_win8_inrange(struct hid_device *hid, struct hid_field *field, __s32 *value) +{ + unsigned f, u; + struct hid_field *rfield; + + if (!*value) { + for (f = 0; f < field->report->maxfield; ++f) { + rfield = field->report->field[f]; + for (u = 0; u < rfield->maxusage; ++u) { + if (rfield->usage[u].hid == HID_DG_TIPSWITCH) { + *value = rfield->value[u]; + return; + } + } + } + } +} + void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) { struct input_dev *input; @@ -1306,7 +1341,13 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct return; } + if (usage->hid == HID_DG_ERASER && value) + *quirks |= HID_QUIRK_INVERT; + if (usage->hid == HID_DG_INRANGE) { + if (hid->group == HID_GROUP_MULTITOUCH_WIN_8) + hidinput_fixup_win8_inrange(hid, field, &value); + if (value) { input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1); return;