From patchwork Wed Nov 14 15:59:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1742311 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 47F81DF264 for ; Wed, 14 Nov 2012 16:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422974Ab2KNQCa (ORCPT ); Wed, 14 Nov 2012 11:02:30 -0500 Received: from mail-wg0-f44.google.com ([74.125.82.44]:38389 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422641Ab2KNP7t (ORCPT ); Wed, 14 Nov 2012 10:59:49 -0500 Received: by mail-wg0-f44.google.com with SMTP id dr13so307340wgb.1 for ; Wed, 14 Nov 2012 07:59:48 -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=7mtsKZwPXEoKENCyUtGUDtvFiO0Jpgj1hPJXTTEa4dw=; b=leNsvyJHpzcEYKVmG7+UU5knhPgiZxsEx1Fvw01sX8d1lnggUuZjPy/2i95JbdArgm L3Vym2+XPapS7kLR/0yrH6ktNSYCMXvDiS1QJ6zbAUjhL0Ew6WngBEqK2Qg8Olh/U42v QwW1D+mK1lV7yoguWAJx58T9txUFxxuE/MbrnTx/V4qxiM1rGOJ+Dyp+JCzCQBN4PhuX vlEvdHfnSgXK3G/XeeuUPpookjy0W50aMg1xBCA0iBXHoyC5r8WML2jBUmUtILVvDaeH ombn7KRasZKqjuBdo+068c+rcplEVkox/meROLLwVWFbMRa+NY8mUZUnhSCZLPXufRAe 5dkA== Received: by 10.216.214.101 with SMTP id b79mr1946509wep.1.1352908788373; Wed, 14 Nov 2012 07:59:48 -0800 (PST) Received: from localhost.localdomain.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id r10sm3050116wiz.0.2012.11.14.07.59.46 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 07:59:47 -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 v4 06/14] HID: hid-multitouch: get maxcontacts also from logical_max value Date: Wed, 14 Nov 2012 16:59:18 +0100 Message-Id: <1352908766-4492-7-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1352908766-4492-1-git-send-email-benjamin.tissoires@gmail.com> References: <1352908766-4492-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;