From patchwork Sun Mar 1 03:34:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 5906921 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69118BF440 for ; Sun, 1 Mar 2015 03:34:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C85D202E9 for ; Sun, 1 Mar 2015 03:34:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52A6C202A1 for ; Sun, 1 Mar 2015 03:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752953AbbCADef (ORCPT ); Sat, 28 Feb 2015 22:34:35 -0500 Received: from mail-oi0-f48.google.com ([209.85.218.48]:57345 "EHLO mail-oi0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752425AbbCADee (ORCPT ); Sat, 28 Feb 2015 22:34:34 -0500 Received: by mail-oi0-f48.google.com with SMTP id a3so21874410oib.7 for ; Sat, 28 Feb 2015 19:34:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FvWl37lwCLRK1vvfayvyipl0hR7KdAVAADPWa5EPKWQ=; b=YnXPRF4IgQuDFa2heZJxBXedMZRus2Cc10t+O6380gumPl//hQ2IREEunXTmQB8C+5 bC61cSTaQ+semVttjSXrsKWsqCsJ2P5/7jtzLrnw5yKgB1h8lKADEXH3T88rxVqD2xoM +t+WINf/79LTVx6wn1tXJnkK7/2ZhPBNFJNA9/lVjCBwjytf/jwjH7i5GROVMRmoh0sD kbKmMIvtGov0u4fkkr7ZL7ACkbtWEOqpAKAlyhjxCvRQ4Cbn4pwl0XUUMC+tPQFTo9L4 yC74NzY5VrWlbzc0o050CyWUSCjGsRDa7XGGN6j+t37yhotmFicdCWRBhJD/mjIYsdWt qjuw== X-Gm-Message-State: ALoCoQk+qs2sUr+5Qydg99P9CMw78qm4FZSYIhGxsMoIIhtEfDdI5YSM3Qb9yvDqcInM9u42TgSy X-Received: by 10.60.96.167 with SMTP id dt7mr14924591oeb.54.1425180873579; Sat, 28 Feb 2015 19:34:33 -0800 (PST) Received: from localhost (199-87-125-144.dyn.kc.surewest.net. [199.87.125.144]) by mx.google.com with ESMTPSA id g3sm5529671obx.25.2015.02.28.19.34.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Feb 2015 19:34:32 -0800 (PST) From: Seth Forshee To: Jiri Kosina Cc: Seth Forshee , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] HID: multitouch: Add support for button type usage Date: Sat, 28 Feb 2015 21:34:30 -0600 Message-Id: <1425180871-5232-1-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425070801-73595-1-git-send-email-seth.forshee@canonical.com> References: <1425070801-73595-1-git-send-email-seth.forshee@canonical.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to [1], Windows Precision Touchpad devices must supply a button type usage in the device capabilities feature report. A value of 0 indicates that the device contains a depressible button (i.e. it's a click-pad) whereas a value of 1 indicates a non-depressible button. Add support for this usage and set INPUT_PROP_BUTTONPAD on the touchpad input device whenever a depressible button is present. v2: Add string for button type usage in debugfs. [1] https://msdn.microsoft.com/en-us/library/windows/hardware/dn467314(v=vs.85).aspx Signed-off-by: Seth Forshee --- drivers/hid/hid-debug.c | 1 + drivers/hid/hid-multitouch.c | 19 +++++++++++++++++++ include/linux/hid.h | 1 + 3 files changed, 21 insertions(+) diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index 8bf61d2..4b2a18a 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c @@ -165,6 +165,7 @@ static const struct hid_usage_entry hid_usage_table[] = { {0, 0x53, "DeviceIndex"}, {0, 0x54, "ContactCount"}, {0, 0x55, "ContactMaximumNumber"}, + {0, 0x59, "ButtonType"}, {0, 0x5A, "SecondaryBarrelSwitch"}, {0, 0x5B, "TransducerSerialNumber"}, { 15, 0, "PhysicalInterfaceDevice" }, diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index f65e78b..b19d721 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -72,6 +72,10 @@ MODULE_LICENSE("GPL"); #define MT_INPUTMODE_TOUCHSCREEN 0x02 #define MT_INPUTMODE_TOUCHPAD 0x03 +#define MT_BUTTONTYPE_DEPRESSIBLE 0 +#define MT_BUTTONTYPE_NONDEPRESSIBLE 1 +#define MT_BUTTONTYPE_MAX MT_BUTTONTYPE_NONDEPRESSIBLE + struct mt_slot { __s32 x, y, cx, cy, p, w, h; __s32 contactid; /* the device ContactID assigned to this slot */ @@ -116,6 +120,7 @@ struct mt_device { __u8 touches_by_report; /* how many touches are present in one report: * 1 means we should use a serial protocol * > 1 means hybrid (multitouch) protocol */ + __u8 buttontype; /* depressible or non-depressible touchpad */ bool serial_maybe; /* need to check for serial protocol */ bool curvalid; /* is the current contact valid? */ unsigned mt_flags; /* flags to pass to input-mt */ @@ -334,6 +339,16 @@ static void mt_feature_mapping(struct hid_device *hdev, td->maxcontacts = td->mtclass.maxcontacts; break; + case HID_DG_BUTTONTYPE: + if (usage->usage_index >= field->report_count) { + dev_err(&hdev->dev, "HID_DG_BUTTONTYPE out of range\n"); + break; + } + + if (field->value[usage->usage_index] <= MT_BUTTONTYPE_MAX) + td->buttontype = field->value[usage->usage_index]; + + break; } } @@ -728,6 +743,9 @@ static void mt_touch_input_configured(struct hid_device *hdev, if (cls->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) td->mt_flags |= INPUT_MT_DROP_UNUSED; + if (td->buttontype == MT_BUTTONTYPE_DEPRESSIBLE) + __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); + input_mt_init_slots(input, td->maxcontacts, td->mt_flags); td->mt_flags = 0; @@ -1009,6 +1027,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; td->cc_index = -1; td->mt_report_id = -1; + td->buttontype = MT_BUTTONTYPE_NONDEPRESSIBLE; hid_set_drvdata(hdev, td); td->fields = devm_kzalloc(&hdev->dev, sizeof(struct mt_fields), diff --git a/include/linux/hid.h b/include/linux/hid.h index 06c4607..498ddad 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -269,6 +269,7 @@ struct hid_item { #define HID_DG_DEVICEINDEX 0x000d0053 #define HID_DG_CONTACTCOUNT 0x000d0054 #define HID_DG_CONTACTMAX 0x000d0055 +#define HID_DG_BUTTONTYPE 0x000d0059 #define HID_DG_BARRELSWITCH2 0x000d005a #define HID_DG_TOOLSERIALNUMBER 0x000d005b