Many video tests need to get the first video device and then call video_compress_fb() on it. Add a convenience function that combines these two operations to reduce duplication. The msg parameter allows tests to describe which frame is being checked, which helps with debugging when a check fails. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- include/test/video.h | 12 ++++++++++++ test/dm/video.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/test/video.h b/include/test/video.h index 000fd708c86..8676613e6a4 100644 --- a/include/test/video.h +++ b/include/test/video.h @@ -42,4 +42,16 @@ int video_compress_fb(struct unit_test_state *uts, struct udevice *dev, */ int video_check_copy_fb(struct unit_test_state *uts, struct udevice *dev); +/** + * ut_check_video() - Compress the frame buffer and return its size + * + * This is a convenience function that gets the first video device and calls + * video_compress_fb() on it. + * + * @uts: Test state + * @msg: Message describing the frame being checked (or NULL) + * Return: compressed size of the frame buffer, or -ve on error + */ +int ut_check_video(struct unit_test_state *uts, const char *msg); + #endif diff --git a/test/dm/video.c b/test/dm/video.c index 92b2ee9a6e3..b7aa835c86a 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -198,6 +198,18 @@ int video_check_copy_fb(struct unit_test_state *uts, struct udevice *dev) return 0; } +int ut_check_video(struct unit_test_state *uts, const char *msg) +{ + struct udevice *dev; + int ret; + + ret = uclass_first_device_err(UCLASS_VIDEO, &dev); + if (ret) + return ret; + + return video_compress_fb(uts, dev, false); +} + /* * Call this function at any point to halt and show the current display. Be * sure to run the test with the -l flag. -- 2.43.0