From patchwork Tue Sep 9 23:11:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 4873351 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EAF91C0338 for ; Tue, 9 Sep 2014 23:11:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14659201B4 for ; Tue, 9 Sep 2014 23:11:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 344982018E for ; Tue, 9 Sep 2014 23:11:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A33E789DAB; Tue, 9 Sep 2014 16:11:35 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B3CA89DAB for ; Tue, 9 Sep 2014 16:11:34 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 09 Sep 2014 16:05:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,494,1406617200"; d="scan'208";a="600532033" Received: from rdvivi-bratislava.jf.intel.com ([10.7.196.158]) by orsmga002.jf.intel.com with ESMTP; 09 Sep 2014 16:11:33 -0700 From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Tue, 9 Sep 2014 19:11:33 -0400 Message-Id: <1410304293-6333-1-git-send-email-rodrigo.vivi@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <20140904085808.GB15520@phenom.ffwll.local> References: <20140904085808.GB15520@phenom.ffwll.local> Cc: Rodrigo Vivi Subject: [Intel-gfx] [PATCH] tests/kms_psr_sink_crc: Check color ref CRC X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);