]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
expo: Pass in the video device for cedit_prepare()
authorSimon Glass <sjg@chromium.org>
Fri, 2 May 2025 14:46:22 +0000 (08:46 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 30 May 2025 08:49:32 +0000 (09:49 +0100)
At present this function locates it own video device. Pass it in to
provide more flexibility.

Signed-off-by: Simon Glass <sjg@chromium.org>
boot/cedit.c
include/cedit.h
test/boot/cedit.c

index f1a9ee7ce201a4c1c5a18b582ae3494024fcfb58..eac851b395a525e6db71a621178ff52da7d4f6d1 100644 (file)
@@ -100,19 +100,16 @@ int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
        return 0;
 }
 
-int cedit_prepare(struct expo *exp, struct video_priv **vid_privp,
+int cedit_prepare(struct expo *exp, struct udevice *vid_dev,
                  struct scene **scnp)
 {
+       struct udevice *dev = vid_dev;
        struct video_priv *vid_priv;
-       struct udevice *dev;
        struct scene *scn;
        uint scene_id;
        int ret;
 
        /* For now we only support a video console */
-       ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
-       if (ret)
-               return log_msg_ret("vid", ret);
        ret = expo_set_display(exp, dev);
        if (ret)
                return log_msg_ret("dis", ret);
@@ -143,7 +140,6 @@ int cedit_prepare(struct expo *exp, struct video_priv **vid_privp,
        if (ret)
                return log_msg_ret("dim", ret);
 
-       *vid_privp = vid_priv;
        *scnp = scn;
 
        return scene_id;
@@ -193,11 +189,17 @@ int cedit_do_action(struct expo *exp, struct scene *scn,
 int cedit_run(struct expo *exp)
 {
        struct video_priv *vid_priv;
-       uint scene_id;
+       struct udevice *dev;
        struct scene *scn;
+       uint scene_id;
        int ret;
 
-       ret = cedit_prepare(exp, &vid_priv, &scn);
+       ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
+       if (ret)
+               return log_msg_ret("vid", ret);
+       vid_priv = dev_get_uclass_priv(dev);
+
+       ret = cedit_prepare(exp, dev, &scn);
        if (ret < 0)
                return log_msg_ret("prep", ret);
        scene_id = ret;
index a9305ceebcb3c466e228ecd0bee65ae563b1a712..319a61aecb803002570d9ce1354b68ad8c5f7ce0 100644 (file)
@@ -56,11 +56,11 @@ int cedit_run(struct expo *exp);
  * This ensures that all menus have a selected item.
  *
  * @exp: Expo to use
- * @vid_privp: Set to private data for the video device
+ * @dev: Video device to use
  * @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,
+int cedit_prepare(struct expo *exp, struct udevice *vid_dev,
                  struct scene **scnp);
 
 /**
index 5b3e9b586a6add21ad9d706f255a4950370c480b..746f60067fd14e2daca5bf0f81bf9fca2abbfc5a 100644 (file)
@@ -63,6 +63,7 @@ static int cedit_fdt(struct unit_test_state *uts)
        struct video_priv *vid_priv;
        extern struct expo *cur_exp;
        struct scene_obj_menu *menu;
+       struct udevice *dev;
        ulong addr = 0x1000;
        struct ofprop prop;
        struct scene *scn;
@@ -72,9 +73,12 @@ static int cedit_fdt(struct unit_test_state *uts)
        void *fdt;
        int i;
 
+       ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
+       vid_priv = dev_get_uclass_priv(dev);
+
        ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
 
-       ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn));
+       ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn));
 
        /* get a menu to fiddle with */
        menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU);
@@ -134,12 +138,16 @@ static int cedit_env(struct unit_test_state *uts)
        struct video_priv *vid_priv;
        extern struct expo *cur_exp;
        struct scene_obj_menu *menu;
+       struct udevice *dev;
        struct scene *scn;
        char *str;
 
        ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
 
-       ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn));
+       ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
+       vid_priv = dev_get_uclass_priv(dev);
+
+       ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn));
 
        /* get a menu to fiddle with */
        menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU);
@@ -189,11 +197,14 @@ static int cedit_cmos(struct unit_test_state *uts)
        struct scene_obj_menu *menu, *menu2;
        struct video_priv *vid_priv;
        extern struct expo *cur_exp;
+       struct udevice *dev;
        struct scene *scn;
 
        ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
 
-       ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn));
+       ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
+       vid_priv = dev_get_uclass_priv(dev);
+       ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn));
 
        /* get the menus to fiddle with */
        menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU);
@@ -238,7 +249,8 @@ static int cedit_render(struct unit_test_state *uts)
 
        exp = cur_exp;
        ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
-       ut_asserteq(ID_SCENE1, cedit_prepare(exp, &vid_priv, &scn));
+       vid_priv = dev_get_uclass_priv(dev);
+       ut_asserteq(ID_SCENE1, cedit_prepare(exp, dev, &scn));
 
        menu = scene_obj_find(scn, ID_POWER_LOSS, SCENEOBJT_MENU);
        ut_assertnonnull(menu);