From patchwork Thu Jan 23 18:18:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 3530181 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 6FE3FC02DC for ; Thu, 23 Jan 2014 18:18:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 210452016C for ; Thu, 23 Jan 2014 18:18:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A580920161 for ; Thu, 23 Jan 2014 18:18:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 851C2FBA12; Thu, 23 Jan 2014 10:18:19 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yk0-f177.google.com (mail-yk0-f177.google.com [209.85.160.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F102FBA12 for ; Thu, 23 Jan 2014 10:18:17 -0800 (PST) Received: by mail-yk0-f177.google.com with SMTP id 19so3216697ykq.8 for ; Thu, 23 Jan 2014 10:18:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=ZK2UMbecbGtHvTXuCdKll00K7Pfmk4AjmHcazNr0aXM=; b=CWGSsJachkeqbocF7tGK0/f2ENyy0GWEqTsnsNvD1Vzi0vQa2r2cnjVCpV2993hQV7 2DF/funYSd2oX8bhdgHFAeed5/IvMkXA2ckW5jP+GxFELKnag8dZAhykYNJB2P1kQDlU 7ZblrTg78LJuAOufFwyLJm21oE99j/VRcu7NTUwf1ueBsK5P9SMzx8gTEgxv5ZeG8mTM v1WFdGeUK3INqbVqnQDozL79x54d/5larD8sM2N717A+KU3WHr9D6QRT9hjFtLS8c9Jw jL0qnyd3Ve+AqNxSzl6nbu4CMO+/25Ur7Nkva6PbCqqDwjyMdZgJvfMXqZdLndbl8fZ+ Dtyg== X-Received: by 10.236.169.165 with SMTP id n25mr1909636yhl.118.1390501096740; Thu, 23 Jan 2014 10:18:16 -0800 (PST) Received: from localhost.localdomain ([189.40.75.73]) by mx.google.com with ESMTPSA id q9sm38724779yhk.16.2014.01.23.10.18.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jan 2014 10:18:15 -0800 (PST) From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Thu, 23 Jan 2014 16:18:04 -0200 Message-Id: <1390501086-4727-1-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/3] tests/kms_sink_crc_basic: Basic test to verify Sink CRC debugfs. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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/Android.mk | 1 + tests/Makefile.sources | 1 + tests/kms_sink_crc_basic.c | 201 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+) create mode 100644 tests/kms_sink_crc_basic.c diff --git a/tests/Android.mk b/tests/Android.mk index c65f94c..fa9e9d7 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -98,6 +98,7 @@ skip_tests_list := \ kms_fbc_crc \ kms_render \ kms_setmode \ + kms_sink_crc_basic \ pm_pc8 \ gem_seqno_wrap \ gem_render_copy \ diff --git a/tests/Makefile.sources b/tests/Makefile.sources index c586bd3..5fe68ae 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -60,6 +60,7 @@ TESTS_progs_M = \ kms_pipe_crc_basic \ kms_render \ kms_setmode \ + kms_sink_crc_basic \ pm_lpsp \ pm_pc8 \ prime_self_import \ diff --git a/tests/kms_sink_crc_basic.c b/tests/kms_sink_crc_basic.c new file mode 100644 index 0000000..fa5b63b --- /dev/null +++ b/tests/kms_sink_crc_basic.c @@ -0,0 +1,201 @@ +/* + * Copyright © 2013 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 "drm_fourcc.h" + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" + +enum color { + WHITE, + BLACK, + NUM_COLORS, +}; + +typedef struct { + struct kmstest_connector_config config; + struct kmstest_fb fb; +} connector_t; + +typedef struct { + int drm_fd; + drmModeRes *resources; +} data_t; + +static void get_crc(char *crc) { + int ret; + FILE *file = fopen("/sys/kernel/debug/dri/0/i915_sink_crc_eDP1", "r"); + igt_require(file); + + ret = fscanf(file, "%s\n", 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 kmstest_fb *fb) +{ + cairo_t *cr; + uint32_t fb_id; + + fb_id = kmstest_create_fb2(data->drm_fd, w, h, + DRM_FORMAT_XRGB8888, false, fb); + igt_assert(fb_id); + + cr = kmstest_get_cairo_ctx(data->drm_fd, fb); + kmstest_paint_color(cr, 0, 0, w, h, r, g, b); + igt_assert(cairo_status(cr) == 0); + + return fb_id; +} + +static bool +connector_set_mode(data_t *data, connector_t *connector, drmModeModeInfo *mode, + enum color crtc_color) +{ + 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; + int ret; + char ref_crc_white[12]; + char ref_crc_black[12]; + char crc_check[12]; + + ret = kmstest_get_connector_config(data->drm_fd, + connector_id, + 1 << 0, + &connector.config); + igt_require(ret == 0); + + /*Go White*/ + connector_set_mode(data, &connector, &connector.config.default_mode, WHITE); + + /* get reference crc for white color */ + get_crc(ref_crc_white); + + /* Go Black */ + connector_set_mode(data, &connector, &connector.config.default_mode, BLACK); + + /* get reference crc for black color */ + get_crc(ref_crc_black); + + if (strcmp(ref_crc_black, ref_crc_white) == 0) { + fprintf(stderr, "CRC Black should differ from CRC White\n"); + igt_fail(1); + } + + /*Go White again*/ + connector_set_mode(data, &connector, &connector.config.default_mode, WHITE); + + get_crc(crc_check); + if (strcmp(crc_check, ref_crc_white) != 0) { + fprintf(stderr, "CRC check for white differ from reference\n"); + igt_fail(1); + } + + /* Go Black again */ + connector_set_mode(data, &connector, &connector.config.default_mode, BLACK); + + get_crc(crc_check); + if (strcmp(crc_check, ref_crc_black) != 0) { + fprintf(stderr, "CRC check for black differ from reference\n"); + igt_fail(1); + } + + kmstest_free_connector_config(&connector.config); +} + +static void run_test(data_t *data) +{ + int i; + drmModeConnectorPtr c; + uint32_t connector_id = 0; + + for (i = 0; i < data->resources->count_connectors; i++) { + connector_id = data->resources->connectors[i]; + c = drmModeGetConnector(data->drm_fd, connector_id); + + if (c->connector_type != DRM_MODE_CONNECTOR_eDP || + c->connection != DRM_MODE_CONNECTED) + continue; + + basic_sink_crc_check(data, connector_id); + return; + } + + fprintf(stderr, "no eDP with CRC support found\n"); + igt_fail(1); +} + +igt_simple_main +{ + data_t data = {}; + + igt_skip_on_simulation(); + + data.drm_fd = drm_open_any(); + + igt_set_vt_graphics_mode(); + + data.resources = drmModeGetResources(data.drm_fd); + igt_assert(data.resources); + + run_test(&data); + + drmModeFreeResources(data.resources); +}