From patchwork Fri Dec 30 12:00:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Kahola X-Patchwork-Id: 9492061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E885D60417 for ; Fri, 30 Dec 2016 12:04:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D761A1FF8F for ; Fri, 30 Dec 2016 12:04:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC38522638; Fri, 30 Dec 2016 12:04:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 480511FF8F for ; Fri, 30 Dec 2016 12:04:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B429C6E25A; Fri, 30 Dec 2016 12:04:51 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6C5F6E252 for ; Fri, 30 Dec 2016 12:04:22 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 30 Dec 2016 04:04:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,432,1477983600"; d="scan'208";a="24384616" Received: from sorvi.fi.intel.com ([10.237.72.109]) by orsmga002.jf.intel.com with ESMTP; 30 Dec 2016 04:04:21 -0800 From: Mika Kahola To: intel-gfx@lists.freedesktop.org Date: Fri, 30 Dec 2016 14:00:39 +0200 Message-Id: <1483099241-15898-4-git-send-email-mika.kahola@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483099241-15898-1-git-send-email-mika.kahola@intel.com> References: <1483099241-15898-1-git-send-email-mika.kahola@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/5] tests/kms_plane_scaling: Add TEST_ONLY flag X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Virus-Scanned: ClamAV using ClamSMTP Add TEST_ONLY flag to test atomic scaling without actually committing the changes. Signed-off-by: Mika Kahola --- tests/kms_plane_scaling.c | 152 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 135 insertions(+), 17 deletions(-) diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c index 368da09..ae3ce40 100644 --- a/tests/kms_plane_scaling.c +++ b/tests/kms_plane_scaling.c @@ -55,9 +55,18 @@ typedef struct { #define FILE_NAME "1080p-left.png" +/* Command line parameters. */ +struct { + bool test_only; +} opt = { + .test_only = false, +}; + static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, - igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s) + igt_plane_t *plane, drmModeModeInfo *mode, + enum igt_commit_style s, bool test_only) { + int ret; igt_display_t *display = &data->display; igt_output_set_pipe(output, pipe); @@ -94,7 +103,6 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, igt_plane_set_fb(plane, &data->fb1); if (s == COMMIT_LEGACY) { - int ret; ret = drmModeSetCrtc(data->drm_fd, plane->pipe->crtc_id, data->fb_id1, @@ -103,6 +111,12 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, 1, mode); igt_assert_eq(ret, 0); + } else if (test_only) { + ret = igt_display_try_commit2(display, + DRM_MODE_ATOMIC_TEST_ONLY | + DRM_MODE_ATOMIC_ALLOW_MODESET | + COMMIT_ATOMIC); + igt_assert_eq(ret, 0); } else { igt_display_commit2(display, s); } @@ -175,13 +189,14 @@ static void iterate_plane_scaling(data_t *d, drmModeModeInfo *mode) } } -static void test_plane_scaling(data_t *d) +static void test_plane_scaling(data_t *d, bool test_only) { igt_display_t *display = &d->display; igt_output_t *output; enum pipe pipe; int valid_tests = 0; int primary_plane_scaling = 0; /* For now */ + int ret; igt_require(d->num_scalers); @@ -208,7 +223,7 @@ static void test_plane_scaling(data_t *d) /* Set up display with plane 1 */ d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY); - prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_UNIVERSAL); + prepare_crtc(d, output, pipe, d->plane1, mode, COMMIT_UNIVERSAL, test_only); if (primary_plane_scaling) { /* Primary plane upscaling */ @@ -216,14 +231,30 @@ static void test_plane_scaling(data_t *d) igt_fb_set_size(&d->fb1, d->plane1, 500, 500); igt_plane_set_position(d->plane1, 0, 0); igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } /* Primary plane 1:1 no scaling */ igt_fb_set_position(&d->fb1, d->plane1, 0, 0); igt_fb_set_size(&d->fb1, d->plane1, d->fb1.width, d->fb1.height); igt_plane_set_position(d->plane1, 0, 0); igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } } /* Set up fb2->plane2 mapping. */ @@ -235,7 +266,15 @@ static void test_plane_scaling(data_t *d) igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-200, d->fb2.height-200); igt_plane_set_position(d->plane2, 100, 100); igt_plane_set_size(d->plane2, mode->hdisplay-200, mode->vdisplay-200); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } iterate_plane_scaling(d, mode); @@ -244,14 +283,30 @@ static void test_plane_scaling(data_t *d) igt_fb_set_size(&d->fb2, d->plane2, 500, 500); igt_plane_set_position(d->plane2, 10, 10); igt_plane_set_size(d->plane2, mode->hdisplay-20, mode->vdisplay-20); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } /* 2nd plane downscaling */ igt_fb_set_position(&d->fb2, d->plane2, 0, 0); igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width, d->fb2.height); igt_plane_set_position(d->plane2, 10, 10); igt_plane_set_size(d->plane2, 500, 500 * d->fb2.height/d->fb2.width); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } if (primary_plane_scaling) { /* Primary plane up scaling */ @@ -259,7 +314,15 @@ static void test_plane_scaling(data_t *d) igt_fb_set_size(&d->fb1, d->plane1, 500, 500); igt_plane_set_position(d->plane1, 0, 0); igt_plane_set_size(d->plane1, mode->hdisplay, mode->vdisplay); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } } /* Set up fb3->plane3 mapping. */ @@ -271,7 +334,15 @@ static void test_plane_scaling(data_t *d) igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-300, d->fb3.height-300); igt_plane_set_position(d->plane3, 100, 100); igt_plane_set_size(d->plane3, mode->hdisplay-300, mode->vdisplay-300); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } /* Switch scaler from plane 2 to plane 3 */ igt_fb_set_position(&d->fb2, d->plane2, 100, 100); @@ -283,7 +354,15 @@ static void test_plane_scaling(data_t *d) igt_fb_set_size(&d->fb3, d->plane3, d->fb3.width-400, d->fb3.height-400); igt_plane_set_position(d->plane3, 10, 10); igt_plane_set_size(d->plane3, mode->hdisplay-300, mode->vdisplay-300); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } if (primary_plane_scaling) { /* Switch scaler from plane 1 to plane 2 */ @@ -296,13 +375,29 @@ static void test_plane_scaling(data_t *d) igt_fb_set_size(&d->fb2, d->plane2, d->fb2.width-500,d->fb2.height-500); igt_plane_set_position(d->plane2, 100, 100); igt_plane_set_size(d->plane2, mode->hdisplay-200, mode->vdisplay-200); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } } /* back to single plane mode */ igt_plane_set_fb(d->plane2, NULL); igt_plane_set_fb(d->plane3, NULL); - igt_display_commit2(display, COMMIT_UNIVERSAL); + + if (test_only) { + ret = igt_display_try_commit_atomic(&d->display, + DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, + NULL); + igt_assert_eq(ret, 0); + } else { + igt_display_commit2(display, COMMIT_UNIVERSAL); + } valid_tests++; cleanup_crtc(d, output, d->plane1); @@ -310,12 +405,35 @@ static void test_plane_scaling(data_t *d) igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); } -igt_simple_main +static int opt_handler(int option, int option_index, void *input) +{ + switch (option) { + case 't': + opt.test_only = true; + break; + default: + igt_assert(false); + } + + return 0; +} + +const char *help_str = + " --test-only test only atomic commit\n"; + +int main(int argc, char *argv[]) { data_t data = {}; - igt_skip_on_simulation(); + struct option long_options[] = { + { "test-only", no_argument, NULL, 't'}, + { 0, 0, 0, 0 } + }; + igt_subtest_init_parse_opts(&argc, argv, "", long_options, help_str, + opt_handler, NULL); + + igt_skip_on_simulation(); data.drm_fd = drm_open_driver(DRIVER_INTEL); igt_require_pipe_crc(); @@ -324,7 +442,7 @@ igt_simple_main data.num_scalers = intel_gen(data.devid) >= 9 ? 2 : 0; - test_plane_scaling(&data); + test_plane_scaling(&data, opt.test_only); igt_display_fini(&data.display); }