From patchwork Wed Jan 25 20:08:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Armstrong Skomra X-Patchwork-Id: 9537867 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 2DED06042B for ; Wed, 25 Jan 2017 20:09:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FAFA27D4D for ; Wed, 25 Jan 2017 20:09:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 141AD27F99; Wed, 25 Jan 2017 20:09:40 +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 8461F27D4D for ; Wed, 25 Jan 2017 20:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751863AbdAYUJi (ORCPT ); Wed, 25 Jan 2017 15:09:38 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33537 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718AbdAYUJi (ORCPT ); Wed, 25 Jan 2017 15:09:38 -0500 Received: by mail-pg0-f65.google.com with SMTP id 194so20547696pgd.0 for ; Wed, 25 Jan 2017 12:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8Q58v9AjqcaLipNaQsjUVSRtdtY9LRcEZhsk7tvgf0Q=; b=KechvWjncCzqzTx6zJQNAj2apNSerLbtn9J7kf6UBmJtqX3jX3BcSa+XpYyUzEoErB n6pOhLegPCqIDwCfIyxYBra2uQFpEFRqbFlg/RvKeyD78cL5Gl27jal4UOFLmiq4X3Bc +otMHB24K4Zu8np/ZJCXvP5Ok4Huynl0z9twQPCsv5DU16FqWhx01AE3SIDI/9/LaicG mgFFeNxGWmEqbQyUsP32aulObNdblGN18XD9+crlpdlDVjkNXx+0wcb3uJqC0lY66jZ4 ZXBDVUt6BWr4w1NoESL+SGOcvbLKgD4eTu+goYlH6gY7dECnKv0GJsTQMVObYPKJf8HG mUWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8Q58v9AjqcaLipNaQsjUVSRtdtY9LRcEZhsk7tvgf0Q=; b=H/mcjdsIx0GG5I0y/GmPZ7O6uU04P+99CApB8IB/5Syk+gkV1uVdGcESoO5ihLPRfu 4rlGzZR/wur0bvMJdZU/OlPm+leiSSXktEH6NMW3P7nZQwNEr0+emwCU4JSKQHFywQG7 SulQG/NX3RtnMXKcGO3eN/SHlEa2i5CXbP3Gxs0+r0RtCKsOo3jV5N+AtjKq0OYFS0MT Yxte3NDwUyW8X5GylCMFKEip1cROcNSy05r0ETlkqSbao9MRqCPcAsUTSvsJshAc2mcm kEGsjEf+8GC90QWKmTFcov62d6nrrlRKq2lDAIf9hCNcbvrmZEqmU3hqEbVMr7Wpsal5 0QgQ== X-Gm-Message-State: AIkVDXIBJVd/cq+2tuNwuhrKHvxpqhyJkgETYrT7I+N/79kq21+SOgyymd5hIGJ1o+b6fg== X-Received: by 10.99.133.65 with SMTP id u62mr1226156pgd.70.1485374977651; Wed, 25 Jan 2017 12:09:37 -0800 (PST) Received: from localhost.localdomain (71-36-102-37.ptld.qwest.net. [71.36.102.37]) by smtp.googlemail.com with ESMTPSA id g64sm3066106pfc.57.2017.01.25.12.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 12:09:36 -0800 (PST) From: Aaron Armstrong Skomra To: linux-input@vger.kernel.org, jkosina@suse.cz, benjamin.tissoires@redhat.com, pinglinux@gmail.com, killertofu@gmail.com Cc: Aaron Armstrong Skomra , Aaron Skomra Subject: [PATCH 6/8] HID: wacom: generic: add vendor defined touch Date: Wed, 25 Jan 2017 12:08:40 -0800 Message-Id: <1485374922-3417-7-git-send-email-skomra@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485374922-3417-1-git-send-email-skomra@gmail.com> References: <1485374922-3417-1-git-send-email-skomra@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 Add vendor defined touch to support the second generation Intuos Pro. Previously all generic Wacom devices used true HID to report their touch. Signed-off-by: Aaron Skomra --- drivers/hid/wacom.h | 1 + drivers/hid/wacom_sys.c | 13 ++++++++++--- drivers/hid/wacom_wac.c | 22 +++++++++++++++++----- drivers/hid/wacom_wac.h | 16 +++++++++++++++- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h index 8d8fe30..0e7b840 100644 --- a/drivers/hid/wacom.h +++ b/drivers/hid/wacom.h @@ -219,4 +219,5 @@ enum led_brightness wacom_leds_brightness_get(struct wacom_led *led); struct wacom_led *wacom_led_find(struct wacom *wacom, unsigned int group, unsigned int id); struct wacom_led *wacom_led_next(struct wacom *wacom, struct wacom_led *cur); +int wacom_equivalent_usage(int usage); #endif diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 4a70783..a4884e7 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -112,11 +112,12 @@ static void wacom_feature_mapping(struct hid_device *hdev, struct wacom *wacom = hid_get_drvdata(hdev); struct wacom_features *features = &wacom->wacom_wac.features; struct hid_data *hid_data = &wacom->wacom_wac.hid_data; + unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); u8 *data; int ret; int n; - switch (usage->hid) { + switch (equivalent_usage) { case HID_DG_CONTACTMAX: /* leave touch_max as is if predefined */ if (!features->touch_max) { @@ -325,8 +326,14 @@ static void wacom_post_parse_hid(struct hid_device *hdev, if (features->type == HID_GENERIC) { /* Any last-minute generic device setup */ if (features->touch_max > 1) { - input_mt_init_slots(wacom_wac->touch_input, wacom_wac->features.touch_max, - INPUT_MT_DIRECT); + if (features->device_type & WACOM_DEVICETYPE_DIRECT) + input_mt_init_slots(wacom_wac->touch_input, + wacom_wac->features.touch_max, + INPUT_MT_DIRECT); + else + input_mt_init_slots(wacom_wac->touch_input, + wacom_wac->features.touch_max, + INPUT_MT_POINTER); } } } diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 636c4a1..2eeaa05 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1599,7 +1599,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) return 0; } -static int wacom_equivalent_usage(int usage) +int wacom_equivalent_usage(int usage) { if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) { int subpage = (usage & 0xFF00) << 8; @@ -1626,6 +1626,16 @@ static int wacom_equivalent_usage(int usage) return subpage | subusage; } + if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) { + int subpage = (usage & 0xFF00) << 8; + int subusage = (usage & 0xFF); + + if (subpage == HID_UP_UNDEFINED) + subpage = WACOM_HID_SP_DIGITIZER; + + return subpage | subusage; + } + return usage; } @@ -2218,8 +2228,10 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev, for (j = 0; j < field->maxusage; j++) { struct hid_usage *usage = &field->usage[j]; + unsigned int equivalent_usage = + wacom_equivalent_usage(usage->hid); - switch (usage->hid) { + switch (equivalent_usage) { case HID_GD_X: case HID_GD_Y: case HID_DG_WIDTH: @@ -2228,7 +2240,7 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev, case HID_DG_INRANGE: case HID_DG_INVERT: case HID_DG_TIPSWITCH: - hid_data->last_slot_field = usage->hid; + hid_data->last_slot_field = equivalent_usage; break; case HID_DG_CONTACTCOUNT: hid_data->cc_report = report->id; @@ -2283,8 +2295,8 @@ void wacom_wac_usage_mapping(struct hid_device *hdev, struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct wacom_features *features = &wacom_wac->features; - /* currently, only direct devices have proper hid report descriptors */ - features->device_type |= WACOM_DEVICETYPE_DIRECT; + if (WACOM_DIRECT_DEVICE(field)) + features->device_type |= WACOM_DEVICETYPE_DIRECT; if (WACOM_PAD_FIELD(field)) wacom_wac_pad_usage_mapping(hdev, field, usage); diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index dac95ba..da38f77 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -101,6 +101,7 @@ #define WACOM_HID_SP_DIGITIZER 0x000d0000 #define WACOM_HID_SP_DIGITIZERINFO 0x00100000 #define WACOM_HID_WD_DIGITIZER (WACOM_HID_UP_WACOMDIGITIZER | 0x01) +#define WACOM_HID_WD_PEN (WACOM_HID_UP_WACOMDIGITIZER | 0x02) #define WACOM_HID_WD_SENSE (WACOM_HID_UP_WACOMDIGITIZER | 0x36) #define WACOM_HID_WD_DIGITIZERFNKEYS (WACOM_HID_UP_WACOMDIGITIZER | 0x39) #define WACOM_HID_WD_SERIALHI (WACOM_HID_UP_WACOMDIGITIZER | 0x5c) @@ -137,6 +138,12 @@ #define WACOM_HID_UP_G11 0xff110000 #define WACOM_HID_G11_PEN (WACOM_HID_UP_G11 | 0x02) #define WACOM_HID_G11_TOUCHSCREEN (WACOM_HID_UP_G11 | 0x11) +#define WACOM_HID_UP_WACOMTOUCH 0xff000000 +#define WACOM_HID_WT_TOUCHSCREEN (WACOM_HID_UP_WACOMTOUCH | 0x04) +#define WACOM_HID_WT_TOUCHPAD (WACOM_HID_UP_WACOMTOUCH | 0x05) +#define WACOM_HID_WT_CONTACTMAX (WACOM_HID_UP_WACOMTOUCH | 0x55) +#define WACOM_HID_WT_X (WACOM_HID_UP_WACOMTOUCH | 0x130) +#define WACOM_HID_WT_Y (WACOM_HID_UP_WACOMTOUCH | 0x131) #define WACOM_PAD_FIELD(f) (((f)->physical == HID_DG_TABLETFUNCTIONKEY) || \ ((f)->physical == WACOM_HID_WD_DIGITIZERFNKEYS) || \ @@ -154,7 +161,14 @@ ((f)->physical == HID_DG_FINGER) || \ ((f)->application == HID_DG_TOUCHSCREEN) || \ ((f)->application == WACOM_HID_G9_TOUCHSCREEN) || \ - ((f)->application == WACOM_HID_G11_TOUCHSCREEN)) + ((f)->application == WACOM_HID_G11_TOUCHSCREEN) || \ + ((f)->application == WACOM_HID_WT_TOUCHPAD) || \ + ((f)->application == HID_DG_TOUCHPAD)) + +#define WACOM_DIRECT_DEVICE(f) (((f)->application == HID_DG_TOUCHSCREEN) || \ + ((f)->application == WACOM_HID_WT_TOUCHSCREEN) || \ + ((f)->application == HID_DG_PEN) || \ + ((f)->application == WACOM_HID_WD_PEN)) enum { PENPARTNER = 0,