From patchwork Fri Oct 26 08:44:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1650341 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 97CFDDF2F6 for ; Fri, 26 Oct 2012 08:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757436Ab2JZIo4 (ORCPT ); Fri, 26 Oct 2012 04:44:56 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:35014 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757410Ab2JZIon (ORCPT ); Fri, 26 Oct 2012 04:44:43 -0400 Received: by mail-wi0-f172.google.com with SMTP id hq12so225486wib.1 for ; Fri, 26 Oct 2012 01:44:42 -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=+LRShHgZdl/AP1dJOToM85zaCm/PCDcAunrmZlIVoD0=; b=zPX5iUuwUrPyviwBPMTW3G8UpXTMiDhw9qWMPnCcWQahYW6vlzELNBXFilMgseOoDv Kk7+aSFRyizRdtzkm9RoPojHtPZFwgxxYOGU7ODiylDvHyPUjQ92iOscWatRnAo5E8PJ /fZ/oCuRZCbxuIk4n0hVeqSuhLsBQ3xHSUEDy4HVItqN+eVW/+c8G6uXVTU3QvqaIF3h mJn+bRX3TpKpPt8VQEwnGhMvC96OzzGTXg/Br6pxebjpRBzlice5m1yrfgefBz/JAe7M hdJ54tNfysBMYRa8+mV2YX3dvS3/sVI08TDs6VxXZdvotDLRoAmEAo27fe6Lzohe4L+M 6StA== Received: by 10.180.92.132 with SMTP id cm4mr239199wib.12.1351241082536; Fri, 26 Oct 2012 01:44:42 -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 dq6sm14151586wib.5.2012.10.26.01.44.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 26 Oct 2012 01:44:42 -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 v2 05/11] HID: hid-multitouch: get maxcontacts also from logical_max value Date: Fri, 26 Oct 2012 10:44:21 +0200 Message-Id: <1351241067-9521-6-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1351241067-9521-1-git-send-email-benjamin.tissoires@gmail.com> References: <1351241067-9521-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 Acked-by: Henrik Rydberg --- 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 95562d8..41f2981 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;