Simon Glass | 8df4a4e | 2023-08-14 16:40:25 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright 2023 Google LLC |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
| 5 | */ |
| 6 | |
| 7 | #ifndef __CEDIT_H |
| 8 | #define __CEDIT_H |
| 9 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 10 | #include <stdbool.h> |
Simon Glass | b1cd32b | 2023-08-14 16:40:34 -0600 | [diff] [blame] | 11 | #include <dm/ofnode_decl.h> |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 12 | #include <linux/types.h> |
Simon Glass | b1cd32b | 2023-08-14 16:40:34 -0600 | [diff] [blame] | 13 | |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 14 | struct abuf; |
Simon Glass | 8df4a4e | 2023-08-14 16:40:25 -0600 | [diff] [blame] | 15 | struct expo; |
Simon Glass | 14bd413 | 2025-05-02 08:46:21 -0600 | [diff] [blame] | 16 | struct expo_action; |
Simon Glass | 6a5af5f | 2023-08-14 16:40:27 -0600 | [diff] [blame] | 17 | struct scene; |
Simon Glass | 04f021f | 2024-10-14 16:32:03 -0600 | [diff] [blame] | 18 | struct udevice; |
Simon Glass | 8df4a4e | 2023-08-14 16:40:25 -0600 | [diff] [blame] | 19 | struct video_priv; |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 20 | struct udevice; |
Simon Glass | 8df4a4e | 2023-08-14 16:40:25 -0600 | [diff] [blame] | 21 | |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 22 | enum { |
| 23 | /* size increment for writing FDT */ |
| 24 | CEDIT_SIZE_INC = 1024, |
| 25 | }; |
| 26 | |
| 27 | /* Name of the cedit node in the devicetree */ |
| 28 | #define CEDIT_NODE_NAME "cedit-values" |
| 29 | |
| 30 | extern struct expo *cur_exp; |
| 31 | |
Simon Glass | 8df4a4e | 2023-08-14 16:40:25 -0600 | [diff] [blame] | 32 | /** |
| 33 | * cedit_arange() - Arrange objects in a configuration-editor scene |
| 34 | * |
| 35 | * @exp: Expo to update |
| 36 | * @vid_priv: Private info of the video device |
| 37 | * @scene_id: scene ID to arrange |
| 38 | * Returns: 0 if OK, -ve on error |
| 39 | */ |
| 40 | int cedit_arange(struct expo *exp, struct video_priv *vid_priv, uint scene_id); |
| 41 | |
| 42 | /** |
| 43 | * cedit_run() - Run a configuration editor |
| 44 | * |
| 45 | * This accepts input until the user quits with Escape |
| 46 | * |
| 47 | * @exp: Expo to use |
| 48 | * Returns: 0 if OK, -ve on error |
| 49 | */ |
| 50 | int cedit_run(struct expo *exp); |
| 51 | |
Simon Glass | 6a5af5f | 2023-08-14 16:40:27 -0600 | [diff] [blame] | 52 | /** |
| 53 | * cedit_prepare() - Prepare to run a cedit |
| 54 | * |
| 55 | * Set up the video device, select the first scene and highlight the first item. |
| 56 | * This ensures that all menus have a selected item. |
| 57 | * |
| 58 | * @exp: Expo to use |
Simon Glass | 736bc0d | 2025-05-02 08:46:22 -0600 | [diff] [blame] | 59 | * @dev: Video device to use |
Simon Glass | 6a5af5f | 2023-08-14 16:40:27 -0600 | [diff] [blame] | 60 | * @scnp: Set to the first scene |
| 61 | * Return: scene ID of first scene if OK, -ve on error |
| 62 | */ |
Simon Glass | 736bc0d | 2025-05-02 08:46:22 -0600 | [diff] [blame] | 63 | int cedit_prepare(struct expo *exp, struct udevice *vid_dev, |
Simon Glass | 6a5af5f | 2023-08-14 16:40:27 -0600 | [diff] [blame] | 64 | struct scene **scnp); |
| 65 | |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 66 | /** |
Simon Glass | 14bd413 | 2025-05-02 08:46:21 -0600 | [diff] [blame] | 67 | * cedit_do_action() - Process an action on a cedit |
| 68 | * |
| 69 | * @exp: Expo to use |
| 70 | * @scn: Current scene |
| 71 | * @vid_priv: Private data for the video device |
| 72 | * @act: Action to process |
| 73 | * Return: 0 on success, -EAGAIN if there was no action taken |
| 74 | */ |
| 75 | int cedit_do_action(struct expo *exp, struct scene *scn, |
| 76 | struct video_priv *vid_priv, struct expo_action *act); |
| 77 | |
| 78 | /** |
Simon Glass | 28bf435 | 2023-08-14 16:40:33 -0600 | [diff] [blame] | 79 | * cedit_write_settings() - Write settings in FDT format |
| 80 | * |
| 81 | * Sets up an FDT with the settings |
| 82 | * |
| 83 | * @exp: Expo to write settings from |
| 84 | * @buf: Returns abuf containing the settings FDT (inited by this function) |
| 85 | * Return: 0 if OK, -ve on error |
| 86 | */ |
| 87 | int cedit_write_settings(struct expo *exp, struct abuf *buf); |
| 88 | |
Simon Glass | b1cd32b | 2023-08-14 16:40:34 -0600 | [diff] [blame] | 89 | /** |
| 90 | * cedit_read_settings() - Read settings in FDT format |
| 91 | * |
| 92 | * Read an FDT with the settings |
| 93 | * |
| 94 | * @exp: Expo to read settings into |
| 95 | * @tree: Tree to read from |
| 96 | * Return: 0 if OK, -ve on error |
| 97 | */ |
| 98 | int cedit_read_settings(struct expo *exp, oftree tree); |
| 99 | |
Simon Glass | 237f375 | 2023-08-14 16:40:35 -0600 | [diff] [blame] | 100 | /** |
| 101 | * cedit_write_settings_env() - Write settings to envrionment variables |
| 102 | * |
| 103 | * @exp: Expo to write settings from |
| 104 | * @verbose: true to print each var as it is set |
| 105 | * Return: 0 if OK, -ve on error |
| 106 | */ |
| 107 | int cedit_write_settings_env(struct expo *exp, bool verbose); |
| 108 | |
Simon Glass | 0f2e5a6 | 2023-08-14 16:40:36 -0600 | [diff] [blame] | 109 | /* |
| 110 | * cedit_read_settings_env() - Read settings from the environment |
| 111 | * |
| 112 | * @exp: Expo to read settings into |
| 113 | * @verbose: true to print each var before it is read |
| 114 | */ |
| 115 | int cedit_read_settings_env(struct expo *exp, bool verbose); |
| 116 | |
Simon Glass | 2b91ca6 | 2023-08-14 16:40:37 -0600 | [diff] [blame] | 117 | /** |
| 118 | * cedit_write_settings_cmos() - Write settings to CMOS RAM |
| 119 | * |
| 120 | * Write settings to the defined places in CMOS RAM |
| 121 | * |
| 122 | * @exp: Expo to write settings from |
| 123 | * @dev: UCLASS_RTC device containing space for this information |
| 124 | * Returns 0 if OK, -ve on error |
| 125 | * @verbose: true to print a summary at the end |
| 126 | */ |
| 127 | int cedit_write_settings_cmos(struct expo *exp, struct udevice *dev, |
| 128 | bool verbose); |
| 129 | |
Simon Glass | 4462fa3 | 2023-08-14 16:40:38 -0600 | [diff] [blame] | 130 | /** |
| 131 | * cedit_read_settings_cmos() - Read settings from CMOS RAM |
| 132 | * |
| 133 | * Read settings from the defined places in CMO RAM |
| 134 | * |
| 135 | * @exp: Expo to read settings into |
| 136 | * @dev: RTC device to read settings from |
| 137 | * @verbose: true to print a summary at the end |
| 138 | */ |
| 139 | int cedit_read_settings_cmos(struct expo *exp, struct udevice *dev, |
| 140 | bool verbose); |
| 141 | |
Simon Glass | 8df4a4e | 2023-08-14 16:40:25 -0600 | [diff] [blame] | 142 | #endif /* __CEDIT_H */ |