From patchwork Fri Apr 26 16:34:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 10919373 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 D6E771390 for ; Fri, 26 Apr 2019 16:35:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3D491FF87 for ; Fri, 26 Apr 2019 16:35:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B667628A16; Fri, 26 Apr 2019 16:35:04 +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 B04271FF87 for ; Fri, 26 Apr 2019 16:35:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbfDZQfD (ORCPT ); Fri, 26 Apr 2019 12:35:03 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36767 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbfDZQfD (ORCPT ); Fri, 26 Apr 2019 12:35:03 -0400 Received: by mail-pg1-f194.google.com with SMTP id 85so1885625pgc.3; Fri, 26 Apr 2019 09:35:02 -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=QBc1ERbBKPa3hvlajbdfe0XwmY0xuJb+gPy+6oRP6mc=; b=hmXVjHcuYvumSP/rJf93rmTAxapKisfm52zGMM1FInfg3VGyr79u4QlzBo8HF+Cpgh 2YWmN2NuJn3pD7h/jNFmko1IhpazXMEF3HrBI/W56lVmNl8xLrpUoXukruyw9D15gGPO 7GfengEHT7x43rsUOuOyi6XouBmISeUT1TOyaIIQdzxot2ymlUwXAeJVZQ+Pn+Zma392 Ha9fIanInkT1MZKWwBrB9du46KLg+ZNCjIiMzUhbc++JZDvvboCRKTo693J30dB6iadg 6g0sEIvG0DM9av5uq+kqFoR+YGynpLvYqfp3Zmzg5Z36dJ/fkFRSscUo2tKwwgSqqwUQ YiSQ== 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=QBc1ERbBKPa3hvlajbdfe0XwmY0xuJb+gPy+6oRP6mc=; b=HKxv450unBYddcxZ6y6twsESFjWlslRc8wEXHv0vv7G3UAnKhymB86yyore57rXG5g hoeINX6Lt1kv1aZ5z4420smnkZ9TdGc08uL2d2D2VKKfkGxWZHLcbbixFGVGYRlLoO57 jBBrOnj50ibD5/28R1CV+zsQIMgrK2WoGGDiqlf0p2JlLJ1ra79KDYjXFAGgfHfOvyK+ jGfr9u3bbn00lfn1DAhmxTSt1y0xF/KBs5d49YXeAtyz469Dv54jyP0X7CSzabSK+yRU zqddumf2wOTc2z6r+KQiHFcyxcwfdZAPgmEHul4IdWUFOEZdbfaW5EuB7CHhORTLVVhc a+mg== X-Gm-Message-State: APjAAAUapzrvykZIDxjHPWcSXYzH5tGXg7QvTywNBHUkV/U0fZw3sr6W UirbgktNWPnTpee3/lWfiiYP5Bl9 X-Google-Smtp-Source: APXvYqwBhgqe+LTKypDtNNnpXIf11dQD8EVY3yQkCUSApOtTuWJexfricuuceERur1ozUfN9g3PYyg== X-Received: by 2002:a63:a441:: with SMTP id c1mr42342289pgp.307.1556296501789; Fri, 26 Apr 2019 09:35:01 -0700 (PDT) Received: from US-191-ENG0002.corp.onewacom.com ([50.225.60.4]) by smtp.gmail.com with ESMTPSA id j5sm7786981pfg.186.2019.04.26.09.34.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 09:35:00 -0700 (PDT) From: "Gerecke, Jason" X-Google-Original-From: "Gerecke, Jason" To: "# v3.17+" , Sasha Levin Cc: linux-input@vger.kernel.org, Ping Cheng , Aaron Armstrong Skomra , Jason Gerecke , Aaron Armstrong Skomra Subject: [PATCH 1/2] HID: wacom: Don't set tool type until we're in range Date: Fri, 26 Apr 2019 09:34:08 -0700 Message-Id: <20190426163408.9676-1-jason.gerecke@wacom.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190426033328.GB17719@sasha-vm> References: <20190426033328.GB17719@sasha-vm> 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 --- Version of patch specifically targeted to stable v4.14.113 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 4c72e68637c2..03b04bc742dd 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1225,13 +1225,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; @@ -1240,9 +1240,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; + } + /* Fix rotation alignment: userspace expects zero at left */ int16_t rotation = (int16_t)get_unaligned_le16(&frame[9]); rotation += 1800/4;