[Concept,18/24] bootctl: Add an option to switch the layout

Message ID 20251018084117.1798704-19-sjg@u-boot.org
State New
Headers
Series bootctl: Expand bootctl to include a new UI |

Commit Message

Simon Glass Oct. 18, 2025, 8:41 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

Provide an operation to switch to a different layout, for use with the
upcoming 'multi' UI.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 boot/bootctl/util.c  | 15 +++++++++++++++
 include/bootctl/ui.h | 16 ++++++++++++++++
 2 files changed, 31 insertions(+)
  

Patch

diff --git a/boot/bootctl/util.c b/boot/bootctl/util.c
index ec8de21815d..48912c67f21 100644
--- a/boot/bootctl/util.c
+++ b/boot/bootctl/util.c
@@ -95,6 +95,21 @@  int bc_ui_poll(struct udevice *disp, int *seqp, bool *selectedp)
 	return ret;
 }
 
+int bc_ui_switch_layout(struct udevice *dev)
+{
+	struct bc_ui_ops *ops = bc_ui_get_ops(dev);
+	int ret;
+
+	if (!ops->switch_layout)
+		return -ENOSYS;
+
+	ret = ops->switch_layout(dev);
+	if (ret)
+		return log_msg_ret("bsl", ret);
+
+	return 0;
+}
+
 void bc_oslist_setup_iter(struct oslist_iter *iter)
 {
 	memset(iter, '\0', sizeof(struct oslist_iter));
diff --git a/include/bootctl/ui.h b/include/bootctl/ui.h
index beb11178c52..4f8e08a00c2 100644
--- a/include/bootctl/ui.h
+++ b/include/bootctl/ui.h
@@ -91,6 +91,14 @@  struct bc_ui_ops {
 	 *	-ve on error
 	 */
 	int (*poll)(struct udevice *dev, int *seqp, bool *selectedp);
+
+	/**
+	 * switch_layout() - Switch between different UI layout modes
+	 *
+	 * @dev: Display device
+	 * Return 0 if OK, -ve on error
+	 */
+	int (*switch_layout)(struct udevice *dev);
 };
 
 #define bc_ui_get_ops(dev)  ((struct bc_ui_ops *)(dev)->driver->ops)
@@ -132,4 +140,12 @@  int bc_ui_render(struct udevice *dev);
  */
 int bc_ui_poll(struct udevice *dev, int *seqp, bool *selectedp);
 
+/**
+ * bc_ui_switch_layout() - Switch between different UI layout modes
+ *
+ * @dev: Display device
+ * Return 0 if OK, -ve on error
+ */
+int bc_ui_switch_layout(struct udevice *dev);
+
 #endif