All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t v2 06/14] lib/igt_kms: Export property blob functions for output/pipe/plane, v2.
Date: Thu, 12 Oct 2017 13:54:27 +0200	[thread overview]
Message-ID: <20171012115435.18880-7-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20171012115435.18880-1-maarten.lankhorst@linux.intel.com>

With the replace_prop_blob functions we can safely replace the blob for
any property, without having to care about error handling ourselves.

This will for example allow overriding color management blobs, or for
kms_atomic set invalid mode blobs.

The color management blob functions are removed, they can now be
replaced by direct calls to replace the properties.

Changes since v1:
- Fix chamelium tests.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_kms.c     | 117 +++++++++++++++++++++++++++++++++++++++---------------
 lib/igt_kms.h     |  19 +++++++--
 tests/chamelium.c |   6 +--
 tests/kms_color.c |  12 +++---
 4 files changed, 110 insertions(+), 44 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index e7b9fbaba709..5f54021350ac 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2443,8 +2443,88 @@ static int igt_output_commit(igt_output_t *output,
 	return 0;
 }
 
-static void
-igt_pipe_replace_blob(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop, void *ptr, size_t length)
+/**
+ * igt_plane_replace_prop_blob:
+ * @plane: plane to set property on.
+ * @prop: property for which the blob will be replaced.
+ * @ptr: Pointer to contents for the property.
+ * @length: Length of contents.
+ *
+ * This function will destroy the old property blob for the given property,
+ * and will create a new property blob with the values passed to this function.
+ *
+ * The new property blob will be committed when you call igt_display_commit(),
+ * igt_display_commit2() or igt_display_commit_atomic().
+ */
+void
+igt_plane_replace_prop_blob(igt_plane_t *plane, enum igt_atomic_plane_properties prop, const void *ptr, size_t length)
+{
+	igt_display_t *display = plane->pipe->display;
+	uint64_t *blob = &plane->values[prop];
+	uint32_t blob_id = 0;
+
+	if (*blob != 0)
+		igt_assert(drmModeDestroyPropertyBlob(display->drm_fd,
+						      *blob) == 0);
+
+	if (length > 0)
+		igt_assert(drmModeCreatePropertyBlob(display->drm_fd,
+						     ptr, length, &blob_id) == 0);
+
+	*blob = blob_id;
+	igt_plane_set_prop_changed(plane, prop);
+}
+
+/**
+ * igt_output_replace_prop_blob:
+ * @output: output to set property on.
+ * @prop: property for which the blob will be replaced.
+ * @ptr: Pointer to contents for the property.
+ * @length: Length of contents.
+ *
+ * This function will destroy the old property blob for the given property,
+ * and will create a new property blob with the values passed to this function.
+ *
+ * The new property blob will be committed when you call igt_display_commit(),
+ * igt_display_commit2() or igt_display_commit_atomic().
+ */
+void
+igt_output_replace_prop_blob(igt_output_t *output, enum igt_atomic_connector_properties prop, const void *ptr, size_t length)
+{
+	igt_display_t *display = output->display;
+	uint64_t *blob = &output->values[prop];
+	uint32_t blob_id = 0;
+
+	if (*blob != 0)
+		igt_assert(drmModeDestroyPropertyBlob(display->drm_fd,
+						      *blob) == 0);
+
+	if (length > 0)
+		igt_assert(drmModeCreatePropertyBlob(display->drm_fd,
+						     ptr, length, &blob_id) == 0);
+
+	*blob = blob_id;
+	igt_output_set_prop_changed(output, prop);
+}
+
+/**
+ * igt_pipe_obj_replace_prop_blob:
+ * @pipe: pipe to set property on.
+ * @prop: property for which the blob will be replaced.
+ * @ptr: Pointer to contents for the property.
+ * @length: Length of contents.
+ *
+ * This function will destroy the old property blob for the given property,
+ * and will create a new property blob with the values passed to this function.
+ *
+ * The new property blob will be committed when you call igt_display_commit(),
+ * igt_display_commit2() or igt_display_commit_atomic().
+ *
+ * Please use igt_output_override_mode() if you want to set #IGT_CRTC_MODE_ID,
+ * it works better with legacy commit.
+ */
+void
+igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop, const void *ptr, size_t length)
 {
 	igt_display_t *display = pipe->display;
 	uint64_t *blob = &pipe->values[prop];
@@ -2836,7 +2916,7 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode)
 
 	if (pipe) {
 		if (output->display->is_atomic)
-			igt_pipe_replace_blob(pipe, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(*mode));
+			igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(*mode));
 		else
 			igt_pipe_obj_set_prop_changed(pipe, IGT_CRTC_MODE_ID);
 	}
