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