From patchwork Fri Nov 15 20:00:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 3189611 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C2D099F432 for ; Fri, 15 Nov 2013 20:00:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DD982094A for ; Fri, 15 Nov 2013 20:00:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A79C208FE for ; Fri, 15 Nov 2013 20:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753161Ab3KOUAM (ORCPT ); Fri, 15 Nov 2013 15:00:12 -0500 Received: from mail-pd0-f175.google.com ([209.85.192.175]:33841 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753143Ab3KOUAL (ORCPT ); Fri, 15 Nov 2013 15:00:11 -0500 Received: by mail-pd0-f175.google.com with SMTP id w10so1799453pde.20 for ; Fri, 15 Nov 2013 12:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Gjj5I2BfFtWmbqNeGZG9h7m6Zy5n0/XnqeUBn4I8ilM=; b=sSeZEqgJUEMnVpxP5K/KEePAL3U4UrKblXKGoM0qY43GsC3MQfXUZKq760FJyHUsGZ LlNEPhoqGmhHIgmHlodvhpDx+8n5rJAMriNZfv2goZPkwTs2EL2pX1QHbPqeWT1qidaz 9y+08fUN7Kq6NUEjGs3JpEuv5LS/PnLwL9S7KKVG/KWOBxqoqh1v9fHfXq+1YpaQIix8 EUMQK5FdyFbyLcW60cl1PT/6wVfYy7kZwPn0cqm37GMK9XI9OpMpw/VjhEz0c4veAsXR 1Y8R8kBd4Y6jriAuhuJcBrHHa1Mbc0t7myZFj9pwrV339irjiiAp7L7gBvreOpEmUgfF FXaQ== X-Received: by 10.68.216.132 with SMTP id oq4mr8344755pbc.50.1384545610618; Fri, 15 Nov 2013 12:00:10 -0800 (PST) Received: from wacom-XPS-8500.wacom.com ([67.51.163.2]) by mx.google.com with ESMTPSA id qn1sm6323202pbc.34.2013.11.15.12.00.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Nov 2013 12:00:09 -0800 (PST) From: Ping Cheng To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, killertofu@gmail.com, chris@cnpbagwell.com, peter.hutterer@who-t.net, Ping Cheng Subject: [PATCH 4/4 v3] Input: wacom - add SW_TOUCH to include/uapi/linux/input.h Date: Fri, 15 Nov 2013 12:00:02 -0800 Message-Id: <1384545602-15549-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.8.3.2 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 New Intuos series models added a hardware switch to turn touch data on/off. To report the state of the switch, SW_TOUCH is added in include/uapi/linux/input.h. Acked-by: Peter Hutterer Tested-by: Jason Gerecke Signed-off-by: Ping Cheng Reviewed-by: Chris Bagwell --- drivers/input/tablet/wacom_sys.c | 12 ++++++++++++ drivers/input/tablet/wacom_wac.c | 30 +++++++++++++++++++++++++++--- drivers/input/tablet/wacom_wac.h | 5 +++++ include/uapi/linux/input.h | 1 + 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 3a7d99c..bb72fa3 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -1193,6 +1193,8 @@ static void wacom_wireless_work(struct work_struct *work) wacom_wac1->features.device_type = BTN_TOOL_PEN; snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", wacom_wac1->features.name); + wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max; + wacom_wac1->shared->type = wacom_wac1->features.type; error = wacom_register_input(wacom1); if (error) goto fail; @@ -1214,6 +1216,10 @@ static void wacom_wireless_work(struct work_struct *work) error = wacom_register_input(wacom2); if (error) goto fail; + + if (wacom_wac1->features.type == INTUOSHT && + wacom_wac1->features.touch_max) + wacom_wac->shared->touch_input = wacom_wac2->input; } error = wacom_initialize_battery(wacom); @@ -1392,6 +1398,12 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i goto fail5; } } + + if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) { + if (wacom_wac->features.device_type == BTN_TOOL_FINGER) + wacom_wac->shared->touch_input = wacom_wac->input; + } + return 0; fail5: wacom_destroy_leds(wacom); diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index c0cd85d..70beca8 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c @@ -1220,13 +1220,23 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom) static int wacom_bpt_pen(struct wacom_wac *wacom) { + struct wacom_features *features = &wacom->features; struct input_dev *input = wacom->input; unsigned char *data = wacom->data; int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0; - if (data[0] != WACOM_REPORT_PENABLED) + if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB) return 0; + if (data[0] == WACOM_REPORT_USB) { + if ((features->type == INTUOSHT) && features->touch_max) { + input_report_switch(wacom->shared->touch_input, + SW_TOUCH, data[8] & 0x40); + input_sync(wacom->shared->touch_input); + } + return 0; + } + prox = (data[1] & 0x20) == 0x20; /* @@ -1259,8 +1269,8 @@ static int wacom_bpt_pen(struct wacom_wac *wacom) * touching and applying pressure; do not report negative * distance. */ - if (data[8] <= wacom->features.distance_max) - d = wacom->features.distance_max - data[8]; + if (data[8] <= features->distance_max) + d = features->distance_max - data[8]; pen = data[1] & 0x01; btn1 = data[1] & 0x02; @@ -1311,6 +1321,13 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len) if (connected) { int pid, battery; + if ((wacom->shared->type == INTUOSHT) && + wacom->shared->touch_max) { + input_report_switch(wacom->shared->touch_input, + SW_TOUCH, data[5] & 0x40); + input_sync(wacom->shared->touch_input); + } + pid = get_unaligned_be16(&data[6]); battery = data[5] & 0x3f; if (wacom->pid != pid) { @@ -1780,6 +1797,13 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, break; case INTUOSHT: + if (features->touch_max && + (features->device_type == BTN_TOOL_FINGER)) { + input_dev->evbit[0] |= BIT_MASK(EV_SW); + __set_bit(SW_TOUCH, input_dev->swbit); + } + /* fall through */ + case BAMBOO_PT: __clear_bit(ABS_MISC, input_dev->absbit); diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h index 854cceb..3600cf7 100644 --- a/drivers/input/tablet/wacom_wac.h +++ b/drivers/input/tablet/wacom_wac.h @@ -55,6 +55,7 @@ #define WACOM_REPORT_TPC1FGE 18 #define WACOM_REPORT_24HDT 1 #define WACOM_REPORT_WL 128 +#define WACOM_REPORT_USB 192 /* device quirks */ #define WACOM_QUIRK_MULTI_INPUT 0x0001 @@ -131,6 +132,10 @@ struct wacom_features { struct wacom_shared { bool stylus_in_proximity; bool touch_down; + /* for wireless device to access USB interfaces */ + unsigned touch_max; + int type; + struct input_dev *touch_input; }; struct wacom_wac { diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index a372627..fcddcb1 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -856,6 +856,7 @@ struct input_keymap_entry { #define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */ #define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */ #define SW_LINEIN_INSERT 0x0d /* set = inserted */ +#define SW_TOUCH 0x0e /* set = touch switch turned on (touch events off) */ #define SW_MAX 0x0f #define SW_CNT (SW_MAX+1)