From patchwork Wed Jan 25 20:08:41 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: 9537869 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 0BD7A6042B for ; Wed, 25 Jan 2017 20:09:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1E9827D4D for ; Wed, 25 Jan 2017 20:09:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5DA427F99; Wed, 25 Jan 2017 20:09:42 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 79B1927D4D for ; Wed, 25 Jan 2017 20:09:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803AbdAYUJl (ORCPT ); Wed, 25 Jan 2017 15:09:41 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34382 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718AbdAYUJl (ORCPT ); Wed, 25 Jan 2017 15:09:41 -0500 Received: by mail-pg0-f66.google.com with SMTP id 3so2782741pgj.1 for ; Wed, 25 Jan 2017 12:09:41 -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=KWcVA4EErE9pMYbn10Xuw4aBFm1KdZLlAdGxCdKaMk8=; b=p6VvFjrmb0dKQYFbmHfQoNnxaXUAnBzCiu2bJG65iG/KsLIzb14MxHrn1wcevLAgrW ILBoAQVB7J2yLLkQghgIPHvSM6cHcWPnOM0DacL4c/PZRsahTscKkDk55+3Q3D0YqrZI EmYRjA8EdT2VuDVnbaRbr1V+sW5VF/bFv/whkp3dKU96VF59kVfSx8GmMSdabaURM3gt RGknrVx4fmHocR9pdS/gvSAQb4nW25+wHBWELZCGfl93K0zlHyEeLu6YRRfjZjG2HX9c d2MK8t4/vM8Q6GGRsFfKTWw+eMJSC46c/BbMjt9qoP5WcoKEsVQpy11EJIvhBcGhOZvG EvLg== 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=KWcVA4EErE9pMYbn10Xuw4aBFm1KdZLlAdGxCdKaMk8=; b=EVW5hBTrtbKd/UC2Qr8niqOVXo1GELy6DwnEEeIT2DhyNnw3cuhJBXENK8gh1nyGeD tLF4yVCJp4kpdEZnjf4RuKSBsCO4ryVS7ANLWMmjROWcqVhf+fluK18/5G+c7g+uZ4sV xEuH3dcpnDu2mM3qRQ4vaGARlmDtlEKlc6NdSXHdh/9lJK+IzPcTtRK5y5ZOjyHEWEFS MmrFGwMvOD9dF8dhzCaGcMOGhIWEm4Dy+bwez8Z4aKfMLarv+8C2rHMx7dkTBy3313S/ 1UthNz6hKCrhoootD+NwIyr0zJp7MjyRe6HY0hl+Zq3sF/x7/C/MIncLA5MhRrq4Ci9C vABw== X-Gm-Message-State: AIkVDXK7xXCuhLL9M5ub5MrFoCkiE3oQ2mOBZzTJryMTF7NV/CdHfjOZtyxPgdQ6gVFmow== X-Received: by 10.84.232.133 with SMTP id i5mr6137750plk.79.1485374980355; Wed, 25 Jan 2017 12:09:40 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Jan 2017 12:09:39 -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 7/8] HID: wacom: generic: support generic touch switch Date: Wed, 25 Jan 2017 12:08:41 -0800 Message-Id: <1485374922-3417-8-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 The second generation Intuos Pro is the first device in the generic codepath which has a touchswitch. We utilize a flag in wacom_shared in order to report this switch event received from the pad on the touch input. Signed-off-by: Aaron Skomra --- drivers/hid/wacom_sys.c | 26 +++++++++++++++++++------- drivers/hid/wacom_wac.c | 19 ++++++++++++++++++- drivers/hid/wacom_wac.h | 4 +++- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index a4884e7..a8e68dc 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -2053,6 +2053,24 @@ static void wacom_release_resources(struct wacom *wacom) wacom->wacom_wac.pad_input = NULL; } +static void wacom_set_shared_values(struct wacom_wac *wacom_wac) +{ + if (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) { + wacom_wac->shared->type = wacom_wac->features.type; + wacom_wac->shared->touch_input = wacom_wac->touch_input; + } + + if (wacom_wac->has_mute_touch_switch) + wacom_wac->shared->has_mute_touch_switch = true; + + if (wacom_wac->shared->has_mute_touch_switch && + wacom_wac->shared->touch_input) { + set_bit(EV_SW, wacom_wac->shared->touch_input->evbit); + input_set_capability(wacom_wac->shared->touch_input, EV_SW, + SW_MUTE_DEVICE); + } +} + static int wacom_parse_and_register(struct wacom *wacom, bool wireless) { struct wacom_wac *wacom_wac = &wacom->wacom_wac; @@ -2172,13 +2190,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) error = hid_hw_open(hdev); - if ((wacom_wac->features.type == INTUOSHT || - wacom_wac->features.type == INTUOSHT2) && - (wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH)) { - wacom_wac->shared->type = wacom_wac->features.type; - wacom_wac->shared->touch_input = wacom_wac->touch_input; - } - + wacom_set_shared_values(wacom_wac); devres_close_group(&hdev->dev, wacom); return 0; diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 2eeaa05..06d152a 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1728,7 +1728,17 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, features->device_type |= WACOM_DEVICETYPE_PAD; break; case WACOM_HID_WD_TOUCHONOFF: - wacom_map_usage(input, usage, field, EV_SW, SW_MUTE_DEVICE, 0); + /* + * This usage, which is used to mute touch events, comes + * from the pad packet, but is reported on the touch + * interface. Because the touch interface may not have + * been created yet, we cannot call wacom_map_usage(). In + * order to process this usage when we receive it, we set + * the usage type and code directly. + */ + wacom_wac->has_mute_touch_switch = true; + usage->type = EV_SW; + usage->code = SW_MUTE_DEVICE; features->device_type |= WACOM_DEVICETYPE_PAD; break; case WACOM_HID_WD_TOUCHSTRIP: @@ -1807,6 +1817,13 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field input_event(input, usage->type, usage->code, 0); break; + case WACOM_HID_WD_TOUCHONOFF: + if (wacom_wac->shared->touch_input) { + input_report_switch(wacom_wac->shared->touch_input, + SW_MUTE_DEVICE, !value); + input_sync(wacom_wac->shared->touch_input); + } + break; default: input_event(input, usage->type, usage->code, value); break; diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index da38f77..4feaf94 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -115,6 +115,7 @@ #define WACOM_HID_WD_ACCELEROMETER_Y (WACOM_HID_UP_WACOMDIGITIZER | 0x0402) #define WACOM_HID_WD_ACCELEROMETER_Z (WACOM_HID_UP_WACOMDIGITIZER | 0x0403) #define WACOM_HID_WD_BATTERY_CHARGING (WACOM_HID_UP_WACOMDIGITIZER | 0x0404) +#define WACOM_HID_WD_TOUCHONOFF (WACOM_HID_UP_WACOMDIGITIZER | 0x0454) #define WACOM_HID_WD_BATTERY_LEVEL (WACOM_HID_UP_WACOMDIGITIZER | 0x043b) #define WACOM_HID_WD_EXPRESSKEY00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0910) #define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0950) @@ -124,7 +125,6 @@ #define WACOM_HID_WD_BUTTONLEFT (WACOM_HID_UP_WACOMDIGITIZER | 0x0993) #define WACOM_HID_WD_BUTTONRIGHT (WACOM_HID_UP_WACOMDIGITIZER | 0x0994) #define WACOM_HID_WD_BUTTONCENTER (WACOM_HID_UP_WACOMDIGITIZER | 0x0995) -#define WACOM_HID_WD_TOUCHONOFF (WACOM_HID_UP_WACOMDIGITIZER | 0x0996) #define WACOM_HID_WD_FINGERWHEEL (WACOM_HID_UP_WACOMDIGITIZER | 0x0d03) #define WACOM_HID_WD_OFFSETLEFT (WACOM_HID_UP_WACOMDIGITIZER | 0x0d30) #define WACOM_HID_WD_OFFSETTOP (WACOM_HID_UP_WACOMDIGITIZER | 0x0d31) @@ -268,6 +268,7 @@ struct wacom_shared { struct input_dev *touch_input; struct hid_device *pen; struct hid_device *touch; + bool has_mute_touch_switch; }; struct hid_data { @@ -324,6 +325,7 @@ struct wacom_wac { int mode_report; int mode_value; struct hid_data hid_data; + bool has_mute_touch_switch; }; #endif