Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Subject: [RFC v4 18/22] lib/igt_color: Add support for 3x3 matrices
Date: Wed, 14 Feb 2024 12:09:49 +0530	[thread overview]
Message-ID: <20240214063953.1285495-19-bhanuprakash.modem@intel.com> (raw)
In-Reply-To: <20240214063953.1285495-1-bhanuprakash.modem@intel.com>

Add helpers to support 3x3 matrices.

Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
---
 lib/igt_color.h          | 10 ++++++++++
 tests/kms_color_helper.c | 30 ++++++++++++++++++++++++++++++
 tests/kms_color_helper.h |  5 +++++
 3 files changed, 45 insertions(+)

diff --git a/lib/igt_color.h b/lib/igt_color.h
index 46c399cd5..4137abeff 100644
--- a/lib/igt_color.h
+++ b/lib/igt_color.h
@@ -25,6 +25,16 @@ typedef struct igt_pixel {
 	float b;
 } igt_pixel_t;
 
+typedef struct igt_matrix_3x3 {
+	/*
+	 * out   matrix       in
+	 * |R|   |0  1  2 |   | R |
+	 * |G| = |3  4  5 | x | G |
+	 * |B|   |6  7  8 |   | B |
+	 */
+	double m[9];
+} igt_matrix_3x3_t;
+
 typedef struct igt_matrix_3x4 {
 	/*
 	 * out   matrix          in
diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index 02e5b975a..786f49141 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -394,6 +394,8 @@ static bool can_use_colorop(igt_display_t *display, igt_colorop_t *colorop, kms_
 	switch (desired->type) {
 	case KMS_COLOROP_ENUMERATED_LUT1D:
 		return (igt_colorop_get_prop(display, colorop, IGT_COLOROP_TYPE) == DRM_COLOROP_1D_CURVE);
+	case KMS_COLOROP_CTM_3X3:
+		return (igt_colorop_get_prop(display, colorop, IGT_COLOROP_TYPE) == DRM_COLOROP_CTM_3X3);
 	case KMS_COLOROP_CTM_3X4:
 		return (igt_colorop_get_prop(display, colorop, IGT_COLOROP_TYPE) == DRM_COLOROP_CTM_3X4);
 	case KMS_COLOROP_CUSTOM_LUT1D:
@@ -484,6 +486,9 @@ void set_colorop(igt_display_t *display, kms_colorop_t *colorop)
 			igt_fail(IGT_EXIT_FAILURE);
 		}
 		break;
+	case KMS_COLOROP_CTM_3X3:
+		igt_colorop_set_ctm_3x3(display, colorop->colorop, colorop->matrix_3x3);
+		break;
 	case KMS_COLOROP_CTM_3X4:
 		igt_colorop_set_ctm_3x4(display, colorop->colorop, colorop->matrix_3x4);
 		break;
@@ -523,6 +528,31 @@ void set_color_pipeline(igt_display_t *display,
 	}
 }
 
+void igt_colorop_set_ctm_3x3(igt_display_t *display,
+			     igt_colorop_t *colorop,
+			     const struct drm_color_ctm *matrix)
+{
+	struct drm_color_ctm ctm;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ctm.matrix); i++) {
+		if (matrix->matrix[i] < 0) {
+			ctm.matrix[i] =
+				(int64_t) (-matrix->matrix[i] *
+				((int64_t) 1L << 32));
+			ctm.matrix[i] |= 1ULL << 63;
+		} else {
+			ctm.matrix[i] =
+				(int64_t) (matrix->matrix[i] *
+				((int64_t) 1L << 32));
+		}
+		igt_debug("CTM[%d]: %llx\n", i, ctm.matrix[i]);
+	}
+
+	/* set blob property */
+	igt_colorop_replace_prop_blob(colorop, IGT_COLOROP_DATA, &ctm, sizeof(ctm));
+}
+
 void igt_colorop_set_ctm_3x4(igt_display_t *display,
 			     igt_colorop_t *colorop,
 			     const igt_matrix_3x4_t *matrix)
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
index 566615ad9..e172b0318 100644
--- a/tests/kms_color_helper.h
+++ b/tests/kms_color_helper.h
@@ -126,6 +126,7 @@ void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
 typedef enum kms_colorop_type {
 	KMS_COLOROP_ENUMERATED_LUT1D,
 	KMS_COLOROP_CUSTOM_LUT1D,
+	KMS_COLOROP_CTM_3X3,
 	KMS_COLOROP_CTM_3X4,
 	KMS_COLOROP_LUT3D
 } kms_colorop_type_t;
