Re: [Intel-gfx] [PATCH v3] i-g-t: Adding test case to test background color.

2015-04-14 Thread Thomas Wood
On 30 March 2015 at 21:44, Chandra Konduru chandra.kond...@intel.com wrote:
 From: chandra konduru chandra.kond...@intel.com

 Adding i-g-t test case to test display crtc background color.

 v2:
 - Added IGT_TEST_DESCRIPTION() (Thomas Wood)
 - Added to .gitignore (Thomas Wood)
 - Added additional details to function header (Thomas Wood)
 - Simplified igt_main (Thomas Wood)

 v3:
 - rebased to latest master (me)
 - took sleep calls out (Daniel)
 - use new tiled types when calling igt_create_fb (me)

I've pushed this patch and the panel fitting and plane scaling test
cases, but I have switched them all to use igt_simple_main and remove
the single subtest, which I think was your intention in v2 of this
patch.



 Signed-off-by: chandra konduru chandra.kond...@intel.com
 ---
  lib/igt_kms.c |  61 
  lib/igt_kms.h |   4 +
  tests/.gitignore  |   1 +
  tests/Android.mk  |   1 +
  tests/Makefile.sources|   1 +
  tests/kms_crtc_background_color.c | 195 
 ++
  6 files changed, 263 insertions(+)
  create mode 100644 tests/kms_crtc_background_color.c

 diff --git a/lib/igt_kms.c b/lib/igt_kms.c
 index 9c131f0..9c46e18 100644
 --- a/lib/igt_kms.c
 +++ b/lib/igt_kms.c
 @@ -940,6 +940,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t 
 prop_id, uint64_t value)
  DRM_MODE_OBJECT_PLANE, prop_id, value);
  }

 +static bool
 +get_crtc_property(int drm_fd, uint32_t crtc_id, const char *name,
 +  uint32_t *prop_id /* out */, uint64_t *value /* out */,
 +  drmModePropertyPtr *prop /* out */)
 +{
 +   return kmstest_get_property(drm_fd, crtc_id, DRM_MODE_OBJECT_CRTC,
 +   name, prop_id, value, prop);
 +}
 +
 +static void
 +igt_crtc_set_property(igt_output_t *output, uint32_t prop_id, uint64_t value)
 +{
 +   drmModeObjectSetProperty(output-display-drm_fd,
 +   output-config.crtc-crtc_id, DRM_MODE_OBJECT_CRTC, prop_id, 
 value);
 +}
 +
  /*
   * Walk a plane's property list to determine its type.  If we don't
   * find a type property, then the kernel doesn't support universal
 @@ -1097,6 +1113,7 @@ void igt_display_init(igt_display_t *display, int 
 drm_fd)
 igt_assert(display-outputs);

 for (i = 0; i  display-n_outputs; i++) {
 +   int j;
 igt_output_t *output = display-outputs[i];

 /*
 @@ -1108,6 +1125,19 @@ void igt_display_init(igt_display_t *display, int 
 drm_fd)
 output-display = display;

 igt_output_refresh(output);
 +
 +   for (j = 0; j  display-n_pipes; j++) {
 +   uint64_t prop_value;
 +   igt_pipe_t *pipe = display-pipes[j];
 +   if (output-config.crtc) {
 +   get_crtc_property(display-drm_fd, 
 output-config.crtc-crtc_id,
 +  background_color,
 +  pipe-background_property,
 +  prop_value,
 +  NULL);
 +   pipe-background = (uint32_t)prop_value;
 +   }
 +   }
 }

 drmModeFreePlaneResources(plane_resources);
 @@ -1527,6 +1557,13 @@ static int igt_output_commit(igt_output_t *output,

 pipe = igt_output_get_driving_pipe(output);

 +   if (pipe-background_changed) {
 +   igt_crtc_set_property(output, pipe-background_property,
 +   pipe-background);
 +
 +   pipe-background_changed = false;
 +   }
 +
 for (i = 0; i  pipe-n_planes; i++) {
 igt_plane_t *plane = pipe-planes[i];

 @@ -1779,6 +1816,30 @@ void igt_plane_set_rotation(igt_plane_t *plane, 
 igt_rotation_t rotation)
 plane-rotation_changed = true;
  }

 +/**
 + * igt_crtc_set_background:
 + * @pipe: pipe pointer to which background color to be set
 + * @background: background color value in BGR 16bpc
 + *
 + * Sets background color for requested pipe. Color value provided here
 + * will be actually submitted at output commit time via background_color
 + * property.
 + * For example to get red as background, set background = 0x.
 + */
 +void igt_crtc_set_background(igt_pipe_t *pipe, uint64_t background)
 +{
 +   igt_display_t *display = pipe-display;
 +
 +   LOG(display, %s.%d: crtc_set_background(%lu)\n,
 +   kmstest_pipe_name(pipe-pipe),
 +   pipe-pipe, background);
 +
 +   pipe-background = background;
 +
 +   pipe-background_changed = true;
 +}
 +
 +
  void igt_wait_for_vblank(int drm_fd, enum pipe pipe)
  {
 drmVBlank wait_vbl;
 diff --git a/lib/igt_kms.h b/lib/igt_kms.h
 index 565df14..84e8456 100644
 --- 

Re: [Intel-gfx] [PATCH v3] i-g-t: Adding test case to test background color.

2015-04-14 Thread Konduru, Chandra


 -Original Message-
 From: Thomas Wood [mailto:thomas.w...@intel.com]
 Sent: Tuesday, April 14, 2015 10:02 AM
 To: Konduru, Chandra
 Cc: Intel Graphics Development
 Subject: Re: [Intel-gfx] [PATCH v3] i-g-t: Adding test case to test background
 color.
 
 On 30 March 2015 at 21:44, Chandra Konduru chandra.kond...@intel.com
 wrote:
  From: chandra konduru chandra.kond...@intel.com
 
  Adding i-g-t test case to test display crtc background color.
 
  v2:
  - Added IGT_TEST_DESCRIPTION() (Thomas Wood)
  - Added to .gitignore (Thomas Wood)
  - Added additional details to function header (Thomas Wood)
  - Simplified igt_main (Thomas Wood)
 
  v3:
  - rebased to latest master (me)
  - took sleep calls out (Daniel)
  - use new tiled types when calling igt_create_fb (me)
 
 I've pushed this patch and the panel fitting and plane scaling test cases, 
 but I
 have switched them all to use igt_simple_main and remove the single subtest,
 which I think was your intention in v2 of this patch.
That should be ok.
Thanks for merging.
 
 
 
  Signed-off-by: chandra konduru chandra.kond...@intel.com
  ---
   lib/igt_kms.c |  61 
   lib/igt_kms.h |   4 +
   tests/.gitignore  |   1 +
   tests/Android.mk  |   1 +
   tests/Makefile.sources|   1 +
   tests/kms_crtc_background_color.c | 195
  ++
   6 files changed, 263 insertions(+)
   create mode 100644 tests/kms_crtc_background_color.c
 
  diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 9c131f0..9c46e18
  100644
  --- a/lib/igt_kms.c
  +++ b/lib/igt_kms.c
  @@ -940,6 +940,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t
 prop_id, uint64_t value)
   DRM_MODE_OBJECT_PLANE, prop_id,
  value);  }
 
  +static bool
  +get_crtc_property(int drm_fd, uint32_t crtc_id, const char *name,
  +  uint32_t *prop_id /* out */, uint64_t *value /* out */,
  +  drmModePropertyPtr *prop /* out */) {
  +   return kmstest_get_property(drm_fd, crtc_id,
 DRM_MODE_OBJECT_CRTC,
  +   name, prop_id, value, prop); }
  +
  +static void
  +igt_crtc_set_property(igt_output_t *output, uint32_t prop_id,
  +uint64_t value) {
  +   drmModeObjectSetProperty(output-display-drm_fd,
  +   output-config.crtc-crtc_id, DRM_MODE_OBJECT_CRTC,
  +prop_id, value); }
  +
   /*
* Walk a plane's property list to determine its type.  If we don't
* find a type property, then the kernel doesn't support universal @@
  -1097,6 +1113,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
  igt_assert(display-outputs);
 
  for (i = 0; i  display-n_outputs; i++) {
  +   int j;
  igt_output_t *output = display-outputs[i];
 
  /*
  @@ -1108,6 +1125,19 @@ void igt_display_init(igt_display_t *display, int
 drm_fd)
  output-display = display;
 
  igt_output_refresh(output);
  +
  +   for (j = 0; j  display-n_pipes; j++) {
  +   uint64_t prop_value;
  +   igt_pipe_t *pipe = display-pipes[j];
  +   if (output-config.crtc) {
  +   get_crtc_property(display-drm_fd, 
  output-config.crtc-
 crtc_id,
  +  background_color,
  +  
  pipe-background_property,
  +  prop_value,
  +  NULL);
  +   pipe-background = (uint32_t)prop_value;
  +   }
  +   }
  }
 
  drmModeFreePlaneResources(plane_resources);
  @@ -1527,6 +1557,13 @@ static int igt_output_commit(igt_output_t
  *output,
 
  pipe = igt_output_get_driving_pipe(output);
 
  +   if (pipe-background_changed) {
  +   igt_crtc_set_property(output, pipe-background_property,
  +   pipe-background);
  +
  +   pipe-background_changed = false;
  +   }
  +
  for (i = 0; i  pipe-n_planes; i++) {
  igt_plane_t *plane = pipe-planes[i];
 
  @@ -1779,6 +1816,30 @@ void igt_plane_set_rotation(igt_plane_t *plane,
 igt_rotation_t rotation)
  plane-rotation_changed = true;  }
 
  +/**
  + * igt_crtc_set_background:
  + * @pipe: pipe pointer to which background color to be set
  + * @background: background color value in BGR 16bpc
  + *
  + * Sets background color for requested pipe. Color value provided
  +here
  + * will be actually submitted at output commit time via background_color
  + * property.
  + * For example to get red as background, set background = 0x.
  + */
  +void igt_crtc_set_background(igt_pipe_t *pipe, uint64_t background) {
  +   igt_display_t *display = pipe

[Intel-gfx] [PATCH v3] i-g-t: Adding test case to test background color.

2015-03-30 Thread Chandra Konduru
From: chandra konduru chandra.kond...@intel.com

Adding i-g-t test case to test display crtc background color.

v2:
- Added IGT_TEST_DESCRIPTION() (Thomas Wood)
- Added to .gitignore (Thomas Wood)
- Added additional details to function header (Thomas Wood)
- Simplified igt_main (Thomas Wood)

v3:
- rebased to latest master (me)
- took sleep calls out (Daniel)
- use new tiled types when calling igt_create_fb (me)

Signed-off-by: chandra konduru chandra.kond...@intel.com
---
 lib/igt_kms.c |  61 
 lib/igt_kms.h |   4 +
 tests/.gitignore  |   1 +
 tests/Android.mk  |   1 +
 tests/Makefile.sources|   1 +
 tests/kms_crtc_background_color.c | 195 ++
 6 files changed, 263 insertions(+)
 create mode 100644 tests/kms_crtc_background_color.c

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 9c131f0..9c46e18 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -940,6 +940,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t 
prop_id, uint64_t value)
 DRM_MODE_OBJECT_PLANE, prop_id, value);
 }
 
