Skip to contentSkip to conversation

Add plane color pipeline tests for Intel hardware

PATCH Superseded Swati Sharma 1 participant 10 messages Oct 3, 2025

Subsystems (2)

v3 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v3 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(v10) 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
v3: -rebase on v10

Bhanuprakash Modem (3):
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

Harry Wentland (1):
tests/kms_colorop: Color pipeline igt base work

Swati Sharma (5):
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: Move color pipeline helpers into kms_color_helper 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   |  185 ++
 lib/drmtest.c                 |    5 +
 lib/drmtest.h                 |    1 +
 lib/igt_color.c               |  697 +++++
 lib/igt_color.h               |  152 +
 lib/igt_color_lut.h           | 4946 +++++++++++++++++++++++++++++++++
 lib/igt_fb.c                  |   33 +-
 lib/igt_fb.h                  |    3 +
 lib/igt_kms.c                 |  379 ++-
 lib/igt_kms.h                 |   99 +
 lib/meson.build               |    1 +
 scripts/convert_3dlut.py      |   94 +
 tests/kms_color.c             |  348 ++-
 tests/kms_color_helper.c      |  383 +++
 tests/kms_color_helper.h      |   85 +-
 tests/kms_colorop.c           |  523 ++++
 tests/kms_colorop.h           |  193 ++
 tests/kms_properties.c        |   92 +-
 tests/kms_writeback.c         |   19 +-
 tests/meson.build             |    2 +
 22 files changed, 8215 insertions(+), 49 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
Signature · 1 line
2.25.1
#1 lore raw

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

From: Harry Wentland <[email protected]>

This is the squashed patch based on the series sent out by Alex Hung. It contains all the changes in the series(v10) 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   |  111 +
 lib/drmtest.c                 |    5 +
 lib/drmtest.h                 |    1 +
 lib/igt_color.c               |  634 +++++
 lib/igt_color.h               |  149 +
 lib/igt_color_lut.h           | 4946 +++++++++++++++++++++++++++++++++
 lib/igt_fb.c                  |   33 +-
 lib/igt_fb.h                  |    3 +
 lib/igt_kms.c                 |  378 ++-
 lib/igt_kms.h                 |   98 +
 lib/meson.build               |    1 +
 scripts/convert_3dlut.py      |   94 +
 tests/kms_colorop.c           |  734 +++++
 tests/kms_colorop.h           |  262 ++
 tests/kms_properties.c        |   92 +-
 tests/kms_writeback.c         |   19 +-
 tests/meson.build             |    1 +
 19 files changed, 7543 insertions(+), 42 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 b38f27d69..ca24519c7 100644
@@ -1590,15 +1590,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 +111 -0

135 lines not on this page · raw message

lib/drmtest.c +5 -0
index 551385867..0c1dc026d 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 a9542dde2..f6f076674 100644
@@ -140,6 +140,7 @@ void igt_require_vc4(int fd);
 void igt_require_xe(int fd);
 void igt_require_vkms(void);
 
+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 +634 -0

634 lines not on this page · raw message

lib/igt_color.h new file +149 -0

149 lines not on this page · raw message

lib/igt_color_lut.h new file +4946 -0

2,028 lines not on this page · raw message

lib/igt_fb.c +31 -2
index f42f37917..ce040664f 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 +360 -18

378 lines not on this page · raw message

lib/igt_kms.h +98 -0

98 lines not on this page · raw message

lib/meson.build +1 -0
index f50a8d44b..26deb8d4b 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 +734 -0

734 lines not on this page · raw message

tests/kms_colorop.h new file +262 -0

262 lines not on this page · raw message

tests/kms_properties.c +86 -6

92 lines not on this page · raw message

tests/kms_writeback.c +12 -7
index 1b81088d7..511d2630b 100644

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

tests/meson.build +1 -0
index a7b9375ed..d7e0b951a 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 v3 2/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 696b76d3f..1298274d9 100644
@@ -1105,6 +1105,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
#3 lore raw

PATCH v3 3/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 1298274d9..d354526e8 100644
@@ -912,6 +912,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
#4 lore raw

PATCH v3 4/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 435e44744..347cbe2a7 100644
@@ -711,6 +711,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 beeab4b3c..fc7eccb6c 100644
@@ -375,6 +375,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
#5 lore raw

PATCH v3 5/9 tests/kms_color: Move color pipeline helpers into kms_color_helper

In reply to Swati Sharma

Refactor kms_color and kms_colorop by moving common color pipeline functions into kms_color_helper.[ch]. This consolidates LUT setup, matrix configuration, and colorop mapping logic, reducing duplication between tests.