@@ -146,6 +147,7 @@ typedef struct kms_colorop {
 
 	union {
 		kms_colorop_enumerated_lut1d_info_t enumerated_lut1d_info;
+		const struct drm_color_ctm *matrix_3x3;
 		const igt_matrix_3x4_t *matrix_3x4;
 	};
 
@@ -164,6 +166,9 @@ igt_colorop_t *get_color_pipeline(igt_display_t *display, igt_plane_t *plane,
 void set_colorop(igt_display_t *display, kms_colorop_t *colorop);
 void set_color_pipeline(igt_display_t *display, igt_plane_t *plane,
 			      kms_colorop_t *colorops[], igt_colorop_t *color_pipeline);
+void igt_colorop_set_ctm_3x3(igt_display_t *display,
+			     igt_colorop_t *colorop,
+			     const struct drm_color_ctm *matrix);
 void igt_colorop_set_ctm_3x4(igt_display_t *display,
 			     igt_colorop_t *colorop,
 			     const igt_matrix_3x4_t *matrix);
-- 
2.43.0


  parent reply	other threads:[~2024-02-14  6:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14  6:39 [RFC v4 00/22] IGT tests for the KMS Color Pipeline API Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 01/22] lib/drmtest: Add is_vkms_device() Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 02/22] lib/igt_kms: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 03/22] include/drm-uapi: Add COLOROP object Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 04/22] lib/igt_kms: Introduce drm_colorop and COLOR_PIPELINE Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 05/22] tests/kms_properties: Add colorop properties test Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 06/22] igt/color: Add SW color transform functionality Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 07/22] lib/igt_fb: Add copy_fb function Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 08/22] tests/kms_colorop: Add kms_colorop tests Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 09/22] drm-uapi: Add 3x4 CTM Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 10/22] lib/igt_kms: Add support for DATA colorop property Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 11/22] lib/igt_color: Add support for 3x4 matrices Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 12/22] tests/kms_colorop: Add 3x4 CTM tests Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 13/22] tests/kms_properties: Fix compilation errors Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 14/22] lib/igt_kms: Destroy colorops on exit Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 15/22] lib/colorops: Move few helpers to common place to reuse Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 16/22] drm-uapi: Add 3x3 CTM Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 17/22] drm-uapi: Add custom 1D LUT Bhanuprakash Modem
2024-02-14  6:39 ` Bhanuprakash Modem [this message]
2024-02-14  6:39 ` [RFC v4 19/22] lib/colorops: Add support for Custom " Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 20/22] lib/igt_kms: Increase the colorops count Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 21/22] tests/kms_color_helper: Add helpers to clear colorops data Bhanuprakash Modem
2024-02-14  6:39 ` [RFC v4 22/22] tests/kms_color: Add plane color pipeline tests for Intel hardware Bhanuprakash Modem
2024-02-14  7:21 ` ✓ CI.xeBAT: success for IGT tests for the KMS Color Pipeline API (rev4) Patchwork
2024-02-14  7:28 ` ✓ Fi.CI.BAT: " Patchwork
2024-02-14  9:38 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-02-20 20:28 ` [RFC v4 00/22] IGT tests for the KMS Color Pipeline API Harry Wentland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240214063953.1285495-19-bhanuprakash.modem@intel.com \
    --to=bhanuprakash.modem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox