1 // SPDX-License-Identifier: GPL-2.0+
3 * Implementation of configuration editor
5 * Copyright 2023 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
15 #include <linux/delay.h>
16 #include "scene_internal.h"
18 int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
20 struct scene_obj_txt *txt;
21 struct scene_obj *obj;
25 scn = expo_lookup_scene_id(exp, scene_id);
27 return log_msg_ret("scn", -ENOENT);
29 txt = scene_obj_find_by_name(scn, "prompt");
31 scene_obj_set_pos(scn, txt->obj.id, 0, vpriv->ysize - 50);
33 txt = scene_obj_find_by_name(scn, "title");
35 scene_obj_set_pos(scn, txt->obj.id, 200, 10);
38 list_for_each_entry(obj, &scn->obj_head, sibling) {
39 if (obj->type == SCENEOBJT_MENU) {
40 scene_obj_set_pos(scn, obj->id, 50, y);
41 scene_menu_arrange(scn, (struct scene_obj_menu *)obj);
49 int cedit_run(struct expo *exp)
51 struct cli_ch_state s_cch, *cch = &s_cch;
52 struct video_priv *vid_priv;
61 /* For now we only support a video console */
62 ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
64 return log_msg_ret("vid", ret);
65 ret = expo_set_display(exp, dev);
67 return log_msg_ret("dis", ret);
69 ret = expo_first_scene_id(exp);
71 return log_msg_ret("scn", ret);
74 ret = expo_set_scene_id(exp, scene_id);
76 return log_msg_ret("sid", ret);
80 /* This is not supported for now */
82 expo_set_text_mode(exp, true);
84 vid_priv = dev_get_uclass_priv(dev);
86 scn = expo_lookup_scene_id(exp, scene_id);
87 scene_highlight_first(scn);
89 cedit_arange(exp, vid_priv, scene_id);
91 ret = expo_calc_dims(exp);
93 return log_msg_ret("dim", ret);
97 struct expo_action act;
100 ret = expo_render(exp);
104 ichar = cli_ch_process(cch, 0);
106 while (!ichar && !tstc()) {
109 ichar = cli_ch_process(cch, -ETIMEDOUT);
113 ichar = cli_ch_process(cch, ichar);
119 key = bootmenu_conv_key(ichar);
120 if (key == BKEY_NONE)
126 ret = expo_send_key(exp, key);
130 ret = expo_action_get(exp, &act);
133 case EXPOACT_POINT_OBJ:
134 scene_set_highlight_id(scn, act.select.id);
135 cedit_arange(exp, vid_priv, scene_id);
138 scene_set_open(scn, act.select.id, true);
139 cedit_arange(exp, vid_priv, scene_id);
142 scene_set_open(scn, act.select.id, false);
143 cedit_arange(exp, vid_priv, scene_id);
146 scene_set_open(scn, scn->highlight_id, false);
147 cedit_arange(exp, vid_priv, scene_id);
150 log_debug("quitting\n");
160 return log_msg_ret("end", ret);