Signed-off-by: Jim Bride <jim.bride@xxxxxxxxxxxxxxx> --- lib/igt_psr.c | 12 ++++++++++++ lib/igt_psr.h | 1 + tests/kms_fbcon_fbt.c | 28 ++++++++++++---------------- tests/kms_frontbuffer_tracking.c | 17 +++++------------ tests/kms_psr_sink_crc.c | 16 ++-------------- 5 files changed, 32 insertions(+), 42 deletions(-) diff --git a/lib/igt_psr.c b/lib/igt_psr.c index d849961..d27c32a 100644 --- a/lib/igt_psr.c +++ b/lib/igt_psr.c @@ -102,3 +102,15 @@ bool igt_psr_active(int fd) actret ? "true" : "false"); return hwactret && actret; } + +/** + * igt_psr_await_status: + * @active: A boolean that causes the function to wait for PSR to activate + * if set to true, or to wait for PSR to deactivate if false. + * + * Returns true if the requested condition is met. + */ +bool igt_psr_await_status(int fd, bool active) +{ + return igt_wait(igt_psr_active(fd) == active, 5000, 1); +} diff --git a/lib/igt_psr.h b/lib/igt_psr.h index b678329..3c355e0 100644 --- a/lib/igt_psr.h +++ b/lib/igt_psr.h @@ -31,5 +31,6 @@ bool igt_psr_source_support(int fd); bool igt_psr_sink_support(int fd); bool igt_psr_possible(int fd); bool igt_psr_active(int fd); +bool igt_psr_await_status(int fd, bool active); #endif /* IGT_PSR_H */ diff --git a/tests/kms_fbcon_fbt.c b/tests/kms_fbcon_fbt.c index 41ab36d..cba632e 100644 --- a/tests/kms_fbcon_fbt.c +++ b/tests/kms_fbcon_fbt.c @@ -103,8 +103,9 @@ static bool fbc_is_enabled(int fd) return strstr(buf, "FBC enabled\n"); } -static bool fbc_wait_until_enabled(int fd) +static bool fbc_await_status(int fd, bool enabled) { + igt_assert(enabled); return igt_wait(fbc_is_enabled(fd), 5000, 1); } @@ -157,29 +158,24 @@ static bool connector_can_psr(drmModeConnectorPtr connector) return (connector->connector_type == DRM_MODE_CONNECTOR_eDP); } -static bool psr_is_enabled(int fd) +static bool psr_await_status(int fd, bool enabled) { - return igt_psr_active(fd); -} - -static bool psr_wait_until_enabled(int fd) -{ - return igt_wait(psr_is_enabled(fd), 5000, 1); + return igt_psr_await_status(fd, enabled); } struct feature { bool (*supported_on_chipset)(int fd); - bool (*wait_until_enabled)(int fd); + bool (*await_status)(int fd, bool enabled); bool (*connector_possible_fn)(drmModeConnectorPtr connector); const char *param_name; } fbc = { .supported_on_chipset = fbc_supported_on_chipset, - .wait_until_enabled = fbc_wait_until_enabled, + .await_status = fbc_await_status, .connector_possible_fn = connector_can_fbc, .param_name = "enable_fbc", }, psr = { .supported_on_chipset = psr_supported_on_chipset, - .wait_until_enabled = psr_wait_until_enabled, + .await_status = psr_await_status, .connector_possible_fn = connector_can_psr, .param_name = "enable_psr", }; @@ -204,17 +200,17 @@ static void subtest(struct feature *feature, bool suspend) kmstest_unset_all_crtcs(drm.fd, drm.res); wait_user("Modes unset."); - igt_assert(!feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, false)); set_mode_for_one_screen(&drm, &fb, feature->connector_possible_fn); wait_user("Screen set."); - igt_assert(feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, true)); if (suspend) { igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); sleep(5); - igt_assert(feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, true)); } igt_remove_fb(drm.fd, &fb); @@ -224,13 +220,13 @@ static void subtest(struct feature *feature, bool suspend) sleep(3); wait_user("Back to fbcon."); - igt_assert(!feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, false)); if (suspend) { igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE); sleep(5); - igt_assert(!feature->wait_until_enabled(drm.fd)); + igt_assert(feature->await_status(drm.fd, false)); } } diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index b202297..4d20899 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -798,11 +798,6 @@ static void fbc_print_status(void) igt_info("FBC status:\n%s\n", buf); } -static bool psr_is_enabled(void) -{ - return igt_psr_active(drm.fd); -} - static void psr_print_status(void) { char buf[256]; @@ -916,11 +911,6 @@ static bool fbc_wait_until_enabled(void) return igt_wait(fbc_is_enabled(), 2000, 1); } -static bool psr_wait_until_enabled(void) -{ - return igt_wait(psr_is_enabled(), 5000, 1); -} - #define fbc_enable() igt_set_module_param_int("enable_fbc", 1) #define fbc_disable() igt_set_module_param_int("enable_fbc", 0) #define psr_enable() igt_psr_enable() @@ -1704,12 +1694,15 @@ static int adjust_assertion_flags(const struct test_mode *t, int flags) } \ \ if (flags_ & ASSERT_PSR_ENABLED) { \ - if (!psr_wait_until_enabled()) { \ + if (!igt_psr_await_status(drm.fd, true)) { \ psr_print_status(); \ igt_assert_f(false, "PSR disabled\n"); \ } \ } else if (flags_ & ASSERT_PSR_DISABLED) { \ - igt_assert(!psr_wait_until_enabled()); \ + if (!igt_psr_await_status(drm.fd, false)) { \ + psr_print_status(); \ + igt_assert_f(false, "PSR enabled\n"); \ + } \ } \ } while (0) diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c index 0c27fc7..c9f7993 100644 --- a/tests/kms_psr_sink_crc.c +++ b/tests/kms_psr_sink_crc.c @@ -198,22 +198,10 @@ static bool psr_possible(data_t *data) igt_psr_possible(data->drm_fd); } -static bool psr_active(data_t *data) -{ - - return running_with_psr_disabled || - igt_psr_active(data->drm_fd); -} - static bool wait_psr_entry(data_t *data) { - int timeout = 5; - while (timeout--) { - if (psr_active(data)) - return true; - sleep(1); - } - return false; + return running_with_psr_disabled || + igt_psr_await_status(data->drm_fd, true); } static void get_sink_crc(data_t *data, char *crc) { -- 2.7.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx