From patchwork Thu Apr 17 01:37:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 882433 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0EB1D184E; Thu, 17 Apr 2025 01:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744853848; cv=none; b=IMNiQoDvg7Cw3jG/C1RzMf/KZCLv9MRGTtoA8vBACi6pJV6TugeXV80HfJaUhtMBgujdpQEBqiM0t0Vm1MnpECQOg75suX/dBCrJiVYTXSuAtT8qc/fLzhLeATUgD+EBCDVTs0r8/E3nRTW5cBGOQHsiSEUhYjjs29NdbXXFgHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744853848; c=relaxed/simple; bh=naFJ//8u1SLM3gWsJv/jw8t60Qpo42QfRvPCnltX5f0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=loN9en2RKRMZxaTGoqpxhVmhNkZfsLyDSWU/ZpinqyUgwhdI538LeiGFXncpnMUwIQUn6BnBJ1b2ByBWaUVoTG9E8AV/TgHQ7A9KwIuv8p65V8MStHqyDJRXq3DYV7iw73U3JbvhpLBfAWZfJpxLPe67AWYJHkB7JJKTBuwrEgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QbDeBJBW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QbDeBJBW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FB22C4CEE2; Thu, 17 Apr 2025 01:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744853847; bh=naFJ//8u1SLM3gWsJv/jw8t60Qpo42QfRvPCnltX5f0=; h=From:To:Cc:Subject:Date:From; b=QbDeBJBWsWxyiyke2jp/6f3csFGrpNMQzYAWGuwNlHqVp1fYKVV/PDu+jRx+KgkiC Xh3AOO51+bVQgLmnTnLaklkgwqY7+AOcuBJ+Xo/wmc4P4C1gKUZzywNME2HakryJN5 kUHgHZmh70T45uGziindDFFqzz8iATSYGZchsp2n73lq3Vfp1g6UJULR2eLN7tY++Z vswlrhi04CJgf2pGPM+LHbYXtFtwl1l42aF4G2eHxXxI9MxFoOHidiWchFdJsXPPb7 o+ddc2+6tsfGL9G+ovebQcmovdIVGTKvOq/mOpBRLl6qht7GrD815ChUFOX5NdixWB MQh2GBQIDDDog== From: Mario Limonciello To: Dmitry Torokhov , Shyam Sundar S K , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: Hans de Goede , linux-input@vger.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...), linux-kernel@vger.kernel.org (open list), platform-driver-x86@vger.kernel.org (open list:AMD PMF DRIVER), Mario Limonciello , Armin Wolf Subject: [PATCH v3 1/2] Input: Add a Kconfig to emulate KEY_SCREENLOCK with META + L Date: Wed, 16 Apr 2025 20:37:21 -0500 Message-ID: <20250417013722.435751-1-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello In the PC industry KEY_SCREENLOCK isn't used as frequently as it used to be. Modern versions of Windows [1], GNOME and KDE support "META" + "L" to lock the screen. Modern hardware [2] also sends this sequence of events for keys with a silkscreen for screen lock. Introduced a new Kconfig option that will change KEY_SCREENLOCK when emitted by driver to META + L. Link: https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec [1] Link: https://www.logitech.com/en-us/shop/p/k860-split-ergonomic.920-009166 [2] Suggested-by: Armin Wolf Signed-off-by: Mario Limonciello --- v3: * Emulation in the input core instead drivers/input/Kconfig | 8 ++++++++ drivers/input/input.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index 88ecdf5218ee9..ffb4163fe315f 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -174,6 +174,14 @@ config INPUT_APMPOWER To compile this driver as a module, choose M here: the module will be called apm-power. +config INPUT_SCREENLOCK_EMULATION + bool "Pass KEY_SCREENLOCK as META + L" + help + Say Y here if you want KEY_SCREENLOCK to be passed to userspace as + META + L. + + If unsure, say Y. + comment "Input Device Drivers" source "drivers/input/keyboard/Kconfig" diff --git a/drivers/input/input.c b/drivers/input/input.c index dfeace85c4710..08a857cea0c5d 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -370,6 +370,13 @@ void input_handle_event(struct input_dev *dev, } } +static void handle_screenlock_as_meta_l(struct input_dev *dev, unsigned int type, + int value) +{ + input_handle_event(dev, type, KEY_LEFTMETA, value); + input_handle_event(dev, type, KEY_L, value); +} + /** * input_event() - report new input event * @dev: device that generated the event @@ -392,6 +399,12 @@ void input_event(struct input_dev *dev, { if (is_event_supported(type, dev->evbit, EV_MAX)) { guard(spinlock_irqsave)(&dev->event_lock); +#ifdef CONFIG_INPUT_SCREENLOCK_EMULATION + if (code == KEY_SCREENLOCK) { + handle_screenlock_as_meta_l(dev, type, value); + return; + } +#endif input_handle_event(dev, type, code, value); } } @@ -2134,6 +2147,12 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int switch (type) { case EV_KEY: +#ifdef CONFIG_INPUT_SCREENLOCK_EMULATION + if (code == KEY_SCREENLOCK) { + __set_bit(KEY_L, dev->keybit); + __set_bit(KEY_LEFTMETA, dev->keybit); + } +#endif __set_bit(code, dev->keybit); break; From patchwork Thu Apr 17 01:37:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 882055 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B835B1B414A; Thu, 17 Apr 2025 01:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744853848; cv=none; b=Fbw4r86eDhZbr2Ey9tusG+M3CUfE2t3EJftsKa8IfVXmpxVS7C8JUt0piBcqLTs08i5Zyf8+rWl+ENh7ziD6QQCkhUXr4FaIArtlGootQ1KFYyRrEkaV3ccUvrOZB82LDUnhJVV1KfZmsOVwEsvnzk2DAiaCf9Exyi1vCC8jcZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744853848; c=relaxed/simple; bh=7i4/x8IKTcwtudhB9CjmkK5JX9DdTZYqVkkUUgqIi7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YdtGkuPAQxxB/HZqRppikCSO0oOeIiHTtrwkyi9z1hZ4XiNk/0O4vu2TF62RHByC8AUcQukS5SWDhNjNDAk3nyphM7RmaioYOpv+e2rkCEsD0ewTFpp84lEPShRwrWBxHhRvFzxkAITt6UWrSi5n2pTyoq9N3gSAkSBGnRDT8jk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZyOGqmIS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZyOGqmIS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD647C4CEEA; Thu, 17 Apr 2025 01:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744853848; bh=7i4/x8IKTcwtudhB9CjmkK5JX9DdTZYqVkkUUgqIi7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZyOGqmISaHO7PQ0WHYTFHQRMeZ5A0IvGst/484Tylrxx8Be3epGmnBnSZBWSvL2ge IOR7GJ/zSz37c7SkQs2N3rad9NcTp0Mm08bGlGGMFaZOR/n/22uGz5ppVPIHolol5K x2MhBkQci4RFBzHx6ouZtbdmrHzzxZ2GJ1iVSYyFsI/bbzmlldtbKjwBWZjX3wDJ3f cJZ/zmDU1/CB3IMe89APnhces7FnPSXrct44/abGuDKGLsVIN9Uv60PJK/zjShA5Sg XP8uCu7XQLRFkAd7PePzzRCt42QrQJiRri9kclbwkmZ+EY/PZpG9ibxWz8nHy/SqpN WOORpIENZD5OQ== From: Mario Limonciello To: Dmitry Torokhov , Shyam Sundar S K , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: Hans de Goede , linux-input@vger.kernel.org (open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)...), linux-kernel@vger.kernel.org (open list), platform-driver-x86@vger.kernel.org (open list:AMD PMF DRIVER), Mario Limonciello Subject: [PATCH v3 2/2] platform/x86/amd: pmf: Use META + L for screen lock command Date: Wed, 16 Apr 2025 20:37:22 -0500 Message-ID: <20250417013722.435751-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250417013722.435751-1-superm1@kernel.org> References: <20250417013722.435751-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello In practice userspace software doesn't react to KEY_SCREENLOCK by default. So any time that the PMF policies would suggest to lock the screen (for example from an HPD sensor event) userspace isn't configured to do it. However userspace is configured for META + L as this is the default in the PC ecosystem. Adjust the PMF driver to select the Kconfig option that makes the input core send META + L. Signed-off-by: Mario Limonciello --- v3: * Use Kconfig from linux-input --- drivers/platform/x86/amd/pmf/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/amd/pmf/Kconfig b/drivers/platform/x86/amd/pmf/Kconfig index 25b8f7ae3abde..10089c69ce582 100644 --- a/drivers/platform/x86/amd/pmf/Kconfig +++ b/drivers/platform/x86/amd/pmf/Kconfig @@ -12,6 +12,7 @@ config AMD_PMF depends on TEE && AMDTEE depends on AMD_SFH_HID depends on HAS_IOMEM + select INPUT_SCREENLOCK_EMULATION help This driver provides support for the AMD Platform Management Framework. The goal is to enhance end user experience by making AMD PCs smarter,