blob: a31b42452477aeca6735f5c8e51d93a0af48eb8c [file] [log] [blame]
Simon Glass040b0462023-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 Rini03de3052024-05-20 13:35:03 -060010#include <stdbool.h>
Simon Glass472317c2023-08-14 16:40:34 -060011#include <dm/ofnode_decl.h>
Tom Rini03de3052024-05-20 13:35:03 -060012#include <linux/types.h>
Simon Glass472317c2023-08-14 16:40:34 -060013
Simon Glass2dee81f2023-08-14 16:40:33 -060014struct abuf;
Simon Glass040b0462023-08-14 16:40:25 -060015struct expo;
Simon Glass8d0f8902023-08-14 16:40:27 -060016struct scene;
Simon Glass040b0462023-08-14 16:40:25 -060017struct video_priv;
Tom Rini03de3052024-05-20 13:35:03 -060018struct udevice;
Simon Glass040b0462023-08-14 16:40:25 -060019
Simon Glass2dee81f2023-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 Glass040b0462023-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 Glass8d0f8902023-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 Glass2dee81f2023-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 Glass472317c2023-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 Glassfc9c0e02023-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 Glassbcf2b722023-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 Glasseb6c71b2023-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 Glasscfc402d2023-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 Glass040b0462023-08-14 16:40:25 -0600128#endif /* __CEDIT_H */