Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3010845ybi; Mon, 17 Jun 2019 14:37:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxffM2Np1MqM8IVvRg9KIr4AhYJIgE7ARY/D6tRztQE6igIlQE6Ck4Lo2Lr96fot/l88xeM X-Received: by 2002:a62:68c4:: with SMTP id d187mr119059738pfc.245.1560807475892; Mon, 17 Jun 2019 14:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807475; cv=none; d=google.com; s=arc-20160816; b=xCUclv8qQcMybXWYcWpSYEx6ZmoH9gAu0xRjFAZZuJpIgGp0XUT8Sp7c3VPctDpCn+ mxc1c2KV9d28D22Ff8dCUbSaQrMYzJ3sWXnP69IBmQfqXijO3tM8bMX3gMwUGuQ0qmJi FzymxZGuzd6z5h+osk5kT6ZZE16cRLB8yS0CM+JZY3nGvIDSA8S/qIVsURBmSxojQeeB m7AFUvtNgh2xJ/iWlpwfN0XbazRQhtn+hOt2K2UoKqILFohmRk44hpa9ZhlX26IueVOs ezAmUlTErgz9Xy0CGKHmWqIPV2LsUfGtOmemw5Z3kRaD9XznXFSh63VVh6OFBnhwxXep MgqA== 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=4fHMH3anfre9qF6QcjElf6ObvMnzf9VeRxLhMTFuVjI=; b=fONbfF4v7/az9NfrLHigREzK2QnNv/hbtn754w2RU9lFxrK/xFjwhTyhqKTU66lX0J KQhtTUw69dkISowazDqVnIPIz6moYz28RVVDQ7SEG+wWT27fgdhRy5Uhp8N1iOYZyLki xGdwrttmxd5V6XGIpJposjDTcCfw+TfsVg04+VmAo/6/yazuPrxOzU6Ve+kN3YcWg2NH IHCZDD0pAV7t5zAyLZ84oa9bxnMnECifV82QvBKQQr6+AktimwVa4LJ69EGov3IAf/e/ d8acGta77mI4fSyPrTMNdGKMVNw6UNw50YCkLO15nRKQfBt/nx9M+SwV4WO18LIrkdBu FZzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kbe1JWpL; 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 x3si11087019pgr.22.2019.06.17.14.37.41; Mon, 17 Jun 2019 14:37:55 -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=Kbe1JWpL; 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 S1729078AbfFQVUV (ORCPT + 99 others); Mon, 17 Jun 2019 17:20:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:44472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729051AbfFQVUT (ORCPT ); Mon, 17 Jun 2019 17:20:19 -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 1C61320861; Mon, 17 Jun 2019 21:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806418; bh=45kesj7+Oxd2NxMEFhNYph4O9Xxx2YyL80b2SXD7kaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kbe1JWpLJisXD0I9Y4vcoYmZIxgZUGW1NvWVjgPj2u31i+QUL6rbrzpKAIWQqezeh IVo5pVfLdPwlR4PG6VA1VNfOUHZW9Wdl4PH18/Dkssm8+Lv+8+dbpBWYPxx2WxfsjG iRsT3HDzDDSPT2IBeeIgDLRmXGijWco5Zyb+Q7Nw= 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 5.1 007/115] HID: wacom: Dont set tool type until were in range Date: Mon, 17 Jun 2019 23:08:27 +0200 Message-Id: <20190617210800.281062213@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@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 @@ -1236,13 +1236,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; @@ -1251,9 +1251,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]));