Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2018-02-01 Thread Srivatsa, Anusha


>-Original Message-
>From: Vivi, Rodrigo
>Sent: Tuesday, December 19, 2017 1:50 PM
>To: Srivatsa, Anusha 
>Cc: Daniel Vetter ; Strano, Luis ;
>Latvala, Petri ; Lofstedt, Marta
>; Saarinen, Jani ; intel-gfx
>; Joseph Garvey 
>Subject: Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal 
>flip
>subtest.
>
>On Tue, Dec 19, 2017 at 12:20:18AM +, Srivatsa, Anusha wrote:
>>
>>
>> >-Original Message-
>> >From: daniel.vet...@ffwll.ch [mailto:daniel.vet...@ffwll.ch] On
>> >Behalf Of Daniel Vetter
>> >Sent: Thursday, December 14, 2017 2:14 AM
>> >To: Srivatsa, Anusha ; Strano, Luis
>> >; Latvala, Petri ;
>> >Lofstedt, Marta ; Saarinen, Jani
>> >
>> >Cc: intel-gfx ; Joseph Garvey
>> >
>> >Subject: Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add
>> >horizontal flip subtest.
>> >
>> >On Thu, Nov 23, 2017 at 12:05 AM, Anusha Srivatsa
>> >
>> >wrote:
>> >> From: Joseph Garvey 
>> >>
>> >> Test that horizontal flip works with supported rotations. Includes
>> >> a fix for the unrotated fb which was not being positioned correctly
>> >> with portrait and landscape rectangles.
>> >>
>> >> v2:(from Anusha)
>> >> - Change 180 degree rotation to follow the rest, use igt_swap(),
>> >> make flip variable a bool. Format the patch correctly (Ville, Petri
>> >> Latvala)
>> >>
>> >> v3: (From Anusha)
>> >> - Correct the name of subtests in order to avoid duplication of
>> >> names
>> >> (Arek)
>> >>
>> >> Signed-off-by: Anusha Srivatsa 
>> >> Signed-off-by: Joseph Garvey 
>> >> Cc: Ville Syrjälä 
>> >> Cc: Petri Latvala 
>> >> Cc: Arkadiusz Hiler 
>> >
>> >I didn't see this patch fly by originally, but now Marta pointed out
>> >that this skips everywhere. We need to rework it.
>> >
>> >General principle is that in kms tests we should _not_ have any
>> >platform/feature checks encoded in the test. Instead, the testcase
>> >should check properties to figure out whether something should work or not.
>> >
>> >
>> >> ---
>> >>  lib/igt_kms.c|   2 +-
>> >>  lib/igt_kms.h|   5 ++
>> >>  tests/kms_rotation_crc.c | 198
>> >> +--
>> >>  3 files changed, 164 insertions(+), 41 deletions(-)
>> >>
>> >> diff --git a/lib/igt_kms.c b/lib/igt_kms.c index a572fc6..3034e44
>> >> 100644
>> >> --- a/lib/igt_kms.c
>> >> +++ b/lib/igt_kms.c
>> >> @@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb,
>> >> igt_plane_t *plane,
>> >>
>> >>  static const char *rotation_name(igt_rotation_t rotation)  {
>> >> -   switch (rotation) {
>> >> +   switch (rotation & IGT_ROTATION_MASK) {
>> >> case IGT_ROTATION_0:
>> >> return "0°";
>> >> case IGT_ROTATION_90:
>> >> diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 8dc118c..b83a828
>> >> 100644
>> >> --- a/lib/igt_kms.h
>> >> +++ b/lib/igt_kms.h
>> >> @@ -281,8 +281,13 @@ typedef enum {
>> >> IGT_ROTATION_90  = 1 << 1,
>> >> IGT_ROTATION_180 = 1 << 2,
>> >> IGT_ROTATION_270 = 1 << 3,
>> >> +   IGT_REFLECT_X= 1 << 4,
>> >> +   IGT_REFLECT_Y= 1 << 5,
>> >>  } igt_rotation_t;
>> >>
>> >> +#define IGT_ROTATION_MASK \
>> >> +   (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 |
>> >> +IGT_ROTATION_270)
>> >> +
>> >>  typedef struct {
>> >> /*< private >*/
>> >> igt_pipe_t *pipe;
>> >> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
>> >> index
>> >> 5aec8fa..9e13667 100644
>> >> --- a/tests/kms_rotation_crc.c
>> >> +++ b/tests/kms_rotation_crc.c
>> >> @@ -32,6 +32,7 @@ typedef struct {
>> >> igt_display_t display;
>> >> struct igt_fb fb;
>> >> struct igt_fb fb_reference;
>> >> +   struct igt_fb fb_unrotated;
>> >> struct igt_fb fb_modeset;
>> >> struct igt_f

Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-12-19 Thread Rodrigo Vivi
On Tue, Dec 19, 2017 at 12:20:18AM +, Srivatsa, Anusha wrote:
> 
> 
> >-Original Message-
> >From: daniel.vet...@ffwll.ch [mailto:daniel.vet...@ffwll.ch] On Behalf Of 
> >Daniel
> >Vetter
> >Sent: Thursday, December 14, 2017 2:14 AM
> >To: Srivatsa, Anusha ; Strano, Luis
> >; Latvala, Petri ; Lofstedt,
> >Marta ; Saarinen, Jani 
> >Cc: intel-gfx ; Joseph Garvey
> >
> >Subject: Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal 
> >flip
> >subtest.
> >
> >On Thu, Nov 23, 2017 at 12:05 AM, Anusha Srivatsa 
> >wrote:
> >> From: Joseph Garvey 
> >>
> >> Test that horizontal flip works with supported rotations. Includes a
> >> fix for the unrotated fb which was not being positioned correctly with
> >> portrait and landscape rectangles.
> >>
> >> v2:(from Anusha)
> >> - Change 180 degree rotation to follow the rest, use igt_swap(), make
> >> flip variable a bool. Format the patch correctly (Ville, Petri
> >> Latvala)
> >>
> >> v3: (From Anusha)
> >> - Correct the name of subtests in order to avoid duplication of names
> >> (Arek)
> >>
> >> Signed-off-by: Anusha Srivatsa 
> >> Signed-off-by: Joseph Garvey 
> >> Cc: Ville Syrjälä 
> >> Cc: Petri Latvala 
> >> Cc: Arkadiusz Hiler 
> >
> >I didn't see this patch fly by originally, but now Marta pointed out that 
> >this skips
> >everywhere. We need to rework it.
> >
> >General principle is that in kms tests we should _not_ have any 
> >platform/feature
> >checks encoded in the test. Instead, the testcase should check properties to
> >figure out whether something should work or not.
> >
> >
> >> ---
> >>  lib/igt_kms.c|   2 +-
> >>  lib/igt_kms.h|   5 ++
> >>  tests/kms_rotation_crc.c | 198
> >> +--
> >>  3 files changed, 164 insertions(+), 41 deletions(-)
> >>
> >> diff --git a/lib/igt_kms.c b/lib/igt_kms.c index a572fc6..3034e44
> >> 100644
> >> --- a/lib/igt_kms.c
> >> +++ b/lib/igt_kms.c
> >> @@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb,
> >> igt_plane_t *plane,
> >>
> >>  static const char *rotation_name(igt_rotation_t rotation)  {
> >> -   switch (rotation) {
> >> +   switch (rotation & IGT_ROTATION_MASK) {
> >> case IGT_ROTATION_0:
> >> return "0°";
> >> case IGT_ROTATION_90:
> >> diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 8dc118c..b83a828
> >> 100644
> >> --- a/lib/igt_kms.h
> >> +++ b/lib/igt_kms.h
> >> @@ -281,8 +281,13 @@ typedef enum {
> >> IGT_ROTATION_90  = 1 << 1,
> >> IGT_ROTATION_180 = 1 << 2,
> >> IGT_ROTATION_270 = 1 << 3,
> >> +   IGT_REFLECT_X= 1 << 4,
> >> +   IGT_REFLECT_Y= 1 << 5,
> >>  } igt_rotation_t;
> >>
> >> +#define IGT_ROTATION_MASK \
> >> +   (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 |
> >> +IGT_ROTATION_270)
> >> +
> >>  typedef struct {
> >> /*< private >*/
> >> igt_pipe_t *pipe;
> >> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c index
> >> 5aec8fa..9e13667 100644
> >> --- a/tests/kms_rotation_crc.c
> >> +++ b/tests/kms_rotation_crc.c
> >> @@ -32,6 +32,7 @@ typedef struct {
> >> igt_display_t display;
> >> struct igt_fb fb;
> >> struct igt_fb fb_reference;
> >> +   struct igt_fb fb_unrotated;
> >> struct igt_fb fb_modeset;
> >> struct igt_fb fb_flip;
> >> igt_crc_t ref_crc;
> >> @@ -43,8 +44,59 @@ typedef struct {
> >> uint32_t override_fmt;
> >> uint64_t override_tiling;
> >> bool flips;
> >> +   int devid;
> >>  } data_t;
> >>
> >> +typedef struct {
> >> +   float r;
> >> +   float g;
> >> +   float b;
> >> +} rgb_color_t;
> >> +
> >> +static void set_color(rgb_color_t *color, float r, float g, float b)
> >> +{
> >> +   color->r = r;
> >> +   color->g = g;
> >> +   color->b = b;
> >> +}
> >> +
> >> +static void rotate_colors(rgb_color_t 

Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-12-18 Thread Srivatsa, Anusha


>-Original Message-
>From: daniel.vet...@ffwll.ch [mailto:daniel.vet...@ffwll.ch] On Behalf Of 
>Daniel
>Vetter
>Sent: Thursday, December 14, 2017 2:14 AM
>To: Srivatsa, Anusha ; Strano, Luis
>; Latvala, Petri ; Lofstedt,
>Marta ; Saarinen, Jani 
>Cc: intel-gfx ; Joseph Garvey
>
>Subject: Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal 
>flip
>subtest.
>
>On Thu, Nov 23, 2017 at 12:05 AM, Anusha Srivatsa 
>wrote:
>> From: Joseph Garvey 
>>
>> Test that horizontal flip works with supported rotations. Includes a
>> fix for the unrotated fb which was not being positioned correctly with
>> portrait and landscape rectangles.
>>
>> v2:(from Anusha)
>> - Change 180 degree rotation to follow the rest, use igt_swap(), make
>> flip variable a bool. Format the patch correctly (Ville, Petri
>> Latvala)
>>
>> v3: (From Anusha)
>> - Correct the name of subtests in order to avoid duplication of names
>> (Arek)
>>
>> Signed-off-by: Anusha Srivatsa 
>> Signed-off-by: Joseph Garvey 
>> Cc: Ville Syrjälä 
>> Cc: Petri Latvala 
>> Cc: Arkadiusz Hiler 
>
>I didn't see this patch fly by originally, but now Marta pointed out that this 
>skips
>everywhere. We need to rework it.
>
>General principle is that in kms tests we should _not_ have any 
>platform/feature
>checks encoded in the test. Instead, the testcase should check properties to
>figure out whether something should work or not.
>
>
>> ---
>>  lib/igt_kms.c|   2 +-
>>  lib/igt_kms.h|   5 ++
>>  tests/kms_rotation_crc.c | 198
>> +--
>>  3 files changed, 164 insertions(+), 41 deletions(-)
>>
>> diff --git a/lib/igt_kms.c b/lib/igt_kms.c index a572fc6..3034e44
>> 100644
>> --- a/lib/igt_kms.c
>> +++ b/lib/igt_kms.c
>> @@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb,
>> igt_plane_t *plane,
>>
>>  static const char *rotation_name(igt_rotation_t rotation)  {
>> -   switch (rotation) {
>> +   switch (rotation & IGT_ROTATION_MASK) {
>> case IGT_ROTATION_0:
>> return "0°";
>> case IGT_ROTATION_90:
>> diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 8dc118c..b83a828
>> 100644
>> --- a/lib/igt_kms.h
>> +++ b/lib/igt_kms.h
>> @@ -281,8 +281,13 @@ typedef enum {
>> IGT_ROTATION_90  = 1 << 1,
>> IGT_ROTATION_180 = 1 << 2,
>> IGT_ROTATION_270 = 1 << 3,
>> +   IGT_REFLECT_X= 1 << 4,
>> +   IGT_REFLECT_Y= 1 << 5,
>>  } igt_rotation_t;
>>
>> +#define IGT_ROTATION_MASK \
>> +   (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 |
>> +IGT_ROTATION_270)
>> +
>>  typedef struct {
>> /*< private >*/
>> igt_pipe_t *pipe;
>> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c index
>> 5aec8fa..9e13667 100644
>> --- a/tests/kms_rotation_crc.c
>> +++ b/tests/kms_rotation_crc.c
>> @@ -32,6 +32,7 @@ typedef struct {
>> igt_display_t display;
>> struct igt_fb fb;
>> struct igt_fb fb_reference;
>> +   struct igt_fb fb_unrotated;
>> struct igt_fb fb_modeset;
>> struct igt_fb fb_flip;
>> igt_crc_t ref_crc;
>> @@ -43,8 +44,59 @@ typedef struct {
>> uint32_t override_fmt;
>> uint64_t override_tiling;
>> bool flips;
>> +   int devid;
>>  } data_t;
>>
>> +typedef struct {
>> +   float r;
>> +   float g;
>> +   float b;
>> +} rgb_color_t;
>> +
>> +static void set_color(rgb_color_t *color, float r, float g, float b)
>> +{
>> +   color->r = r;
>> +   color->g = g;
>> +   color->b = b;
>> +}
>> +
>> +static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
>> + rgb_color_t *bl, igt_rotation_t rotation) {
>> +   rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
>> +
>> +   if (rotation & IGT_REFLECT_X) {
>> +   igt_swap(*tl, *tr);
>> +   igt_swap(*bl, *br);
>> +   }
>> +
>> +   if (rotation & IGT_ROTATION_90) {
>> +   bl_tmp = *bl;
>> +   br_tmp = *br;
>> +   tl_tmp = *tl;
>> +   tr_tmp = *tr;
>> +   *tl = tr_tmp;
>> +   *bl = tl_tmp;
>> 

Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-12-18 Thread Rodrigo Vivi
On Thu, Dec 14, 2017 at 10:14:19AM +, Daniel Vetter wrote:
> On Thu, Nov 23, 2017 at 12:05 AM, Anusha Srivatsa
>  wrote:
> > From: Joseph Garvey 
> >
> > Test that horizontal flip works with supported rotations. Includes
> > a fix for the unrotated fb which was not being positioned correctly
> > with portrait and landscape rectangles.
> >
> > v2:(from Anusha)
> > - Change 180 degree rotation to follow the rest, use
> > igt_swap(), make flip variable a bool. Format the
> > patch correctly (Ville, Petri Latvala)
> >
> > v3: (From Anusha)
> > - Correct the name of subtests in order to avoid duplication
> > of names (Arek)
> >
> > Signed-off-by: Anusha Srivatsa 
> > Signed-off-by: Joseph Garvey 
> > Cc: Ville Syrjälä 
> > Cc: Petri Latvala 
> > Cc: Arkadiusz Hiler 
> 
> I didn't see this patch fly by originally, but now Marta pointed out
> that this skips everywhere. We need to rework it.
> 
> General principle is that in kms tests we should _not_ have any
> platform/feature checks encoded in the test. Instead, the testcase
> should check properties to figure out whether something should work or
> not.

I fully agree.

But oops... I just merged the cnl patch while I had swear that I'd just merge
when the test case was done. :/

> 
> 
> > ---
> >  lib/igt_kms.c|   2 +-
> >  lib/igt_kms.h|   5 ++
> >  tests/kms_rotation_crc.c | 198 
> > +--
> >  3 files changed, 164 insertions(+), 41 deletions(-)
> >
> > diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> > index a572fc6..3034e44 100644
> > --- a/lib/igt_kms.c
> > +++ b/lib/igt_kms.c
> > @@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t 
> > *plane,
> >
> >  static const char *rotation_name(igt_rotation_t rotation)
> >  {
> > -   switch (rotation) {
> > +   switch (rotation & IGT_ROTATION_MASK) {
> > case IGT_ROTATION_0:
> > return "0°";
> > case IGT_ROTATION_90:
> > diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> > index 8dc118c..b83a828 100644
> > --- a/lib/igt_kms.h
> > +++ b/lib/igt_kms.h
> > @@ -281,8 +281,13 @@ typedef enum {
> > IGT_ROTATION_90  = 1 << 1,
> > IGT_ROTATION_180 = 1 << 2,
> > IGT_ROTATION_270 = 1 << 3,
> > +   IGT_REFLECT_X= 1 << 4,
> > +   IGT_REFLECT_Y= 1 << 5,
> >  } igt_rotation_t;
> >
> > +#define IGT_ROTATION_MASK \
> > +   (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 | 
> > IGT_ROTATION_270)
> > +
> >  typedef struct {
> > /*< private >*/
> > igt_pipe_t *pipe;
> > diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
> > index 5aec8fa..9e13667 100644
> > --- a/tests/kms_rotation_crc.c
> > +++ b/tests/kms_rotation_crc.c
> > @@ -32,6 +32,7 @@ typedef struct {
> > igt_display_t display;
> > struct igt_fb fb;
> > struct igt_fb fb_reference;
> > +   struct igt_fb fb_unrotated;
> > struct igt_fb fb_modeset;
> > struct igt_fb fb_flip;
> > igt_crc_t ref_crc;
> > @@ -43,8 +44,59 @@ typedef struct {
> > uint32_t override_fmt;
> > uint64_t override_tiling;
> > bool flips;
> > +   int devid;
> >  } data_t;
> >
> > +typedef struct {
> > +   float r;
> > +   float g;
> > +   float b;
> > +} rgb_color_t;
> > +
> > +static void set_color(rgb_color_t *color, float r, float g, float b)
> > +{
> > +   color->r = r;
> > +   color->g = g;
> > +   color->b = b;
> > +}
> > +
> > +static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t 
> > *br,
> > + rgb_color_t *bl, igt_rotation_t rotation)
> > +{
> > +   rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
> > +
> > +   if (rotation & IGT_REFLECT_X) {
> > +   igt_swap(*tl, *tr);
> > +   igt_swap(*bl, *br);
> > +   }
> > +
> > +   if (rotation & IGT_ROTATION_90) {
> > +   bl_tmp = *bl;
> > +   br_tmp = *br;
> > +   tl_tmp = *tl;
> > +   tr_tmp = *tr;
> > +   *tl = tr_tmp;
> > +   *bl = tl_tmp;
> > +   *tr = br_tmp;
> > +   *br = bl_tmp;
> > +   } else if (rotation & IGT_ROTATION_180) {
> > +   igt_swap(*tl, *br);
> > +   igt_swap(*tr, *bl);
> > +   } else if (rotation & IGT_ROTATION_270) {
> > +   bl_tmp = *bl;
> > +   br_tmp = *br;
> > +   tl_tmp = *tl;
> > +   tr_tmp = *tr;
> > +   *tl = bl_tmp;
> > +   *bl = br_tmp;
> > +   *tr = tl_tmp;
> > +   *br = tr_tmp;
> > +   }
> > +}
> > +
> > +#define RGB_COLOR(color) \
> > +   color.r, color.g, color.b
> > +
> >  static void
> >  paint_squares(data_t *data, igt_rotation_t rotation,
> >   struct igt_fb *fb, float o)
> > @@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
> > cairo_t *cr;
> > unsigned int w = fb

Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-12-14 Thread Daniel Vetter
On Thu, Nov 23, 2017 at 12:05 AM, Anusha Srivatsa
 wrote:
> From: Joseph Garvey 
>
> Test that horizontal flip works with supported rotations. Includes
> a fix for the unrotated fb which was not being positioned correctly
> with portrait and landscape rectangles.
>
> v2:(from Anusha)
> - Change 180 degree rotation to follow the rest, use
> igt_swap(), make flip variable a bool. Format the
> patch correctly (Ville, Petri Latvala)
>
> v3: (From Anusha)
> - Correct the name of subtests in order to avoid duplication
> of names (Arek)
>
> Signed-off-by: Anusha Srivatsa 
> Signed-off-by: Joseph Garvey 
> Cc: Ville Syrjälä 
> Cc: Petri Latvala 
> Cc: Arkadiusz Hiler 

I didn't see this patch fly by originally, but now Marta pointed out
that this skips everywhere. We need to rework it.

General principle is that in kms tests we should _not_ have any
platform/feature checks encoded in the test. Instead, the testcase
should check properties to figure out whether something should work or
not.


> ---
>  lib/igt_kms.c|   2 +-
>  lib/igt_kms.h|   5 ++
>  tests/kms_rotation_crc.c | 198 
> +--
>  3 files changed, 164 insertions(+), 41 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index a572fc6..3034e44 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t 
> *plane,
>
>  static const char *rotation_name(igt_rotation_t rotation)
>  {
> -   switch (rotation) {
> +   switch (rotation & IGT_ROTATION_MASK) {
> case IGT_ROTATION_0:
> return "0°";
> case IGT_ROTATION_90:
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 8dc118c..b83a828 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -281,8 +281,13 @@ typedef enum {
> IGT_ROTATION_90  = 1 << 1,
> IGT_ROTATION_180 = 1 << 2,
> IGT_ROTATION_270 = 1 << 3,
> +   IGT_REFLECT_X= 1 << 4,
> +   IGT_REFLECT_Y= 1 << 5,
>  } igt_rotation_t;
>
> +#define IGT_ROTATION_MASK \
> +   (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 | 
> IGT_ROTATION_270)
> +
>  typedef struct {
> /*< private >*/
> igt_pipe_t *pipe;
> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
> index 5aec8fa..9e13667 100644
> --- a/tests/kms_rotation_crc.c
> +++ b/tests/kms_rotation_crc.c
> @@ -32,6 +32,7 @@ typedef struct {
> igt_display_t display;
> struct igt_fb fb;
> struct igt_fb fb_reference;
> +   struct igt_fb fb_unrotated;
> struct igt_fb fb_modeset;
> struct igt_fb fb_flip;
> igt_crc_t ref_crc;
> @@ -43,8 +44,59 @@ typedef struct {
> uint32_t override_fmt;
> uint64_t override_tiling;
> bool flips;
> +   int devid;
>  } data_t;
>
> +typedef struct {
> +   float r;
> +   float g;
> +   float b;
> +} rgb_color_t;
> +
> +static void set_color(rgb_color_t *color, float r, float g, float b)
> +{
> +   color->r = r;
> +   color->g = g;
> +   color->b = b;
> +}
> +
> +static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
> + rgb_color_t *bl, igt_rotation_t rotation)
> +{
> +   rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
> +
> +   if (rotation & IGT_REFLECT_X) {
> +   igt_swap(*tl, *tr);
> +   igt_swap(*bl, *br);
> +   }
> +
> +   if (rotation & IGT_ROTATION_90) {
> +   bl_tmp = *bl;
> +   br_tmp = *br;
> +   tl_tmp = *tl;
> +   tr_tmp = *tr;
> +   *tl = tr_tmp;
> +   *bl = tl_tmp;
> +   *tr = br_tmp;
> +   *br = bl_tmp;
> +   } else if (rotation & IGT_ROTATION_180) {
> +   igt_swap(*tl, *br);
> +   igt_swap(*tr, *bl);
> +   } else if (rotation & IGT_ROTATION_270) {
> +   bl_tmp = *bl;
> +   br_tmp = *br;
> +   tl_tmp = *tl;
> +   tr_tmp = *tr;
> +   *tl = bl_tmp;
> +   *bl = br_tmp;
> +   *tr = tl_tmp;
> +   *br = tr_tmp;
> +   }
> +}
> +
> +#define RGB_COLOR(color) \
> +   color.r, color.g, color.b
> +
>  static void
>  paint_squares(data_t *data, igt_rotation_t rotation,
>   struct igt_fb *fb, float o)
> @@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
> cairo_t *cr;
> unsigned int w = fb->width;
> unsigned int h = fb->height;
> +   rgb_color_t tl, tr, bl, br;
>
> cr = igt_get_cairo_ctx(data->gfx_fd, fb);
>
> -   if (rotation == IGT_ROTATION_180) {
> -   cairo_translate(cr, w, h);
> -   cairo_rotate(cr, M_PI);
> -   }
> +   set_color(&tl, o, 0.0f, 0.0f);
> +   set_color(&tr, 0.0f, o, 0.0f);
> +   set_color(&br, o, o, o);
> +   set_color(&bl, 0.0f, 0.0f, o);
>
> -   if (rotation == IGT_ROTATION_90) 

Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-12-12 Thread Petri Latvala
On Wed, Nov 22, 2017 at 03:05:55PM -0800, Anusha Srivatsa wrote:
> From: Joseph Garvey 
> 
> Test that horizontal flip works with supported rotations. Includes
> a fix for the unrotated fb which was not being positioned correctly
> with portrait and landscape rectangles.
> 
> v2:(from Anusha)
> - Change 180 degree rotation to follow the rest, use
> igt_swap(), make flip variable a bool. Format the
> patch correctly (Ville, Petri Latvala)
> 
> v3: (From Anusha)
> - Correct the name of subtests in order to avoid duplication
> of names (Arek)
> 
> Signed-off-by: Anusha Srivatsa 
> Signed-off-by: Joseph Garvey 
> Cc: Ville Syrjälä 
> Cc: Petri Latvala 
> Cc: Arkadiusz Hiler 


Reviewed-by: Petri Latvala 

And merged, thanks.


___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-11-29 Thread Srivatsa, Anusha


>-Original Message-
>From: Latvala, Petri
>Sent: Wednesday, November 29, 2017 1:55 AM
>To: Srivatsa, Anusha 
>Cc: intel-gfx@lists.freedesktop.org; Joseph Garvey ;
>Ville Syrjälä ; Hiler, Arkadiusz
>
>Subject: Re: [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.
>
>On Wed, Nov 22, 2017 at 03:05:55PM -0800, Anusha Srivatsa wrote:
>> From: Joseph Garvey 
>>
>> Test that horizontal flip works with supported rotations. Includes a
>> fix for the unrotated fb which was not being positioned correctly with
>> portrait and landscape rectangles.
>>
>> v2:(from Anusha)
>> - Change 180 degree rotation to follow the rest, use igt_swap(), make
>> flip variable a bool. Format the patch correctly (Ville, Petri
>> Latvala)
>>
>> v3: (From Anusha)
>> - Correct the name of subtests in order to avoid duplication of names
>> (Arek)
>>
>> Signed-off-by: Anusha Srivatsa 
>> Signed-off-by: Joseph Garvey 
>> Cc: Ville Syrjälä 
>> Cc: Petri Latvala 
>> Cc: Arkadiusz Hiler 
>> ---
>>  lib/igt_kms.c|   2 +-
>>  lib/igt_kms.h|   5 ++
>>  tests/kms_rotation_crc.c | 198
>> +--
>>  3 files changed, 164 insertions(+), 41 deletions(-)
>>
>> diff --git a/lib/igt_kms.c b/lib/igt_kms.c index a572fc6..3034e44
>> 100644
>> --- a/lib/igt_kms.c
>> +++ b/lib/igt_kms.c
>> @@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb,
>> igt_plane_t *plane,
>>
>>  static const char *rotation_name(igt_rotation_t rotation)  {
>> -switch (rotation) {
>> +switch (rotation & IGT_ROTATION_MASK) {
>>  case IGT_ROTATION_0:
>>  return "0°";
>>  case IGT_ROTATION_90:
>> diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 8dc118c..b83a828
>> 100644
>> --- a/lib/igt_kms.h
>> +++ b/lib/igt_kms.h
>> @@ -281,8 +281,13 @@ typedef enum {
>>  IGT_ROTATION_90  = 1 << 1,
>>  IGT_ROTATION_180 = 1 << 2,
>>  IGT_ROTATION_270 = 1 << 3,
>> +IGT_REFLECT_X= 1 << 4,
>> +IGT_REFLECT_Y= 1 << 5,
>>  } igt_rotation_t;
>>
>> +#define IGT_ROTATION_MASK \
>> +(IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 |
>> +IGT_ROTATION_270)
>> +
>>  typedef struct {
>>  /*< private >*/
>>  igt_pipe_t *pipe;
>> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c index
>> 5aec8fa..9e13667 100644
>> --- a/tests/kms_rotation_crc.c
>> +++ b/tests/kms_rotation_crc.c
>> @@ -32,6 +32,7 @@ typedef struct {
>>  igt_display_t display;
>>  struct igt_fb fb;
>>  struct igt_fb fb_reference;
>> +struct igt_fb fb_unrotated;
>>  struct igt_fb fb_modeset;
>>  struct igt_fb fb_flip;
>>  igt_crc_t ref_crc;
>> @@ -43,8 +44,59 @@ typedef struct {
>>  uint32_t override_fmt;
>>  uint64_t override_tiling;
>>  bool flips;
>> +int devid;
>>  } data_t;
>>
>> +typedef struct {
>> +float r;
>> +float g;
>> +float b;
>> +} rgb_color_t;
>> +
>> +static void set_color(rgb_color_t *color, float r, float g, float b)
>> +{
>> +color->r = r;
>> +color->g = g;
>> +color->b = b;
>> +}
>> +
>> +static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
>> +  rgb_color_t *bl, igt_rotation_t rotation) {
>> +rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
>> +
>> +if (rotation & IGT_REFLECT_X) {
>> +igt_swap(*tl, *tr);
>> +igt_swap(*bl, *br);
>> +}
>> +
>> +if (rotation & IGT_ROTATION_90) {
>> +bl_tmp = *bl;
>> +br_tmp = *br;
>> +tl_tmp = *tl;
>> +tr_tmp = *tr;
>> +*tl = tr_tmp;
>> +*bl = tl_tmp;
>> +*tr = br_tmp;
>> +*br = bl_tmp;
>> +} else if (rotation & IGT_ROTATION_180) {
>> +igt_swap(*tl, *br);
>> +igt_swap(*tr, *bl);
>> +} else if (rotation & IGT_ROTATION_270) {
>> +bl_tmp = *bl;
>> +br_tmp = *br;
>> +tl_tmp = *tl;
>> +tr_tmp = *tr;
>> +*tl = bl_tmp;
>> +*bl = br_tmp;
>> +*tr = tl_tmp;
>> +*br = tr_tmp;
>> +}
>> +}
>> +
>> +#define RGB_COLOR(color) \
>> +color.r, color.g, color.b
>> +
>>  static void
>>  paint_squares(data_t *data, igt_rotation_t rotation,
>>struct igt_fb *fb, float o)
>> @@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
>>  cairo_t *cr;
>>  unsigned int w = fb->width;
>>  unsigned int h = fb->height;
>> +rgb_color_t tl, tr, bl, br;
>>
>>  cr = igt_get_cairo_ctx(data->gfx_fd, fb);
>>
>> -if (rotation == IGT_ROTATION_180) {
>> -cairo_translate(cr, w, h);
>> -cairo_rotate(cr, M_PI);
>> -}
>> +set_color(&tl, o, 0.0f, 0.0f);
>> +set_color(&tr, 0.0f, o, 0.0f);
>> +set_color(&br, o, o, o);
>> +set_color(&bl, 0.0f, 0.0f, o);
>>
>> -if (rotation == IGT_ROTATION_90) {
>> -/* Paint 4 squares with width == height in Green, White,
>> -Blue, Red Clockwise or

Re: [Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-11-29 Thread Petri Latvala
On Wed, Nov 22, 2017 at 03:05:55PM -0800, Anusha Srivatsa wrote:
> From: Joseph Garvey 
> 
> Test that horizontal flip works with supported rotations. Includes
> a fix for the unrotated fb which was not being positioned correctly
> with portrait and landscape rectangles.
> 
> v2:(from Anusha)
> - Change 180 degree rotation to follow the rest, use
> igt_swap(), make flip variable a bool. Format the
> patch correctly (Ville, Petri Latvala)
> 
> v3: (From Anusha)
> - Correct the name of subtests in order to avoid duplication
> of names (Arek)
> 
> Signed-off-by: Anusha Srivatsa 
> Signed-off-by: Joseph Garvey 
> Cc: Ville Syrjälä 
> Cc: Petri Latvala 
> Cc: Arkadiusz Hiler 
> ---
>  lib/igt_kms.c|   2 +-
>  lib/igt_kms.h|   5 ++
>  tests/kms_rotation_crc.c | 198 
> +--
>  3 files changed, 164 insertions(+), 41 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index a572fc6..3034e44 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t 
> *plane,
>  
>  static const char *rotation_name(igt_rotation_t rotation)
>  {
> - switch (rotation) {
> + switch (rotation & IGT_ROTATION_MASK) {
>   case IGT_ROTATION_0:
>   return "0°";
>   case IGT_ROTATION_90:
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 8dc118c..b83a828 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -281,8 +281,13 @@ typedef enum {
>   IGT_ROTATION_90  = 1 << 1,
>   IGT_ROTATION_180 = 1 << 2,
>   IGT_ROTATION_270 = 1 << 3,
> + IGT_REFLECT_X= 1 << 4,
> + IGT_REFLECT_Y= 1 << 5,
>  } igt_rotation_t;
>  
> +#define IGT_ROTATION_MASK \
> + (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 | IGT_ROTATION_270)
> +
>  typedef struct {
>   /*< private >*/
>   igt_pipe_t *pipe;
> diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
> index 5aec8fa..9e13667 100644
> --- a/tests/kms_rotation_crc.c
> +++ b/tests/kms_rotation_crc.c
> @@ -32,6 +32,7 @@ typedef struct {
>   igt_display_t display;
>   struct igt_fb fb;
>   struct igt_fb fb_reference;
> + struct igt_fb fb_unrotated;
>   struct igt_fb fb_modeset;
>   struct igt_fb fb_flip;
>   igt_crc_t ref_crc;
> @@ -43,8 +44,59 @@ typedef struct {
>   uint32_t override_fmt;
>   uint64_t override_tiling;
>   bool flips;
> + int devid;
>  } data_t;
>  
> +typedef struct {
> + float r;
> + float g;
> + float b;
> +} rgb_color_t;
> +
> +static void set_color(rgb_color_t *color, float r, float g, float b)
> +{
> + color->r = r;
> + color->g = g;
> + color->b = b;
> +}
> +
> +static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
> +   rgb_color_t *bl, igt_rotation_t rotation)
> +{
> + rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
> +
> + if (rotation & IGT_REFLECT_X) {
> + igt_swap(*tl, *tr);
> + igt_swap(*bl, *br);
> + }
> +
> + if (rotation & IGT_ROTATION_90) {
> + bl_tmp = *bl;
> + br_tmp = *br;
> + tl_tmp = *tl;
> + tr_tmp = *tr;
> + *tl = tr_tmp;
> + *bl = tl_tmp;
> + *tr = br_tmp;
> + *br = bl_tmp;
> + } else if (rotation & IGT_ROTATION_180) {
> + igt_swap(*tl, *br);
> + igt_swap(*tr, *bl);
> + } else if (rotation & IGT_ROTATION_270) {
> + bl_tmp = *bl;
> + br_tmp = *br;
> + tl_tmp = *tl;
> + tr_tmp = *tr;
> + *tl = bl_tmp;
> + *bl = br_tmp;
> + *tr = tl_tmp;
> + *br = tr_tmp;
> + }
> +}
> +
> +#define RGB_COLOR(color) \
> + color.r, color.g, color.b
> +
>  static void
>  paint_squares(data_t *data, igt_rotation_t rotation,
> struct igt_fb *fb, float o)
> @@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
>   cairo_t *cr;
>   unsigned int w = fb->width;
>   unsigned int h = fb->height;
> + rgb_color_t tl, tr, bl, br;
>  
>   cr = igt_get_cairo_ctx(data->gfx_fd, fb);
>  
> - if (rotation == IGT_ROTATION_180) {
> - cairo_translate(cr, w, h);
> - cairo_rotate(cr, M_PI);
> - }
> + set_color(&tl, o, 0.0f, 0.0f);
> + set_color(&tr, 0.0f, o, 0.0f);
> + set_color(&br, o, o, o);
> + set_color(&bl, 0.0f, 0.0f, o);
>  
> - if (rotation == IGT_ROTATION_90) {
> - /* Paint 4 squares with width == height in Green, White,
> - Blue, Red Clockwise order to look like 270 degree rotated*/
> - igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0);
> - igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o);
> - igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0);
> - igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o);
> - } else

[Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-11-22 Thread Anusha Srivatsa
From: Joseph Garvey 

Test that horizontal flip works with supported rotations. Includes
a fix for the unrotated fb which was not being positioned correctly
with portrait and landscape rectangles.

v2:(from Anusha)
- Change 180 degree rotation to follow the rest, use
igt_swap(), make flip variable a bool. Format the
patch correctly (Ville, Petri Latvala)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication
of names (Arek)

Signed-off-by: Anusha Srivatsa 
Signed-off-by: Joseph Garvey 
Cc: Ville Syrjälä 
Cc: Petri Latvala 
Cc: Arkadiusz Hiler 
---
 lib/igt_kms.c|   2 +-
 lib/igt_kms.h|   5 ++
 tests/kms_rotation_crc.c | 198 +--
 3 files changed, 164 insertions(+), 41 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a572fc6..3034e44 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t 
*plane,
 
 static const char *rotation_name(igt_rotation_t rotation)
 {
-   switch (rotation) {
+   switch (rotation & IGT_ROTATION_MASK) {
case IGT_ROTATION_0:
return "0°";
case IGT_ROTATION_90:
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8dc118c..b83a828 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -281,8 +281,13 @@ typedef enum {
IGT_ROTATION_90  = 1 << 1,
IGT_ROTATION_180 = 1 << 2,
IGT_ROTATION_270 = 1 << 3,
+   IGT_REFLECT_X= 1 << 4,
+   IGT_REFLECT_Y= 1 << 5,
 } igt_rotation_t;
 
+#define IGT_ROTATION_MASK \
+   (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 | IGT_ROTATION_270)
+
 typedef struct {
/*< private >*/
igt_pipe_t *pipe;
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 5aec8fa..9e13667 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -32,6 +32,7 @@ typedef struct {
igt_display_t display;
struct igt_fb fb;
struct igt_fb fb_reference;
+   struct igt_fb fb_unrotated;
struct igt_fb fb_modeset;
struct igt_fb fb_flip;
igt_crc_t ref_crc;
@@ -43,8 +44,59 @@ typedef struct {
uint32_t override_fmt;
uint64_t override_tiling;
bool flips;
+   int devid;
 } data_t;
 
+typedef struct {
+   float r;
+   float g;
+   float b;
+} rgb_color_t;
+
+static void set_color(rgb_color_t *color, float r, float g, float b)
+{
+   color->r = r;
+   color->g = g;
+   color->b = b;
+}
+
+static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
+ rgb_color_t *bl, igt_rotation_t rotation)
+{
+   rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
+
+   if (rotation & IGT_REFLECT_X) {
+   igt_swap(*tl, *tr);
+   igt_swap(*bl, *br);
+   }
+
+   if (rotation & IGT_ROTATION_90) {
+   bl_tmp = *bl;
+   br_tmp = *br;
+   tl_tmp = *tl;
+   tr_tmp = *tr;
+   *tl = tr_tmp;
+   *bl = tl_tmp;
+   *tr = br_tmp;
+   *br = bl_tmp;
+   } else if (rotation & IGT_ROTATION_180) {
+   igt_swap(*tl, *br);
+   igt_swap(*tr, *bl);
+   } else if (rotation & IGT_ROTATION_270) {
+   bl_tmp = *bl;
+   br_tmp = *br;
+   tl_tmp = *tl;
+   tr_tmp = *tr;
+   *tl = bl_tmp;
+   *bl = br_tmp;
+   *tr = tl_tmp;
+   *br = tr_tmp;
+   }
+}
+
+#define RGB_COLOR(color) \
+   color.r, color.g, color.b
+
 static void
 paint_squares(data_t *data, igt_rotation_t rotation,
  struct igt_fb *fb, float o)
@@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
cairo_t *cr;
unsigned int w = fb->width;
unsigned int h = fb->height;
+   rgb_color_t tl, tr, bl, br;
 
cr = igt_get_cairo_ctx(data->gfx_fd, fb);
 
-   if (rotation == IGT_ROTATION_180) {
-   cairo_translate(cr, w, h);
-   cairo_rotate(cr, M_PI);
-   }
+   set_color(&tl, o, 0.0f, 0.0f);
+   set_color(&tr, 0.0f, o, 0.0f);
+   set_color(&br, o, o, o);
+   set_color(&bl, 0.0f, 0.0f, o);
 
-   if (rotation == IGT_ROTATION_90) {
-   /* Paint 4 squares with width == height in Green, White,
-   Blue, Red Clockwise order to look like 270 degree rotated*/
-   igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0);
-   igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o);
-   igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0);
-   igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o);
-   } else if (rotation == IGT_ROTATION_270) {
-   /* Paint 4 squares with width == height in Blue, Red,
-   Green, White Clockwise order to look like 90 degree rotated*/
-   igt_paint_color

[Intel-gfx] [PATCH i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-10-20 Thread Anusha Srivatsa
From: Joseph Garvey 

Test that horizontal flip works with supported rotations. Includes
a fix for the unrotated fb which was not being positioned correctly
with portrait and landscape rectangles.

v2:(from Anusha)
- Change 180 degree rotation to follow the rest, use
igt_swap(), make flip variable a bool. Format the
patch correctly (Ville, Petri Latvala)

v3: (From Anusha)
- Correct the name of subtests in order to avoid duplication
of names (Arek)

Signed-off-by: Anusha Srivatsa 
Signed-off-by: Joseph Garvey 
Cc: Ville Syrjälä 
Cc: Petri Latvala 
Cc: Arkadiusz Hiler 
---
 lib/igt_kms.c|   2 +-
 lib/igt_kms.h|   5 ++
 tests/kms_rotation_crc.c | 198 +--
 3 files changed, 164 insertions(+), 41 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a572fc6..3034e44 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t 
*plane,
 
 static const char *rotation_name(igt_rotation_t rotation)
 {
-   switch (rotation) {
+   switch (rotation & IGT_ROTATION_MASK) {
case IGT_ROTATION_0:
return "0°";
case IGT_ROTATION_90:
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8dc118c..b83a828 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -281,8 +281,13 @@ typedef enum {
IGT_ROTATION_90  = 1 << 1,
IGT_ROTATION_180 = 1 << 2,
IGT_ROTATION_270 = 1 << 3,
+   IGT_REFLECT_X= 1 << 4,
+   IGT_REFLECT_Y= 1 << 5,
 } igt_rotation_t;
 
+#define IGT_ROTATION_MASK \
+   (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 | IGT_ROTATION_270)
+
 typedef struct {
/*< private >*/
igt_pipe_t *pipe;
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 5aec8fa..9e13667 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -32,6 +32,7 @@ typedef struct {
igt_display_t display;
struct igt_fb fb;
struct igt_fb fb_reference;
+   struct igt_fb fb_unrotated;
struct igt_fb fb_modeset;
struct igt_fb fb_flip;
igt_crc_t ref_crc;
@@ -43,8 +44,59 @@ typedef struct {
uint32_t override_fmt;
uint64_t override_tiling;
bool flips;
+   int devid;
 } data_t;
 
+typedef struct {
+   float r;
+   float g;
+   float b;
+} rgb_color_t;
+
+static void set_color(rgb_color_t *color, float r, float g, float b)
+{
+   color->r = r;
+   color->g = g;
+   color->b = b;
+}
+
+static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
+ rgb_color_t *bl, igt_rotation_t rotation)
+{
+   rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
+
+   if (rotation & IGT_REFLECT_X) {
+   igt_swap(*tl, *tr);
+   igt_swap(*bl, *br);
+   }
+
+   if (rotation & IGT_ROTATION_90) {
+   bl_tmp = *bl;
+   br_tmp = *br;
+   tl_tmp = *tl;
+   tr_tmp = *tr;
+   *tl = tr_tmp;
+   *bl = tl_tmp;
+   *tr = br_tmp;
+   *br = bl_tmp;
+   } else if (rotation & IGT_ROTATION_180) {
+   igt_swap(*tl, *br);
+   igt_swap(*tr, *bl);
+   } else if (rotation & IGT_ROTATION_270) {
+   bl_tmp = *bl;
+   br_tmp = *br;
+   tl_tmp = *tl;
+   tr_tmp = *tr;
+   *tl = bl_tmp;
+   *bl = br_tmp;
+   *tr = tl_tmp;
+   *br = tr_tmp;
+   }
+}
+
+#define RGB_COLOR(color) \
+   color.r, color.g, color.b
+
 static void
 paint_squares(data_t *data, igt_rotation_t rotation,
  struct igt_fb *fb, float o)
@@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
cairo_t *cr;
unsigned int w = fb->width;
unsigned int h = fb->height;
+   rgb_color_t tl, tr, bl, br;
 
cr = igt_get_cairo_ctx(data->gfx_fd, fb);
 
-   if (rotation == IGT_ROTATION_180) {
-   cairo_translate(cr, w, h);
-   cairo_rotate(cr, M_PI);
-   }
+   set_color(&tl, o, 0.0f, 0.0f);
+   set_color(&tr, 0.0f, o, 0.0f);
+   set_color(&br, o, o, o);
+   set_color(&bl, 0.0f, 0.0f, o);
 
-   if (rotation == IGT_ROTATION_90) {
-   /* Paint 4 squares with width == height in Green, White,
-   Blue, Red Clockwise order to look like 270 degree rotated*/
-   igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0);
-   igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o);
-   igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0);
-   igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o);
-   } else if (rotation == IGT_ROTATION_270) {
-   /* Paint 4 squares with width == height in Blue, Red,
-   Green, White Clockwise order to look like 90 degree rotated*/
-   igt_paint_color

[Intel-gfx] [patch i-g-t] igt/kms_rotation_crc: Add horizontal flip subtest.

2017-10-04 Thread Anusha Srivatsa
From: Joseph Garvey 

Test that horizontal flip works with supported rotations. Includes
a fix for the unrotated fb which was not being positioned correctly
with portrait and landscape rectangles.

v2:(from Anusha)
- Change 180 degree rotation to follow the rest, use
igt_swap(), make flip variable a bool. Format the
patch correctly (Ville, Petri Latvala)

Signed-off-by: Anusha Srivatsa 
Signed-off-by: Joseph Garvey 
Cc: Ville Syrjälä 
Cc: Petri Latvala 
---
 lib/igt_kms.c|   2 +-
 lib/igt_kms.h|   5 ++
 tests/kms_rotation_crc.c | 197 +--
 3 files changed, 163 insertions(+), 41 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a572fc6..3034e44 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3050,7 +3050,7 @@ void igt_fb_set_size(struct igt_fb *fb, igt_plane_t 
*plane,
 
 static const char *rotation_name(igt_rotation_t rotation)
 {
-   switch (rotation) {
+   switch (rotation & IGT_ROTATION_MASK) {
case IGT_ROTATION_0:
return "0°";
case IGT_ROTATION_90:
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8dc118c..b83a828 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -281,8 +281,13 @@ typedef enum {
IGT_ROTATION_90  = 1 << 1,
IGT_ROTATION_180 = 1 << 2,
IGT_ROTATION_270 = 1 << 3,
+   IGT_REFLECT_X= 1 << 4,
+   IGT_REFLECT_Y= 1 << 5,
 } igt_rotation_t;
 
+#define IGT_ROTATION_MASK \
+   (IGT_ROTATION_0 | IGT_ROTATION_90 | IGT_ROTATION_180 | IGT_ROTATION_270)
+
 typedef struct {
/*< private >*/
igt_pipe_t *pipe;
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 5aec8fa..b894df3 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -32,6 +32,7 @@ typedef struct {
igt_display_t display;
struct igt_fb fb;
struct igt_fb fb_reference;
+   struct igt_fb fb_unrotated;
struct igt_fb fb_modeset;
struct igt_fb fb_flip;
igt_crc_t ref_crc;
@@ -43,8 +44,59 @@ typedef struct {
uint32_t override_fmt;
uint64_t override_tiling;
bool flips;
+   int devid;
 } data_t;
 
+typedef struct {
+   float r;
+   float g;
+   float b;
+} rgb_color_t;
+
+static void set_color(rgb_color_t *color, float r, float g, float b)
+{
+   color->r = r;
+   color->g = g;
+   color->b = b;
+}
+
+static void rotate_colors(rgb_color_t *tl, rgb_color_t *tr, rgb_color_t *br,
+ rgb_color_t *bl, igt_rotation_t rotation)
+{
+   rgb_color_t bl_tmp, br_tmp, tl_tmp, tr_tmp;
+
+   if (rotation & IGT_REFLECT_X) {
+   igt_swap(*tl, *tr);
+   igt_swap(*bl, *br);
+   }
+
+   if (rotation & IGT_ROTATION_90) {
+   bl_tmp = *bl;
+   br_tmp = *br;
+   tl_tmp = *tl;
+   tr_tmp = *tr;
+   *tl = tr_tmp;
+   *bl = tl_tmp;
+   *tr = br_tmp;
+   *br = bl_tmp;
+   } else if (rotation & IGT_ROTATION_180) {
+   igt_swap(*tl, *br);
+   igt_swap(*tr, *bl);
+   } else if (rotation & IGT_ROTATION_270) {
+   bl_tmp = *bl;
+   br_tmp = *br;
+   tl_tmp = *tl;
+   tr_tmp = *tr;
+   *tl = bl_tmp;
+   *bl = br_tmp;
+   *tr = tl_tmp;
+   *br = tr_tmp;
+   }
+}
+
+#define RGB_COLOR(color) \
+   color.r, color.g, color.b
+
 static void
 paint_squares(data_t *data, igt_rotation_t rotation,
  struct igt_fb *fb, float o)
@@ -52,35 +104,21 @@ paint_squares(data_t *data, igt_rotation_t rotation,
cairo_t *cr;
unsigned int w = fb->width;
unsigned int h = fb->height;
+   rgb_color_t tl, tr, bl, br;
 
cr = igt_get_cairo_ctx(data->gfx_fd, fb);
 
-   if (rotation == IGT_ROTATION_180) {
-   cairo_translate(cr, w, h);
-   cairo_rotate(cr, M_PI);
-   }
+   set_color(&tl, o, 0.0f, 0.0f);
+   set_color(&tr, 0.0f, o, 0.0f);
+   set_color(&br, o, o, o);
+   set_color(&bl, 0.0f, 0.0f, o);
 
-   if (rotation == IGT_ROTATION_90) {
-   /* Paint 4 squares with width == height in Green, White,
-   Blue, Red Clockwise order to look like 270 degree rotated*/
-   igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0);
-   igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o);
-   igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0);
-   igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o);
-   } else if (rotation == IGT_ROTATION_270) {
-   /* Paint 4 squares with width == height in Blue, Red,
-   Green, White Clockwise order to look like 90 degree rotated*/
-   igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, 0.0, o);
-   igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, 0.0, 0.0);
-