From patchwork Tue May 5 09:53:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 6336611 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 5BD72BEEE1 for ; Tue, 5 May 2015 09:53:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73456202FF for ; Tue, 5 May 2015 09:53:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 86FCE20303 for ; Tue, 5 May 2015 09:53:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 175636E489; Tue, 5 May 2015 02:53:33 -0700 (PDT) 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 432526E489 for ; Tue, 5 May 2015 02:53:32 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 05 May 2015 02:53:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,372,1427785200"; d="scan'208";a="489513918" Received: from tursulin-linux.isw.intel.com ([10.102.226.59]) by FMSMGA003.fm.intel.com with ESMTP; 05 May 2015 02:53:30 -0700 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Tue, 5 May 2015 10:53:23 +0100 Message-Id: <1430819603-492-4-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1430819603-492-1-git-send-email-tvrtko.ursulin@linux.intel.com> References: <1430819603-492-1-git-send-email-tvrtko.ursulin@linux.intel.com> Cc: Thomas Wood Subject: [Intel-gfx] [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how the test is run 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=-3.2 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_MED, T_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: Tvrtko Ursulin As it stands running the test like "sudo tests/kms_plane_scaling" does not work. Fix it by using the same method igt_paint_image uses. v2: Export Cairo read callback instead of duplicating it. (Thomas Wood) Signed-off-by: Tvrtko Ursulin Cc: chandra konduru Cc: Thomas Wood --- lib/igt_fb.c | 17 ++++++++++++++--- lib/igt_fb.h | 2 ++ tests/kms_plane_scaling.c | 7 ++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index cc4b8ee..2416e76 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -338,8 +338,18 @@ void igt_paint_test_pattern(cairo_t *cr, int width, int height) igt_assert(!cairo_status(cr)); } -static cairo_status_t -stdio_read_func(void *closure, unsigned char* data, unsigned int size) +/** + * igt_cairo_read_func: + * @closure: callback closure parameter + * @data: callback data parameter + * @size: callback size parameter + * + * Read callback for cairo_image_surface_create_from_png_stream to be used + * in conjuction with igt_fopen_data in order to open data files from IGT + * standard locations. + */ +cairo_status_t +igt_cairo_read_func(void *closure, unsigned char* data, unsigned int size) { if (fread(data, 1, size, (FILE*)closure) != size) return CAIRO_STATUS_READ_ERROR; @@ -369,7 +379,8 @@ void igt_paint_image(cairo_t *cr, const char *filename, f = igt_fopen_data(filename); - image = cairo_image_surface_create_from_png_stream(&stdio_read_func, f); + image = cairo_image_surface_create_from_png_stream(&igt_cairo_read_func, + f); igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS); img_width = cairo_image_surface_get_width(image); diff --git a/lib/igt_fb.h b/lib/igt_fb.h index a07acd2..2da5f0c 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -98,6 +98,8 @@ void igt_write_fb_to_png(int fd, struct igt_fb *fb, const char *filename); int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align, double yspacing, const char *fmt, ...) __attribute__((format (printf, 4, 5))); +cairo_status_t +igt_cairo_read_func(void *closure, unsigned char* data, unsigned int size); /* helpers to handle drm fourcc codes */ uint32_t igt_bpp_depth_to_drm_format(int bpp, int depth); diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c index 00db5cb..272f759 100644 --- a/tests/kms_plane_scaling.c +++ b/tests/kms_plane_scaling.c @@ -210,6 +210,7 @@ static void test_plane_scaling(data_t *d) enum pipe pipe; int valid_tests = 0; int primary_plane_scaling = 0; /* For now */ + FILE* f; igt_require(d->display.has_universal_planes); igt_require(d->num_scalers); @@ -223,11 +224,15 @@ static void test_plane_scaling(data_t *d) mode = igt_output_get_mode(output); /* allocate fb2 with image size */ - image = cairo_image_surface_create_from_png(FILE_NAME); + + f = igt_fopen_data(FILE_NAME); + image = cairo_image_surface_create_from_png_stream( + &igt_cairo_read_func, f); igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS); d->image_w = cairo_image_surface_get_width(image); d->image_h = cairo_image_surface_get_height(image); cairo_surface_destroy(image); + fclose(f); d->fb_id2 = igt_create_fb(d->drm_fd, d->image_w, d->image_h,