@@ -2865,7 +2945,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
 		old_output = igt_pipe_get_output(old_pipe);
 		if (!old_output) {
 			if (display->is_atomic)
-				igt_pipe_replace_blob(old_pipe, IGT_CRTC_MODE_ID, NULL, 0);
+				igt_pipe_obj_replace_prop_blob(old_pipe, IGT_CRTC_MODE_ID, NULL, 0);
 			else
 				igt_pipe_obj_set_prop_changed(old_pipe, IGT_CRTC_MODE_ID);
 
@@ -2879,7 +2959,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe)
 
 	if (pipe_obj) {
 		if (display->is_atomic)
-			igt_pipe_replace_blob(pipe_obj, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(drmModeModeInfo));
+			igt_pipe_obj_replace_prop_blob(pipe_obj, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(drmModeModeInfo));
 		else
 			igt_pipe_obj_set_prop_changed(pipe_obj, IGT_CRTC_MODE_ID);
 
@@ -2908,18 +2988,11 @@ void igt_pipe_refresh(igt_display_t *display, enum pipe pipe, bool force)
 
 		pipe_obj->values[IGT_CRTC_MODE_ID] = 0;
 		if (output)
-			igt_pipe_replace_blob(pipe_obj, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(drmModeModeInfo));
+			igt_pipe_obj_replace_prop_blob(pipe_obj, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(drmModeModeInfo));
 	} else
 		igt_pipe_obj_set_prop_changed(pipe_obj, IGT_CRTC_MODE_ID);
 }
 
-void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode)
-{
-	igt_output_set_prop_value(output, IGT_CONNECTOR_SCALING_MODE, scaling_mode);
-
-	igt_require(output->props[IGT_CONNECTOR_SCALING_MODE]);
-}
-
 igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx)
 {
 	igt_pipe_t *pipe;
@@ -3119,24 +3192,6 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe)
 	igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)&pipe->out_fence_fd);
 }
 
