From patchwork Thu Oct 6 21:22:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 9365327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7B9126077E for ; Thu, 6 Oct 2016 21:22:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6637429253 for ; Thu, 6 Oct 2016 21:22:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B06829256; Thu, 6 Oct 2016 21:22:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AB4329253 for ; Thu, 6 Oct 2016 21:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935071AbcJFVWs (ORCPT ); Thu, 6 Oct 2016 17:22:48 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:33373 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935171AbcJFVWr (ORCPT ); Thu, 6 Oct 2016 17:22:47 -0400 Received: by mail-qt0-f196.google.com with SMTP id m5so836161qtb.0 for ; Thu, 06 Oct 2016 14:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MjzuAD6AXUz9N6SFIawLDvLGQIBTJmVZO9TUrwfuuaI=; b=Fy9Qy52C3rK9bse5SF25ra8rFLLjq10QDEQFKzaiKp1dt480tS64l+puVEyWSspyoV SB6EaIgnNFDX2KQIL8nD7NNJFRVnnAHq59aXhAn5nhEFTiUSjVVo78vUo+dB0DhHz3xc fgFkUVhLKW1UFvzv21+DzkZLPFN9OV8DyDNrShRmMO0SKEdjSUDpciFp0thWkGKPP/iw iJe9K5TM3MpuPUL9G6KPYdAOjLP7g8e+46GXp29TaQzW6FHEVKxi/QNQzdHQRdaqYC4s dfZd1CbpQOcPtFeGjDAK8rkhxfmSiXUp7rl6J+iCOPmKDAunQ6u18ce3+6BA+ia+LjF+ VoVg== 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=MjzuAD6AXUz9N6SFIawLDvLGQIBTJmVZO9TUrwfuuaI=; b=fHIZEP4QxM38fBPOwEMtKlfUM1AtXePGR+YF0oiTbYsihS4iRzXGevVVT5ZTwpUDlH GrfH6HNlN6MrI/eclfsteUMJViNE0MURs6Anggtu/NST0J/GWEqVj0Qw6ZBAVWAG/7yI ro7en/STrOGdJs9ew+tZxK7vWtp9Yw/5LXHa7LPZ70Rn31eZmCnm8nn0GfFvOqhnSYbC 3f4L97H9t0qnbVjPfgXMiOlJlwrH5ljzEvv6Fh6PNSJZGZ52254/qsp8qAzwtcXbJmFb lmfParaeaibm3qChW7M/Mee3Tk1hY1RSs5MtWag6+3Z76svTwSIPDIsLy+kx2LKy3yTm /F8Q== X-Gm-Message-State: AA6/9RnMkaCWltFIIece6SW/jT+mpWIH+qFsUFIoEzv/6xSKQPbtKzXGl2JES3v8X0vm+A== X-Received: by 10.200.40.197 with SMTP id j5mr16634498qtj.43.1475788966795; Thu, 06 Oct 2016 14:22:46 -0700 (PDT) Received: from wacom-arch2.corp.onewacom.com ([50.225.60.4]) by smtp.gmail.com with ESMTPSA id m4sm5773714qkf.29.2016.10.06.14.22.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Oct 2016 14:22:46 -0700 (PDT) From: Jason Gerecke To: linux-input@vger.kernel.org, Jiri Kosina Cc: Benjamin Tissoires , Ping Cheng , Ping Cheng , Aaron Skomra , Jason Gerecke , Jason Gerecke Subject: [PATCH 04/19] HID: wacom: Detect and correct descriptors missing HID_DG_BARRELSWITCH2 Date: Thu, 6 Oct 2016 14:22:16 -0700 Message-Id: <20161006212231.31440-5-killertofu@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161006212231.31440-1-killertofu@gmail.com> References: <20161006212231.31440-1-killertofu@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ISDv4 devices have long supported reporting data from each of two barrel switches, but HID_DG_BARRELSWITCH2 itself was only recently standardized. Prior to its adoption, ISDv4 devices would associate the bit indicating the state of the second barrel switch with the "Undefined" 0x000D0000 usage. Although most such devices have explicit support, a few use the HID_GENERIC codepath which ignores the "Undefined" usage. This patch adds code which detects the presence of a pre-standard second barrel switch and corrects the usage value so that the HID_GENERIC code will declare its presence and report its state. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_sys.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 773fa11..033cc03 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -240,6 +240,30 @@ static void wacom_usage_mapping(struct hid_device *hdev, features->touch_max = 1; } + /* + * ISDv4 devices which predate HID's adoption of the + * HID_DG_BARELSWITCH2 usage use 0x000D0000 in its + * position instead. We can accurately detect if a + * usage with that value should be HID_DG_BARRELSWITCH2 + * based on the surrounding usages, which have remained + * constant across generations. + */ + if (features->type == HID_GENERIC && + usage->hid == 0x000D0000 && + field->application == HID_DG_PEN && + field->physical == HID_DG_STYLUS) { + int i = usage->usage_index; + + if (i-4 >= 0 && i+1 < field->maxusage && + field->usage[i-4].hid == HID_DG_TIPSWITCH && + field->usage[i-3].hid == HID_DG_BARRELSWITCH && + field->usage[i-2].hid == HID_DG_ERASER && + field->usage[i-1].hid == HID_DG_INVERT && + field->usage[i+1].hid == HID_DG_INRANGE) { + usage->hid = HID_DG_BARRELSWITCH2; + } + } + switch (usage->hid) { case HID_GD_X: features->x_max = field->logical_maximum;