From patchwork Thu Oct 25 14:09:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1644391 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 38EB03FC36 for ; Thu, 25 Oct 2012 14:13:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756149Ab2JYOLJ (ORCPT ); Thu, 25 Oct 2012 10:11:09 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:46798 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759417Ab2JYOLG (ORCPT ); Thu, 25 Oct 2012 10:11:06 -0400 Received: by mail-wi0-f172.google.com with SMTP id hq12so6028874wib.1 for ; Thu, 25 Oct 2012 07:11:05 -0700 (PDT) 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=mUX2i+dGQwe0X5VSZXcDrHu0FE9T3jog3VhNUVgLlno=; b=bOD2m6DIFU27yThrf2Oo2KE4SJVT+schEkW4YD7c4V9rfZ5Fzu1R9ah7TFy4/AR24W BoxIJxkm6lLP2wppIgWFiM2t29gHIxUni1DHfA78AadPYkxc9FteWoxhcx8BULfFSXi3 jq8XYBVanWACWaZeVURAUS+/KHBun1KIyuvKjuuEY7aMLaSxFbG+5e5m2KxFg39x+PJM Bf6u2mYvSOh8UpVpFJYwn0CChHNr4l/xWME2uCrrB1vEIDGsJLj36bhx+eu9PRepW/L2 GuCinLyFlVUOmEAoYtei5adCW54Szr2+to5ah2iFn83E8XVy0++fgj1Fi2opZ7+svizl Seuw== Received: by 10.180.99.36 with SMTP id en4mr14164475wib.8.1351174265147; Thu, 25 Oct 2012 07:11:05 -0700 (PDT) Received: from miniplouf.lan (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id bn7sm11429654wib.8.2012.10.25.07.11.03 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Oct 2012 07:11:04 -0700 (PDT) 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 04/10] HID: hid-multitouch: get maxcontacts also from logical_max value Date: Thu, 25 Oct 2012 16:09:43 +0200 Message-Id: <1351174189-24719-5-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1351174189-24719-1-git-send-email-benjamin.tissoires@gmail.com> References: <1351174189-24719-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 Win8 devices are required to present the feature "Maximum Contact Number". Fortunately all win7 devices I've seen presents this feature. If the current value is 0, then, the driver can get the actual supported contact count by refering to the logical_max. This win8 specification ensures that logical_max may not be above 250. This also allows us to detect when devices like irtouch or stantum reports an obviously wrong value of 255. Signed-off-by: Benjamin Tissoires --- drivers/hid/hid-multitouch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index e96ecc3..38a4feb 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -121,6 +121,7 @@ struct mt_device { #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 #define MT_DEFAULT_MAXCONTACT 10 +#define MT_MAX_MAXCONTACT 250 #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) @@ -283,6 +284,9 @@ static void mt_feature_mapping(struct hid_device *hdev, case HID_DG_CONTACTMAX: td->maxcontact_report_id = field->report->id; td->maxcontacts = field->value[0]; + if (!td->maxcontacts && + field->logical_maximum <= MT_MAX_MAXCONTACT) + td->maxcontacts = field->logical_maximum; if (td->mtclass.maxcontacts) /* check if the maxcontacts is given by the class */ td->maxcontacts = td->mtclass.maxcontacts;