From patchwork Fri May 16 13:07:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: oscar.mateo@intel.com X-Patchwork-Id: 4191401 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 2B719BFF02 for ; Fri, 16 May 2014 13:12:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BD56202EA for ; Fri, 16 May 2014 13:12:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 60C8820253 for ; Fri, 16 May 2014 13:12:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A350A6E2D7; Fri, 16 May 2014 06:12:36 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 932916E2D7 for ; Fri, 16 May 2014 06:12:35 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 16 May 2014 06:12:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="4.97,1067,1389772800"; d="scan'208"; a="533033728" Received: from omateolo-linux2.iwi.intel.com ([172.28.253.145]) by fmsmga001.fm.intel.com with ESMTP; 16 May 2014 06:12:33 -0700 From: oscar.mateo@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 16 May 2014 14:07:11 +0100 Message-Id: <1400245632-12928-1-git-send-email-oscar.mateo@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1400238531-10414-1-git-send-email-oscar.mateo@intel.com> References: <1400238531-10414-1-git-send-email-oscar.mateo@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/2] lib/igt_fb: igt_create_fb_with_bo_size 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.8 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 From: Oscar Mateo Useful for testing bigger/smaller fb-wrapped buffer objects. Cc: Ville Syrjälä Signed-off-by: Oscar Mateo --- lib/igt_fb.c | 45 ++++++++++++++++++++++++++++++++++++++------- lib/igt_fb.h | 3 +++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 2149fcd..f43af93 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -76,7 +76,8 @@ static struct format_desc_struct { /* helpers to create nice-looking framebuffers */ static int create_bo_for_fb(int fd, int width, int height, int bpp, bool tiled, uint32_t *gem_handle_ret, - unsigned *size_ret, unsigned *stride_ret) + unsigned *size_ret, unsigned *stride_ret, + unsigned bo_size) { uint32_t gem_handle; int size, ret = 0; @@ -106,7 +107,9 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp, size = stride * height; } - gem_handle = gem_create(fd, size); + if (bo_size == 0) + bo_size = size; + gem_handle = gem_create(fd, bo_size); if (tiled) ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X, stride); @@ -376,17 +379,18 @@ void igt_paint_image(cairo_t *cr, const char *filename, } /** - * igt_create_fb: + * igt_create_fb_with_bo_size: * @fd: open i915 drm file descriptor * @width: width of the framebuffer in pixel * @height: height of the framebuffer in pixel * @format: drm fourcc pixel format code * @tiled: X-tiled or linear framebuffer * @fb: pointer to an #igt_fb structure + * @bo_size: size of the backing bo (0 for minimum needed size) * * This function allocates a gem buffer object suitable to back a framebuffer * with the requested properties and then wraps it up in a drm framebuffer - * object. All metadata is stored in @fb. + * object of the requested size. All metadata is stored in @fb. * * The backing storage of the framebuffer is filled with all zeros, i.e. black * for rgb pixel formats. @@ -395,8 +399,9 @@ void igt_paint_image(cairo_t *cr, const char *filename, * The kms id of the created framebuffer on success or a negative error code on * failure. */ -unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, - bool tiled, struct igt_fb *fb) +unsigned int igt_create_fb_with_bo_size(int fd, int width, int height, + uint32_t format, bool tiled, + struct igt_fb *fb, unsigned bo_size) { uint32_t handles[4]; uint32_t pitches[4]; @@ -409,7 +414,7 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, bpp = igt_drm_format_to_bpp(format); ret = create_bo_for_fb(fd, width, height, bpp, tiled, &fb->gem_handle, - &fb->size, &fb->stride); + &fb->size, &fb->stride, bo_size); if (ret < 0) return ret; @@ -435,6 +440,32 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, } /** + * igt_create_fb: + * @fd: open i915 drm file descriptor + * @width: width of the framebuffer in pixel + * @height: height of the framebuffer in pixel + * @format: drm fourcc pixel format code + * @tiled: X-tiled or linear framebuffer + * @fb: pointer to an #igt_fb structure + * + * This function allocates a gem buffer object suitable to back a framebuffer + * with the requested properties and then wraps it up in a drm framebuffer + * object. All metadata is stored in @fb. + * + * The backing storage of the framebuffer is filled with all zeros, i.e. black + * for rgb pixel formats. + * + * Returns: + * The kms id of the created framebuffer on success or a negative error code on + * failure. + */ +unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, + bool tiled, struct igt_fb *fb) +{ + return igt_create_fb_with_bo_size(fd, width, height, format, tiled, fb, 0); +} + +/** * igt_create_color_fb: * @fd: open i915 drm file descriptor * @width: width of the framebuffer in pixel diff --git a/lib/igt_fb.h b/lib/igt_fb.h index e8bb2a8..c6558bf 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -62,6 +62,9 @@ enum igt_text_align { align_hcenter = 0x08, }; +unsigned int igt_create_fb_with_bo_size(int fd, int width, int height, + uint32_t format, bool tiled, + struct igt_fb *fb, unsigned bo_size); unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, bool tiled, struct igt_fb *fb); unsigned int igt_create_color_fb(int fd, int width, int height,