+static bool
+get_crtc_property(int drm_fd, uint32_t crtc_id, const char *name,
+  uint32_t *prop_id /* out */, uint64_t *value /* out */,
+  drmModePropertyPtr *prop /* out */)
+{
+   return kmstest_get_property(drm_fd, crtc_id, DRM_MODE_OBJECT_CRTC,
+   name, prop_id, value, prop);
+}
+
+static void
+igt_crtc_set_property(igt_output_t *output, uint32_t prop_id, uint64_t value)
+{
+   drmModeObjectSetProperty(output-display-drm_fd,
+   output-config.crtc-crtc_id, DRM_MODE_OBJECT_CRTC, prop_id, 
value);
+}
+
 /*
  * Walk a plane's property list to determine its type.  If we don't
  * find a type property, then the kernel doesn't support universal
@@ -1097,6 +1113,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
igt_assert(display-outputs);
 
for (i = 0; i  display-n_outputs; i++) {
+   int j;
igt_output_t *output = display-outputs[i];
 
/*
@@ -1108,6 +1125,19 @@ void igt_display_init(igt_display_t *display, int drm_fd)
output-display = display;
 
igt_output_refresh(output);
+
+   for (j = 0; j  display-n_pipes; j++) {
+   uint64_t prop_value;
+   igt_pipe_t *pipe = display-pipes[j];
+   if (output-config.crtc) {
+   get_crtc_property(display-drm_fd, 
output-config.crtc-crtc_id,
+  background_color,
+  pipe-background_property,
+  prop_value,
+  NULL);
+   pipe-background = (uint32_t)prop_value;
+   }
+   }
}
 
drmModeFreePlaneResources(plane_resources);
@@ -1527,6 +1557,13 @@ static int igt_output_commit(igt_output_t *output,
 
pipe = igt_output_get_driving_pipe(output);
 
+   if (pipe-background_changed) {
+   igt_crtc_set_property(output, pipe-background_property,
+   pipe-background);
+
+   pipe-background_changed = false;
+   }
+
for (i = 0; i  pipe-n_planes; i++) {
igt_plane_t *plane = pipe-planes[i];
 
@@ -1779,6 +1816,30 @@ void igt_plane_set_rotation(igt_plane_t *plane, 
igt_rotation_t rotation)
plane-rotation_changed = true;
 }
 
+/**
+ * igt_crtc_set_background:
+ * @pipe: pipe pointer to which background color to be set
+ * @background: background color value in BGR 16bpc
+ *
+ * Sets background color for requested pipe. Color value provided here
+ * will be actually submitted at output commit time via background_color
+ * property.
+ * For example to get red as background, set background = 0x.
+ */
+void igt_crtc_set_background(igt_pipe_t *pipe, uint64_t background)
+{
+   igt_display_t *display = pipe-display;
+
+   LOG(display, %s.%d: crtc_set_background(%lu)\n,
+   kmstest_pipe_name(pipe-pipe),
+   pipe-pipe, background);
+
+   pipe-background = background;
+
+   pipe-background_changed = true;
+}
+
+
 void igt_wait_for_vblank(int drm_fd, enum pipe pipe)
 {
drmVBlank wait_vbl;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 565df14..84e8456 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -207,6 +207,9 @@ struct igt_pipe {
 #define IGT_MAX_PLANES 4
int n_planes;
igt_plane_t planes[IGT_MAX_PLANES];
+   uint64_t background; /* Background color MSB BGR 16bpc LSB */
+   uint32_t background_changed : 1;
+   uint32_t background_property;
 };
 
 typedef struct {
@@ -252,6 +255,7 @@ void igt_plane_set_position(igt_plane_t *plane, int x,