Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3008484ybi; Mon, 17 Jun 2019 14:34:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGbFJdOHm8yBxCsnYCZhMkL1yBWbfEbUi3wToOIRMWFG3TTEUH98pEwrZRcR2zuJSZv8wo X-Received: by 2002:aa7:914e:: with SMTP id 14mr64274367pfi.136.1560807274271; Mon, 17 Jun 2019 14:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807274; cv=none; d=google.com; s=arc-20160816; b=gRq2bVsCJVHg1bgQ/DTgiqnmtzlKJikbWF0TD7zB/BFsH7Sod0cS1Fo5jQEdL0LpcU oeu2zHNPLay/w1L9kTsqkJHdoiCo78cz6aIXLs8Kmcrm+/HIlDoPncVVEiSCuQmYuSG6 OfcX7bbVJ1X78TzPscSKgB+eC/gccdmCfO5WfTy38m37shGl2JC25W2AbzFHj1MHUp8C rSuL5qC/QgyviFaNdId+2agNP0bWAsEVQ4epPp5uXpNwOHInoQDRQUeCgE7QaswAAkmw 6FEkxOI5gCQKHx8lgiyHMGh7wmdbB+hcd95QA+bqv2TWWcfcUxWt6r7/ldEspgzuMnrW X0xQ== 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=CfCcMnRQpi0Bp4Xl6Jm3E6cW+FRqmH/5N6yJw6Lj2zc=; b=vUWpqhseR7iKlUEyj27Nw6WoIA79UAF+sNud9zIvsfyZyB8NNv/FYnT4hl4B3vix2K AOft75Xg79235E6XnLsv1D7sJPPqgKrDBSuaQ04h2C/2sU/gW3a7pdQn+XDJWnp0GXn4 ReD43v7ZQ96FVU1CH4n3XI/bm13qG80SSUi/sQB+raObEwYSllOmbZgvLPQM3QiF3JIL qJVP9R5JmlKfk8kkq8/FLCJ3zj3ebeFLE8yJVjf3qy3LvC/zUN4zxzFbByyLsUvGS6lR LFyO0hb4IGgTaOmfyC4GrJMJVS15fgXLhbP7nuK6ZGoCS8EPflSaI41nUF5Vs7x0lSmE km/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="M/ksfGSn"; 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 s14si412714pji.28.2019.06.17.14.34.19; Mon, 17 Jun 2019 14:34:34 -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="M/ksfGSn"; 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 S1730038AbfFQVeR (ORCPT + 99 others); Mon, 17 Jun 2019 17:34:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:50842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729620AbfFQVY7 (ORCPT ); Mon, 17 Jun 2019 17:24:59 -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 BCE2D206B7; Mon, 17 Jun 2019 21:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806698; bh=igOdzN89KKVX8A3h5h5NoYHgXU5ZTK3QVBO+0ZZ7Sbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M/ksfGSn9PzWWgzY8t2BrwbKDI2QQJWKKxDnpCdI8IA1W/JxpdckBssghpefb74J5 4uoiiz+IGtIQptc6trzdKwGy50n4xIGt0K7o4VkR5dZQGKcDiUFEtTTDv04UoMNyIm Mso8uEZGL3oKKajucvIE8BEqcMjAT82o8hKTDp5w= 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 05/75] HID: wacom: Dont report anything prior to the tool entering range Date: Mon, 17 Jun 2019 23:09:16 +0200 Message-Id: <20190617210753.036762812@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 e92a7be7fe5b2510fa60965eaf25f9e3dc08b8cc upstream. 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: 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 | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1288,23 +1288,26 @@ static void wacom_intuos_pro2_bt_pen(str 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;