From patchwork Wed Nov 7 16:37:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1711621 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id DF758DFB7A for ; Wed, 7 Nov 2012 16:39:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753925Ab2KGQjV (ORCPT ); Wed, 7 Nov 2012 11:39:21 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:56378 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753600Ab2KGQiH (ORCPT ); Wed, 7 Nov 2012 11:38:07 -0500 Received: by mail-ee0-f46.google.com with SMTP id b15so1021344eek.19 for ; Wed, 07 Nov 2012 08:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=+al+C/wD1zzelF80mfvKVVPZ156wfxJJyv2p1lBb7bo=; b=VLHTlap3Fia7XjtvH/m5WnmCrZJ79my9Uax/WCkg5Wm+yyF3PSS/7aRiM3UDM+5XB5 bREHI66Ih3SoBaGnGFvS/lRazd4WhzIkIbyPQd+IE9mdM2QBl9Zufbz0O6t4c+SnO63q KlbXkcyMolmjkdbQAV+Okcw5lcJt9HWcYMmo6TjrBBLCiaJmDKFiGBEBds2I20CD3AiM FE0weQMnTnVBXAcO5/X/gOmmbgeMXcF4q4hLvYUJx4Y4sPaDSbSQsf03OIGxzinSU/3L 6CxY6Ae8HDe+F5qoOKGYXOqCMyUi2d6nTN0p0tnyJrqdS57BKksCvRL1PLxysB6RP3TP D2Eg== Received: by 10.14.215.69 with SMTP id d45mr17308949eep.16.1352306286394; Wed, 07 Nov 2012 08:38:06 -0800 (PST) Received: from miniplouf.banquise.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id a44sm64766844eeo.7.2012.11.07.08.38.05 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Nov 2012 08:38:05 -0800 (PST) From: Benjamin Tissoires To: "benjamin.tissoires" , Dmitry Torokhov , Henrik Rydberg , Jiri Kosina , Stephane Chatty , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/13] HID: hid-multitouch: add MT_QUIRK_IGNORE_DUPLICATES Date: Wed, 7 Nov 2012 17:37:32 +0100 Message-Id: <1352306256-12180-10-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1352306256-12180-1-git-send-email-benjamin.tissoires@gmail.com> References: <1352306256-12180-1-git-send-email-benjamin.tissoires@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org this prevents a device to reuse contact id 0 several time when sending garbage values to complete the report. Signed-off-by: Benjamin Tissoires --- drivers/hid/hid-multitouch.c | 6 ++++++ include/linux/input/mt.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 2352770..351c814 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -52,6 +52,7 @@ MODULE_LICENSE("GPL"); #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6) #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8) #define MT_QUIRK_NO_AREA (1 << 9) +#define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) struct mt_slot { __s32 x, y, cx, cy, p, w, h; @@ -510,6 +511,11 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input) if (slotnum < 0 || slotnum >= td->maxcontacts) return; + if (td->mtclass.quirks & MT_QUIRK_IGNORE_DUPLICATES && + input_mt_is_active(&input->mt->slots[slotnum]) && + input_mt_is_used(input->mt, &input->mt->slots[slotnum])) + return; + input_mt_slot(input, slotnum); input_mt_report_slot_state(input, MT_TOOL_FINGER, s->touch_state); diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h index cc5cca7..2e86bd0 100644 --- a/include/linux/input/mt.h +++ b/include/linux/input/mt.h @@ -69,6 +69,12 @@ static inline bool input_mt_is_active(const struct input_mt_slot *slot) return input_mt_get_value(slot, ABS_MT_TRACKING_ID) >= 0; } +static inline bool input_mt_is_used(const struct input_mt *mt, + const struct input_mt_slot *slot) +{ + return slot->frame == mt->frame; +} + int input_mt_init_slots(struct input_dev *dev, unsigned int num_slots, unsigned int flags); void input_mt_destroy_slots(struct input_dev *dev);