diff mbox series

[4/5] sandbox: video: Move sandbox video sync to a driver operation

Message ID 20230821181339.4135800-5-alpernebiyasak@gmail.com
State Under Review
Delegated to: Anatolij Gustschin
Headers show
Series sandbox: video: Refactor out of uclass, try partial screen updates | expand

Commit Message

Alper Nebi Yasak Aug. 21, 2023, 6:13 p.m. UTC
The sandbox SDL video sync is handled in the uclass because there has
been a sync rate limiter and a way to bypass that. Previous patches
move the rate limit code into SDL-specific files, and provide a generic
way to defer and force video syncs.

Sandbox code shouldn't be in the uclasses if possible. Move the
remaining sandbox sync call into the driver ops. Now that sandbox video
sync attempts can defer without resetting video damage, force a video
sync before checking that video syncs reset video damage.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
---

 drivers/video/sandbox_sdl.c  | 16 ++++++++++++++++
 drivers/video/video-uclass.c | 14 --------------
 test/dm/video.c              |  2 +-
 3 files changed, 17 insertions(+), 15 deletions(-)

Comments

Simon Glass Aug. 21, 2023, 10:10 p.m. UTC | #1
On Mon, 21 Aug 2023 at 12:13, Alper Nebi Yasak <alpernebiyasak@gmail.com> wrote:
>
> The sandbox SDL video sync is handled in the uclass because there has
> been a sync rate limiter and a way to bypass that. Previous patches
> move the rate limit code into SDL-specific files, and provide a generic
> way to defer and force video syncs.
>
> Sandbox code shouldn't be in the uclasses if possible. Move the
> remaining sandbox sync call into the driver ops. Now that sandbox video
> sync attempts can defer without resetting video damage, force a video
> sync before checking that video syncs reset video damage.
>
> Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
> ---
>
>  drivers/video/sandbox_sdl.c  | 16 ++++++++++++++++
>  drivers/video/video-uclass.c | 14 --------------
>  test/dm/video.c              |  2 +-
>  3 files changed, 17 insertions(+), 15 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c
index 9081c7da62e4..7dc2787a5d25 100644
--- a/drivers/video/sandbox_sdl.c
+++ b/drivers/video/sandbox_sdl.c
@@ -99,6 +99,17 @@  int sandbox_sdl_set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp)
 	return 0;
 }
 
+static int sandbox_sdl_video_sync(struct udevice *dev)
+{
+	struct video_priv *priv = dev_get_uclass_priv(dev);
+	void *fb = priv->fb;
+
+	if (IS_ENABLED(CONFIG_VIDEO_COPY))
+		fb = priv->copy_fb;
+
+	return sandbox_sdl_sync(fb);
+}
+
 static int sandbox_sdl_remove(struct udevice *dev)
 {
 	/*
@@ -133,6 +144,10 @@  static const struct udevice_id sandbox_sdl_ids[] = {
 	{ }
 };
 
+static struct video_ops sandbox_sdl_ops = {
+	.video_sync = sandbox_sdl_video_sync,
+};
+
 U_BOOT_DRIVER(sandbox_lcd_sdl) = {
 	.name	= "sandbox_lcd_sdl",
 	.id	= UCLASS_VIDEO,
@@ -141,4 +156,5 @@  U_BOOT_DRIVER(sandbox_lcd_sdl) = {
 	.probe	= sandbox_sdl_probe,
 	.remove	= sandbox_sdl_remove,
 	.plat_auto	= sizeof(struct sandbox_sdl_plat),
+	.ops	= &sandbox_sdl_ops,
 };
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index d867185da539..2632216c05ae 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -23,9 +23,6 @@ 
 #include <dm/device_compat.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
-#ifdef CONFIG_SANDBOX
-#include <asm/sdl.h>
-#endif
 
 /*
  * Theory of operation:
@@ -454,17 +451,6 @@  int video_sync(struct udevice *vid, bool force)
 
 	video_flush_dcache(vid);
 
-#if defined(CONFIG_VIDEO_SANDBOX_SDL)
-	void *fb = priv->fb;
-
-	if (IS_ENABLED(CONFIG_VIDEO_COPY))
-		fb = priv->copy_fb;
-
-	ret = sandbox_sdl_sync(fb);
-	while (force && ret == -EAGAIN)
-		ret = sandbox_sdl_sync(fb);
-#endif
-
 	if (IS_ENABLED(CONFIG_VIDEO_DAMAGE)) {
 		priv->damage.xstart = priv->xsize;
 		priv->damage.ystart = priv->ysize;
diff --git a/test/dm/video.c b/test/dm/video.c
index 4c3bcd26e94f..487e4d4a73a2 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -756,7 +756,7 @@  static int dm_test_video_damage(struct unit_test_state *uts)
 	ut_asserteq(1280, priv->damage.xend);
 	ut_asserteq(510, priv->damage.yend);
 
-	video_sync(dev, false);
+	video_sync(dev, true);
 	ut_asserteq(priv->xsize, priv->damage.xstart);
 	ut_asserteq(priv->ysize, priv->damage.ystart);
 	ut_asserteq(0, priv->damage.xend);