All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
@ 2018-08-15 10:08 ` Maarten Lankhorst
  0 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2018-08-15 10:08 UTC (permalink / raw)
  To: igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

This adds the possibility to test arbitrary enumerations in IGT without
having to define mappings for each and every one.

Changes since v1:
- Add commit description.
- Add try_prop_enum, to allow handling unknown enumerations.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_kms.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h | 31 +++++++++++++++++-
 2 files changed, 120 insertions(+), 1 deletion(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index c9e00c3bd6a7..e5272103e243 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2891,6 +2891,48 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties
 					plane->drm_plane->plane_id, plane->props[prop]);
 }
 
+static bool igt_mode_object_get_prop_enum_value(int drm_fd, uint32_t id, const char *str, uint64_t *val)
+{
+	drmModePropertyPtr prop = drmModeGetProperty(drm_fd, id);
+	int i;
+
+	igt_assert(id);
+	igt_assert(prop);
+
+	for (i = 0; i < prop->count_enums; i++)
+		if (!strcmp(str, prop->enums[i].name)) {
+			*val = prop->enums[i].value;
+			drmModeFreeProperty(prop);
+			return true;
+		}
+
+	return false;
+}
+
+bool igt_plane_try_prop_enum(igt_plane_t *plane,
+			     enum igt_atomic_plane_properties prop,
+			     const char *val)
+{
+	igt_display_t *display = plane->pipe->display;
+	uint64_t uval;
+
+	igt_assert(plane->props[prop]);
+
+	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+						 plane->props[prop], val, &uval))
+		return false;
+
+	igt_plane_set_prop_value(plane, prop, uval);
+	return true;
+}
+
+void igt_plane_set_prop_enum(igt_plane_t *plane,
+			     enum igt_atomic_plane_properties prop,
+			     const char *val)
+{
+	igt_assert(igt_plane_try_prop_enum(plane, prop, val));
+}
+
 /**
  * igt_plane_replace_prop_blob:
  * @plane: plane to set property on.
@@ -2942,6 +2984,30 @@ uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_pro
 					output->id, output->props[prop]);
 }
 
+bool igt_output_try_prop_enum(igt_output_t *output,
+			      enum igt_atomic_connector_properties prop,
+			      const char *val)
+{
+	igt_display_t *display = output->display;
+	uint64_t uval;
+
+	igt_assert(output->props[prop]);
+
+	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+						 output->props[prop], val, &uval))
+		return false;
+
+	igt_output_set_prop_value(output, prop, uval);
+	return true;
+}
+
+void igt_output_set_prop_enum(igt_output_t *output,
+			      enum igt_atomic_connector_properties prop,
+			      const char *val)
+{
+	igt_assert(igt_output_try_prop_enum(output, prop, val));
+}
+
 /**
  * igt_output_replace_prop_blob:
  * @output: output to set property on.
@@ -2993,6 +3059,30 @@ uint64_t igt_pipe_obj_get_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties
 					pipe->crtc_id, pipe->props[prop]);
 }
 
+bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe_obj,
+				enum igt_atomic_crtc_properties prop,
+				const char *val)
+{
+	igt_display_t *display = pipe_obj->display;
+	uint64_t uval;
+
+	igt_assert(pipe_obj->props[prop]);
+
+	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+						 pipe_obj->props[prop], val, &uval))
+		return false;
+
+	igt_pipe_obj_set_prop_value(pipe_obj, prop, uval);
+	return true;
+}
+
+void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe_obj,
+				enum igt_atomic_crtc_properties prop,
+				const char *val)
+{
+	igt_assert(igt_pipe_obj_try_prop_enum(pipe_obj, prop, val));
+}
+
 /**
  * igt_pipe_obj_replace_prop_blob:
  * @pipe: pipe to set property on.
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4222a3418103..3a12f2782eed 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -574,6 +574,14 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties
 		igt_plane_set_prop_changed(plane, prop); \
 	} while (0)
 
+extern bool igt_plane_try_prop_enum(igt_plane_t *plane,
+				    enum igt_atomic_plane_properties prop,
+				    const char *val);
+
+extern void igt_plane_set_prop_enum(igt_plane_t *plane,
+				    enum igt_atomic_plane_properties prop,
+				    const char *val);
+
 extern void igt_plane_replace_prop_blob(igt_plane_t *plane,
 					enum igt_atomic_plane_properties prop,
 					const void *ptr, size_t length);
@@ -609,10 +617,17 @@ uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_pro
 		igt_output_set_prop_changed(output, prop); \
 	} while (0)
 
+extern bool igt_output_try_prop_enum(igt_output_t *output,
+				     enum igt_atomic_connector_properties prop,
+				     const char *val);
+
+extern void igt_output_set_prop_enum(igt_output_t *output,
+				     enum igt_atomic_connector_properties prop,
+				     const char *val);
+
 extern void igt_output_replace_prop_blob(igt_output_t *output,
 					 enum igt_atomic_connector_properties prop,
 					 const void *ptr, size_t length);
-
 /**
  * igt_pipe_obj_has_prop:
  * @pipe: Pipe to check.
@@ -693,6 +708,20 @@ igt_pipe_has_prop(igt_display_t *display, enum pipe pipe,
 #define igt_pipe_set_prop_value(display, pipe, prop, value) \
 	igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop, value)
 
+extern bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe,
+				       enum igt_atomic_crtc_properties prop,
+				       const char *val);
+
+extern void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe,
+				       enum igt_atomic_crtc_properties prop,
+				       const char *val);
+
+#define igt_pipe_try_prop_enum(display, pipe, prop, val) \
+	igt_pipe_obj_try_prop_enum(&(display)->pipes[(pipe)], prop, val)
+
+#define igt_pipe_set_prop_enum(display, pipe, prop, val) \
+	igt_pipe_obj_set_prop_enum(&(display)->pipes[(pipe)], prop, val)
+
 extern void igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe,
 					   enum igt_atomic_crtc_properties prop,
 					   const void *ptr, size_t length);
-- 
2.18.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [igt-dev] [PATCH v2 1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
@ 2018-08-15 10:08 ` Maarten Lankhorst
  0 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2018-08-15 10:08 UTC (permalink / raw)
  To: igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

This adds the possibility to test arbitrary enumerations in IGT without
having to define mappings for each and every one.

Changes since v1:
- Add commit description.
- Add try_prop_enum, to allow handling unknown enumerations.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_kms.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h | 31 +++++++++++++++++-
 2 files changed, 120 insertions(+), 1 deletion(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index c9e00c3bd6a7..e5272103e243 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2891,6 +2891,48 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties
 					plane->drm_plane->plane_id, plane->props[prop]);
 }
 
