Black screen is forbidden on this test. So let's fail if sink crc shows it is back. Also there are many cases where we know for shure it should be all green, so let's check for them. Instead of checking colors we could print with sw using cairo and check if we have identical crc like cursor testcases. However with PSR the chance of artifacts is low and chance of getting blank screen or unchanged screen is high. So even drawing on sw and comparing both CRCs we can have the same result. However the risk is that screen never changed. So the safest way is to compare if screen changed and check the green color when we know it should be green or not green. v2: Hardcoded green was simply wrong because green CRC can change depending on display.Split R, G and B on CRC and bitewise them with mask to verify it is green. Signed-off-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx> --- tests/kms_psr_sink_crc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c index ee8e2ff..79f410c 100644 --- a/tests/kms_psr_sink_crc.c +++ b/tests/kms_psr_sink_crc.c @@ -38,6 +38,8 @@ bool running_with_psr_disabled; +#define CRC_BLACK "000000000000" + enum planes { PRIMARY, SPRITE, @@ -255,6 +257,38 @@ static void get_sink_crc(data_t *data, char *crc) { * Now give a time for human eyes */ usleep(300000); + + /* Black screen is always invalid */ + igt_assert(strcmp(crc, CRC_BLACK) != 0); +} + +static bool is_green(char *crc) +{ + char color_mask[5] = "FFFF\0"; + char rs[5], gs[5], bs[5]; + unsigned int rh, gh, bh, mask; + int ret; + + sscanf(color_mask, "%4x", &mask); + + memcpy(rs, &crc[0], 4); + rs[4] = '\0'; + ret = sscanf(rs, "%4x", &rh); + igt_require(ret > 0); + + memcpy(gs, &crc[4], 4); + gs[4] = '\0'; + ret = sscanf(gs, "%4x", &gh); + igt_require(ret > 0); + + memcpy(bs, &crc[8], 4); + bs[4] = '\0'; + ret = sscanf(bs, "%4x", &bh); + igt_require(ret > 0); + + return ((rh & mask) == 0 && + (gh & mask) != 0 && + (bh & mask) == 0); } static void test_crc(data_t *data) @@ -268,6 +302,15 @@ static void test_crc(data_t *data) igt_plane_set_fb(data->primary, &data->fb_green); igt_display_commit(&data->display); + /* Confirm that screen became Green */ + get_sink_crc(data, ref_crc); + igt_assert(is_green(ref_crc)); + + /* Confirm screen stays Green after PSR got active */ + igt_assert(wait_psr_entry(data, 10)); + get_sink_crc(data, ref_crc); + igt_assert(is_green(ref_crc)); + /* Setting a secondary fb/plane */ switch (data->test_plane) { case PRIMARY: default: test_plane = data->primary; break; @@ -277,14 +320,18 @@ static void test_crc(data_t *data) igt_plane_set_fb(test_plane, &data->fb_white); igt_display_commit(&data->display); + /* Confirm it is not Green anymore */ igt_assert(wait_psr_entry(data, 10)); get_sink_crc(data, ref_crc); + igt_assert(!is_green(ref_crc)); switch (data->op) { case PAGE_FLIP: /* Only in use when testing primary plane */ igt_assert(drmModePageFlip(data->drm_fd, data->crtc_id, data->fb_green.fb_id, 0, NULL) == 0); + get_sink_crc(data, crc); + igt_assert(is_green(crc)); break; case MMAP_GTT: ptr = gem_mmap__gtt(data->drm_fd, handle, 4096, PROT_WRITE); -- 1.9.3 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx