From patchwork Tue Jan 26 13:29:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 8121941 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 836159F1C0 for ; Tue, 26 Jan 2016 13:29:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A38BD20256 for ; Tue, 26 Jan 2016 13:29:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B31EA20253 for ; Tue, 26 Jan 2016 13:29:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 342B46E5BF; Tue, 26 Jan 2016 05:29:27 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id E473A6E5BF for ; Tue, 26 Jan 2016 05:29:22 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 26 Jan 2016 05:29:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,350,1449561600"; d="scan'208";a="889472133" Received: from svosulli-mobl3.amr.corp.intel.com (HELO panetone.amr.corp.intel.com) ([10.252.193.19]) by fmsmga001.fm.intel.com with ESMTP; 26 Jan 2016 05:29:21 -0800 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 26 Jan 2016 11:29:04 -0200 Message-Id: <1453814944-15373-6-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.7.0.rc3 In-Reply-To: <1453814944-15373-1-git-send-email-paulo.r.zanoni@intel.com> References: <1453814944-15373-1-git-send-email-paulo.r.zanoni@intel.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH igt 6/6] tests/igt_fb: rename igt_get_all_formats to igt_get_all_cairo_formats 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.2 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 I recently had this discussion with Daniel where I didn't want to use igt_drm_format_to_bpp() because it uses the format_desc array, and igt_fb currently assumes that all the format_desc formats have a matching valid Cairo format, so I wouldn't be able to easily add formats such as ARGB2101010. The function that has the assumption mentioned above is igt_get_all_formats: its current users call igt_get_all_formats, and then call cairo-dependent functions, such as igt_get_cairo_ctx on the returned formats. In order to document the current behavior and prevent any problems in case we start adding new formats without matching Cairo versions to format_desc, rename igt_get_all_formats to igt_get_all_cairo_formats and make it explicitly check for CAIRO_FORMAT_INVALID. Requested-by: Daniel Vetter Signed-off-by: Paulo Zanoni --- lib/igt_fb.c | 22 ++++++++++++++-------- lib/igt_fb.h | 2 +- tests/kms_atomic.c | 2 +- tests/kms_render.c | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 0462c35..5f23136 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -1141,28 +1141,34 @@ const char *igt_format_str(uint32_t drm_format) } /** - * igt_get_all_formats: + * igt_get_all_cairo_formats: * @formats: pointer to pointer to store the allocated formats array * @format_count: pointer to integer to store the size of the allocated array * - * This functions returns an array of all the drm fourcc codes supported by this - * library. + * This functions returns an array of all the drm fourcc codes supported by + * cairo and this library. */ -void igt_get_all_formats(const uint32_t **formats, int *format_count) +void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count) { static uint32_t *drm_formats; + static int n_formats; if (!drm_formats) { struct format_desc_struct *f; uint32_t *format; - drm_formats = calloc(ARRAY_SIZE(format_desc), - sizeof(*drm_formats)); + n_formats = 0; + for_each_format(f) + if (f->cairo_id != CAIRO_FORMAT_INVALID) + n_formats++; + + drm_formats = calloc(n_formats, sizeof(*drm_formats)); format = &drm_formats[0]; for_each_format(f) - *format++ = f->drm_id; + if (f->cairo_id != CAIRO_FORMAT_INVALID) + *format++ = f->drm_id; } *formats = drm_formats; - *format_count = ARRAY_SIZE(format_desc); + *format_count = n_formats; } diff --git a/lib/igt_fb.h b/lib/igt_fb.h index 064027c..4e6a769 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -117,7 +117,7 @@ int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align, uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth); uint32_t igt_drm_format_to_bpp(uint32_t drm_format); const char *igt_format_str(uint32_t drm_format); -void igt_get_all_formats(const uint32_t **formats, int *format_count); +void igt_get_all_cairo_formats(const uint32_t **formats, int *format_count); #endif /* __IGT_FB_H__ */ diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c index 501093c..c8b8b78 100644 --- a/tests/kms_atomic.c +++ b/tests/kms_atomic.c @@ -843,7 +843,7 @@ static uint32_t plane_get_igt_format(struct kms_atomic_plane_state *plane) plane_kms = drmModeGetPlane(plane->state->desc->fd, plane->obj); igt_assert(plane_kms); - igt_get_all_formats(&igt_formats, &num_igt_formats); + igt_get_all_cairo_formats(&igt_formats, &num_igt_formats); for (i = 0; i < num_igt_formats; i++) { int j; diff --git a/tests/kms_render.c b/tests/kms_render.c index 467d71f..e0a2b58 100644 --- a/tests/kms_render.c +++ b/tests/kms_render.c @@ -173,7 +173,7 @@ static void test_connector(const char *test_name, int format_count; int i; - igt_get_all_formats(&formats, &format_count); + igt_get_all_cairo_formats(&formats, &format_count); for (i = 0; i < format_count; i++) { if (intel_gen(intel_get_drm_devid(drm_fd)) < 4 && formats[i] == DRM_FORMAT_XRGB2101010) {