aboutsummaryrefslogtreecommitdiff
path: root/include/cedit.h
blob: a31b42452477aeca6735f5c8e51d93a0af48eb8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright 2023 Google LLC
 * Written by Simon Glass <sjg@chromium.org>
 */

#ifndef __CEDIT_H
#define __CEDIT_H

#include <stdbool.h>
#include <dm/ofnode_decl.h>
#include <linux/types.h>

struct abuf;
struct expo;
struct scene;
struct video_priv;
struct udevice;

enum {
	/* size increment for writing FDT */
	CEDIT_SIZE_INC	= 1024,
};

/* Name of the cedit node in the devicetree */
#define CEDIT_NODE_NAME		"cedit-values"

extern struct expo *cur_exp;

/**
 * cedit_arange() - Arrange objects in a configuration-editor scene
 *
 * @exp: Expo to update
 * @vid_priv: Private info of the video device
 * @scene_id: scene ID to arrange
 * Returns: 0 if OK, -ve on error
 */
int cedit_arange(struct expo *exp, struct video_priv *vid_priv, uint scene_id);

/**
 * cedit_run() - Run a configuration editor
 *
 * This accepts input until the user quits with Escape
 *
 * @exp: Expo to use
 * Returns: 0 if OK, -ve on error
 */
int cedit_run(struct expo *exp);

/**
 * cedit_prepare() - Prepare to run a cedit
 *
 * Set up the video device, select the first scene and highlight the first item.
 * This ensures that all menus have a selected item.
 *
 * @exp: Expo to use
 * @vid_privp: Set to private data for the video device
 * @scnp: Set to the first scene
 * Return: scene ID of first scene if OK, -ve on error
 */
int cedit_prepare(struct expo *exp, struct video_priv **vid_privp,
		  struct scene **scnp);

/**
 * cedit_write_settings() - Write settings in FDT format
 *
 * Sets up an FDT with the settings
 *
 * @exp: Expo to write settings from
 * @buf: Returns abuf containing the settings FDT (inited by this function)
 * Return: 0 if OK, -ve on error
 */
int cedit_write_settings(struct expo *exp, struct abuf *buf);

/**
 * cedit_read_settings() - Read settings in FDT format
 *
 * Read an FDT with the settings
 *
 * @exp: Expo to read settings into
 * @tree: Tree to read from
 * Return: 0 if OK, -ve on error
 */
int cedit_read_settings(struct expo *exp, oftree tree);

/**
 * cedit_write_settings_env() - Write settings to envrionment variables
 *
 * @exp: Expo to write settings from
 * @verbose: true to print each var as it is set
 * Return: 0 if OK, -ve on error
 */
int cedit_write_settings_env(struct expo *exp, bool verbose);

/*
 * cedit_read_settings_env() - Read settings from the environment
 *
 * @exp: Expo to read settings into
 * @verbose: true to print each var before it is read
 */
int cedit_read_settings_env(struct expo *exp, bool verbose);

/**
 * cedit_write_settings_cmos() - Write settings to CMOS RAM
 *
 * Write settings to the defined places in CMOS RAM
 *
 * @exp: Expo to write settings from
 * @dev: UCLASS_RTC device containing space for this information
 * Returns 0 if OK, -ve on error
 * @verbose: true to print a summary at the end
 */
int cedit_write_settings_cmos(struct expo *exp, struct udevice *dev,
			      bool verbose);

/**
 * cedit_read_settings_cmos() - Read settings from CMOS RAM
 *
 * Read settings from the defined places in CMO RAM
 *
 * @exp: Expo to read settings into
 * @dev: RTC device to read settings from
 * @verbose: true to print a summary at the end
 */
int cedit_read_settings_cmos(struct expo *exp, struct udevice *dev,
			     bool verbose);

#endif /* __CEDIT_H */