From patchwork Tue Mar 18 10:29:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sagar.a.kamble@intel.com X-Patchwork-Id: 3847901 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1970BF540 for ; Tue, 18 Mar 2014 10:29:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0B5D20138 for ; Tue, 18 Mar 2014 10:29:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 02048201BB for ; Tue, 18 Mar 2014 10:29:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F1EF4AC5C; Tue, 18 Mar 2014 03:29:11 -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 AED704AC5C for ; Tue, 18 Mar 2014 03:29:10 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 18 Mar 2014 03:28:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,677,1389772800"; d="scan'208";a="502184992" Received: from sagar-desktop.iind.intel.com ([10.223.82.31]) by orsmga002.jf.intel.com with ESMTP; 18 Mar 2014 03:28:41 -0700 From: sagar.a.kamble@intel.com To: intel-gfx@lists.freedesktop.org Date: Tue, 18 Mar 2014 15:59:43 +0530 Message-Id: <1395138583-1945-1-git-send-email-sagar.a.kamble@intel.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: References: Cc: Sagar Kamble Subject: [Intel-gfx] [PATCH v3 1/1] kms_cursor_crc: Enabling this test for all cursor sizes 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 From: Sagar Kamble v1: Added 128x128 and 256x256 cursor size support. v2: Refined the test to use igt_subtest_f and automate enumeration. v3: Restructuring test enumeration using drmGetCap. [Daniel's review comments] Signed-off-by: Sagar Kamble Reviewed-by: Imre Deak --- tests/kms_cursor_crc.c | 131 ++++++++++++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 51 deletions(-) diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c index f98fbdb..9ddf9b4 100644 --- a/tests/kms_cursor_crc.c +++ b/tests/kms_cursor_crc.c @@ -32,6 +32,13 @@ #include "igt_debugfs.h" #include "igt_kms.h" +#ifndef DRM_CAP_CURSOR_WIDTH +#define DRM_CAP_CURSOR_WIDTH 0x8 +#endif +#ifndef DRM_CAP_CURSOR_HEIGHT +#define DRM_CAP_CURSOR_HEIGHT 0x9 +#endif + enum cursor_type { WHITE_VISIBLE, WHITE_INVISIBLE, @@ -124,7 +131,7 @@ static void cursor_disable(test_data_t *test_data) } static void test_crc(test_data_t *test_data, enum cursor_type cursor_type, - bool onscreen) + bool onscreen, int cursor_w, int cursor_h) { int left = test_data->left; int right = test_data->right; @@ -135,43 +142,43 @@ static void test_crc(test_data_t *test_data, enum cursor_type cursor_type, if (onscreen) { /* cursor onscreen, crc should match, except when white visible cursor is used */ - test_data->crc_must_match = cursor_type != WHITE_VISIBLE; + test_data->crc_must_match = (cursor_type != WHITE_VISIBLE); /* fully inside */ do_test(test_data, left, right, top, bottom); /* 2 pixels inside */ - do_test(test_data, left - 62, right + 62, top , bottom ); - do_test(test_data, left , right , top - 62, bottom + 62); - do_test(test_data, left - 62, right + 62, top - 62, bottom + 62); + do_test(test_data, left - (cursor_w-2), right + (cursor_w-2), top , bottom ); + do_test(test_data, left , right , top - (cursor_h-2), bottom + (cursor_h-2)); + do_test(test_data, left - (cursor_w-2), right + (cursor_w-2), top - (cursor_h-2), bottom + (cursor_h-2)); /* 1 pixel inside */ - do_test(test_data, left - 63, right + 63, top , bottom ); - do_test(test_data, left , right , top - 63, bottom + 63); - do_test(test_data, left - 63, right + 63, top - 63, bottom + 63); + do_test(test_data, left - (cursor_w-1), right + (cursor_w-1), top , bottom ); + do_test(test_data, left , right , top - (cursor_h-1), bottom + (cursor_h-1)); + do_test(test_data, left - (cursor_w-1), right + (cursor_w-1), top - (cursor_h-1), bottom + (cursor_h-1)); } else { /* cursor offscreen, crc should always match */ test_data->crc_must_match = true; /* fully outside */ - do_test(test_data, left - 64, right + 64, top , bottom ); - do_test(test_data, left , right , top - 64, bottom + 64); - do_test(test_data, left - 64, right + 64, top - 64, bottom + 64); + do_test(test_data, left - (cursor_w), right + (cursor_w), top , bottom ); + do_test(test_data, left , right , top - (cursor_h), bottom + (cursor_h)); + do_test(test_data, left - (cursor_w), right + (cursor_w), top - (cursor_h), bottom + (cursor_h)); /* fully outside by 1 extra pixels */ - do_test(test_data, left - 65, right + 65, top , bottom ); - do_test(test_data, left , right , top - 65, bottom + 65); - do_test(test_data, left - 65, right + 65, top - 65, bottom + 65); + do_test(test_data, left - (cursor_w+1), right + (cursor_w+1), top , bottom ); + do_test(test_data, left , right , top - (cursor_h+1), bottom + (cursor_h+1)); + do_test(test_data, left - (cursor_w+1), right + (cursor_w+1), top - (cursor_h+1), bottom + (cursor_h+1)); /* fully outside by 2 extra pixels */ - do_test(test_data, left - 66, right + 66, top , bottom ); - do_test(test_data, left , right , top - 66, bottom + 66); - do_test(test_data, left - 66, right + 66, top - 66, bottom + 66); + do_test(test_data, left - (cursor_w+2), right + (cursor_w+2), top , bottom ); + do_test(test_data, left , right , top - (cursor_h+2), bottom + (cursor_h+2)); + do_test(test_data, left - (cursor_w+2), right + (cursor_w+2), top - (cursor_h+2), bottom + (cursor_h+2)); /* fully outside by a lot of extra pixels */ - do_test(test_data, left - 512, right + 512, top , bottom ); - do_test(test_data, left , right , top - 512, bottom + 512); - do_test(test_data, left - 512, right + 512, top - 512, bottom + 512); + do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top , bottom ); + do_test(test_data, left , right , top - (cursor_h+512), bottom + (cursor_h+512)); + do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top - (cursor_h+512), bottom + (cursor_h+512)); /* go nuts */ do_test(test_data, INT_MIN, INT_MAX, INT_MIN, INT_MAX); @@ -180,7 +187,8 @@ static void test_crc(test_data_t *test_data, enum cursor_type cursor_type, cursor_disable(test_data); } -static bool prepare_crtc(test_data_t *test_data, igt_output_t *output) +static bool prepare_crtc(test_data_t *test_data, igt_output_t *output, + int cursor_w, int cursor_h) { drmModeModeInfo *mode; data_t *data = test_data->data; @@ -219,9 +227,9 @@ static bool prepare_crtc(test_data_t *test_data, igt_output_t *output) /* x/y position where the cursor is still fully visible */ test_data->left = 0; - test_data->right = mode->hdisplay - 64; + test_data->right = mode->hdisplay - cursor_w; test_data->top = 0; - test_data->bottom = mode->vdisplay - 64; + test_data->bottom = mode->vdisplay - cursor_h; /* make sure cursor is disabled */ cursor_disable(test_data); @@ -249,7 +257,8 @@ static void cleanup_crtc(test_data_t *test_data, igt_output_t *output) igt_output_set_pipe(output, PIPE_ANY); } -static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen) +static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen, + int cursor_w, int cursor_h) { igt_display_t *display = &data->display; igt_output_t *output; @@ -259,13 +268,12 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen) }; int valid_tests = 0; - for_each_connected_output(display, output) { test_data.output = output; for (p = 0; p < igt_display_get_n_pipes(display); p++) { test_data.pipe = p; - if (!prepare_crtc(&test_data, output)) + if (!prepare_crtc(&test_data, output, cursor_w, cursor_h)) continue; valid_tests++; @@ -274,8 +282,7 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen) igt_subtest_name(), pipe_name(test_data.pipe), igt_output_name(output)); - test_crc(&test_data, cursor_type, onscreen); - + test_crc(&test_data, cursor_type, onscreen, cursor_w, cursor_h); fprintf(stdout, "\n%s on pipe %c, connector %s: PASSED\n\n", igt_subtest_name(), pipe_name(test_data.pipe), @@ -291,31 +298,72 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen) static void create_cursor_fb(data_t *data, enum cursor_type cursor_type, - double r, double g, double b, double a) + double r, double g, double b, double a, + int cur_w, int cur_h) { cairo_t *cr; uint32_t fb_id[NUM_CURSOR_TYPES]; - fb_id[cursor_type] = kmstest_create_fb2(data->drm_fd, 64, 64, + fb_id[cursor_type] = kmstest_create_fb2(data->drm_fd, cur_w, cur_h, DRM_FORMAT_ARGB8888, false, &data->fb[cursor_type]); igt_assert(fb_id[cursor_type]); cr = kmstest_get_cairo_ctx(data->drm_fd, &data->fb[cursor_type]); - kmstest_paint_color_alpha(cr, 0, 0, 64, 64, r, g, b, a); + kmstest_paint_color_alpha(cr, 0, 0, cur_w, cur_h, r, g, b, a); igt_assert(cairo_status(cr) == 0); } +static void run_test_generic(data_t *data, int cursor_max_size) +{ + int cursor_size; + char c_size[5]; + for (cursor_size = 64; cursor_size <= cursor_max_size; cursor_size *= 2) + { + igt_require(cursor_max_size >= cursor_size); + sprintf(c_size, "%d", cursor_size); + + /* Creating cursor framebuffers */ + create_cursor_fb(data, WHITE_VISIBLE, 1.0, 1.0, 1.0, 1.0, cursor_size, cursor_size); + create_cursor_fb(data, WHITE_INVISIBLE, 1.0, 1.0, 1.0, 0.0, cursor_size, cursor_size); + create_cursor_fb(data, BLACK_VISIBLE, 0.0, 0.0, 0.0, 1.0, cursor_size, cursor_size); + create_cursor_fb(data, BLACK_INVISIBLE, 0.0, 0.0, 0.0, 0.0, cursor_size, cursor_size); + + /* Using created cursor FBs to test cursor support */ + igt_subtest_f("white-visible-cursor-%s-onscreen", c_size) + run_test(data, WHITE_VISIBLE, true, cursor_size, cursor_size); + igt_subtest_f("white-invisible-cursor-%s-offscreen", c_size) + run_test(data, WHITE_INVISIBLE, false, cursor_size, cursor_size); + igt_subtest_f("black-visible-cursor-%s-onscreen", c_size) + run_test(data, BLACK_VISIBLE, true, cursor_size, cursor_size); + igt_subtest_f("black-invisible-cursor-%s-offscreen", c_size) + run_test(data, BLACK_INVISIBLE, false, cursor_size, cursor_size); + } + +} + igt_main { data_t data = {}; + int cursor_max_size, ret; + uint64_t cursor_width, cursor_height; igt_skip_on_simulation(); igt_fixture { data.drm_fd = drm_open_any(); + ret = drmGetCap(data.drm_fd, DRM_CAP_CURSOR_WIDTH, &cursor_width); + igt_assert(ret == 0); + /* Not making use of cursor_height since it is same as width, still reading */ + ret = drmGetCap(data.drm_fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height); + igt_assert(ret == 0); + + fprintf(stdout, "%d, %d\n", cursor_width, cursor_height); + /* We assume width and height are same so max is assigned width */ + cursor_max_size = (int)cursor_width; + igt_set_vt_graphics_mode(); igt_debugfs_init(&data.debugfs); @@ -325,28 +373,9 @@ igt_main data.pipe_crc = calloc(igt_display_get_n_pipes(&data.display), sizeof(data.pipe_crc[0])); - create_cursor_fb(&data, WHITE_VISIBLE, 1.0, 1.0, 1.0, 1.0); - create_cursor_fb(&data, WHITE_INVISIBLE, 1.0, 1.0, 1.0, 0.0); - create_cursor_fb(&data, BLACK_VISIBLE, 0.0, 0.0, 0.0, 1.0); - create_cursor_fb(&data, BLACK_INVISIBLE, 0.0, 0.0, 0.0, 0.0); } - igt_subtest("cursor-white-visible-onscreen") - run_test(&data, WHITE_VISIBLE, true); - igt_subtest("cursor-white-visible-offscreen") - run_test(&data, WHITE_VISIBLE, false); - igt_subtest("cursor-white-invisible-onscreen") - run_test(&data, WHITE_INVISIBLE, true); - igt_subtest("cursor-white-invisible-offscreen") - run_test(&data, WHITE_INVISIBLE, false); - igt_subtest("cursor-black-visible-onscreen") - run_test(&data, BLACK_VISIBLE, true); - igt_subtest("cursor-black-visible-offscreen") - run_test(&data, BLACK_VISIBLE, false); - igt_subtest("cursor-black-invisible-onscreen") - run_test(&data, BLACK_INVISIBLE, true); - igt_subtest("cursor-black-invisible-offscreen") - run_test(&data, BLACK_INVISIBLE, false); + run_test_generic(&data, cursor_max_size); igt_fixture { free(data.pipe_crc);