diff options
| author | Alper Nebi Yasak <[email protected]> | 2023-08-18 17:31:27 +0300 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2025-05-01 04:30:46 -0600 |
| commit | 532d003f5fa33ae7d0ffc2932a2245667b1d6201 (patch) | |
| tree | 4b59722eae8eaa7d8c2d0116dcfa8ae4407604aa /test | |
| parent | 6398e1149fc26828908b801569f68a18ac5ee2ab (diff) | |
video: test: Test partial updates of hardware frame buffer
With VIDEO_COPY enabled, only the modified parts of the frame buffer are
intended to be copied to the hardware. Add a test that checks this, by
overwriting contents we prepared without telling the video uclass and
then checking if the overwritten contents have been redrawn on the next
sync.
Signed-off-by: Alper Nebi Yasak <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Link: https://lore.kernel.org/u-boot/[email protected]/
Diffstat (limited to 'test')
| -rw-r--r-- | test/dm/video.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/dm/video.c b/test/dm/video.c index edb1b4ede8c..80e65d66dba 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -656,3 +656,57 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_video_truetype_bs, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +/* Test partial rendering onto hardware frame buffer */ +static int dm_test_video_copy(struct unit_test_state *uts) +{ + struct sandbox_sdl_plat *plat; + struct video_uc_plat *uc_plat; + struct udevice *dev, *con; + struct video_priv *priv; + const char *test_string = "\n\tCriticism may not be agreeable, but it is necessary.\t"; + ulong addr; + + if (!IS_ENABLED(CONFIG_VIDEO_COPY)) + return -EAGAIN; + + ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); + ut_assertnonnull(dev); + uc_plat = dev_get_uclass_plat(dev); + uc_plat->hide_logo = true; + plat = dev_get_plat(dev); + plat->font_size = 32; + ut_assert(!device_active(dev)); + ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); + ut_assertnonnull(dev); + priv = dev_get_uclass_priv(dev); + + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + vidconsole_put_string(con, "\n\n\n\n\n"); + vidconsole_put_string(con, test_string); + vidconsole_put_string(con, test_string); + + ut_asserteq(6678, compress_frame_buffer(uts, dev, false)); + ut_assertok(check_copy_frame_buffer(uts, dev)); + + /* + * Secretly clear the hardware frame buffer, but in a different + * color (black) to see which parts will be overwritten. + */ + memset(priv->copy_fb, 0, priv->fb_size); + + /* + * We should have the full content on the main buffer, but only + * the new content should have been copied to the copy buffer. + */ + vidconsole_put_string(con, test_string); + vidconsole_put_string(con, test_string); + ut_asserteq(7589, compress_frame_buffer(uts, dev, false)); + ut_asserteq(5278, compress_frame_buffer(uts, dev, true)); + + return 0; +} +DM_TEST(dm_test_video_copy, UTF_SCAN_PDATA | UTF_SCAN_FDT); |
