From patchwork Wed Mar 2 14:00:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 8480821 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 6B098C0553 for ; Wed, 2 Mar 2016 14:01:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B92522038A for ; Wed, 2 Mar 2016 14:01:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CAC3F202AE for ; Wed, 2 Mar 2016 14:01:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD65A6E87F; Wed, 2 Mar 2016 14:01:22 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0695B6E87B for ; Wed, 2 Mar 2016 14:01:16 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id p65so9809832wmp.1 for ; Wed, 02 Mar 2016 06:01:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Qor8lPjXKUcOYZAcduNAimpMcuGJWwc/H2pPpUEdOLs=; b=JOjbGyZ5Q9yhuqpH+pir+T0BcOazGAAGkI7CegNFD0U8veqmqciD+e0S9J5jln08SW Dl312i4FXRxWyCe34R2VtMT24NsCN6wYb15/rhZ1NOA8/LMQlquz46iwr3h5b6HMF++D KLGmMvrubSVVMZOUFwmrzVuRLoycTdJKfcoxKG9TG1nlXOootied9i/yVTCDC7wJiCBv c1itnW9E+wjv6j+LkC70QNyDfc6n9m8dGCOKyyrJbydfm7BJj9yk6junTVjz83uHpca3 qeCG9SVeB+UFEozcldsIcz118zHSiqMGaSl0L9e9MraIdJ1yjsomy0MH9xcVNfQRrhvQ DpAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Qor8lPjXKUcOYZAcduNAimpMcuGJWwc/H2pPpUEdOLs=; b=LK1Lo7LNYbKMJE+X3G0Ijqd2rgo34Zzsznw8j9sKcWNIgmbn9PhKB4ye/qzt/SMRb1 yI44AJHwIHXlSggf5hKeAJoMk/yM6SAAtuK4lU15zfSJuWMDbsybXvKq45n2orZ6iyZL 3iFwVVBQFxZSaYdI2nrwu/o7iRoEWrctRNZB6Fqq5Hj66PBc76yfKcWwXVqdEYRlhZYk Vb7GeKWRsliB1WeEpiv/rEY0n90eFq+qSOUs7Iap49WNqKrL+Dh21AHvda+h1RVY9DCa DnH3KMelJT5eXwQwzl30dLCOVi5RmMo0z+MnYZ6/0u/K2fWCEEngNgyNAe8h/NmKAZ25 rXLQ== X-Gm-Message-State: AD7BkJIl+7pwvju/LBvlmL9FMfBZQPflE+dO6jR41TmotbEzp2dAX5WMvxYMmwx5CMKw6A== X-Received: by 10.28.128.138 with SMTP id b132mr81230wmd.26.1456927274306; Wed, 02 Mar 2016 06:01:14 -0800 (PST) Received: from cizrna.lan ([109.72.12.223]) by smtp.gmail.com with ESMTPSA id e19sm4359876wmd.1.2016.03.02.06.01.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 06:01:13 -0800 (PST) From: Tomeu Vizoso To: Intel GFX discussion Date: Wed, 2 Mar 2016 15:00:15 +0100 Message-Id: <1456927221-32421-9-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456927221-32421-1-git-send-email-tomeu.vizoso@collabora.com> References: <1456927221-32421-1-git-send-email-tomeu.vizoso@collabora.com> Cc: Daniel Stone , Tomeu Vizoso , Micah Fedke , Gustavo Padovan , Emil Velikov Subject: [Intel-gfx] [i-g-t PATCH v1 08/14] lib: Add igt_create_bo_with_dimensions 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_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 igt_create_bo_with_dimensions() is intended to abstract differences between drivers in buffer object creation. The driver-specific ioctls will be called if the driver that is being tested can satisfy the needs of the calling subtest, or it will be skipped otherwise. Signed-off-by: Tomeu Vizoso --- lib/igt_fb.c | 83 ++++++++++++++++++++++++++++++++++++++++++------------------ lib/igt_fb.h | 6 +++++ 2 files changed, 65 insertions(+), 24 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index cd1605308308..0a3526f4e4ea 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -174,30 +174,66 @@ void igt_calc_fb_size(int fd, int width, int height, int bpp, uint64_t tiling, *size_ret = size; } +int igt_create_bo_with_dimensions(int fd, int width, int height, + uint32_t format, uint64_t modifier, + unsigned stride, unsigned *size_ret, + unsigned *stride_ret, bool *is_dumb) +{ + int bpp = igt_drm_format_to_bpp(format); + int bo; + + igt_assert((modifier && stride) || (!modifier && !stride)); + + if (modifier) { + unsigned size, calculated_stride; + + igt_calc_fb_size(fd, width, height, bpp, modifier, &size, + &calculated_stride); + if (stride == 0) + stride = calculated_stride; + + if (is_dumb) + *is_dumb = false; + + if (is_i915_device(fd)) { + + bo = gem_create(fd, size); + gem_set_tiling(fd, bo, modifier, stride); + + if (size_ret) + *size_ret = size; + + if (stride_ret) + *stride_ret = stride; + + return bo; + } else { + bool driver_has_tiling_support = false; + + igt_require(driver_has_tiling_support); + return -EINVAL; + } + } else { + if (is_dumb) + *is_dumb = true; + return dumb_create(fd, width, height, bpp, stride_ret, size_ret); + } +} + /* helpers to create nice-looking framebuffers */ -static int create_bo_for_fb(int fd, int width, int height, int bpp, +static int create_bo_for_fb(int fd, int width, int height, uint32_t format, uint64_t tiling, unsigned bo_size, unsigned bo_stride, uint32_t *gem_handle_ret, - unsigned *size_ret, unsigned *stride_ret) + unsigned *size_ret, unsigned *stride_ret, + bool *is_dumb) { uint32_t gem_handle; int ret = 0; - unsigned size, stride; - - igt_calc_fb_size(fd, width, height, bpp, tiling, &size, &stride); - if (bo_size == 0) - bo_size = size; - if (bo_stride == 0) - bo_stride = stride; - - gem_handle = gem_create(fd, bo_size); - if (tiling == LOCAL_I915_FORMAT_MOD_X_TILED) - ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X, - bo_stride); + gem_handle = igt_create_bo_with_dimensions(fd, width, height, format, + tiling, bo_stride, size_ret, + stride_ret, is_dumb); - *stride_ret = bo_stride; - *size_ret = bo_size; *gem_handle_ret = gem_handle; return ret; @@ -501,17 +537,14 @@ igt_create_fb_with_bo_size(int fd, int width, int height, unsigned bo_stride) { uint32_t fb_id; - int bpp; memset(fb, 0, sizeof(*fb)); - bpp = igt_drm_format_to_bpp(format); - - igt_debug("%s(width=%d, height=%d, format=0x%x [bpp=%d], tiling=0x%"PRIx64", size=%d)\n", - __func__, width, height, format, bpp, tiling, bo_size); - do_or_die(create_bo_for_fb(fd, width, height, bpp, tiling, bo_size, + igt_debug("%s(width=%d, height=%d, format=0x%x, tiling=0x%"PRIx64", size=%d)\n", + __func__, width, height, format, tiling, bo_size); + do_or_die(create_bo_for_fb(fd, width, height, format, tiling, bo_size, bo_stride, &fb->gem_handle, &fb->size, - &fb->stride)); + &fb->stride, &fb->is_dumb)); igt_debug("%s(handle=%d, pitch=%d)\n", __func__, fb->gem_handle, fb->stride); @@ -860,6 +893,7 @@ struct fb_blit_upload { uint32_t handle; unsigned size, stride; uint8_t *map; + bool is_dumb; } linear; }; @@ -928,7 +962,8 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb) LOCAL_DRM_FORMAT_MOD_NONE, 0, 0, &blit->linear.handle, &blit->linear.size, - &blit->linear.stride); + &blit->linear.stride, + &blit->linear.is_dumb); igt_assert(ret == 0); diff --git a/lib/igt_fb.h b/lib/igt_fb.h index 4e6a76947c18..10e59deebe88 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -47,6 +47,7 @@ typedef struct _cairo cairo_t; struct igt_fb { uint32_t fb_id; uint32_t gem_handle; + bool is_dumb; uint32_t drm_format; int width; int height; @@ -97,6 +98,11 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, uint32_t format, uint64_t tiling); void igt_remove_fb(int fd, struct igt_fb *fb); +int igt_create_bo_with_dimensions(int fd, int width, int height, uint32_t format, + uint64_t modifier, unsigned stride, + unsigned *stride_out, unsigned *size_out, + bool *is_dumb); + /* cairo-based painting */ cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb); void igt_paint_color(cairo_t *cr, int x, int y, int w, int h,