-void
-igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
-{
-	igt_pipe_replace_blob(pipe, IGT_CRTC_DEGAMMA_LUT, ptr, length);
-}
-
-void
-igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length)
-{
-	igt_pipe_replace_blob(pipe, IGT_CRTC_CTM, ptr, length);
-}
-
-void
-igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
-{
-	igt_pipe_replace_blob(pipe, IGT_CRTC_GAMMA_LUT, ptr, length);
-}
-
 /**
  * igt_crtc_set_background:
  * @pipe: pipe pointer to which background color to be set
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index b53127ffef5f..2e4c23437f4e 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -366,7 +366,6 @@ const char *igt_output_name(igt_output_t *output);
 drmModeModeInfo *igt_output_get_mode(igt_output_t *output);
 void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode);
 void igt_output_set_pipe(igt_output_t *output, enum pipe pipe);
-void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode);
 igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx);
 igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type);
 igt_output_t *igt_output_from_connector(igt_display_t *display,
@@ -381,9 +380,6 @@ static inline bool igt_plane_supports_rotation(igt_plane_t *plane)
 	return plane->props[IGT_PLANE_ROTATION] != 0;
 }
 void igt_pipe_request_out_fence(igt_pipe_t *pipe);
-void igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
-void igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length);
-void igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length);
 
 void igt_plane_set_fb(igt_plane_t *plane, struct igt_fb *fb);
 void igt_plane_set_fence_fd(igt_plane_t *plane, int fence_fd);
@@ -513,6 +509,10 @@ static inline bool igt_output_is_connected(igt_output_t *output)
 		igt_plane_set_prop_changed(plane, prop); \
 	} while (0)
 
+extern void igt_plane_replace_prop_blob(igt_plane_t *plane,
+					enum igt_atomic_plane_properties prop,
+					const void *ptr, size_t length);
+
 #define igt_output_is_prop_changed(output, prop) \
 	(!!((output)->changed & (1 << (prop))))
 #define igt_output_set_prop_changed(output, prop) \
@@ -527,6 +527,10 @@ static inline bool igt_output_is_connected(igt_output_t *output)
 		igt_output_set_prop_changed(output, prop); \
 	} while (0)
 
+extern void igt_output_replace_prop_blob(igt_output_t *output,
+					 enum igt_atomic_connector_properties prop,
+					 const void *ptr, size_t length);
+
 #define igt_pipe_obj_is_prop_changed(pipe_obj, prop) \
 	(!!((pipe_obj)->changed & (1 << (prop))))
 
@@ -554,6 +558,13 @@ static inline bool igt_output_is_connected(igt_output_t *output)
 #define igt_pipe_set_prop_value(display, pipe, prop, value) \
 	igt_pipe_obj_set_prop_value(&(display)->pipes[(pipe)], prop, value)
 
+extern void igt_pipe_obj_replace_prop_blob(igt_pipe_t *pipe_obj,
+					   enum igt_atomic_crtc_properties prop,
+					   const void *ptr, size_t length);
+
+#define igt_pipe_replace_prop_blob(display, pipe, prop, ptr, length) \
+	igt_pipe_obj_replace_prop_blob(&(display)->pipes[(pipe)], prop, ptr, length)
+
 void igt_pipe_refresh(igt_display_t *display, enum pipe pipe, bool force);
 
 void igt_enable_connectors(void);
diff --git a/tests/chamelium.c b/tests/chamelium.c
index e3d81357b32b..ae164920e86e 100644
--- a/tests/chamelium.c
+++ b/tests/chamelium.c
@@ -462,9 +462,9 @@ enable_output(data_t *data,
 	igt_output_set_pipe(output, output->config.pipe);
 
 	/* Clear any color correction values that might be enabled */
-	igt_pipe_set_degamma_lut(primary->pipe, NULL, 0);
-	igt_pipe_set_gamma_lut(primary->pipe, NULL, 0);
-	igt_pipe_set_ctm_matrix(primary->pipe, NULL, 0);
+	igt_pipe_obj_replace_prop_blob(primary->pipe, IGT_CRTC_DEGAMMA_LUT, NULL, 0);
+	igt_pipe_obj_replace_prop_blob(primary->pipe, IGT_CRTC_GAMMA_LUT, NULL, 0);
+	igt_pipe_obj_replace_prop_blob(primary->pipe, IGT_CRTC_CTM, NULL, 0);
 
 	kmstest_set_connector_broadcast_rgb(display->drm_fd, connector,
 					    BROADCAST_RGB_FULL);
diff --git a/tests/kms_color.c b/tests/kms_color.c
index bcd48d89875c..e30e6bf4e409 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -189,7 +189,7 @@ static void set_degamma(data_t *data,
 						   data->degamma_lut_size,
 						   data->color_depth, 0);
 
-	igt_pipe_set_degamma_lut(pipe, lut, size);
+	igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_DEGAMMA_LUT, lut, size);
 
 	free(lut);
 }
@@ -204,7 +204,7 @@ static void set_gamma(data_t *data,
 						   data->gamma_lut_size,
 						   data->color_depth, 0);
 
-	igt_pipe_set_gamma_lut(pipe, lut, size);
+		igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_GAMMA_LUT, lut, size);
 
 	free(lut);
 }
@@ -224,12 +224,12 @@ static void set_ctm(igt_pipe_t *pipe, const double *coefficients)
 				(int64_t) (coefficients[i] * ((int64_t) 1L << 32));
 	}
 
-	igt_pipe_set_ctm_matrix(pipe, &ctm, sizeof(ctm));
+	igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_CTM, &ctm, sizeof(ctm));
 }
 
