blob: 319a61aecb803002570d9ce1354b68ad8c5f7ce0 [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 Glass14bd4132025-05-02 08:46:21 -060016struct expo_action;
Simon Glass6a5af5f2023-08-14 16:40:27 -060017struct scene;
Simon Glass04f021f2024-10-14 16:32:03 -060018struct udevice;
Simon Glass8df4a4e2023-08-14 16:40:25 -060019struct video_priv;
Tom Rinidec7ea02024-05-20 13:35:03 -060020struct udevice;
Simon Glass8df4a4e2023-08-14 16:40:25 -060021
Simon Glass28bf4352023-08-14 16:40:33 -060022enum {
23 /* size increment for writing FDT */
24 CEDIT_SIZE_INC = 1024,
25};
26
27/* Name of the cedit node in the devicetree */
28#define CEDIT_NODE_NAME "cedit-values"
29
30extern struct expo *cur_exp;
31
Simon Glass8df4a4e2023-08-14 16:40:25 -060032/**
33 * cedit_arange() - Arrange objects in a configuration-editor scene
34 *
35 * @exp: Expo to update
36 * @vid_priv: Private info of the video device
37 * @scene_id: scene ID to arrange
38 * Returns: 0 if OK, -ve on error
39 */
40int cedit_arange(struct expo *exp, struct video_priv *vid_priv, uint scene_id);
41
42/**
43 * cedit_run() - Run a configuration editor
44 *
45 * This accepts input until the user quits with Escape
46 *
47 * @exp: Expo to use
48 * Returns: 0 if OK, -ve on error
49 */
50int cedit_run(struct expo *exp);
51
Simon Glass6a5af5f2023-08-14 16:40:27 -060052/**
53 * cedit_prepare() - Prepare to run a cedit
54 *
55 * Set up the video device, select the first scene and highlight the first item.
56 * This ensures that all menus have a selected item.
57 *
58 * @exp: Expo to use
Simon Glass736bc0d2025-05-02 08:46:22 -060059 * @dev: Video device to use
Simon Glass6a5af5f2023-08-14 16:40:27 -060060 * @scnp: Set to the first scene
61 * Return: scene ID of first scene if OK, -ve on error
62 */
Simon Glass736bc0d2025-05-02 08:46:22 -060063int cedit_prepare(struct expo *exp, struct udevice *vid_dev,
Simon Glass6a5af5f2023-08-14 16:40:27 -060064 struct scene **scnp);
65
Simon Glass28bf4352023-08-14 16:40:33 -060066/**
Simon Glass14bd4132025-05-02 08:46:21 -060067 * cedit_do_action() - Process an action on a cedit
68 *
69 * @exp: Expo to use
70 * @scn: Current scene
71 * @vid_priv: Private data for the video device
72 * @act: Action to process
73 * Return: 0 on success, -EAGAIN if there was no action taken
74 */
75int cedit_do_action(struct expo *exp, struct scene *scn,
76 struct video_priv *vid_priv, struct expo_action *act);
77
78/**
Simon Glass28bf4352023-08-14 16:40:33 -060079 * cedit_write_settings() - Write settings in FDT format
80 *
81 * Sets up an FDT with the settings
82 *
83 * @exp: Expo to write settings from
84 * @buf: Returns abuf containing the settings FDT (inited by this function)
85 * Return: 0 if OK, -ve on error
86 */
87int cedit_write_settings(struct expo *exp, struct abuf *buf);
88
Simon Glassb1cd32b2023-08-14 16:40:34 -060089/**
90 * cedit_read_settings() - Read settings in FDT format
91 *
92 * Read an FDT with the settings
93 *
94 * @exp: Expo to read settings into
95 * @tree: Tree to read from
96 * Return: 0 if OK, -ve on error
97 */
98int cedit_read_settings(struct expo *exp, oftree tree);
99
Simon Glass237f3752023-08-14 16:40:35 -0600100/**
101 * cedit_write_settings_env() - Write settings to envrionment variables
102 *
103 * @exp: Expo to write settings from
104 * @verbose: true to print each var as it is set
105 * Return: 0 if OK, -ve on error
106 */
107int cedit_write_settings_env(struct expo *exp, bool verbose);
108
Simon Glass0f2e5a62023-08-14 16:40:36 -0600109/*
110 * cedit_read_settings_env() - Read settings from the environment
111 *
112 * @exp: Expo to read settings into
113 * @verbose: true to print each var before it is read
114 */
115int cedit_read_settings_env(struct expo *exp, bool verbose);
116
Simon Glass2b91ca62023-08-14 16:40:37 -0600117/**
118 * cedit_write_settings_cmos() - Write settings to CMOS RAM
119 *
120 * Write settings to the defined places in CMOS RAM
121 *
122 * @exp: Expo to write settings from
123 * @dev: UCLASS_RTC device containing space for this information
124 * Returns 0 if OK, -ve on error
125 * @verbose: true to print a summary at the end
126 */
127int cedit_write_settings_cmos(struct expo *exp, struct udevice *dev,
128 bool verbose);
129
Simon Glass4462fa32023-08-14 16:40:38 -0600130/**
131 * cedit_read_settings_cmos() - Read settings from CMOS RAM
132 *
133 * Read settings from the defined places in CMO RAM
134 *
135 * @exp: Expo to read settings into
136 * @dev: RTC device to read settings from
137 * @verbose: true to print a summary at the end
138 */
139int cedit_read_settings_cmos(struct expo *exp, struct udevice *dev,
140 bool verbose);
141
Simon Glass8df4a4e2023-08-14 16:40:25 -0600142#endif /* __CEDIT_H */