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