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