From patchwork Mon Sep 15 12:28:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 323 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=1757939393; bh=g183alaATjKDVCMBQyFDou2+7AyFN+KhiJqXyCqswWg=; 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=UrWTVBUqbWIRte0I8tcti+m4diTbuC+M+r+jaBjC40ErAGZeymvJ6hFyZw7Vah0Le CM4w+c3/ZPu5k9GSI2k7KNKj/gUMcp4tvz7Cn/Z/6vsH5BqFg0YVllQqn1VK3pJa3q 2+EbFFQgAgD6McFxkAT87n1KHVU8HZBiNxFlPy3GxLq6pIe+6UQ7IuPDXrYT5iBgmm gx5ztUS5DKsoxUGUnE3oW7doEKZT6ld9UVliLJvi3sWM5QMvGLcCZ7+nus6MxoQsi0 EqzCdLT4QNZ1LPT49Z5bMtAAIeb7WH+GaXmoMoohiud1c3YhEcNgG8qLvuwFypqvKW GsJY3bF6PKWGg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CF4AA67BCB for ; Mon, 15 Sep 2025 06:29: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 wCuQWv0LNJv0 for ; Mon, 15 Sep 2025 06:29:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939393; bh=g183alaATjKDVCMBQyFDou2+7AyFN+KhiJqXyCqswWg=; 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=UrWTVBUqbWIRte0I8tcti+m4diTbuC+M+r+jaBjC40ErAGZeymvJ6hFyZw7Vah0Le CM4w+c3/ZPu5k9GSI2k7KNKj/gUMcp4tvz7Cn/Z/6vsH5BqFg0YVllQqn1VK3pJa3q 2+EbFFQgAgD6McFxkAT87n1KHVU8HZBiNxFlPy3GxLq6pIe+6UQ7IuPDXrYT5iBgmm gx5ztUS5DKsoxUGUnE3oW7doEKZT6ld9UVliLJvi3sWM5QMvGLcCZ7+nus6MxoQsi0 EqzCdLT4QNZ1LPT49Z5bMtAAIeb7WH+GaXmoMoohiud1c3YhEcNgG8qLvuwFypqvKW GsJY3bF6PKWGg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BE15967B34 for ; Mon, 15 Sep 2025 06:29:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939392; bh=nTTlk1VtTafkxp8iEXK2L7zXYcHIMbh+qBQryo0Qy6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=igG4eHoSJh1ZjsW6TZhtMaqgZUhWXZIXVHfHbCrtD7H8tfdfVbSUT2iLFI6TcT3C8 pTUV/9fiZICUuT88SQP4ObmM6EzPvGAvNbXaW1F2txE6TveizI8Y3oOpxw9OAIwGGg o3mdm2iSYZXLLObnoM97Zu0lcPN7ulblJLcHANL1Shhx5o0f6ihr7S8+XKZlIrFG2O KEGfJSmDYZ5NBAymEyO9t83474qxSD9oWuc3E1oCuG61MYrvxvFjOa0iG8GzTcQxAz ngw6wY2A6Zrr6WLqJThoAf53Kykp+oHmcZZaytSzrw06TBBncBNRPPchdA0D7qyfCu II9LHtBuF3cgQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F3F3A67A04; Mon, 15 Sep 2025 06:29:51 -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 tDh7hOAqJSfx; Mon, 15 Sep 2025 06:29:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939386; bh=LooLBxuF4iRK5Z3Pb4qtg6Y5DNVoo25dPwjfupzFm8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YEMIKSTjiOffg2dQm0LpEVL8dpREkK/rIki99/fLQiuZCblxtMbNjRm2YCf0AZTS/ GWdyOGUaASwGD7rvbekohmOFNvtytSnDxmepjhCeXDw2h3E48wwbSUvftWAo7DypMo AlEzMH/8/BpAHFrk7ZJSJIjUdEdGJn4kRM+k1Cf/m2beLFGhNrzx/7lA2huKRWJg3f aYhozz2V2+3iew2K9GftdbpvABJ2/P+qmboxU6/p4YROYcLJHhKJLRHNG+iIh6IjAk pF77yq+rQiFkBkpmMNVrL583otLLtSQjWG5YFlyEwmjpx+7ghsJxE7MdwjRYJBlutj 2csnlOBdws1cQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4324F67B45; Mon, 15 Sep 2025 06:29:46 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 06:28:41 -0600 Message-ID: <20250915122905.1217249-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915122905.1217249-1-sjg@u-boot.org> References: <20250915122905.1217249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AZEXY24FCFF5DNDLYPGHO2QASKCIYF4K X-Message-ID-Hash: AZEXY24FCFF5DNDLYPGHO2QASKCIYF4K 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 08/23] expo: Provide a way to enable the mouse 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 In some cases it is useful to use expo with a mouse (or touchpad). Add a way to tell expo to find and record a mouse device. Signed-off-by: Simon Glass --- boot/expo.c | 19 +++++++++++++++++++ include/expo.h | 13 +++++++++++++ test/boot/expo.c | 22 ++++++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/boot/expo.c b/boot/expo.c index 6f05c47aba6..e18f149a22f 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -163,6 +164,24 @@ void expo_set_text_mode(struct expo *exp, bool text_mode) exp->text_mode = text_mode; } +int expo_set_mouse_enable(struct expo *exp, bool enable) +{ + int ret; + + if (!enable) { + exp->mouse_enabled = false; + return 0; + } + + ret = uclass_first_device_err(UCLASS_MOUSE, &exp->mouse); + if (ret) + return log_msg_ret("sme", ret); + + exp->mouse_enabled = true; + + return 0; +} + struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id) { struct scene *scn; diff --git a/include/expo.h b/include/expo.h index c025e5494a1..f49a6fc5dce 100644 --- a/include/expo.h +++ b/include/expo.h @@ -109,6 +109,7 @@ struct expo_theme { * @name: Name of the expo (allocated) * @display: Display to use (`UCLASS_VIDEO`), or NULL to use text mode * @cons: Console to use (`UCLASS_VIDEO_CONSOLE`), or NULL to use text mode + * @mouse: Mouse to use (`UCLASS_MOUSE`), or NULL if no mouse * @scene_id: Current scene ID (0 if none) * @next_id: Next ID number to use, for automatic allocation * @action: Action selected by user. At present only one is supported, with the @@ -118,6 +119,7 @@ struct expo_theme { * @text_mode: true to use text mode for the menu (no vidconsole) * @popup: true to use popup menus, instead of showing all items * @show_highlight: show a highlight bar on the selected menu item + * @mouse_enabled: true if the mouse is enabled * @priv: Private data for the controller * @done: Indicates that a cedit session is complete and the user has quit * @save: Indicates that cedit data should be saved, rather than discarded @@ -130,6 +132,7 @@ struct expo { char *name; struct udevice *display; struct udevice *cons; + struct udevice *mouse; uint scene_id; uint next_id; struct expo_action action; @@ -138,6 +141,7 @@ struct expo { bool text_mode; bool popup; bool show_highlight; + bool mouse_enabled; void *priv; bool done; bool save; @@ -667,6 +671,15 @@ int expo_arrange(struct expo *exp); */ void expo_set_text_mode(struct expo *exp, bool text_mode); +/** + * expo_set_mouse_enable() - Controls whether the expo enables mouse input + * + * @exp: Expo to update + * @enable: true to enable mouse input, false to disable + * Returns: 0 if OK, or -ve error if no mouse found + */ +int expo_set_mouse_enable(struct expo *exp, bool enable); + /** * scene_new() - create a new scene in a expo * diff --git a/test/boot/expo.c b/test/boot/expo.c index 634bab8f203..9ee2c312f86 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -928,3 +928,25 @@ static int expo_test_build(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(expo_test_build, UTF_DM); + +/* test expo_set_mouse_enable() */ +static int expo_mouse_enable(struct unit_test_state *uts) +{ + struct udevice *dev; + struct expo *exp; + + ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); + ut_assertok(expo_new(EXPO_NAME, NULL, &exp)); + ut_assertok(expo_set_display(exp, dev)); + + ut_asserteq(false, exp->mouse_enabled); + + ut_assertok(expo_set_mouse_enable(exp, true)); + ut_assertnonnull(exp->mouse); + ut_asserteq(UCLASS_MOUSE, device_get_uclass_id(exp->mouse)); + + expo_destroy(exp); + + return 0; +} +BOOTSTD_TEST(expo_mouse_enable, UTF_DM | UTF_SCAN_FDT);