Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4245884pxb; Mon, 8 Feb 2021 11:20:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwK6OXNdZkk3ZIpKJUOaMLSzmTUiLFFLeo9lGDv6EsLtIcnsO5KgLbX22Xr19BUNKiaTrXH X-Received: by 2002:aa7:ce18:: with SMTP id d24mr14204411edv.376.1612812051475; Mon, 08 Feb 2021 11:20:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612812051; cv=none; d=google.com; s=arc-20160816; b=qCD3UJwJzpDWU8fhlpekfvtCozPGzWVVe2v6EeeU1aoKcHaKBeXN8USZk4CLpcpla6 +eJusrtmyp6R595cL96U8vO/J7T3Qbfa5uMeW5P4/ReCCnK36cNEP2nobRO1Y17mxjQB sL6FTIs19XxLRWrMf0XQaYJ8zGKpk1/X+h8VsIqbuow5CZzPzCz8XDmQhn6Sa07YMiiy LIjv+TA0kJ8oXrGSyxolk8hy+oFXT0Wbwz4VSp4P3nUqiYVRvNjDjU1NZI7y4x0PtU66 Pf9ict43GI5mCXcW27sOf9VUwUG63I4YxFHFqLsIms3IyUoB8krx0mJu/vitI6SSSdGc XaYw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=whrsztdWgXv1TfLJF6BxiqBOIEKlVIfHyisOrmhexBY=; b=xSzNJYOsRc8wiCoihL2zW/uZ6ZWGO3XlkXD3xTngyG00zkgqudEU/Hp1/Y+xlKZnjH DCBEaO5EcKo59DFj3lT5TV91v4QZDYTbetqTaNXOj1LRtXJqfZ6+SkOkhz7hJ1hBmXuz GrciYEUZdb0oiQK7cYw8bDa5U5FpDw1blBwBC6ClTqiMEuX+WygkIyL9FoGgUMbXBQtL d1J8oer+lttqHi9viOR0pQET/Z5Wen3p1ZNKUDXcJCEUSXcCM2p4t+Smeeez4GUsMOQP pXt1Ao+Rdf6LB2QuKVDfnFMpmvwRhhWnrjaTRIeQHBqSoDkuQNM0p4ZbBHgV2aqBt870 1Jdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="u1v8/jik"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du8si11301921ejc.659.2021.02.08.11.20.28; Mon, 08 Feb 2021 11:20:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="u1v8/jik"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230154AbhBHTTq (ORCPT + 99 others); Mon, 8 Feb 2021 14:19:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:46598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235137AbhBHR7o (ORCPT ); Mon, 8 Feb 2021 12:59:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7C9BC64E8B; Mon, 8 Feb 2021 17:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612807099; bh=N22Zf85f0trjNoELs3GnoGMbbStZyq3DAIB/qb+HGCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u1v8/jik+grw87np1PptmGJfMx8wZwdQh2Kt5BZKFrCHmjE0Q6/i6IKJpXtgr0h1M 9L4HaD0ymxCEmlb8Sz8Y05WZNEmMoFxoyZCW8qscGhK/LFb3cxD0/F2ftZ7BUBTCp9 zDOAAiEPtg7SQ8XT5XLy6qirA4ZAnSwSL8Kz8j0eAwY6Cbx0kUaUZjCLX6ggBbM/4v Rt5dz5WSnJtL89Vxg+I/ghxX0OyykxIP0UjhFFNCuatgOS3MsgPetd6yNKqXICY1yJ 24oUxCvumgUQyhvoEiBL0o+TqYHcZZ5ENZ3tmJuUedxeGU586TJXxWW13sQS2h3tVI CKSB3QC5+ZT6w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans de Goede , =?UTF-8?q?Stefan=20Br=C3=BCns?= , Mark Gross , Sasha Levin , platform-driver-x86@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 09/36] platform/x86: hp-wmi: Disable tablet-mode reporting by default Date: Mon, 8 Feb 2021 12:57:39 -0500 Message-Id: <20210208175806.2091668-9-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210208175806.2091668-1-sashal@kernel.org> References: <20210208175806.2091668-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-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit 67fbe02a5cebc3c653610f12e3c0424e58450153 ] Recently userspace has started making more use of SW_TABLET_MODE (when an input-dev reports this). Specifically recent GNOME3 versions will: 1. When SW_TABLET_MODE is reported and is reporting 0: 1.1 Disable accelerometer-based screen auto-rotation 1.2 Disable automatically showing the on-screen keyboard when a text-input field is focussed 2. When SW_TABLET_MODE is reported and is reporting 1: 2.1 Ignore input-events from the builtin keyboard and touchpad (this is for 360° hinges style 2-in-1s where the keyboard and touchpads are accessible on the back of the tablet when folded into tablet-mode) This means that claiming to support SW_TABLET_MODE when it does not actually work / reports correct values has bad side-effects. The check in the hp-wmi code which is used to decide if the input-dev should claim SW_TABLET_MODE support, only checks if the HPWMI_HARDWARE_QUERY is supported. It does *not* check if the hardware actually is capable of reporting SW_TABLET_MODE. This leads to the hp-wmi input-dev claiming SW_TABLET_MODE support, while in reality it will always report 0 as SW_TABLET_MODE value. This has been seen on a "HP ENVY x360 Convertible 15-cp0xxx" and this likely is the case on a whole lot of other HP models. This problem causes both auto-rotation and on-screen keyboard support to not work on affected x360 models. There is no easy fix for this, but since userspace expects SW_TABLET_MODE reporting to be reliable when advertised it is better to not claim/report SW_TABLET_MODE support at all, then to claim to support it while it does not work. To avoid the mentioned problems, add a new enable_tablet_mode_sw module-parameter which defaults to false. Note I've made this an int using the standard -1=auto, 0=off, 1=on triplett, with the hope that in the future we can come up with a better way to detect SW_TABLET_MODE support. ATM the default auto option just does the same as off. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1918255 Cc: Stefan Brüns Signed-off-by: Hans de Goede Acked-by: Mark Gross Link: https://lore.kernel.org/r/20210120124941.73409-1-hdegoede@redhat.com Signed-off-by: Sasha Levin --- drivers/platform/x86/hp-wmi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 18bf8aeb5f870..e94e59283ecb9 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -32,6 +32,10 @@ MODULE_LICENSE("GPL"); MODULE_ALIAS("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C"); MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); +static int enable_tablet_mode_sw = -1; +module_param(enable_tablet_mode_sw, int, 0444); +MODULE_PARM_DESC(enable_tablet_mode_sw, "Enable SW_TABLET_MODE reporting (-1=auto, 0=no, 1=yes)"); + #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" #define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4" @@ -654,10 +658,12 @@ static int __init hp_wmi_input_setup(void) } /* Tablet mode */ - val = hp_wmi_hw_state(HPWMI_TABLET_MASK); - if (!(val < 0)) { - __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); - input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val); + if (enable_tablet_mode_sw > 0) { + val = hp_wmi_hw_state(HPWMI_TABLET_MASK); + if (val >= 0) { + __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); + input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val); + } } err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL); -- 2.27.0