From patchwork Wed Dec 13 09:50:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vidya Srinivas X-Patchwork-Id: 10109577 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 1CCB1602C2 for ; Wed, 13 Dec 2017 09:41:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17794290E0 for ; Wed, 13 Dec 2017 09:41:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C60C29139; Wed, 13 Dec 2017 09:41:50 +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 B622D290E0 for ; Wed, 13 Dec 2017 09:41:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60B746E3F6; Wed, 13 Dec 2017 09:41:49 +0000 (UTC) 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 ESMTPS id E59AE6E3F6 for ; Wed, 13 Dec 2017 09:41:47 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Dec 2017 01:41:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,397,1508828400"; d="scan'208";a="186554262" Received: from vsrini4-ubuntu.iind.intel.com ([10.223.25.4]) by fmsmga006.fm.intel.com with ESMTP; 13 Dec 2017 01:41:45 -0800 From: Vidya Srinivas To: intel-gfx@lists.freedesktop.org Date: Wed, 13 Dec 2017 15:20:48 +0530 Message-Id: <1513158652-8912-3-git-send-email-vidya.srinivas@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513158652-8912-1-git-send-email-vidya.srinivas@intel.com> References: <1513158652-8912-1-git-send-email-vidya.srinivas@intel.com> Cc: daniel.vetter@intel.com, Vidya Srinivas Subject: [Intel-gfx] [PATCH i-g-t 2/6] i-g-t: lib: Add plane pixel format support 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 From: Mahesh Kumar This patch adds the following: - Query supported pixel formats from kernel for a given plane. - Get number of supported pixel formats for a plane - Check if format is supported by cairo - Add support to get format name string Signed-off-by: Mahesh Kumar Signed-off-by: Jyoti Yadav Signed-off-by: Vidya Srinivas --- lib/igt_fb.c | 16 ++++++++++++++++ lib/igt_kms.c | 29 +++++++++++++++++++++++++++++ lib/igt_kms.h | 7 +++++++ 3 files changed, 52 insertions(+) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index d4eaed7..21d666d 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -68,6 +68,22 @@ static struct format_desc_struct { DF(XRGB2101010, RGB30, 32, 30), DF(ARGB8888, ARGB32, 32, 32), }; + +const char *igt_get_format_name(uint32_t format) +{ + switch(format) { + case DRM_FORMAT_RGB565: + return "RGB565"; + case DRM_FORMAT_XRGB8888: + return "XRGB8888"; + case DRM_FORMAT_XRGB2101010: + return "XRGB2101010"; + case DRM_FORMAT_ARGB8888: + return "ARGB8888"; + default: + return "Unknown"; + } +} #undef DF #define for_each_format(f) \ diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 223dbe4..cc17f5c 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -3639,3 +3639,32 @@ uint32_t kmstest_get_vbl_flag(uint32_t pipe_id) return pipe_flag; } } + +/** + * igt_is_cairo_supported_format: + * @pixel_format: pixel format to be checked in supported cairo list. + * + * Returns true if pixel format is present in the supported cairo pixel + * format list and returns false if not present/supported in cairo. + */ +bool igt_is_cairo_supported_format(uint32_t pixel_format) +{ + const uint32_t *igt_formats; + int num_igt_formats; + int i; + + igt_get_all_cairo_formats(&igt_formats, &num_igt_formats); + for (i = 0; i < num_igt_formats; i++) { + if (pixel_format == igt_formats[i]) + return true; + } + return false; +} + +int igt_get_format_count_plane(igt_plane_t *plane) +{ + if (plane) + return plane->drm_plane->count_formats; + + return -EINVAL; +} diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 2a480bf..ced7d73 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -389,6 +389,10 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t *plane, void igt_wait_for_vblank(int drm_fd, enum pipe pipe); void igt_wait_for_vblank_count(int drm_fd, enum pipe pipe, int count); +bool igt_is_cairo_supported_format(uint32_t pixel_format); +int igt_get_format_count_plane(igt_plane_t *plane); +const char *igt_get_format_name(uint32_t format); + static inline bool igt_output_is_connected(igt_output_t *output) { /* Something went wrong during probe? */ @@ -486,6 +490,9 @@ static inline bool igt_output_is_connected(igt_output_t *output) for (int j__ = 0; assert(igt_can_fail()), (plane) = &(display)->pipes[(pipe)].planes[j__], \ j__ < (display)->pipes[(pipe)].n_planes; j__++) +#define for_each_format_in_plane(plane, format) \ + for (int k__ = 0; (format) = plane->drm_plane->formats[k__], k__ < plane->drm_plane->count_formats; k__++) + #define IGT_FIXED(i,f) ((i) << 16 | (f)) /**