Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3009318ybi; Mon, 17 Jun 2019 14:35:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxUCmaf4JQ1K0/zOqKSFImY3+QqCHWB7yQSJf0HJ9rZWEnd3BpIICvFo4MDaVfz1aBr9Wq X-Received: by 2002:a17:90a:c503:: with SMTP id k3mr1260433pjt.46.1560807342529; Mon, 17 Jun 2019 14:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807342; cv=none; d=google.com; s=arc-20160816; b=y6JuNIe0c7DneP4roxQ+6v/Ul+Uc/ZezORbnTLt676B4GNZP0nYD292GM2rbz9mZSy sURBQ3u5Uy/kkz+TAcVPFigaVN6avQbxc92NBv9D4v97U3QXtJFqO6PLTcd5sfqvX5wj ukgmxCp95Eq85ugFhXykXRRa2/8bWZNHZwS7SUCG76XsK/ESqaB3K4zn1FpLZAM8xhSF dy1afN1omjLlxScIwuQNZrJ8y+9LmEVO+kx6NsC9WJeqx5W5hZBCDh27xpHEp2lIda3u ZyEvydjTTqPjkrQQVgk3PTT8uhGY/m7uJStng7mBsWYvpOwYhYpAGj5Ca40tHIqh3ZmA DRrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rje667VUYUcjOT5gvbU5GSTRJnzjcb7cZ7N53t5f2ho=; b=HsvNFdKTuJSmBwjAUHPcDgEpdW5q6ib7TiMEitusUoo17X2YNNqWoggsZR6aonrWhq oycxTrjApdell6+TicyYq3GQtn5ybjYYEzYvnbSeKi2ob3216BTsSHpS1Y9r/k/519xv NJaiwpANwyfxUurO3kbkRJUezpeyiZLcmOt+C9ULv1dekwdiJopCjr7i0Ttf1HyDzhSP x9lurIfXGO1MQCUn8HZTZT4IBI3dgYXpwW3wfvSQ6y2mqOwKq3LNN7wAjjQouK+8KTTq PFRgYvb2d8t6uHyY9az9SFISEJTl4sFg+BDwDCLiWMr5ZfH8puWtlUt2teTAyiRTPy3p EDJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YMlYHdr2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2si336725pju.5.2019.06.17.14.35.27; Mon, 17 Jun 2019 14:35:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YMlYHdr2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729436AbfFQVZB (ORCPT + 99 others); Mon, 17 Jun 2019 17:25:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:50798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730002AbfFQVY4 (ORCPT ); Mon, 17 Jun 2019 17:24:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1EBC22063F; Mon, 17 Jun 2019 21:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806695; bh=w/hydCOjqgW8uONSveZfIb+bT2z90YdWoK/qwoTe1VU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YMlYHdr2Jo0iOnbMDYONDOv7UA/CoP8H8w/E5Oj53tyESXfiEG9yKI8euAT2ZUVLM gQF0MHG8uizoHrhvUfL+vzYTRQ7NnoUR7SpsMGONal8SVqJo9BbL8gMNYbdJTqLt/w PYmSMt6jVcVikd2bxOIw5szVJHDP0HNwSQTX7Yoo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gerecke , Aaron Armstrong Skomra , Benjamin Tissoires Subject: [PATCH 4.19 04/75] HID: wacom: Dont set tool type until were in range Date: Mon, 17 Jun 2019 23:09:15 +0200 Message-Id: <20190617210753.003156342@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210752.799453599@linuxfoundation.org> References: <20190617210752.799453599@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gerecke commit 2cc08800a6b9fcda7c7afbcf2da1a6e8808da725 upstream. 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: a48324de6d4d ("HID: wacom: Bluetooth IRQ for Intuos Pro should handle prox/range") Cc: # 4.11+ Signed-off-by: Jason Gerecke Reviewed-by: Aaron Armstrong Skomra Signed-off-by: Benjamin Tissoires Signed-off-by: Greg Kroah-Hartman --- drivers/hid/wacom_wac.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1234,13 +1234,13 @@ static void wacom_intuos_pro2_bt_pen(str /* 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; @@ -1249,9 +1249,24 @@ static void wacom_intuos_pro2_bt_pen(str 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]));