In addition, LUT and matrix reference data are now defined in lib/ with extern declarations, avoiding multiple-definition issues. The 3DLUT table is marked static const to prevent accidental writes.

This change prepares the groundwork for adding more color pipeline tests while keeping kms_color and kms_colorop focused on test logic.

---
 lib/igt_color.c          |  52 +++++++++-
 lib/igt_color.h          |  77 ++++++--------
 lib/igt_color_lut.h      |   2 +-
 tests/kms_color_helper.c | 202 ++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.h |  56 +++++++++-
 tests/kms_colorop.c      | 215 +--------------------------------------
 tests/kms_colorop.h      |  69 -------------
 tests/meson.build        |   1 +
 8 files changed, 344 insertions(+), 330 deletions(-)
lib/igt_color.c +51 -1
index 6a306bda2..e66d6fe54 100644
@@ -16,6 +16,56 @@
 #include "igt_core.h"
 #include "igt_x86.h"
 
+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
+} };
+
+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
+} };
+
+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)
 {
@@ -220,7 +270,7 @@ igt_get_lut3d_index_blue_fast(int r, int g, int b, long dim, int components)
 }
 
 /* algorithm from https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/main/src/OpenColorIO/ops/lut3d/Lut3DOpCPU.cpp#L422 */
-static void igt_color_3dlut_tetrahedral(igt_pixel_t *pixel, igt_3dlut_t *lut3d, long m_dim)
+static void igt_color_3dlut_tetrahedral(igt_pixel_t *pixel, const igt_3dlut_t *lut3d, long m_dim)
 {
 	int n000, n100, n010, n001, n110, n101, n011, n111;
 	float m_step = (float) m_dim - 1.0f;
lib/igt_color.h +32 -45

102 lines not on this page · raw message

lib/igt_color_lut.h +1 -1
index b5c149c3d..046a28504 100644
@@ -27,7 +27,7 @@ typedef struct igt_3dlut {
  * A 3D LUT table with 17x17x17 entries for Traversal order RGB.
  * It can be generated by scripts/convert_3dlut.py
  */
-igt_3dlut_t igt_3dlut_17_rgb = { {
+static const igt_3dlut_t igt_3dlut_17_rgb = { {
 	{ .red = 0.000000, .green = 0.000000, .blue = 0.000000 },
 	{ .red = 0.175580, .green = 0.003419, .blue = 0.006838 },
 	{ .red = 0.338706, .green = 0.015140, .blue = 0.012454 },
tests/kms_color_helper.c +202 -0

205 lines not on this page · raw message

tests/kms_color_helper.h +55 -1

75 lines not on this page · raw message

tests/kms_colorop.c +2 -213

239 lines not on this page · raw message

tests/kms_colorop.h +0 -69

75 lines not on this page · raw message

tests/meson.build +1 -0
index d7e0b951a..d1506eb47 100644
@@ -374,6 +374,7 @@ extra_sources = {
 	'dumb_buffer': ['dumb_buffer.c' ],
 	'testdisplay': [ 'testdisplay_hotplug.c' ],
 	'kms_color':  [ 'kms_color_helper.c' ],
+	'kms_colorop':  [ 'kms_color_helper.c' ],
 	'kms_chamelium_audio': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
 	'kms_chamelium_color':  [ 'kms_color_helper.c', join_paths ('chamelium', 'kms_chamelium_helper.c') ],
 	'kms_chamelium_edid': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
Signature · 1 line
2.25.1
#6 lore raw

PATCH v3 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.

---
 lib/igt_color.c          | 13 ++++++
 lib/igt_color.h          | 16 ++++++++
 tests/kms_color_helper.c | 87 ++++++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.h | 14 +++++++
 4 files changed, 130 insertions(+)
lib/igt_color.c +13 -0
index e66d6fe54..b822993df 100644
@@ -682,3 +682,16 @@ void igt_colorop_set_3dlut(igt_display_t *display,
 {
 	igt_colorop_replace_prop_blob(colorop, IGT_COLOROP_DATA, lut3d, lut_size);
 }
+
+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_lut32) * lut_info.lut_size);
+}
lib/igt_color.h +16 -0
index c88b9838c..3359e011b 100644
@@ -63,6 +63,18 @@ typedef struct igt_1dlut {
 	struct drm_color_lut32 lut[MAX_COLOR_LUT_ENTRIES];
 } igt_1dlut_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_lut32 *lut;
+} kms_colorop_multseg_lut1d_info_t;
+
 typedef bool (*compare_fb_t)(igt_fb_t *in, igt_fb_t *out);
 typedef int (*transform_fb)(igt_fb_t *in);
 typedef int (*transform_pixel)(igt_pixel_t *pixel);
@@ -106,6 +118,10 @@ void igt_colorop_set_3dlut(igt_display_t *display,
 			   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);
+
 /* transformations */
 
 void igt_color_srgb_inv_eotf(igt_pixel_t *pixel);
tests/kms_color_helper.c +87 -0

108 lines not on this page · raw message

tests/kms_color_helper.h +14 -0
index eb56c0586..696cb0fb3 100644
@@ -121,10 +121,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_lut32 *lut);
+void create_unity_lut(segment_data_t *info, struct drm_color_lut32 *lut);
+void create_max_lut(segment_data_t *info, struct drm_color_lut32 *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
@@ -146,6 +159,7 @@ typedef struct kms_colorop {
 		kms_colorop_enumerated_lut1d_info_t enumerated_lut1d_info;
 		igt_1dlut_t *lut1d;
 		const igt_3dlut_t *lut3d;
+		kms_colorop_multseg_lut1d_info_t multseg_lut1d_info;
 		const igt_matrix_3x4_t *matrix_3x4;
 		double multiplier;
 	};
Signature · 1 line
2.25.1
#7 lore raw

PATCH v3 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 |  4 ++++
 2 files changed, 36 insertions(+)
tests/kms_color_helper.c +32 -0
index ebb93f0e2..d34e6527f 100644
@@ -677,3 +677,35 @@ segment_data_t *get_segment_data(int drm_fd, uint64_t blob_id)
 
 	return info;
 }
+
+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 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]);
+}
tests/kms_color_helper.h +4 -0
index 696cb0fb3..f4a120894 100644
@@ -183,5 +183,9 @@ void set_color_pipeline(igt_display_t *display, igt_plane_t *plane,
 		        kms_colorop_t *colorops[], igt_colorop_t *color_pipeline);
 void set_color_pipeline_bypass(igt_plane_t *plane);
 
