From patchwork Wed Jul 26 08:47:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vidya Srinivas X-Patchwork-Id: 9864425 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 38C2B6038C for ; Wed, 26 Jul 2017 08:39:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26ED828737 for ; Wed, 26 Jul 2017 08:39:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C11C2873D; Wed, 26 Jul 2017 08:39:47 +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 A4A4928737 for ; Wed, 26 Jul 2017 08:39:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B75F6E669; Wed, 26 Jul 2017 08:39:46 +0000 (UTC) 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 ESMTPS id 881A36E66A for ; Wed, 26 Jul 2017 08:39:43 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2017 01:39:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,414,1496127600"; d="scan'208";a="115789105" Received: from vsrini4-ubuntu-intel.iind.intel.com ([10.223.25.59]) by orsmga002.jf.intel.com with ESMTP; 26 Jul 2017 01:39:41 -0700 From: Vidya Srinivas To: intel-gfx@lists.freedesktop.org Date: Wed, 26 Jul 2017 14:17:13 +0530 Message-Id: <1501058833-14496-3-git-send-email-vidya.srinivas@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501058833-14496-1-git-send-email-vidya.srinivas@intel.com> References: <1501058833-14496-1-git-send-email-vidya.srinivas@intel.com> MIME-Version: 1.0 Cc: Vidya Srinivas Subject: [Intel-gfx] [PATCH i-g-t 2/2] tests/test_nv12.c: This patch adds test_nv12 test case. It is a simple test that covers testing NV12 in linear/tile-X/tile-Y tiling formats. 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: chandra konduru Previous version reference https://patchwork.freedesktop.org/patch/59067/ was posted by Chandra Konduru on Sept 9 2015 based on the IGT framework available at that time Current version: Rebased as per current IGT (me). This version tests basic NV12 in linear/tile-X/tile-Y tiling formats. Signed-off-by: Chandra Konduru Signed-off-by: Vidya Srinivas --- tests/Makefile.sources | 1 + tests/test_nv12.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 tests/test_nv12.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 5b98a5a..5fe5ced 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -233,6 +233,7 @@ TESTS_progs = \ tools_test \ vgem_basic \ vgem_slow \ + test_nv12 \ $(NULL) TESTS_progs_X = \ diff --git a/tests/test_nv12.c b/tests/test_nv12.c new file mode 100644 index 0000000..976eaf5 --- /dev/null +++ b/tests/test_nv12.c @@ -0,0 +1,171 @@ +/* + * Copyright © 20137 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 +#include +#include +#include +#include +#include "drm.h" +#include "ioctl_wrappers.h" +#include "drmtest.h" +#include "igt.h" +#include "igt_aux.h" +#include "sw_sync.h" + + +IGT_TEST_DESCRIPTION("Test page flips and tiling scenarios"); + +uint32_t devid; + +typedef struct { + int drm_fd; + igt_display_t display; + + struct igt_fb fb1_nv12; + struct igt_fb fb2; + int fb_id1_nv12; + int fb_id2; + + igt_plane_t *plane1; + uint64_t tiled; + int rotation; +} data_t; + +#define IMG_FILE "1080-left.png" + +static void +paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h) +{ + cairo_t *cr; + cr = igt_get_cairo_ctx(d->drm_fd, fb); + igt_paint_image(cr, IMG_FILE, 0, 0, w, h); + cairo_destroy(cr); +} + +static void test_nv12_plane(data_t *d) +{ + igt_display_t *display = &d->display; + igt_output_t *output; + enum pipe pipe; + int valid_tests = 0; + int img_width; + int img_height; + + for_each_pipe_with_valid_output(display, pipe, output) { + drmModeModeInfo *mode; + mode = igt_output_get_mode(output); + igt_output_set_pipe(output, pipe); + + /* get planes */ + d->plane1 = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY); + + /* set required rotation */ + igt_plane_set_rotation(d->plane1, d->rotation); + + /* allocate fb2, fb2_nv12, fb1_nv12 with image size */ + igt_get_image_size(IMG_FILE, &img_width, &img_height); + + /* fb2 is in RGB format */ + d->fb_id2 = igt_create_fb(d->drm_fd, + img_width, img_height, + DRM_FORMAT_XRGB8888, + d->tiled, /* tiled */ + &d->fb2); + + d->fb_id1_nv12 = igt_create_fb(d->drm_fd, + img_width, img_height, + DRM_FORMAT_NV12, + d->tiled, /* tiled */ + &d->fb1_nv12); + + /* set up data for fb2: both fb1_nv12, fb2_nv12 uses this */ + paint_image(d, &d->fb2, img_width, img_height); + + igt_fb_csc_xrgb_to_nv12(d->drm_fd, &d->fb1_nv12, &d->fb2); + + /* single plane mode - nv12 & scaling */ + igt_plane_set_fb(d->plane1, &d->fb1_nv12); + igt_fb_set_position(&d->fb1_nv12, d->plane1, 0, 0); + igt_fb_set_size(&d->fb1_nv12, d->plane1, d->fb1_nv12.width, + d->fb1_nv12.height); + igt_plane_set_position(d->plane1, 0, 0); + igt_plane_set_size(d->plane1, d->fb1_nv12.width, d->fb1_nv12.height); + igt_display_commit2(display, COMMIT_UNIVERSAL); + + valid_tests++; + sleep(1); + } + igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); +} + +igt_main +{ + data_t data = {}; + igt_skip_on_simulation(); + + igt_fixture { + data.drm_fd = drm_open_driver(DRIVER_INTEL); + kmstest_set_vt_graphics_mode(); + igt_display_init(&data.display, data.drm_fd); + igt_require_gem(data.drm_fd); + + devid = intel_get_drm_devid(data.drm_fd); + igt_assert(intel_gen(devid) >= 9); + } + + data.rotation = IGT_ROTATION_0; + + igt_subtest_f("nv12-plane-tile-linear") { + data.rotation = IGT_ROTATION_0; + data.tiled = LOCAL_DRM_FORMAT_MOD_NONE; + test_nv12_plane(&data); + } + + igt_subtest_f("nv12-plane-tile-x") { + data.rotation = IGT_ROTATION_0; + data.tiled = LOCAL_I915_FORMAT_MOD_X_TILED; + test_nv12_plane(&data); + } + + igt_subtest_f("nv12-plane-tile-y") { + data.rotation = IGT_ROTATION_0; + data.tiled = LOCAL_I915_FORMAT_MOD_Y_TILED; + test_nv12_plane(&data); + } + + igt_subtest_f("nv12-plane-tile-yf") { + data.rotation = IGT_ROTATION_0; + data.tiled = LOCAL_I915_FORMAT_MOD_Yf_TILED; + test_nv12_plane(&data); + } + + igt_fixture { + igt_display_fini(&data.display); + } +}