From patchwork Fri Sep 6 19:08:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 2855001 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 03A9EBF43F for ; Fri, 6 Sep 2013 19:17:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB4FC20319 for ; Fri, 6 Sep 2013 19:17:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C716020318 for ; Fri, 6 Sep 2013 19:17:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5B88E7692 for ; Fri, 6 Sep 2013 12:17: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 8D19AE764C for ; Fri, 6 Sep 2013 12:09:36 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 06 Sep 2013 12:09:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,856,1371106800"; d="scan'208";a="374564982" Received: from unknown (HELO strange.amr.corp.intel.com) ([10.255.14.105]) by orsmga001.jf.intel.com with ESMTP; 06 Sep 2013 12:09:09 -0700 From: Damien Lespiau To: intel-gfx@lists.freedesktop.org Date: Fri, 6 Sep 2013 20:08:44 +0100 Message-Id: <1378494530-3600-7-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1378494530-3600-1-git-send-email-damien.lespiau@intel.com> References: <1378494530-3600-1-git-send-email-damien.lespiau@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 06/12] testdisplay: Map the fb inside paint_color_key() 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: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-6.6 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 So the code for this is self-contained. This goes along the way of reducing the number of global variables in testdisplay. Take the opportunity to unmap the fb after use as well. Signed-off-by: Damien Lespiau --- tests/testdisplay.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/testdisplay.c b/tests/testdisplay.c index c3a0d04..3d696a0 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -82,7 +82,6 @@ unsigned int plane_crtc_id; unsigned int plane_id; int plane_width, plane_height; static const uint32_t SPRITE_COLOR_KEY = 0x00aaaaaa; -uint32_t *fb_ptr; /* * Mode setting with the kernel interfaces is a bit of a chore. @@ -213,6 +212,11 @@ static void paint_color_key(struct kmstest_fb *fb_info) { int i, j; + uint32_t *fb_ptr; + + fb_ptr = gem_mmap(drm_fd, fb_info->gem_handle, + fb_info->size, PROT_READ | PROT_WRITE); + igt_assert(fb_ptr); for (i = crtc_y; i < crtc_y + crtc_h; i++) for (j = crtc_x; j < crtc_x + crtc_w; j++) { @@ -221,6 +225,8 @@ paint_color_key(struct kmstest_fb *fb_info) offset = (i * fb_info->stride / 4) + j; fb_ptr[offset] = SPRITE_COLOR_KEY; } + + munmap(fb_ptr, fb_info->size); } static void paint_image(cairo_t *cr, const char *file) @@ -358,10 +364,6 @@ set_mode(struct connector *c) fb_id = kmstest_create_fb(drm_fd, width, height, bpp, depth, enable_tiling, &fb_info); paint_output_info(c, &fb_info); - - fb_ptr = gem_mmap(drm_fd, fb_info.gem_handle, - fb_info.size, PROT_READ | PROT_WRITE); - igt_assert(fb_ptr); paint_color_key(&fb_info); gem_close(drm_fd, fb_info.gem_handle);