Skip to contentSkip to conversation

Add plane color pipeline tests for Intel hardware

PATCH Superseded Swati Sharma 2 participants 11 messages Jul 6, 2025

Subsystems (2)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

cover Add plane color pipeline tests for Intel hardware

Patch [1/9] is the squashed patch based on the series sent out by Alex Hung. It contains all the changes in the series(v9) currently under review below

https://patchwork.freedesktop.org/series/123448/

This patch lays the ground work for incremental changes and Intel specific pipeline changes followed in subsequent patches [2-9].

v2: -dropped CTM 3x3 colorop and used CTM 3x4 colorop instead
-added new plane test with 1D LUT and CTM 3x4 colorops

Bhanuprakash Modem (4):
lib/colorops: Move few helpers to common place to reuse lib/colorops: Add support for 1D LUT multi-segmented tests/kms_color_helper: Add helpers to clear colorops data tests/kms_color: Add Intel plane pipeline tests with LUT1D (MULTSEG)
and CTM

Swati Sharma (5):
tests/kms_colorop: Color pipeline igt base work
drm-uapi: Add Color lut range attributes
drm-uapi: Add 1D LUT multi-segmented color op
lib/kms: Add support for COLOROP_HW_CAPS property tests/kms_color: Add Intel plane pipeline tests with LUT1D and CTM

 include/drm-uapi/amdgpu_drm.h |    9 -
 include/drm-uapi/drm.h        |   15 +
 include/drm-uapi/drm_mode.h   |  183 ++
 lib/drmtest.c                 |    5 +
 lib/drmtest.h                 |    1 +
 lib/igt_color.c               |  672 +++++
 lib/igt_color.h               |  119 +
 lib/igt_color_lut.c           | 4927 +++++++++++++++++++++++++++++++++
 lib/igt_color_lut.h           |   28 +
 lib/igt_fb.c                  |   34 +-
 lib/igt_fb.h                  |    3 +
 lib/igt_kms.c                 |  403 ++-
 lib/igt_kms.h                 |  101 +
 lib/meson.build               |    2 +
 scripts/convert_3dlut.py      |   94 +
 tests/kms_color.c             |  348 ++-
 tests/kms_color_helper.c      |  401 +++
 tests/kms_color_helper.h      |  110 +
 tests/kms_colorop.c           |  703 +++++
 tests/kms_properties.c        |   94 +-
 tests/kms_writeback.c         |   38 +-
 tests/meson.build             |    2 +
 22 files changed, 8225 insertions(+), 67 deletions(-)
 create mode 100644 lib/igt_color.c
 create mode 100644 lib/igt_color.h
 create mode 100644 lib/igt_color_lut.c
 create mode 100644 lib/igt_color_lut.h
 create mode 100755 scripts/convert_3dlut.py
 create mode 100644 tests/kms_colorop.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/9 tests/kms_colorop: Color pipeline igt base work

This is the squashed patch based on the series sent out by Alex Hung. It contains all the changes in the series(v9) currently under review below

https://patchwork.freedesktop.org/series/123448/

This patch lays the ground work for incremental changes and Intel specific pipeline changes.

NOTE: This patch is not meant for review. Any review related to this patch should be done on the original series. In order not to diverge the discussion from the main series.

---
 include/drm-uapi/amdgpu_drm.h |    9 -
 include/drm-uapi/drm.h        |   15 +
 include/drm-uapi/drm_mode.h   |  109 +
 lib/drmtest.c                 |    5 +
 lib/drmtest.h                 |    1 +
 lib/igt_color.c               |  648 +++++
 lib/igt_color.h               |  162 ++
 lib/igt_color_lut.h           | 4946 +++++++++++++++++++++++++++++++++
 lib/igt_fb.c                  |   34 +-
 lib/igt_fb.h                  |    3 +
 lib/igt_kms.c                 |  402 ++-
 lib/igt_kms.h                 |  100 +
 lib/meson.build               |    1 +
 scripts/convert_3dlut.py      |   94 +
 tests/kms_colorop.c           |  751 +++++
 tests/kms_colorop.h           |  261 ++
 tests/kms_properties.c        |   94 +-
 tests/kms_writeback.c         |   38 +-
 tests/meson.build             |    1 +
 19 files changed, 7613 insertions(+), 61 deletions(-)
 create mode 100644 lib/igt_color.c
 create mode 100644 lib/igt_color.h
 create mode 100644 lib/igt_color_lut.h
 create mode 100755 scripts/convert_3dlut.py
 create mode 100644 tests/kms_colorop.c
 create mode 100644 tests/kms_colorop.h
include/drm-uapi/amdgpu_drm.h +0 -9
index ddcda5d3b..85ad93c73 100644
@@ -1589,15 +1589,6 @@ struct drm_amdgpu_info_uq_metadata {
 #define AMDGPU_FAMILY_GC_11_5_0			150 /* GC 11.5.0 */
 #define AMDGPU_FAMILY_GC_12_0_0			152 /* GC 12.0.0 */
 
-/* FIXME wrong namespace! */
-struct drm_color_ctm_3x4 {
-	/*
-	 * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude
-	 * (not two's complement!) format.
-	 */
-	__u64 matrix[12];
-};
-
 #if defined(__cplusplus)
 }
 #endif
