From patchwork Mon Oct 6 16:54:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 507 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=1759769723; bh=U9kiinuVHksyA5nPCS8CQGqJxv5TQgc1iCuC4Cc08FA=; 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=swYBqU5KdtFpZyNJ3SgyT2K5Sj9wSbnynPEFPdDT4QzGPbhTOWjx2v3bcmBoQgHtx VuikkyvWvOdl+5CpzWcb1i4BIxKmWgLw0gdLgTlLhW5Sd7W4IMeZ6ml1zZwNTxyqhv 7wq3ibB52Mpue0O6psoiEUrC3BcJykVnmsNaJstM9NNjjYmh6c8nvHNsJTg31AchI1 KIYyxOaQTICV3KmTSA8ujX9RE7LiNNoivcSyf0MfmdSMFGyFVk9UWn5OeGk7CvhbKg sVF0LaAJqTt7DSxtaI2LflIbsoUf9c76wZr1pQTZeLt4yqBtyiYIOj+UyrZkXq1cIR 81bB59TkMkCfg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 384AD67F1D for ; Mon, 6 Oct 2025 10:55:23 -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 aRi_G_X6I7N3 for ; Mon, 6 Oct 2025 10:55:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759769721; bh=U9kiinuVHksyA5nPCS8CQGqJxv5TQgc1iCuC4Cc08FA=; 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=Z/1ntzzc9saAkKF1mOyfn/+RQsfJ4tWDMnoCbiiw4xjhE03WLlx0MkM6P8JJF9U+V U5IFKpldeHYZGSPCcaJrQ++DnXtCMcZ/jcDk5DF4OwzwTYfWU0LG2jN4I4MlK/7y+s BrEyA64v5zYeDSkBYO8NI5byv0UpcS8jCSNCHoDrFQ7ffTpk7xNT8D0l45cKRbJO/I fqi1xGFugeKREwVqkRHbT9rHWRvtn7VQqv1m84ZaO9rn7OJdmz4A4VX63tJirMBvFi vMw2M+u+M6Hyv/F62Bg7Kts+xvtSXh+8u7yxw4YtWpwDCZnSTSpe9iwlExhrdxWcVa 0EEYlHhkWPLHA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E1E3A67F8E for ; Mon, 6 Oct 2025 10:55:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759769718; bh=tBgDCRys8jaJMVQYt3bw63Wdc2PAOzFU39GBhmnKND0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3u6nCZF4ImwrFLPRejRS/ShI7VtxWGJgQOp7PaCOMp2ZFqt9YjZIQ+vitJkkar1s 384l+T7A3Mck9QhihpPr21n9OD3ds7qhx5FY/lHRzZfZen8ywjqYXZ3oQUKP/AyctA 972dJwJqJesElWCspA3flffruwt4IA43Deyqjcgw/KpIZsFq/FNu/iYbw7pc8NkRUm 5n6dVYn3l5D0MejKR9R33y5Cqi+33Gx6YgEe2NZSbOhcYUO1iwCqvMRMWbnoxIUGll ViueVqmZfEeHs9DXGWiBjLjRUVK8RfKLlNWudEqyuMIU/fYfBiSM9HTeNTAA8EdiU5 xuqg3X2lh15QA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B404067F8B; Mon, 6 Oct 2025 10:55:18 -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 sZt5Q3o7x5h9; Mon, 6 Oct 2025 10:55:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759769711; bh=iu/z7J80zOo5ttZt+C36Nz3ipZMKvPfeYjYWfP9nrAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QH1I4kckxExSc0bfDOq2ukw9EMgf9OBLyvjcWE5su7Jk4mmMQlXer6/5ZvZ5P4XPi 67+67Xdev15Is/lBmtO9OXnCLwuXgWNPulkWyxAwmLv4GdeuuLGIYlcdZvb6RSMBFx K8vdIPamg/b7E9rl9MI+4UWa/NfcDDPCDMr7zAINACWxezqos9+/uxt2k5xLKCz4cZ xLXaBy4k2sKAHWZmasj40P4co+gyHqpq7y3gxpdWYL8rW1HrpAZ0iLJYq0FpO4fvBv sLm3eNK5nCjaByA6nLM6ZUgzo5RG898EY41qzN4r5pnKX2j9CEg0FvziuzfH/oE+Zz NmVJ5EAqo5kGw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 277A867ECE; Mon, 6 Oct 2025 10:55:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 10:54:35 -0600 Message-ID: <20251006165452.1675349-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006165452.1675349-1-sjg@u-boot.org> References: <20251006165452.1675349-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VZQ53KIWBVSBPDL6EWHBDTQNWOCH3PML X-Message-ID-Hash: VZQ53KIWBVSBPDL6EWHBDTQNWOCH3PML 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/14] mouse: Update mouse_get_click() to use struct vid_pos 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 Change the API to use struct vid_pos instead of separate x/y pointers. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/expo.c | 9 +++++---- drivers/input/mouse-uclass.c | 8 ++------ include/mouse.h | 5 ++--- test/dm/mouse.c | 29 ++++++++++++++--------------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/boot/expo.c b/boot/expo.c index 00924a19d27..1051133e200 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -413,18 +413,19 @@ static int poll_keys(struct expo *exp) static int poll_mouse(struct expo *exp, int *xp, int *yp) { - int ret, x, y; + struct vid_pos pos; + int ret; if (!exp->mouse_enabled) return -EAGAIN; /* First check if we have a click available */ - ret = mouse_get_click(exp->mouse, &x, &y); + ret = mouse_get_click(exp->mouse, &pos); if (ret) return log_msg_ret("epm", ret); - *xp = x; - *yp = y; + *xp = pos.x; + *yp = pos.y; return 0; /* Click available */ } diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c index 0e5faccf1e2..1bb836ff59d 100644 --- a/drivers/input/mouse-uclass.c +++ b/drivers/input/mouse-uclass.c @@ -23,7 +23,7 @@ int mouse_get_event(struct udevice *dev, struct mouse_event *evt) return 0; } -int mouse_get_click(struct udevice *dev, int *xp, int *yp) +int mouse_get_click(struct udevice *dev, struct vid_pos *pos) { struct mouse_uc_priv *uc_priv = dev_get_uclass_priv(dev); struct mouse_event event; @@ -53,11 +53,7 @@ int mouse_get_click(struct udevice *dev, int *xp, int *yp) /* If we just detected a click, return it */ if (pending) { - if (xp) - *xp = uc_priv->click_pos.x; - if (yp) - *yp = uc_priv->click_pos.y; - + *pos = uc_priv->click_pos; return 0; } } diff --git a/include/mouse.h b/include/mouse.h index 8e65ac79b94..76f9c789b7b 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -95,10 +95,9 @@ int mouse_get_event(struct udevice *dev, struct mouse_event *event); * mouse_get_click() - Check if a left mouse button click has occurred * * @dev: Mouse device - * @xp: Returns X coordinate of click (can be NULL) - * @yp: Returns Y coordinate of click (can be NULL) + * @pos: Returns position of click * Returns: 0 if a click has occurred, -EAGAIN if no click pending */ -int mouse_get_click(struct udevice *dev, int *xp, int *py); +int mouse_get_click(struct udevice *dev, struct vid_pos *pos); #endif diff --git a/test/dm/mouse.c b/test/dm/mouse.c index 1b4c2b5f60f..3efff4a0d7d 100644 --- a/test/dm/mouse.c +++ b/test/dm/mouse.c @@ -99,7 +99,7 @@ static int dm_test_mouse_click(struct unit_test_state *uts) { struct udevice *dev; struct mouse_event inject; - int x, y; + struct vid_pos pos; ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); @@ -107,7 +107,7 @@ static int dm_test_mouse_click(struct unit_test_state *uts) sandbox_mouse_set_test_mode(dev, true); /* test that no click is detected initially */ - ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + ut_asserteq(-EAGAIN, mouse_get_click(dev, &pos)); /* inject a left button press */ inject.type = MOUSE_EV_BUTTON; @@ -123,7 +123,7 @@ static int dm_test_mouse_click(struct unit_test_state *uts) * calling mouse_get_click() should not detect a click yet (press * only) */ - ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + ut_asserteq(-EAGAIN, mouse_get_click(dev, &pos)); /* inject a left button release */ inject.type = MOUSE_EV_BUTTON; @@ -136,12 +136,12 @@ static int dm_test_mouse_click(struct unit_test_state *uts) sandbox_mouse_inject(dev, &inject); /* now mouse_get_click() should detect the click */ - ut_assertok(mouse_get_click(dev, &x, &y)); - ut_asserteq(300, x); - ut_asserteq(400, y); + ut_assertok(mouse_get_click(dev, &pos)); + ut_asserteq(300, pos.x); + ut_asserteq(400, pos.y); /* verify no more clicks are pending */ - ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + ut_asserteq(-EAGAIN, mouse_get_click(dev, &pos)); return 0; } @@ -151,6 +151,7 @@ static int dm_test_mouse_click_no_coordinates(struct unit_test_state *uts) { struct udevice *dev; struct mouse_event inject; + struct vid_pos pos; ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); @@ -167,15 +168,13 @@ static int dm_test_mouse_click_no_coordinates(struct unit_test_state *uts) sandbox_mouse_inject(dev, &inject); /* process the press event */ - ut_asserteq(-EAGAIN, mouse_get_click(dev, NULL, NULL)); + ut_asserteq(-EAGAIN, mouse_get_click(dev, &pos)); inject.button.press_state = BUTTON_RELEASED; sandbox_mouse_inject(dev, &inject); - /* - * now test that click is detected without coordinate return - */ - ut_assertok(mouse_get_click(dev, NULL, NULL)); + /* now test that click is detected (coordinates are ignored) */ + ut_assertok(mouse_get_click(dev, &pos)); return 0; } @@ -185,7 +184,7 @@ static int dm_test_mouse_right_button(struct unit_test_state *uts) { struct udevice *dev; struct mouse_event inject; - int x, y; + struct vid_pos pos; ut_assertok(uclass_first_device_err(UCLASS_MOUSE, &dev)); @@ -204,13 +203,13 @@ static int dm_test_mouse_right_button(struct unit_test_state *uts) inject.button.y = 200; sandbox_mouse_inject(dev, &inject); - ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + ut_asserteq(-EAGAIN, mouse_get_click(dev, &pos)); inject.button.press_state = BUTTON_RELEASED; sandbox_mouse_inject(dev, &inject); /* still no click detected since it was right button */ - ut_asserteq(-EAGAIN, mouse_get_click(dev, &x, &y)); + ut_asserteq(-EAGAIN, mouse_get_click(dev, &pos)); return 0; }