sandbox: video: Speed up video output
authorSimon Glass <sjg@chromium.org>
Mon, 1 Oct 2018 17:55:14 +0000 (11:55 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 9 Oct 2018 10:40:27 +0000 (04:40 -0600)
At present there are many situations where sandbox syncs the display to
the SDL frame buffer. This is a very expensive operation but is only
needed every now and then. Update video_sync() so that we can specify
whether this operation is really needed.

At present this flag is not used on other architectures. It could also
be used for reducing writeback-cache flushes but the benefit of that would
need to be investigated.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
drivers/video/vidconsole-uclass.c
drivers/video/video-uclass.c
drivers/video/video_bmp.c
include/video.h
test/dm/video.c

index 7f95e9c6e5669ee11e36b1df6a11e6d2f8eb7729..89ac8b3cc8fc1d80e345a96fc9cc5114c954b7db 100644 (file)
@@ -86,7 +86,7 @@ static int vidconsole_back(struct udevice *dev)
                if (priv->ycur < 0)
                        priv->ycur = 0;
        }
-       video_sync(dev->parent);
+       video_sync(dev->parent, false);
 
        return 0;
 }
@@ -113,7 +113,7 @@ static void vidconsole_newline(struct udevice *dev)
        }
        priv->last_ch = 0;
 
-       video_sync(dev->parent);
+       video_sync(dev->parent, false);
 }
 
 static const struct vid_rgb colors[VID_COLOR_COUNT] = {
@@ -293,7 +293,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
 
                if (mode == 2) {
                        video_clear(dev->parent);
-                       video_sync(dev->parent);
+                       video_sync(dev->parent, false);
                        priv->ycur = 0;
                        priv->xcur_frac = priv->xstart_frac;
                } else {
@@ -449,7 +449,7 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch)
        struct udevice *dev = sdev->priv;
 
        vidconsole_put_char(dev, ch);
-       video_sync(dev->parent);
+       video_sync(dev->parent, false);
 }
 
 static void vidconsole_puts(struct stdio_dev *sdev, const char *s)
@@ -458,7 +458,7 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s)
 
        while (*s)
                vidconsole_put_char(dev, *s++);
-       video_sync(dev->parent);
+       video_sync(dev->parent, false);
 }
 
 /* Set up the number of rows and colours (rotated drivers override this) */
@@ -547,7 +547,7 @@ static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc,
        for (s = argv[1]; *s; s++)
                vidconsole_put_char(dev, *s);
 
-       video_sync(dev->parent);
+       video_sync(dev->parent, false);
 
        return 0;
 }
index dd0873767ba5ef6c38ea771ce2e51d1cc13f7c53..fea0886c41505ddb424447d2013064974aa0cb5a 100644 (file)
@@ -128,7 +128,7 @@ void video_set_default_colors(struct video_priv *priv)
 }
 
 /* Flush video activity to the caches */
-void video_sync(struct udevice *vid)
+void video_sync(struct udevice *vid, bool force)
 {
        /*
         * flush_dcache_range() is declared in common.h but it seems that some
@@ -147,7 +147,7 @@ void video_sync(struct udevice *vid)
        struct video_priv *priv = dev_get_uclass_priv(vid);
        static ulong last_sync;
 
-       if (get_timer(last_sync) > 10) {
+       if (force || get_timer(last_sync) > 10) {
                sandbox_sdl_sync(priv->fb);
                last_sync = get_timer(0);
        }
@@ -162,7 +162,7 @@ void video_sync_all(void)
             dev;
             uclass_find_next_device(&dev)) {
                if (device_active(dev))
-                       video_sync(dev);
+                       video_sync(dev, true);
        }
 }
 
index aeff65648c1a54f390c95b3d7960fa3a4ca899b8..1377e190817dfb95bb03f450e60337daaf9f2feb 100644 (file)
@@ -345,7 +345,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                break;
        };
 
-       video_sync(dev);
+       video_sync(dev, false);
 
        return 0;
 }
index e7fc5c94e2e83cbbc8cc0978bac8a22421d1c092..cd5558f86eb4da266cb9adff98508b9988c94209 100644 (file)
@@ -131,8 +131,10 @@ void video_clear(struct udevice *dev);
  * buffer are displayed to the user.
  *
  * @dev:       Device to sync
+ * @force:     True to force a sync even if there was one recently (this is
+ *             very expensive on sandbox)
  */
-void video_sync(struct udevice *vid);
+void video_sync(struct udevice *vid, bool force);
 
 /**
  * video_sync_all() - Sync all devices' frame buffers with there hardware
index ef74c2de7211d431d616dd714bc6954b50b85543..7def338058e1f737ab862c3388fa62010b4676ee 100644 (file)
@@ -169,7 +169,7 @@ static int dm_test_video_ansi(struct unit_test_state *uts)
 
        /* reference clear: */
        video_clear(con->parent);
-       video_sync(con->parent);
+       video_sync(con->parent, false);
        ut_asserteq(46, compress_frame_buffer(dev));
 
        /* test clear escape sequence: [2J */