include/drm-uapi/drm.h +15 -0
index 4e4f7c2c3..6b9af3348 100644
@@ -869,6 +869,21 @@ struct drm_get_cap {
  */
 #define DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT	6
 
+/**
+ * DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE
+ *
+ * If set to 1, the DRM core will
+ * - expose plane COLOR_PIPELINE properties for pre-blending color management.
+ * - reject setting of these plane properties:
+ *   - COLOR_ENCODING
+ *   - COLOR_RANGE
+ *
+ * The client must enable &DRM_CLIENT_CAP_ATOMIC first.
+ *
+ * This capability is currently in development.
+ */
+#define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE	7
+
 /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
 struct drm_set_client_cap {
 	__u64 capability;
include/drm-uapi/drm_mode.h +109 -0

133 lines not on this page · raw message

lib/drmtest.c +5 -0
index 436b6de78..a3904083f 100644
@@ -118,6 +118,11 @@ static bool __is_device(int fd, const char *expect)
 	return strcmp(expect, name) == 0;
 }
 
+bool is_vkms_device(int fd)
+{
+	return __is_device(fd, "vkms");
+}
+
 bool is_amdgpu_device(int fd)
 {
 	return __is_device(fd, "amdgpu");
lib/drmtest.h +1 -0
index 27e5a18e2..b3d53f252 100644
@@ -136,6 +136,7 @@ void igt_require_nouveau(int fd);
 void igt_require_vc4(int fd);
 void igt_require_xe(int fd);
 
+bool is_vkms_device(int fd);
 bool is_amdgpu_device(int fd);
 bool is_i915_device(int fd);
 bool is_mtk_device(int fd);
lib/igt_color.c new file +648 -0

649 lines not on this page · raw message

lib/igt_color.h new file +162 -0

163 lines not on this page · raw message

lib/igt_color_lut.h new file +4946 -0

2,001 lines not on this page · raw message

lib/igt_fb.c +32 -2
index 9fc1bfc65..47ad33512 100644

Lines of this file are not shown. View the raw message.

lib/igt_fb.h +3 -0
index d5aa1e88a..b2176558b 100644

Lines of this file are not shown. View the raw message.

lib/igt_kms.c +384 -18

402 lines not on this page · raw message

lib/igt_kms.h +100 -0

100 lines not on this page · raw message

lib/meson.build +1 -0
index ff81baae1..60469ddab 100644

Lines of this file are not shown. View the raw message.

scripts/convert_3dlut.py new file +94 -0

94 lines not on this page · raw message

tests/kms_colorop.c new file +751 -0

751 lines not on this page · raw message

tests/kms_colorop.h new file +261 -0

261 lines not on this page · raw message

tests/kms_properties.c +88 -6

94 lines not on this page · raw message

tests/kms_writeback.c +12 -26
index 05680837e..20c3a32c2 100644

Lines of this file are not shown. View the raw message.

tests/meson.build +1 -0
index 55bcf57ec..447ae379c 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 2/9 lib/colorops: Move few helpers to common place to reuse

In reply to Swati Sharma

From: Bhanuprakash Modem <[email protected]>

Move few colorops helpers to common place to reuse. Created new igt_color_lut.c file to avoid compilation errors.

---
 lib/igt_color.c          |  106 +-
 lib/igt_color.h          |  105 +-
 lib/igt_color_lut.c      | 4927 ++++++++++++++++++++++++++++++++++++++
 lib/igt_color_lut.h      | 4920 +------------------------------------
 lib/meson.build          |    1 +
 tests/kms_color_helper.c |  204 ++
 tests/kms_color_helper.h |   67 +
 tests/kms_colorop.c      |  380 ++-
 tests/kms_colorop.h      |  261 --
 tests/meson.build        |    1 +
 10 files changed, 5463 insertions(+), 5509 deletions(-)
 create mode 100644 lib/igt_color_lut.c
 delete mode 100644 tests/kms_colorop.h
lib/igt_color.c +65 -41
index 035d0b486..50da99b35 100644
@@ -16,6 +16,71 @@
 #include "igt_core.h"
 #include "igt_x86.h"
 
+const struct igt_color_tf srgb_tf = {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0};
+const struct igt_color_tf srgb_eotf = {2.4f, (float)(1/1.055), (float)(0.055/1.055), (float)(1/12.92), 0.04045f, 0, 0};
+const struct igt_color_tf bt2020_inv_oetf = {(float)(1/0.45f), (float)(1/1.0993f), (float)(0.0993f/1.0993f), (float)(1/4.5f), (float)(0.081), 0, 0};
+const struct igt_color_tf_pq pq_eotf = {-107/128.0f, 1.0f, 32/2523.0f, 2413/128.0f, -2392/128.0f, 8192/1305.0f };
+
+const igt_matrix_3x4_t igt_matrix_3x4_50_desat = { {
+	0.5, 0.25, 0.25, 0.0,
+	0.25, 0.5, 0.25, 0.0,
+	0.25, 0.25, 0.5, 0.0
+} };
+
+const igt_matrix_3x4_t igt_matrix_3x4_overdrive = { {
+	1.5, 0.0, 0.0, 0.0,
+	0.0, 1.5, 0.0, 0.0,
+	0.0, 0.0, 1.5, 0.0
+} };
+
+const igt_matrix_3x4_t igt_matrix_3x4_oversaturate = { {
+	1.5,   -0.25, -0.25, 0.0,
+	-0.25,  1.5,  -0.25, 0.0,
+	-0.25, -0.25,  1.5,  0.0
+} };
+
+#if 0
+const igt_matrix_3x4_t igt_matrix_3x4_bt709_enc = { {
+	 0.2126,   0.7152,  0.0722, 0.0,
+	-0.1146, -0.3854,  0.5,    0.0,
+	 0.5,     -0.4542, -0.0458, 0.0
+} };
+
+const igt_matrix_3x4_t igt_matrix_3x4_bt709_dec = { {
+	1.0,  0.0,     1.5748, 0.0,
+	1.0, -0.1873, -0.4681, 0.0,
+	1.0,  1.8556,  0.0,    0.0
+} };
+#else
+const igt_matrix_3x4_t igt_matrix_3x4_bt709_enc = { {
+	 0.2126,   0.7152,   0.0722,  0.0,
+	-0.09991, -0.33609,  0.436,   0.0,
+	 0.615,   -0.55861, -0.05639, 0.0
+} };
+
+const igt_matrix_3x4_t igt_matrix_3x4_bt709_dec = { {
+	1.0,  0.0,      1.28033, 0.0,
+	1.0, -0.21482, -0.38059, 0.0,
+	1.0,  2.12798,  0.0,     0.0
+} };
+#endif
+
+igt_1dlut_t igt_1dlut_srgb_inv_eotf = { {
+} };
+
+igt_1dlut_t igt_1dlut_srgb_eotf = { {
+} };
+
+const char * const kms_colorop_lut1d_tf_names[KMS_COLOROP_LUT1D_NUM_ENUMS] = {
+	[KMS_COLOROP_LUT1D_SRGB_EOTF] = "sRGB EOTF",
+	[KMS_COLOROP_LUT1D_SRGB_INV_EOTF] = "sRGB Inverse EOTF",
+	[KMS_COLOROP_LUT1D_BT2020_INV_OETF] = "BT.2020 Inverse OETF",
+	[KMS_COLOROP_LUT1D_BT2020_OETF] = "BT.2020 OETF",
+	[KMS_COLOROP_LUT1D_PQ_EOTF] = "PQ EOTF",
+	[KMS_COLOROP_LUT1D_PQ_INV_EOTF] = "PQ Inverse EOTF",
+	[KMS_COLOROP_LUT1D_PQ_125_EOTF] = "PQ 125 EOTF",
+	[KMS_COLOROP_LUT1D_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",
+};
 
 static float clamp(float val, float min, float max)
 {
@@ -592,7 +657,6 @@ bool igt_cmp_fb_pixels(igt_fb_t *fb1, igt_fb_t *fb2, uint8_t up, uint8_t down)
 	return matched;
 }
 
-
 void igt_dump_fb(igt_display_t *display, igt_fb_t *fb,
 		 const char *path_name, const char *file_name)
 {
@@ -606,43 +670,3 @@ void igt_dump_fb(igt_display_t *display, igt_fb_t *fb,
 	igt_assert_eq(status, CAIRO_STATUS_SUCCESS);
 	cairo_surface_destroy(fb_surface_out);
 }
-
-void igt_colorop_set_ctm_3x4(igt_display_t *display,
-			     igt_colorop_t *colorop,
-			     const igt_matrix_3x4_t *matrix)
-{
-	struct drm_color_ctm_3x4 ctm;
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(ctm.matrix); i++) {
-		if (matrix->m[i] < 0) {
-			ctm.matrix[i] =
-				(int64_t) (-matrix->m[i] *
-				((int64_t) 1L << 32));
-			ctm.matrix[i] |= 1ULL << 63;
-		} else {
-			ctm.matrix[i] =
-				(int64_t) (matrix->m[i] *
-				((int64_t) 1L << 32));
-		}
-	}
-
-	/* set blob property */
-	igt_colorop_replace_prop_blob(colorop, IGT_COLOROP_DATA, &ctm, sizeof(ctm));
-}
-
-void igt_colorop_set_custom_1dlut(igt_display_t *display,
-				  igt_colorop_t *colorop,
-				  const igt_1dlut_t *lut1d,
-				  const size_t lut_size)
-{
-	igt_colorop_replace_prop_blob(colorop, IGT_COLOROP_DATA, lut1d, lut_size);
-}
-
-void igt_colorop_set_3dlut(igt_display_t *display,
-			   igt_colorop_t *colorop,
-			   const igt_3dlut_norm_t *lut3d,
-			   const size_t lut_size)
-{
-	igt_colorop_replace_prop_blob(colorop, IGT_COLOROP_DATA, lut3d, lut_size);
-}
\ No newline at end of file
lib/igt_color.h +31 -74

138 lines not on this page · raw message

lib/igt_color_lut.c new file +4927 -0

2,740 lines not on this page · raw message

lib/igt_color_lut.h +1 -4919

4,920 lines not on this page · raw message

lib/meson.build +1 -0
index 60469ddab..73a48c0e7 100644

Lines of this file are not shown. View the raw message.

tests/kms_color_helper.c +204 -0

204 lines not on this page · raw message

tests/kms_color_helper.h +67 -0

67 lines not on this page · raw message

tests/kms_colorop.c +166 -214

380 lines not on this page · raw message

tests/kms_colorop.h deleted +0 -261

261 lines not on this page · raw message

tests/meson.build +1 -0
index 447ae379c..94a5c8a65 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.

#3 lore raw

PATCH 3/9 drm-uapi: Add Color lut range attributes

In reply to Swati Sharma
---
 include/drm-uapi/drm_mode.h | 64 +++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
include/drm-uapi/drm_mode.h +64 -0
index 4c8d404b1..26ee2a68e 100644
@@ -1103,6 +1103,70 @@ struct hdr_output_metadata {
 				  DRM_MODE_PAGE_FLIP_ASYNC | \
 				  DRM_MODE_PAGE_FLIP_TARGET)
 
+/**
+ * DRM_COLOROP_1D_LUT_MULTSEG_INTERPOLATE
+ *
+ * linearly interpolate between the points
+ */
+#define DRM_COLOROP_1D_LUT_MULTSEG_INTERPOLATE BIT(0)
+
+/**
+ * DRM_COLOROP_1D_LUT_MULTSEG_REUSE_LAST
+ *
+ * the last value of the previous range is the
+ * first value of the current range.
+ */
+#define DRM_COLOROP_1D_LUT_MULTSEG_REUSE_LAST BIT(1)
+
+/**
+ * DRM_COLOROP_1D_LUT_MULTSEG_NON_DECREASING
+ *
+ * the curve must be non-decreasing
+ */
+#define DRM_COLOROP_1D_LUT_MULTSEG_NON_DECREASING BIT(2)
+
+/**
+ * DRM_COLOROP_1D_LUT_MULTSEG_REFLECT_NEGATIVE
+ *
+ *  the curve is reflected across origin for negative inputs
+ */
+#define DRM_COLOROP_1D_LUT_MULTSEG_REFLECT_NEGATIVE BIT(3)
+
+/**
+ * DRM_COLOROP_1D_LUT_MULTSEG_SINGLE_CHANNEL
+ *
+ * the same curve (red) is used for blue and green channels as well
+ */
+#define DRM_COLOROP_1D_LUT_MULTSEG_SINGLE_CHANNEL BIT(4)
+
+/**
+ * struct drm_color_lut_range
+ *
+ * structure to advertise capability of a color hardware
+ * block that accepts LUT values.  It can represent LUTs with
+ * varied number of entries and distributions
+ * (Multi segmented, Logarithmic etc).
+ */
+
+struct drm_color_lut_range {
+	/* DRM_COLOROP_1D_LUT_MULTSEG_* */
+	__u32 flags;
+	/* number of points on the curve in the segment */
+	__u16 count;
+	/* input start/end values of the segment */
+	__s32 start, end;
+	/* normalization factor. Represents 1.0 in terms of smallest step size */
+	__u32 norm_factor;
+
+	/* precision of HW LUT*/
+	struct {
+		/* Integer precision */
+		__u16 intp;
+		/* Fractional precision */
+		__u16 fracp;
+	} precision;
+};
+
 /*
  * Request a page flip on the specified crtc.
  *
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/9 drm-uapi: Add 1D LUT multi-segmented color op

In reply to Swati Sharma
---
 include/drm-uapi/drm_mode.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/drm-uapi/drm_mode.h +10 -0
index 26ee2a68e..de89ad687 100644
@@ -910,6 +910,16 @@ enum drm_colorop_type {
 	 */
 	DRM_COLOROP_1D_LUT,
 
+	/**
+	 * @DRM_COLOROP_1D_LUT_MULTSEG:
+	 *
+	 * A 1D LUT with multiple segments to cover the full color range with non-uniformly
+	 * distributed &drm_color_lut entries, packed into a blob via the DATA property.
+	 * The driver's expected LUT size and segmented capabilities are advertised via the
+	 * HW_CAPS property.
+	 */
+	DRM_COLOROP_1D_LUT_MULTSEG,
+
 	/**
 	 * @DRM_COLOROP_CTM_3X4:
 	 *
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/9 lib/kms: Add support for COLOROP_HW_CAPS property

In reply to Swati Sharma
---
 lib/igt_kms.c | 1 +
 lib/igt_kms.h | 1 +
 2 files changed, 2 insertions(+)
lib/igt_kms.c +1 -0
index c99bba74b..daba319ed 100644
@@ -710,6 +710,7 @@ const char * const igt_colorop_prop_names[IGT_NUM_COLOROP_PROPS] = {
 	[IGT_COLOROP_BYPASS] = "BYPASS",
 	[IGT_COLOROP_CURVE_1D_TYPE] = "CURVE_1D_TYPE",
 	[IGT_COLOROP_SIZE] = "SIZE",
+	[IGT_COLOROP_HW_CAPS] = "HW_CAPS",
 	[IGT_COLOROP_DATA] = "DATA",
 	[IGT_COLOROP_MULTIPLIER] = "MULTIPLIER",
 	[IGT_COLOROP_COLOR_DEPTH] = "COLOR_DEPTH",
lib/igt_kms.h +1 -0
index 0d0592106..d63099a65 100644
@@ -374,6 +374,7 @@ enum igt_atomic_colorop_properties {
 	IGT_COLOROP_BYPASS,
 	IGT_COLOROP_CURVE_1D_TYPE,
 	IGT_COLOROP_SIZE,
+	IGT_COLOROP_HW_CAPS,
 	IGT_COLOROP_DATA,
 	IGT_COLOROP_MULTIPLIER,
 	IGT_COLOROP_COLOR_DEPTH,
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/9 lib/colorops: Add support for 1D LUT multi-segmented

In reply to Swati Sharma

From: Bhanuprakash Modem <[email protected]>

Add helpers to support 1D LUT multi-segmented.

---
 tests/kms_color_helper.c | 100 +++++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.h |  29 ++++++++++++
 2 files changed, 129 insertions(+)
tests/kms_color_helper.c +100 -0
index ded61ccad..c5f2dcc20 100644
@@ -24,6 +24,8 @@
 
 #include "kms_color_helper.h"
 
+#define MIN(a, b)	((a) < (b) ? (a) : (b))
+
 bool pipe_output_combo_valid(data_t *data, enum pipe pipe)
 {
 	bool ret = true;
@@ -403,6 +405,10 @@ static bool can_use_colorop(igt_display_t *display, igt_colorop_t *colorop, kms_
 		if (igt_colorop_get_prop(display, colorop, IGT_COLOROP_TYPE) == DRM_COLOROP_1D_LUT)
 			return true;
 		return false;
+	case KMS_COLOROP_MULTSEG_LUT1D:
+		if (igt_colorop_get_prop(display, colorop, IGT_COLOROP_TYPE) == DRM_COLOROP_1D_LUT_MULTSEG)
+			return true;
+		return false;
 	case KMS_COLOROP_MULTIPLIER:
 		return (igt_colorop_get_prop(display, colorop, IGT_COLOROP_TYPE) == DRM_COLOROP_MULTIPLIER);
 	case KMS_COLOROP_LUT3D:
@@ -514,6 +520,9 @@ void set_colorop(igt_display_t *display, kms_colorop_t *colorop)
 		lut_size = igt_colorop_get_prop(display, colorop->colorop, IGT_COLOROP_SIZE);
 		igt_colorop_set_custom_1dlut(display, colorop->colorop, colorop->lut1d, lut_size * sizeof(struct drm_color_lut));
 		break;
+	case KMS_COLOROP_MULTSEG_LUT1D:
+		igt_colorop_set_multseg_1dlut(display, colorop->colorop, colorop->multseg_lut1d_info);
+		break;
 	case KMS_COLOROP_MULTIPLIER:
 		mult = colorop->multiplier * (mult << 32);	/* convert double to fixed number */
 		igt_colorop_set_prop_value(colorop->colorop, IGT_COLOROP_MULTIPLIER, mult);
@@ -592,3 +601,94 @@ void igt_colorop_set_3dlut(igt_display_t *display,
 {
 	igt_colorop_replace_prop_blob(colorop, IGT_COLOROP_DATA, lut3d, lut_size);
 }
+
+void create_zero_lut(segment_data_t *info, struct drm_color_lut_32 *lut)
+{
+	int i;
+
+	for (i = 0; i < info->entries_count; i++)
+		lut[i].red = lut[i].green = lut[i].blue = 0;
+}
+
+void create_unity_lut(segment_data_t *info, struct drm_color_lut_32 *lut)
+{
+	uint32_t val, segment, entry, index = 0;
+	uint32_t max_val = 0xffffffff;
+
+	for (segment = 0; segment < info->segment_count; segment++) {
+		uint32_t entry_count = info->segment_data[segment].count;
+		uint32_t start = info->segment_data[segment].start;
+		uint32_t end = info->segment_data[segment].end;
+
+		for (entry = 1; entry <= entry_count; entry++) {
+			val = start + entry * ((end - start) * 1.0 / entry_count);
+			lut[index].red = lut[index].green = lut[index].blue =
+				(index == 0) ? 0 : MIN(val, max_val);
+
+			index++;
+		}
+	}
+}
+
+void create_max_lut(segment_data_t *info, struct drm_color_lut_32 *lut)
+{
+	int i;
+	uint32_t max_val = 0xffffffff;
+
+	for (i = 0; i < info->entries_count; i++)
+		lut[i].red = lut[i].green = lut[i].blue = (i == 0) ? 0 : max_val;
+}
+
+void clear_segment_data(segment_data_t *info)
+{
+	if (!info)
+		return;
+
+	free(info->segment_data);
+	free(info);
+}
+
+segment_data_t *get_segment_data(int drm_fd, uint64_t blob_id)
+{
+	drmModePropertyBlobPtr blob;
+	struct drm_color_lut_range *lut_range = NULL;
+	segment_data_t *info = NULL;
+	uint32_t i;
+
+	blob = drmModeGetPropertyBlob(drm_fd, blob_id);
+	igt_assert(blob);
+	igt_assert(blob->length);
+
+	info = malloc(sizeof(segment_data_t));
+	igt_assert(info);
+
+	lut_range = (struct drm_color_lut_range *) blob->data;
+	info->segment_count = blob->length / sizeof(lut_range[0]);
+	igt_assert(info->segment_count);
+
+	info->segment_data = malloc(sizeof(struct drm_color_lut_range) * info->segment_count);
+	igt_assert(info->segment_data);
+
+	info->entries_count = 0;
+	for (i = 0; i < info->segment_count; i++) {
+		info->entries_count += lut_range[i].count;
+		info->segment_data[i] = lut_range[i];
+	}
+
+	drmModeFreePropertyBlob(blob);
+
+	return info;
+}
+
+void igt_colorop_set_multseg_1dlut(igt_display_t *display,
+				   igt_colorop_t *colorop,
+				   const kms_colorop_multseg_lut1d_info_t lut_info)
+{
+	/* set blob property */
+	for (int i = 0; i < lut_info.lut_size; i++)
+		igt_debug("Lut[%d]: 0x%08x 0x%08x 0x%08x\n",
+			 i, lut_info.lut[i].red, lut_info.lut[i].green, lut_info.lut[i].blue);
+
+	igt_colorop_replace_prop_blob(colorop, IGT_COLOROP_DATA,
+			lut_info.lut, sizeof(struct drm_color_lut_32) * lut_info.lut_size);
+}
tests/kms_color_helper.h +29 -0
index 11abe7e46..29efb7e7b 100644
@@ -122,10 +122,23 @@ void invalid_gamma_lut_sizes(data_t *data, enum pipe p);
 void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
 void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
 
+typedef struct {
+	uint32_t segment_count;
+	struct drm_color_lut_range *segment_data;
+	uint32_t entries_count;
+} segment_data_t;
+
+void create_zero_lut(segment_data_t *info, struct drm_color_lut_32 *lut);
+void create_unity_lut(segment_data_t *info, struct drm_color_lut_32 *lut);
+void create_max_lut(segment_data_t *info, struct drm_color_lut_32 *lut);
+void clear_segment_data(segment_data_t *info);
+segment_data_t *get_segment_data(int drm_fd, uint64_t blob_id);
+
 /* Test version definitions */
 typedef enum kms_colorop_type {
 	KMS_COLOROP_ENUMERATED_LUT1D,
 	KMS_COLOROP_CUSTOM_LUT1D,
+	KMS_COLOROP_MULTSEG_LUT1D,
 	KMS_COLOROP_CTM_3X4,
 	KMS_COLOROP_MULTIPLIER,
 	KMS_COLOROP_LUT3D
@@ -140,6 +153,18 @@ typedef struct kms_colorop_lut3d_info {
 	enum drm_colorop_lut3d_interpolation_type interpolation;
 } kms_colorop_lut3d_info_t;
 
+typedef enum kms_colorop_multseg_lut1d_tf {
+       KMS_COLOROP_MULTSEG_LUT1D_ZERO,
+       KMS_COLOROP_MULTSEG_LUT1D_LINEAR,
+       KMS_COLOROP_MULTSEG_LUT1D_MAX,
+} kms_colorop_multseg_lut1d_tf_t;
+
+typedef struct kms_colorop_multseg_lut1d_info {
+	uint32_t lut_size;
+	kms_colorop_multseg_lut1d_tf_t lut_type;
+	struct drm_color_lut_32 *lut;
+} kms_colorop_multseg_lut1d_info_t;
+
 typedef struct kms_colorop {
 	kms_colorop_type_t type;
 
@@ -147,6 +172,7 @@ typedef struct kms_colorop {
 		kms_colorop_enumerated_lut1d_info_t enumerated_lut1d_info;
 		igt_1dlut_t *lut1d;
 		igt_3dlut_t *lut3d;
+		kms_colorop_multseg_lut1d_info_t multseg_lut1d_info;
 		const igt_matrix_3x4_t *matrix_3x4;
 		double multiplier;
 	};
@@ -179,6 +205,9 @@ void igt_colorop_set_3dlut(igt_display_t *display,
 			   igt_colorop_t *colorop,
 			   const igt_3dlut_norm_t *lut3d,
 			   const size_t lut_size);
+void igt_colorop_set_multseg_1dlut(igt_display_t *display,
+				   igt_colorop_t *colorop,
+				   const kms_colorop_multseg_lut1d_info_t custom_lut1d_info);
 
 #define set_color_pipeline_bypass(plane)  igt_plane_set_prop_enum((plane), IGT_PLANE_COLOR_PIPELINE, "Bypass")
 
Signature · 1 line
2.25.1
#7 lore raw

PATCH 7/9 tests/kms_color_helper: Add helpers to clear colorops data

In reply to Swati Sharma

From: Bhanuprakash Modem <[email protected]>

- Clear the DATA blob
- Set the BYPASS prop true

---
 tests/kms_color_helper.c | 32 ++++++++++++++++++++++++++++++++
 tests/kms_color_helper.h |  3 +++
 2 files changed, 35 insertions(+)
tests/kms_color_helper.c +32 -0
index c5f2dcc20..9ca96919f 100644
@@ -499,6 +499,27 @@ static void fill_custom_1dlut(igt_display_t *display, kms_colorop_t *colorop)
 	}
 }
 
+void clear_colorop(igt_display_t *display, kms_colorop_t *colorop)
+{
+	igt_assert(colorop->colorop);
+	igt_colorop_set_prop_value(colorop->colorop, IGT_COLOROP_BYPASS, 1);
+
+	switch (colorop->type) {
+	case KMS_COLOROP_CTM_3X4:
+	case KMS_COLOROP_CUSTOM_LUT1D:
+	case KMS_COLOROP_MULTSEG_LUT1D:
+		igt_colorop_replace_prop_blob(colorop->colorop, IGT_COLOROP_DATA, NULL, 0);
+		break;
+	case KMS_COLOROP_MULTIPLIER:
+		igt_colorop_set_prop_value(colorop->colorop, IGT_COLOROP_MULTIPLIER, 1);
+		break;
+	case KMS_COLOROP_ENUMERATED_LUT1D:
+	case KMS_COLOROP_LUT3D:
+	default:
+		return;
+	}
+}
+
 void set_colorop(igt_display_t *display, kms_colorop_t *colorop)
 {
 	uint64_t lut_size = 0;
@@ -533,6 +554,17 @@ void set_colorop(igt_display_t *display, kms_colorop_t *colorop)
 	}
 }
 
+void clear_color_pipeline(igt_display_t *display,
+			  igt_plane_t *plane,
+			  kms_colorop_t *colorops[],
+			  igt_colorop_t *color_pipeline)
+{
+	int i;
+
+	for(i = 0; colorops[i]; i++)
+		clear_colorop(display, colorops[i]);
+}
+
 void set_color_pipeline(igt_display_t *display,
 			igt_plane_t *plane,
 			kms_colorop_t *colorops[],
tests/kms_color_helper.h +3 -0
index 29efb7e7b..c384de8a2 100644
@@ -208,6 +208,9 @@ void igt_colorop_set_3dlut(igt_display_t *display,
 void igt_colorop_set_multseg_1dlut(igt_display_t *display,
 				   igt_colorop_t *colorop,
 				   const kms_colorop_multseg_lut1d_info_t custom_lut1d_info);
+void clear_colorop(igt_display_t *display, kms_colorop_t *colorop);
+void clear_color_pipeline(igt_display_t *display, igt_plane_t *plane,
+			  kms_colorop_t *colorops[], igt_colorop_t *color_pipeline);
 
 #define set_color_pipeline_bypass(plane)  igt_plane_set_prop_enum((plane), IGT_PLANE_COLOR_PIPELINE, "Bypass")
 
Signature · 1 line
2.25.1
#8 lore raw

PATCH 8/9 tests/kms_color: Add Intel plane pipeline tests with LUT1D (MULTSEG) and CTM

In reply to Swati Sharma

From: Bhanuprakash Modem <[email protected]>

For now, Intel plane color pipeline contains 3 colorops:
Pre-csc gamma (1D LUT MULTSEG) --> CTM 3x4 --> Post-csc gamma (1D LUT MULTSEG)

Create subtests to cover different combinations of available colorops:
igt@kms_color@plane-lut1d-multseg igt@kms_color@plane-ctm3x4 igt@kms_color@plane-lut1d-multseg-ctm3x4 igt@kms_color@plane-ctm3x4-lut1d-multseg igt@kms_color@plane-lut1d-multseg-lut1d-multseg igt@kms_color@plane-lut1d-multseg-ctm3x4-lut1d-multseg

v2: -renamed subtests
-updated create_unity_lut() logic
-used CTM 3x4

---
 tests/kms_color.c        | 279 ++++++++++++++++++++++++++++++++++++++-
 tests/kms_color_helper.c |  20 ++-
 2 files changed, 290 insertions(+), 9 deletions(-)
tests/kms_color.c +273 -6
index 447fcc7f9..1c61fac71 100644
@@ -32,6 +32,8 @@
 
 #include "kms_color_helper.h"
 
+#define MAX_COLOROPS	5
+
 /**
  * SUBTEST: degamma
  * Description: Verify that degamma LUT transformation works correctly
@@ -76,6 +78,20 @@
  * @gamma-lut:          Gamma LUT
  */
 
+/**
+ * SUBTEST: plane-%s
+ * Description: Test plane color pipeline with colorops: %arg[1].
+ *
+ * arg[1]:
+ *
+ * @lut1d-multseg:			1D LUT MULTSEG
+ * @ctm3x4:				3X4 CTM
+ * @lut1d-multseg-ctm3x4:		1D LUT MULTSEG --> 3X4 CTM
+ * @ctm3x4-lut1d-multseg:		3X4 CTM --> 1D LUT MULTSEG
+ * @lut1d-multseg-lut1d-multseg:	1D LUT MULTSEG --> 1D LUT MULTSEG
+ * @lut1d-multseg-ctm3x4-lut1d-multseg: 1D LUT MULTSEG --> 3X4 CTM --> 1D LUT MULTSEG
+ */
+
 IGT_TEST_DESCRIPTION("Test Color Features at Pipe level");
 
 static bool test_pipe_degamma(data_t *data,
@@ -724,6 +740,137 @@ static void test_pipe_limited_range_ctm(data_t *data,
 }
 #endif
 
+static void clear_lut_data(kms_colorop_t *colorops[])
+{
+	int i;
+
+	for (i = 0; colorops[i]; i++) {
+		if (colorops[i]->type != KMS_COLOROP_MULTSEG_LUT1D)
+			continue;
+
+		if (colorops[i]->multseg_lut1d_info.lut)
+			free(colorops[i]->multseg_lut1d_info.lut);
+	}
+}
+
+static void prepare_lut_data(data_t *data, kms_colorop_t *colorops[])
+{
+	int i;
+
+	for (i = 0; colorops[i]; i++) {
+		uint64_t hwlut_caps = 0;
+		segment_data_t *segment_info;
+
+		if (colorops[i]->type != KMS_COLOROP_MULTSEG_LUT1D)
+			continue;
+
+		hwlut_caps = igt_colorop_get_prop(&data->display, colorops[i]->colorop, IGT_COLOROP_HW_CAPS);
+		segment_info = get_segment_data(data->drm_fd, hwlut_caps);
+
+		igt_info("Lut size (%s): %d\n", colorops[i]->name, segment_info->entries_count);
+
+		colorops[i]->multseg_lut1d_info.lut_size = segment_info->entries_count;
+		colorops[i]->multseg_lut1d_info.lut =
+			malloc(sizeof(struct drm_color_lut_32) * colorops[i]->multseg_lut1d_info.lut_size);
+		igt_assert(colorops[i]->multseg_lut1d_info.lut);
+
+		switch (colorops[i]->multseg_lut1d_info.lut_type) {
+			case KMS_COLOROP_MULTSEG_LUT1D_ZERO:
+				create_zero_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
+				break;
+			case KMS_COLOROP_MULTSEG_LUT1D_LINEAR:
+				create_unity_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
+				break;
+			case KMS_COLOROP_MULTSEG_LUT1D_MAX:
+			default:
+				create_max_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
+		}
+
+		clear_segment_data(segment_info);
+	}
+}
+
+static bool ctm_colorop_only(kms_colorop_t *colorops[])
+{
+	int i;
+
+	for (i = 0; colorops[i]; i++)
+		if (colorops[i]->type != KMS_COLOROP_CTM_3X4)
+			return false;
+	return true;
+}
+
+static bool test_plane_colorops(data_t *data,
+				const color_t *fb_colors,
+				const color_t *exp_colors,
+				kms_colorop_t *colorops[])
+{
+	igt_plane_t *plane = data->primary;
+	igt_output_t *output = data->output;
+	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode = data->mode;
+	struct igt_fb fb;
+	bool ret;
+	igt_colorop_t *color_pipeline = get_color_pipeline(display, plane, colorops);
+	igt_crc_t crc_gamma, crc_fullcolors;
+
+	igt_output_set_pipe(output, plane->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      DRM_FORMAT_MOD_LINEAR,
+			      &fb));
+	igt_plane_set_fb(plane, &fb);
+
+	/* Disable Pipe color props. */
+	disable_ctm(plane->pipe);
+	disable_degamma(plane->pipe);
+	disable_gamma(plane->pipe);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	set_color_pipeline_bypass(plane);
+	paint_rectangles(data, mode, exp_colors, &fb);
+	igt_plane_set_fb(plane, &fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_wait_for_vblank(data->drm_fd,
+		display->pipes[plane->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullcolors);
+
+	/*
+	 * Draw gradient colors with LUT to remap all
+	 * values to max red/green/blue.
+	 */
+	prepare_lut_data(data, colorops);
+	set_color_pipeline(display, plane, colorops, color_pipeline);
+	if (ctm_colorop_only(colorops))
+		paint_rectangles(data, mode, fb_colors, &fb);
+	else
+		paint_gradient_rectangles(data, mode, fb_colors, &fb);
+	igt_plane_set_fb(plane, &fb);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+	igt_wait_for_vblank(data->drm_fd,
+			display->pipes[plane->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_gamma);
+
+	/*
+	 * Verify that the CRC of the software computed output is
+	 * equal to the CRC of the gamma LUT transformation output.
+	 */
+	ret = igt_check_crc_equal(&crc_gamma, &crc_fullcolors);
+
+	clear_lut_data(colorops);
+	clear_color_pipeline(display, plane, colorops, color_pipeline);
+	igt_plane_set_fb(plane, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, COMMIT_ATOMIC);
+
+	return ret;
+}
+
 static void
 prep_pipe(data_t *data, enum pipe p)
 {
@@ -759,6 +906,10 @@ static void test_setup(data_t *data, enum pipe p)
 					  data->primary->pipe->pipe,
 					  IGT_PIPE_CRC_SOURCE_AUTO);
 
+	igt_display_require_output_on_pipe(&data->display, p);
+	data->output = igt_get_single_output_for_pipe(&data->display, p);
+	igt_require(data->output);
+
 	igt_display_reset(&data->display);
 }
 
@@ -852,6 +1003,42 @@ run_ctm_tests_for_pipe(data_t *data, enum pipe p,
 	test_cleanup(data);
 }
 
+static void run_plane_color_tests(data_t *data,
+				  const color_t *fb_colors,
+				  const color_t *exp_colors,
+				  kms_colorop_t *colorops[])
+{
+	enum pipe pipe;
+
+	data->color_depth = 8;
+	data->drm_format = DRM_FORMAT_XRGB8888;
+
+	for_each_pipe(&data->display, pipe) {
+		test_setup(data, pipe);
+
+		data->mode = igt_output_get_mode(data->output);
+
+		if (!pipe_output_combo_valid(data, pipe)){
+			test_cleanup(data);
+			continue;
+		}
+
+		/*
+		 * TODO: Extend the test to multiple planes?
+		 * Since, Intel planes (HDR & SDR) have different capabilities.
+		 */
+		if (!igt_plane_has_prop(data->primary, IGT_PLANE_COLOR_PIPELINE))
+			continue;
+
+		igt_dynamic_f("pipe-%s-%s",
+			      kmstest_pipe_name(pipe),
+			      igt_output_name(data->output))
+			igt_assert(test_plane_colorops(data, fb_colors, exp_colors, colorops));
+	}
+
+	test_cleanup(data);
+}
+
 static void
 run_deep_color_tests_for_pipe(data_t *data, enum pipe p)
 {
@@ -1155,13 +1342,93 @@ run_tests_for_pipe(data_t *data)
 		}
 	}
 
-	igt_fixture
-		igt_require(data->display.is_atomic);
+	igt_subtest_group {
+		static const color_t colors_red_to_blue[] = {
+			{ 0.0, 0.0, 1.0 },
+			{ 0.0, 1.0, 0.0 },
+			{ 0.0, 0.0, 1.0 },
+		};
+		const igt_matrix_3x4_t ctm_red_to_blue = { {
+			0.0, 0.0, 0.0, 0.0,
+			0.0, 1.0, 0.0, 0.0,
+			1.0, 0.0, 1.0, 0.0,
+		} };
+		kms_colorop_t lut1d_multseg_linear = {
+			.type = KMS_COLOROP_MULTSEG_LUT1D,
+			.name = "Pre/Post CSC GAMMA (linear LUT)",
+			.multseg_lut1d_info = {
+				.lut_type = KMS_COLOROP_MULTSEG_LUT1D_LINEAR,
+			},
+		};
+		kms_colorop_t lut1d_multseg_max = {
+			.type = KMS_COLOROP_MULTSEG_LUT1D,
+			.name = "Pre/Post CSC GAMMA (max LUT)",
+			.multseg_lut1d_info = {
+				.lut_type = KMS_COLOROP_MULTSEG_LUT1D_MAX,
+			},
+		};
+		kms_colorop_t ctm_3x4 = {
+			.type = KMS_COLOROP_CTM_3X4,
+			.name = "CTM 3X4 (red to blue)",
+			.matrix_3x4 = &ctm_red_to_blue,
+		};
+		struct {
+			const char *name;
+			const color_t *fb_colors;
+			const color_t *exp_colors;
+			kms_colorop_t *colorops[MAX_COLOROPS];
+		} plane_colorops_tests[] = {
+			{ .name = "lut1d-multseg",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_rgb,
+			  .colorops = { &lut1d_multseg_max, NULL },
+			},
+			{ .name = "ctm3x4",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_red_to_blue,
+			  .colorops = { &ctm_3x4, NULL },
+			},
+			{ .name = "lut1d-multseg-ctm3x4",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_red_to_blue,
+			  .colorops = { &lut1d_multseg_max, &ctm_3x4, NULL },
+			},
+			{ .name = "ctm3x4-lut1d-multseg",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_red_to_blue,
+			  .colorops = { &ctm_3x4, &lut1d_multseg_max, NULL },
+			},
+			{ .name = "lut1d-multseg-lut1d-multseg",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_rgb,
+			  .colorops = { &lut1d_multseg_linear, &lut1d_multseg_max, NULL },
+			},
+			{ .name = "lut1d-multseg-ctm3x4-lut1d-multseg",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_red_to_blue,
+			  .colorops = { &lut1d_multseg_linear, &ctm_3x4, &lut1d_multseg_max, NULL },
+			},
+		};
 
-	igt_describe("Verify that deep color works correctly");
-	igt_subtest_with_dynamic("deep-color") {
-		for_each_pipe(&data->display, pipe) {
-			run_deep_color_tests_for_pipe(data, pipe);
+		igt_fixture {
+			if (drmSetClientCap(data->display.drm_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0)
+				data->display.is_atomic = 1;
+		}
+
+		for (i = 0; i < ARRAY_SIZE(plane_colorops_tests); i++) {
+			igt_describe_f("Test plane color pipeline with colorops: %s", plane_colorops_tests[i].name);
+			igt_subtest_with_dynamic_f("plane-%s", plane_colorops_tests[i].name)
+				run_plane_color_tests(data,
+						      plane_colorops_tests[i].fb_colors,
+						      plane_colorops_tests[i].exp_colors,
+						      plane_colorops_tests[i].colorops);
+		}
+
+		igt_describe("Verify that deep color works correctly");
+		igt_subtest_with_dynamic("deep-color") {
+			for_each_pipe(&data->display, pipe) {
+				run_deep_color_tests_for_pipe(data, pipe);
+			}
 		}
 	}
 }
tests/kms_color_helper.c +17 -3
index 9ca96919f..ba6890c86 100644
@@ -642,18 +642,32 @@ void create_zero_lut(segment_data_t *info, struct drm_color_lut_32 *lut)
 		lut[i].red = lut[i].green = lut[i].blue = 0;
 }
 
+static uint32_t get_max(int precision)
+{
+	if(precision > 32)
+		 precision = 32;
+
+	return (uint64_t)(1 << precision) - 1;
+}
+
 void create_unity_lut(segment_data_t *info, struct drm_color_lut_32 *lut)
 {
 	uint32_t val, segment, entry, index = 0;
-	uint32_t max_val = 0xffffffff;
+	float norm_val;
 
 	for (segment = 0; segment < info->segment_count; segment++) {
 		uint32_t entry_count = info->segment_data[segment].count;
 		uint32_t start = info->segment_data[segment].start;
 		uint32_t end = info->segment_data[segment].end;
+		uint32_t norm_factor = info->segment_data[segment].norm_factor;
+		int precision =  info->segment_data[segment].precision.intp + info->segment_data[segment].precision.fracp;
+		uint32_t max_val = get_max(precision);
+
+		/* TODO: Add int precision logic */
+		for (entry = 0; entry < entry_count; entry++) {
+			norm_val = (start * 1.0) / norm_factor + entry * ((end - start) * 1.0 / (((entry_count - 1) ? entry_count - 1 : 1) * norm_factor));
+			val = (norm_val * (1 << info->segment_data[segment].precision.fracp));
 
-		for (entry = 1; entry <= entry_count; entry++) {
-			val = start + entry * ((end - start) * 1.0 / entry_count);
 			lut[index].red = lut[index].green = lut[index].blue =
 				(index == 0) ? 0 : MIN(val, max_val);
 
Signature · 1 line
2.25.1
#9 lore raw

PATCH 9/9 tests/kms_color: Add Intel plane pipeline tests with LUT1D and CTM

In reply to Swati Sharma

For now, Intel plane color pipeline contains 3 colorops:
Pre-csc gamma (1D LUT) --> CTM 3x4 --> Post-csc gamma (1D LUT)

Create subtests to cover different combinations of available colorops:
igt@kms_color@plane-lut1d igt@kms_color@plane-lut1d-ctm3x4 igt@kms_color@plane-ctm3x4-lut1d igt@kms_color@plane-lut1d-lut1d igt@kms_color@plane-lut1d-ctm3x4-lut1d

---
 tests/kms_color.c        | 131 ++++++++++++++++++++++++++++++---------
 tests/kms_color_helper.c |  55 +++++++++++++++-
 tests/kms_color_helper.h |  11 ++++
 3 files changed, 164 insertions(+), 33 deletions(-)
tests/kms_color.c +100 -31
index 1c61fac71..02c43901e 100644
@@ -90,6 +90,11 @@
  * @ctm3x4-lut1d-multseg:		3X4 CTM --> 1D LUT MULTSEG
  * @lut1d-multseg-lut1d-multseg:	1D LUT MULTSEG --> 1D LUT MULTSEG
  * @lut1d-multseg-ctm3x4-lut1d-multseg: 1D LUT MULTSEG --> 3X4 CTM --> 1D LUT MULTSEG
+ * @lut1d:				1D LUT
+ * @lut1d-ctm3x4:			1D LUT --> 3X4 CTM
+ * @ctm3x4-lut1d:			3X4 CTM --> 1D LUT
+ * @lut1d-lut1d:			1D LUT --> 1D LUT
+ * @lut1d-ctm3x4-lut1d: 		1D LUT --> 3X4 CTM --> 1D LUT
  */
 
 IGT_TEST_DESCRIPTION("Test Color Features at Pipe level");
@@ -745,11 +750,13 @@ static void clear_lut_data(kms_colorop_t *colorops[])
 	int i;
 
 	for (i = 0; colorops[i]; i++) {
-		if (colorops[i]->type != KMS_COLOROP_MULTSEG_LUT1D)
-			continue;
-
-		if (colorops[i]->multseg_lut1d_info.lut)
-			free(colorops[i]->multseg_lut1d_info.lut);
+		if (colorops[i]->type == KMS_COLOROP_MULTSEG_LUT1D) {
+			if (colorops[i]->multseg_lut1d_info.lut)
+				free(colorops[i]->multseg_lut1d_info.lut);
+		} else if (colorops[i]->type == KMS_COLOROP_CUSTOM_LUT1D) {
+			if (colorops[i]->lut1d->lut)
+				free(colorops[i]->lut1d->lut);
+		}
 	}
 }
 
@@ -758,35 +765,62 @@ static void prepare_lut_data(data_t *data, kms_colorop_t *colorops[])
 	int i;
 
 	for (i = 0; colorops[i]; i++) {
-		uint64_t hwlut_caps = 0;
-		segment_data_t *segment_info;
+		if (colorops[i]->type == KMS_COLOROP_MULTSEG_LUT1D) {
+			uint64_t hwlut_caps = 0;
+			segment_data_t *segment_info;
+
+			hwlut_caps = igt_colorop_get_prop(&data->display, colorops[i]->colorop, IGT_COLOROP_HW_CAPS);
+			segment_info = get_segment_data(data->drm_fd, hwlut_caps);
+
+			igt_info("Lut size (%s): %d\n", colorops[i]->name, segment_info->entries_count);
+
+			colorops[i]->multseg_lut1d_info.lut_size = segment_info->entries_count;
+			colorops[i]->multseg_lut1d_info.lut =
+				malloc(sizeof(struct drm_color_lut_32) * colorops[i]->multseg_lut1d_info.lut_size);
+			igt_assert(colorops[i]->multseg_lut1d_info.lut);
+
+			switch (colorops[i]->multseg_lut1d_info.lut_type) {
+				case KMS_COLOROP_MULTSEG_LUT1D_ZERO:
+					create_zero_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
+					break;
+				case KMS_COLOROP_MULTSEG_LUT1D_LINEAR:
+					create_unity_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
+					break;
+				case KMS_COLOROP_MULTSEG_LUT1D_MAX:
+				default:
+					create_max_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
+			}
+			clear_segment_data(segment_info);
+		} else if (colorops[i]->type == KMS_COLOROP_CUSTOM_LUT1D) {
+			unsigned int size;
+			gamma_lut_t *lut;
+			struct drm_color_lut_32 *lut_32;
+
+			size = igt_colorop_get_prop(&data->display, colorops[i]->colorop, IGT_COLOROP_SIZE);
+			igt_assert_f(size <= MAX_COLOR_LUT_ENTRIES,
+					"LUT size %u exceeds max %u\n", size, MAX_COLOR_LUT_ENTRIES);
+
+			switch (colorops[i]->lut_type) {
+				case KMS_COLOROP_LUT1D_ZERO:
+					lut = generate_table(size, 0.0);
+					break;
+				case KMS_COLOROP_LUT1D_LINEAR:
+					lut = generate_table(size, 1.0);
+					break;
+				case KMS_COLOROP_LUT1D_MAX:
+				default:
+					lut = generate_table_max(size);
+			}
 
-		if (colorops[i]->type != KMS_COLOROP_MULTSEG_LUT1D)
-			continue;
+			lut_32 = coeffs_to_lut_32(data, lut, 32, 0);
+			igt_assert(lut_32);
 
-		hwlut_caps = igt_colorop_get_prop(&data->display, colorops[i]->colorop, IGT_COLOROP_HW_CAPS);
-		segment_info = get_segment_data(data->drm_fd, hwlut_caps);
-
-		igt_info("Lut size (%s): %d\n", colorops[i]->name, segment_info->entries_count);
-
-		colorops[i]->multseg_lut1d_info.lut_size = segment_info->entries_count;
-		colorops[i]->multseg_lut1d_info.lut =
-			malloc(sizeof(struct drm_color_lut_32) * colorops[i]->multseg_lut1d_info.lut_size);
-		igt_assert(colorops[i]->multseg_lut1d_info.lut);
-
-		switch (colorops[i]->multseg_lut1d_info.lut_type) {
-			case KMS_COLOROP_MULTSEG_LUT1D_ZERO:
-				create_zero_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
-				break;
-			case KMS_COLOROP_MULTSEG_LUT1D_LINEAR:
-				create_unity_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
-				break;
-			case KMS_COLOROP_MULTSEG_LUT1D_MAX:
-			default:
-				create_max_lut(segment_info, colorops[i]->multseg_lut1d_info.lut);
-		}
+			colorops[i]->lut1d = calloc(1, sizeof(struct igt_1dlut));
+			igt_assert(colorops[i]->lut1d);
 
-		clear_segment_data(segment_info);
+			memcpy(colorops[i]->lut1d->lut, lut_32, size * sizeof(struct drm_color_lut_32));
+			free_lut(lut);
+		}
 	}
 }
 
@@ -1367,6 +1401,16 @@ run_tests_for_pipe(data_t *data)
 				.lut_type = KMS_COLOROP_MULTSEG_LUT1D_MAX,
 			},
 		};
+		kms_colorop_t lut1d_linear = {
+			.type = KMS_COLOROP_CUSTOM_LUT1D,
+			.name = "Pre/Post CSC GAMMA (linear LUT)",
+			.lut_type = KMS_COLOROP_LUT1D_LINEAR,
+		};
+		kms_colorop_t lut1d_max = {
+			.type = KMS_COLOROP_CUSTOM_LUT1D,
+			.name = "Pre/Post CSC GAMMA (max LUT)",
+			.lut_type = KMS_COLOROP_LUT1D_MAX,
+		};
 		kms_colorop_t ctm_3x4 = {
 			.type = KMS_COLOROP_CTM_3X4,
 			.name = "CTM 3X4 (red to blue)",
@@ -1408,6 +1452,31 @@ run_tests_for_pipe(data_t *data)
 			  .exp_colors = colors_red_to_blue,
 			  .colorops = { &lut1d_multseg_linear, &ctm_3x4, &lut1d_multseg_max, NULL },
 			},
+			{ .name = "lut1d",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_rgb,
+			  .colorops = { &lut1d_max, NULL },
+			},
+			{ .name = "lut1d-ctm3x4",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_red_to_blue,
+			  .colorops = { &lut1d_max, &ctm_3x4, NULL },
+			},
+			{ .name = "ctm3x4-lut1d",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_red_to_blue,
+			  .colorops = { &ctm_3x4, &lut1d_max, NULL },
+			},
+			{ .name = "lut1d-lut1d",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_rgb,
+			  .colorops = { &lut1d_linear, &lut1d_max, NULL },
+			},
+			{ .name = "lut1d-ctm3x4-lut1d",
+			  .fb_colors = colors_rgb,
+			  .exp_colors = colors_red_to_blue,
+			  .colorops = { &lut1d_linear, &ctm_3x4, &lut1d_max, NULL },
+			},
 		};
 
 		igt_fixture {
tests/kms_color_helper.c +53 -2

68 lines not on this page · raw message

tests/kms_color_helper.h +11 -0
index c384de8a2..86f0a0e11 100644
@@ -96,6 +96,10 @@ struct drm_color_lut *coeffs_to_lut(data_t *data,
 				    const gamma_lut_t *gamma,
 				    uint32_t color_depth,
 				    int off);
+struct drm_color_lut_32 *coeffs_to_lut_32(data_t *data,
+				          const gamma_lut_t *gamma,
+				          uint32_t color_depth,
+				          int off);
 void set_degamma(data_t *data,
 		 igt_pipe_t *pipe,
 		 const gamma_lut_t *gamma);
@@ -159,6 +163,12 @@ typedef enum kms_colorop_multseg_lut1d_tf {
        KMS_COLOROP_MULTSEG_LUT1D_MAX,
 } kms_colorop_multseg_lut1d_tf_t;
 
+typedef enum kms_colorop_lut1d_tf_v2 {
+       KMS_COLOROP_LUT1D_ZERO,
+       KMS_COLOROP_LUT1D_LINEAR,
+       KMS_COLOROP_LUT1D_MAX,
+} kms_colorop_lut1d_tf_v2_t;
+
 typedef struct kms_colorop_multseg_lut1d_info {
 	uint32_t lut_size;
 	kms_colorop_multseg_lut1d_tf_t lut_type;
@@ -177,6 +187,7 @@ typedef struct kms_colorop {
 		double multiplier;
 	};
 
+	kms_colorop_lut1d_tf_v2_t lut_type;
 	kms_colorop_lut3d_info_t lut3d_info;
 
 	const char *name;
Signature · 1 line
2.25.1
#10 lore raw

✗ Fi.CI.BUILD: failure for Add plane color pipeline tests for Intel hardware (rev2)

In reply to Swati Sharma
== Series Details ==

== Series Details ==

Series: Add plane color pipeline tests for Intel hardware (rev2)
URL : https://patchwork.freedesktop.org/series/150455/
State : failure

== Summary ==

Applying: tests/kms_colorop: Color pipeline igt base work Using index info to reconstruct a base tree...
M lib/igt_kms.c
M lib/igt_kms.h
M lib/meson.build
M tests/kms_writeback.c
M tests/meson.build
Falling back to patching base and 3-way merge... Auto-merging tests/meson.build
Auto-merging tests/kms_writeback.c
Auto-merging lib/meson.build
Auto-merging lib/igt_kms.h
CONFLICT (content): Merge conflict in lib/igt_kms.h Auto-merging lib/igt_kms.c
CONFLICT (content): Merge conflict in lib/igt_kms.c
Patch failed at 0001 tests/kms_colorop: Color pipeline igt base work When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".