From patchwork Thu Sep 4 01:29:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 4842051 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 93FADC033A for ; Thu, 4 Sep 2014 01:30:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E28A2020A for ; Thu, 4 Sep 2014 01:30:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4A35E2024F for ; Thu, 4 Sep 2014 01:30:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 118E06E610; Wed, 3 Sep 2014 18:30:10 -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 ECB436E5F4 for ; Wed, 3 Sep 2014 18:30:08 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 03 Sep 2014 18:30:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,462,1406617200"; d="scan'208";a="568049925" Received: from rdvivi-bratislava.jf.intel.com ([10.7.196.74]) by orsmga001.jf.intel.com with ESMTP; 03 Sep 2014 18:30:07 -0700 From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Wed, 3 Sep 2014 21:29:57 -0400 Message-Id: <1409794206-2126-3-git-send-email-rodrigo.vivi@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409794206-2126-1-git-send-email-rodrigo.vivi@intel.com> References: <1409794206-2126-1-git-send-email-rodrigo.vivi@intel.com> Cc: Rodrigo Vivi Subject: [Intel-gfx] [PATCH 03/12] tests/kms_sink_crc_basic: Simplify test by using igt_kms functions 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=-5.9 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 Signed-off-by: Rodrigo Vivi --- tests/kms_sink_crc_basic.c | 150 +++++++++++++++------------------------------ 1 file changed, 48 insertions(+), 102 deletions(-) diff --git a/tests/kms_sink_crc_basic.c b/tests/kms_sink_crc_basic.c index 3703dc1..e24220e 100644 --- a/tests/kms_sink_crc_basic.c +++ b/tests/kms_sink_crc_basic.c @@ -34,20 +34,15 @@ #include "igt_debugfs.h" #include "igt_kms.h" -enum color { - WHITE, - BLACK, - NUM_COLORS, -}; - -typedef struct { - struct kmstest_connector_config config; - struct igt_fb fb; -} connector_t; +#define CRC_BLACK "000000000000" +#define CRC_RED "c10100000000" +#define CRC_GREEN "0000c1010000" typedef struct { int drm_fd; - drmModeRes *resources; + igt_display_t display; + struct igt_fb fb_green, fb_red; + igt_plane_t *primary; } data_t; static void get_crc(char *crc) { @@ -59,111 +54,64 @@ static void get_crc(char *crc) { igt_require(ret > 0); fclose(file); -} - -static uint32_t create_fb(data_t *data, - int w, int h, - double r, double g, double b, - struct igt_fb *fb) -{ - cairo_t *cr; - uint32_t fb_id; - - fb_id = igt_create_fb(data->drm_fd, w, h, - DRM_FORMAT_XRGB8888, I915_TILING_NONE, fb); - igt_assert(fb_id); - - cr = igt_get_cairo_ctx(data->drm_fd, fb); - igt_paint_color(cr, 0, 0, w, h, r, g, b); - igt_assert(cairo_status(cr) == 0); - return fb_id; + /* Black screen is always invalid */ + igt_assert(strcmp(crc, CRC_BLACK) != 0); } -static bool -connector_set_mode(data_t *data, connector_t *connector, drmModeModeInfo *mode, - enum color crtc_color) +static void basic_sink_crc_check(data_t *data) { - struct kmstest_connector_config *config = &connector->config; - unsigned int fb_id; - int ret; - - if (crtc_color == WHITE) - fb_id = create_fb(data, mode->hdisplay, mode->vdisplay, - 1.0, 1.0, 1.0, &connector->fb); - else - fb_id = create_fb(data, mode->hdisplay, mode->vdisplay, - 0.0, 0.0, 0.0, &connector->fb); - igt_assert(fb_id); - - ret = drmModeSetCrtc(data->drm_fd, - config->crtc->crtc_id, - connector->fb.fb_id, - 0, 0, /* x, y */ - &config->connector->connector_id, - 1, - mode); - igt_assert(ret == 0); - - return 0; -} - -static void basic_sink_crc_check(data_t *data, uint32_t connector_id) -{ - connector_t connector; - char ref_crc_white[12]; - char ref_crc_black[12]; - char crc_check[12]; - - igt_require(kmstest_get_connector_config(data->drm_fd, - connector_id, - 1 << 0, - &connector.config)); + char crc[12]; - /*Go White*/ - connector_set_mode(data, &connector, &connector.config.default_mode, WHITE); + /* Go Green */ + igt_plane_set_fb(data->primary, &data->fb_green); + igt_display_commit(&data->display); - /* get reference crc for white color */ - get_crc(ref_crc_white); + /* It should be Green */ + get_crc(crc); + igt_assert(strcmp(crc, CRC_GREEN) == 0); - /* Go Black */ - connector_set_mode(data, &connector, &connector.config.default_mode, BLACK); + /* Go Red */ + igt_plane_set_fb(data->primary, &data->fb_red); + igt_display_commit(&data->display); - /* get reference crc for black color */ - get_crc(ref_crc_black); - - igt_assert(strcmp(ref_crc_black, ref_crc_white) != 0); - - /*Go White again*/ - connector_set_mode(data, &connector, &connector.config.default_mode, WHITE); - - get_crc(crc_check); - igt_assert(strcmp(crc_check, ref_crc_white) == 0); - - /* Go Black again */ - connector_set_mode(data, &connector, &connector.config.default_mode, BLACK); - - get_crc(crc_check); - igt_assert(strcmp(crc_check, ref_crc_black) == 0); - - kmstest_free_connector_config(&connector.config); + /* It should be Red */ + get_crc(crc); + igt_assert(strcmp(crc, CRC_RED) == 0); } static void run_test(data_t *data) { - int i; - drmModeConnectorPtr c; - uint32_t connector_id = 0; + igt_display_t *display = &data->display; + igt_output_t *output; + drmModeModeInfo *mode; - for (i = 0; i < data->resources->count_connectors; i++) { - connector_id = data->resources->connectors[i]; - c = drmModeGetConnector(data->drm_fd, connector_id); + for_each_connected_output(display, output) { + drmModeConnectorPtr c = output->config.connector; if (c->connector_type != DRM_MODE_CONNECTOR_eDP || c->connection != DRM_MODE_CONNECTED) continue; - basic_sink_crc_check(data, connector_id); + igt_output_set_pipe(output, PIPE_ANY); + + mode = igt_output_get_mode(output); + + igt_create_color_fb(data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, I915_TILING_X, + 0.0, 1.0, 0.0, + &data->fb_green); + + igt_create_color_fb(data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, I915_TILING_X, + 1.0, 0.0, 0.0, + &data->fb_red); + + data->primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); + + basic_sink_crc_check(data); return; } @@ -179,11 +127,9 @@ igt_simple_main data.drm_fd = drm_open_any(); kmstest_set_vt_graphics_mode(); - - data.resources = drmModeGetResources(data.drm_fd); - igt_assert(data.resources); + igt_display_init(&data.display, data.drm_fd); run_test(&data); - drmModeFreeResources(data.resources); + igt_display_fini(&data.display); }