From patchwork Wed Apr 24 22:12:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 10915821 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 E2297922 for ; Wed, 24 Apr 2019 22:13:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D002528B81 for ; Wed, 24 Apr 2019 22:13:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C45D628B86; Wed, 24 Apr 2019 22:13:27 +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 6351A28B81 for ; Wed, 24 Apr 2019 22:13:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732370AbfDXWN0 (ORCPT ); Wed, 24 Apr 2019 18:13:26 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:36080 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730399AbfDXWN0 (ORCPT ); Wed, 24 Apr 2019 18:13:26 -0400 Received: by mail-pg1-f195.google.com with SMTP id 85so10100657pgc.3; Wed, 24 Apr 2019 15:13:26 -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 :mime-version:content-transfer-encoding; bh=jnbYhUxzQuCjZ18WmWgdJZMr0kvcvWmIQwnzOA5hoo0=; b=pfyiFXzc2aO3jB4GrbTrMzUj53VQU0dqcpYamsHRQQtmD/LY7jW8VT6UKerfj90JVe iTdW3/bx87sQC2eaNWqo8q3gaC20cAWWtNrOkSEisW3pLA2zK0MyHHe4MYDsmGLpZJwZ KrHstDp6iPsyXqdRuji0kWrjQdA4BcTDeT9VAQKijp9sWc6jrcithh53CYP8ZJErZ3Q1 BPmvexJHiz36eys04C4cWhXtpVmSO+enarztr9h4llbl2xa21pLlhcwSUSsvsOfOL6Tc pAVYFwNA/0nzJSdTSvDRoeVLN4D5iJ5rfVWrGX+5+19R+h8C5NevGrO/TtUjj8GmNV4m FTxQ== 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:mime-version:content-transfer-encoding; bh=jnbYhUxzQuCjZ18WmWgdJZMr0kvcvWmIQwnzOA5hoo0=; b=J5dbCdeCYrA1N6ccv8M/g9ME+Z3d8O/dEY0l7JeBsGp+m5Y//41md5KsFX64A7/1WO vfVSk8BlPYjShogbWJIYPCH9iwZ6f+xpin1SJvsjCdA9rPP15GUZsj7SrvPc6huaTmc2 P56HcStdswj/5l5ZQNN+LzC6JxahyZ3JAykeYoPW/HnHMKDV2u/A5iLkySpdcKoMifzA a3o9vIF2Fx/HWaV5J0svZhgcp/Xhs6jaqN7FFeDt0EV+UM606U9ZK/x8CSA5jLuA8Jka 49fyuxhspaUTJYWaUwrLqBphuACp/XONUGmnRYPEUo9x5NnBC+HT4TlAdkQCtOToYxM6 q14g== X-Gm-Message-State: APjAAAWYcIO3GPqIqFG9b+XiaUhR8y6fZB80dTnj51fez5G9ecHJvPlw 9U9IaZ0ha8qQl0zfaE8ZxiIiBSSb X-Google-Smtp-Source: APXvYqwmExcm9c7SD5pUQDaUCNI96aA+TGZTd0jp9WdRf8JNu+KqL7JdYrlvicVXWXpc4BRkj2WRZg== X-Received: by 2002:a62:5797:: with SMTP id i23mr36055454pfj.12.1556144005479; Wed, 24 Apr 2019 15:13:25 -0700 (PDT) Received: from US-191-ENG0002.corp.onewacom.com ([50.225.60.4]) by smtp.gmail.com with ESMTPSA id l15sm23929427pfi.79.2019.04.24.15.13.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 15:13:24 -0700 (PDT) From: "Gerecke, Jason" X-Google-Original-From: "Gerecke, Jason" To: linux-input@vger.kernel.org, Benjamin Tissoires Cc: Ping Cheng , Aaron Armstrong Skomra , Jason Gerecke , stable@vger.kernel.org, Aaron Armstrong Skomra Subject: [PATCH 2/2] HID: wacom: Don't report anything prior to the tool entering range Date: Wed, 24 Apr 2019 15:12:58 -0700 Message-Id: <20190424221258.19992-2-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424221258.19992-1-jason.gerecke@wacom.com> References: <20190424221258.19992-1-jason.gerecke@wacom.com> MIME-Version: 1.0 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 From: Jason Gerecke If the tool spends some time in prox before entering range, a series of events (e.g. ABS_DISTANCE, MSC_SERIAL) can be sent before we or userspace have any clue about the pen whose data is being reported. We need to hold off on reporting anything until the pen has entered range. Since we still want to report events that occur "in prox" after the pen has *left* range we use 'wacom-tool[0]' as the indicator that the pen did at one point enter range and provide us/userspace with tool type and serial number information. Fixes: a48324de6d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range") Cc: # 4.11+ Signed-off-by: Jason Gerecke Reviewed-by: Aaron Armstrong Skomra --- drivers/hid/wacom_wac.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 4c1bc239207e..613342bb9d6b 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1290,23 +1290,26 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) get_unaligned_le16(&frame[11])); } } - input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); - if (wacom->features.type == INTUOSP2_BT) { - input_report_abs(pen_input, ABS_DISTANCE, - range ? frame[13] : wacom->features.distance_max); - } else { - input_report_abs(pen_input, ABS_DISTANCE, - range ? frame[7] : wacom->features.distance_max); - } - input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01); - input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02); - input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04); + if (wacom->tool[0]) { + input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); + if (wacom->features.type == INTUOSP2_BT) { + input_report_abs(pen_input, ABS_DISTANCE, + range ? frame[13] : wacom->features.distance_max); + } else { + input_report_abs(pen_input, ABS_DISTANCE, + range ? frame[7] : wacom->features.distance_max); + } + + input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01); + input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02); + input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04); - input_report_key(pen_input, wacom->tool[0], prox); - input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]); - input_report_abs(pen_input, ABS_MISC, - wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */ + input_report_key(pen_input, wacom->tool[0], prox); + input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]); + input_report_abs(pen_input, ABS_MISC, + wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */ + } wacom->shared->stylus_in_proximity = prox;