-#define disable_degamma(pipe) igt_pipe_set_degamma_lut(pipe, NULL, 0)
-#define disable_gamma(pipe) igt_pipe_set_gamma_lut(pipe, NULL, 0)
-#define disable_ctm(pipe) igt_pipe_set_ctm_matrix(pipe, NULL, 0)
+#define disable_degamma(pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_DEGAMMA_LUT, NULL, 0)
+#define disable_gamma(pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_GAMMA_LUT, NULL, 0)
+#define disable_ctm(pipe) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_CTM, NULL, 0)
 
 static void output_set_property_enum(igt_output_t *output,
 				     const char *property,
-- 
2.14.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-10-12 11:54 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12 11:54 [PATCH i-g-t v2 00/14] lib/igt_kms: Rewrite property handling to better match atomic Maarten Lankhorst
2017-10-12 11:54 ` [PATCH i-g-t v2 01/14] lib/igt_kms: Rework connector properties to be more atomic, v2 Maarten Lankhorst
2017-10-12 11:54 ` [PATCH i-g-t v2 02/14] lib/igt_kms: Rework plane properties to be more atomic, v5 Maarten Lankhorst
2017-10-19  9:08   ` Mika Kahola
2017-10-19  9:44     ` Maarten Lankhorst
2017-10-20  8:03       ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 03/14] lib/igt_kms: Rework pipe properties to be more atomic, v7 Maarten Lankhorst
2017-10-19 10:28   ` Mika Kahola
2018-03-05 14:37   ` Maxime Ripard
2018-03-05 14:37     ` [igt-dev] [Intel-gfx] " Maxime Ripard
2018-03-06 13:41     ` Daniel Vetter
2018-03-06 13:41       ` [igt-dev] [Intel-gfx] " Daniel Vetter
2018-03-06 13:47       ` Maarten Lankhorst
2018-03-06 13:47         ` [Intel-gfx] " Maarten Lankhorst
2017-10-12 11:54 ` [PATCH i-g-t v2 04/14] lib/igt_kms: Allow setting any plane property through the universal path Maarten Lankhorst
2017-10-19 11:04   ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 05/14] lib/igt_kms: Allow setting any output property through the !atomic paths Maarten Lankhorst
2017-10-20  9:38   ` Mika Kahola
2017-10-12 11:54 ` Maarten Lankhorst [this message]
2017-10-19 11:24   ` [PATCH i-g-t v2 06/14] lib/igt_kms: Export property blob functions for output/pipe/plane, v2 Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 07/14] lib/igt_kms: Unexport broadcast rgb API Maarten Lankhorst
2017-10-19 11:28   ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 08/14] lib/igt_kms: Add igt_$obj_has_prop functions Maarten Lankhorst
2017-10-12 15:33   ` [PATCH i-g-t v2] lib/igt_kms: Add igt_$obj_has_prop functions, v2 Maarten Lankhorst
2017-10-19 12:06     ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 09/14] lib/igt_kms: Add igt_$obj_get_prop functions Maarten Lankhorst
2017-10-19 12:58   ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 10/14] lib/igt_kms: Remove igt_pipe_get_property Maarten Lankhorst
2017-10-19 13:18   ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 11/14] lib/igt_kms: Remove igt_crtc_set_background() Maarten Lankhorst
2017-10-20  6:33   ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 12/14] tests/kms_color: Rework tests slightly to work better with new atomic api Maarten Lankhorst
2017-10-20  7:14   ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 13/14] tests/chamelium: Remove reliance on output->config.pipe Maarten Lankhorst
2017-10-20  7:15   ` Mika Kahola
2017-10-12 11:54 ` [PATCH i-g-t v2 14/14] tests/kms_atomic: Convert/rewrite tests to use igt_kms framework Maarten Lankhorst
2017-10-12 15:33   ` [PATCH i-g-t v2] tests/kms_atomic: Convert/rewrite tests to use igt_kms framework, v2 Maarten Lankhorst
2017-10-20 10:02     ` Mika Kahola
2017-10-20 10:08       ` Maarten Lankhorst
2017-10-20 10:16         ` Mika Kahola
2017-10-20 11:43           ` Maarten Lankhorst
2017-10-12 12:28 ` ✓ Fi.CI.BAT: success for lib/igt_kms: Rewrite property handling to better match atomic. (rev4) Patchwork
2017-10-12 15:01 ` ✗ Fi.CI.IGT: failure " Patchwork
2017-10-12 16:04 ` ✓ Fi.CI.BAT: success for lib/igt_kms: Rewrite property handling to better match atomic. (rev6) Patchwork
2017-10-12 23:47 ` ✗ Fi.CI.IGT: failure " Patchwork

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=20171012115435.18880-7-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.