From patchwork Fri Apr 11 00:26:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 3965531 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 849689F336 for ; Fri, 11 Apr 2014 00:24:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A6162081B for ; Fri, 11 Apr 2014 00:24:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5133A20831 for ; Fri, 11 Apr 2014 00:24:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C7BF46ECAC; Thu, 10 Apr 2014 17:24:31 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 703296ECAC for ; Thu, 10 Apr 2014 17:24:30 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 10 Apr 2014 17:24:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,837,1389772800"; d="scan'208";a="518847829" Received: from mdroper-hswdev.fm.intel.com (HELO mdroper-hswdev) ([10.1.134.215]) by orsmga002.jf.intel.com with ESMTP; 10 Apr 2014 17:24:22 -0700 Received: from mattrope by mdroper-hswdev with local (Exim 4.82) (envelope-from ) id 1WYPIw-0000si-Ln; Thu, 10 Apr 2014 17:26:50 -0700 From: Matt Roper To: intel-gfx@lists.freedesktop.org Date: Thu, 10 Apr 2014 17:26:25 -0700 Message-Id: <1397175985-3328-4-git-send-email-matthew.d.roper@intel.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1397175985-3328-1-git-send-email-matthew.d.roper@intel.com> References: <1397175876-3216-1-git-send-email-matthew.d.roper@intel.com> <1397175985-3328-1-git-send-email-matthew.d.roper@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 3/3] kms_universal_plane: Universal plane testing 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.8 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 Add a simple test to exercise universal plane support. Signed-off-by: Matt Roper --- tests/Makefile.sources | 1 + tests/kms_universal_plane.c | 211 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 212 insertions(+) create mode 100644 tests/kms_universal_plane.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index bf02a48..4911914 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -63,6 +63,7 @@ TESTS_progs_M = \ kms_plane \ kms_render \ kms_setmode \ + kms_universal_plane \ pm_lpsp \ pm_pc8 \ pm_rps \ diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c new file mode 100644 index 0000000..f1ec6fb --- /dev/null +++ b/tests/kms_universal_plane.c @@ -0,0 +1,211 @@ +/* + * Copyright © 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include +#include +#include + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" + +typedef struct { + int drm_fd; + igt_display_t display; +} data_t; + +/* + * Universal plane testing. + * - Black primary plane via traditional interfaces, red sprite, grab CRC:1. + * - Blue primary plane via traditional interfaces, red sprite, grab CRC:2. + * - Yellow primary via traditional interfaces + * - Blue primary plane, red sprite via universal planes, grab CRC:3 and compare + * with CRC:2 (should be the same) + * - Disable primary plane, grab CRC:4 (should be same as CRC:1) + * - Reenable primary, grab CRC:5 (should be same as CRC:2 and CRC:3) + */ + +typedef struct { + data_t *data; + igt_pipe_crc_t *pipe_crc; + igt_crc_t crc_1, crc_2, crc_3, crc_4, crc_5; + struct igt_fb red_fb, blue_fb, black_fb, yellow_fb; +} test_t; + +static void +test_init(test_t *test, igt_output_t *output, enum pipe pipe) +{ + data_t *data = test->data; + drmModeModeInfo *mode; + + test->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + + igt_output_set_pipe(output, pipe); + + mode = igt_output_get_mode(output); + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 0.0, 0.0, 0.0, + &test->black_fb); + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 0.0, 0.0, 1.0, + &test->blue_fb); + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 1.0, 1.0, 0.0, + &test->yellow_fb); + igt_create_color_fb(data->drm_fd, 100, 100, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 1.0, 0.0, 0.0, + &test->red_fb); +} + +static void +test_fini(test_t *test, igt_output_t *output) +{ + igt_pipe_crc_free(test->pipe_crc); + + igt_remove_fb(test->data->drm_fd, &test->black_fb); + igt_remove_fb(test->data->drm_fd, &test->blue_fb); + igt_remove_fb(test->data->drm_fd, &test->red_fb); + igt_remove_fb(test->data->drm_fd, &test->yellow_fb); + + igt_display_use_universal_commits(&test->data->display, false); + igt_output_set_pipe(output, PIPE_ANY); + igt_display_commit(&test->data->display); +} + +static void +test_pipe(data_t *data, enum pipe pipe, igt_output_t *output) +{ + test_t test = { .data = data }; + igt_plane_t *primary, *sprite; + + igt_skip_on(pipe >= data->display.n_pipes); + + fprintf(stdout, "Testing connector %s using pipe %c\n", + igt_output_name(output), pipe_name(pipe)); + + test_init(&test, output, pipe); + + primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); + sprite = igt_output_get_plane(output, IGT_PLANE_2); + if (!sprite) { + test_fini(&test, output); + igt_skip("No sprite plane available\n"); + } + + igt_plane_set_position(sprite, 100, 100); + + /* Step 1: Legacy API's, black primary, red sprite (CRC 1) */ + igt_plane_set_fb(primary, &test.black_fb); + igt_plane_set_fb(sprite, &test.red_fb); + igt_display_commit(&data->display); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_1); + + /* Step 2: Legacy API', blue primary, red sprite (CRC 2) */ + igt_plane_set_fb(primary, &test.blue_fb); + igt_plane_set_fb(sprite, &test.red_fb); + igt_display_commit(&data->display); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_2); + + /* Step 3: Legacy API's, yellow primary */ + igt_plane_set_fb(primary, &test.yellow_fb); + igt_display_commit(&data->display); + + /* Step 4: Universal API's, blue primary, red sprite (CRC 3) */ + igt_display_use_universal_commits(&test.data->display, true); + igt_plane_set_fb(primary, &test.blue_fb); + igt_plane_set_fb(sprite, &test.red_fb); + igt_display_commit(&data->display); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_3); + + /* Step 5: Universal API's, disable primary plane (CRC 4) */ + igt_plane_set_fb(primary, NULL); + igt_display_commit(&data->display); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_4); + + /* Step 6: Universal API's, re-enable primary with blue (CRC 5) */ + igt_display_use_universal_commits(&test.data->display, true); + igt_plane_set_fb(primary, &test.blue_fb); + igt_display_commit(&data->display); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.crc_5); + + /* Blue bg + red sprite should be same under both types of API's */ + igt_assert(igt_crc_equal(&test.crc_2, &test.crc_3)); + + /* Disabling primary plane should be same as black primary */ + igt_assert(igt_crc_equal(&test.crc_1, &test.crc_4)); + + /* Re-enabling primary should return to blue properly */ + igt_assert(igt_crc_equal(&test.crc_2, &test.crc_5)); + + igt_plane_set_fb(primary, NULL); + igt_plane_set_fb(sprite, NULL); + + test_fini(&test, output); +} + +static void +run_tests_for_pipe(data_t *data, enum pipe pipe) +{ + igt_output_t *output; + + igt_assert(data->display.has_universal_planes); + + igt_subtest_f("universal-plane-pipe-%c", pipe_name(pipe)) + for_each_connected_output(&data->display, output) + test_pipe(data, pipe, output); +} + +static data_t data; + +igt_main +{ + + igt_skip_on_simulation(); + + igt_fixture { + data.drm_fd = drm_open_any(); + + igt_set_vt_graphics_mode(); + + igt_require_pipe_crc(); + igt_display_init(&data.display, data.drm_fd); + + igt_require(data.display.has_universal_planes); + } + + for (int pipe = 0; pipe < 3; pipe++) + run_tests_for_pipe(&data, pipe); + + igt_fixture { + igt_display_fini(&data.display); + } +}