expo: Add CLI context to the expo
An expo generally needs to keep track of the keyboard state while it is
running, so move the context into struct expo
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c
index 9d0dc35..43125e1 100644
--- a/boot/bootflow_menu.c
+++ b/boot/bootflow_menu.c
@@ -178,7 +178,6 @@
int bootflow_menu_run(struct bootstd_priv *std, bool text_mode,
struct bootflow **bflowp)
{
- struct cli_ch_state s_cch, *cch = &s_cch;
struct bootflow *sel_bflow;
struct udevice *dev;
struct expo *exp;
@@ -186,8 +185,6 @@
bool done;
int ret;
- cli_ch_init(cch);
-
sel_bflow = NULL;
*bflowp = NULL;
@@ -225,16 +222,16 @@
if (ret)
break;
- ichar = cli_ch_process(cch, 0);
+ ichar = cli_ch_process(&exp->cch, 0);
if (!ichar) {
while (!ichar && !tstc()) {
schedule();
mdelay(2);
- ichar = cli_ch_process(cch, -ETIMEDOUT);
+ ichar = cli_ch_process(&exp->cch, -ETIMEDOUT);
}
if (!ichar) {
ichar = getchar();
- ichar = cli_ch_process(cch, ichar);
+ ichar = cli_ch_process(&exp->cch, ichar);
}
}
diff --git a/boot/cedit.c b/boot/cedit.c
index 4e80875..ed499f1 100644
--- a/boot/cedit.c
+++ b/boot/cedit.c
@@ -151,14 +151,12 @@
int cedit_run(struct expo *exp)
{
- struct cli_ch_state s_cch, *cch = &s_cch;
struct video_priv *vid_priv;
uint scene_id;
struct scene *scn;
bool done, save;
int ret;
- cli_ch_init(cch);
ret = cedit_prepare(exp, &vid_priv, &scn);
if (ret < 0)
return log_msg_ret("prep", ret);
@@ -174,16 +172,16 @@
if (ret)
break;
- ichar = cli_ch_process(cch, 0);
+ ichar = cli_ch_process(&exp->cch, 0);
if (!ichar) {
while (!ichar && !tstc()) {
schedule();
mdelay(2);
- ichar = cli_ch_process(cch, -ETIMEDOUT);
+ ichar = cli_ch_process(&exp->cch, -ETIMEDOUT);
}
if (!ichar) {
ichar = getchar();
- ichar = cli_ch_process(cch, ichar);
+ ichar = cli_ch_process(&exp->cch, ichar);
}
}
diff --git a/boot/expo.c b/boot/expo.c
index 8ce645e..9c042f1 100644
--- a/boot/expo.c
+++ b/boot/expo.c
@@ -30,6 +30,7 @@
INIT_LIST_HEAD(&exp->scene_head);
INIT_LIST_HEAD(&exp->str_head);
exp->next_id = EXPOID_BASE_ID;
+ cli_ch_init(&exp->cch);
*expp = exp;
diff --git a/include/expo.h b/include/expo.h
index 3c383d2..b3b9c0b 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -108,6 +108,7 @@
* @theme: Information about fonts styles, etc.
* @scene_head: List of scenes
* @str_head: list of strings
+ * @cch: Keyboard context for input
*/
struct expo {
char *name;
@@ -122,6 +123,7 @@
struct expo_theme theme;
struct list_head scene_head;
struct list_head str_head;
+ struct cli_ch_state cch;
};
/**