From patchwork Sat Aug 13 00:10:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 1062582 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7D06S0W028722 for ; Sat, 13 Aug 2011 00:08:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752658Ab1HMAI0 (ORCPT ); Fri, 12 Aug 2011 20:08:26 -0400 Received: from mail-yi0-f46.google.com ([209.85.218.46]:64181 "EHLO mail-yi0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752343Ab1HMAI0 (ORCPT ); Fri, 12 Aug 2011 20:08:26 -0400 Received: by yie30 with SMTP id 30so2323815yie.19 for ; Fri, 12 Aug 2011 17:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=4zzjKMEIxf6YS2wSWhiYF7ZyV6wsCvSA1H2v/ceKOvo=; b=moiDaTr6yDq+8j30GIFr0B8ZvBv7CZ4CAedoRiMoB8TQvtmwgxzM0/oVYCxCJIeEVN XKA/+Yywq4s1/80e+ZCeBno2HIuFTF+BdfBEwjrD0GrcykWQPh0A33Fj+NGtNihsZRqK oGHLMrbcKaenLp1UlydprGmH4PaReD1resr9M= Received: by 10.236.161.129 with SMTP id w1mr4880558yhk.263.1313194105992; Fri, 12 Aug 2011 17:08:25 -0700 (PDT) Received: from localhost.localdomain ([204.119.25.44]) by mx.google.com with ESMTPS id g69sm1586804yhk.16.2011.08.12.17.08.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Aug 2011 17:08:25 -0700 (PDT) From: Ping Cheng To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, Ping Cheng , Ping Cheng Subject: [PATCH 5/5] input: wacom - retrieve maximum number of contacts Date: Fri, 12 Aug 2011 17:10:05 -0700 Message-Id: <1313194205-5098-1-git-send-email-pinglinux@gmail.com> X-Mailer: git-send-email 1.7.6 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 13 Aug 2011 00:08:27 +0000 (UTC) Retrieve it from the HID descriptor when it is available Signed-off-by: Ping Cheng --- drivers/input/tablet/wacom_sys.c | 23 ++++++++++++++++++++++- drivers/input/tablet/wacom_wac.h | 1 + 2 files changed, 23 insertions(+), 1 deletions(-) diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 958b4eb..6fb292d 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -28,6 +28,7 @@ #define HID_USAGE_Y_TILT 0x3e #define HID_USAGE_FINGER 0x22 #define HID_USAGE_STYLUS 0x20 +#define HID_MT_CONTACTMAX 0x55 #define HID_COLLECTION 0xc0 enum { @@ -151,11 +152,16 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi int result = 0; int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0; unsigned char *report; + unsigned char *rep_data; report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL); if (!report) return -ENOMEM; + rep_data = kmalloc(2, GFP_KERNEL); + if (!rep_data) + return -ENOMEM; + /* retrive report descriptors */ do { result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), @@ -284,6 +290,19 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi pen = 1; i++; break; + + case HID_MT_CONTACTMAX: + do { + rep_data[0] = 12; + result = usb_get_report(intf, + WAC_HID_FEATURE_REPORT, rep_data[0], + rep_data, 2); + } while ((result < 0) && (limit++ < WAC_MSG_RETRIES)); + + if ((result >= 0) && (rep_data[1] > 2)) + features->touch_max = rep_data[1]; + i++; + break; } break; @@ -297,6 +316,7 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi out: result = 0; kfree(report); + kfree(rep_data); return result; } @@ -505,7 +525,8 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i endpoint = &intf->cur_altsetting->endpoint[0].desc; - /* Retrieve the physical and logical size for OEM devices */ + /* Retrieve the physical and logical size for touch devices */ + features->touch_max = 0; error = wacom_retrieve_hid_descriptor(intf, features); if (error) goto fail3; diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index 53eb71b..e19e435 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h @@ -86,6 +86,7 @@ struct wacom_features { int pressure_fuzz; int distance_fuzz; unsigned quirks; + unsigned touch_max; }; struct wacom_shared {