diff mbox

[i-g-t,4/4] kms_plane_scaling: Find the image regardless how the test is run

Message ID 1430819603-492-4-git-send-email-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tvrtko Ursulin May 5, 2015, 9:53 a.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

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 <tvrtko.ursulin@intel.com>
Cc: chandra konduru <chandra.konduru@intel.com>
Cc: Thomas Wood <thomas.wood@intel.com>
---
 lib/igt_fb.c              | 17 ++++++++++++++---
 lib/igt_fb.h              |  2 ++
 tests/kms_plane_scaling.c |  7 ++++++-
 3 files changed, 22 insertions(+), 4 deletions(-)

Comments

Chandra Konduru May 5, 2015, 5:22 p.m. UTC | #1
> -----Original Message-----
> From: Tvrtko Ursulin [mailto:tvrtko.ursulin@linux.intel.com]
> Sent: Tuesday, May 05, 2015 2:53 AM
> To: Intel-gfx@lists.freedesktop.org
> Cc: Ursulin, Tvrtko; Konduru, Chandra; Wood, Thomas
> Subject: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how the
> test is run
> 
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> 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.
As image size is required in other tests too, in recent patch
I added igt_get_image_size() which can be used here
instead duplication.

> 
> v2: Export Cairo read callback instead of duplicating it. (Thomas Wood)
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: chandra konduru <chandra.konduru@intel.com>
> Cc: Thomas Wood <thomas.wood@intel.com>
> ---
>  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);

Above can be replaced with
	igt_get_image_size(FILE_NAME, &d->image_w, &d->image_h);

> 
>  		d->fb_id2 = igt_create_fb(d->drm_fd,
>  				d->image_w, d->image_h,
> --
> 2.3.5
Tvrtko Ursulin May 6, 2015, 9:29 a.m. UTC | #2
On 05/05/2015 06:22 PM, Konduru, Chandra wrote:
>> -----Original Message-----
>> From: Tvrtko Ursulin [mailto:tvrtko.ursulin@linux.intel.com]
>> Sent: Tuesday, May 05, 2015 2:53 AM
>> To: Intel-gfx@lists.freedesktop.org
>> Cc: Ursulin, Tvrtko; Konduru, Chandra; Wood, Thomas
>> Subject: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how the
>> test is run
>>
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> 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.
> As image size is required in other tests too, in recent patch
> I added igt_get_image_size() which can be used here
> instead duplication.

Ok, please do, I only attempted to fix it along the way since it did not 
run for me. And at the time there was no igt_get_image_size.

Regards,

Tvrtko
Chandra Konduru May 6, 2015, 6:17 p.m. UTC | #3
> -----Original Message-----
> From: Tvrtko Ursulin [mailto:tvrtko.ursulin@linux.intel.com]
> Sent: Wednesday, May 06, 2015 2:29 AM
> To: Konduru, Chandra; Intel-gfx@lists.freedesktop.org
> Cc: Ursulin, Tvrtko; Wood, Thomas
> Subject: Re: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how
> the test is run
> 
> 
> On 05/05/2015 06:22 PM, Konduru, Chandra wrote:
> >> -----Original Message-----
> >> From: Tvrtko Ursulin [mailto:tvrtko.ursulin@linux.intel.com]
> >> Sent: Tuesday, May 05, 2015 2:53 AM
> >> To: Intel-gfx@lists.freedesktop.org
> >> Cc: Ursulin, Tvrtko; Konduru, Chandra; Wood, Thomas
> >> Subject: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image
> >> regardless how the test is run
> >>
> >> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >>
> >> 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.
> > As image size is required in other tests too, in recent patch I added
> > igt_get_image_size() which can be used here instead duplication.
> 
> Ok, please do, I only attempted to fix it along the way since it did not run for me.
> And at the time there was no igt_get_image_size.
Yeah, you are right. Sure I have few things to changes to do anyway for adding rotation to kms_plane_scaling.
Along with that, I will make above change. In that case, I presume you drop this patch.
> 
> Regards,
> 
> Tvrtko
Tvrtko Ursulin May 7, 2015, 8:54 a.m. UTC | #4
On 05/06/2015 07:17 PM, Konduru, Chandra wrote:
>> -----Original Message-----
>> From: Tvrtko Ursulin [mailto:tvrtko.ursulin@linux.intel.com]
>> Sent: Wednesday, May 06, 2015 2:29 AM
>> To: Konduru, Chandra; Intel-gfx@lists.freedesktop.org
>> Cc: Ursulin, Tvrtko; Wood, Thomas
>> Subject: Re: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image regardless how
>> the test is run
>>
>>
>> On 05/05/2015 06:22 PM, Konduru, Chandra wrote:
>>>> -----Original Message-----
>>>> From: Tvrtko Ursulin [mailto:tvrtko.ursulin@linux.intel.com]
>>>> Sent: Tuesday, May 05, 2015 2:53 AM
>>>> To: Intel-gfx@lists.freedesktop.org
>>>> Cc: Ursulin, Tvrtko; Konduru, Chandra; Wood, Thomas
>>>> Subject: [PATCH i-g-t 4/4] kms_plane_scaling: Find the image
>>>> regardless how the test is run
>>>>
>>>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>>>
>>>> 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.
>>> As image size is required in other tests too, in recent patch I added
>>> igt_get_image_size() which can be used here instead duplication.
>>
>> Ok, please do, I only attempted to fix it along the way since it did not run for me.
>> And at the time there was no igt_get_image_size.
> Yeah, you are right. Sure I have few things to changes to do anyway for adding rotation to kms_plane_scaling.
> Along with that, I will make above change. In that case, I presume you drop this patch.

Dropping happily.

Regards,

Tvrtko
diff mbox

Patch

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,