+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);
+
 #endif
 
Signature · 1 line
2.25.1
#8 lore raw

PATCH v3 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 c424083b7..3f38c484e 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_lut32) * 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)
 {
@@ -1157,16 +1344,96 @@ 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_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);
+		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);
 
 			if (igt_run_in_simulation())
 				break;
+			}
 		}
 	}
 }
tests/kms_color_helper.c +17 -3
index d34e6527f..32925e4bc 100644
@@ -608,18 +608,32 @@ void create_zero_lut(segment_data_t *info, struct drm_color_lut32 *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_lut32 *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 v3 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        | 125 ++++++++++++++++++++++++++++++---------
 tests/kms_color_helper.c |  50 +++++++++++++++-
 tests/kms_color_helper.h |  11 ++++
 3 files changed, 157 insertions(+), 29 deletions(-)
tests/kms_color.c +97 -28
index 3f38c484e..a854a24a0 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;
 
-		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);
 
-		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);
 
-		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_lut32) * colorops[i]->multseg_lut1d_info.lut_size);
+			igt_assert(colorops[i]->multseg_lut1d_info.lut);
 
-		colorops[i]->multseg_lut1d_info.lut_size = segment_info->entries_count;
-		colorops[i]->multseg_lut1d_info.lut =
-			malloc(sizeof(struct drm_color_lut32) * 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_lut32 *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);
+			}
 
-		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);
-		}
+			lut_32 = coeffs_to_lut_32(data, lut, 32, 0);
+			igt_assert(lut_32);
 
-		clear_segment_data(segment_info);
+			colorops[i]->lut1d = calloc(1, sizeof(struct igt_1dlut));
+			igt_assert(colorops[i]->lut1d);
+
+			memcpy(colorops[i]->lut1d->lut, lut_32, size * sizeof(struct drm_color_lut32));
+			free_lut(lut);
+		}
 	}
 }
 
@@ -1369,6 +1403,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)",
@@ -1410,6 +1454,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 +49 -1

62 lines not on this page · raw message

tests/kms_color_helper.h +11 -0
index f4a120894..5cab6d6f1 100644
@@ -95,6 +95,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_lut32 *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);
@@ -152,6 +156,12 @@ typedef struct kms_colorop_lut3d_info {
 	enum drm_colorop_lut3d_interpolation_type interpolation;
 } kms_colorop_lut3d_info_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 {
 	kms_colorop_type_t type;
 
@@ -164,6 +174,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