blob: 9d2e817eb97aa9fd91795241620b5ee0ca9ce14b [file] [log] [blame]
Simon Glass87c6f8a2023-01-06 08:52:36 -06001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright 2022 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
Simon Glass040b0462023-08-14 16:40:25 -06007#ifndef __EXPO_H
8#define __EXPO_H
Simon Glass87c6f8a2023-01-06 08:52:36 -06009
Simon Glass2e593892023-06-01 10:22:53 -060010#include <dm/ofnode_decl.h>
Simon Glass87c6f8a2023-01-06 08:52:36 -060011#include <linux/list.h>
12
13struct udevice;
14
15/**
16 * enum expoact_type - types of actions reported by the expo
17 *
18 * @EXPOACT_NONE: no action
Simon Glass4e64bee2023-06-01 10:22:59 -060019 * @EXPOACT_POINT_OBJ: object was highlighted (@id indicates which)
Simon Glass3f33b9c2023-06-01 10:22:56 -060020 * @EXPOACT_POINT_ITEM: menu item was highlighted (@id indicates which)
Simon Glass87c6f8a2023-01-06 08:52:36 -060021 * @EXPOACT_SELECT: menu item was selected (@id indicates which)
Simon Glass4e64bee2023-06-01 10:22:59 -060022 * @EXPOACT_OPEN: menu was opened, so an item can be selected (@id indicates
23 * which menu object)
24 * @EXPOACT_CLOSE: menu was closed (@id indicates which menu object)
Simon Glass87c6f8a2023-01-06 08:52:36 -060025 * @EXPOACT_QUIT: request to exit the menu
26 */
27enum expoact_type {
28 EXPOACT_NONE,
Simon Glass4e64bee2023-06-01 10:22:59 -060029 EXPOACT_POINT_OBJ,
Simon Glass3f33b9c2023-06-01 10:22:56 -060030 EXPOACT_POINT_ITEM,
Simon Glass87c6f8a2023-01-06 08:52:36 -060031 EXPOACT_SELECT,
Simon Glass4e64bee2023-06-01 10:22:59 -060032 EXPOACT_OPEN,
33 EXPOACT_CLOSE,
Simon Glass87c6f8a2023-01-06 08:52:36 -060034 EXPOACT_QUIT,
35};
36
37/**
38 * struct expo_action - an action report by the expo
39 *
40 * @type: Action type (EXPOACT_NONE if there is no action)
Simon Glass3f33b9c2023-06-01 10:22:56 -060041 * @select: Used for EXPOACT_POINT_ITEM and EXPOACT_SELECT
Simon Glass87c6f8a2023-01-06 08:52:36 -060042 * @id: ID number of the object affected.
43 */
44struct expo_action {
45 enum expoact_type type;
46 union {
47 struct {
48 int id;
49 } select;
50 };
51};
52
53/**
Simon Glass2e593892023-06-01 10:22:53 -060054 * struct expo_theme - theme for the expo
55 *
56 * @font_size: Default font size for all text
57 * @menu_inset: Inset width (on each side and top/bottom) for menu items
58 * @menuitem_gap_y: Gap between menu items in pixels
59 */
60struct expo_theme {
61 u32 font_size;
62 u32 menu_inset;
63 u32 menuitem_gap_y;
64};
65
66/**
Simon Glass87c6f8a2023-01-06 08:52:36 -060067 * struct expo - information about an expo
68 *
69 * A group of scenes which can be presented to the user, typically to obtain
70 * input or to make a selection.
71 *
72 * @name: Name of the expo (allocated)
73 * @display: Display to use (`UCLASS_VIDEO`), or NULL to use text mode
Simon Glass42b18492023-06-01 10:22:34 -060074 * @cons: Console to use (`UCLASS_VIDEO_CONSOLE`), or NULL to use text mode
Simon Glass87c6f8a2023-01-06 08:52:36 -060075 * @scene_id: Current scene ID (0 if none)
76 * @next_id: Next ID number to use, for automatic allocation
77 * @action: Action selected by user. At present only one is supported, with the
78 * type set to EXPOACT_NONE if there is no action
79 * @text_mode: true to use text mode for the menu (no vidconsole)
Simon Glassd3db0212023-06-01 10:22:55 -060080 * @popup: true to use popup menus, instead of showing all items
Simon Glass87c6f8a2023-01-06 08:52:36 -060081 * @priv: Private data for the controller
Simon Glass2e593892023-06-01 10:22:53 -060082 * @theme: Information about fonts styles, etc.
Simon Glass87c6f8a2023-01-06 08:52:36 -060083 * @scene_head: List of scenes
84 * @str_head: list of strings
85 */
86struct expo {
87 char *name;
88 struct udevice *display;
Simon Glass42b18492023-06-01 10:22:34 -060089 struct udevice *cons;
Simon Glass87c6f8a2023-01-06 08:52:36 -060090 uint scene_id;
91 uint next_id;
92 struct expo_action action;
93 bool text_mode;
Simon Glassd3db0212023-06-01 10:22:55 -060094 bool popup;
Simon Glass87c6f8a2023-01-06 08:52:36 -060095 void *priv;
Simon Glass2e593892023-06-01 10:22:53 -060096 struct expo_theme theme;
Simon Glass87c6f8a2023-01-06 08:52:36 -060097 struct list_head scene_head;
98 struct list_head str_head;
99};
100
101/**
102 * struct expo_string - a string that can be used in an expo
103 *
104 * @id: ID number of the string
105 * @str: String
106 * @sibling: Node to link this object to its siblings
107 */
108struct expo_string {
109 uint id;
110 const char *str;
111 struct list_head sibling;
112};
113
114/**
115 * struct scene - information about a scene in an expo
116 *
117 * A collection of text/image/menu items in an expo
118 *
119 * @expo: Expo this scene is part of
120 * @name: Name of the scene (allocated)
121 * @id: ID number of the scene
Simon Glassdef898c2023-06-01 10:22:27 -0600122 * @title_id: String ID of title of the scene (allocated)
Simon Glassd3db0212023-06-01 10:22:55 -0600123 * @highlight_id: ID of highlighted object, if any
Simon Glass87c6f8a2023-01-06 08:52:36 -0600124 * @sibling: Node to link this scene to its siblings
125 * @obj_head: List of objects in the scene
126 */
127struct scene {
128 struct expo *expo;
129 char *name;
130 uint id;
Simon Glassdef898c2023-06-01 10:22:27 -0600131 uint title_id;
Simon Glassd3db0212023-06-01 10:22:55 -0600132 uint highlight_id;
Simon Glass87c6f8a2023-01-06 08:52:36 -0600133 struct list_head sibling;
134 struct list_head obj_head;
135};
136
137/**
138 * enum scene_obj_t - type of a scene object
139 *
140 * @SCENEOBJT_NONE: Used to indicate that the type does not matter
141 * @SCENEOBJT_IMAGE: Image data to render
142 * @SCENEOBJT_TEXT: Text line to render
143 * @SCENEOBJT_MENU: Menu containing items the user can select
144 */
145enum scene_obj_t {
146 SCENEOBJT_NONE = 0,
147 SCENEOBJT_IMAGE,
148 SCENEOBJT_TEXT,
149 SCENEOBJT_MENU,
150};
151
152/**
Simon Glassae45d6c2023-06-01 10:22:49 -0600153 * struct scene_dim - Dimensions of an object
154 *
155 * @x: x position, in pixels from left side
156 * @y: y position, in pixels from top
157 * @w: width, in pixels
158 * @h: height, in pixels
159 */
160struct scene_dim {
161 int x;
162 int y;
163 int w;
164 int h;
165};
166
167/**
Simon Glassce72c9e2023-06-01 10:22:50 -0600168 * enum scene_obj_flags_t - flags for objects
169 *
170 * @SCENEOF_HIDE: object should be hidden
Simon Glassd3db0212023-06-01 10:22:55 -0600171 * @SCENEOF_POINT: object should be highlighted
172 * @SCENEOF_OPEN: object should be opened (e.g. menu is opened so that an option
173 * can be selected)
Simon Glassce72c9e2023-06-01 10:22:50 -0600174 */
175enum scene_obj_flags_t {
176 SCENEOF_HIDE = 1 << 0,
Simon Glassd3db0212023-06-01 10:22:55 -0600177 SCENEOF_POINT = 1 << 1,
178 SCENEOF_OPEN = 1 << 2,
Simon Glassce72c9e2023-06-01 10:22:50 -0600179};
180
181/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600182 * struct scene_obj - information about an object in a scene
183 *
184 * @scene: Scene that this object relates to
185 * @name: Name of the object (allocated)
186 * @id: ID number of the object
187 * @type: Type of this object
Simon Glassae45d6c2023-06-01 10:22:49 -0600188 * @dim: Dimensions for this object
Simon Glassce72c9e2023-06-01 10:22:50 -0600189 * @flags: Flags for this object
Simon Glasseb6c71b2023-08-14 16:40:37 -0600190 * @bit_length: Number of bits used for this object in CMOS RAM
191 * @start_bit: Start bit to use for this object in CMOS RAM
Simon Glass87c6f8a2023-01-06 08:52:36 -0600192 * @sibling: Node to link this object to its siblings
193 */
194struct scene_obj {
195 struct scene *scene;
196 char *name;
197 uint id;
198 enum scene_obj_t type;
Simon Glassae45d6c2023-06-01 10:22:49 -0600199 struct scene_dim dim;
Simon Glasseb6c71b2023-08-14 16:40:37 -0600200 u8 flags;
201 u8 bit_length;
202 u16 start_bit;
Simon Glass87c6f8a2023-01-06 08:52:36 -0600203 struct list_head sibling;
204};
205
206/**
207 * struct scene_obj_img - information about an image object in a scene
208 *
209 * This is a rectangular image which is blitted onto the display
210 *
211 * @obj: Basic object information
212 * @data: Image data in BMP format
213 */
214struct scene_obj_img {
215 struct scene_obj obj;
216 char *data;
217};
218
219/**
220 * struct scene_obj_txt - information about a text object in a scene
221 *
222 * This is a single-line text object
223 *
224 * @obj: Basic object information
225 * @str_id: ID of the text string to display
226 * @font_name: Name of font (allocated by caller)
227 * @font_size: Nominal size of font in pixels
228 */
229struct scene_obj_txt {
230 struct scene_obj obj;
231 uint str_id;
232 const char *font_name;
233 uint font_size;
234};
235
236/**
237 * struct scene_obj_menu - information about a menu object in a scene
238 *
239 * A menu has a number of items which can be selected by the user
240 *
241 * It also has:
242 *
243 * - a text/image object (@pointer_id) which points to the current item
244 * (@cur_item_id)
245 *
246 * - a preview object which shows an image related to the current item
247 *
248 * @obj: Basic object information
249 * @title_id: ID of the title text, or 0 if none
250 * @cur_item_id: ID of the current menu item, or 0 if none
251 * @pointer_id: ID of the object pointing to the current selection
252 * @item_head: List of items in the menu
253 */
254struct scene_obj_menu {
255 struct scene_obj obj;
256 uint title_id;
257 uint cur_item_id;
258 uint pointer_id;
259 struct list_head item_head;
260};
261
262/**
263 * enum scene_menuitem_flags_t - flags for menu items
264 *
265 * @SCENEMIF_GAP_BEFORE: Add a gap before this item
266 */
267enum scene_menuitem_flags_t {
268 SCENEMIF_GAP_BEFORE = 1 << 0,
269};
270
271/**
272 * struct scene_menitem - a menu item in a menu
273 *
274 * A menu item has:
275 *
276 * - text object holding the name (short) and description (can be longer)
277 * - a text object holding the keypress
278 *
279 * @name: Name of the item (this is allocated by this call)
280 * @id: ID number of the object
281 * @key_id: ID of text object to use as the keypress to show
282 * @label_id: ID of text object to use as the label text
283 * @desc_id: ID of text object to use as the description text
284 * @preview_id: ID of the preview object, or 0 if none
285 * @flags: Flags for this item
286 * @sibling: Node to link this item to its siblings
287 */
288struct scene_menitem {
289 char *name;
290 uint id;
291 uint key_id;
292 uint label_id;
293 uint desc_id;
294 uint preview_id;
295 uint flags;
296 struct list_head sibling;
297};
298
299/**
300 * expo_new() - create a new expo
301 *
302 * Allocates a new expo
303 *
304 * @name: Name of expo (this is allocated by this call)
305 * @priv: Private data for the controller
306 * @expp: Returns a pointer to the new expo on success
307 * Returns: 0 if OK, -ENOMEM if out of memory
308 */
309int expo_new(const char *name, void *priv, struct expo **expp);
310
311/**
312 * expo_destroy() - Destroy an expo and free all its memory
313 *
314 * @exp: Expo to destroy
315 */
316void expo_destroy(struct expo *exp);
317
318/**
Simon Glass9af34152023-06-01 10:22:47 -0600319 * expo_set_dynamic_start() - Set the start of the 'dynamic' IDs
320 *
321 * It is common for a set of 'static' IDs to be used to refer to objects in the
322 * expo. These typically use an enum so that they are defined in sequential
323 * order.
324 *
325 * Dynamic IDs (for objects not in the enum) are intended to be used for
326 * objects to which the code does not need to refer. These are ideally located
327 * above the static IDs.
328 *
329 * Use this function to set the start of the dynamic range, making sure that the
330 * value is higher than all the statically allocated IDs.
331 *
332 * @exp: Expo to update
333 * @dyn_start: Start ID that expo should use for dynamic allocation
334 */
335void expo_set_dynamic_start(struct expo *exp, uint dyn_start);
336
337/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600338 * expo_str() - add a new string to an expo
339 *
340 * @exp: Expo to update
341 * @name: Name to use (this is allocated by this call)
342 * @id: ID to use for the new object (0 to allocate one)
343 * @str: Pointer to text to display (allocated by caller)
344 * Returns: ID number for the object (typically @id), or -ve on error
345 */
346int expo_str(struct expo *exp, const char *name, uint id, const char *str);
347
348/**
349 * expo_get_str() - Get a string by ID
350 *
351 * @exp: Expo to use
352 * @id: String ID to look up
353 * @returns string, or NULL if not found
354 */
355const char *expo_get_str(struct expo *exp, uint id);
356
357/**
358 * expo_set_display() - set the display to use for a expo
359 *
360 * @exp: Expo to update
361 * @dev: Display to use (`UCLASS_VIDEO`), NULL to use text mode
362 * Returns: 0 (always)
363 */
364int expo_set_display(struct expo *exp, struct udevice *dev);
365
366/**
Simon Glass699b0ac2023-06-01 10:22:52 -0600367 * expo_calc_dims() - Calculate the dimensions of the objects
368 *
369 * Updates the width and height of all objects based on their contents
370 *
371 * @exp: Expo to update
372 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
373 */
374int expo_calc_dims(struct expo *exp);
375
376/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600377 * expo_set_scene_id() - Set the current scene ID
378 *
379 * @exp: Expo to update
380 * @scene_id: New scene ID to use (0 to select no scene)
381 * Returns: 0 if OK, -ENOENT if there is no scene with that ID
382 */
383int expo_set_scene_id(struct expo *exp, uint scene_id);
384
385/**
Simon Glassa0874dc2023-06-01 10:23:02 -0600386 * expo_first_scene_id() - Get the ID of the first scene
387 *
388 * @exp: Expo to check
389 * Returns: Scene ID of first scene, or -ENOENT if there are no scenes
390 */
391int expo_first_scene_id(struct expo *exp);
392
393/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600394 * expo_render() - render the expo on the display / console
395 *
396 * @exp: Expo to render
397 *
398 * Returns: 0 if OK, -ECHILD if there is no current scene, -ENOENT if the
399 * current scene is not found, other error if something else goes wrong
400 */
401int expo_render(struct expo *exp);
402
403/**
Simon Glass5904d952023-06-01 10:22:37 -0600404 * expo_set_text_mode() - Controls whether the expo renders in text mode
Simon Glass87c6f8a2023-01-06 08:52:36 -0600405 *
406 * @exp: Expo to update
407 * @text_mode: true to use text mode, false to use the console
408 */
Simon Glass5904d952023-06-01 10:22:37 -0600409void expo_set_text_mode(struct expo *exp, bool text_mode);
Simon Glass87c6f8a2023-01-06 08:52:36 -0600410
411/**
412 * scene_new() - create a new scene in a expo
413 *
414 * The scene is given the ID @id which must be unique across all scenes, objects
415 * and items. The expo's @next_id is updated to at least @id + 1
416 *
417 * @exp: Expo to update
418 * @name: Name to use (this is allocated by this call)
419 * @id: ID to use for the new scene (0 to allocate one)
420 * @scnp: Returns a pointer to the new scene on success
421 * Returns: ID number for the scene (typically @id), or -ve on error
422 */
423int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp);
424
425/**
426 * expo_lookup_scene_id() - Look up a scene by ID
427 *
428 * @exp: Expo to check
429 * @scene_id: Scene ID to look up
430 * @returns pointer to scene if found, else NULL
431 */
432struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id);
433
434/**
Simon Glass756c9552023-06-01 10:22:57 -0600435 * scene_highlight_first() - Highlight the first item in a scene
436 *
437 * This highlights the first item, so that the user can see that it is pointed
438 * to
439 *
440 * @scn: Scene to update
441 */
442void scene_highlight_first(struct scene *scn);
443
444/**
445 * scene_set_highlight_id() - Set the object which is highlighted
446 *
447 * Sets a new object to highlight in the scene
448 *
449 * @scn: Scene to update
450 * @id: ID of object to highlight
451 */
452void scene_set_highlight_id(struct scene *scn, uint id);
453
454/**
455 * scene_set_open() - Set whether an item is open or not
456 *
457 * @scn: Scene to update
458 * @id: ID of object to update
459 * @open: true to open the object, false to close it
460 * Returns: 0 if OK, -ENOENT if @id is invalid
461 */
462int scene_set_open(struct scene *scn, uint id, bool open);
463
464/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600465 * scene_title_set() - set the scene title
466 *
467 * @scn: Scene to update
Simon Glassdef898c2023-06-01 10:22:27 -0600468 * @title_id: Title ID to set
469 * Returns: 0 if OK
Simon Glass87c6f8a2023-01-06 08:52:36 -0600470 */
Simon Glassdef898c2023-06-01 10:22:27 -0600471int scene_title_set(struct scene *scn, uint title_id);
Simon Glass87c6f8a2023-01-06 08:52:36 -0600472
473/**
474 * scene_obj_count() - Count the number of objects in a scene
475 *
476 * @scn: Scene to check
477 * Returns: number of objects in the scene, 0 if none
478 */
479int scene_obj_count(struct scene *scn);
480
481/**
482 * scene_img() - add a new image to a scene
483 *
484 * @scn: Scene to update
485 * @name: Name to use (this is allocated by this call)
486 * @id: ID to use for the new object (0 to allocate one)
487 * @data: Pointer to image data
488 * @imgp: If non-NULL, returns the new object
489 * Returns: ID number for the object (typically @id), or -ve on error
490 */
491int scene_img(struct scene *scn, const char *name, uint id, char *data,
492 struct scene_obj_img **imgp);
493
494/**
495 * scene_txt() - add a new text object to a scene
496 *
497 * @scn: Scene to update
498 * @name: Name to use (this is allocated by this call)
499 * @id: ID to use for the new object (0 to allocate one)
500 * @str_id: ID of the string to use
501 * @txtp: If non-NULL, returns the new object
502 * Returns: ID number for the object (typically @id), or -ve on error
503 */
504int scene_txt(struct scene *scn, const char *name, uint id, uint str_id,
505 struct scene_obj_txt **txtp);
506
507/**
508 * scene_txt_str() - add a new string to expr and text object to a scene
509 *
510 * @scn: Scene to update
511 * @name: Name to use (this is allocated by this call)
512 * @id: ID to use for the new object (0 to allocate one)
513 * @str_id: ID of the string to use
514 * @str: Pointer to text to display (allocated by caller)
515 * @txtp: If non-NULL, returns the new object
516 * Returns: ID number for the object (typically @id), or -ve on error
517 */
518int scene_txt_str(struct scene *scn, const char *name, uint id, uint str_id,
519 const char *str, struct scene_obj_txt **txtp);
520
521/**
522 * scene_menu() - create a menu
523 *
524 * @scn: Scene to update
525 * @name: Name to use (this is allocated by this call)
526 * @id: ID to use for the new object (0 to allocate one)
527 * @menup: If non-NULL, returns the new object
528 * Returns: ID number for the object (typically @id), or -ve on error
529 */
530int scene_menu(struct scene *scn, const char *name, uint id,
531 struct scene_obj_menu **menup);
532
533/**
534 * scene_txt_set_font() - Set the font for an object
535 *
536 * @scn: Scene to update
537 * @id: ID of object to update
538 * @font_name: Font name to use (allocated by caller)
539 * @font_size: Font size to use (nominal height in pixels)
540 */
541int scene_txt_set_font(struct scene *scn, uint id, const char *font_name,
542 uint font_size);
543
544/**
545 * scene_obj_set_pos() - Set the postion of an object
546 *
547 * @scn: Scene to update
548 * @id: ID of object to update
549 * @x: x position, in pixels from left side
550 * @y: y position, in pixels from top
551 * Returns: 0 if OK, -ENOENT if @id is invalid
552 */
553int scene_obj_set_pos(struct scene *scn, uint id, int x, int y);
554
555/**
Simon Glass699b0ac2023-06-01 10:22:52 -0600556 * scene_obj_set_size() - Set the size of an object
557 *
558 * @scn: Scene to update
559 * @id: ID of object to update
560 * @w: width in pixels
561 * @h: height in pixels
562 * Returns: 0 if OK, -ENOENT if @id is invalid
563 */
564int scene_obj_set_size(struct scene *scn, uint id, int w, int h);
565
566/**
Simon Glass87c6f8a2023-01-06 08:52:36 -0600567 * scene_obj_set_hide() - Set whether an object is hidden
568 *
569 * The update happens when the expo is next rendered.
570 *
571 * @scn: Scene to update
572 * @id: ID of object to update
573 * @hide: true to hide the object, false to show it
574 * Returns: 0 if OK, -ENOENT if @id is invalid
575 */
576int scene_obj_set_hide(struct scene *scn, uint id, bool hide);
577
578/**
579 * scene_menu_set_title() - Set the title of a menu
580 *
581 * @scn: Scene to update
582 * @id: ID of menu object to update
583 * @title_id: ID of text object to use as the title
584 * Returns: 0 if OK, -ENOENT if @id is invalid, -EINVAL if @title_id is invalid
585 */
586int scene_menu_set_title(struct scene *scn, uint id, uint title_id);
587
588/**
589 * scene_menu_set_pointer() - Set the item pointer for a menu
590 *
591 * This is a visual indicator of the current item, typically a ">" character
592 * which sits next to the current item and moves when the user presses the
593 * up/down arrow keys
594 *
595 * @scn: Scene to update
596 * @id: ID of menu object to update
597 * @cur_item_id: ID of text or image object to use as a pointer to the current
598 * item
599 * Returns: 0 if OK, -ENOENT if @id is invalid, -EINVAL if @cur_item_id is invalid
600 */
601int scene_menu_set_pointer(struct scene *scn, uint id, uint cur_item_id);
602
603/**
604 * scene_obj_get_hw() - Get width and height of an object in a scene
605 *
606 * @scn: Scene to check
607 * @id: ID of menu object to check
608 * @widthp: If non-NULL, returns width of object in pixels
609 * Returns: Height of object in pixels
610 */
611int scene_obj_get_hw(struct scene *scn, uint id, int *widthp);
612
613/**
614 * scene_menuitem() - Add an item to a menu
615 *
616 * @scn: Scene to update
617 * @menu_id: ID of menu object to update
618 * @name: Name to use (this is allocated by this call)
619 * @id: ID to use for the new object (0 to allocate one)
620 * @key_id: ID of text object to use as the keypress to show
621 * @label_id: ID of text object to use as the label text
622 * @desc_id: ID of text object to use as the description text
623 * @preview_id: ID of object to use as the preview (text or image)
624 * @flags: Flags for this item (enum scene_menuitem_flags_t)
625 * @itemp: If non-NULL, returns the new object
626 * Returns: ID number for the item (typically @id), or -ve on error
627 */
628int scene_menuitem(struct scene *scn, uint menu_id, const char *name, uint id,
629 uint key_id, uint label_id, uint desc_id, uint preview_id,
630 uint flags, struct scene_menitem **itemp);
631
632/**
633 * scene_arrange() - Arrange the scene to deal with object sizes
634 *
635 * Updates any menus in the scene so that their objects are in the right place.
636 *
637 * @scn: Scene to arrange
638 * Returns: 0 if OK, -ve on error
639 */
640int scene_arrange(struct scene *scn);
641
642/**
643 * expo_send_key() - set a keypress to the expo
644 *
645 * @exp: Expo to receive the key
646 * @key: Key to send (ASCII or enum bootmenu_key)
647 * Returns: 0 if OK, -ECHILD if there is no current scene
648 */
649int expo_send_key(struct expo *exp, int key);
650
651/**
652 * expo_action_get() - read user input from the expo
653 *
654 * @exp: Expo to check
655 * @act: Returns action
656 * Returns: 0 if OK, -EAGAIN if there was no action to return
657 */
658int expo_action_get(struct expo *exp, struct expo_action *act);
659
Simon Glass2e593892023-06-01 10:22:53 -0600660/**
661 * expo_apply_theme() - Apply a theme to an expo
662 *
663 * @exp: Expo to update
664 * @node: Node containing the theme
665 */
666int expo_apply_theme(struct expo *exp, ofnode node);
667
Simon Glass82cafee2023-06-01 10:23:01 -0600668/**
669 * expo_build() - Build an expo from an FDT description
670 *
671 * Build a complete expo from a description in the provided devicetree.
672 *
Massimo Pegorera3a057f2023-09-09 12:32:28 +0200673 * See doc/develop/expo.rst for a description of the format
Simon Glass82cafee2023-06-01 10:23:01 -0600674 *
675 * @root: Root node for expo description
676 * @expp: Returns the new expo
677 * Returns: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is a format
678 * error, -ENOENT if there is a references to a non-existent string
679 */
680int expo_build(ofnode root, struct expo **expp);
681
Simon Glass040b0462023-08-14 16:40:25 -0600682#endif /*__EXPO_H */