From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92B9AC43217 for ; Wed, 23 Feb 2022 02:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237633AbiBWCjL (ORCPT ); Tue, 22 Feb 2022 21:39:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237876AbiBWCic (ORCPT ); Tue, 22 Feb 2022 21:38:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2B275F4D1; Tue, 22 Feb 2022 18:33:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8D000B81E1D; Wed, 23 Feb 2022 02:33:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35228C340EB; Wed, 23 Feb 2022 02:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645583590; bh=+6XjYk4EJwm/J+lyiGtf8jIrpFJkTC+MKtWsP5gwjrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bY7uF0MZ3YPsw8A7sPlRzddGTu01FaRYcidmQ3qIMIW7MtEQ8xl2DGkm/qN5Kc83R FxwgXF51XOc0cNhc/bcReNj8qyIuOYHWUPtLMTH/++nGiaEJIBMt5rlz+0G1x+Z/ab YGI4RmvZ1+gXQ7ja2COc6b/00SAwEBGFJ3qoPXSRXycNou06oeuoamtIJlSIaLMcru pcmdaVhmgcfCjwMz11t3hJ16kb7LsU3d/ttg/Lrn3R6IYDgwlyhbop1DhW8uztIzhg aqHhxBnhOT9IANZl4OojCHiVosRMJcE4v1PYjP0o0zy1DDXyhOPBRIwkivGFRfRcPe XwnshCLAZa+9w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Peter Hutterer , Benjamin Tissoires , Jiri Kosina , Dmitry Torokhov , Sasha Levin , linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 4/9] Input: clear BTN_RIGHT/MIDDLE on buttonpads Date: Tue, 22 Feb 2022 21:32:55 -0500 Message-Id: <20220223023300.242616-4-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220223023300.242616-1-sashal@kernel.org> References: <20220223023300.242616-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: José Expósito [ Upstream commit 37ef4c19b4c659926ce65a7ac709ceaefb211c40 ] Buttonpads are expected to map the INPUT_PROP_BUTTONPAD property bit and the BTN_LEFT key bit. As explained in the specification, where a device has a button type value of 0 (click-pad) or 1 (pressure-pad) there should not be discrete buttons: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/touchpad-windows-precision-touchpad-collection#device-capabilities-feature-report However, some drivers map the BTN_RIGHT and/or BTN_MIDDLE key bits even though the device is a buttonpad and therefore does not have those buttons. This behavior has forced userspace applications like libinput to implement different workarounds and quirks to detect buttonpads and offer to the user the right set of features and configuration options. For more information: https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/726 In order to avoid this issue clear the BTN_RIGHT and BTN_MIDDLE key bits when the input device is register if the INPUT_PROP_BUTTONPAD property bit is set. Notice that this change will not affect udev because it does not check for buttons. See systemd/src/udev/udev-builtin-input_id.c. List of known affected hardware: - Chuwi AeroBook Plus - Chuwi Gemibook - Framework Laptop - GPD Win Max - Huawei MateBook 2020 - Prestigio Smartbook 141 C2 - Purism Librem 14v1 - StarLite Mk II - AMI firmware - StarLite Mk II - Coreboot firmware - StarLite Mk III - AMI firmware - StarLite Mk III - Coreboot firmware - StarLabTop Mk IV - AMI firmware - StarLabTop Mk IV - Coreboot firmware - StarBook Mk V Acked-by: Peter Hutterer Acked-by: Benjamin Tissoires Acked-by: Jiri Kosina Signed-off-by: José Expósito Link: https://lore.kernel.org/r/20220208174806.17183-1-jose.exposito89@gmail.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/input/input.c b/drivers/input/input.c index 5d94fc3fce0bb..cb31236425a11 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -2112,6 +2112,12 @@ int input_register_device(struct input_dev *dev) /* KEY_RESERVED is not supposed to be transmitted to userspace. */ __clear_bit(KEY_RESERVED, dev->keybit); + /* Buttonpads should not map BTN_RIGHT and/or BTN_MIDDLE. */ + if (test_bit(INPUT_PROP_BUTTONPAD, dev->propbit)) { + __clear_bit(BTN_RIGHT, dev->keybit); + __clear_bit(BTN_MIDDLE, dev->keybit); + } + /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ input_cleanse_bitmasks(dev); -- 2.34.1