From patchwork Mon Oct 6 23:21:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 547 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793033; bh=3zLv17Fiv5HL13CZxB2v4Pl6G9MW639ax91aqA4z/u8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rpK7CDLyrnluuMaDSQpniM1dOlt5/0Ua9LAihFQOSApQAYgF7KDBGzoP1QAB45tUE BFD7reGIqlLZyi8kpDpKsqFECcEZZjTHgKeli1fTks6uAG2aP6YbDq3zEdO0wfGvuI 9BZSr5O4Tp3LKurftqmcV8CR4r0bK56+/HOduHC8c17fJnwIDutdRq02VbRJed4lij KgHYRj/BCtg/A2hs+N7DXKsRU7bQ8PHM6SR+uupPWc1VtvKdC+yUVIr0ySmENo0FBC wQaSKgngQeBoX2FZyO2DN0hdYepZTXDiGFxA//D5xIX0Jzab8gYOYdydWSMKXuiBl6 YPCzNHgjhSRgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9727167FB7 for ; Mon, 6 Oct 2025 17:23:53 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id OuOWtat51AlM for ; Mon, 6 Oct 2025 17:23:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793033; bh=3zLv17Fiv5HL13CZxB2v4Pl6G9MW639ax91aqA4z/u8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=rpK7CDLyrnluuMaDSQpniM1dOlt5/0Ua9LAihFQOSApQAYgF7KDBGzoP1QAB45tUE BFD7reGIqlLZyi8kpDpKsqFECcEZZjTHgKeli1fTks6uAG2aP6YbDq3zEdO0wfGvuI 9BZSr5O4Tp3LKurftqmcV8CR4r0bK56+/HOduHC8c17fJnwIDutdRq02VbRJed4lij KgHYRj/BCtg/A2hs+N7DXKsRU7bQ8PHM6SR+uupPWc1VtvKdC+yUVIr0ySmENo0FBC wQaSKgngQeBoX2FZyO2DN0hdYepZTXDiGFxA//D5xIX0Jzab8gYOYdydWSMKXuiBl6 YPCzNHgjhSRgA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 863FC67F58 for ; Mon, 6 Oct 2025 17:23:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793032; bh=9Ld8RczQcWeYbnRj+coVOWkLmGEvckXvTKDE6aG8txA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rj1vkQ34BrFoSnUS9jsekRbB4yKU/v6Ix8LpQmvI6BgT5wvni0xuGl+zQbxCRVsnJ Y1YkO4K3I+K2MwKtQsXFOTZHwlZYlxHaDDO9mUz5cVSx3LZWfcV/+d3A9GGwitCwjX LVPLw7IzF9Rcu2CcCoeDePmWr/xPAYFNXFwK9itM63lr2qGeilFzuBVBwv51lyUwKZ jpjxrf7SJOEiupsqEor1iFu94ZDedyTWfupj0NioQi5pTY4FneVpqeCT00xUdxIqjH oXi1EFSoMgIS2UQ6Myo00zMcFFssqeeFR+VcjduqiHpqyTPbWAyPdEGuJQYeqZgUmz +YE3r+dS75Oxw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2A70467AF3; Mon, 6 Oct 2025 17:23:52 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id nDypPmbX4cvp; Mon, 6 Oct 2025 17:23:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759793027; bh=oLU6N0LraHADfnOSgZjJdO9qJmk7d8rkWgFO/gKz0EA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ll1jKutUW41InHdvXMwHvv4s7x2n9fOtKgCuTTDXws/5dgSEOL0kv8ELUFEVbDuTx gsbFscHpNv7PRPSB/npXM2L5ll4A7PGUPZcavMQR2LWalzxm8aQEVKkLsmZq440v4C HOn6Ek/hwDkGuxn73134BEeb0vMgqjXZDrP7QTOuEvvOk6GXZrxWRXFdQNC8bgVf2p v8UA2Tp0traaMvpdSTchg9rBe3a3wwRfi4dwIiWaNCQFpJQ7le45IjxXkEJ8p7Un7y si9kfAr96ln9m4RXR+LXYcPil7ghmDUGuBGMfa5PGCqgy3BR6oDOAC17pg6LvN1CJ6 LuwN+4kZKDQtg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5FC3867FE0; Mon, 6 Oct 2025 17:23:47 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:59 -0600 Message-ID: <20251006232236.2091941-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: P5OSHKVMV56T2M6NP5NGRBOIOCFI6M6K X-Message-ID-Hash: P5OSHKVMV56T2M6NP5NGRBOIOCFI6M6K X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 17/17] efi: mouse: Scale the pointer to the display List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass If a display is provided to the mouse uclass, use it to scale the coords returned by the absolute-pointer protocol. Signed-off-by: Simon Glass --- drivers/input/efi_mouse.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/input/efi_mouse.c b/drivers/input/efi_mouse.c index 53976bf9e22..e9870e119a0 100644 --- a/drivers/input/efi_mouse.c +++ b/drivers/input/efi_mouse.c @@ -13,6 +13,7 @@ #include #include #include +#include /* Maximum coordinate value for mouse position */ #define MOUSE_MAX_COORD 0xffff @@ -49,12 +50,14 @@ struct efi_mouse_priv { * get_abs_pointer() - Handle absolute pointer input * * @priv: Private data + * @uc_priv: Uclass-private data * @rel_x: Returns relative X movement * @rel_y: Returns relative Y movement * @new_buttons: Returns button state * Return: 0 if OK, -EAGAIN if no event, -ve on error */ -static int get_abs_pointer(struct efi_mouse_priv *priv, int *rel_x, +static int get_abs_pointer(struct efi_mouse_priv *priv, + struct mouse_uc_priv *uc_priv, int *rel_x, int *rel_y, int *new_buttons) { struct efi_absolute_pointer_state state; @@ -83,8 +86,28 @@ static int get_abs_pointer(struct efi_mouse_priv *priv, int *rel_x, log_debug("abs: rel_x=%d, rel_y=%d\n", *rel_x, *rel_y); } priv->abs_last = state; - priv->x = state.current_x; - priv->y = state.current_y; + + /* Update absolute position - scale to video display if available */ + if (uc_priv->video_dev && priv->abs->mode) { + struct efi_absolute_pointer_mode *mode = priv->abs->mode; + u64 x_range = mode->abs_max_x - mode->abs_min_x; + u64 y_range = mode->abs_max_y - mode->abs_min_y; + + if (x_range > 0 && y_range > 0) { + log_debug("abs: unscaled x=%llx y=%llx\n", + state.current_x, state.current_y); + priv->x = ((state.current_x - mode->abs_min_x) * + uc_priv->video_width) / x_range; + priv->y = ((state.current_y - mode->abs_min_y) * + uc_priv->video_height) / y_range; + } else { + priv->x = state.current_x; + priv->y = state.current_y; + } + } else { + priv->x = state.current_x; + priv->y = state.current_y; + } /* Extract button state */ *new_buttons = state.active_buttons & 0x3; /* Left and right buttons */ @@ -219,6 +242,7 @@ static int get_button_event(struct efi_mouse_priv *priv, int new_buttons, static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) { + struct mouse_uc_priv *uc_priv = dev_get_uclass_priv(dev); struct efi_mouse_priv *priv = dev_get_priv(dev); struct mouse_motion *motion; int new_buttons; @@ -230,7 +254,8 @@ static int efi_mouse_get_event(struct udevice *dev, struct mouse_event *event) * so we poll directly */ if (priv->use_absolute) - ret = get_abs_pointer(priv, &rel_x, &rel_y, &new_buttons); + ret = get_abs_pointer(priv, uc_priv, &rel_x, &rel_y, + &new_buttons); else ret = get_rel_pointer(priv, &rel_x, &rel_y, &new_buttons); if (ret)