+static bool igt_mode_object_get_prop_enum_value(int drm_fd, uint32_t id, const char *str, uint64_t *val)
+{
+	drmModePropertyPtr prop = drmModeGetProperty(drm_fd, id);
+	int i;
+
+	igt_assert(id);
+	igt_assert(prop);
+
+	for (i = 0; i < prop->count_enums; i++)
+		if (!strcmp(str, prop->enums[i].name)) {
+			*val = prop->enums[i].value;
+			drmModeFreeProperty(prop);
+			return true;
+		}
+
+	return false;
+}
+
+bool igt_plane_try_prop_enum(igt_plane_t *plane,
+			     enum igt_atomic_plane_properties prop,
+			     const char *val)
+{
+	igt_display_t *display = plane->pipe->display;
+	uint64_t uval;
+
+	igt_assert(plane->props[prop]);
+
+	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+						 plane->props[prop], val, &uval))
+		return false;
+
+	igt_plane_set_prop_value(plane, prop, uval);
+	return true;
+}
+
+void igt_plane_set_prop_enum(igt_plane_t *plane,
+			     enum igt_atomic_plane_properties prop,
+			     const char *val)
+{
+	igt_assert(igt_plane_try_prop_enum(plane, prop, val));
+}
+
 /**
  * igt_plane_replace_prop_blob:
  * @plane: plane to set property on.
@@ -2942,6 +2984,30 @@ uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_pro
 					output->id, output->props[prop]);
 }
 
+bool igt_output_try_prop_enum(igt_output_t *output,
+			      enum igt_atomic_connector_properties prop,
+			      const char *val)
+{
+	igt_display_t *display = output->display;
+	uint64_t uval;
+
+	igt_assert(output->props[prop]);
+
+	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+						 output->props[prop], val, &uval))
+		return false;
+
+	igt_output_set_prop_value(output, prop, uval);
+	return true;
+}
+
+void igt_output_set_prop_enum(igt_output_t *output,
+			      enum igt_atomic_connector_properties prop,
+			      const char *val)
+{
+	igt_assert(igt_output_try_prop_enum(output, prop, val));
+}
+
 /**
  * igt_output_replace_prop_blob:
  * @output: output to set property on.
@@ -2993,6 +3059,30 @@ uint64_t igt_pipe_obj_get_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties
 					pipe->crtc_id, pipe->props[prop]);
 }
 
+bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe_obj,
+				enum igt_atomic_crtc_properties prop,
+				const char *val)
+{
+	igt_display_t *display = pipe_obj->display;
+	uint64_t uval;
+
+	igt_assert(pipe_obj->props[prop]);
+
+	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
+						 pipe_obj->props[prop], val, &uval))
+		return false;
+
+	igt_pipe_obj_set_prop_value(pipe_obj, prop, uval);
+	return true;
+}
+
+void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe_obj,
+				enum igt_atomic_crtc_properties prop,
+				const char *val)
+{
+	igt_assert(igt_pipe_obj_try_prop_enum(pipe_obj, prop, val));
+}
+
 /**
  * igt_pipe_obj_replace_prop_blob:
  * @pipe: pipe to set property on.
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4222a3418103..3a12f2782eed 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -574,6 +574,14 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties
 		igt_plane_set_prop_changed(plane, prop); \
 	} while (0)
 
+extern bool igt_plane_try_prop_enum(igt_plane_t *plane,
+				    enum igt_atomic_plane_properties prop,
+				    const char *val);
+
+extern void igt_plane_set_prop_enum(igt_plane_t *plane,
+				    enum igt_atomic_plane_properties prop,
+				    const char *val);
+
 extern void igt_plane_replace_prop_blob(igt_plane_t *plane,
 					enum igt_atomic_plane_properties prop,
 					const void *ptr, size_t length);
@@ -609,10 +617,17 @@ uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_pro
 		igt_output_set_prop_changed(output, prop); \
 	} while (0)
 
+extern bool igt_output_try_prop_enum(igt_output_t *output,
+				     enum igt_atomic_connector_properties prop,
+				     const char *val);
+
+extern void igt_output_set_prop_enum(igt_output_t *output,
+				     enum igt_atomic_connector_properties prop,
+				     const char *val);
+
 extern void igt_output_replace_prop_blob(igt_output_t *output,
 					 enum igt_atomic_connector_properties prop,
 					 const void *ptr, size_t length);
-
 /**
  * igt_pipe_obj_has_prop:
  * @pipe: Pipe to check.
@@ -693,6 +708,20 @@ igt_pipe_has_prop(igt_display_t *display, enum pipe pipe,
 #define igt_pipe_set_prop_value(display, pipe, prop, value) \
 	igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop, value)
 
+extern bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe,
+				       enum igt_atomic_crtc_properties prop,
+				       const char *val);
+
+extern void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe,
+				       enum igt_atomic_crtc_properties prop,
+				       const char *val);
+
+#define igt_pipe_try_prop_enum(display, pipe, prop, val) \
+	igt_pipe_obj_try_prop_enum(&(display)->pipes[(pipe)], prop, val)
+
+#define igt_pipe_set_prop_enum(display, pipe, prop, val) \
+	igt_pipe_obj_set_prop_enum(&(display)->pipes[(pipe)], prop, val)
+
 extern void igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe,
 					   enum igt_atomic_crtc_properties prop,
 					   const void *ptr, size_t length);
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
  2018-08-15 10:08 ` [igt-dev] " Maarten Lankhorst
@ 2018-08-15 10:08   ` Maarten Lankhorst
  -1 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2018-08-15 10:08 UTC (permalink / raw)
  To: igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

We now have infrastructure for generic enum handling. This will make it easier
to write new tests without defining all enum constants beforehand.

Changes since v1:
- Fix compile error, sent old version by accident.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_color_encoding.c | 20 +++++++++++
 lib/igt_color_encoding.h |  3 ++
 lib/igt_kms.c            | 77 +++++-----------------------------------
 3 files changed, 32 insertions(+), 68 deletions(-)

diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
index f445dbbc0250..03e16e0c9658 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -23,6 +23,7 @@
 
 #include "igt_color_encoding.h"
 #include "igt_matrix.h"
+#include "igt_core.h"
 
 struct color_encoding {
 	float kr, kb;
@@ -141,3 +142,22 @@ struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding color_encoding,
 
 	return igt_matrix_multiply(&r, &c);
 }
+
+const char *igt_color_encoding_to_str(enum igt_color_encoding encoding)
+{
+	switch (encoding) {
+	case IGT_COLOR_YCBCR_BT601: return "ITU-R BT.601 YCbCr";
+	case IGT_COLOR_YCBCR_BT709: return "ITU-R BT.709 YCbCr";
+	case IGT_COLOR_YCBCR_BT2020: return "ITU-R BT.2020 YCbCr";
+	default: igt_assert(0); return NULL;
+	}
+}
+
+const char *igt_color_range_to_str(enum igt_color_range range)
+{
+	switch (range) {
+	case IGT_COLOR_YCBCR_LIMITED_RANGE: return "YCbCr limited range";
+	case IGT_COLOR_YCBCR_FULL_RANGE: return "YCbCr full range";
+	default: igt_assert(0); return NULL;
+	}
+}
diff --git a/lib/igt_color_encoding.h b/lib/igt_color_encoding.h
index 0d8c819322af..3884e4939f4c 100644
--- a/lib/igt_color_encoding.h
+++ b/lib/igt_color_encoding.h
@@ -41,6 +41,9 @@ enum igt_color_range {
 	IGT_NUM_COLOR_RANGES,
 };
 
+const char *igt_color_encoding_to_str(enum igt_color_encoding encoding);
+const char *igt_color_range_to_str(enum igt_color_range range);
+
 struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding color_encoding,
 					enum igt_color_range color_range);
 struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding color_encoding,
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e5272103e243..62d8468415c6 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -196,61 +196,6 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
 	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
 };
 
-static const char * const igt_color_encoding_names[IGT_NUM_COLOR_ENCODINGS] = {
-	[IGT_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
-	[IGT_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
-	[IGT_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
-};
-
-static const char * const igt_color_range_names[IGT_NUM_COLOR_RANGES] = {
-	[IGT_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
-	[IGT_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
-};
-
-static void parse_enum_prop(drmModePropertyPtr prop,
-			    int num_enums,
-			    uint64_t values[],
-			    const char * const enum_names[])
-{
-	igt_assert((prop->flags & ~(DRM_MODE_PROP_IMMUTABLE |
-				    DRM_MODE_PROP_ATOMIC)) == DRM_MODE_PROP_ENUM);
-	igt_assert(prop->count_enums == prop->count_values);
-	igt_assert(prop->count_enums >= 1);
-	igt_assert(!!(prop->flags & DRM_MODE_PROP_IMMUTABLE) == (prop->count_enums == 1));
-
-	for (int i = 0; i < prop->count_enums; i++) {
-		for (int j = 0; j < num_enums; j++) {
-			if (strcmp(prop->enums[i].name, enum_names[j]))
-				continue;
-
-			values[j] = prop->enums[i].value;
-		}
-	}
-}
-
-static void
-parse_color_encoding_prop(igt_plane_t *plane, drmModePropertyPtr prop)
-{
-	parse_enum_prop(prop, ARRAY_SIZE(igt_color_encoding_names),
-			plane->color_encoding.values,
-			igt_color_encoding_names);
-}
-
-static void
-parse_color_range_prop(igt_plane_t *plane, drmModePropertyPtr prop)
-{
-	parse_enum_prop(prop, ARRAY_SIZE(igt_color_range_names),
-			plane->color_range.values,
-			igt_color_range_names);
-}
-
-typedef void (*parse_plane_prop_t)(igt_plane_t *plane, drmModePropertyPtr prop);
-
-static const parse_plane_prop_t igt_parse_plane_prop[IGT_NUM_PLANE_PROPS] = {
-	[IGT_PLANE_COLOR_ENCODING] = parse_color_encoding_prop,
-	[IGT_PLANE_COLOR_RANGE] = parse_color_range_prop,
-};
-
 /*
  * Retrieve all the properies specified in props_name and store them into
  * plane->props.
@@ -275,9 +220,6 @@ igt_fill_plane_props(igt_display_t *display, igt_plane_t *plane,
 			if (strcmp(prop->name, prop_names[j]) != 0)
 				continue;
 
-			if (igt_parse_plane_prop[j])
-				igt_parse_plane_prop[j](plane, prop);
-
 			plane->props[j] = props->props[i];
 			break;
 		}
@@ -1799,11 +1741,12 @@ static void igt_plane_reset(igt_plane_t *plane)
 	igt_plane_set_prop_value(plane, IGT_PLANE_CRTC_ID, 0);
 
 	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
-		igt_plane_set_prop_value(plane, IGT_PLANE_COLOR_ENCODING,
-					 plane->color_encoding.values[IGT_COLOR_YCBCR_BT601]);
+		igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_ENCODING,
+			igt_color_encoding_to_str(IGT_COLOR_YCBCR_BT601));
+
 	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
-		igt_plane_set_prop_value(plane, IGT_PLANE_COLOR_RANGE,
-					 plane->color_range.values[IGT_COLOR_YCBCR_LIMITED_RANGE]);
+		igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_RANGE,
+			igt_color_range_to_str(IGT_COLOR_YCBCR_LIMITED_RANGE));
 
 	/* Use default rotation */
 	if (igt_plane_has_prop(plane, IGT_PLANE_ROTATION))
@@ -3722,13 +3665,11 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb)
 		igt_fb_set_size(fb, plane, fb->width, fb->height);
 
 		if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
-			igt_plane_set_prop_value(plane,
-						 IGT_PLANE_COLOR_ENCODING,
-						 plane->color_encoding.values[fb->color_encoding]);
+			igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_ENCODING,
+				igt_color_encoding_to_str(fb->color_encoding));
 		if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
