From 42b18494bdaf677c4726ef47a839b16a1a3daba2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:22:34 -0600 Subject: expo: Store the console in the expo Rather than finding this each time, keep a pointer to it. This simplifies the code a little. Signed-off-by: Simon Glass --- boot/expo.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index 05950a17603..cd1b1a3de50 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -83,7 +83,16 @@ const char *expo_get_str(struct expo *exp, uint id) int expo_set_display(struct expo *exp, struct udevice *dev) { + struct udevice *cons; + int ret; + + ret = device_find_first_child_by_uclass(dev, UCLASS_VIDEO_CONSOLE, + &cons); + if (ret) + return log_msg_ret("con", ret); + exp->display = dev; + exp->cons = cons; return 0; } -- cgit v1.2.3 From 14a86a510792cb8a69ded6ea3b6c34a150bae3ab Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:22:35 -0600 Subject: expo: Avoid automatically arranging the scene This should ideally be done once after all scene changes have been made. Require an explicit call when everything is ready. Always arrange after a key it sent, just for convenience. Signed-off-by: Simon Glass --- boot/expo.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index cd1b1a3de50..bfdda9570c6 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -116,8 +116,16 @@ struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id) int expo_set_scene_id(struct expo *exp, uint scene_id) { - if (!expo_lookup_scene_id(exp, scene_id)) + struct scene *scn; + int ret; + + scn = expo_lookup_scene_id(exp, scene_id); + if (!scn) return log_msg_ret("id", -ENOENT); + ret = scene_arrange(scn); + if (ret) + return log_msg_ret("arr", ret); + exp->scene_id = scene_id; return 0; @@ -165,6 +173,11 @@ int expo_send_key(struct expo *exp, int key) ret = scene_send_key(scn, key, &exp->action); if (ret) return log_msg_ret("key", ret); + + /* arrange it to get any changes */ + ret = scene_arrange(scn); + if (ret) + return log_msg_ret("arr", ret); } return scn ? 0 : -ECHILD; -- cgit v1.2.3 From 5904d953a1183e191e9ec4ab15c31c6522f625ad Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:22:37 -0600 Subject: expo: Rename exp_set_text_mode() Rename this function to match its peers, using the full "expo' prefix. Signed-off-by: Simon Glass --- boot/expo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index bfdda9570c6..e7c81a3983d 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -97,7 +97,7 @@ int expo_set_display(struct expo *exp, struct udevice *dev) return 0; } -void exp_set_text_mode(struct expo *exp, bool text_mode) +void expo_set_text_mode(struct expo *exp, bool text_mode) { exp->text_mode = text_mode; } -- cgit v1.2.3 From c98cb512521e5e035774c49ab9a855cbb6b13813 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:22:43 -0600 Subject: bootstd: Add a separate log category for expo This feature is different enough from bootstd that it probably deserves its own log category. It cannot use a uclass since it is not a device. Add a new category. Signed-off-by: Simon Glass --- boot/expo.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index e7c81a3983d..8b966b6c793 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -6,6 +6,8 @@ * Written by Simon Glass */ +#define LOG_CATEGORY LOGC_EXPO + #include #include #include -- cgit v1.2.3 From 9af341502c1cdf1d40a41e8fe6c3922f1e409f33 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:22:47 -0600 Subject: expo: Allow setting the start of the dynamic-ID range Provide a way to set this value so that it is easy to separate the statically allocated IDs (generated by the caller) from those generated dynamically by expo itself. Signed-off-by: Simon Glass --- boot/expo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index 8b966b6c793..be11cfd4e94 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -56,6 +56,21 @@ void expo_destroy(struct expo *exp) free(exp); } +uint resolve_id(struct expo *exp, uint id) +{ + if (!id) + id = exp->next_id++; + else if (id >= exp->next_id) + exp->next_id = id + 1; + + return id; +} + +void expo_set_dynamic_start(struct expo *exp, uint dyn_start) +{ + exp->next_id = dyn_start; +} + int expo_str(struct expo *exp, const char *name, uint id, const char *str) { struct expo_string *estr; -- cgit v1.2.3 From 699b0acb522fd808b67b745b541bacf18c275d15 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:22:52 -0600 Subject: expo: Set up the width and height of objects Provide a way to set the full dimensions of objects, i.e. including the width and height. For menus, calculate the bounding box of all objects in the menu. Set all labels to be the same size, so that highlighting works correct, once implemented. Signed-off-by: Simon Glass --- boot/expo.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index be11cfd4e94..67cae3c7e28 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -114,6 +114,30 @@ int expo_set_display(struct expo *exp, struct udevice *dev) return 0; } +int expo_calc_dims(struct expo *exp) +{ + struct scene *scn; + int ret; + + if (!exp->cons) + return log_msg_ret("dim", -ENOTSUPP); + + list_for_each_entry(scn, &exp->scene_head, sibling) { + /* + * Do the menus last so that all the menus' text objects + * are dimensioned + */ + ret = scene_calc_dims(scn, false); + if (ret) + return log_msg_ret("scn", ret); + ret = scene_calc_dims(scn, true); + if (ret) + return log_msg_ret("scn", ret); + } + + return 0; +} + void expo_set_text_mode(struct expo *exp, bool text_mode) { exp->text_mode = text_mode; -- cgit v1.2.3 From 2e59389704cd1e46101f7ffda2dac3f44f2fa332 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:22:53 -0600 Subject: expo: Support simple themes It is a pain to manually set the fonts of all objects to be consistent. Some spacing settings are also better set globally than by manually positioning each object. Add a 'theme' to the expo, to hold this information. For now it includes only the font size. Signed-off-by: Simon Glass --- boot/expo.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index 67cae3c7e28..d5e935966bf 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -231,3 +231,23 @@ int expo_action_get(struct expo *exp, struct expo_action *act) return act->type == EXPOACT_NONE ? -EAGAIN : 0; } + +int expo_apply_theme(struct expo *exp, ofnode node) +{ + struct scene *scn; + struct expo_theme *theme = &exp->theme; + int ret; + + log_debug("Applying theme %s\n", ofnode_get_name(node)); + + memset(theme, '\0', sizeof(struct expo_theme)); + ofnode_read_u32(node, "font-size", &theme->font_size); + + list_for_each_entry(scn, &exp->scene_head, sibling) { + ret = scene_apply_theme(scn, theme); + if (ret) + return log_msg_ret("app", ret); + } + + return 0; +} -- cgit v1.2.3 From 4c87e073a4573159f97eb4ed80ec4088f33c7008 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:22:58 -0600 Subject: expo: Draw the current opened menu on top When a menu is opened, it must be displayed over all other objects in the scene, so that all its items are visible. Handle this by drawing the menu object a second time, after all other objects have been drawn. Draw all of the objects which are dependent on the menu object. Signed-off-by: Simon Glass --- boot/expo.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index d5e935966bf..e99555163ca 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -172,6 +172,18 @@ int expo_set_scene_id(struct expo *exp, uint scene_id) return 0; } +int expo_first_scene_id(struct expo *exp) +{ + struct scene *scn; + + if (list_empty(&exp->scene_head)) + return -ENOENT; + + scn = list_first_entry(&exp->scene_head, struct scene, sibling); + + return scn->id; +} + int expo_render(struct expo *exp) { struct udevice *dev = exp->display; -- cgit v1.2.3 From 7230fdb3837ad745adff4cf129dd04e893fe0a36 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:23:00 -0600 Subject: expo: Add spacing around menus and items It looks better if menus have a bit of an inset, rather than be drawn hard up against the background. Also, menu items look better if they have a bit of spacing between them. Add theme options for these and implement the required changes. Signed-off-by: Simon Glass --- boot/expo.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index e99555163ca..8c6fbc0e30b 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -254,6 +254,8 @@ int expo_apply_theme(struct expo *exp, ofnode node) memset(theme, '\0', sizeof(struct expo_theme)); ofnode_read_u32(node, "font-size", &theme->font_size); + ofnode_read_u32(node, "menu-inset", &theme->menu_inset); + ofnode_read_u32(node, "menuitem-gap-y", &theme->menuitem_gap_y); list_for_each_entry(scn, &exp->scene_head, sibling) { ret = scene_apply_theme(scn, theme); -- cgit v1.2.3 From 82cafee133ee5c087449761988c096fc26a17cf6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 Jun 2023 10:23:01 -0600 Subject: expo: Support building an expo from a description file The only way to create an expo at present is by calling the functions to create each object. It is useful to have more data-driven approach, where the objects can be specified in a suitable file format and created from that. This makes testing easier as well. Add support for describing an expo in a devicetree node. This allows more complex tests to be set up, as well as providing an easier format for users. It also provides a better basis for the upcoming configuration editor. Signed-off-by: Simon Glass --- boot/expo.c | 1 + 1 file changed, 1 insertion(+) (limited to 'boot/expo.c') diff --git a/boot/expo.c b/boot/expo.c index 8c6fbc0e30b..db837f7b492 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -58,6 +58,7 @@ void expo_destroy(struct expo *exp) uint resolve_id(struct expo *exp, uint id) { + log_debug("resolve id %d\n", id); if (!id) id = exp->next_id++; else if (id >= exp->next_id) -- cgit v1.2.3