aboutsummaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-08-14 16:40:34 -0600
committerTom Rini <trini@konsulko.com>2023-08-25 13:54:33 -0400
commit472317cb12e534f56b631365987934960dfb0a3f (patch)
tree3ac102f38603af6ee02075c0743bb08f824119dd /boot
parent2dee81fe5f4a6427ba48fe17ff017930ddf3b4e4 (diff)
downloadu-boot-472317cb12e534f56b631365987934960dfb0a3f.zip
u-boot-472317cb12e534f56b631365987934960dfb0a3f.tar.gz
u-boot-472317cb12e534f56b631365987934960dfb0a3f.tar.bz2
expo: cedit: Support reading settings from a file
Add a command to read cedit settings from a devicetree file. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot')
-rw-r--r--boot/cedit.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/boot/cedit.c b/boot/cedit.c
index 4dd79a2..6a74a38 100644
--- a/boot/cedit.c
+++ b/boot/cedit.c
@@ -23,9 +23,11 @@
* struct cedit_iter_priv - private data for cedit operations
*
* @buf: Buffer to use when writing settings to the devicetree
+ * @node: Node to read from when reading settings from devicetree
*/
struct cedit_iter_priv {
struct abuf *buf;
+ ofnode node;
};
int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
@@ -318,3 +320,53 @@ int cedit_write_settings(struct expo *exp, struct abuf *buf)
return 0;
}
+
+static int h_read_settings(struct scene_obj *obj, void *vpriv)
+{
+ struct cedit_iter_priv *priv = vpriv;
+ ofnode node = priv->node;
+
+ switch (obj->type) {
+ case SCENEOBJT_NONE:
+ case SCENEOBJT_IMAGE:
+ case SCENEOBJT_TEXT:
+ break;
+ case SCENEOBJT_MENU: {
+ struct scene_obj_menu *menu;
+ uint val;
+
+ if (ofnode_read_u32(node, obj->name, &val))
+ return log_msg_ret("rd", -ENOENT);
+ menu = (struct scene_obj_menu *)obj;
+ menu->cur_item_id = val;
+
+ break;
+ }
+ }
+
+ return 0;
+}
+
+int cedit_read_settings(struct expo *exp, oftree tree)
+{
+ struct cedit_iter_priv priv;
+ ofnode root, node;
+ int ret;
+
+ root = oftree_root(tree);
+ if (!ofnode_valid(root))
+ return log_msg_ret("roo", -ENOENT);
+ node = ofnode_find_subnode(root, CEDIT_NODE_NAME);
+ if (!ofnode_valid(node))
+ return log_msg_ret("pat", -ENOENT);
+
+ /* read in the items */
+ priv.node = node;
+ ret = expo_iter_scene_objs(exp, h_read_settings, &priv);
+ if (ret) {
+ log_debug("Failed to read settings (err=%d)\n", ret);
+ return log_msg_ret("set", ret);
+ }
+
+ return 0;
+}