[RFC 32/33] drm/i915/color: Add a dummy pipeline with 3D LUT
Uma Shankar
uma.shankar at intel.com
Tue Aug 29 16:04:21 UTC 2023
From: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
This patch is to demonstrate how a pipeline can be added.
Co-developed-by: Uma Shankar <uma.shankar at intel.com>
Signed-off-by: Uma Shankar <uma.shankar at intel.com>
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 3 ++
drivers/gpu/drm/drm_atomic_uapi.c | 15 +++++++++
drivers/gpu/drm/i915/display/intel_color.c | 37 ++++++++++++++++++++--
include/drm/drm_plane.h | 6 ++++
4 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index a554e04c2ce3..9c389d97b344 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -349,6 +349,8 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
drm_property_blob_get(state->color.post_csc_lut);
if (state->color.private_color_op_data)
drm_property_blob_get(state->color.private_color_op_data);
+ if (state->color.lut_3d)
+ drm_property_blob_get(state->color.lut_3d);
state->color_mgmt_changed = false;
}
@@ -402,6 +404,7 @@ void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)
drm_property_blob_put(state->color.ctm);
drm_property_blob_put(state->color.post_csc_lut);
drm_property_blob_put(state->color.private_color_op_data);
+ drm_property_blob_put(state->color.lut_3d);
}
EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 9e0fb36d1f47..5629db763fd1 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -482,6 +482,15 @@ int drm_plane_reset_color_op_blobs(struct drm_plane *plane,
&blob_replaced);
temp_replaced |= blob_replaced;
+ if (ret)
+ goto out;
+
+ ret = drm_atomic_replace_property_blob_from_id(dev,
+ &state->color.lut_3d,
+ 0, -1, -1,
+ &blob_replaced);
+ temp_replaced |= blob_replaced;
+
if (ret)
goto out;
out:
@@ -551,6 +560,12 @@ int drm_plane_replace_color_op_blobs(struct drm_plane *plane,
color_op[i].blob_id,
-1, -1,
&blob_replaced);
+ } else if (color_op[i].name == DRM_CB_3D_LUT) {
+ ret = drm_atomic_replace_property_blob_from_id(dev,
+ &state->color.lut_3d,
+ color_op[i].blob_id,
+ -1, sizeof(struct drm_color_lut_ext),
+ &blob_replaced);
} else {
ret = -EINVAL;
goto copy_fail;
diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index 4e5c82c88bd4..2352ddb4a96a 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -4265,6 +4265,19 @@ static const struct drm_color_lut_range xelpd_post_csc_hdr[] = {
},
};
+static const struct drm_color_lut_range dummy_3d_lut_range[] = {
+ {
+ .flags = (DRM_MODE_LUT_POST_CSC |
+ DRM_MODE_LUT_REFLECT_NEGATIVE |
+ DRM_MODE_LUT_INTERPOLATE |
+ DRM_MODE_LUT_NON_DECREASING),
+ .count = 32,
+ .input_bpc = 24, .output_bpc = 16,
+ .start = 0, .end = (1 << 24) - 1,
+ .min = 0, .max = (1 << 24) - 1,
+ },
+};
+
struct drm_color_op color_pipeline_sdr[] = {
{
.name = DRM_CB_PRE_CSC,
@@ -4300,10 +4313,17 @@ struct drm_color_op color_pipeline_hdr[] = {
},
};
+struct drm_color_op color_pipeline_3dlut[] = {
+ {
+ .name = DRM_CB_3D_LUT,
+ .type = CURVE_3D,
+ },
+};
+
static int intel_prepare_plane_color_pipeline(struct drm_plane *plane)
{
struct drm_i915_private *i915 = to_i915(plane->dev);
- struct drm_property_blob *blob[2] = {NULL};
+ struct drm_property_blob *blob[3] = {NULL};
int ret = 0, i = 0;
if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
@@ -4350,6 +4370,17 @@ static int intel_prepare_plane_color_pipeline(struct drm_plane *plane)
color_pipeline_sdr[1].blob_id = blob[i++]->base.id;
}
+ blob[i] = drm_property_create_blob(plane->dev,
+ sizeof(dummy_3d_lut_range),
+ dummy_3d_lut_range);
+
+ if (IS_ERR(blob[i])) {
+ ret = PTR_ERR(blob[i]);
+ goto out;
+ }
+
+ color_pipeline_3dlut[0].blob_id = blob[i++]->base.id;
+
out:
if (ret) {
for (int j = 0; j < i; j++) {
@@ -4368,7 +4399,7 @@ void intel_color_plane_init(struct drm_plane *plane)
if (DISPLAY_VER(i915) < 13)
return;
- drm_plane_create_get_color_pipeline_property(plane->dev, plane, 2);
+ drm_plane_create_get_color_pipeline_property(plane->dev, plane, 3);
intel_prepare_plane_color_pipeline(plane);
@@ -4387,6 +4418,8 @@ void intel_color_plane_init(struct drm_plane *plane)
color_pipeline_sdr,
sizeof(color_pipeline_sdr));
+ drm_plane_add_color_pipeline(plane, "color pipeline 3dlut", color_pipeline_3dlut,
+ sizeof(color_pipeline_3dlut));
drm_plane_attach_get_color_pipeline_property(plane);
drm_plane_create_set_color_pipeline_property(plane->dev, plane);
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 601b01e47a93..5cb84fa32dd5 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -284,6 +284,12 @@ struct drm_plane_state {
* For example: Parameterized/non-parameterized fixed function operations
*/
struct drm_property_blob *private_color_op_data;
+
+ /* @lut_3d:
+ *
+ * Three dimensional luts
+ */
+ struct drm_property_blob *lut_3d;
} color;
/**
--
2.38.1
More information about the wayland-devel
mailing list