-			igt_plane_set_prop_value(plane,
-						 IGT_PLANE_COLOR_RANGE,
-						 plane->color_range.values[fb->color_range]);
+			igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_RANGE,
+				igt_color_range_to_str(fb->color_range));
 	} else {
 		igt_plane_set_size(plane, 0, 0);
 
-- 
2.18.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [igt-dev] [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
@ 2018-08-15 10:08   ` Maarten Lankhorst
  0 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2018-08-15 10:08 UTC (permalink / raw)
  To: igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

We now have infrastructure for generic enum handling. This will make it easier
to write new tests without defining all enum constants beforehand.

Changes since v1:
- Fix compile error, sent old version by accident.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_color_encoding.c | 20 +++++++++++
 lib/igt_color_encoding.h |  3 ++
 lib/igt_kms.c            | 77 +++++-----------------------------------
 3 files changed, 32 insertions(+), 68 deletions(-)

diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
index f445dbbc0250..03e16e0c9658 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -23,6 +23,7 @@
 
 #include "igt_color_encoding.h"
 #include "igt_matrix.h"
+#include "igt_core.h"
 
 struct color_encoding {
 	float kr, kb;
@@ -141,3 +142,22 @@ struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding color_encoding,
 
 	return igt_matrix_multiply(&r, &c);
 }
+
+const char *igt_color_encoding_to_str(enum igt_color_encoding encoding)
+{
+	switch (encoding) {
+	case IGT_COLOR_YCBCR_BT601: return "ITU-R BT.601 YCbCr";
+	case IGT_COLOR_YCBCR_BT709: return "ITU-R BT.709 YCbCr";
+	case IGT_COLOR_YCBCR_BT2020: return "ITU-R BT.2020 YCbCr";
+	default: igt_assert(0); return NULL;
+	}
+}
+
+const char *igt_color_range_to_str(enum igt_color_range range)
+{
+	switch (range) {
+	case IGT_COLOR_YCBCR_LIMITED_RANGE: return "YCbCr limited range";
+	case IGT_COLOR_YCBCR_FULL_RANGE: return "YCbCr full range";
+	default: igt_assert(0); return NULL;
+	}
+}
diff --git a/lib/igt_color_encoding.h b/lib/igt_color_encoding.h
index 0d8c819322af..3884e4939f4c 100644
--- a/lib/igt_color_encoding.h
+++ b/lib/igt_color_encoding.h
@@ -41,6 +41,9 @@ enum igt_color_range {
 	IGT_NUM_COLOR_RANGES,
 };
 
+const char *igt_color_encoding_to_str(enum igt_color_encoding encoding);
+const char *igt_color_range_to_str(enum igt_color_range range);
+
 struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding color_encoding,
 					enum igt_color_range color_range);
 struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding color_encoding,
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e5272103e243..62d8468415c6 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -196,61 +196,6 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
 	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
 };
 
-static const char * const igt_color_encoding_names[IGT_NUM_COLOR_ENCODINGS] = {
-	[IGT_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
-	[IGT_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
-	[IGT_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
-};
-
-static const char * const igt_color_range_names[IGT_NUM_COLOR_RANGES] = {
-	[IGT_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
-	[IGT_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
-};
-
-static void parse_enum_prop(drmModePropertyPtr prop,
-			    int num_enums,
-			    uint64_t values[],
-			    const char * const enum_names[])
-{
-	igt_assert((prop->flags & ~(DRM_MODE_PROP_IMMUTABLE |
-				    DRM_MODE_PROP_ATOMIC)) == DRM_MODE_PROP_ENUM);
-	igt_assert(prop->count_enums == prop->count_values);
-	igt_assert(prop->count_enums >= 1);
-	igt_assert(!!(prop->flags & DRM_MODE_PROP_IMMUTABLE) == (prop->count_enums == 1));
-
-	for (int i = 0; i < prop->count_enums; i++) {
-		for (int j = 0; j < num_enums; j++) {
-			if (strcmp(prop->enums[i].name, enum_names[j]))
-				continue;
-
-			values[j] = prop->enums[i].value;
-		}
-	}
-}
-
-static void
-parse_color_encoding_prop(igt_plane_t *plane, drmModePropertyPtr prop)
-{
-	parse_enum_prop(prop, ARRAY_SIZE(igt_color_encoding_names),
-			plane->color_encoding.values,
-			igt_color_encoding_names);
-}
-
-static void
-parse_color_range_prop(igt_plane_t *plane, drmModePropertyPtr prop)
-{
-	parse_enum_prop(prop, ARRAY_SIZE(igt_color_range_names),
-			plane->color_range.values,
-			igt_color_range_names);
-}
-
-typedef void (*parse_plane_prop_t)(igt_plane_t *plane, drmModePropertyPtr prop);
-
-static const parse_plane_prop_t igt_parse_plane_prop[IGT_NUM_PLANE_PROPS] = {
-	[IGT_PLANE_COLOR_ENCODING] = parse_color_encoding_prop,
-	[IGT_PLANE_COLOR_RANGE] = parse_color_range_prop,
-};
-
 /*
  * Retrieve all the properies specified in props_name and store them into
  * plane->props.
@@ -275,9 +220,6 @@ igt_fill_plane_props(igt_display_t *display, igt_plane_t *plane,
 			if (strcmp(prop->name, prop_names[j]) != 0)
 				continue;
 
-			if (igt_parse_plane_prop[j])
-				igt_parse_plane_prop[j](plane, prop);
-
 			plane->props[j] = props->props[i];
 			break;
 		}
@@ -1799,11 +1741,12 @@ static void igt_plane_reset(igt_plane_t *plane)
 	igt_plane_set_prop_value(plane, IGT_PLANE_CRTC_ID, 0);
 
 	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
-		igt_plane_set_prop_value(plane, IGT_PLANE_COLOR_ENCODING,
-					 plane->color_encoding.values[IGT_COLOR_YCBCR_BT601]);
+		igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_ENCODING,
+			igt_color_encoding_to_str(IGT_COLOR_YCBCR_BT601));
+
 	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
-		igt_plane_set_prop_value(plane, IGT_PLANE_COLOR_RANGE,
-					 plane->color_range.values[IGT_COLOR_YCBCR_LIMITED_RANGE]);
+		igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_RANGE,
+			igt_color_range_to_str(IGT_COLOR_YCBCR_LIMITED_RANGE));
 
 	/* Use default rotation */
 	if (igt_plane_has_prop(plane, IGT_PLANE_ROTATION))
@@ -3722,13 +3665,11 @@ void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb)
 		igt_fb_set_size(fb, plane, fb->width, fb->height);
 
 		if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
-			igt_plane_set_prop_value(plane,
-						 IGT_PLANE_COLOR_ENCODING,
-						 plane->color_encoding.values[fb->color_encoding]);
+			igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_ENCODING,
+				igt_color_encoding_to_str(fb->color_encoding));
 		if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
-			igt_plane_set_prop_value(plane,
-						 IGT_PLANE_COLOR_RANGE,
-						 plane->color_range.values[fb->color_range]);
+			igt_plane_set_prop_enum(plane, IGT_PLANE_COLOR_RANGE,
+				igt_color_range_to_str(fb->color_range));
 	} else {
 		igt_plane_set_size(plane, 0, 0);
 
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v2 3/3] tests: Add kms plane alpha blending test, v2.
  2018-08-15 10:08 ` [igt-dev] " Maarten Lankhorst
@ 2018-08-15 10:08   ` Maarten Lankhorst
  -1 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2018-08-15 10:08 UTC (permalink / raw)
  To: igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

Add a few tests to test various blending modes.

Some of the tests will skip if pixel mode alpha cannot be enabled
with plane alpha at the same time. This is for mali-dp. I didn't
test on that platform, but tested with the same check on i915.

The tests won't pass i915 on pre-gen11 hw. i915 has small rounding
errors with 0xff and 0x00 alpha, which gives CRC mismatches.

Changes since v1:
- Send the correct version, with the skips for mali-dp in place.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_kms.c                 |   2 +
 lib/igt_kms.h                 |   2 +
 tests/Makefile.sources        |   1 +
 tests/kms_plane_alpha_blend.c | 571 ++++++++++++++++++++++++++++++++++
 tests/meson.build             |   1 +
 5 files changed, 577 insertions(+)
 create mode 100644 tests/kms_plane_alpha_blend.c

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 62d8468415c6..70373bc373a9 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -175,6 +175,8 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	[IGT_PLANE_IN_FORMATS] = "IN_FORMATS",
 	[IGT_PLANE_COLOR_ENCODING] = "COLOR_ENCODING",
 	[IGT_PLANE_COLOR_RANGE] = "COLOR_RANGE",
+	[IGT_PLANE_PIXEL_BLEND_MODE] = "pixel blend mode",
+	[IGT_PLANE_ALPHA] = "alpha",
 };
 
 const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3a12f2782eed..f0509b51a038 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -266,6 +266,8 @@ enum igt_atomic_plane_properties {
        IGT_PLANE_IN_FORMATS,
        IGT_PLANE_COLOR_ENCODING,
        IGT_PLANE_COLOR_RANGE,
+       IGT_PLANE_PIXEL_BLEND_MODE,
+       IGT_PLANE_ALPHA,
        IGT_NUM_PLANE_PROPS
 };
 
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c84933f1d971..e17eb3cb2029 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -194,6 +194,7 @@ TESTS_progs = \
 	kms_pipe_b_c_ivb \
 	kms_pipe_crc_basic \
 	kms_plane \
+	kms_plane_alpha_blend \
 	kms_plane_lowres \
 	kms_plane_multiple \
 	kms_plane_scaling \
diff --git a/tests/kms_plane_alpha_blend.c b/tests/kms_plane_alpha_blend.c
new file mode 100644
index 000000000000..3aa8f295a7e5
--- /dev/null
+++ b/tests/kms_plane_alpha_blend.c
@@ -0,0 +1,571 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *   Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
+ */
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Test plane alpha and blending mode properties");
+
+typedef struct {
+	int gfx_fd;
+	igt_display_t display;
+	struct igt_fb xrgb_fb, argb_fb_0, argb_fb_cov_0, argb_fb_7e, argb_fb_cov_7e, argb_fb_fc, argb_fb_cov_fc, argb_fb_100, black_fb, gray_fb;
+	igt_crc_t ref_crc;
+	igt_pipe_crc_t *pipe_crc;
+} data_t;
+
+static void __draw_gradient(struct igt_fb *fb, int w, int h, double a, cairo_t *cr)
+{
+	cairo_pattern_t *pat;
+
+	pat = cairo_pattern_create_linear(0, 0, w, h);
+	cairo_pattern_add_color_stop_rgba(pat, 0.00, 0.00, 0.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.25, 1.00, 1.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.50, 0.00, 1.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.75, 1.00, 0.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 1.00, 1.00, 1.00, 1.00, 1.);
+
+	cairo_rectangle(cr, 0, 0, w, h);
+	cairo_set_source(cr, pat);
+	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+	cairo_paint_with_alpha(cr, a);
+	cairo_pattern_destroy(pat);
+}
+
+static void draw_gradient(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	__draw_gradient(fb, w, h, a, cr);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_gradient_coverage(struct igt_fb *fb, int w, int h, uint8_t a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	uint8_t *data = cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->stride;
+	int i;
+
+	__draw_gradient(fb, w, h, 1., cr);
+
+	for (; h--; data += stride)
+		for (i = 0; i < w; i++)
+			data[i * 4 + 3] = a;
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	igt_paint_color_alpha(cr, 0, 0,         w / 2, h / 2, 1., 0., 0., a);
+	igt_paint_color_alpha(cr, w / 2, 0,     w / 2, h / 2, 0., 1., 0., a);
+	igt_paint_color_alpha(cr, 0, h / 2,     w / 2, h / 2, 0., 0., 1., a);
+	igt_paint_color_alpha(cr, w / 2, h / 2, w / 4, h / 2, 1., 1., 1., a);
+	igt_paint_color_alpha(cr, 3 * w / 4, h / 2, w / 4, h / 2, 0., 0., 0., a);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares_coverage(struct igt_fb *fb, int w, int h, uint8_t as)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	int i, j;
+	uint32_t *data = (void *)cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->stride / 4;
+	uint32_t a = as << 24;
+
+	for (j = 0; j < h / 2; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff0000;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a | 0xff00;
+	}
+
+	for (j = h / 2; j < h; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff;
+
+		for (; i < 3 * w / 4; i++)
+			data[j * stride + i] = a | 0xffffff;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a;
+	}
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void reset_alpha(igt_display_t *display, enum pipe pipe)
+{
+	igt_plane_t *plane;
+
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+	}
+}
+
+static bool has_multiplied_alpha(data_t *data, igt_plane_t *plane)
+{
+	int ret;
+
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x8080);
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	ret = igt_display_try_commit_atomic(&data->display,
+		DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+	igt_plane_set_fb(plane, NULL);
+
+	return ret == 0;
+}
+
+static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe)
+{
+	drmModeModeInfo *mode;
+	igt_display_t *display = &data->display;
+	int w, h;
+	igt_plane_t *primary = igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_display_reset(display);
+	igt_output_set_pipe(output, pipe);
+
+	/* create the pipe_crc object for this pipe */
+	igt_pipe_crc_free(data->pipe_crc);
+	data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	mode = igt_output_get_mode(output);
+	w = mode->hdisplay;
+	h = mode->vdisplay;
+
+	/* recreate all fbs if incompatible */
+	if (data->xrgb_fb.width != w || data->xrgb_fb.height != h) {
+		cairo_t *cr;
+
+		igt_remove_fb(data->gfx_fd, &data->xrgb_fb);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_100);
+		igt_remove_fb(data->gfx_fd, &data->black_fb);
+		igt_remove_fb(data->gfx_fd, &data->gray_fb);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->xrgb_fb);
+		draw_gradient(&data->xrgb_fb, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_0);
+		draw_gradient_coverage(&data->argb_fb_cov_0, w, h, 0);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_0);
+
+		cr = igt_get_cairo_ctx(data->gfx_fd, &data->argb_fb_0);
+		igt_paint_color_alpha(cr, 0, 0, w, h, 0., 0., 0., 1.0);
+		igt_put_cairo_ctx(data->gfx_fd, &data->argb_fb_0, cr);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_7e);
+		draw_squares(&data->argb_fb_7e, w, h, 126. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_7e);
+		draw_squares_coverage(&data->argb_fb_cov_7e, w, h, 0x7e);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_fc);
+		draw_squares(&data->argb_fb_fc, w, h, 252. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_fc);
+		draw_squares_coverage(&data->argb_fb_cov_fc, w, h, 0xfc);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_100);
+		draw_gradient(&data->argb_fb_100, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->black_fb);
+
+		igt_create_color_fb(data->gfx_fd, w, h,
+				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+				    .5, .5, .5, &data->gray_fb);
+	}
+
+	igt_plane_set_fb(primary, &data->black_fb);
+	/* reset alpha property to default */
+	reset_alpha(display, pipe);
+}
+
+static void basic_alpha(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+	int i;
+
+	/* Testcase 1: alpha = 0.0, plane should be transparant. */
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_start(data->pipe_crc);
+	igt_pipe_crc_get_single(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+
+	/* transparant fb should be transparant, no matter what.. */
+	for (i = 7; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, i | (i << 8));
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+
+	/* And test alpha = 0, should give same CRC, but doesn't on some i915 platforms. */
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_pipe_crc_stop(data->pipe_crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void argb_opaque(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with an opaque fb */
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void argb_transparant(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with a transparant fb */
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_min(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0);
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_mid(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x7fff);
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_cov_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_max(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_cov_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, NULL);
+}
+
+static void alpha_7efc(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+	int i;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_pipe_crc_start(data->pipe_crc);
+
+	/* for coverage, plane alpha and fb alpha should be swappable, so swap fb and alpha */
+	for (i = 0; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, ((i/2) << 8) | (i/2));
+		igt_plane_set_fb(plane, &data->argb_fb_fc);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &ref_crc);
+
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, (i << 8) | i);
+		igt_plane_set_fb(plane, &data->argb_fb_7e);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+}
+
+static void coverage_7efc(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+	int i;
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+	igt_pipe_crc_start(data->pipe_crc);
+
+	/* for coverage, plane alpha and fb alpha should be swappable, so swap fb and alpha */
+	for (i = 0; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, ((i/2) << 8) | (i/2));
+		igt_plane_set_fb(plane, &data->argb_fb_cov_fc);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &ref_crc);
+
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, (i << 8) | i);
+		igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+}
+
+static void coverage_premult_constant(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+
+	/* Set a background color on the primary fb for testing */
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+	igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_start(data->pipe_crc);
+	igt_pipe_crc_get_single(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+	igt_plane_set_fb(plane, &data->argb_fb_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x7e7e);
+	igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void run_test_on_pipe_planes(data_t *data, enum pipe pipe, bool blend,
+				    bool must_multiply,
+				    void(*test)(data_t *, enum pipe, igt_plane_t *))
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output = igt_get_single_output_for_pipe(display, pipe);
+	igt_plane_t *plane;
+	bool found = false;
+	bool multiply = false;
+
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (!igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			continue;
+
+		if (blend && !igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			continue;
+
+		prepare_crtc(data, output, pipe);
+
+		/* reset plane alpha properties between each plane */
+		reset_alpha(display, pipe);
+
+		found = true;
+		if (must_multiply && !has_multiplied_alpha(data, plane))
+			continue;
+		multiply = true;
+
+		igt_info("Testing plane %u\n", plane->index);
+		test(data, pipe, plane);
+		igt_plane_set_fb(plane, NULL);
+	}
+
+	igt_require_f(found, "No planes with %s property found\n",
+		      blend ? "pixel blending mode" : "alpha");
+	igt_require_f(multiply, "Multiplied (plane x pixel) alpha not available\n");
+}
+
+static void run_subtests(data_t *data, enum pipe pipe)
+{
+	igt_fixture {
+		bool found = false;
+		igt_plane_t *plane;
+
+		igt_display_require_output_on_pipe(&data->display, pipe);
+		for_each_plane_on_pipe(&data->display, pipe, plane) {
+			if (!igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+				continue;
+
+			found = true;
+			break;
+		}
+
+		igt_require_f(found, "Found no plane on pipe %s with alpha blending supported\n",
+			      kmstest_pipe_name(pipe));
+	}
+
+	igt_subtest_f("pipe-%s-alpha-basic", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, true, basic_alpha);
+
+	igt_subtest_f("pipe-%s-alpha-7efc", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, true, alpha_7efc);
+
+	igt_subtest_f("pipe-%s-coverage-7efc", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, true, coverage_7efc);
+
+	igt_subtest_f("pipe-%s-coverage-vs-premult-vs-constant", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, coverage_premult_constant);
+
+	igt_subtest_f("pipe-%s-alpha-transparant-fb", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, false, argb_transparant);
+
+	igt_subtest_f("pipe-%s-alpha-opaque-fb", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, false, argb_opaque);
+
+	igt_subtest_f("pipe-%s-constant-alpha-min", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_min);
+
+	igt_subtest_f("pipe-%s-constant-alpha-mid", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_mid);
+
+	igt_subtest_f("pipe-%s-constant-alpha-max", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_max);
+}
+
+igt_main
+{
+	data_t data = {};
+	enum pipe pipe;
+
+	igt_fixture {
+		igt_skip_on_simulation();
+
+		data.gfx_fd = drm_open_driver(DRIVER_ANY);
+		igt_require_pipe_crc(data.gfx_fd);
+		igt_display_init(&data.display, data.gfx_fd);
+		igt_require(data.display.is_atomic);
+	}
+
+	for_each_pipe_static(pipe)
+		igt_subtest_group
+			run_subtests(&data, pipe);
+
+	igt_fixture
+		igt_display_fini(&data.display);
+}
diff --git a/tests/meson.build b/tests/meson.build
index 17deb945ec95..4241d68fb176 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -169,6 +169,7 @@ test_progs = [
 	'kms_pipe_b_c_ivb',
 	'kms_pipe_crc_basic',
 	'kms_plane',
+	'kms_plane_alpha_blend',
 	'kms_plane_lowres',
 	'kms_plane_multiple',
 	'kms_plane_scaling',
-- 
2.18.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [igt-dev] [PATCH v2 3/3] tests: Add kms plane alpha blending test, v2.
@ 2018-08-15 10:08   ` Maarten Lankhorst
  0 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2018-08-15 10:08 UTC (permalink / raw)
  To: igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

Add a few tests to test various blending modes.

Some of the tests will skip if pixel mode alpha cannot be enabled
with plane alpha at the same time. This is for mali-dp. I didn't
test on that platform, but tested with the same check on i915.

The tests won't pass i915 on pre-gen11 hw. i915 has small rounding
errors with 0xff and 0x00 alpha, which gives CRC mismatches.

Changes since v1:
- Send the correct version, with the skips for mali-dp in place.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_kms.c                 |   2 +
 lib/igt_kms.h                 |   2 +
 tests/Makefile.sources        |   1 +
 tests/kms_plane_alpha_blend.c | 571 ++++++++++++++++++++++++++++++++++
 tests/meson.build             |   1 +
 5 files changed, 577 insertions(+)
 create mode 100644 tests/kms_plane_alpha_blend.c

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 62d8468415c6..70373bc373a9 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -175,6 +175,8 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	[IGT_PLANE_IN_FORMATS] = "IN_FORMATS",
 	[IGT_PLANE_COLOR_ENCODING] = "COLOR_ENCODING",
 	[IGT_PLANE_COLOR_RANGE] = "COLOR_RANGE",
+	[IGT_PLANE_PIXEL_BLEND_MODE] = "pixel blend mode",
+	[IGT_PLANE_ALPHA] = "alpha",
 };
 
 const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 3a12f2782eed..f0509b51a038 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -266,6 +266,8 @@ enum igt_atomic_plane_properties {
        IGT_PLANE_IN_FORMATS,
        IGT_PLANE_COLOR_ENCODING,
        IGT_PLANE_COLOR_RANGE,
+       IGT_PLANE_PIXEL_BLEND_MODE,
+       IGT_PLANE_ALPHA,
        IGT_NUM_PLANE_PROPS
 };
 
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c84933f1d971..e17eb3cb2029 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -194,6 +194,7 @@ TESTS_progs = \
 	kms_pipe_b_c_ivb \
 	kms_pipe_crc_basic \
 	kms_plane \
+	kms_plane_alpha_blend \
 	kms_plane_lowres \
 	kms_plane_multiple \
 	kms_plane_scaling \
diff --git a/tests/kms_plane_alpha_blend.c b/tests/kms_plane_alpha_blend.c
new file mode 100644
index 000000000000..3aa8f295a7e5
--- /dev/null
+++ b/tests/kms_plane_alpha_blend.c
@@ -0,0 +1,571 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *   Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
+ */
+
+#include "igt.h"
+
+IGT_TEST_DESCRIPTION("Test plane alpha and blending mode properties");
+
+typedef struct {
+	int gfx_fd;
+	igt_display_t display;
+	struct igt_fb xrgb_fb, argb_fb_0, argb_fb_cov_0, argb_fb_7e, argb_fb_cov_7e, argb_fb_fc, argb_fb_cov_fc, argb_fb_100, black_fb, gray_fb;
+	igt_crc_t ref_crc;
+	igt_pipe_crc_t *pipe_crc;
+} data_t;
+
+static void __draw_gradient(struct igt_fb *fb, int w, int h, double a, cairo_t *cr)
+{
+	cairo_pattern_t *pat;
+
+	pat = cairo_pattern_create_linear(0, 0, w, h);
+	cairo_pattern_add_color_stop_rgba(pat, 0.00, 0.00, 0.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.25, 1.00, 1.00, 0.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.50, 0.00, 1.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 0.75, 1.00, 0.00, 1.00, 1.);
+	cairo_pattern_add_color_stop_rgba(pat, 1.00, 1.00, 1.00, 1.00, 1.);
+
+	cairo_rectangle(cr, 0, 0, w, h);
+	cairo_set_source(cr, pat);
+	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+	cairo_paint_with_alpha(cr, a);
+	cairo_pattern_destroy(pat);
+}
+
+static void draw_gradient(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	__draw_gradient(fb, w, h, a, cr);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_gradient_coverage(struct igt_fb *fb, int w, int h, uint8_t a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	uint8_t *data = cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->stride;
+	int i;
+
+	__draw_gradient(fb, w, h, 1., cr);
+
+	for (; h--; data += stride)
+		for (i = 0; i < w; i++)
+			data[i * 4 + 3] = a;
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	igt_paint_color_alpha(cr, 0, 0,         w / 2, h / 2, 1., 0., 0., a);
+	igt_paint_color_alpha(cr, w / 2, 0,     w / 2, h / 2, 0., 1., 0., a);
+	igt_paint_color_alpha(cr, 0, h / 2,     w / 2, h / 2, 0., 0., 1., a);
+	igt_paint_color_alpha(cr, w / 2, h / 2, w / 4, h / 2, 1., 1., 1., a);
+	igt_paint_color_alpha(cr, 3 * w / 4, h / 2, w / 4, h / 2, 0., 0., 0., a);
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void draw_squares_coverage(struct igt_fb *fb, int w, int h, uint8_t as)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	int i, j;
+	uint32_t *data = (void *)cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->stride / 4;
+	uint32_t a = as << 24;
+
+	for (j = 0; j < h / 2; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff0000;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a | 0xff00;
+	}
+
+	for (j = h / 2; j < h; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff;
+
+		for (; i < 3 * w / 4; i++)
+			data[j * stride + i] = a | 0xffffff;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a;
+	}
+
+	igt_put_cairo_ctx(fb->fd, fb, cr);
+}
+
+static void reset_alpha(igt_display_t *display, enum pipe pipe)
+{
+	igt_plane_t *plane;
+
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+
+		if (igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+	}
+}
+
+static bool has_multiplied_alpha(data_t *data, igt_plane_t *plane)
+{
+	int ret;
+
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x8080);
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	ret = igt_display_try_commit_atomic(&data->display,
+		DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xffff);
+	igt_plane_set_fb(plane, NULL);
+
+	return ret == 0;
+}
+
+static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe)
+{
+	drmModeModeInfo *mode;
+	igt_display_t *display = &data->display;
+	int w, h;
+	igt_plane_t *primary = igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY);
+
+	igt_display_reset(display);
+	igt_output_set_pipe(output, pipe);
+
+	/* create the pipe_crc object for this pipe */
+	igt_pipe_crc_free(data->pipe_crc);
+	data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	mode = igt_output_get_mode(output);
+	w = mode->hdisplay;
+	h = mode->vdisplay;
+
+	/* recreate all fbs if incompatible */
+	if (data->xrgb_fb.width != w || data->xrgb_fb.height != h) {
+		cairo_t *cr;
+
+		igt_remove_fb(data->gfx_fd, &data->xrgb_fb);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_0);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_7e);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_cov_fc);
+		igt_remove_fb(data->gfx_fd, &data->argb_fb_100);
+		igt_remove_fb(data->gfx_fd, &data->black_fb);
+		igt_remove_fb(data->gfx_fd, &data->gray_fb);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->xrgb_fb);
+		draw_gradient(&data->xrgb_fb, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_0);
+		draw_gradient_coverage(&data->argb_fb_cov_0, w, h, 0);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_0);
+
+		cr = igt_get_cairo_ctx(data->gfx_fd, &data->argb_fb_0);
+		igt_paint_color_alpha(cr, 0, 0, w, h, 0., 0., 0., 1.0);
+		igt_put_cairo_ctx(data->gfx_fd, &data->argb_fb_0, cr);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_7e);
+		draw_squares(&data->argb_fb_7e, w, h, 126. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_7e);
+		draw_squares_coverage(&data->argb_fb_cov_7e, w, h, 0x7e);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_fc);
+		draw_squares(&data->argb_fb_fc, w, h, 252. / 255.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_cov_fc);
+		draw_squares_coverage(&data->argb_fb_cov_fc, w, h, 0xfc);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_ARGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->argb_fb_100);
+		draw_gradient(&data->argb_fb_100, w, h, 1.);
+
+		igt_create_fb(data->gfx_fd, w, h,
+			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+			      &data->black_fb);
+
+		igt_create_color_fb(data->gfx_fd, w, h,
+				    DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+				    .5, .5, .5, &data->gray_fb);
+	}
+
+	igt_plane_set_fb(primary, &data->black_fb);
+	/* reset alpha property to default */
+	reset_alpha(display, pipe);
+}
+
+static void basic_alpha(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+	int i;
+
+	/* Testcase 1: alpha = 0.0, plane should be transparant. */
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_start(data->pipe_crc);
+	igt_pipe_crc_get_single(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+
+	/* transparant fb should be transparant, no matter what.. */
+	for (i = 7; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, i | (i << 8));
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+
+	/* And test alpha = 0, should give same CRC, but doesn't on some i915 platforms. */
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_pipe_crc_stop(data->pipe_crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void argb_opaque(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with an opaque fb */
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void argb_transparant(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	/* alpha = 1.0, plane should be fully opaque, test with a transparant fb */
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_min(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	igt_plane_set_fb(plane, NULL);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0);
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_mid(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x7fff);
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_cov_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void constant_alpha_max(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc, crc;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_fb(plane, &data->argb_fb_100);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->argb_fb_cov_0);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, &data->xrgb_fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_fb(plane, NULL);
+}
+
+static void alpha_7efc(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+	int i;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_pipe_crc_start(data->pipe_crc);
+
+	/* for coverage, plane alpha and fb alpha should be swappable, so swap fb and alpha */
+	for (i = 0; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, ((i/2) << 8) | (i/2));
+		igt_plane_set_fb(plane, &data->argb_fb_fc);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &ref_crc);
+
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, (i << 8) | i);
+		igt_plane_set_fb(plane, &data->argb_fb_7e);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+}
+
+static void coverage_7efc(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+	int i;
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+	igt_pipe_crc_start(data->pipe_crc);
+
+	/* for coverage, plane alpha and fb alpha should be swappable, so swap fb and alpha */
+	for (i = 0; i < 256; i += 8) {
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, ((i/2) << 8) | (i/2));
+		igt_plane_set_fb(plane, &data->argb_fb_cov_fc);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &ref_crc);
+
+		igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, (i << 8) | i);
+		igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+		igt_display_commit2(display, COMMIT_ATOMIC);
+
+		igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+		igt_assert_crc_equal(&ref_crc, &crc);
+	}
+}
+
+static void coverage_premult_constant(data_t *data, enum pipe pipe, igt_plane_t *plane)
+{
+	igt_display_t *display = &data->display;
+	igt_crc_t ref_crc = {}, crc = {};
+
+	/* Set a background color on the primary fb for testing */
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		igt_plane_set_fb(igt_pipe_get_plane_type(&display->pipes[pipe], DRM_PLANE_TYPE_PRIMARY), &data->gray_fb);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+	igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_start(data->pipe_crc);
+	igt_pipe_crc_get_single(data->pipe_crc, &ref_crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+	igt_plane_set_fb(plane, &data->argb_fb_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+
+	igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "None");
+	igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0x7e7e);
+	igt_plane_set_fb(plane, &data->argb_fb_cov_7e);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_pipe_crc_get_current(display->drm_fd, data->pipe_crc, &crc);
+	igt_assert_crc_equal(&ref_crc, &crc);
+}
+
+static void run_test_on_pipe_planes(data_t *data, enum pipe pipe, bool blend,
+				    bool must_multiply,
+				    void(*test)(data_t *, enum pipe, igt_plane_t *))
+{
+	igt_display_t *display = &data->display;
+	igt_output_t *output = igt_get_single_output_for_pipe(display, pipe);
+	igt_plane_t *plane;
+	bool found = false;
+	bool multiply = false;
+
+	for_each_plane_on_pipe(display, pipe, plane) {
+		if (!igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+			continue;
+
+		if (blend && !igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
+			continue;
+
+		prepare_crtc(data, output, pipe);
+
+		/* reset plane alpha properties between each plane */
+		reset_alpha(display, pipe);
+
+		found = true;
+		if (must_multiply && !has_multiplied_alpha(data, plane))
+			continue;
+		multiply = true;
+
+		igt_info("Testing plane %u\n", plane->index);
+		test(data, pipe, plane);
+		igt_plane_set_fb(plane, NULL);
+	}
+
+	igt_require_f(found, "No planes with %s property found\n",
+		      blend ? "pixel blending mode" : "alpha");
+	igt_require_f(multiply, "Multiplied (plane x pixel) alpha not available\n");
+}
+
+static void run_subtests(data_t *data, enum pipe pipe)
+{
+	igt_fixture {
+		bool found = false;
+		igt_plane_t *plane;
+
+		igt_display_require_output_on_pipe(&data->display, pipe);
+		for_each_plane_on_pipe(&data->display, pipe, plane) {
+			if (!igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
+				continue;
+
+			found = true;
+			break;
+		}
+
+		igt_require_f(found, "Found no plane on pipe %s with alpha blending supported\n",
+			      kmstest_pipe_name(pipe));
+	}
+
+	igt_subtest_f("pipe-%s-alpha-basic", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, true, basic_alpha);
+
+	igt_subtest_f("pipe-%s-alpha-7efc", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, true, alpha_7efc);
+
+	igt_subtest_f("pipe-%s-coverage-7efc", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, true, coverage_7efc);
+
+	igt_subtest_f("pipe-%s-coverage-vs-premult-vs-constant", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, coverage_premult_constant);
+
+	igt_subtest_f("pipe-%s-alpha-transparant-fb", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, false, argb_transparant);
+
+	igt_subtest_f("pipe-%s-alpha-opaque-fb", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, false, false, argb_opaque);
+
+	igt_subtest_f("pipe-%s-constant-alpha-min", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_min);
+
+	igt_subtest_f("pipe-%s-constant-alpha-mid", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_mid);
+
+	igt_subtest_f("pipe-%s-constant-alpha-max", kmstest_pipe_name(pipe))
+		run_test_on_pipe_planes(data, pipe, true, false, constant_alpha_max);
+}
+
+igt_main
+{
+	data_t data = {};
+	enum pipe pipe;
+
+	igt_fixture {
+		igt_skip_on_simulation();
+
+		data.gfx_fd = drm_open_driver(DRIVER_ANY);
+		igt_require_pipe_crc(data.gfx_fd);
+		igt_display_init(&data.display, data.gfx_fd);
+		igt_require(data.display.is_atomic);
+	}
+
+	for_each_pipe_static(pipe)
+		igt_subtest_group
+			run_subtests(&data, pipe);
+
+	igt_fixture
+		igt_display_fini(&data.display);
+}
diff --git a/tests/meson.build b/tests/meson.build
index 17deb945ec95..4241d68fb176 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -169,6 +169,7 @@ test_progs = [
 	'kms_pipe_b_c_ivb',
 	'kms_pipe_crc_basic',
 	'kms_plane',
+	'kms_plane_alpha_blend',
 	'kms_plane_lowres',
 	'kms_plane_multiple',
 	'kms_plane_scaling',
-- 
2.18.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for series starting with [v2,1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
  2018-08-15 10:08 ` [igt-dev] " Maarten Lankhorst
                   ` (2 preceding siblings ...)
  (?)
@ 2018-08-15 15:54 ` Patchwork
  -1 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2018-08-15 15:54 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: igt-dev

== Series Details ==

Series: series starting with [v2,1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
URL   : https://patchwork.freedesktop.org/series/48240/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4669 -> IGTPW_1716 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/48240/revisions/1/mbox/

== Known issues ==

  Here are the changes found in IGTPW_1716 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_requests:
      {fi-bsw-kefka}:     PASS -> INCOMPLETE (fdo#105876)

    igt@drv_selftest@live_workarounds:
      {fi-bsw-kefka}:     PASS -> DMESG-FAIL (fdo#107292)

    igt@kms_frontbuffer_tracking@basic:
      fi-hsw-peppy:       PASS -> DMESG-FAIL (fdo#102614)
      {fi-byt-clapper}:   PASS -> FAIL (fdo#103167)

    {igt@kms_psr@primary_mmap_gtt}:
      fi-cnl-psr:         PASS -> DMESG-WARN (fdo#107372)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_coherency:
      fi-gdg-551:         DMESG-FAIL (fdo#107164) -> PASS

    igt@drv_selftest@live_hangcheck:
      fi-skl-guc:         DMESG-FAIL (fdo#107174) -> PASS

    igt@drv_selftest@live_workarounds:
      fi-kbl-7560u:       DMESG-FAIL (fdo#107292) -> PASS

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#105876 https://bugs.freedesktop.org/show_bug.cgi?id=105876
  fdo#107164 https://bugs.freedesktop.org/show_bug.cgi?id=107164
  fdo#107174 https://bugs.freedesktop.org/show_bug.cgi?id=107174
  fdo#107292 https://bugs.freedesktop.org/show_bug.cgi?id=107292
  fdo#107372 https://bugs.freedesktop.org/show_bug.cgi?id=107372


== Participating hosts (53 -> 48) ==

  Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


== Build changes ==

    * IGT: IGT_4597 -> IGTPW_1716

  CI_DRM_4669: aea12ded40860145c23f1c1a28a386fb97ae6e4e @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1716: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1716/
  IGT_4597: 347a07ba3d7796f7f701baed1599319fe3fc1958 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@kms_plane_alpha_blend@pipe-a-alpha-7efc
+igt@kms_plane_alpha_blend@pipe-a-alpha-basic
+igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb
+igt@kms_plane_alpha_blend@pipe-a-alpha-transparant-fb
+igt@kms_plane_alpha_blend@pipe-a-constant-alpha-max
+igt@kms_plane_alpha_blend@pipe-a-constant-alpha-mid
+igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min
+igt@kms_plane_alpha_blend@pipe-a-coverage-7efc
+igt@kms_plane_alpha_blend@pipe-a-coverage-vs-premult-vs-constant
+igt@kms_plane_alpha_blend@pipe-b-alpha-7efc
+igt@kms_plane_alpha_blend@pipe-b-alpha-basic
+igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb
+igt@kms_plane_alpha_blend@pipe-b-alpha-transparant-fb
+igt@kms_plane_alpha_blend@pipe-b-constant-alpha-max
+igt@kms_plane_alpha_blend@pipe-b-constant-alpha-mid
+igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min
+igt@kms_plane_alpha_blend@pipe-b-coverage-7efc
+igt@kms_plane_alpha_blend@pipe-b-coverage-vs-premult-vs-constant
+igt@kms_plane_alpha_blend@pipe-c-alpha-7efc
+igt@kms_plane_alpha_blend@pipe-c-alpha-basic
+igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb
+igt@kms_plane_alpha_blend@pipe-c-alpha-transparant-fb
+igt@kms_plane_alpha_blend@pipe-c-constant-alpha-max
+igt@kms_plane_alpha_blend@pipe-c-constant-alpha-mid
+igt@kms_plane_alpha_blend@pipe-c-constant-alpha-min
+igt@kms_plane_alpha_blend@pipe-c-coverage-7efc
+igt@kms_plane_alpha_blend@pipe-c-coverage-vs-premult-vs-constant
+igt@kms_plane_alpha_blend@pipe-d-alpha-7efc
+igt@kms_plane_alpha_blend@pipe-d-alpha-basic
+igt@kms_plane_alpha_blend@pipe-d-alpha-opaque-fb
+igt@kms_plane_alpha_blend@pipe-d-alpha-transparant-fb
+igt@kms_plane_alpha_blend@pipe-d-constant-alpha-max
+igt@kms_plane_alpha_blend@pipe-d-constant-alpha-mid
+igt@kms_plane_alpha_blend@pipe-d-constant-alpha-min
+igt@kms_plane_alpha_blend@pipe-d-coverage-7efc
+igt@kms_plane_alpha_blend@pipe-d-coverage-vs-premult-vs-constant
+igt@kms_plane_alpha_blend@pipe-e-alpha-7efc
+igt@kms_plane_alpha_blend@pipe-e-alpha-basic
+igt@kms_plane_alpha_blend@pipe-e-alpha-opaque-fb
+igt@kms_plane_alpha_blend@pipe-e-alpha-transparant-fb
+igt@kms_plane_alpha_blend@pipe-e-constant-alpha-max
+igt@kms_plane_alpha_blend@pipe-e-constant-alpha-mid
+igt@kms_plane_alpha_blend@pipe-e-constant-alpha-min
+igt@kms_plane_alpha_blend@pipe-e-coverage-7efc
+igt@kms_plane_alpha_blend@pipe-e-coverage-vs-premult-vs-constant
+igt@kms_plane_alpha_blend@pipe-f-alpha-7efc
+igt@kms_plane_alpha_blend@pipe-f-alpha-basic
+igt@kms_plane_alpha_blend@pipe-f-alpha-opaque-fb
+igt@kms_plane_alpha_blend@pipe-f-alpha-transparant-fb
+igt@kms_plane_alpha_blend@pipe-f-constant-alpha-max
+igt@kms_plane_alpha_blend@pipe-f-constant-alpha-mid
+igt@kms_plane_alpha_blend@pipe-f-constant-alpha-min
+igt@kms_plane_alpha_blend@pipe-f-coverage-7efc
+igt@kms_plane_alpha_blend@pipe-f-coverage-vs-premult-vs-constant

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1716/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [igt-dev] ✗ Fi.CI.IGT: failure for series starting with [v2,1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
  2018-08-15 10:08 ` [igt-dev] " Maarten Lankhorst
                   ` (3 preceding siblings ...)
  (?)
@ 2018-08-15 20:11 ` Patchwork
  -1 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2018-08-15 20:11 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: igt-dev

== Series Details ==

Series: series starting with [v2,1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
URL   : https://patchwork.freedesktop.org/series/48240/
State : failure

== Summary ==

= CI Bug Log - changes from IGT_4597_full -> IGTPW_1716_full =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1716_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1716_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/48240/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1716_full:

  === IGT changes ===

    ==== Possible regressions ====

    igt@kms_draw_crc@draw-method-xrgb8888-blt-ytiled:
      shard-glk:          PASS -> FAIL

    
== Known issues ==

  Here are the changes found in IGTPW_1716_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_hangcheck:
      shard-kbl:          PASS -> DMESG-FAIL (fdo#106947, fdo#106560)

    igt@gem_ppgtt@blt-vs-render-ctx0:
      shard-kbl:          PASS -> INCOMPLETE (fdo#106023, fdo#103665)

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-kbl:          PASS -> FAIL (fdo#102887, fdo#105363)

    igt@perf@blocking:
      shard-hsw:          PASS -> FAIL (fdo#102252)

    igt@testdisplay:
      shard-glk:          PASS -> INCOMPLETE (fdo#107093, fdo#103359, k.org#198133)

    
    ==== Possible fixes ====

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-snb:          FAIL (fdo#106641) -> PASS

    igt@kms_busy@extended-modeset-hang-oldfb-render-e:
      shard-snb:          INCOMPLETE (fdo#105411) -> SKIP

    igt@kms_plane@pixel-format-pipe-a-planes:
      shard-snb:          FAIL (fdo#107161) -> PASS

    igt@kms_rotation_crc@primary-rotation-180:
      shard-snb:          FAIL (fdo#103925) -> PASS

    igt@kms_setmode@basic:
      shard-kbl:          FAIL (fdo#99912) -> PASS

    
  fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
  fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
  fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
  fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
  fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
  fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
  fdo#107093 https://bugs.freedesktop.org/show_bug.cgi?id=107093
  fdo#107161 https://bugs.freedesktop.org/show_bug.cgi?id=107161
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4597 -> IGTPW_1716
    * Linux: CI_DRM_4668 -> CI_DRM_4669

  CI_DRM_4668: 8bae517a4dd2ab6ba57b880835fd253e169779f2 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4669: aea12ded40860145c23f1c1a28a386fb97ae6e4e @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1716: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1716/
  IGT_4597: 347a07ba3d7796f7f701baed1599319fe3fc1958 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1716/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [igt-dev] [PATCH v2 1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
  2018-08-15 10:08 ` [igt-dev] " Maarten Lankhorst
@ 2018-08-24  7:29   ` Mika Kahola
  -1 siblings, 0 replies; 14+ messages in thread
From: Mika Kahola @ 2018-08-24  7:29 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

Looks ok to me.

Reviewed-by: Mika Kahola <mika.kahola@intel.com>

On Wed, 2018-08-15 at 12:08 +0200, Maarten Lankhorst wrote:
> This adds the possibility to test arbitrary enumerations in IGT
> without
> having to define mappings for each and every one.
> 
> Changes since v1:
> - Add commit description.
> - Add try_prop_enum, to allow handling unknown enumerations.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_kms.c | 90
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/igt_kms.h | 31 +++++++++++++++++-
>  2 files changed, 120 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index c9e00c3bd6a7..e5272103e243 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -2891,6 +2891,48 @@ uint64_t igt_plane_get_prop(igt_plane_t
> *plane, enum igt_atomic_plane_properties
>  					plane->drm_plane->plane_id,
> plane->props[prop]);
>  }
>  
> +static bool igt_mode_object_get_prop_enum_value(int drm_fd, uint32_t
> id, const char *str, uint64_t *val)
> +{
> +	drmModePropertyPtr prop = drmModeGetProperty(drm_fd, id);
> +	int i;
> +
> +	igt_assert(id);
> +	igt_assert(prop);
> +
> +	for (i = 0; i < prop->count_enums; i++)
> +		if (!strcmp(str, prop->enums[i].name)) {
> +			*val = prop->enums[i].value;
> +			drmModeFreeProperty(prop);
> +			return true;
> +		}
> +
> +	return false;
> +}
> +
> +bool igt_plane_try_prop_enum(igt_plane_t *plane,
> +			     enum igt_atomic_plane_properties prop,
> +			     const char *val)
> +{
> +	igt_display_t *display = plane->pipe->display;
> +	uint64_t uval;
> +
> +	igt_assert(plane->props[prop]);
> +
> +	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
> +						 plane->props[prop], 
> val, &uval))
> +		return false;
> +
> +	igt_plane_set_prop_value(plane, prop, uval);
> +	return true;
> +}
> +
> +void igt_plane_set_prop_enum(igt_plane_t *plane,
> +			     enum igt_atomic_plane_properties prop,
> +			     const char *val)
> +{
> +	igt_assert(igt_plane_try_prop_enum(plane, prop, val));
> +}
> +
>  /**
>   * igt_plane_replace_prop_blob:
>   * @plane: plane to set property on.
> @@ -2942,6 +2984,30 @@ uint64_t igt_output_get_prop(igt_output_t
> *output, enum igt_atomic_connector_pro
>  					output->id, output-
> >props[prop]);
>  }
>  
> +bool igt_output_try_prop_enum(igt_output_t *output,
> +			      enum igt_atomic_connector_properties
> prop,
> +			      const char *val)
> +{
> +	igt_display_t *display = output->display;
> +	uint64_t uval;
> +
> +	igt_assert(output->props[prop]);
> +
> +	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
> +						 output-
> >props[prop], val, &uval))
> +		return false;
> +
> +	igt_output_set_prop_value(output, prop, uval);
> +	return true;
> +}
> +
> +void igt_output_set_prop_enum(igt_output_t *output,
> +			      enum igt_atomic_connector_properties
> prop,
> +			      const char *val)
> +{
> +	igt_assert(igt_output_try_prop_enum(output, prop, val));
> +}
> +
>  /**
>   * igt_output_replace_prop_blob:
>   * @output: output to set property on.
> @@ -2993,6 +3059,30 @@ uint64_t igt_pipe_obj_get_prop(igt_pipe_t
> *pipe, enum igt_atomic_crtc_properties
>  					pipe->crtc_id, pipe-
> >props[prop]);
>  }
>  
> +bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe_obj,
> +				enum igt_atomic_crtc_properties
> prop,
> +				const char *val)
> +{
> +	igt_display_t *display = pipe_obj->display;
> +	uint64_t uval;
> +
> +	igt_assert(pipe_obj->props[prop]);
> +
> +	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
> +						 pipe_obj-
> >props[prop], val, &uval))
> +		return false;
> +
> +	igt_pipe_obj_set_prop_value(pipe_obj, prop, uval);
> +	return true;
> +}
> +
> +void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe_obj,
> +				enum igt_atomic_crtc_properties
> prop,
> +				const char *val)
> +{
> +	igt_assert(igt_pipe_obj_try_prop_enum(pipe_obj, prop, val));
> +}
> +
>  /**
>   * igt_pipe_obj_replace_prop_blob:
>   * @pipe: pipe to set property on.
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 4222a3418103..3a12f2782eed 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -574,6 +574,14 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane,
> enum igt_atomic_plane_properties
>  		igt_plane_set_prop_changed(plane, prop); \
>  	} while (0)
>  
> +extern bool igt_plane_try_prop_enum(igt_plane_t *plane,
> +				    enum igt_atomic_plane_properties
> prop,
> +				    const char *val);
> +
> +extern void igt_plane_set_prop_enum(igt_plane_t *plane,
> +				    enum igt_atomic_plane_properties
> prop,
> +				    const char *val);
> +
>  extern void igt_plane_replace_prop_blob(igt_plane_t *plane,
>  					enum
> igt_atomic_plane_properties prop,
>  					const void *ptr, size_t
> length);
> @@ -609,10 +617,17 @@ uint64_t igt_output_get_prop(igt_output_t
> *output, enum igt_atomic_connector_pro
>  		igt_output_set_prop_changed(output, prop); \
>  	} while (0)
>  
> +extern bool igt_output_try_prop_enum(igt_output_t *output,
> +				     enum
> igt_atomic_connector_properties prop,
> +				     const char *val);
> +
> +extern void igt_output_set_prop_enum(igt_output_t *output,
> +				     enum
> igt_atomic_connector_properties prop,
> +				     const char *val);
> +
>  extern void igt_output_replace_prop_blob(igt_output_t *output,
>  					 enum
> igt_atomic_connector_properties prop,
>  					 const void *ptr, size_t
> length);
> -
>  /**
>   * igt_pipe_obj_has_prop:
>   * @pipe: Pipe to check.
> @@ -693,6 +708,20 @@ igt_pipe_has_prop(igt_display_t *display, enum
> pipe pipe,
>  #define igt_pipe_set_prop_value(display, pipe, prop, value) \
>  	igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop,
> value)
>  
> +extern bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe,
> +				       enum
> igt_atomic_crtc_properties prop,
> +				       const char *val);
> +
> +extern void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe,
> +				       enum
> igt_atomic_crtc_properties prop,
> +				       const char *val);
> +
> +#define igt_pipe_try_prop_enum(display, pipe, prop, val) \
> +	igt_pipe_obj_try_prop_enum(&(display)->pipes[(pipe)], prop,
> val)
> +
> +#define igt_pipe_set_prop_enum(display, pipe, prop, val) \
> +	igt_pipe_obj_set_prop_enum(&(display)->pipes[(pipe)], prop,
> val)
> +
>  extern void igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe,
>  					   enum
> igt_atomic_crtc_properties prop,
>  					   const void *ptr, size_t
> length);
-- 
Mika Kahola - Intel OTC

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [igt-dev] [PATCH v2 1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2.
@ 2018-08-24  7:29   ` Mika Kahola
  0 siblings, 0 replies; 14+ messages in thread
From: Mika Kahola @ 2018-08-24  7:29 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

Looks ok to me.

Reviewed-by: Mika Kahola <mika.kahola@intel.com>

On Wed, 2018-08-15 at 12:08 +0200, Maarten Lankhorst wrote:
> This adds the possibility to test arbitrary enumerations in IGT
> without
> having to define mappings for each and every one.
> 
> Changes since v1:
> - Add commit description.
> - Add try_prop_enum, to allow handling unknown enumerations.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_kms.c | 90
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/igt_kms.h | 31 +++++++++++++++++-
>  2 files changed, 120 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index c9e00c3bd6a7..e5272103e243 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -2891,6 +2891,48 @@ uint64_t igt_plane_get_prop(igt_plane_t
> *plane, enum igt_atomic_plane_properties
>  					plane->drm_plane->plane_id,
> plane->props[prop]);
>  }
>  
> +static bool igt_mode_object_get_prop_enum_value(int drm_fd, uint32_t
> id, const char *str, uint64_t *val)
> +{
> +	drmModePropertyPtr prop = drmModeGetProperty(drm_fd, id);
> +	int i;
> +
> +	igt_assert(id);
> +	igt_assert(prop);
> +
> +	for (i = 0; i < prop->count_enums; i++)
> +		if (!strcmp(str, prop->enums[i].name)) {
> +			*val = prop->enums[i].value;
> +			drmModeFreeProperty(prop);
> +			return true;
> +		}
> +
> +	return false;
> +}
> +
> +bool igt_plane_try_prop_enum(igt_plane_t *plane,
> +			     enum igt_atomic_plane_properties prop,
> +			     const char *val)
> +{
> +	igt_display_t *display = plane->pipe->display;
> +	uint64_t uval;
> +
> +	igt_assert(plane->props[prop]);
> +
> +	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
> +						 plane->props[prop], 
> val, &uval))
> +		return false;
> +
> +	igt_plane_set_prop_value(plane, prop, uval);
> +	return true;
> +}
> +
> +void igt_plane_set_prop_enum(igt_plane_t *plane,
> +			     enum igt_atomic_plane_properties prop,
> +			     const char *val)
> +{
> +	igt_assert(igt_plane_try_prop_enum(plane, prop, val));
> +}
> +
>  /**
>   * igt_plane_replace_prop_blob:
>   * @plane: plane to set property on.
> @@ -2942,6 +2984,30 @@ uint64_t igt_output_get_prop(igt_output_t
> *output, enum igt_atomic_connector_pro
>  					output->id, output-
> >props[prop]);
>  }
>  
> +bool igt_output_try_prop_enum(igt_output_t *output,
> +			      enum igt_atomic_connector_properties
> prop,
> +			      const char *val)
> +{
> +	igt_display_t *display = output->display;
> +	uint64_t uval;
> +
> +	igt_assert(output->props[prop]);
> +
> +	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
> +						 output-
> >props[prop], val, &uval))
> +		return false;
> +
> +	igt_output_set_prop_value(output, prop, uval);
> +	return true;
> +}
> +
> +void igt_output_set_prop_enum(igt_output_t *output,
> +			      enum igt_atomic_connector_properties
> prop,
> +			      const char *val)
> +{
> +	igt_assert(igt_output_try_prop_enum(output, prop, val));
> +}
> +
>  /**
>   * igt_output_replace_prop_blob:
>   * @output: output to set property on.
> @@ -2993,6 +3059,30 @@ uint64_t igt_pipe_obj_get_prop(igt_pipe_t
> *pipe, enum igt_atomic_crtc_properties
>  					pipe->crtc_id, pipe-
> >props[prop]);
>  }
>  
> +bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe_obj,
> +				enum igt_atomic_crtc_properties
> prop,
> +				const char *val)
> +{
> +	igt_display_t *display = pipe_obj->display;
> +	uint64_t uval;
> +
> +	igt_assert(pipe_obj->props[prop]);
> +
> +	if (!igt_mode_object_get_prop_enum_value(display->drm_fd,
> +						 pipe_obj-
> >props[prop], val, &uval))
> +		return false;
> +
> +	igt_pipe_obj_set_prop_value(pipe_obj, prop, uval);
> +	return true;
> +}
> +
> +void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe_obj,
> +				enum igt_atomic_crtc_properties
> prop,
> +				const char *val)
> +{
> +	igt_assert(igt_pipe_obj_try_prop_enum(pipe_obj, prop, val));
> +}
> +
>  /**
>   * igt_pipe_obj_replace_prop_blob:
>   * @pipe: pipe to set property on.
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 4222a3418103..3a12f2782eed 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -574,6 +574,14 @@ uint64_t igt_plane_get_prop(igt_plane_t *plane,
> enum igt_atomic_plane_properties
>  		igt_plane_set_prop_changed(plane, prop); \
>  	} while (0)
>  
> +extern bool igt_plane_try_prop_enum(igt_plane_t *plane,
> +				    enum igt_atomic_plane_properties
> prop,
> +				    const char *val);
> +
> +extern void igt_plane_set_prop_enum(igt_plane_t *plane,
> +				    enum igt_atomic_plane_properties
> prop,
> +				    const char *val);
> +
>  extern void igt_plane_replace_prop_blob(igt_plane_t *plane,
>  					enum
> igt_atomic_plane_properties prop,
>  					const void *ptr, size_t
> length);
> @@ -609,10 +617,17 @@ uint64_t igt_output_get_prop(igt_output_t
> *output, enum igt_atomic_connector_pro
>  		igt_output_set_prop_changed(output, prop); \
>  	} while (0)
>  
> +extern bool igt_output_try_prop_enum(igt_output_t *output,
> +				     enum
> igt_atomic_connector_properties prop,
> +				     const char *val);
> +
> +extern void igt_output_set_prop_enum(igt_output_t *output,
> +				     enum
> igt_atomic_connector_properties prop,
> +				     const char *val);
> +
>  extern void igt_output_replace_prop_blob(igt_output_t *output,
>  					 enum
> igt_atomic_connector_properties prop,
>  					 const void *ptr, size_t
> length);
> -
>  /**
>   * igt_pipe_obj_has_prop:
>   * @pipe: Pipe to check.
> @@ -693,6 +708,20 @@ igt_pipe_has_prop(igt_display_t *display, enum
> pipe pipe,
>  #define igt_pipe_set_prop_value(display, pipe, prop, value) \
>  	igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop,
> value)
>  
> +extern bool igt_pipe_obj_try_prop_enum(igt_pipe_t *pipe,
> +				       enum
> igt_atomic_crtc_properties prop,
> +				       const char *val);
> +
> +extern void igt_pipe_obj_set_prop_enum(igt_pipe_t *pipe,
> +				       enum
> igt_atomic_crtc_properties prop,
> +				       const char *val);
> +
> +#define igt_pipe_try_prop_enum(display, pipe, prop, val) \
> +	igt_pipe_obj_try_prop_enum(&(display)->pipes[(pipe)], prop,
> val)
> +
> +#define igt_pipe_set_prop_enum(display, pipe, prop, val) \
> +	igt_pipe_obj_set_prop_enum(&(display)->pipes[(pipe)], prop,
> val)
> +
>  extern void igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe,
>  					   enum
> igt_atomic_crtc_properties prop,
>  					   const void *ptr, size_t
> length);
-- 
Mika Kahola - Intel OTC

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [igt-dev] [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
  2018-08-15 10:08   ` [igt-dev] " Maarten Lankhorst
@ 2018-08-28 10:42     ` Mika Kahola
  -1 siblings, 0 replies; 14+ messages in thread
From: Mika Kahola @ 2018-08-28 10:42 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

On Wed, 2018-08-15 at 12:08 +0200, Maarten Lankhorst wrote:
> We now have infrastructure for generic enum handling. This will make
> it easier
> to write new tests without defining all enum constants beforehand.
> 
> Changes since v1:
> - Fix compile error, sent old version by accident.
> 
Reviewed-by: Mika Kahola <mika.kahola@intel.com>

> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_color_encoding.c | 20 +++++++++++
>  lib/igt_color_encoding.h |  3 ++
>  lib/igt_kms.c            | 77 +++++---------------------------------
> --
>  3 files changed, 32 insertions(+), 68 deletions(-)
> 
> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
> index f445dbbc0250..03e16e0c9658 100644
> --- a/lib/igt_color_encoding.c
> +++ b/lib/igt_color_encoding.c
> @@ -23,6 +23,7 @@
>  
>  #include "igt_color_encoding.h"
>  #include "igt_matrix.h"
> +#include "igt_core.h"
>  
>  struct color_encoding {
>  	float kr, kb;
> @@ -141,3 +142,22 @@ struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum
> igt_color_encoding color_encoding,
>  
>  	return igt_matrix_multiply(&r, &c);
>  }
> +
> +const char *igt_color_encoding_to_str(enum igt_color_encoding
> encoding)
> +{
> +	switch (encoding) {
> +	case IGT_COLOR_YCBCR_BT601: return "ITU-R BT.601 YCbCr";
> +	case IGT_COLOR_YCBCR_BT709: return "ITU-R BT.709 YCbCr";
> +	case IGT_COLOR_YCBCR_BT2020: return "ITU-R BT.2020 YCbCr";
> +	default: igt_assert(0); return NULL;
> +	}
> +}
> +
> +const char *igt_color_range_to_str(enum igt_color_range range)
> +{
> +	switch (range) {
> +	case IGT_COLOR_YCBCR_LIMITED_RANGE: return "YCbCr limited
> range";
> +	case IGT_COLOR_YCBCR_FULL_RANGE: return "YCbCr full range";
> +	default: igt_assert(0); return NULL;
> +	}
> +}
> diff --git a/lib/igt_color_encoding.h b/lib/igt_color_encoding.h
> index 0d8c819322af..3884e4939f4c 100644
> --- a/lib/igt_color_encoding.h
> +++ b/lib/igt_color_encoding.h
> @@ -41,6 +41,9 @@ enum igt_color_range {
>  	IGT_NUM_COLOR_RANGES,
>  };
>  
> +const char *igt_color_encoding_to_str(enum igt_color_encoding
> encoding);
> +const char *igt_color_range_to_str(enum igt_color_range range);
> +
>  struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding
> color_encoding,
>  					enum igt_color_range
> color_range);
>  struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding
> color_encoding,
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index e5272103e243..62d8468415c6 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -196,61 +196,6 @@ const char * const
> igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
>  	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
>  };
>  
> -static const char * const
> igt_color_encoding_names[IGT_NUM_COLOR_ENCODINGS] = {
> -	[IGT_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
> -	[IGT_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
> -	[IGT_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
> -};
> -
> -static const char * const
> igt_color_range_names[IGT_NUM_COLOR_RANGES] = {
> -	[IGT_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
> -	[IGT_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
> -};
> -
> -static void parse_enum_prop(drmModePropertyPtr prop,
> -			    int num_enums,
> -			    uint64_t values[],
> -			    const char * const enum_names[])
> -{
> -	igt_assert((prop->flags & ~(DRM_MODE_PROP_IMMUTABLE |
> -				    DRM_MODE_PROP_ATOMIC)) ==
> DRM_MODE_PROP_ENUM);
> -	igt_assert(prop->count_enums == prop->count_values);
> -	igt_assert(prop->count_enums >= 1);
> -	igt_assert(!!(prop->flags & DRM_MODE_PROP_IMMUTABLE) ==
> (prop->count_enums == 1));
> -
> -	for (int i = 0; i < prop->count_enums; i++) {
> -		for (int j = 0; j < num_enums; j++) {
> -			if (strcmp(prop->enums[i].name,
> enum_names[j]))
> -				continue;
> -
> -			values[j] = prop->enums[i].value;
> -		}
> -	}
> -}
> -
> -static void
> -parse_color_encoding_prop(igt_plane_t *plane, drmModePropertyPtr
> prop)
> -{
> -	parse_enum_prop(prop, ARRAY_SIZE(igt_color_encoding_names),
> -			plane->color_encoding.values,
> -			igt_color_encoding_names);
> -}
> -
> -static void
> -parse_color_range_prop(igt_plane_t *plane, drmModePropertyPtr prop)
> -{
> -	parse_enum_prop(prop, ARRAY_SIZE(igt_color_range_names),
> -			plane->color_range.values,
> -			igt_color_range_names);
> -}
> -
> -typedef void (*parse_plane_prop_t)(igt_plane_t *plane,
> drmModePropertyPtr prop);
> -
> -static const parse_plane_prop_t
> igt_parse_plane_prop[IGT_NUM_PLANE_PROPS] = {
> -	[IGT_PLANE_COLOR_ENCODING] = parse_color_encoding_prop,
> -	[IGT_PLANE_COLOR_RANGE] = parse_color_range_prop,
> -};
> -
>  /*
>   * Retrieve all the properies specified in props_name and store them
> into
>   * plane->props.
> @@ -275,9 +220,6 @@ igt_fill_plane_props(igt_display_t *display,
> igt_plane_t *plane,
>  			if (strcmp(prop->name, prop_names[j]) != 0)
>  				continue;
>  
> -			if (igt_parse_plane_prop[j])
> -				igt_parse_plane_prop[j](plane,
> prop);
> -
>  			plane->props[j] = props->props[i];
>  			break;
>  		}
> @@ -1799,11 +1741,12 @@ static void igt_plane_reset(igt_plane_t
> *plane)
>  	igt_plane_set_prop_value(plane, IGT_PLANE_CRTC_ID, 0);
>  
>  	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
> -		igt_plane_set_prop_value(plane,
> IGT_PLANE_COLOR_ENCODING,
> -					 plane-
> >color_encoding.values[IGT_COLOR_YCBCR_BT601]);
> +		igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_ENCODING,
> +			igt_color_encoding_to_str(IGT_COLOR_YCBCR_BT
> 601));
> +
>  	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
> -		igt_plane_set_prop_value(plane,
> IGT_PLANE_COLOR_RANGE,
> -					 plane-
> >color_range.values[IGT_COLOR_YCBCR_LIMITED_RANGE]);
> +		igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_RANGE,
> +			igt_color_range_to_str(IGT_COLOR_YCBCR_LIMIT
> ED_RANGE));
>  
>  	/* Use default rotation */
>  	if (igt_plane_has_prop(plane, IGT_PLANE_ROTATION))
> @@ -3722,13 +3665,11 @@ void igt_plane_set_fb(igt_plane_t *plane,
> struct igt_fb *fb)
>  		igt_fb_set_size(fb, plane, fb->width, fb->height);
>  
>  		if (igt_plane_has_prop(plane,
> IGT_PLANE_COLOR_ENCODING))
> -			igt_plane_set_prop_value(plane,
> -						 IGT_PLANE_COLOR_ENC
> ODING,
> -						 plane-
> >color_encoding.values[fb->color_encoding]);
> +			igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_ENCODING,
> +				igt_color_encoding_to_str(fb-
> >color_encoding));
>  		if (igt_plane_has_prop(plane,
> IGT_PLANE_COLOR_RANGE))
> -			igt_plane_set_prop_value(plane,
> -						 IGT_PLANE_COLOR_RAN
> GE,
> -						 plane-
> >color_range.values[fb->color_range]);
> +			igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_RANGE,
> +				igt_color_range_to_str(fb-
> >color_range));
>  	} else {
>  		igt_plane_set_size(plane, 0, 0);
>  
-- 
Mika Kahola - Intel OTC

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [igt-dev] [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
@ 2018-08-28 10:42     ` Mika Kahola
  0 siblings, 0 replies; 14+ messages in thread
From: Mika Kahola @ 2018-08-28 10:42 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

On Wed, 2018-08-15 at 12:08 +0200, Maarten Lankhorst wrote:
> We now have infrastructure for generic enum handling. This will make
> it easier
> to write new tests without defining all enum constants beforehand.
> 
> Changes since v1:
> - Fix compile error, sent old version by accident.
> 
Reviewed-by: Mika Kahola <mika.kahola@intel.com>

> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  lib/igt_color_encoding.c | 20 +++++++++++
>  lib/igt_color_encoding.h |  3 ++
>  lib/igt_kms.c            | 77 +++++---------------------------------
> --
>  3 files changed, 32 insertions(+), 68 deletions(-)
> 
> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
> index f445dbbc0250..03e16e0c9658 100644
> --- a/lib/igt_color_encoding.c
> +++ b/lib/igt_color_encoding.c
> @@ -23,6 +23,7 @@
>  
>  #include "igt_color_encoding.h"
>  #include "igt_matrix.h"
> +#include "igt_core.h"
>  
>  struct color_encoding {
>  	float kr, kb;
> @@ -141,3 +142,22 @@ struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum
> igt_color_encoding color_encoding,
>  
>  	return igt_matrix_multiply(&r, &c);
>  }
> +
> +const char *igt_color_encoding_to_str(enum igt_color_encoding
> encoding)
> +{
> +	switch (encoding) {
> +	case IGT_COLOR_YCBCR_BT601: return "ITU-R BT.601 YCbCr";
> +	case IGT_COLOR_YCBCR_BT709: return "ITU-R BT.709 YCbCr";
> +	case IGT_COLOR_YCBCR_BT2020: return "ITU-R BT.2020 YCbCr";
> +	default: igt_assert(0); return NULL;
> +	}
> +}
> +
> +const char *igt_color_range_to_str(enum igt_color_range range)
> +{
> +	switch (range) {
> +	case IGT_COLOR_YCBCR_LIMITED_RANGE: return "YCbCr limited
> range";
> +	case IGT_COLOR_YCBCR_FULL_RANGE: return "YCbCr full range";
> +	default: igt_assert(0); return NULL;
> +	}
> +}
> diff --git a/lib/igt_color_encoding.h b/lib/igt_color_encoding.h
> index 0d8c819322af..3884e4939f4c 100644
> --- a/lib/igt_color_encoding.h
> +++ b/lib/igt_color_encoding.h
> @@ -41,6 +41,9 @@ enum igt_color_range {
>  	IGT_NUM_COLOR_RANGES,
>  };
>  
> +const char *igt_color_encoding_to_str(enum igt_color_encoding
> encoding);
> +const char *igt_color_range_to_str(enum igt_color_range range);
> +
>  struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding
> color_encoding,
>  					enum igt_color_range
> color_range);
>  struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding
> color_encoding,
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index e5272103e243..62d8468415c6 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -196,61 +196,6 @@ const char * const
> igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = {
>  	[IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB",
>  };
>  
> -static const char * const
> igt_color_encoding_names[IGT_NUM_COLOR_ENCODINGS] = {
> -	[IGT_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
> -	[IGT_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
> -	[IGT_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
> -};
> -
> -static const char * const
> igt_color_range_names[IGT_NUM_COLOR_RANGES] = {
> -	[IGT_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
> -	[IGT_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
> -};
> -
> -static void parse_enum_prop(drmModePropertyPtr prop,
> -			    int num_enums,
> -			    uint64_t values[],
> -			    const char * const enum_names[])
> -{
> -	igt_assert((prop->flags & ~(DRM_MODE_PROP_IMMUTABLE |
> -				    DRM_MODE_PROP_ATOMIC)) ==
> DRM_MODE_PROP_ENUM);
> -	igt_assert(prop->count_enums == prop->count_values);
> -	igt_assert(prop->count_enums >= 1);
> -	igt_assert(!!(prop->flags & DRM_MODE_PROP_IMMUTABLE) ==
> (prop->count_enums == 1));
> -
> -	for (int i = 0; i < prop->count_enums; i++) {
> -		for (int j = 0; j < num_enums; j++) {
> -			if (strcmp(prop->enums[i].name,
> enum_names[j]))
> -				continue;
> -
> -			values[j] = prop->enums[i].value;
> -		}
> -	}
> -}
> -
> -static void
> -parse_color_encoding_prop(igt_plane_t *plane, drmModePropertyPtr
> prop)
> -{
> -	parse_enum_prop(prop, ARRAY_SIZE(igt_color_encoding_names),
> -			plane->color_encoding.values,
> -			igt_color_encoding_names);
> -}
> -
> -static void
> -parse_color_range_prop(igt_plane_t *plane, drmModePropertyPtr prop)
> -{
> -	parse_enum_prop(prop, ARRAY_SIZE(igt_color_range_names),
> -			plane->color_range.values,
> -			igt_color_range_names);
> -}
> -
> -typedef void (*parse_plane_prop_t)(igt_plane_t *plane,
> drmModePropertyPtr prop);
> -
> -static const parse_plane_prop_t
> igt_parse_plane_prop[IGT_NUM_PLANE_PROPS] = {
> -	[IGT_PLANE_COLOR_ENCODING] = parse_color_encoding_prop,
> -	[IGT_PLANE_COLOR_RANGE] = parse_color_range_prop,
> -};
> -
>  /*
>   * Retrieve all the properies specified in props_name and store them
> into
>   * plane->props.
> @@ -275,9 +220,6 @@ igt_fill_plane_props(igt_display_t *display,
> igt_plane_t *plane,
>  			if (strcmp(prop->name, prop_names[j]) != 0)
>  				continue;
>  
> -			if (igt_parse_plane_prop[j])
> -				igt_parse_plane_prop[j](plane,
> prop);
> -
>  			plane->props[j] = props->props[i];
>  			break;
>  		}
> @@ -1799,11 +1741,12 @@ static void igt_plane_reset(igt_plane_t
> *plane)
>  	igt_plane_set_prop_value(plane, IGT_PLANE_CRTC_ID, 0);
>  
>  	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
> -		igt_plane_set_prop_value(plane,
> IGT_PLANE_COLOR_ENCODING,
> -					 plane-
> >color_encoding.values[IGT_COLOR_YCBCR_BT601]);
> +		igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_ENCODING,
> +			igt_color_encoding_to_str(IGT_COLOR_YCBCR_BT
> 601));
> +
>  	if (igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
> -		igt_plane_set_prop_value(plane,
> IGT_PLANE_COLOR_RANGE,
> -					 plane-
> >color_range.values[IGT_COLOR_YCBCR_LIMITED_RANGE]);
> +		igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_RANGE,
> +			igt_color_range_to_str(IGT_COLOR_YCBCR_LIMIT
> ED_RANGE));
>  
>  	/* Use default rotation */
>  	if (igt_plane_has_prop(plane, IGT_PLANE_ROTATION))
> @@ -3722,13 +3665,11 @@ void igt_plane_set_fb(igt_plane_t *plane,
> struct igt_fb *fb)
>  		igt_fb_set_size(fb, plane, fb->width, fb->height);
>  
>  		if (igt_plane_has_prop(plane,
> IGT_PLANE_COLOR_ENCODING))
> -			igt_plane_set_prop_value(plane,
> -						 IGT_PLANE_COLOR_ENC
> ODING,
> -						 plane-
> >color_encoding.values[fb->color_encoding]);
> +			igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_ENCODING,
> +				igt_color_encoding_to_str(fb-
> >color_encoding));
>  		if (igt_plane_has_prop(plane,
> IGT_PLANE_COLOR_RANGE))
> -			igt_plane_set_prop_value(plane,
> -						 IGT_PLANE_COLOR_RAN
> GE,
> -						 plane-
> >color_range.values[fb->color_range]);
> +			igt_plane_set_prop_enum(plane,
> IGT_PLANE_COLOR_RANGE,
> +				igt_color_range_to_str(fb-
> >color_range));
>  	} else {
>  		igt_plane_set_size(plane, 0, 0);
>  
-- 
Mika Kahola - Intel OTC

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [igt-dev] [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
  2018-08-28 10:42     ` Mika Kahola
@ 2018-08-30  9:12       ` Maarten Lankhorst
  -1 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2018-08-30  9:12 UTC (permalink / raw)
  To: mika.kahola, igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

Op 28-08-18 om 12:42 schreef Mika Kahola:
> On Wed, 2018-08-15 at 12:08 +0200, Maarten Lankhorst wrote:
>> We now have infrastructure for generic enum handling. This will make
>> it easier
>> to write new tests without defining all enum constants beforehand.
>>
>> Changes since v1:
>> - Fix compile error, sent old version by accident.
>>
> Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Thanks, pushed first 2 patches.

~Maarten
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [igt-dev] [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2.
@ 2018-08-30  9:12       ` Maarten Lankhorst
  0 siblings, 0 replies; 14+ messages in thread
From: Maarten Lankhorst @ 2018-08-30  9:12 UTC (permalink / raw)
  To: mika.kahola, igt-dev; +Cc: Lowry Li, Liviu Dudau, dri-devel

Op 28-08-18 om 12:42 schreef Mika Kahola:
> On Wed, 2018-08-15 at 12:08 +0200, Maarten Lankhorst wrote:
>> We now have infrastructure for generic enum handling. This will make
>> it easier
>> to write new tests without defining all enum constants beforehand.
>>
>> Changes since v1:
>> - Fix compile error, sent old version by accident.
>>
> Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Thanks, pushed first 2 patches.

~Maarten
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-08-30  9:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-15 10:08 [PATCH v2 1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Maarten Lankhorst
2018-08-15 10:08 ` [igt-dev] " Maarten Lankhorst
2018-08-15 10:08 ` [PATCH v2 2/3] lib/kms: Remove special enum handling and replace with call to igt_plane_set_prop_enum, v2 Maarten Lankhorst
2018-08-15 10:08   ` [igt-dev] " Maarten Lankhorst
2018-08-28 10:42   ` Mika Kahola
2018-08-28 10:42     ` Mika Kahola
2018-08-30  9:12     ` Maarten Lankhorst
2018-08-30  9:12       ` Maarten Lankhorst
2018-08-15 10:08 ` [PATCH v2 3/3] tests: Add kms plane alpha blending test, v2 Maarten Lankhorst
2018-08-15 10:08   ` [igt-dev] " Maarten Lankhorst
2018-08-15 15:54 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [v2,1/3] lib/igt_kms: Add try_prop_enum and set_prop_enum for mode objects, v2 Patchwork
2018-08-15 20:11 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-08-24  7:29 ` [igt-dev] [PATCH v2 1/3] " Mika Kahola
2018-08-24  7:29   ` Mika Kahola

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.