From 5b32d5a203bcd1a82b40f83da91f2cfab7a08349 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 10 Mar 2017 11:35:24 +0200 Subject: kmstest: Add optional argument to the flip option to limit the flips Signed-off-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- utils/kmstest.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'utils/kmstest.cpp') diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp index cd0fc1a..32dcb69 100644 --- a/utils/kmstest.cpp +++ b/utils/kmstest.cpp @@ -54,6 +54,7 @@ static bool s_flip_sync; static bool s_cvt; static bool s_cvt_v2; static bool s_cvt_vid_opt; +static unsigned s_max_flips; static set s_used_crtcs; static set s_used_planes; @@ -359,7 +360,7 @@ static const char* usage_str = " --dmt Search for the given mode from DMT tables\n" " --cea Search for the given mode from CEA tables\n" " --cvt=CVT Create videomode with CVT. CVT is 'v1', 'v2' or 'v2o'\n" - " --flip Do page flipping for each output\n" + " --flip[=max] Do page flipping for each output with an optional maximum flips count\n" " --sync Synchronize page flipping\n" "\n" ", and can be given by index () or id ().\n" @@ -443,10 +444,12 @@ static vector parse_cmdline(int argc, char **argv) { s_use_cea = true; }), - Option("|flip", []() + Option("|flip?", [&](string s) { s_flip_mode = true; s_num_buffers = 2; + if (!s.empty()) + s_max_flips = stoi(s); }), Option("|sync", []() { @@ -821,6 +824,8 @@ static void set_crtcs_n_planes(Card& card, const vector& outputs) set_crtcs_n_planes_legacy(card, outputs); } +static bool max_flips_reached; + class FlipState : private PageFlipHandlerBase { public: @@ -841,6 +846,8 @@ private: void handle_page_flip(uint32_t frame, double time) { m_frame_num++; + if (s_max_flips && m_frame_num >= s_max_flips) + max_flips_reached = true; auto now = std::chrono::steady_clock::now(); @@ -988,7 +995,7 @@ static void main_flip(Card& card, const vector& outputs) for (unique_ptr& fs : flipstates) fs->start_flipping(); - while (true) { + while (!max_flips_reached) { int r; FD_SET(0, &fds); -- cgit v1.2.3