From patchwork Wed Mar 25 21:50:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 6095311 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA80BBF90F for ; Wed, 25 Mar 2015 21:51:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4DA020379 for ; Wed, 25 Mar 2015 21:51:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 44BA32035E for ; Wed, 25 Mar 2015 21:51:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BDA2B6E93D; Wed, 25 Mar 2015 14:51:49 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qg0-f52.google.com (mail-qg0-f52.google.com [209.85.192.52]) by gabe.freedesktop.org (Postfix) with ESMTP id 01A136E93B for ; Wed, 25 Mar 2015 14:51:49 -0700 (PDT) Received: by qgfa8 with SMTP id a8so63254693qgf.0 for ; Wed, 25 Mar 2015 14:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5GulFGLrKiDUjKwzcle8deSm740TjhTllnv+TW47qX8=; b=uGNrTENGFlMEZhjmbpgNpAs5BDGcNGEtNK+XpuNJLgq4gM59o3blmJqbAKPGvY0EMk J6MXzX9xbTT6taSSQZcLI2EHJntOQGkatWqGqcFIY7Zv0WR1aHJWPrw+3b68r/rt7mEd j6NimLIQ9HDrDfCqN6hShPI+tBkpnQwxjkOha3qu2uja0momSIZ/+vbOErixvtCOz2zq ILC5ClvZj+vUnOMBwgDP+RWrH+/IwEVwzEA4jf1XbNvtp/OAIirjP5BZ7cjqBJ48Fy52 sMTxCRebV7vAoZ1YW7ujMIklSlMDI/mrZksD3KUzpLKCczYPyP3WB9qDkV98qFWe27q4 kbNA== X-Received: by 10.140.232.68 with SMTP id d65mr11508193qhc.99.1427320308707; Wed, 25 Mar 2015 14:51:48 -0700 (PDT) Received: from localhost.localdomain ([187.121.139.226]) by mx.google.com with ESMTPSA id b52sm2308334qgb.16.2015.03.25.14.51.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Mar 2015 14:51:48 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Wed, 25 Mar 2015 18:50:38 -0300 Message-Id: <1427320239-25667-6-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427320239-25667-1-git-send-email-przanoni@gmail.com> References: <1427320239-25667-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 6/7] tests/kms_fbc_crc: remove redundant information from data_t 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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: Paulo Zanoni While it is nice to have shorter names for the most-accessed variables, it makes the code more difficult to read since it's not clear to the code reader whether that "gem_handle" is from some FB or something else. The reader also has to audit the code to see if, for example, the value of data->handle[0] stays consistent with data->fb[0].gem_handle all the tame or if at some point the value is replaced with something else. So remove the redundant information, making it explicit that we're using the gem handles and FB IDs of the framebuffers all the time. Signed-off-by: Paulo Zanoni --- tests/kms_fbc_crc.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c index f1888c4..abdc065 100644 --- a/tests/kms_fbc_crc.c +++ b/tests/kms_fbc_crc.c @@ -61,13 +61,11 @@ typedef struct { drm_intel_bufmgr *bufmgr; drm_intel_context *ctx[2]; uint32_t devid; - uint32_t handle[2]; igt_display_t display; igt_output_t *output; enum pipe pipe; igt_plane_t *primary; struct igt_fb fb[2]; - uint32_t fb_id[2]; } data_t; static const char *test_mode_str(enum test_mode mode) @@ -216,14 +214,14 @@ static void test_crc(data_t *data, enum test_mode mode) uint32_t crtc_id = data->output->config.crtc->crtc_id; igt_pipe_crc_t *pipe_crc = data->pipe_crc; igt_crc_t crc; - uint32_t handle = data->handle[0]; + uint32_t handle = data->fb[0].gem_handle; igt_assert(fbc_enabled(data)); if (mode >= TEST_PAGE_FLIP_AND_MMAP_CPU) { - handle = data->handle[1]; + handle = data->fb[1].gem_handle; igt_assert(drmModePageFlip(data->drm_fd, crtc_id, - data->fb_id[1], 0, NULL) == 0); + data->fb[1].fb_id, 0, NULL) == 0); igt_assert(wait_for_fbc_enabled(data)); } @@ -232,7 +230,7 @@ static void test_crc(data_t *data, enum test_mode mode) void *ptr; case TEST_PAGE_FLIP: igt_assert(drmModePageFlip(data->drm_fd, crtc_id, - data->fb_id[1], 0, NULL) == 0); + data->fb[1].fb_id, 0, NULL) == 0); break; case TEST_MMAP_CPU: case TEST_PAGE_FLIP_AND_MMAP_CPU: @@ -314,24 +312,21 @@ static bool prepare_test(data_t *data, enum test_mode test_mode) igt_output_t *output = data->output; drmModeModeInfo *mode; igt_pipe_crc_t *pipe_crc; + int rc; data->primary = igt_output_get_plane(data->output, IGT_PLANE_PRIMARY); mode = igt_output_get_mode(data->output); - data->fb_id[0] = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, - DRM_FORMAT_XRGB8888, - LOCAL_I915_FORMAT_MOD_X_TILED, - 0.0, 0.0, 0.0, &data->fb[0]); - igt_assert(data->fb_id[0]); - data->fb_id[1] = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, - DRM_FORMAT_XRGB8888, - LOCAL_I915_FORMAT_MOD_X_TILED, - 0.1, 0.1, 0.1, - &data->fb[1]); - igt_assert(data->fb_id[1]); - - data->handle[0] = data->fb[0].gem_handle; - data->handle[1] = data->fb[1].gem_handle; + rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + LOCAL_I915_FORMAT_MOD_X_TILED, + 0.0, 0.0, 0.0, &data->fb[0]); + igt_assert(rc); + rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + LOCAL_I915_FORMAT_MOD_X_TILED, + 0.1, 0.1, 0.1, &data->fb[1]); + igt_assert(rc); /* scanout = fb[1] */ igt_plane_set_fb(data->primary, &data->fb[1]); @@ -372,10 +367,10 @@ static bool prepare_test(data_t *data, enum test_mode test_mode) * Disable FBC RT address for both contexts * (by "rendering" to a non-scanout buffer). */ - exec_nop(data, data->handle[0], data->ctx[1]); - exec_nop(data, data->handle[0], data->ctx[0]); - exec_nop(data, data->handle[0], data->ctx[1]); - exec_nop(data, data->handle[0], data->ctx[0]); + exec_nop(data, data->fb[0].gem_handle, data->ctx[1]); + exec_nop(data, data->fb[0].gem_handle, data->ctx[0]); + exec_nop(data, data->fb[0].gem_handle, data->ctx[1]); + exec_nop(data, data->fb[0].gem_handle, data->ctx[0]); } /* scanout = fb[0] */