From patchwork Wed Jun 12 21:19:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Armstrong Skomra X-Patchwork-Id: 10993345 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77193924 for ; Thu, 13 Jun 2019 17:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D440212BE for ; Thu, 13 Jun 2019 17:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51A2D26222; Thu, 13 Jun 2019 17:17:37 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 C36B922B26 for ; Thu, 13 Jun 2019 17:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbfFMRRg (ORCPT ); Thu, 13 Jun 2019 13:17:36 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46210 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728364AbfFLVTx (ORCPT ); Wed, 12 Jun 2019 17:19:53 -0400 Received: by mail-pl1-f196.google.com with SMTP id e5so7137510pls.13 for ; Wed, 12 Jun 2019 14:19:52 -0700 (PDT) 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=TgBqO5bqG7zM63JLBbZ1qUW+9HfnA+3bsQPxH+q5gG0=; b=b3mvr9//KARy849IUyRRXsqlXlcbvxvEOoSCeriYajvzAWzhO9k+AqNHSQZdg7zDCF 8AfjYTDgM2DGh9ymO6leV3KGmb3+hT8FAyVvseTrpNL+bLDtACzM/oC61+G0Y3lnQH0d eAB5dwALRuW4X6J0HcygnIUKVxfo1EtiHpL/INRlxjuXeimxfRCMAH1LQazivZOCR/0k jHhgGQsimrTAud0ApI0c9FVcSeXE1ihqVcys1nPJhxs5i9YkDyb9rc3QolvXTIHFLwxO ckTUeJgsjLT+LWWTuQpmO6KEvhHtO2ti8zBkWYJDniJ/QrdUeQTIWoJlcN4YzjSnU6ST 5rvg== 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=TgBqO5bqG7zM63JLBbZ1qUW+9HfnA+3bsQPxH+q5gG0=; b=ewnYdOdVok4KxtVyzRSshCwsBZZWTchwnWrd8tDooX3syKpMEUMzQyIbi9mM+Dzqn3 WFOJLTD8AXcTF1yJkdQnUMKTAaD9g+b5NCqViA/MZ5g6vufJpbs2mZb67nqxeJdRPYUo PIdmtcAIOQUK2EzaHKaDTutB4EEqShhb/QAxiWZSP3N1vhFXPOz14KKAXbF2X/skAIgh WuR/ImczfTFHQiDDrBEA0zvpM5IyrJgBVyAJp2usTagylQL0AhY4+JxsDrtmT5VTlZg5 uR4VSEHQMwFgn1KdvR8wgKlYAl0Tfg0mUTllh9cS5zsJvn7h4V1E0Kpn262aRIpt7KsB F/gA== X-Gm-Message-State: APjAAAXHm0oD9ce7fqkftWpVLmORBt15/9JY2CIy5NxbhuYMBRpta6xe ESiJBvCsnm7uFRpM3gHl0FKLrC1SeP9z8Q== X-Google-Smtp-Source: APXvYqzuzLDR0cxy5d7BIAPvakuGXfDGNOTRHHOBseKYjfye9e3q9pgMCLPzuMs5AHRDJ4DWAeriVg== X-Received: by 2002:a17:902:29a7:: with SMTP id h36mr31800872plb.158.1560374392060; Wed, 12 Jun 2019 14:19:52 -0700 (PDT) Received: from west.Home ([97.115.133.135]) by smtp.googlemail.com with ESMTPSA id m6sm423283pgr.18.2019.06.12.14.19.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jun 2019 14:19:51 -0700 (PDT) From: Aaron Armstrong Skomra X-Google-Original-From: Aaron Armstrong Skomra To: linux-input@vger.kernel.org, jikos@kernel.org, benjamin.tissoires@redhat.com, pinglinux@gmail.com, jason.gerecke@wacom.com Cc: Aaron Armstrong Skomra Subject: [PATCH 1/4] HID: wacom: Add 2nd gen Intuos Pro Small support Date: Wed, 12 Jun 2019 14:19:28 -0700 Message-Id: <1560374371-2688-2-git-send-email-aaron.skomra@wacom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560374371-2688-1-git-send-email-aaron.skomra@wacom.com> References: <1560374371-2688-1-git-send-email-aaron.skomra@wacom.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 existing INTUOSP2_BT device class supports LEDs and this device does not. A new device class enum entry, "INTUOSP2S_BT", is created to avoid the INTUOSP2_BT LED code. Signed-off-by: Aaron Armstrong Skomra Reviewed-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 30 +++++++++++++++++++++++++----- drivers/hid/wacom_wac.h | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index a98ad4fdcf9e..b764e9d72b5b 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1220,7 +1220,8 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) unsigned char *data = wacom->data; int i; - if (wacom->features.type == INTUOSP2_BT) { + if (wacom->features.type == INTUOSP2_BT || + wacom->features.type == INTUOSP2S_BT) { wacom->serial[0] = get_unaligned_le64(&data[99]); wacom->id[0] = get_unaligned_le16(&data[107]); pen_frame_len = 14; @@ -1257,7 +1258,8 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3])); - if (wacom->features.type == INTUOSP2_BT) { + if (wacom->features.type == INTUOSP2_BT || + wacom->features.type == INTUOSP2S_BT) { /* Fix rotation alignment: userspace expects zero at left */ int16_t rotation = (int16_t)get_unaligned_le16(&frame[9]); @@ -1276,7 +1278,8 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) } } input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); - if (wacom->features.type == INTUOSP2_BT) { + if (wacom->features.type == INTUOSP2_BT || + wacom->features.type == INTUOSP2S_BT) { input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max); } else { @@ -1436,7 +1439,8 @@ static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len) } wacom_intuos_pro2_bt_pen(wacom); - if (wacom->features.type == INTUOSP2_BT) { + if (wacom->features.type == INTUOSP2_BT || + wacom->features.type == INTUOSP2S_BT) { wacom_intuos_pro2_bt_touch(wacom); wacom_intuos_pro2_bt_pad(wacom); wacom_intuos_pro2_bt_battery(wacom); @@ -3204,6 +3208,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) break; case INTUOSP2_BT: + case INTUOSP2S_BT: case INTUOSHT3_BT: sync = wacom_intuos_pro2_bt_irq(wacom_wac, len); break; @@ -3384,7 +3389,8 @@ void wacom_setup_device_quirks(struct wacom *wacom) if (features->type == REMOTE) features->device_type = WACOM_DEVICETYPE_PAD; - if (features->type == INTUOSP2_BT) { + if (features->type == INTUOSP2_BT || + features->type == INTUOSP2S_BT) { features->device_type |= WACOM_DEVICETYPE_PEN | WACOM_DEVICETYPE_PAD | WACOM_DEVICETYPE_TOUCH; @@ -3565,6 +3571,7 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, case INTUOS5S: case INTUOSPS: case INTUOSP2_BT: + case INTUOSP2S_BT: input_set_abs_params(input_dev, ABS_DISTANCE, 0, features->distance_max, features->distance_fuzz, 0); @@ -3676,6 +3683,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, switch (features->type) { case INTUOSP2_BT: + case INTUOSP2S_BT: input_dev->evbit[0] |= BIT_MASK(EV_SW); __set_bit(SW_MUTE_DEVICE, input_dev->swbit); @@ -3691,6 +3699,12 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 5920, 4, 0); } + else if (wacom_wac->shared->touch->product == 0x393) { + input_set_abs_params(input_dev, ABS_MT_POSITION_X, + 0, 6400, 4, 0); + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, + 0, 4000, 4, 0); + } input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40); input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40); @@ -3997,6 +4011,7 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, case INTUOS5S: case INTUOSPS: case INTUOSP2_BT: + case INTUOSP2S_BT: input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); break; @@ -4574,6 +4589,10 @@ static const struct wacom_features wacom_features_0x37A = static const struct wacom_features wacom_features_0x37B = { "Wacom One by Wacom M", 21600, 13500, 2047, 63, BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; +static const struct wacom_features wacom_features_0x393 = + { "Wacom Intuos Pro S", 31920, 19950, 8191, 63, + INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, + .touch_max = 10 }; static const struct wacom_features wacom_features_HID_ANY_ID = { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID }; @@ -4746,6 +4765,7 @@ const struct hid_device_id wacom_ids[] = { { BT_DEVICE_WACOM(0x379) }, { USB_DEVICE_WACOM(0x37A) }, { USB_DEVICE_WACOM(0x37B) }, + { BT_DEVICE_WACOM(0x393) }, { USB_DEVICE_WACOM(0x4001) }, { USB_DEVICE_WACOM(0x4004) }, { USB_DEVICE_WACOM(0x5000) }, diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index f67d871841c0..48f08f8a556d 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -215,6 +215,7 @@ enum { INTUOSPM, INTUOSPL, INTUOSP2_BT, + INTUOSP2S_BT, INTUOSHT3_BT, WACOM_21UX2, WACOM_22HD, From patchwork Wed Jun 12 21:19:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Armstrong Skomra X-Patchwork-Id: 10993343 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 364ED13AD for ; Thu, 13 Jun 2019 17:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19D21212BE for ; Thu, 13 Jun 2019 17:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E67726222; Thu, 13 Jun 2019 17:17:37 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A26BC212BE for ; Thu, 13 Jun 2019 17:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728380AbfFMRRf (ORCPT ); Thu, 13 Jun 2019 13:17:35 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39722 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728367AbfFLVTz (ORCPT ); Wed, 12 Jun 2019 17:19:55 -0400 Received: by mail-pf1-f196.google.com with SMTP id j2so10406411pfe.6 for ; Wed, 12 Jun 2019 14:19:54 -0700 (PDT) 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=+Gs3dUnf0lvFU6Y9D7j4o8m55XLSOT6vzM8Pt6nXjys=; b=jyuvLfQRkx7P8zsLYFIVI/BGnj+qjLHvwn1XelpvFCZrHOtATpyWG4jvgdUqGBsZCF p2H7LpdQpvV1BY8lm0IFbutKaUXIJEiTIuJ/LrIRajoXxQLrZjCt3pb5LceNc5I8zNFj RvtY40GTRTEwBhDY6w28fTiyITN8DVwbRxr+7Z2SUQN7xdnkcWwJmWUH2Xx/J6kStkG+ N1b9ye/sio+kZIUfYms4WjtJWgmEVus3goaY5L7wwWcbHgIcN+/SGA8FfmHXO6trrISb IwDUdPyNZZrwDoKNI6QYOcT7hk7BpdLGcgTzetx7cVG3VYJ5WreINKOquuRjfVSMPanD Jx7A== 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=+Gs3dUnf0lvFU6Y9D7j4o8m55XLSOT6vzM8Pt6nXjys=; b=S04hwX48QiP8AOQ+dlvaS7PaGUJN6eE34313k3PIlZa184lOy2qwf3iqZbfffr7J/1 wYKUhx+jTy3M4TrK93sDOVKlhhWZ3ZB6VMAlNls+kRHcxn4/bRwfI6kjqj7re+8Sa9Bs tv+/ddiBVQp9h6UWttKUMUtDUvAmUtXR7r+bTSlEh9SQC4zmRN3NURRujwxJSpaLl+4A +bBwhY4Ec2bO3of+H6S32SKcJWnskdrN+GdkwexiOs3PqGaUNb1autpLem0rP5rORE1l VOgOzMII3I09dKZXswQO6BoRKbIzch170VMbIUsObOvOBBwMCFwQ0l3bppUan+BlmfYG 0EZg== X-Gm-Message-State: APjAAAVYw8U71oG5BrGcvsMnfN+q2RO7Y1YziJxKoHzh7QvbYxqml/wT wSq2/OR7LXs9yqArEZghnefINiJnCwZEzg== X-Google-Smtp-Source: APXvYqw14+DbF3TCgkcGMwCdOd2YHpY/Kdfag3x8y7Cl4ovTH1ihlLnYMywhuzLuspRhEDkrWwo5Cw== X-Received: by 2002:aa7:8a95:: with SMTP id a21mr89262244pfc.215.1560374394133; Wed, 12 Jun 2019 14:19:54 -0700 (PDT) Received: from west.Home ([97.115.133.135]) by smtp.googlemail.com with ESMTPSA id m6sm423283pgr.18.2019.06.12.14.19.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jun 2019 14:19:53 -0700 (PDT) From: Aaron Armstrong Skomra X-Google-Original-From: Aaron Armstrong Skomra To: linux-input@vger.kernel.org, jikos@kernel.org, benjamin.tissoires@redhat.com, pinglinux@gmail.com, jason.gerecke@wacom.com Cc: Aaron Armstrong Skomra Subject: [PATCH 2/4] HID: wacom: generic: read HID_DG_CONTACTMAX from any feature report Date: Wed, 12 Jun 2019 14:19:29 -0700 Message-Id: <1560374371-2688-3-git-send-email-aaron.skomra@wacom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560374371-2688-1-git-send-email-aaron.skomra@wacom.com> References: <1560374371-2688-1-git-send-email-aaron.skomra@wacom.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 In the generic code path, HID_DG_CONTACTMAX was previously only read from the second byte of report 0x23. Another report (0x82) has the HID_DG_CONTACTMAX in the higher nibble of the third byte. We should support reading the value of HID_DG_CONTACTMAX no matter what report we are reading or which position that value is in. To do this we submit the feature report as a event report using hid_report_raw_event(). Our modified finger event path records the value of HID_DG_CONTACTMAX when it sees that usage. Fixes: 8ffffd5212846 ("HID: wacom: fix timeout on probe for some wacoms") Signed-off-by: Aaron Armstrong Skomra --- drivers/hid/wacom_sys.c | 10 ++++++---- drivers/hid/wacom_wac.c | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 2e3e03df83da..9ec895e5fd00 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -314,14 +314,16 @@ static void wacom_feature_mapping(struct hid_device *hdev, /* leave touch_max as is if predefined */ if (!features->touch_max) { /* read manually */ - data = kzalloc(2, GFP_KERNEL); + n = hid_report_len(field->report); + data = hid_alloc_report_buf(field->report, GFP_KERNEL); if (!data) break; data[0] = field->report->id; ret = wacom_get_report(hdev, HID_FEATURE_REPORT, - data, 2, WAC_CMD_RETRIES); - if (ret == 2) { - features->touch_max = data[1]; + data, n, WAC_CMD_RETRIES); + if (ret == n) { + ret = hid_report_raw_event(hdev, + HID_FEATURE_REPORT, data, n, 0); } else { features->touch_max = 16; hid_warn(hdev, "wacom_feature_mapping: " diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index b764e9d72b5b..678f504239a0 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2492,6 +2492,7 @@ static void wacom_wac_finger_event(struct hid_device *hdev, struct wacom *wacom = hid_get_drvdata(hdev); struct wacom_wac *wacom_wac = &wacom->wacom_wac; unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); + struct wacom_features *features = &wacom->wacom_wac.features; switch (equivalent_usage) { case HID_GD_X: @@ -2512,6 +2513,9 @@ static void wacom_wac_finger_event(struct hid_device *hdev, case HID_DG_TIPSWITCH: wacom_wac->hid_data.tipswitch = value; break; + case HID_DG_CONTACTMAX: + features->touch_max = value; + return; } From patchwork Wed Jun 12 21:19:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Armstrong Skomra X-Patchwork-Id: 10993341 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AA0815E6 for ; Thu, 13 Jun 2019 17:17:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7142F212BE for ; Thu, 13 Jun 2019 17:17:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65C6326223; Thu, 13 Jun 2019 17:17:36 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 ECD6922B26 for ; Thu, 13 Jun 2019 17:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728382AbfFMRRf (ORCPT ); Thu, 13 Jun 2019 13:17:35 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42148 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728380AbfFLVT5 (ORCPT ); Wed, 12 Jun 2019 17:19:57 -0400 Received: by mail-pg1-f193.google.com with SMTP id l19so7010868pgh.9 for ; Wed, 12 Jun 2019 14:19:57 -0700 (PDT) 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=dl6yD7yqASoIUM0WG4fSaC5rnha2MTYjGeTyUb8CVIY=; b=ExDAxRFQAgo81hsSTxYqu66Ji8O+76iPngLb/VjA090rBZeUqvoV0kWBFOeJmL9NOL WmV4zueHk1wgQ8E85UPiz8wvqpmp7T2PZbtbiU0ZtbRQndDZtwwsOTbejjzQTbm3lcZe 9ilx6v8km+LG3fe/WD9XqXsUyGq2geyiYDd3tG7AAO+wj9HRo5HbGRfVVAM+/3RXhxhX M8IEX+Cpz+FyZJMAhxRH0S6HzNrXtRnDyEEzMIX1i9KTAi8Bb+395Cf37lmwFwD03Kv2 hXl12I5PkQ1ua6VduyhNVElEoFBufvIp2dj9SudzZqXsdnjFGvBlo5G5vCxB88YJ4b14 zOTA== 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=dl6yD7yqASoIUM0WG4fSaC5rnha2MTYjGeTyUb8CVIY=; b=L1xRn52u/WzLHenqCt063cd+Ci0b5F7geDJhABdmk/qCfMMRMOsk5JpdDZQ85obLbf GnkjaokqSMLMU9zdFD07JmaMBV1do2NDtiDPvUNBf3sVIpOfeMYDHGR6h4h7K4sRE/KK G7z7gfwMAW0kIn5KeX+qFFSCg76niXlFGjRCM7SV1O1ziPPLwbnbfKAqIodLJjQk8KaX Sbm7nqwMcDtbuheyLtGlH8idv4UOOHYHmUKIA00bwUqWr0qnmcFV7mjI7svUqSGRKC6d 1iyc2pFLNnvbuIzjf7EHHGdDMA5z00x/9LcGuyfx8T9nRhdwIDMkOo/T8g+YNru/esUj EY+g== X-Gm-Message-State: APjAAAXd9hgBMKtLnJ3Np4ndp8ax+bPzZ7ilHM2Q/ufQoiivowOrTIh7 4JaPeCRfaioB7X9TJGEeglaMJNv8sblSOw== X-Google-Smtp-Source: APXvYqzh63wXSiQbTziPBQRnMZX14lvI4Z459t7cVx9tzyA9K/RKUvceKkTM/gpEwUZItP31G/FL0A== X-Received: by 2002:a63:2c01:: with SMTP id s1mr26703289pgs.261.1560374396310; Wed, 12 Jun 2019 14:19:56 -0700 (PDT) Received: from west.Home ([97.115.133.135]) by smtp.googlemail.com with ESMTPSA id m6sm423283pgr.18.2019.06.12.14.19.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jun 2019 14:19:55 -0700 (PDT) From: Aaron Armstrong Skomra X-Google-Original-From: Aaron Armstrong Skomra To: linux-input@vger.kernel.org, jikos@kernel.org, benjamin.tissoires@redhat.com, pinglinux@gmail.com, jason.gerecke@wacom.com Cc: Aaron Armstrong Skomra Subject: [PATCH 3/4] HID: wacom: generic: support the 'report valid' usage for touch Date: Wed, 12 Jun 2019 14:19:30 -0700 Message-Id: <1560374371-2688-4-git-send-email-aaron.skomra@wacom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560374371-2688-1-git-send-email-aaron.skomra@wacom.com> References: <1560374371-2688-1-git-send-email-aaron.skomra@wacom.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 Finger data is separated into chunks in our Bluetooth report, where each report contains the same number of chunks. Those chunks are not aligned in any particular way to a set of finger touches. That is, the first half of a group of simultaneous touches may be in one chunk at the end of a report and the second half could be at the beginning of the next report. Also some chunks contain no data and potentially some chunks could contain leftover (bad) data. Introduce and process the WACOM_HID_WT_REPORT_VALID usage that the device uses to let us know if we should process a chunk of data. Signed-off-by: Aaron Armstrong Skomra --- drivers/hid/wacom_wac.c | 12 +++++++++++- drivers/hid/wacom_wac.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 678f504239a0..67ecd149ad21 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1752,6 +1752,9 @@ int wacom_equivalent_usage(int usage) int subpage = (usage & 0xFF00) << 8; int subusage = (usage & 0xFF); + if (usage == WACOM_HID_WT_REPORT_VALID) + return usage; + if (subpage == HID_UP_UNDEFINED) subpage = WACOM_HID_SP_DIGITIZER; @@ -2494,6 +2497,9 @@ static void wacom_wac_finger_event(struct hid_device *hdev, unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); struct wacom_features *features = &wacom->wacom_wac.features; + if (wacom_wac->is_invalid_bt_frame) + return; + switch (equivalent_usage) { case HID_GD_X: wacom_wac->hid_data.x = value; @@ -2513,12 +2519,14 @@ static void wacom_wac_finger_event(struct hid_device *hdev, case HID_DG_TIPSWITCH: wacom_wac->hid_data.tipswitch = value; break; + case WACOM_HID_WT_REPORT_VALID: + wacom_wac->is_invalid_bt_frame = !value; + return; case HID_DG_CONTACTMAX: features->touch_max = value; return; } - if (usage->usage_index + 1 == field->report_count) { if (equivalent_usage == wacom_wac->hid_data.last_slot_field) wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); @@ -2533,6 +2541,8 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev, struct hid_data* hid_data = &wacom_wac->hid_data; int i; + wacom_wac->is_invalid_bt_frame = false; + for (i = 0; i < report->maxfield; i++) { struct hid_field *field = report->field[i]; int j; diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 48f08f8a556d..1cb63a4a0a41 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h @@ -159,6 +159,7 @@ #define WACOM_HID_WT_SERIALNUMBER (WACOM_HID_UP_WACOMTOUCH | 0x5b) #define WACOM_HID_WT_X (WACOM_HID_UP_WACOMTOUCH | 0x130) #define WACOM_HID_WT_Y (WACOM_HID_UP_WACOMTOUCH | 0x131) +#define WACOM_HID_WT_REPORT_VALID (WACOM_HID_UP_WACOMTOUCH | 0x1d0) #define WACOM_BATTERY_USAGE(f) (((f)->hid == HID_DG_BATTERYSTRENGTH) || \ ((f)->hid == WACOM_HID_WD_BATTERY_CHARGING) || \ From patchwork Wed Jun 12 21:19:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Armstrong Skomra X-Patchwork-Id: 10993339 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71A94924 for ; Thu, 13 Jun 2019 17:17:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56278237F1 for ; Thu, 13 Jun 2019 17:17:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AB8723B24; Thu, 13 Jun 2019 17:17:36 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 BD0E6212BE for ; Thu, 13 Jun 2019 17:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728432AbfFMRRe (ORCPT ); Thu, 13 Jun 2019 13:17:34 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38459 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728382AbfFLVUA (ORCPT ); Wed, 12 Jun 2019 17:20:00 -0400 Received: by mail-pg1-f194.google.com with SMTP id v11so9606430pgl.5 for ; Wed, 12 Jun 2019 14:19:59 -0700 (PDT) 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=jbXWyJaGiOfwS6mYiG2SXG/TJnY2qBshaIYIe+LLt1A=; b=dp29t4oaU3yEO5G9oAc2ontxol5WQq/UZbrxItjnVn1eL694yZ6CEc/5/whbA8+VHV Ar5beHjVgYdlDoaD33WSdkJRErTvwj4ei1HfZCtME7IWyDSj7BYPdjfpAlRQPkK053jb RI4QbaRrgrsopA49XkWxmNNK/z0qp7NwIcBH6U66ONBaT8AwupAQSEqZ+v+2PpLF26LO Hn6COC2sfKb50BryBcryVPNerDl7QNgzJMglI0VELba7JibXQuuf2owlk6PSrtfbMwes 58T9fBEuzD0H18cB1h53eHHa02LHxb+wVTnjxnJ3oU2xqMiRZ88B+nDZGl1HBIS3rb6Z mTrg== 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=jbXWyJaGiOfwS6mYiG2SXG/TJnY2qBshaIYIe+LLt1A=; b=ltPlkeTXWJFC0YkNrgPIFHqINc8tbP6KH2XgjHoaI1k2BHSdX785znecS3ML/cBHcP iL5QfWt28r6EdJJABZ4VnnDuCQE5+fgfiMwmox6dG63NPmdg0oAMk5pIDFP7abkcMIxn YWVXnOyarSk/8PrShoi0PA4GN8+UkYAmmgFGauFo26NDqGlsSgcbbeOWgRwtgSV8THWV 3fZTciDqVG0Y/oTiDpFtuan+XVTHtEx0CkG4qwF3zhb2GKcyLr7PdZFFGrZN5haMIgGJ rEpPUZr3cVnzDnuo3jSmIO+NLERhX7h72PSKKD2mSxibkT5u3s6J0vSpxOzD+EdzZ3Pm td4Q== X-Gm-Message-State: APjAAAXajQ8wI7J4u9bA+ZugZ9WWtHi/lv9tqGIH9kd1v18Snc8iETRG 398X9OsyNLhHTzHQhBvT/4xVNEZ2YgbAAQ== X-Google-Smtp-Source: APXvYqyx7ZKt+0YLJDGkUkv8VC1KWkvHtKa5EH9llikgNK8I7bjOCK3sKdygcNFOJ/jPjZs8vQxJig== X-Received: by 2002:a63:1343:: with SMTP id 3mr27851724pgt.426.1560374398565; Wed, 12 Jun 2019 14:19:58 -0700 (PDT) Received: from west.Home ([97.115.133.135]) by smtp.googlemail.com with ESMTPSA id m6sm423283pgr.18.2019.06.12.14.19.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jun 2019 14:19:57 -0700 (PDT) From: Aaron Armstrong Skomra X-Google-Original-From: Aaron Armstrong Skomra To: linux-input@vger.kernel.org, jikos@kernel.org, benjamin.tissoires@redhat.com, pinglinux@gmail.com, jason.gerecke@wacom.com Cc: Aaron Armstrong Skomra Subject: [PATCH 4/4] HID: wacom: generic: read the number of expected touches on a per collection basis Date: Wed, 12 Jun 2019 14:19:31 -0700 Message-Id: <1560374371-2688-5-git-send-email-aaron.skomra@wacom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560374371-2688-1-git-send-email-aaron.skomra@wacom.com> References: <1560374371-2688-1-git-send-email-aaron.skomra@wacom.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 Bluetooth connections may contain more than one set of touches, or a partial set of touches, in one report. Set the number of expected touches when reading a collection instead of once per report (in the pre-report function). Accordingly, reset the number of touches expected after each sync. Signed-off-by: Aaron Armstrong Skomra --- drivers/hid/wacom_wac.c | 79 ++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 67ecd149ad21..104e6d1f4c80 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2563,25 +2563,9 @@ static void wacom_wac_finger_pre_report(struct hid_device *hdev, case HID_DG_TIPSWITCH: hid_data->last_slot_field = equivalent_usage; break; - case HID_DG_CONTACTCOUNT: - hid_data->cc_report = report->id; - hid_data->cc_index = i; - hid_data->cc_value_index = j; - break; } } } - - if (hid_data->cc_report != 0 && - hid_data->cc_index >= 0) { - struct hid_field *field = report->field[hid_data->cc_index]; - int value = field->value[hid_data->cc_value_index]; - if (value) - hid_data->num_expected = value; - } - else { - hid_data->num_expected = wacom_wac->features.touch_max; - } } static void wacom_wac_finger_report(struct hid_device *hdev, @@ -2591,6 +2575,7 @@ static void wacom_wac_finger_report(struct hid_device *hdev, struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct input_dev *input = wacom_wac->touch_input; unsigned touch_max = wacom_wac->features.touch_max; + struct hid_data *hid_data = &wacom_wac->hid_data; /* If more packets of data are expected, give us a chance to * process them rather than immediately syncing a partial @@ -2604,6 +2589,7 @@ static void wacom_wac_finger_report(struct hid_device *hdev, input_sync(input); wacom_wac->hid_data.num_received = 0; + hid_data->num_expected = 0; /* keep touch state for pen event */ wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac); @@ -2678,12 +2664,73 @@ static void wacom_report_events(struct hid_device *hdev, } } +static void wacom_set_num_expected(struct hid_device *hdev, + struct hid_report *report, + int collection_index, + struct hid_field *field, + int field_index) +{ + struct wacom *wacom = hid_get_drvdata(hdev); + struct wacom_wac *wacom_wac = &wacom->wacom_wac; + struct hid_data *hid_data = &wacom_wac->hid_data; + unsigned int original_collection_level = + hdev->collection[collection_index].level; + bool end_collection = false; + int i; + + if (hid_data->num_expected) + return; + + // find the contact count value for this segment + for (i = field_index; i < report->maxfield && !end_collection; i++) { + struct hid_field *field = report->field[i]; + unsigned int field_level = + hdev->collection[field->usage[0].collection_index].level; + unsigned int j; + + if (field_level != original_collection_level) + continue; + + for (j = 0; j < field->maxusage; j++) { + struct hid_usage *usage = &field->usage[j]; + + if (usage->collection_index != collection_index) { + end_collection = true; + break; + } + if (wacom_equivalent_usage(usage->hid) == HID_DG_CONTACTCOUNT) { + hid_data->cc_report = report->id; + hid_data->cc_index = i; + hid_data->cc_value_index = j; + + if (hid_data->cc_report != 0 && + hid_data->cc_index >= 0) { + + struct hid_field *field = + report->field[hid_data->cc_index]; + int value = + field->value[hid_data->cc_value_index]; + + if (value) + hid_data->num_expected = value; + } + } + } + } + + if (hid_data->cc_report == 0 || hid_data->cc_index < 0) + hid_data->num_expected = wacom_wac->features.touch_max; +} + static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report, int collection_index, struct hid_field *field, int field_index) { struct wacom *wacom = hid_get_drvdata(hdev); + if (WACOM_FINGER_FIELD(field)) + wacom_set_num_expected(hdev, report, collection_index, field, + field_index); wacom_report_events(hdev, report, collection_index, field_index); /*