blob: a535bc1695d6faad60a03adbcda03acbfc44990b [file] [log] [blame]
Simon Glassd8adbe92023-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 Glass8df4a4e2023-08-14 16:40:25 -06007#ifndef __EXPO_H
8#define __EXPO_H
Simon Glassd8adbe92023-01-06 08:52:36 -06009
Simon Glassa968f5f2023-10-01 19:13:31 -060010#include <abuf.h>
Simon Glassc999e172023-06-01 10:22:53 -060011#include <dm/ofnode_decl.h>
Simon Glassd8adbe92023-01-06 08:52:36 -060012#include <linux/list.h>
13
14struct udevice;
15
Simon Glassa968f5f2023-10-01 19:13:31 -060016#include <cli.h>
17
Simon Glassd8adbe92023-01-06 08:52:36 -060018/**
19 * enum expoact_type - types of actions reported by the expo
20 *
21 * @EXPOACT_NONE: no action
Simon Glassf0e1e8c2023-06-01 10:22:59 -060022 * @EXPOACT_POINT_OBJ: object was highlighted (@id indicates which)
Simon Glass719a3c62023-06-01 10:22:56 -060023 * @EXPOACT_POINT_ITEM: menu item was highlighted (@id indicates which)
Simon Glassd8adbe92023-01-06 08:52:36 -060024 * @EXPOACT_SELECT: menu item was selected (@id indicates which)
Simon Glassf0e1e8c2023-06-01 10:22:59 -060025 * @EXPOACT_OPEN: menu was opened, so an item can be selected (@id indicates
26 * which menu object)
27 * @EXPOACT_CLOSE: menu was closed (@id indicates which menu object)
Simon Glassd8adbe92023-01-06 08:52:36 -060028 * @EXPOACT_QUIT: request to exit the menu
29 */
30enum expoact_type {
31 EXPOACT_NONE,
Simon Glassf0e1e8c2023-06-01 10:22:59 -060032 EXPOACT_POINT_OBJ,
Simon Glass719a3c62023-06-01 10:22:56 -060033 EXPOACT_POINT_ITEM,
Simon Glassd8adbe92023-01-06 08:52:36 -060034 EXPOACT_SELECT,
Simon Glassf0e1e8c2023-06-01 10:22:59 -060035 EXPOACT_OPEN,
36 EXPOACT_CLOSE,
Simon Glassd8adbe92023-01-06 08:52:36 -060037 EXPOACT_QUIT,
38};
39
40/**
41 * struct expo_action - an action report by the expo
42 *
43 * @type: Action type (EXPOACT_NONE if there is no action)
Simon Glass719a3c62023-06-01 10:22:56 -060044 * @select: Used for EXPOACT_POINT_ITEM and EXPOACT_SELECT
Simon Glassd8adbe92023-01-06 08:52:36 -060045 * @id: ID number of the object affected.
46 */
47struct expo_action {
48 enum expoact_type type;
49 union {
50 struct {
51 int id;
52 } select;
53 };
54};
55
56/**
Simon Glassc999e172023-06-01 10:22:53 -060057 * struct expo_theme - theme for the expo
58 *
59 * @font_size: Default font size for all text
60 * @menu_inset: Inset width (on each side and top/bottom) for menu items
61 * @menuitem_gap_y: Gap between menu items in pixels
62 */
63struct expo_theme {
64 u32 font_size;
65 u32 menu_inset;
66 u32 menuitem_gap_y;
67};
68
69/**
Simon Glassd8adbe92023-01-06 08:52:36 -060070 * struct expo - information about an expo
71 *
72 * A group of scenes which can be presented to the user, typically to obtain
73 * input or to make a selection.
74 *
75 * @name: Name of the expo (allocated)
76 * @display: Display to use (`UCLASS_VIDEO`), or NULL to use text mode
Simon Glass67e2af12023-06-01 10:22:34 -060077 * @cons: Console to use (`UCLASS_VIDEO_CONSOLE`), or NULL to use text mode
Simon Glassd8adbe92023-01-06 08:52:36 -060078 * @scene_id: Current scene ID (0 if none)
79 * @next_id: Next ID number to use, for automatic allocation
80 * @action: Action selected by user. At present only one is supported, with the
81 * type set to EXPOACT_NONE if there is no action
82 * @text_mode: true to use text mode for the menu (no vidconsole)
Simon Glassd353b752023-06-01 10:22:55 -060083 * @popup: true to use popup menus, instead of showing all items
Simon Glassd8adbe92023-01-06 08:52:36 -060084 * @priv: Private data for the controller
Simon Glassc999e172023-06-01 10:22:53 -060085 * @theme: Information about fonts styles, etc.
Simon Glassd8adbe92023-01-06 08:52:36 -060086 * @scene_head: List of scenes
87 * @str_head: list of strings
88 */
89struct expo {
90 char *name;
91 struct udevice *display;
Simon Glass67e2af12023-06-01 10:22:34 -060092 struct udevice *cons;
Simon Glassd8adbe92023-01-06 08:52:36 -060093 uint scene_id;
94 uint next_id;
95 struct expo_action action;
96 bool text_mode;
Simon Glassd353b752023-06-01 10:22:55 -060097 bool popup;
Simon Glassd8adbe92023-01-06 08:52:36 -060098 void *priv;
Simon Glassc999e172023-06-01 10:22:53 -060099 struct expo_theme theme;
Simon Glassd8adbe92023-01-06 08:52:36 -0600100 struct list_head scene_head;
101 struct list_head str_head;
102};
103
104/**
105 * struct expo_string - a string that can be used in an expo
106 *
107 * @id: ID number of the string
108 * @str: String
109 * @sibling: Node to link this object to its siblings
110 */
111struct expo_string {
112 uint id;
113 const char *str;
114 struct list_head sibling;
115};
116
117/**
118 * struct scene - information about a scene in an expo
119 *
120 * A collection of text/image/menu items in an expo
121 *
122 * @expo: Expo this scene is part of
123 * @name: Name of the scene (allocated)
124 * @id: ID number of the scene
Simon Glassea274b62023-06-01 10:22:27 -0600125 * @title_id: String ID of title of the scene (allocated)
Simon Glassd353b752023-06-01 10:22:55 -0600126 * @highlight_id: ID of highlighted object, if any
Simon Glassa968f5f2023-10-01 19:13:31 -0600127 * @cls: cread state to use for input
128 * @buf: Buffer for input
129 * @entry_save: Buffer to hold vidconsole text-entry information
Simon Glassd8adbe92023-01-06 08:52:36 -0600130 * @sibling: Node to link this scene to its siblings
131 * @obj_head: List of objects in the scene
132 */
133struct scene {
134 struct expo *expo;
135 char *name;
136 uint id;
Simon Glassea274b62023-06-01 10:22:27 -0600137 uint title_id;
Simon Glassd353b752023-06-01 10:22:55 -0600138 uint highlight_id;
Simon Glassa968f5f2023-10-01 19:13:31 -0600139 struct cli_line_state cls;
140 struct abuf buf;
141 struct abuf entry_save;
Simon Glassd8adbe92023-01-06 08:52:36 -0600142 struct list_head sibling;
143 struct list_head obj_head;
144};
145
146/**
147 * enum scene_obj_t - type of a scene object
148 *
149 * @SCENEOBJT_NONE: Used to indicate that the type does not matter
150 * @SCENEOBJT_IMAGE: Image data to render
151 * @SCENEOBJT_TEXT: Text line to render
152 * @SCENEOBJT_MENU: Menu containing items the user can select
153 */
154enum scene_obj_t {
155 SCENEOBJT_NONE = 0,
156 SCENEOBJT_IMAGE,
157 SCENEOBJT_TEXT,
Simon Glass193bfea2023-10-01 19:13:27 -0600158
159 /* types from here on can be highlighted */
Simon Glassd8adbe92023-01-06 08:52:36 -0600160 SCENEOBJT_MENU,
161};
162
163/**
Simon Glass7b043952023-06-01 10:22:49 -0600164 * struct scene_dim - Dimensions of an object
165 *
166 * @x: x position, in pixels from left side
167 * @y: y position, in pixels from top
168 * @w: width, in pixels
169 * @h: height, in pixels
170 */
171struct scene_dim {
172 int x;
173 int y;
174 int w;
175 int h;
176};
177
178/**
Simon Glass6081b0f2023-06-01 10:22:50 -0600179 * enum scene_obj_flags_t - flags for objects
180 *
181 * @SCENEOF_HIDE: object should be hidden
Simon Glassd353b752023-06-01 10:22:55 -0600182 * @SCENEOF_POINT: object should be highlighted
183 * @SCENEOF_OPEN: object should be opened (e.g. menu is opened so that an option
184 * can be selected)
Simon Glass6081b0f2023-06-01 10:22:50 -0600185 */
186enum scene_obj_flags_t {
187 SCENEOF_HIDE = 1 << 0,
Simon Glassd353b752023-06-01 10:22:55 -0600188 SCENEOF_POINT = 1 << 1,
189 SCENEOF_OPEN = 1 << 2,
Simon Glass6081b0f2023-06-01 10:22:50 -0600190};
191
Simon Glassa968f5f2023-10-01 19:13:31 -0600192enum {
193 /* Maximum number of characters allowed in an line editor */
194 EXPO_MAX_CHARS = 250,
195};
196
Simon Glass6081b0f2023-06-01 10:22:50 -0600197/**
Simon Glassd8adbe92023-01-06 08:52:36 -0600198 * struct scene_obj - information about an object in a scene
199 *
200 * @scene: Scene that this object relates to
201 * @name: Name of the object (allocated)
202 * @id: ID number of the object
203 * @type: Type of this object
Simon Glass7b043952023-06-01 10:22:49 -0600204 * @dim: Dimensions for this object
Simon Glass6081b0f2023-06-01 10:22:50 -0600205 * @flags: Flags for this object
Simon Glass2b91ca62023-08-14 16:40:37 -0600206 * @bit_length: Number of bits used for this object in CMOS RAM
207 * @start_bit: Start bit to use for this object in CMOS RAM
Simon Glassd8adbe92023-01-06 08:52:36 -0600208 * @sibling: Node to link this object to its siblings
209 */
210struct scene_obj {
211 struct scene *scene;
212 char *name;
213 uint id;
214 enum scene_obj_t type;
Simon Glass7b043952023-06-01 10:22:49 -0600215 struct scene_dim dim;
Simon Glass2b91ca62023-08-14 16:40:37 -0600216 u8 flags;
217 u8 bit_length;
218 u16 start_bit;
Simon Glassd8adbe92023-01-06 08:52:36 -0600219 struct list_head sibling;
220};
221
Simon Glass193bfea2023-10-01 19:13:27 -0600222/* object can be highlighted when moving around expo */
223static inline bool scene_obj_can_highlight(const struct scene_obj *obj)
224{
225 return obj->type >= SCENEOBJT_MENU;
226}
227
Simon Glassd8adbe92023-01-06 08:52:36 -0600228/**
229 * struct scene_obj_img - information about an image object in a scene
230 *
231 * This is a rectangular image which is blitted onto the display
232 *
233 * @obj: Basic object information
234 * @data: Image data in BMP format
235 */
236struct scene_obj_img {
237 struct scene_obj obj;
238 char *data;
239};
240
241/**
242 * struct scene_obj_txt - information about a text object in a scene
243 *
244 * This is a single-line text object
245 *
246 * @obj: Basic object information
247 * @str_id: ID of the text string to display
248 * @font_name: Name of font (allocated by caller)
249 * @font_size: Nominal size of font in pixels
250 */
251struct scene_obj_txt {
252 struct scene_obj obj;
253 uint str_id;
254 const char *font_name;
255 uint font_size;
256};
257
258/**
259 * struct scene_obj_menu - information about a menu object in a scene
260 *
261 * A menu has a number of items which can be selected by the user
262 *
263 * It also has:
264 *
265 * - a text/image object (@pointer_id) which points to the current item
266 * (@cur_item_id)
267 *
268 * - a preview object which shows an image related to the current item
269 *
270 * @obj: Basic object information
271 * @title_id: ID of the title text, or 0 if none
272 * @cur_item_id: ID of the current menu item, or 0 if none
273 * @pointer_id: ID of the object pointing to the current selection
274 * @item_head: List of items in the menu
275 */
276struct scene_obj_menu {
277 struct scene_obj obj;
278 uint title_id;
279 uint cur_item_id;
280 uint pointer_id;
281 struct list_head item_head;
282};
283
284/**
285 * enum scene_menuitem_flags_t - flags for menu items
286 *
287 * @SCENEMIF_GAP_BEFORE: Add a gap before this item
288 */
289enum scene_menuitem_flags_t {
290 SCENEMIF_GAP_BEFORE = 1 << 0,
291};
292
293/**
294 * struct scene_menitem - a menu item in a menu
295 *
296 * A menu item has:
297 *
298 * - text object holding the name (short) and description (can be longer)
299 * - a text object holding the keypress
300 *
301 * @name: Name of the item (this is allocated by this call)
302 * @id: ID number of the object
303 * @key_id: ID of text object to use as the keypress to show
304 * @label_id: ID of text object to use as the label text
305 * @desc_id: ID of text object to use as the description text
306 * @preview_id: ID of the preview object, or 0 if none
307 * @flags: Flags for this item
308 * @sibling: Node to link this item to its siblings
309 */
310struct scene_menitem {
311 char *name;
312 uint id;
313 uint key_id;
314 uint label_id;
315 uint desc_id;
316 uint preview_id;
317 uint flags;
318 struct list_head sibling;
319};
320
321/**
322 * expo_new() - create a new expo
323 *
324 * Allocates a new expo
325 *
326 * @name: Name of expo (this is allocated by this call)
327 * @priv: Private data for the controller
328 * @expp: Returns a pointer to the new expo on success
329 * Returns: 0 if OK, -ENOMEM if out of memory
330 */
331int expo_new(const char *name, void *priv, struct expo **expp);
332
333/**
334 * expo_destroy() - Destroy an expo and free all its memory
335 *
336 * @exp: Expo to destroy
337 */
338void expo_destroy(struct expo *exp);
339
340/**
Simon Glass6e9e4152023-06-01 10:22:47 -0600341 * expo_set_dynamic_start() - Set the start of the 'dynamic' IDs
342 *
343 * It is common for a set of 'static' IDs to be used to refer to objects in the
344 * expo. These typically use an enum so that they are defined in sequential
345 * order.
346 *
347 * Dynamic IDs (for objects not in the enum) are intended to be used for
348 * objects to which the code does not need to refer. These are ideally located
349 * above the static IDs.
350 *
351 * Use this function to set the start of the dynamic range, making sure that the
352 * value is higher than all the statically allocated IDs.
353 *
354 * @exp: Expo to update
355 * @dyn_start: Start ID that expo should use for dynamic allocation
356 */
357void expo_set_dynamic_start(struct expo *exp, uint dyn_start);
358
359/**
Simon Glassd8adbe92023-01-06 08:52:36 -0600360 * expo_str() - add a new string to an expo
361 *
362 * @exp: Expo to update
363 * @name: Name to use (this is allocated by this call)
364 * @id: ID to use for the new object (0 to allocate one)
365 * @str: Pointer to text to display (allocated by caller)
366 * Returns: ID number for the object (typically @id), or -ve on error
367 */
368int expo_str(struct expo *exp, const char *name, uint id, const char *str);
369
370/**
371 * expo_get_str() - Get a string by ID
372 *
373 * @exp: Expo to use
374 * @id: String ID to look up
375 * @returns string, or NULL if not found
376 */
377const char *expo_get_str(struct expo *exp, uint id);
378
379/**
380 * expo_set_display() - set the display to use for a expo
381 *
382 * @exp: Expo to update
383 * @dev: Display to use (`UCLASS_VIDEO`), NULL to use text mode
384 * Returns: 0 (always)
385 */
386int expo_set_display(struct expo *exp, struct udevice *dev);
387
388/**
Simon Glass7a960052023-06-01 10:22:52 -0600389 * expo_calc_dims() - Calculate the dimensions of the objects
390 *
391 * Updates the width and height of all objects based on their contents
392 *
393 * @exp: Expo to update
394 * Returns 0 if OK, -ENOTSUPP if there is no graphical console
395 */
396int expo_calc_dims(struct expo *exp);
397
398/**
Simon Glassd8adbe92023-01-06 08:52:36 -0600399 * expo_set_scene_id() - Set the current scene ID
400 *
401 * @exp: Expo to update
402 * @scene_id: New scene ID to use (0 to select no scene)
403 * Returns: 0 if OK, -ENOENT if there is no scene with that ID
404 */
405int expo_set_scene_id(struct expo *exp, uint scene_id);
406
407/**
Simon Glassc8925112023-06-01 10:23:02 -0600408 * expo_first_scene_id() - Get the ID of the first scene
409 *
410 * @exp: Expo to check
411 * Returns: Scene ID of first scene, or -ENOENT if there are no scenes
412 */
413int expo_first_scene_id(struct expo *exp);
414
415/**
Simon Glassd8adbe92023-01-06 08:52:36 -0600416 * expo_render() - render the expo on the display / console
417 *
418 * @exp: Expo to render
419 *
420 * Returns: 0 if OK, -ECHILD if there is no current scene, -ENOENT if the
421 * current scene is not found, other error if something else goes wrong
422 */
423int expo_render(struct expo *exp);
424
425/**
Simon Glassb2c40342023-06-01 10:22:37 -0600426 * expo_set_text_mode() - Controls whether the expo renders in text mode
Simon Glassd8adbe92023-01-06 08:52:36 -0600427 *
428 * @exp: Expo to update
429 * @text_mode: true to use text mode, false to use the console
430 */
Simon Glassb2c40342023-06-01 10:22:37 -0600431void expo_set_text_mode(struct expo *exp, bool text_mode);
Simon Glassd8adbe92023-01-06 08:52:36 -0600432
433/**
434 * scene_new() - create a new scene in a expo
435 *
436 * The scene is given the ID @id which must be unique across all scenes, objects
437 * and items. The expo's @next_id is updated to at least @id + 1
438 *
439 * @exp: Expo to update
440 * @name: Name to use (this is allocated by this call)
441 * @id: ID to use for the new scene (0 to allocate one)
442 * @scnp: Returns a pointer to the new scene on success
443 * Returns: ID number for the scene (typically @id), or -ve on error
444 */
445int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp);
446
447/**
448 * expo_lookup_scene_id() - Look up a scene by ID
449 *
450 * @exp: Expo to check
451 * @scene_id: Scene ID to look up
452 * @returns pointer to scene if found, else NULL
453 */
454struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id);
455
456/**
Simon Glass01922ec2023-06-01 10:22:57 -0600457 * scene_highlight_first() - Highlight the first item in a scene
458 *
459 * This highlights the first item, so that the user can see that it is pointed
460 * to
461 *
462 * @scn: Scene to update
463 */
464void scene_highlight_first(struct scene *scn);
465
466/**
467 * scene_set_highlight_id() - Set the object which is highlighted
468 *
469 * Sets a new object to highlight in the scene
470 *
471 * @scn: Scene to update
472 * @id: ID of object to highlight
473 */
474void scene_set_highlight_id(struct scene *scn, uint id);
475
476/**
477 * scene_set_open() - Set whether an item is open or not
478 *
479 * @scn: Scene to update
480 * @id: ID of object to update
481 * @open: true to open the object, false to close it
482 * Returns: 0 if OK, -ENOENT if @id is invalid
483 */
484int scene_set_open(struct scene *scn, uint id, bool open);
485
486/**
Simon Glassd8adbe92023-01-06 08:52:36 -0600487 * scene_title_set() - set the scene title
488 *
489 * @scn: Scene to update
Simon Glassea274b62023-06-01 10:22:27 -0600490 * @title_id: Title ID to set
491 * Returns: 0 if OK
Simon Glassd8adbe92023-01-06 08:52:36 -0600492 */
Simon Glassea274b62023-06-01 10:22:27 -0600493int scene_title_set(struct scene *scn, uint title_id);
Simon Glassd8adbe92023-01-06 08:52:36 -0600494
495/**
496 * scene_obj_count() - Count the number of objects in a scene
497 *
498 * @scn: Scene to check
499 * Returns: number of objects in the scene, 0 if none
500 */
501int scene_obj_count(struct scene *scn);
502
503/**
504 * scene_img() - add a new image to a scene
505 *
506 * @scn: Scene to update
507 * @name: Name to use (this is allocated by this call)
508 * @id: ID to use for the new object (0 to allocate one)
509 * @data: Pointer to image data
510 * @imgp: If non-NULL, returns the new object
511 * Returns: ID number for the object (typically @id), or -ve on error
512 */
513int scene_img(struct scene *scn, const char *name, uint id, char *data,
514 struct scene_obj_img **imgp);
515
516/**
517 * scene_txt() - add a new text object to a scene
518 *
519 * @scn: Scene to update
520 * @name: Name to use (this is allocated by this call)
521 * @id: ID to use for the new object (0 to allocate one)
522 * @str_id: ID of the string to use
523 * @txtp: If non-NULL, returns the new object
524 * Returns: ID number for the object (typically @id), or -ve on error
525 */
526int scene_txt(struct scene *scn, const char *name, uint id, uint str_id,
527 struct scene_obj_txt **txtp);
528
529/**
Simon Glassdb6a0512023-10-01 19:13:23 -0600530 * scene_txt_str() - add a new string to expo and text object to a scene
Simon Glassd8adbe92023-01-06 08:52:36 -0600531 *
532 * @scn: Scene to update
533 * @name: Name to use (this is allocated by this call)
534 * @id: ID to use for the new object (0 to allocate one)
535 * @str_id: ID of the string to use
536 * @str: Pointer to text to display (allocated by caller)
537 * @txtp: If non-NULL, returns the new object
538 * Returns: ID number for the object (typically @id), or -ve on error
539 */
540int scene_txt_str(struct scene *scn, const char *name, uint id, uint str_id,
541 const char *str, struct scene_obj_txt **txtp);
542
543/**
544 * scene_menu() - create a menu
545 *
546 * @scn: Scene to update
547 * @name: Name to use (this is allocated by this call)
548 * @id: ID to use for the new object (0 to allocate one)
549 * @menup: If non-NULL, returns the new object
550 * Returns: ID number for the object (typically @id), or -ve on error
551 */
552int scene_menu(struct scene *scn, const char *name, uint id,
553 struct scene_obj_menu **menup);
554
555/**
556 * scene_txt_set_font() - Set the font for an object
557 *
558 * @scn: Scene to update
559 * @id: ID of object to update
560 * @font_name: Font name to use (allocated by caller)
561 * @font_size: Font size to use (nominal height in pixels)
562 */
563int scene_txt_set_font(struct scene *scn, uint id, const char *font_name,
564 uint font_size);
565
566/**
567 * scene_obj_set_pos() - Set the postion of an object
568 *
569 * @scn: Scene to update
570 * @id: ID of object to update
571 * @x: x position, in pixels from left side
572 * @y: y position, in pixels from top
573 * Returns: 0 if OK, -ENOENT if @id is invalid
574 */
575int scene_obj_set_pos(struct scene *scn, uint id, int x, int y);
576
577/**
Simon Glass7a960052023-06-01 10:22:52 -0600578 * scene_obj_set_size() - Set the size of an object
579 *
580 * @scn: Scene to update
581 * @id: ID of object to update
582 * @w: width in pixels
583 * @h: height in pixels
584 * Returns: 0 if OK, -ENOENT if @id is invalid
585 */
586int scene_obj_set_size(struct scene *scn, uint id, int w, int h);
587
588/**
Simon Glassd8adbe92023-01-06 08:52:36 -0600589 * scene_obj_set_hide() - Set whether an object is hidden
590 *
591 * The update happens when the expo is next rendered.
592 *
593 * @scn: Scene to update
594 * @id: ID of object to update
595 * @hide: true to hide the object, false to show it
596 * Returns: 0 if OK, -ENOENT if @id is invalid
597 */
598int scene_obj_set_hide(struct scene *scn, uint id, bool hide);
599
600/**
601 * scene_menu_set_title() - Set the title of a menu
602 *
603 * @scn: Scene to update
604 * @id: ID of menu object to update
605 * @title_id: ID of text object to use as the title
606 * Returns: 0 if OK, -ENOENT if @id is invalid, -EINVAL if @title_id is invalid
607 */
608int scene_menu_set_title(struct scene *scn, uint id, uint title_id);
609
610/**
611 * scene_menu_set_pointer() - Set the item pointer for a menu
612 *
613 * This is a visual indicator of the current item, typically a ">" character
614 * which sits next to the current item and moves when the user presses the
615 * up/down arrow keys
616 *
617 * @scn: Scene to update
618 * @id: ID of menu object to update
619 * @cur_item_id: ID of text or image object to use as a pointer to the current
620 * item
621 * Returns: 0 if OK, -ENOENT if @id is invalid, -EINVAL if @cur_item_id is invalid
622 */
623int scene_menu_set_pointer(struct scene *scn, uint id, uint cur_item_id);
624
625/**
626 * scene_obj_get_hw() - Get width and height of an object in a scene
627 *
628 * @scn: Scene to check
629 * @id: ID of menu object to check
630 * @widthp: If non-NULL, returns width of object in pixels
631 * Returns: Height of object in pixels
632 */
633int scene_obj_get_hw(struct scene *scn, uint id, int *widthp);
634
635/**
636 * scene_menuitem() - Add an item to a menu
637 *
638 * @scn: Scene to update
639 * @menu_id: ID of menu object to update
640 * @name: Name to use (this is allocated by this call)
641 * @id: ID to use for the new object (0 to allocate one)
642 * @key_id: ID of text object to use as the keypress to show
643 * @label_id: ID of text object to use as the label text
644 * @desc_id: ID of text object to use as the description text
645 * @preview_id: ID of object to use as the preview (text or image)
646 * @flags: Flags for this item (enum scene_menuitem_flags_t)
647 * @itemp: If non-NULL, returns the new object
648 * Returns: ID number for the item (typically @id), or -ve on error
649 */
650int scene_menuitem(struct scene *scn, uint menu_id, const char *name, uint id,
651 uint key_id, uint label_id, uint desc_id, uint preview_id,
652 uint flags, struct scene_menitem **itemp);
653
654/**
655 * scene_arrange() - Arrange the scene to deal with object sizes
656 *
657 * Updates any menus in the scene so that their objects are in the right place.
658 *
659 * @scn: Scene to arrange
660 * Returns: 0 if OK, -ve on error
661 */
662int scene_arrange(struct scene *scn);
663
664/**
665 * expo_send_key() - set a keypress to the expo
666 *
667 * @exp: Expo to receive the key
668 * @key: Key to send (ASCII or enum bootmenu_key)
669 * Returns: 0 if OK, -ECHILD if there is no current scene
670 */
671int expo_send_key(struct expo *exp, int key);
672
673/**
674 * expo_action_get() - read user input from the expo
675 *
676 * @exp: Expo to check
677 * @act: Returns action
678 * Returns: 0 if OK, -EAGAIN if there was no action to return
679 */
680int expo_action_get(struct expo *exp, struct expo_action *act);
681
Simon Glassc999e172023-06-01 10:22:53 -0600682/**
683 * expo_apply_theme() - Apply a theme to an expo
684 *
685 * @exp: Expo to update
686 * @node: Node containing the theme
687 */
688int expo_apply_theme(struct expo *exp, ofnode node);
689
Simon Glass61300722023-06-01 10:23:01 -0600690/**
691 * expo_build() - Build an expo from an FDT description
692 *
693 * Build a complete expo from a description in the provided devicetree.
694 *
Massimo Pegorerc8c70022023-09-09 12:32:28 +0200695 * See doc/develop/expo.rst for a description of the format
Simon Glass61300722023-06-01 10:23:01 -0600696 *
697 * @root: Root node for expo description
698 * @expp: Returns the new expo
699 * Returns: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is a format
700 * error, -ENOENT if there is a references to a non-existent string
701 */
702int expo_build(ofnode root, struct expo **expp);
703
Simon Glass8df4a4e2023-08-14 16:40:25 -0600704#endif /*__EXPO_H */