From patchwork Fri Jul 14 15:18:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 107806 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1034194qge; Fri, 14 Jul 2017 08:19:11 -0700 (PDT) X-Received: by 10.98.54.196 with SMTP id d187mr5910665pfa.169.1500045551482; Fri, 14 Jul 2017 08:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500045551; cv=none; d=google.com; s=arc-20160816; b=zaZ51UJ5YuGP/uQsuMlygaCqy8De0hm3np6u6vDaNtuozbg/CN/LQxY2KQr0atWiat j5nhPFwKCW99TZOVSFJZLylvhzCj3TEywZzA6Y8cWo7VCjpvuUXLqva0dMvfQVtjyg4X sF1i8tEXB3BB+Z7p7nij2q9KvJ1O9qKyAy26to7Qern1Frq1+wRjVY1/KxTC1NikpmRE WQE7jpfhX6T/SiG+8y6CPqoIHJ2eIH7LPeau8c6et2XOq4fRlyXIOab7c8Af/9u1hjFU IiJv8QJ964t8YLN3B7BMKtcsPmugskUDCQoswzNFSdqAul/tnyCTMlWl1M3PC7IbhylU ofuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:message-id:date :subject:to:from:delivered-to:arc-authentication-results; bh=k/kNDg+jTgmCoNySEp4KoXfq0xQVifCD3b526Ct/mUQ=; b=Aqs0O7lFrshyUYlemNY3MdHUKTseVKvhFSWU5rIMhSsCbmJA5uBiQE6AkNpB1a28oN E5xldWXC6E2UM/uJ4THilHcqcmmX3s7TFCi8OORELD3uYnfzfq4eTMoxqpZ5QsI1Necc EBiuEUAD5rxEThENsgZROczUzeX+XypQ3JL0YjNdG1s+xlJKTC8/dAxAp/s8VWA9sLMG KJGXDfbLqrc2AgD0o2m88T5yg5mdQavLEIFEmTsn+Mgy1Af/fUCNcHN1+etsqm5Ejgxm lcrWFQ+sSEygWkXmt/fWgu+Zl5hBwzhDUpSYVGX2ZQ+TPF64LQtFzGpto0uJWvxoWbOs yvmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id v19si6542941pgc.246.2017.07.14.08.19.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 08:19:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 59BE66E862; Fri, 14 Jul 2017 15:19:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8BD36E870; Fri, 14 Jul 2017 15:19:01 +0000 (UTC) Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.9]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id v6EFIuFO000867; Fri, 14 Jul 2017 16:18:57 +0100 From: Liviu Dudau To: Intel GFX discussion Subject: [PATCH i-g-t v2 5/7] kms_writeback: Add writeback-check-output Date: Fri, 14 Jul 2017 16:18:54 +0100 Message-Id: <20170714151856.32041-6-liviu.dudau@arm.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170714151856.32041-1-liviu.dudau@arm.com> References: <20170714151856.32041-1-liviu.dudau@arm.com> Cc: Boris Brezillon , DRI devel X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Brian Starkey Add a test which makes commits using the writeback connector, and checks the output buffer hash to make sure it is/isn't written as appropriate. Signed-off-by: Brian Starkey --- tests/kms_writeback.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c index d2066482..8201a81c 100644 --- a/tests/kms_writeback.c +++ b/tests/kms_writeback.c @@ -29,6 +29,7 @@ #include "igt.h" #include "igt_fb.h" +#include "sw_sync.h" /* We need to define these ourselves until we get an updated libdrm */ #ifndef DRM_MODE_CONNECTOR_WRITEBACK @@ -278,6 +279,115 @@ static void writeback_fb_id(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t * igt_assert(ret == 0); } +static void fill_fb(igt_fb_t *fb, double color[3]) +{ + cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb); + igt_assert(cr); + + igt_paint_color(cr, 0, 0, fb->width, fb->height, + color[0], color[1], color[2]); +} + +static void get_and_wait_out_fence(igt_output_t *output) +{ + int ret, out_fence = out_fence = igt_output_get_last_writeback_out_fence(output); + igt_assert(out_fence >= 0); + + ret = sync_fence_wait(out_fence, 1000); + igt_assert(ret == 0); + close(out_fence); +} + +static void writeback_seqence(igt_output_t *output, igt_plane_t *plane, + igt_fb_t *in_fb, igt_fb_t *out_fbs[], int n_commits) +{ + int i, color_idx = 0; + double in_fb_colors[2][3] = { + { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + }; + double clear_color[3] = { 1.0, 1.0, 1.0 }; + igt_crc_t cleared_crc, out_expected; + + for (i = 0; i < n_commits; i++, color_idx++) { + /* Change the input color each time */ + fill_fb(in_fb, in_fb_colors[color_idx % 2]); + + if (out_fbs[i]) { + igt_crc_t out_before; + + /* Get the expected CRC */ + fill_fb(out_fbs[i], in_fb_colors[color_idx % 2]); + igt_fb_get_crc(out_fbs[i], &out_expected); + + fill_fb(out_fbs[i], clear_color); + if (i == 0) + igt_fb_get_crc(out_fbs[i], &cleared_crc); + igt_fb_get_crc(out_fbs[i], &out_before); + igt_assert_crc_equal(&cleared_crc, &out_before); + } + + /* Commit */ + igt_plane_set_fb(plane, in_fb); + igt_output_set_writeback_fb(output, out_fbs[i]); + if (out_fbs[i]) + igt_output_request_writeback_out_fence(output); + igt_display_commit_atomic(output->display, + DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + if (out_fbs[i]) + get_and_wait_out_fence(output); + + /* Make sure the old output buffer is untouched */ + if (i > 0 && out_fbs[i - 1] && (out_fbs[i] != out_fbs[i - 1])) { + igt_crc_t out_prev; + igt_fb_get_crc(out_fbs[i - 1], &out_prev); + igt_assert_crc_equal(&cleared_crc, &out_prev); + } + + /* Make sure this output buffer is written */ + if (out_fbs[i]) { + igt_crc_t out_after; + igt_fb_get_crc(out_fbs[i], &out_after); + igt_assert_crc_equal(&out_expected, &out_after); + + /* And clear it, for the next time */ + fill_fb(out_fbs[i], clear_color); + } + } +} + +static void writeback_check_output(igt_output_t *output, igt_plane_t *plane, + igt_fb_t *input_fb, igt_fb_t *output_fb) +{ + igt_fb_t *out_fbs[2] = { 0 }; + igt_fb_t second_out_fb; + int ret; + + /* One commit, with a writeback. */ + writeback_seqence(output, plane, input_fb, &output_fb, 1); + + /* Two commits, the second with no writeback */ + out_fbs[0] = output_fb; + writeback_seqence(output, plane, input_fb, out_fbs, 2); + + /* Two commits, both with writeback */ + out_fbs[1] = output_fb; + writeback_seqence(output, plane, input_fb, out_fbs, 2); + + ret = igt_create_fb(output_fb->fd, output_fb->width, output_fb->height, + DRM_FORMAT_XRGB8888, + igt_fb_mod_to_tiling(0), + &second_out_fb); + igt_require(ret > 0); + + /* Two commits, with different writeback buffers */ + out_fbs[1] = &second_out_fb; + writeback_seqence(output, plane, input_fb, out_fbs, 2); + + igt_remove_fb(output_fb->fd, &second_out_fb); +} + igt_main { igt_display_t display; @@ -364,6 +474,19 @@ igt_main igt_remove_fb(display.drm_fd, &output_fb); } + igt_subtest("writeback-check-output") { + igt_fb_t output_fb; + ret = igt_create_fb(display.drm_fd, mode.hdisplay, mode.vdisplay, + DRM_FORMAT_XRGB8888, + igt_fb_mod_to_tiling(0), + &output_fb); + igt_require(ret > 0); + + writeback_check_output(output, plane, &input_fb, &output_fb); + + igt_remove_fb(display.drm_fd, &output_fb); + } + igt_fixture { igt_remove_fb(display.drm_fd, &input_fb); igt_display_fini(&display);