[Concept,01/14] video: Do the sync timing within video_sync()

Message ID 20251006205856.2009292-2-sjg@u-boot.org
State New
Headers
Series expo: More mouse development for expo |

Commit Message

Simon Glass Oct. 6, 2025, 8:58 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

The timer is used in a different function from that where it is set up.
Move setup into video_sync() so that the code is all together.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/video-uclass.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
  

Patch

diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 500a04a0442..37171f6b2da 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -519,11 +519,6 @@  int video_manual_sync(struct udevice *vid, uint flags)
 
 	video_flush_dcache(vid, false);
 
-	if (IS_ENABLED(CONFIG_VIDEO_COPY) && (flags & VIDSYNC_COPY))
-		video_flush_dcache(vid, true);
-
-	priv->last_sync = get_timer(0);
-
 	if (IS_ENABLED(CONFIG_VIDEO_DAMAGE)) {
 		struct vid_bbox *damage = &priv->damage;
 
@@ -542,6 +537,7 @@  int video_sync(struct udevice *vid, bool force)
 	struct video_priv *priv = dev_get_uclass_priv(vid);
 	struct video_uc_priv *uc_priv = uclass_get_priv(vid->uclass);
 	uint flags = 0;
+	int ret;
 
 	/* Skip sync if manual-sync mode is active */
 	if (uc_priv->manual_sync)
@@ -558,7 +554,13 @@  int video_sync(struct udevice *vid, bool force)
 	if (IS_ENABLED(CONFIG_VIDEO_COPY))
 		flags |= VIDSYNC_COPY;
 
-	return video_manual_sync(vid, flags);
+	ret = video_manual_sync(vid, flags);
+	if (ret)
+		return ret;
+
+	priv->last_sync = get_timer(0);
+
+	return 0;
 }
 
 void video_sync_all(void)