blob: 24a2ba6a6a3df0da2d2d3cf81204a452b2564634 [file] [log] [blame]
Simon Glass5e2607a2023-01-06 08:52:37 -06001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Internal header file for scenes
4 *
5 * Copyright 2022 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 */
8
9#ifndef __SCENE_INTERNAL_H
10#define __SCENE_INTERNAL_H
11
12/**
13 * expo_lookup_scene_id() - Look up a scene ID
14 *
15 * @exp: Expo to use
16 * @id: scene ID to look up
17 * Returns: Scene for that ID, or NULL if none
18 */
19struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id);
20
21/**
22 * resolve_id() - Automatically allocate an ID if needed
23 *
24 * @exp: Expo to use
25 * @id: ID to use, or 0 to auto-allocate one
Simon Glassd2043b52023-06-01 10:22:26 -060026 * Returns: Either @id, or the auto-allocated ID
Simon Glass5e2607a2023-01-06 08:52:37 -060027 */
28uint resolve_id(struct expo *exp, uint id);
29
30/**
31 * scene_obj_find() - Find an object in a scene
32 *
33 * Note that @type is used to restrict the search when the object type is known.
34 * If any type is acceptable, set @type to SCENEOBJT_NONE
35 *
36 * @scn: Scene to search
37 * @id: ID of object to find
38 * @type: Type of the object, or SCENEOBJT_NONE to match any type
Simon Glassd2043b52023-06-01 10:22:26 -060039 * Returns: Object found, or NULL if not found
Simon Glass5e2607a2023-01-06 08:52:37 -060040 */
41void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type);
42
43/**
44 * scene_obj_add() - Add a new object to a scene
45 *
46 * @scn: Scene to update
47 * @name: Name to use (this is allocated by this call)
48 * @id: ID to use for the new object (0 to allocate one)
49 * @type: Type of object to add
50 * @size: Size to allocate for the object, in bytes
51 * @objp: Returns a pointer to the new object (must not be NULL)
52 * Returns: ID number for the object (generally @id), or -ve on error
53 */
54int scene_obj_add(struct scene *scn, const char *name, uint id,
55 enum scene_obj_t type, uint size, struct scene_obj **objp);
56
57/**
Simon Glassce72c9e2023-06-01 10:22:50 -060058 * scene_obj_flag_clrset() - Adjust object flags
59 *
60 * @scn: Scene to update
61 * @id: ID of object to update
62 * @clr: Bits to clear in the object's flags
63 * @set: Bits to set in the object's flags
64 * Returns 0 if OK, -ENOENT if the object was not found
65 */
66int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set);
67
68/**
Simon Glass5e2607a2023-01-06 08:52:37 -060069 * scene_menu_arrange() - Set the position of things in the menu
70 *
71 * This updates any items associated with a menu to make sure they are
72 * positioned correctly relative to the menu. It also selects the first item
73 * if not already done
74 *
75 * @scn: Scene to update
76 * @menu: Menu to process
Simon Glassd2043b52023-06-01 10:22:26 -060077 * Returns: 0 if OK, -ve on error
Simon Glass5e2607a2023-01-06 08:52:37 -060078 */
79int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
80
81/**
82 * scene_menu_send_key() - Send a key to a menu for processing
83 *
84 * @scn: Scene to use
85 * @menu: Menu to use
86 * @key: Key code to send (KEY_...)
87 * @event: Place to put any event which is generated by the key
Simon Glassd2043b52023-06-01 10:22:26 -060088 * Returns: 0 if OK, -ENOTTY if there is no current menu item, other -ve on other
Simon Glass5e2607a2023-01-06 08:52:37 -060089 * error
90 */
91int scene_menu_send_key(struct scene *scn, struct scene_obj_menu *menu, int key,
92 struct expo_action *event);
93
94/**
95 * scene_menu_destroy() - Destroy a menu in a scene
96 *
97 * @scn: Scene to destroy
98 */
99void scene_menu_destroy(struct scene_obj_menu *menu);
100
101/**
102 * scene_menu_display() - Display a menu as text
103 *
104 * @menu: Menu to display
Simon Glassd2043b52023-06-01 10:22:26 -0600105 * Returns: 0 if OK, -ENOENT if @id is invalid
Simon Glass5e2607a2023-01-06 08:52:37 -0600106 */
107int scene_menu_display(struct scene_obj_menu *menu);
108
109/**
110 * scene_destroy() - Destroy a scene and all its memory
111 *
112 * @scn: Scene to destroy
113 */
114void scene_destroy(struct scene *scn);
115
116/**
117 * scene_render() - Render a scene
118 *
119 * This is called from expo_render()
120 *
121 * @scn: Scene to render
122 * Returns: 0 if OK, -ve on error
123 */
124int scene_render(struct scene *scn);
125
126/**
127 * scene_send_key() - set a keypress to a scene
128 *
129 * @scn: Scene to receive the key
130 * @key: Key to send (KEYCODE_UP)
131 * @event: Returns resulting event from this keypress
132 * Returns: 0 if OK, -ve on error
133 */
134int scene_send_key(struct scene *scn, int key, struct expo_action *event);
135
136#endif /* __SCENE_INTERNAL_H */