From patchwork Wed Dec 13 09:50:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srinivas, Vidya" X-Patchwork-Id: 10109581 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 68572602C2 for ; Wed, 13 Dec 2017 09:41:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62BAD290E0 for ; Wed, 13 Dec 2017 09:41:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5791E29139; Wed, 13 Dec 2017 09:41:56 +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 A0FC2290E0 for ; Wed, 13 Dec 2017 09:41:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 419D36E3FE; Wed, 13 Dec 2017 09:41:55 +0000 (UTC) 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 ESMTPS id C62EA6E3FC for ; Wed, 13 Dec 2017 09:41:53 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Dec 2017 01:41:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,397,1508828400"; d="scan'208";a="186554277" Received: from vsrini4-ubuntu.iind.intel.com ([10.223.25.4]) by fmsmga006.fm.intel.com with ESMTP; 13 Dec 2017 01:41:51 -0800 From: Vidya Srinivas To: intel-gfx@lists.freedesktop.org Date: Wed, 13 Dec 2017 15:20:50 +0530 Message-Id: <1513158652-8912-5-git-send-email-vidya.srinivas@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513158652-8912-1-git-send-email-vidya.srinivas@intel.com> References: <1513158652-8912-1-git-send-email-vidya.srinivas@intel.com> Cc: daniel.vetter@intel.com, Vidya Srinivas Subject: [Intel-gfx] [PATCH i-g-t 4/6] i-g-t kms_plane_scaling: test scaling with tiling rotation and pixel 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Jyoti Yadav This patch adds subtest for testing scaling in combination with rotation and pixel formats. Signed-off-by: Jyoti Yadav Signed-off-by: Mahesh Kumar Signed-off-by: Vidya Srinivas --- tests/kms_plane_scaling.c | 203 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 194 insertions(+), 9 deletions(-) diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c index a827cb3..3725d8e 100644 --- a/tests/kms_plane_scaling.c +++ b/tests/kms_plane_scaling.c @@ -54,6 +54,52 @@ typedef struct { } data_t; #define FILE_NAME "1080p-left.png" +#define MIN_SRC_WIDTH_HEIGHT 9 +#define MAX_SRC_WIDTH 4096 + +#define MAX_ROTATION 4 +static igt_rotation_t get_rotation_angle(int rot) +{ + switch (rot) { + case 0: + return IGT_ROTATION_0; + break; + case 1: + return IGT_ROTATION_90; + break; + case 2: + return IGT_ROTATION_180; + break; + case 3: + return IGT_ROTATION_270; + break; + default: + igt_info("Unknown/Unsupported Rotation %d\n", rot); + return IGT_ROTATION_0; + } +} + +#define MAX_TILING 4 +static uint64_t get_tiling(int tiling) +{ + switch (tiling) { + case 0: + return LOCAL_DRM_FORMAT_MOD_NONE; + break; + case 1: + return LOCAL_I915_FORMAT_MOD_X_TILED; + break; + case 2: + return LOCAL_I915_FORMAT_MOD_Y_TILED; + break; + case 3: + return LOCAL_I915_FORMAT_MOD_Yf_TILED; + break; + default: + igt_info("Unknown/Unsupported Tiling %d\n", tiling); + return LOCAL_DRM_FORMAT_MOD_NONE; + } +} 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) @@ -129,6 +175,128 @@ static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane) igt_display_commit2(display, COMMIT_UNIVERSAL); } +static void paint_fb(data_t *d, struct igt_fb *fb) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(d->drm_fd, fb); + igt_paint_color(cr, 0, 0, fb->width, fb->height, 0.0, 1.0, 0.0); + igt_assert(cairo_status(cr) == 0); + cairo_destroy(cr); +} + +static void check_scaling_pipe_plane_rot(data_t *d, igt_plane_t *plane, uint32_t pixel_format, + uint64_t tiling, enum pipe pipe, igt_output_t *output, + igt_rotation_t rot) +{ + igt_display_t *display = &d->display; + int width, height; + drmModeModeInfo *mode; + igt_output_set_pipe(output, pipe); + mode = igt_output_get_mode(output); + + /* create buffer in the range of min and max source side limit.*/ + width = height = MIN_SRC_WIDTH_HEIGHT; + d->fb_id1 = igt_create_fb(display->drm_fd, width, height, + pixel_format, tiling, &d->fb1); + paint_fb(d, &d->fb1); + igt_assert(d->fb_id1); + igt_plane_set_fb(plane, &d->fb1); + + /* Check min to full resolution upscaling */ + igt_fb_set_position(&d->fb1, plane, 0, 0); + igt_fb_set_size(&d->fb1, plane, width, height); + igt_plane_set_position(plane, 0, 0); + igt_plane_set_size(plane, mode->hdisplay, mode->vdisplay); + igt_plane_set_rotation(plane, rot); + igt_display_commit2(display, COMMIT_ATOMIC); + + igt_plane_set_fb(plane, NULL); + igt_plane_set_position(plane, 0, 0); + if (d->fb_id1) { + igt_remove_fb(d->drm_fd, &d->fb1); + d->fb_id1 = 0; + } +} + +static void test_scaler_with_rotation_pipe(data_t *d, igt_output_t *output, + enum pipe pipe) +{ + igt_display_t *display = &d->display; + igt_plane_t *plane; + + igt_output_set_pipe(output, pipe); + for_each_plane_on_pipe(display, pipe, plane) { + + if (plane->type == DRM_PLANE_TYPE_CURSOR) + continue; + + for (int i = 0; i < MAX_ROTATION; i++) { + igt_rotation_t rot = get_rotation_angle(i); + check_scaling_pipe_plane_rot(d, plane, DRM_FORMAT_XRGB8888, + LOCAL_I915_FORMAT_MOD_Y_TILED, + pipe, output, rot); + } + } +} + +static void test_scaler_with_rotation(data_t *d, enum pipe pipe) +{ + igt_output_t *output; + + for_each_valid_output_on_pipe(&d->display, pipe, output) { + igt_output_set_pipe(output, pipe); + test_scaler_with_rotation_pipe(d, output, pipe); + igt_output_set_pipe(output, PIPE_ANY); + } +} + +static void +test_scaler_with_pixel_format_pipe_plane(data_t *d, igt_output_t *output, + enum pipe pipe, igt_plane_t *plane, + uint64_t tiling) +{ + uint32_t format; + + for_each_format_in_plane(plane, format) { + if (igt_is_cairo_supported_format(format)) { + check_scaling_pipe_plane_rot(d, plane, format, tiling, + pipe, output, IGT_ROTATION_0); + } + } +} + +static void test_scaler_with_pixel_format_pipe(data_t *d, igt_output_t *output, + enum pipe pipe) +{ + igt_display_t *display = &d->display; + igt_plane_t *plane; + + igt_output_set_pipe(output, pipe); + for_each_plane_on_pipe(display, pipe, plane) { + + if (plane->type == DRM_PLANE_TYPE_CURSOR) + continue; + + for (int i = 0; i < MAX_TILING; i++) { + uint64_t tiling = get_tiling(i); + test_scaler_with_pixel_format_pipe_plane(d, output, pipe, plane, + tiling); + } + } +} + +static void test_scaler_with_pixel_format(data_t *d, enum pipe pipe) +{ + igt_output_t *output; + + for_each_valid_output_on_pipe(&d->display, pipe, output) { + igt_output_set_pipe(output, pipe); + test_scaler_with_pixel_format_pipe(d, output, pipe); + igt_output_set_pipe(output, PIPE_ANY); + } +} + /* does iterative scaling on plane2 */ static void iterate_plane_scaling(data_t *d, drmModeModeInfo *mode) { @@ -312,23 +480,40 @@ static void test_plane_scaling(data_t *d, enum pipe pipe) igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); } -igt_simple_main +igt_main { data_t data = {}; enum pipe pipe; igt_skip_on_simulation(); - - data.drm_fd = drm_open_driver(DRIVER_INTEL); - igt_require_pipe_crc(data.drm_fd); - igt_display_init(&data.display, data.drm_fd); - data.devid = intel_get_drm_devid(data.drm_fd); + igt_fixture { + data.drm_fd = drm_open_driver(DRIVER_INTEL); + kmstest_set_vt_graphics_mode(); + igt_require_pipe_crc(data.drm_fd); + igt_display_init(&data.display, data.drm_fd); + data.devid = intel_get_drm_devid(data.drm_fd); + igt_require_gem(data.drm_fd); + } data.num_scalers = intel_gen(data.devid) >= 9 ? 2 : 0; - for_each_pipe_static(pipe) - test_plane_scaling(&data, pipe); + for_each_pipe_static(pipe) { + + igt_subtest_f("scaler_basic_test") { + test_plane_scaling(&data, pipe); + } + + igt_subtest_f("scaler_with_pixel_format") { + test_scaler_with_pixel_format(&data, pipe); + } - igt_display_fini(&data.display); + igt_subtest_f("scaler_with_rotation") { + test_scaler_with_rotation(&data, pipe); + } + + igt_fixture { + igt_display_fini(&data.display); + } + } }