Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1775635pxp; Mon, 7 Mar 2022 02:02:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3WiwhVl1dmUWg3znE30HmjZhPTcuaM0GHigg3c0lNQV3JXY/f/GCDlsltiU4HYKoBOd1i X-Received: by 2002:a17:902:e302:b0:151:bfe9:da34 with SMTP id q2-20020a170902e30200b00151bfe9da34mr10802524plc.100.1646647366444; Mon, 07 Mar 2022 02:02:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647366; cv=none; d=google.com; s=arc-20160816; b=upx9XXJaumCw1CS1gKqRl4MIoVN8RwifB7cC5AIHoNtgXuqSr1bxf/Yg91+B3CrB2O p1GPFyRh5NvpOxjqCQQmhIjXEreggLelFd2kWB36jdzT8AaMNyPK5ea1VWkNTIRoJXsI J3S2vYg8UQ62m1pZkDYY2ekQDLildgDxpHo9JZlPKDrsAmhEPxYK4g5K1FRnDGMbQzxc kCc2EzZrnqAzp2gP5sUo5DqoXfZKoFWDEMXLZWXaPqojtZb3vlisqVs3FTppvAs3+cz2 LBk5UsFfIEZLmrUk3ULzUFxpCjNEvtGL261IhBTtg8NyX4K6LatgJTugAZnT6ehpEe5z P/OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=igEvj0R4lFDZjtO5OtzGF5xzQf9dorx8kjDj+BqpEvs=; b=QyIRUkbaAz9fb17ixuf/qJR7c9LevQ1hAHGd+nFpG4JUSYoD2V8xwG31zlKmqGLwOu L9g4Vvibf60MOkdYCZH7DdXFnGycWkyMdv8lRNOatuvWSRk3/+BpO0RD0VtgycloDfUV 7ionbb/t7EAheho2JJ9H/6MPjAU1008ysYjV8bRyykGwRCyWcZ0u/gE7Qv/agsPcM3ln Y4ivrGu2VM5Wl1PzpvjOfVt7USiEwJRqdVyeS5e/Fha6xkaEsOUAN53N+Xl9YiB/yt9Q MJw2IMkHgaKB4T60qanHZWE8yNT0FS7uXiL7+dcvEEPSzC2WJND5C9EID3UURdNjdMde taew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T3itxYFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a170902d34a00b00151d89dcddcsi4582127plk.481.2022.03.07.02.02.30; Mon, 07 Mar 2022 02:02:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T3itxYFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236785AbiCGJZD (ORCPT + 99 others); Mon, 7 Mar 2022 04:25:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237196AbiCGJXa (ORCPT ); Mon, 7 Mar 2022 04:23:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45CDD522C6; Mon, 7 Mar 2022 01:22:04 -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 D8544B810C5; Mon, 7 Mar 2022 09:22:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D099C340E9; Mon, 7 Mar 2022 09:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644921; bh=YcUfRZgWEGpn1g4IoP0l5BsEI6IBAvoQlVrFxmlIMIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3itxYFMs5u56QAyiDW2/yd/C6vQJO/RbflT4EEa6qCFzKcRyvMi+CGMa5hhIh+J3 QflWWYnrtIVHf4X0K2/oSvrde9sWT8HeGlS8nu7FABC4P2Not9Rd05e0DwPMXaz4Ap VKyqtvLFg+/isI1WqgXJ3l/NcMHccMaMqYd1Qx5w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Hutterer , Benjamin Tissoires , Jiri Kosina , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Dmitry Torokhov , Sasha Levin Subject: [PATCH 4.14 04/42] Input: clear BTN_RIGHT/MIDDLE on buttonpads Date: Mon, 7 Mar 2022 10:18:38 +0100 Message-Id: <20220307091636.276904052@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.146155347@linuxfoundation.org> References: <20220307091636.146155347@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 cadb368be8eff..cb8ff919ba82b 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -2120,6 +2120,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