From patchwork Mon Apr 7 15:27:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 878858 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 33C271FECD7; Mon, 7 Apr 2025 15:27:36 +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=1744039656; cv=none; b=GN2ARGSDvy96Er3P0oRWusXVLobzOLRpuKJb+fLbSJ9M4OB9EDv5YwESHPabbcjGehgW+uhkGzs24ftSyhIMO2iGOVhWfkuly+HLhYEYcXKQWUrCjsNV1JFmv6aKXTwniAfo0OEW00bo1427H9LUTSEnrBorFfGdTZhxFysGyUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744039656; c=relaxed/simple; bh=u2II3i2hdzG9z+TnFhyJj9+LpYjrMkHbTOoqlXB+GUU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FQYE/IbWRBL4aKTnORsGLCrajuRKEbVPhK/6PItACGsQUIU0Isl5hWzRiV9NzP+svmqhKgQGlXi+wI3S2yQskZNHx5l9TK7fFvpA9TdNNjVn3E9Tug7bF/iC6rxL8C4qZtYVYbGFhtd/u+Tpo9gPjsmwyosnTgZbpaZ3Y6MBvrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QzKf8q6S; 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="QzKf8q6S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 305D2C4CEDD; Mon, 7 Apr 2025 15:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744039656; bh=u2II3i2hdzG9z+TnFhyJj9+LpYjrMkHbTOoqlXB+GUU=; h=From:To:Cc:Subject:Date:From; b=QzKf8q6S7mjY9zeeFEU7G6QDykS1W98rJbHIon67hHqAcuYoXT5KORPCSHKEdEhEz EKRu3O727NngRu/ug4YMOqz/EYNKBKVeQB5EpnA/5wOK0uErEqIJAg0P16qm/fmE4k hjM8eD/JgDUU8oeUzO7qoY8lv3wpnRUQD06pSJQbRln5RF5WyVaPeX9Pkn29cDGIQH 3tPsk5Obt+QppUNeqGoje9q5byy/avmdvDLho4E87K03o6bcvzuwGnPZoHebmpVv39 qmHEgjFpoe+0XT1Qi9hqSduPUvLzpmjw/XF3U5ctEjkSsZc7hKPSR0ozYloOXnprzI KwAXYYSl8R9Lw== 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 1/2] Input: Add a helper for reporting a screen lock key sequence Date: Mon, 7 Apr 2025 10:27:04 -0500 Message-ID: <20250407152705.1222469-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 helper input_report_lock_sequence() for drivers to utilize if they want to send this sequence. 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 --- drivers/input/input.c | 20 ++++++++++++++++++++ include/linux/input.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/drivers/input/input.c b/drivers/input/input.c index ec4346f20efdd..dfeace85c4710 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -508,6 +508,26 @@ void input_copy_abs(struct input_dev *dst, unsigned int dst_axis, } EXPORT_SYMBOL(input_copy_abs); +/** + * input_report_lock_sequence - Report key combination to lock the screen + * @dev: input device + * + * Key combination used in the PC industry since Windows 7 for locking display + * is META + L. This is also used in GNOME and KDE by default. + * See https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec + */ +void input_report_lock_sequence(struct input_dev *dev) +{ + input_report_key(dev, KEY_LEFTMETA, 1); + input_report_key(dev, KEY_L, 1); + input_sync(dev); + input_report_key(dev, KEY_L, 0); + input_sync(dev); + input_report_key(dev, KEY_LEFTMETA, 0); + input_sync(dev); +} +EXPORT_SYMBOL(input_report_lock_sequence); + /** * input_grab_device - grabs device for exclusive use * @handle: input handle that wants to own the device diff --git a/include/linux/input.h b/include/linux/input.h index 7d7cb0593a63e..16f7bef12f1c1 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -492,6 +492,8 @@ void input_set_abs_params(struct input_dev *dev, unsigned int axis, void input_copy_abs(struct input_dev *dst, unsigned int dst_axis, const struct input_dev *src, unsigned int src_axis); +void input_report_lock_sequence(struct input_dev *dev); + #define INPUT_GENERATE_ABS_ACCESSORS(_suffix, _item) \ static inline int input_abs_get_##_suffix(struct input_dev *dev, \ unsigned int axis) \ From patchwork Mon Apr 7 15:27:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 879197 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 0357D2010E5; Mon, 7 Apr 2025 15:27:37 +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=1744039658; cv=none; b=mDi/t9gJHjyyj1YXaV3Stxoi77LBEYF23NIy80rmK7etHuS3z9KHDQfoTnB0ugfRAjBvMkH6FvL9snIYkf2dAo9ok1/ICR3KLKdq+TNmZq6d5XnFAxc0FlpmIG4cY2CCDtSf3vNevhlat9ekyFcBdQX0P6j2X0IccM132Xpn/qE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744039658; c=relaxed/simple; bh=qQsZexYccx4FgFlElnzxUAZ919mneXYpXEL1vk8tYKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g3NZzG2UVl61PZQSky5B049uQOFwHr2tjMYMkpl4HWLDxUq1RydU6Y0k6YnVmtzHkTUz/nnDnK8becNUZlWSvozCWGJRl/NNnH7qfu+4J/mm0z9FtohLHqgdBULaWjMNMKVTyl1iz8dBkpqtPzZjDEWDLC2R+Tytc+OggdZOxOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nj7fN0Mt; 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="Nj7fN0Mt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53A98C4CEE9; Mon, 7 Apr 2025 15:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744039657; bh=qQsZexYccx4FgFlElnzxUAZ919mneXYpXEL1vk8tYKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nj7fN0Mt+FxJFsBNPMWZFJ5I0DOHruIiKuYIVUCeniU/qUyabxtjOwvews0MGdXqc 311LtPLtqTHT62IcJDCKYqtF6voEK1uB9rX23tdutypV6vVSz9sl+FR0lXmyH4fziG XSI0UNdsYKgDPwYHpf7YeS+9GBBIJ03ck0Fis8XxblmTXPSWgjWAuHzGbvvRDSayTE CvHJEOxmS7Um4DlEJAPg/bly/yQNrzWBmc/aAeskMepkqBRkLKJMMDwvG0K1At+FmM CPy1CcKS7kaMwYpnKxXlWQBEBC/n9L+RXQD4HTb9Q3nZCHPNXH+dVatM5zItSOoWJw oheK4NwGLrvrQ== 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 2/2] platform/x86/amd: pmf: Use meta + L for screen lock command Date: Mon, 7 Apr 2025 10:27:05 -0500 Message-ID: <20250407152705.1222469-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250407152705.1222469-1-superm1@kernel.org> References: <20250407152705.1222469-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 send meta + L. Signed-off-by: Mario Limonciello --- v2: * Use helper from linux-input --- drivers/platform/x86/amd/pmf/tee-if.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c index 20521d1f28f22..4bda905c3ba5c 100644 --- a/drivers/platform/x86/amd/pmf/tee-if.c +++ b/drivers/platform/x86/amd/pmf/tee-if.c @@ -170,7 +170,7 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_ amd_pmf_update_uevents(dev, KEY_SUSPEND); break; case 2: - amd_pmf_update_uevents(dev, KEY_SCREENLOCK); + input_report_lock_sequence(dev->pmf_idev); break; default: dev_err(dev->dev, "Invalid PMF policy system state: %d\n", val); @@ -441,8 +441,9 @@ int amd_pmf_register_input_device(struct amd_pmf_dev *dev) dev->pmf_idev->phys = "amd-pmf/input0"; input_set_capability(dev->pmf_idev, EV_KEY, KEY_SLEEP); - input_set_capability(dev->pmf_idev, EV_KEY, KEY_SCREENLOCK); input_set_capability(dev->pmf_idev, EV_KEY, KEY_SUSPEND); + input_set_capability(dev->pmf_idev, EV_KEY, KEY_L); + input_set_capability(dev->pmf_idev, EV_KEY, KEY_LEFTMETA); err = input_register_device(dev->pmf_idev); if (err) {