blob: a31b42452477aeca6735f5c8e51d93a0af48eb8c [file] [log] [blame]
Simon Glass8df4a4e2023-08-14 16:40:25 -06001/* 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 Rinidec7ea02024-05-20 13:35:03 -060010#include <stdbool.h>
Simon Glassb1cd32b2023-08-14 16:40:34 -060011#include <dm/ofnode_decl.h>
Tom Rinidec7ea02024-05-20 13:35:03 -060012#include <linux/types.h>
Simon Glassb1cd32b2023-08-14 16:40:34 -060013
Simon Glass28bf4352023-08-14 16:40:33 -060014struct abuf;
Simon Glass8df4a4e2023-08-14 16:40:25 -060015struct expo;
Simon Glass6a5af5f2023-08-14 16:40:27 -060016struct scene;
Simon Glass8df4a4e2023-08-14 16:40:25 -060017struct video_priv;
Tom Rinidec7ea02024-05-20 13:35:03 -060018struct udevice;
Simon Glass8df4a4e2023-08-14 16:40:25 -060019
Simon Glass28bf4352023-08-14 16:40:33 -060020enum {
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
28extern struct expo *cur_exp;
29
Simon Glass8df4a4e2023-08-14 16:40:25 -060030/**
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 */
38int 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 */
48int cedit_run(struct expo *exp);
49
Simon Glass6a5af5f2023-08-14 16:40:27 -060050/**
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 */
61int cedit_prepare(struct expo *exp, struct video_priv **vid_privp,
62 struct scene **scnp);
63
Simon Glass28bf4352023-08-14 16:40:33 -060064/**
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 */
73int cedit_write_settings(struct expo *exp, struct abuf *buf);
74
Simon Glassb1cd32b2023-08-14 16:40:34 -060075/**
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 */
84int cedit_read_settings(struct expo *exp, oftree tree);
85
Simon Glass237f3752023-08-14 16:40:35 -060086/**
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 */
93int cedit_write_settings_env(struct expo *exp, bool verbose);
94
Simon Glass0f2e5a62023-08-14 16:40:36 -060095/*
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 */
101int cedit_read_settings_env(struct expo *exp, bool verbose);
102
Simon Glass2b91ca62023-08-14 16:40:37 -0600103/**
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 */
113int cedit_write_settings_cmos(struct expo *exp, struct udevice *dev,
114 bool verbose);
115
Simon Glass4462fa32023-08-14 16:40:38 -0600116/**
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 */
125int cedit_read_settings_cmos(struct expo *exp, struct udevice *dev,
126 bool verbose);
127
Simon Glass8df4a4e2023-08-14 16:40:25 -0600128#endif /* __CEDIT_H */