[Intel-gfx] [PATCH i-g-t 2/5] lib: kms: add helpers for color management properties on pipes

Lionel Landwerlin lionel.g.landwerlin at intel.com
Thu Feb 25 17:16:10 UTC 2016


v2: Rename CTM_MATRIX property to CTM

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 lib/igt_kms.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h | 17 +++++++++++++-
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index dd4ca45..22996d5 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1179,6 +1179,21 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 						   &prop_value,
 						   NULL);
 				pipe->background = (uint32_t)prop_value;
+				get_crtc_property(display->drm_fd, output->config.crtc->crtc_id,
+						  "DEGAMMA_LUT",
+						  &pipe->degamma_property,
+						  NULL,
+					  NULL);
+				get_crtc_property(display->drm_fd, output->config.crtc->crtc_id,
+						  "CTM_MATRIX",
+						  &pipe->ctm_property,
+						  NULL,
+						  NULL);
+				get_crtc_property(display->drm_fd, output->config.crtc->crtc_id,
+						  "GAMMA_LUT",
+						  &pipe->gamma_property,
+						  NULL,
+						  NULL);
 			}
 		}
 	}
@@ -1328,6 +1343,16 @@ static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, enum igt_plane plane)
 	return &pipe->planes[idx];
 }
 
+bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
+			   uint32_t *prop_id, uint64_t *value,
+			   drmModePropertyPtr *prop)
+{
+	return get_crtc_property(pipe->display->drm_fd,
+				 pipe->crtc_id,
+				 name,
+				 prop_id, value, prop);
+}
+
 static uint32_t igt_plane_get_fb_id(igt_plane_t *plane)
 {
 	if (plane->fb)
@@ -1635,6 +1660,17 @@ static int igt_output_commit(igt_output_t *output,
 		pipe->background_changed = false;
 	}
 
+	if (pipe->color_mgmt_changed) {
+		igt_crtc_set_property(output, pipe->degamma_property,
+				      pipe->degamma_blob);
+		igt_crtc_set_property(output, pipe->ctm_property,
+				      pipe->ctm_blob);
+		igt_crtc_set_property(output, pipe->gamma_property,
+				      pipe->gamma_blob);
+
+		pipe->color_mgmt_changed = false;
+	}
+
 	for (i = 0; i < pipe->n_planes; i++) {
 		igt_plane_t *plane = &pipe->planes[i];
 
@@ -1967,6 +2003,44 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation)
 	plane->rotation_changed = true;
 }
 
+static void
+igt_pipe_replace_blob(igt_pipe_t *pipe, uint64_t *blob, void *ptr, size_t length)
+{
+	igt_display_t *display = pipe->display;
+	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;
+}
+
+void
+igt_pipe_set_degamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
+{
+	igt_pipe_replace_blob(pipe, &pipe->degamma_blob, ptr, length);
+	pipe->color_mgmt_changed = 1;
+}
+
+void
+igt_pipe_set_ctm_matrix(igt_pipe_t *pipe, void *ptr, size_t length)
+{
+	igt_pipe_replace_blob(pipe, &pipe->ctm_blob, ptr, length);
+	pipe->color_mgmt_changed = 1;
+}
+
+void
+igt_pipe_set_gamma_lut(igt_pipe_t *pipe, void *ptr, size_t length)
+{
+	igt_pipe_replace_blob(pipe, &pipe->gamma_blob, ptr, length);
+	pipe->color_mgmt_changed = 1;
+}
+
 /**
  * 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 77327c2..11a37d5 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -215,6 +215,15 @@ struct igt_pipe {
 	uint64_t background; /* Background color MSB BGR 16bpc LSB */
 	uint32_t background_changed : 1;
 	uint32_t background_property;
+
+	uint64_t degamma_blob;
+	uint32_t degamma_property;
+	uint64_t ctm_blob;
+	uint32_t ctm_property;
+	uint64_t gamma_blob;
+	uint32_t gamma_property;
+	uint32_t color_mgmt_changed : 1;
+
 	uint32_t crtc_id;
 };
 
@@ -253,12 +262,19 @@ 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);
 igt_plane_t *igt_output_get_plane(igt_output_t *output, enum igt_plane plane);
+bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name,
+			   uint32_t *prop_id, uint64_t *value,
+			   drmModePropertyPtr *prop);
 
 static inline bool igt_plane_supports_rotation(igt_plane_t *plane)
 {
 	return plane->rotation_property != 0;
 }
 
+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_position(igt_plane_t *plane, int x, int y);
 void igt_plane_set_size(igt_plane_t *plane, int w, int h);
@@ -294,4 +310,3 @@ const unsigned char* igt_kms_get_alt_edid(void);
 
 
 #endif /* __IGT_KMS_H__ */
-
-- 
2.7.0



More information about the Intel-gfx mailing list