Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1958892imm; Thu, 21 Jun 2018 05:10:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJvIZMec4H64vojU08LNJ4297vMYj43vTAuyUMB9HyMtZg7/f4KKVLLNhnvhMs4P/2mOeWK X-Received: by 2002:a62:249b:: with SMTP id k27-v6mr27461408pfk.143.1529583038546; Thu, 21 Jun 2018 05:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529583038; cv=none; d=google.com; s=arc-20160816; b=DaRLGowuOvzqszScQBTjNnAe674qP9zZ5wVHppHw4cUTORv1vX/vcny6LNipXQiK4d e4PhmlUt7ZprtOOjRSFFfXhSjlcheG913UxmJNBqajw+x2aABys1Hpu6bS0wu0KDbHkk mXKkSvkDjCaIK8NN9Uc126D3FLazb9MZcf0FTf7rpMvpMGvzbirPBYJeosGHVX1RB0jI algq/MDHqngvxfeY+3kqpsuuLQs8cTf4bkGc/z/KqJ8bn3W4wDJ4WytTUzjHgqfDlVMS 3oqn2FkwflsWZXQl34dlAjGEMhNlUCoiHZ36sCHmG1IlB/EfN/q71UKb3EiQkkd17AF7 Zi+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=N+McUOChHhIHULKSqth0rqDugfvMOwzeBgd3aTGijA0=; b=qqu6IH2walkYpW/3jBOYXlixkSgRcI7iHE5UVmg6Aix8eNuYCXn6iWVFT33EpqyutO 9Gu6jngcY+OjqB4Is9O15TedSza1EVoWM/uhX4iPIKyP1+CJZPhD3RxoWmm3gu/ie3zB y1SYGd2SvC+2OGWrbQLSriOL2afPmgm5iD+CqCrOD0jqF9Zvolq94xMW2xvkMdOcevqA u5sdlPR2+I3WKjn4SVa9EF8de+V2tgXbtfOeUwuU988ERnTQS6RH8IPJTrqgeGbRZZoo k/jH2nCsMqQXiAYXr8N90U+E2AWfOmj+bqya1gba26i5xTRZCZlAg0ClHZ6kN5dborO8 WE+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v190-v6si4512776pfv.48.2018.06.21.05.10.24; Thu, 21 Jun 2018 05:10:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933569AbeFUMJf (ORCPT + 99 others); Thu, 21 Jun 2018 08:09:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58366 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933496AbeFUMJa (ORCPT ); Thu, 21 Jun 2018 08:09:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9BE18182D16; Thu, 21 Jun 2018 12:09:28 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-117-99.ams2.redhat.com [10.36.117.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8C2A2026D6B; Thu, 21 Jun 2018 12:09:27 +0000 (UTC) From: Benjamin Tissoires To: Jiri Kosina , Dmitry Torokhov Cc: Mario.Limonciello@dell.com, Peter Hutterer , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH v3 10/12] HID: multitouch: report MT_TOOL_PALM for non-confident touches Date: Thu, 21 Jun 2018 14:09:06 +0200 Message-Id: <20180621120908.16706-11-benjamin.tissoires@redhat.com> In-Reply-To: <20180621120908.16706-1-benjamin.tissoires@redhat.com> References: <20180621120908.16706-1-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 21 Jun 2018 12:09:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 21 Jun 2018 12:09:28 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'benjamin.tissoires@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Torokhov According to Microsoft specification [1] for Precision Touchpads (and Touchscreens) the devices use "confidence" reports to signal accidental touches, or contacts that are "too large to be a finger". Instead of simply marking contact inactive in this case (which causes issues if contact was originally proper and we lost confidence in it later, as this results in accidental clicks, drags, etc), let's report such contacts as MT_TOOL_PALM and let userspace decide what to do. Additionally, let's report contact size for such touches as maximum allowed for major/minor, which should help userspace that is not yet aware of MT_TOOL_PALM to still perform palm rejection. [1] https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/touchpad-windows-precision-touchpad-collection Signed-off-by: Dmitry Torokhov [splitted and rebased] Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped the delayed release in case of palm detection. This is a FW bug for PTP devices, and should only happen with touchscreens - move input_set_abs_params(hi->input, ABS_MT_TOOL_TYPE,...) into its own test so other devices can add MT_QUIRK_CONFIDENCE to their quirks. no changes in v3 --- drivers/hid/hid-multitouch.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index a4a274ebfbef..36c8b67bb032 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -736,6 +736,13 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, cls->name == MT_CLS_WIN_8_DUAL) && field->application == HID_DG_TOUCHPAD) app->quirks |= MT_QUIRK_CONFIDENCE; + + if (app->quirks & MT_QUIRK_CONFIDENCE) + input_set_abs_params(hi->input, + ABS_MT_TOOL_TYPE, + MT_TOOL_FINGER, + MT_TOOL_PALM, 0, 0); + MT_STORE_FIELD(confidence_state); return 1; case HID_DG_TIPSWITCH: @@ -958,10 +965,12 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input, if (quirks & MT_QUIRK_HOVERING) inrange_state = *slot->inrange_state; - active = (*slot->tip_state || inrange_state) && confidence_state; + active = *slot->tip_state || inrange_state; if (app->application == HID_GD_SYSTEM_MULTIAXIS) tool = MT_TOOL_DIAL; + else if (unlikely(!confidence_state)) + tool = MT_TOOL_PALM; input_mt_slot(input, slotnum); input_mt_report_slot_state(input, tool, active); @@ -993,11 +1002,20 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input, orientation = -azimuth; } - /* - * divided by two to match visual scale of touch - * for devices with this quirk - */ - if (quirks & MT_QUIRK_TOUCH_SIZE_SCALING) { + if (unlikely(!confidence_state)) { + /* + * When reporting palm, set contact to maximum + * size to help userspace that does not + * recognize MT_TOOL_PALM to reject contacts + * that are too large. + */ + major = input_abs_get_max(input, ABS_MT_TOUCH_MAJOR); + minor = input_abs_get_max(input, ABS_MT_TOUCH_MINOR); + } else if (quirks & MT_QUIRK_TOUCH_SIZE_SCALING) { + /* + * divided by two to match visual scale of touch + * for devices with this quirk + */ major = major >> 1; minor = minor >> 1; } -- 2.14.3