From patchwork Mon Jan 16 07:15:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Praveen Paneri X-Patchwork-Id: 9518195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D3A55601C3 for ; Mon, 16 Jan 2017 07:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3472283CB for ; Mon, 16 Jan 2017 07:10:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9667E2838E; Mon, 16 Jan 2017 07:10:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5CC992838E for ; Mon, 16 Jan 2017 07:10:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B14DC6E23F; Mon, 16 Jan 2017 07:10:16 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9BD546E23F for ; Mon, 16 Jan 2017 07:10:15 +0000 (UTC) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 15 Jan 2017 23:10:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.33,238,1477983600"; d="scan'208"; a="1083471673" Received: from intel-desktop.iind.intel.com ([10.223.82.55]) by orsmga001.jf.intel.com with ESMTP; 15 Jan 2017 23:10:14 -0800 From: Praveen Paneri To: intel-gfx@lists.freedesktop.org Date: Mon, 16 Jan 2017 12:45:45 +0530 Message-Id: <1484550948-8649-2-git-send-email-praveen.paneri@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484550948-8649-1-git-send-email-praveen.paneri@intel.com> References: <1484550948-8649-1-git-send-email-praveen.paneri@intel.com> Cc: Praveen Paneri Subject: [Intel-gfx] [PATCH 2/5] lib/igt_fb: Add helper function for tile_to_mod 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-Virus-Scanned: ClamAV using ClamSMTP igt_get_fb_tile_size function takes modifer as an argument This helper function will let users to convert tiling to modifier and use igt_get_fb_tile_size() Signed-off-by: Praveen Paneri --- lib/igt_fb.c | 27 +++++++++++++++++++++++++++ lib/igt_fb.h | 1 + 2 files changed, 28 insertions(+) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 32e0277..c8e8d3d 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -206,6 +206,33 @@ uint64_t igt_fb_mod_to_tiling(uint64_t modifier) } } +/** + * igt_fb_tiling_to_mod: + * @tiling: DRM framebuffer tiling + * + * This function converts a DRM framebuffer tiling to its corresponding + * modifier constant. + * + * Returns: + * A modifier constant + */ +uint64_t igt_fb_tiling_to_mod(uint64_t tiling) +{ + switch (tiling) { + case I915_TILING_NONE: + return LOCAL_DRM_FORMAT_MOD_NONE; + case I915_TILING_X: + return LOCAL_I915_FORMAT_MOD_X_TILED; + case I915_TILING_Y: + return LOCAL_I915_FORMAT_MOD_Y_TILED; + case I915_TILING_Yf: + return LOCAL_I915_FORMAT_MOD_Yf_TILED; + default: + igt_assert(0); + } +} + + /* helpers to create nice-looking framebuffers */ static int create_bo_for_fb(int fd, int width, int height, uint32_t format, uint64_t tiling, unsigned size, unsigned stride, diff --git a/lib/igt_fb.h b/lib/igt_fb.h index b178eba..6972a80 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -131,6 +131,7 @@ int igt_create_bo_with_dimensions(int fd, int width, int height, uint32_t format bool *is_dumb); uint64_t igt_fb_mod_to_tiling(uint64_t modifier); +uint64_t igt_fb_tiling_to_mod(uint64_t tiling); /* cairo-based painting */ cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb);