From patchwork Wed Nov 7 16:37:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1711681 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 E4F5B3FC8F for ; Wed, 7 Nov 2012 16:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753668Ab2KGQkR (ORCPT ); Wed, 7 Nov 2012 11:40:17 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:33927 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753254Ab2KGQiC (ORCPT ); Wed, 7 Nov 2012 11:38:02 -0500 Received: by mail-ee0-f46.google.com with SMTP id b15so1021334eek.19 for ; Wed, 07 Nov 2012 08:38:02 -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=dJhK5YU4S+7JC1vRI37hXisVtxbAn+baa3LYOrClYsc=; b=U5y8/teLNi+LonabBTtO4YuWFbaB9HWnk9CnPR/4ttHzOFSwws5DUfg1bR/Bmo5Rld Pt2k/BF2mCF1iATKCDie9T95MSMlMpYlgf0iUiBJ5cAaagsQT5JF0A1rQ0Ogj0hrzp6Z K8WCYqO2nNuLyVqBsF1PV33oeDoIk/C1BGE+kqLFvki9pc+36OP8q1TuVgbfnTo5Hotz 2elPBdvF/Jqfu58pYbOo17ut7MwvHHwRGBOVJlSxDIsrh/3xFdsdOCp+A3E5RJkT4sfA ns6sic0SAJi+QgpO+bzK9uC9oC2NmiqBALAmGd1SQ2JPnBfPRC9RrD0AM+0pk1lA4UBt LjHg== Received: by 10.14.221.194 with SMTP id r42mr17269819eep.25.1352306282012; Wed, 07 Nov 2012 08:38:02 -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.00 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Nov 2012 08:38:01 -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 06/13] HID: hid-multitouch: get maxcontacts also from logical_max value Date: Wed, 7 Nov 2012 17:37:29 +0100 Message-Id: <1352306256-12180-7-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 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 a6a4e0a..ae57b8f 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;