From patchwork Wed Apr 24 22:12:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 10915819 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 126021515 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 008AA28B81 for ; Wed, 24 Apr 2019 22:13:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E79EC28B86; Wed, 24 Apr 2019 22:13:26 +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 885C228B81 for ; Wed, 24 Apr 2019 22:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731945AbfDXWN0 (ORCPT ); Wed, 24 Apr 2019 18:13:26 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43669 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730399AbfDXWNZ (ORCPT ); Wed, 24 Apr 2019 18:13:25 -0400 Received: by mail-pg1-f195.google.com with SMTP id z9so10073058pgu.10; Wed, 24 Apr 2019 15:13:25 -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:mime-version :content-transfer-encoding; bh=YzX3Aq6PqWF1zFfvKYeYCVTOF+ll2slIYCUeLOvHmQc=; b=vB4zpdPLBeD8m+/sa0/u9CCXbSoU4jHeuA+fIRMq2/xf3Ma/BckyNb/Z4JDIdyDCSG 2bB8ps7k3+3GThOjkwebnoCBj1AIAu4PVAGgbAxwbO4SO67IkqXJPcBc+WaOBGbhgyRs lNKV+mozPU7eCRGb+PXriEIh85dnxIR7B5sfN/zj617Fw+DYOmTafPDDF/VxiiTWzO9w A5rsUa60Q9i0OuQmmzmSVC9AdreYAOoQ/zKTxFEPGHGzEFpFLQdZpnwMxPouZ9jYCls5 rVFMqvE9HSeEQFmhfnJ9WlgOzS6VGOR0y47M8vTrDfcX4w/oAnwpbiwrvhymm+EfymtP qQrA== 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:mime-version :content-transfer-encoding; bh=YzX3Aq6PqWF1zFfvKYeYCVTOF+ll2slIYCUeLOvHmQc=; b=UyhdJHSJ4pSxzQXUWjpkySwOQ24XlB9as7cV+0uPGyGJ8MuzXqSNdTwdNulBpt++n6 kBffYRDg9nyRSmhsJlcPcwlWIznLQ9EUkuNfDT4BFt2xY9JrJ6E+wQJcAhAetHAeCpGN LYRhYRSdeXHEEoak8CvNc3LAv30g4xrkByYlQ+Hi4ZxOzSPeBYWG2PsVp0TA8OBg7nbr gGvaohLoB/DnE8cjB6CweLTXjZfq0OYFvndGbKvTancv3Qz3iwBsQbIg2HABMU6g/ygH WIJI5MdWPYrGRlxxjGUDmEWd3k0p8ytyRvCPw333baGm5DVCxrLPNlw5dbl5cf7MHbam myQA== X-Gm-Message-State: APjAAAUATtIic9LbXp/Kk/1xMOAh/3wnLA7fEcU3aCvsHgsgJsm92wgi XT5BNwvCo9vCuz/VTzxOuG36Z7bR X-Google-Smtp-Source: APXvYqxuj2E0EA0amQ0H8S+l2UWzM+yvTFaScFGNQAId1stM/kJasD6Un0mCRz1iI8wvKEg2a779mw== X-Received: by 2002:aa7:9116:: with SMTP id 22mr28850827pfh.165.1556144004365; Wed, 24 Apr 2019 15:13:24 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 15:13:22 -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 1/2] HID: wacom: Don't set tool type until we're in range Date: Wed, 24 Apr 2019 15:12:57 -0700 Message-Id: <20190424221258.19992-1-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.21.0 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 The serial number and tool type information that is reported by the tablet while a pen is merely "in prox" instead of fully "in range" can be stale and cause us to report incorrect tool information. Serial number, tool type, and other information is only valid once the pen comes fully in range so we should be careful to not use this information until that point. In particular, this issue may cause the driver to incorectly report BTN_TOOL_RUBBER after switching from the eraser tool back to the pen. 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 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 747730d32ab6..4c1bc239207e 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1236,13 +1236,13 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) /* Add back in missing bits of ID for non-USI pens */ wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF; } - wacom->tool[0] = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0])); for (i = 0; i < pen_frames; i++) { unsigned char *frame = &data[i*pen_frame_len + 1]; bool valid = frame[0] & 0x80; bool prox = frame[0] & 0x40; bool range = frame[0] & 0x20; + bool invert = frame[0] & 0x10; if (!valid) continue; @@ -1251,9 +1251,24 @@ static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) wacom->shared->stylus_in_proximity = false; wacom_exit_report(wacom); input_sync(pen_input); + + wacom->tool[0] = 0; + wacom->id[0] = 0; + wacom->serial[0] = 0; return; } + if (range) { + if (!wacom->tool[0]) { /* first in range */ + /* Going into range select tool */ + if (invert) + wacom->tool[0] = BTN_TOOL_RUBBER; + else if (wacom->id[0]) + wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]); + else + wacom->tool[0] = BTN_TOOL_PEN; + } + input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));