From patchwork Thu Jun 23 08:31:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Hung X-Patchwork-Id: 9194681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EDCD16077D for ; Thu, 23 Jun 2016 08:32:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE2DE2842D for ; Thu, 23 Jun 2016 08:32:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D22ED2843D; Thu, 23 Jun 2016 08:32:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7491B2842D for ; Thu, 23 Jun 2016 08:32:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751807AbcFWIbw (ORCPT ); Thu, 23 Jun 2016 04:31:52 -0400 Received: from ausc60pc101.us.dell.com ([143.166.85.206]:27575 "EHLO ausc60pc101.us.dell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751308AbcFWIbv (ORCPT ); Thu, 23 Jun 2016 04:31:51 -0400 DomainKey-Signature: s=smtpout; d=dell.com; c=nofws; q=dns; h=X-LoopCount0:X-IronPort-AV:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References; b=NzMEAxc4x1UDcAIUtfDSbw9GTKxbF8N4ldaaaC3or2Mt+wxIyIhhWMMR eKBqrBIg0Df1YmPmah8TiNCcKI7QXwKIhHivvryfQjAE0A1J3eT8j3TPz ol7G5HZmRdguUsMwhdbqZSVR8h8xthX0lUxhBEropl27xQ1VQ3ggTiKkT k=; DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1466670710; x=1498206710; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=AXXv51ODy6XNGam+2tfpC1btycwMM1NEWlOwoGoBbsw=; b=vGqE2JPL9zJznMharwmZkBNPiNHJ0AoutrvmVq7x6BduMndDfFzE+sDi RmuDAsFgC5/KJCaJMJUvPNlHISBjjQCipXq8mEK5VvAZAxvdjbmXJUFdr FNBdChonvyc2gobYB9olKQe0w9SeYAlHuAow/krYLjxacUkM7pJ8ky1ZO 4=; X-LoopCount0: from 10.106.62.236 X-IronPort-AV: E=Sophos;i="5.26,509,1459832400"; d="scan'208";a="948542842" From: Allen Hung To: Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, LKML , Allen Hung Subject: [PATCH 2/2] HID: multitouch: enable palm rejection for Windows Precision Touchpad Date: Thu, 23 Jun 2016 16:31:30 +0800 Message-Id: <1466670690-77458-2-git-send-email-allen_hung@dell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466670690-77458-1-git-send-email-allen_hung@dell.com> References: <1466670690-77458-1-git-send-email-allen_hung@dell.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The usage Confidence is mandary to Windows Precision Touchpad devices. If it is examined in input_mapping on a WIndows Precision Touchpad, a new add quirk MT_QUIRK_CONFIDENCE desgned for such devices will be applied to the device. A touch with the confidence bit is not set is determined as invalid. Tested on Dell XPS13 9343 Signed-off-by: Allen Hung Reviewed-by: Benjamin Tissoires --- drivers/hid/hid-multitouch.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 4ef7006..fb6f1f4 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -61,6 +61,7 @@ MODULE_LICENSE("GPL"); #define MT_QUIRK_ALWAYS_VALID (1 << 4) #define MT_QUIRK_VALID_IS_INRANGE (1 << 5) #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) +#define MT_QUIRK_CONFIDENCE (1 << 7) #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) #define MT_QUIRK_NO_AREA (1 << 9) #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) @@ -78,6 +79,7 @@ struct mt_slot { __s32 contactid; /* the device ContactID assigned to this slot */ bool touch_state; /* is the touch valid? */ bool inrange_state; /* is the finger in proximity of the sensor? */ + bool confidence_state; /* is the touch made by a finger? */ }; struct mt_class { @@ -502,6 +504,9 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, mt_store_field(usage, td, hi); return 1; case HID_DG_CONFIDENCE: + if (cls->name == MT_CLS_WIN_8 && + field->application == HID_DG_TOUCHPAD) + cls->quirks |= MT_QUIRK_CONFIDENCE; mt_store_field(usage, td, hi); return 1; case HID_DG_TIPSWITCH: @@ -614,6 +619,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) 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; @@ -628,10 +634,14 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) return; } + if (!(td->mtclass.quirks & MT_QUIRK_CONFIDENCE)) + s->confidence_state = 1; + active = (s->touch_state || s->inrange_state) && + s->confidence_state; + input_mt_slot(input, slotnum); - input_mt_report_slot_state(input, MT_TOOL_FINGER, - s->touch_state || s->inrange_state); - if (s->touch_state || s->inrange_state) { + input_mt_report_slot_state(input, MT_TOOL_FINGER, active); + if (active) { /* this finger is in proximity of the sensor */ int wide = (s->w > s->h); /* divided by two to match visual scale of touch */ @@ -696,6 +706,8 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, td->curdata.touch_state = value; break; case HID_DG_CONFIDENCE: + if (quirks & MT_QUIRK_CONFIDENCE) + td->curdata.confidence_state = value; if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE) td->curvalid = value; break;