From patchwork Sat Oct 18 08:40:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 612 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=1760776934; bh=KghEjEI7dIVZc4b+OfpTWMNCG0s/jwUbTjRlcp386Bg=; 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=YrEADb27yklUYOlXyYsEoGf0ETTM3hg5NIJGY1/VXXgW2G5PBnNzbwwrJBpnkOKST dhkx85k+qAcLfQrwsHPD1qFU8Zwqp1IqXOtWXSsPKAC9KTA1vkmeT4SQphjC9+uCP4 Fu160NMJO286AbtblbnrL2xvMo6fiBinmvC7HBh1ye0GBpJcOSLxL+5NDYDQm1X1nk fhxOGBtPrKp5kfaZ9ABccVN+yKZXLcnihZ1Q/3xiaegi/StjXb34QhrDb6X3B2wwyq NNPrCCKsrItmEMh6CnEUE2g91w4+vobtwGg2mSbj7Tmf0bE7XoNsrdii4i1CDEiCCN H9nJX17RHrzZQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 283426819D for ; Sat, 18 Oct 2025 02:42:14 -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 jJ-k8ey4Il98 for ; Sat, 18 Oct 2025 02:42:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760776932; bh=KghEjEI7dIVZc4b+OfpTWMNCG0s/jwUbTjRlcp386Bg=; 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=tiJ1Rxzyuo+WmNco3hGV84z9euzTg4pdHoRClMwDoNB6ZX3ylTKAXVObuKIbmj4aq yWj1s7zjidlioMSHeGKYC418JZTJ2LI2hPtSnStzzKgyA7yvhtn4pbnHoz2TuCFF6O aSTEE0C7wa/taqA8TgCexfkl29D5PCWu12MKGjf6jq8jMWyWmYlfBcfqQ4xYeOvCrI xMJ1q7EMV+gXdgIg0zVSMhoKNnlZUSOTxsJFoneGjx6eDAFfxY1SH07+bU2E1820jK dVtIjs0wSfv0KEPHKJMft/8WZOUIifNFvBo5tEooORfLDx5cY8fLEjwMU30xXqIYHb 0S55mAGwOZUww== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4AFD0681BC for ; Sat, 18 Oct 2025 02:42:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760776929; bh=cujy1sSKs2Ri8ONSr87cR3NflmXdVOzWlLPahgI44Wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZVHbytQR+u/GfHeY/fyfxQno05nRkM0eg8lJAK1juwelQ8WCV0CpgjtjnqpD2awY3 z33/PbeFPV+Jj5iOmt3zHSbAx/Xl/EnHho/fOuIIw5V84avFAvGo6AXrfHSlHGJkwW vcwTzlQVSvHNEdQjo9tH+fCsy1+t9NaMQw/y9fG3VyJyi+c1rpFAINCuyco5oLrRfo yhH6fzy62Y4vZ2V9XbR7Y2i8DeENGDUENSF6QkA28T+8q2hDtouAhmHCMlpgvTF3G1 SUT0X/2653FZSwthaq5XkTAa/Hi8OxhdqtheyK4+Wmp+Ds/xwZx0sm9PK1zizzZxBG +EbuFxjd3SFmw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D0B9E68109; Sat, 18 Oct 2025 02:42:09 -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 lBUIDj84vCfS; Sat, 18 Oct 2025 02:42:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760776929; bh=TNZBCeXwFdfaoVdzX6CwB3R5gYu6vP6TwUQZGNe97LU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=piFiZNL5v2PqgxpnlaoaB0/8sRncdn3zqQ8MQTNLStsTAhz/uwTMAGE15G6XqEhlu BponZNiQxk6o4NZ+bjkrn7C/CwomrB6Riu8ddeMT4Wh2AUb0auayR7+3zjy2zUXxFc ufpUKoO6nck4WYcLmPaac2+GobW3mZMCpj6sxhrbcGipnua27xRBeZp7z7IAjWpY+e 2AVFYiGsca7AwnWb4BTfmqDPSGvhe7G/dy36NsXcBEYyIWCgLoSX+BFWAjlwpM8vSN oS4miOF2r7QYXutdtt84QET1ovs+Owp/XJ7lDwqkTLkVk8IMVe/n3dOLoddfVebd2n EKJF+0Ki3zghg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 33D886814E; Sat, 18 Oct 2025 02:42:09 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sat, 18 Oct 2025 02:40:57 -0600 Message-ID: <20251018084117.1798704-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251018084117.1798704-1-sjg@u-boot.org> References: <20251018084117.1798704-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TQ4FCQYQBNLGDRDC2CNUJD3AXYSETISX X-Message-ID-Hash: TQ4FCQYQBNLGDRDC2CNUJD3AXYSETISX 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: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/24] bootctl: Create a common struct for the BOOTCTL_UI uclass 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 All UI implementations will likely share a number of common elements, so move these into a per-device uclass struct. Signed-off-by: Simon Glass --- boot/bootctl/bootctl-uclass.c | 2 + boot/bootctl/simple_ui.c | 93 +++++++++++++---------------------- include/bootctl/ui.h | 27 ++++++++++ 3 files changed, 63 insertions(+), 59 deletions(-) diff --git a/boot/bootctl/bootctl-uclass.c b/boot/bootctl/bootctl-uclass.c index f7280b83da3..756702b3e9a 100644 --- a/boot/bootctl/bootctl-uclass.c +++ b/boot/bootctl/bootctl-uclass.c @@ -10,6 +10,7 @@ #include #include +#include UCLASS_DRIVER(bootctrl) = { .id = UCLASS_BOOTCTL, @@ -42,4 +43,5 @@ UCLASS_DRIVER(bootctrl_ui) = { .id = UCLASS_BOOTCTL_UI, .name = "bootctrl_ui", .per_device_plat_auto = sizeof(struct bootctl_uc_plat), + .per_device_auto = sizeof(struct bc_ui_priv), }; diff --git a/boot/bootctl/simple_ui.c b/boot/bootctl/simple_ui.c index b4b8541ac22..14c6de5bb1e 100644 --- a/boot/bootctl/simple_ui.c +++ b/boot/bootctl/simple_ui.c @@ -25,32 +25,9 @@ /* TODO: Define to 1 to use text mode (for terminals), 0 for graphics */ #define TEXT_MODE 0 -/** - * struct ui_priv - information about the display - * - * @expo: Expo containing the menu - * @scn: Current scene being shown - * @lpriv: Private data of logic device - * @console: vidconsole device in use - * @autoboot_template: template string to use for autoboot - * @autoboot_str: current string displayed for autoboot timeout - * @logo: logo in bitmap format, NULL to use default - * @logo_size: size of the logo in bytes - */ -struct ui_priv { - struct expo *expo; - struct scene *scn; /* consider dropping this */ - struct logic_priv *lpriv; - struct udevice *console; - struct abuf autoboot_template; - struct abuf *autoboot_str; - const void *logo; - int logo_size; -}; - static int simple_ui_probe(struct udevice *dev) { - struct ui_priv *priv = dev_get_priv(dev); + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); struct udevice *ldev; int ret; @@ -58,7 +35,7 @@ static int simple_ui_probe(struct udevice *dev) if (ret) return log_msg_ret("sup", ret); - priv->lpriv = dev_get_priv(ldev); + upriv->lpriv = dev_get_priv(ldev); return 0; } @@ -81,7 +58,7 @@ static int simple_ui_print(struct udevice *dev, const char *msg) static int simple_ui_show(struct udevice *dev) { - struct ui_priv *priv = dev_get_priv(dev); + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); struct bootstd_priv *std; struct scene *scn; struct abuf *buf; @@ -91,30 +68,30 @@ static int simple_ui_show(struct udevice *dev) ret = bootstd_get_priv(&std); if (ret) return log_msg_ret("sdb", ret); - ret = bootflow_menu_setup(std, TEXT_MODE, &priv->expo); + ret = bootflow_menu_setup(std, TEXT_MODE, &upriv->expo); if (ret) return log_msg_ret("sds", ret); - ret = expo_first_scene_id(priv->expo); + ret = expo_first_scene_id(upriv->expo); if (ret < 0) return log_msg_ret("ufs", ret); scene_id = ret; - scn = expo_lookup_scene_id(priv->expo, scene_id); + scn = expo_lookup_scene_id(upriv->expo, scene_id); scene_obj_set_hide(scn, OBJ_AUTOBOOT, false); - ret = expo_edit_str(priv->expo, STR_AUTOBOOT, - &priv->autoboot_template, - &priv->autoboot_str); + ret = expo_edit_str(upriv->expo, STR_AUTOBOOT, + &upriv->autoboot_template, + &upriv->autoboot_str); if (ret) return log_msg_ret("ses", ret); - ret = expo_edit_str(priv->expo, STR_MENU_TITLE, NULL, &buf); + ret = expo_edit_str(upriv->expo, STR_MENU_TITLE, NULL, &buf); if (ret) return log_msg_ret("set", ret); abuf_printf(buf, "Boot control"); - if (priv->logo) { + if (upriv->logo) { ret = scene_img_set_data(scn, OBJ_U_BOOT_LOGO, - priv->logo, priv->logo_size); + upriv->logo, upriv->logo_size); if (ret) return log_msg_ret("log", ret); ret = scene_obj_set_pos(scn, OBJ_U_BOOT_LOGO, 1135, 10); @@ -125,7 +102,7 @@ static int simple_ui_show(struct udevice *dev) log_debug("theme '%s'\n", ofnode_get_name(std->theme)); if (ofnode_valid(std->theme)) { - ret = expo_setup_theme(priv->expo, std->theme); + ret = expo_setup_theme(upriv->expo, std->theme); if (ret) return log_msg_ret("thm", ret); } @@ -135,22 +112,22 @@ static int simple_ui_show(struct udevice *dev) return log_msg_ret("usa", ret); scene_set_highlight_id(scn, OBJ_MENU); - priv->scn = scn; + upriv->scn = scn; - ret = device_find_first_child_by_uclass(priv->expo->display, - UCLASS_VIDEO_CONSOLE, - &priv->console); + ret = device_find_first_child_by_uclass(upriv->expo->display, + UCLASS_VIDEO_CONSOLE, + &upriv->console); if (ret) return log_msg_ret("suq", ret); - vidconsole_set_quiet(priv->console, true); + vidconsole_set_quiet(upriv->console, true); return 0; } static int simple_ui_add(struct udevice *dev, struct osinfo *info) { - struct ui_priv *priv = dev_get_priv(dev); - struct logic_priv *lpriv = priv->lpriv; + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); + struct logic_priv *lpriv = upriv->lpriv; int seq = lpriv->osinfo.count; struct bootstd_priv *std; struct scene *scn; @@ -159,7 +136,7 @@ static int simple_ui_add(struct udevice *dev, struct osinfo *info) info = alist_add(&lpriv->osinfo, *info); if (!info) return -ENOMEM; - ret = bootflow_menu_add(priv->expo, &info->bflow, seq, &scn); + ret = bootflow_menu_add(upriv->expo, &info->bflow, seq, &scn); if (ret) return log_msg_ret("sda", ret); @@ -167,11 +144,11 @@ static int simple_ui_add(struct udevice *dev, struct osinfo *info) if (ret) return log_msg_ret("sup", ret); if (ofnode_valid(std->theme)) { - ret = expo_setup_theme(priv->expo, std->theme); + ret = expo_setup_theme(upriv->expo, std->theme); if (ret) return log_msg_ret("thm", ret); } - ret = expo_calc_dims(priv->expo); + ret = expo_calc_dims(upriv->expo); if (ret) return log_msg_ret("ecd", ret); @@ -187,19 +164,18 @@ static int simple_ui_add(struct udevice *dev, struct osinfo *info) static int simple_ui_render(struct udevice *dev) { - struct ui_priv *priv = dev_get_priv(dev); + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); int ret; - ret = abuf_printf(priv->autoboot_str, - priv->autoboot_template.data, - priv->lpriv->autoboot_remain_s); + ret = abuf_printf(upriv->autoboot_str, upriv->autoboot_template.data, + upriv->lpriv->autoboot_remain_s); if (ret < 0) return log_msg_ret("uip", ret); - ret = expo_arrange(priv->expo); + ret = expo_arrange(upriv->expo); if (ret) return log_msg_ret("sda", ret); - ret = expo_render(priv->expo); + ret = expo_render(upriv->expo); if (ret) return log_msg_ret("sdr", ret); @@ -208,18 +184,18 @@ static int simple_ui_render(struct udevice *dev) static int simple_ui_poll(struct udevice *dev, int *seqp, bool *selectedp) { - struct ui_priv *priv = dev_get_priv(dev); - struct logic_priv *lpriv = priv->lpriv; + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); + struct logic_priv *lpriv = upriv->lpriv; int seq, ret; bool ok = true; *seqp = -1; *selectedp = false; - ret = bootflow_menu_poll(priv->expo, &seq); + ret = bootflow_menu_poll(upriv->expo, &seq); ok = !ret; if (ret == -ERESTART || ret == -EREMCHG) { lpriv->autoboot_active = false; - scene_obj_set_hide(priv->scn, OBJ_AUTOBOOT, true); + scene_obj_set_hide(upriv->scn, OBJ_AUTOBOOT, true); ok = true; } else if (ret == -EAGAIN) { ok = true; @@ -241,9 +217,9 @@ static int simple_ui_poll(struct udevice *dev, int *seqp, bool *selectedp) static int simple_ui_of_to_plat(struct udevice *dev) { - struct ui_priv *priv = dev_get_priv(dev); + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); - priv->logo = dev_read_prop(dev, "logo", &priv->logo_size); + upriv->logo = dev_read_prop(dev, "logo", &upriv->logo_size); return 0; } @@ -270,5 +246,4 @@ U_BOOT_DRIVER(simple_ui) = { .bind = simple_ui_bind, .probe = simple_ui_probe, .ops = &ops, - .priv_auto = sizeof(struct ui_priv), }; diff --git a/include/bootctl/ui.h b/include/bootctl/ui.h index 8333ff199dd..beb11178c52 100644 --- a/include/bootctl/ui.h +++ b/include/bootctl/ui.h @@ -10,11 +10,38 @@ #define __bootctl_display_h #include +#include +struct expo; +struct logic_priv; struct osinfo; struct oslist_iter; +struct scene; struct udevice; +/** + * struct bc_ui_priv - Common uclass private data for UI devices + * + * @expo: Expo containing the menu + * @scn: Current scene being shown + * @lpriv: Private data of logic device + * @console: vidconsole device in use + * @autoboot_template: template string to use for autoboot + * @autoboot_str: current string displayed for autoboot timeout + * @logo: logo in bitmap format, NULL to use default + * @logo_size: size of the logo in bytes + */ +struct bc_ui_priv { + struct expo *expo; + struct scene *scn; + struct logic_priv *lpriv; + struct udevice *console; + struct abuf autoboot_template; + struct abuf *autoboot_str; + const void *logo; + int logo_size; +}; + /** * struct bc_ui_ops - Operations for displays */