* [PATCH RESEND v9 00/20] Display Global Histogram
@ 2025-12-02 6:26 Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 01/20] DO_NOT_REVIEW: plane/crtc color pipeline Arun R Murthy
` (19 more replies)
0 siblings, 20 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:26 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy,
Dmitry Baryshkov
Display histogram is a hardware functionality where a statistics for 'n'
number of frames is generated to form a histogram data. This is notified
to the user via histogram event. Compositor will then upon sensing the
histogram event will read the histogram data from KMD via crtc property.
User can use this histogram and apply various equilization techniques to
enhance the image or use this histogram for shaders.
Display ImageEnhancemenT is a hardware that interpolates the LUT value
to generate the enhanced output image. 1DLUT value is to be provided by
the user via crtc property.
One such library Global Histogram Enhancement(GHE) will take the histogram
as input and apply the algorithm to enhance the density and then
return the enhanced LUT factor. This library can be located @
https://github.com/intel/ghe
The corresponding mutter changes to enable/disable histogram, read the
histogram data, communicate with the library and write the enhanced data
back to the KMD is also pushed for review at https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3873
and https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3873/diffs?commit_id=270808ca7c8be48513553d95b4a47541f5d40206
The IGT changes for validating the histogram event and reading the
histogram is also pushed for review at https://patchwork.freedesktop.org/series/135789/
NOTE: i915 driver changes for histogram and IET LUT is not fully tested
and the series is pushed to get the inital feel of the histogram/IET LUT
usage as well as to get started with the review.
---
Changes in v10:
- EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v9: https://lore.kernel.org/r/20251201-dpst-v9-0-e462d55dba65@intel.com
---
Arun R Murthy (20):
DO_NOT_REVIEW: plane/crtc color pipeline
drm: Define histogram structures exposed to user
drm: Add new element histogram for colorop
drm/colorop: Export function to create pipeline element histogram
drm: Define ImageEnhancemenT LUT structures exposed to user
drm: Add new element Image EnhancemenT for colorop
drm/colorop: Export function to create pipeline element iet lut
drm/i915/histogram: Define registers for histogram
drm/i915/histogram: Add support for histogram
drm/xe: Add histogram support to Xe builds
drm/i915/histogram: histogram interrupt handling
[DO_NOT_RTEVIEW] Plane Color Pipeline support for Intel platforms
drm/i915/colorop: Add crtc color pipeline for i915
drm/i915/histogram: Hook i915 histogram with drm histogram
drm/i915/iet: Add support to writing the IET LUT data
drm/i915/colorop: create IET LUT properties
drm/i915/crtc: Hook i915 IET LUT with the drm IET properties
drm/i915/histogram: histogram delay counter doesn't reset
drm/i915/histogram: Histogram changes for Display 20+
drm/i915/histogram: Enable pipe dithering
drivers/gpu/drm/Makefile | 2 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 6 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 2 +-
drivers/gpu/drm/drm_atomic.c | 3 +
drivers/gpu/drm/drm_atomic_uapi.c | 103 +++++-
drivers/gpu/drm/drm_colorop.c | 181 ++++++++-
drivers/gpu/drm/drm_connector.c | 1 +
drivers/gpu/drm/drm_crtc.c | 77 ++++
drivers/gpu/drm/drm_crtc_internal.h | 6 +
drivers/gpu/drm/drm_ioctl.c | 12 +
drivers/gpu/drm/drm_mode_object.c | 16 +
drivers/gpu/drm/i915/Makefile | 3 +
.../gpu/drm/i915/display/intel_color_pipeline.c | 156 ++++++++
.../gpu/drm/i915/display/intel_color_pipeline.h | 15 +
drivers/gpu/drm/i915/display/intel_colorop.c | 35 ++
drivers/gpu/drm/i915/display/intel_colorop.h | 15 +
drivers/gpu/drm/i915/display/intel_crtc.c | 7 +
drivers/gpu/drm/i915/display/intel_display.c | 18 +
drivers/gpu/drm/i915/display/intel_display_irq.c | 6 +-
.../gpu/drm/i915/display/intel_display_limits.h | 15 +
drivers/gpu/drm/i915/display/intel_display_regs.h | 5 +-
drivers/gpu/drm/i915/display/intel_display_types.h | 7 +
drivers/gpu/drm/i915/display/intel_histogram.c | 406 +++++++++++++++++++++
drivers/gpu/drm/i915/display/intel_histogram.h | 53 +++
.../gpu/drm/i915/display/intel_histogram_regs.h | 73 ++++
drivers/gpu/drm/xe/Makefile | 3 +
include/drm/drm_atomic.h | 20 +
include/drm/drm_atomic_uapi.h | 2 +
include/drm/drm_colorop.h | 76 ++++
include/drm/drm_crtc.h | 27 ++
include/drm/drm_drv.h | 6 +
include/drm/drm_file.h | 21 +-
include/uapi/drm/drm.h | 44 +++
include/uapi/drm/drm_mode.h | 153 ++++++++
34 files changed, 1545 insertions(+), 30 deletions(-)
---
base-commit: db56e7764a202da6c1f9583e9b9cc0365a973d7a
change-id: 20241218-dpst-c8ecf18062bb
Best regards,
--
Arun R Murthy <arun.r.murthy@intel.com>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 01/20] DO_NOT_REVIEW: plane/crtc color pipeline
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
@ 2025-12-02 6:26 ` Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 02/20] drm: Define histogram structures exposed to user Arun R Murthy
` (18 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:26 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Squashed patch for plane and crtc pipeline implementation in drm.
https://patchwork.freedesktop.org/series/152970/
https://patchwork.freedesktop.org/patch/675255
Note: Entire series is not taken
AMD changes not take!
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/Makefile | 2 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 6 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 2 +-
drivers/gpu/drm/drm_atomic.c | 3 +
drivers/gpu/drm/drm_atomic_uapi.c | 64 ++++++++++++++++--
drivers/gpu/drm/drm_colorop.c | 35 ++++++++--
drivers/gpu/drm/drm_connector.c | 1 +
drivers/gpu/drm/drm_crtc.c | 77 ++++++++++++++++++++++
drivers/gpu/drm/drm_crtc_internal.h | 6 ++
drivers/gpu/drm/drm_ioctl.c | 12 ++++
drivers/gpu/drm/drm_mode_object.c | 16 +++++
include/drm/drm_atomic.h | 20 ++++++
include/drm/drm_atomic_uapi.h | 2 +
include/drm/drm_colorop.h | 4 ++
include/drm/drm_crtc.h | 27 ++++++++
include/drm/drm_drv.h | 6 ++
include/drm/drm_file.h | 21 ++++--
include/uapi/drm/drm.h | 44 +++++++++++++
18 files changed, 327 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4b3f3ad5058a32288561c1e576012f5f9a55c423..6987bb6745c2a3377ff38001532a7569745bc0d7 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -172,7 +172,7 @@ obj-y += display/
obj-$(CONFIG_DRM_TTM) += ttm/
obj-$(CONFIG_DRM_SCHED) += scheduler/
obj-$(CONFIG_DRM_RADEON)+= radeon/
-obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/
+#obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/
obj-$(CONFIG_DRM_AMDGPU)+= amd/amdxcp/
obj-$(CONFIG_DRM_I915) += i915/
obj-$(CONFIG_DRM_XE) += xe/
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
index 1dcc79b35225f5c9128cfd020ce9a37fe6f42d39..9a2834d626106b21b17f57bf4a3dac8edbf2ffbd 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
@@ -570,7 +570,7 @@ static void __drm_ctm_to_dc_matrix(const struct drm_color_ctm *ctm,
*
* The matrix needs to be a 3x4 (12 entry) matrix.
*/
-static void __drm_ctm_3x4_to_dc_matrix(const struct drm_color_ctm_3x4 *ctm,
+static void __drm_ctm_3x4_to_dc_matrix(const struct drm_amdgpu_color_ctm_3x4 *ctm,
struct fixed31_32 *matrix)
{
int i;
@@ -1971,7 +1971,7 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
{
struct amdgpu_device *adev = drm_to_adev(crtc->base.state->dev);
struct dm_plane_state *dm_plane_state = to_dm_plane_state(plane_state);
- struct drm_color_ctm_3x4 *ctm = NULL;
+ struct drm_amdgpu_color_ctm_3x4 *ctm = NULL;
struct dc_color_caps *color_caps = NULL;
bool has_crtc_cm_degamma;
int ret;
@@ -2026,7 +2026,7 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
/* Setup CRTC CTM. */
if (dm_plane_state->ctm) {
- ctm = (struct drm_color_ctm_3x4 *)dm_plane_state->ctm->data;
+ ctm = (struct drm_amdgpu_color_ctm_3x4 *)dm_plane_state->ctm->data;
/*
* DCN2 and older don't support both pre-blending and
* post-blending gamut remap. For this HW family, if we have
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
index 2e3ee78999d99d4b109620e41c1b6c52784fad0f..337ef1810b9c8d9c0b99c63ba0c3490d1cef7079 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
@@ -1695,7 +1695,7 @@ dm_atomic_plane_set_property(struct drm_plane *plane,
ret = drm_property_replace_blob_from_id(plane->dev,
&dm_plane_state->ctm,
val,
- sizeof(struct drm_color_ctm_3x4), -1,
+ sizeof(struct drm_amdgpu_color_ctm_3x4), -1,
&replaced);
dm_plane_state->base.color_mgmt_changed |= replaced;
return ret;
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 67e095e398a34de31e5ae95861512b5f4e6465f6..c15d66834419ee6f6311d91cb0698dacd35269db 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -389,6 +389,7 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
state->crtcs[index].new_state = crtc_state;
state->crtcs[index].ptr = crtc;
crtc_state->state = state;
+ crtc_state->color_pipeline_enabled = state->post_blend_color_pipeline;
drm_dbg_atomic(state->dev, "Added [CRTC:%d:%s] %p state to %p\n",
crtc->base.id, crtc->name, crtc_state, state);
@@ -475,6 +476,8 @@ static void drm_atomic_crtc_print_state(struct drm_printer *p,
drm_printf(p, "\tplane_mask=%x\n", state->plane_mask);
drm_printf(p, "\tconnector_mask=%x\n", state->connector_mask);
drm_printf(p, "\tencoder_mask=%x\n", state->encoder_mask);
+ drm_printf(p, "\tcolor-pipeline=%d\n",
+ state->color_pipeline ? state->color_pipeline->base.id : 0);
drm_printf(p, "\tmode: " DRM_MODE_FMT "\n", DRM_MODE_ARG(&state->mode));
if (crtc->funcs->atomic_print_state)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 7320db4b8489f10e24ed772094c77e2172951633..f2ba8e4c2bf2317880eed9d17f7ba3b113f2c057 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -394,8 +394,8 @@ static s32 __user *get_out_fence_for_connector(struct drm_atomic_state *state,
}
static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
- struct drm_crtc_state *state, struct drm_property *property,
- uint64_t val)
+ struct drm_crtc_state *state, struct drm_file *file_priv,
+ struct drm_property *property, uint64_t val)
{
struct drm_device *dev = crtc->dev;
struct drm_mode_config *config = &dev->mode_config;
@@ -404,7 +404,17 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
if (property == config->prop_active)
state->active = val;
- else if (property == config->prop_mode_id) {
+ else if (property == crtc->color_pipeline_property) {
+ /* find DRM colorop object */
+ struct drm_colorop *colorop = NULL;
+
+ colorop = drm_colorop_find(dev, file_priv, val);
+
+ if (val && !colorop)
+ return -EACCES;
+
+ drm_atomic_set_colorop_for_crtc(state, colorop);
+ } else if (property == config->prop_mode_id) {
struct drm_property_blob *mode =
drm_property_lookup_blob(dev, val);
ret = drm_atomic_set_mode_prop_for_crtc(state, mode);
@@ -413,6 +423,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
} else if (property == config->prop_vrr_enabled) {
state->vrr_enabled = val;
} else if (property == config->degamma_lut_property) {
+ if (file_priv->post_blend_color_pipeline) {
+ drm_dbg_atomic(dev,
+ "Setting DEGAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
+ return -EINVAL;
+ }
ret = drm_property_replace_blob_from_id(dev,
&state->degamma_lut,
val,
@@ -429,6 +444,11 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
state->color_mgmt_changed |= replaced;
return ret;
} else if (property == config->gamma_lut_property) {
+ if (file_priv->post_blend_color_pipeline) {
+ drm_dbg_atomic(dev,
+ "Setting GAMMA_LUT CRTC property not permitted with DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE client cap\n");
+ return -EINVAL;
+ }
ret = drm_property_replace_blob_from_id(dev,
&state->gamma_lut,
val,
@@ -487,6 +507,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
*val = 0;
else if (property == crtc->scaling_filter_property)
*val = state->scaling_filter;
+ else if (property == crtc->color_pipeline_property)
+ *val = (state->color_pipeline) ? state->color_pipeline->base.id : 0;
else if (property == crtc->sharpness_strength_property)
*val = state->sharpness_strength;
else if (crtc->funcs->atomic_get_property)
@@ -722,6 +744,34 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,
&replaced);
}
+/**
+ * drm_atomic_set_colorop_for_crtc - set colorop for crtc
+ * @crtc_state: atomic state object for the crtc
+ * @colorop: colorop to use for the crtc
+ *
+ * Helper function to select the color pipeline on a crtc by setting
+ * it to the first drm_colorop element of the pipeline.
+ */
+void
+drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
+ struct drm_colorop *colorop)
+{
+ struct drm_crtc *crtc = crtc_state->crtc;
+
+ if (colorop)
+ drm_dbg_atomic(crtc->dev,
+ "Set [COLOROP:%d] for [CRTC:%d:%s] state %p\n",
+ colorop->base.id, crtc->base.id, crtc->name,
+ crtc_state);
+ else
+ drm_dbg_atomic(crtc->dev,
+ "Set [NOCOLOROP] for [CRTC:%d:%s] state %p\n",
+ crtc->base.id, crtc->name, crtc_state);
+
+ crtc_state->color_pipeline = colorop;
+}
+EXPORT_SYMBOL(drm_atomic_set_colorop_for_crtc);
+
static int drm_atomic_colorop_set_property(struct drm_colorop *colorop,
struct drm_colorop_state *state,
struct drm_file *file_priv,
@@ -1050,8 +1100,11 @@ int drm_atomic_get_property(struct drm_mode_object *obj,
if (colorop->plane)
WARN_ON(!drm_modeset_is_locked(&colorop->plane->mutex));
+ else if (colorop->crtc)
+ WARN_ON(!drm_modeset_is_locked(&colorop->crtc->mutex));
- ret = drm_atomic_colorop_get_property(colorop, colorop->state, property, val);
+ ret = drm_atomic_colorop_get_property(colorop,
+ colorop->state, property, val);
break;
}
default:
@@ -1206,7 +1259,7 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
}
ret = drm_atomic_crtc_set_property(crtc,
- crtc_state, prop, prop_value);
+ crtc_state, file_priv, prop, prop_value);
break;
}
case DRM_MODE_OBJECT_PLANE: {
@@ -1606,6 +1659,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
state->acquire_ctx = &ctx;
state->allow_modeset = !!(arg->flags & DRM_MODE_ATOMIC_ALLOW_MODESET);
state->plane_color_pipeline = file_priv->plane_color_pipeline;
+ state->post_blend_color_pipeline = file_priv->post_blend_color_pipeline;
retry:
copied_objs = 0;
diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index 44eb823585d2e88b1e606c3b435ba30a88d4cfcb..96eaaa078281a48dad057e06900b112ebb032631 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -28,6 +28,7 @@
#include <drm/drm_print.h>
#include <drm/drm_drv.h>
#include <drm/drm_plane.h>
+#include <drm/drm_crtc.h>
#include "drm_crtc_internal.h"
@@ -92,9 +93,9 @@ static const struct drm_prop_enum_list drm_colorop_lut3d_interpolation_list[] =
/* Init Helpers */
-static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
- struct drm_plane *plane, enum drm_colorop_type type,
- uint32_t flags)
+static int drm_common_colorop_init(struct drm_device *dev,
+ struct drm_colorop *colorop,
+ enum drm_colorop_type type, uint32_t flags)
{
struct drm_mode_config *config = &dev->mode_config;
struct drm_property *prop;
@@ -107,7 +108,6 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co
colorop->base.properties = &colorop->properties;
colorop->dev = dev;
colorop->type = type;
- colorop->plane = plane;
colorop->next = NULL;
list_add_tail(&colorop->head, &config->colorop_list);
@@ -156,6 +156,33 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co
return ret;
}
+static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
+ struct drm_plane *plane, enum drm_colorop_type type,
+ uint32_t flags)
+{
+ int ret = 0;
+
+ ret = drm_common_colorop_init(dev, colorop, type, flags);
+
+ colorop->plane = plane;
+
+ return ret;
+}
+
+static int drm_crtc_colorop_init(struct drm_device *dev,
+ struct drm_colorop *colorop,
+ struct drm_crtc *crtc,
+ enum drm_colorop_type type, uint32_t flags)
+{
+ int ret;
+
+ ret = drm_common_colorop_init(dev, colorop, type, flags);
+
+ colorop->crtc = crtc;
+
+ return ret;
+}
+
/**
* drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline
*
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 4d6dc9ebfdb5bc730b1aff7a184448af7b93f078..f58cfd2131139ff3e613adc4dbb9ddbedf724dc7 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -3440,6 +3440,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
*/
ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
file_priv->plane_color_pipeline,
+ file_priv->post_blend_color_pipeline,
(uint32_t __user *)(unsigned long)(out_resp->props_ptr),
(uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
&out_resp->count_props);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index a7797d260f1e2fe5fae2127b340b39318e30a3e2..d1650dfbe6062c8ac9a5da3af1ac499113a6645a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -994,3 +994,80 @@ bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state)
return hweight32(crtc_state->encoder_mask) > 1;
}
EXPORT_SYMBOL(drm_crtc_in_clone_mode);
+
+struct drm_property *
+drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
+ const struct drm_prop_enum_list *pipelines,
+ int num_pipelines)
+{
+ struct drm_prop_enum_list *all_pipelines;
+ struct drm_property *prop;
+ int len = 0;
+ int i;
+
+ all_pipelines = kcalloc(num_pipelines + 1,
+ sizeof(*all_pipelines),
+ GFP_KERNEL);
+
+ if (!all_pipelines) {
+ drm_err(dev, "failed to allocate color pipeline\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
+ /* Create default Bypass color pipeline */
+ all_pipelines[len].type = 0;
+ all_pipelines[len].name = "Bypass";
+ len++;
+
+ /* Add all other color pipelines */
+ for (i = 0; i < num_pipelines; i++, len++) {
+ all_pipelines[len].type = pipelines[i].type;
+ all_pipelines[len].name = pipelines[i].name;
+ }
+
+ prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
+ "COLOR_PIPELINE",
+ all_pipelines, len);
+ if (IS_ERR(prop)) {
+ kfree(all_pipelines);
+ return prop;
+ }
+
+ drm_object_attach_property(obj, prop, 0);
+
+ kfree(all_pipelines);
+ return prop;
+}
+
+/**
+ * drm_crtc_create_color_pipeline_property - create a new color pipeline
+ * property
+ *
+ * @crtc: drm CRTC
+ * @pipelines: list of pipelines
+ * @num_pipelines: number of pipelines
+ *
+ * Create the COLOR_PIPELINE CRTC property to specify color pipelines on
+ * the CRTC.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_crtc_create_color_pipeline_property(struct drm_crtc *crtc,
+ const struct drm_prop_enum_list *pipelines,
+ int num_pipelines)
+{
+ struct drm_property *prop;
+
+ prop = drm_common_create_color_pipeline_property(crtc->dev,
+ &crtc->base,
+ pipelines,
+ num_pipelines);
+ if (IS_ERR(prop))
+ return PTR_ERR(prop);
+
+ crtc->color_pipeline_property = prop;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_create_color_pipeline_property);
diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
index c094092296448093c5cd192ecdc8ea9a50769c90..c53f154e5392a10c326c844b7321666275f9ac02 100644
--- a/drivers/gpu/drm/drm_crtc_internal.h
+++ b/drivers/gpu/drm/drm_crtc_internal.h
@@ -35,6 +35,7 @@
#ifndef __DRM_CRTC_INTERNAL_H__
#define __DRM_CRTC_INTERNAL_H__
+#include <drm/drm_property.h>
#include <linux/err.h>
#include <linux/types.h>
@@ -79,6 +80,10 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
int drm_crtc_register_all(struct drm_device *dev);
void drm_crtc_unregister_all(struct drm_device *dev);
int drm_crtc_force_disable(struct drm_crtc *crtc);
+struct drm_property *
+drm_common_create_color_pipeline_property(struct drm_device *dev, struct drm_mode_object *obj,
+ const struct drm_prop_enum_list *pipelines,
+ int num_pipelines);
struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc);
@@ -164,6 +169,7 @@ void drm_mode_object_unregister(struct drm_device *dev,
struct drm_mode_object *object);
int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
bool plane_color_pipeline,
+ bool post_blend_color_pipeline,
uint32_t __user *prop_ptr,
uint64_t __user *prop_values,
uint32_t *arg_count_props);
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index ff193155129e7e863888d8958458978566b144f8..ea9600f5392f520a2b42ba7ef363d2f08ce19812 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -304,6 +304,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
req->value = drm_core_check_feature(dev, DRIVER_ATOMIC) &&
dev->mode_config.async_page_flip;
break;
+ case DRM_CAP_POST_BLEND_COLOR_PIPELINE:
+ req->value = drm_core_check_feature(dev, DRIVER_POST_BLEND_COLOR_PIPELINE);
+ break;
default:
return -EINVAL;
}
@@ -380,6 +383,15 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
return -EINVAL;
file_priv->plane_color_pipeline = req->value;
break;
+ case DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE:
+ if (!file_priv->atomic)
+ return -EINVAL;
+ if (req->value > 1)
+ return -EINVAL;
+ if (!drm_core_check_feature(dev, DRIVER_POST_BLEND_COLOR_PIPELINE))
+ return -EINVAL;
+ file_priv->post_blend_color_pipeline = req->value;
+ break;
default:
return -EINVAL;
}
diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c
index b45d501b10c868c6d9b7a5a8760eadbd7b372a6a..40e979af34a34a8127bb2e48e74192049c9ca6cc 100644
--- a/drivers/gpu/drm/drm_mode_object.c
+++ b/drivers/gpu/drm/drm_mode_object.c
@@ -388,6 +388,7 @@ EXPORT_SYMBOL(drm_object_property_get_default_value);
/* helper for getconnector and getproperties ioctls */
int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
bool plane_color_pipeline,
+ bool post_blend_color_pipeline,
uint32_t __user *prop_ptr,
uint64_t __user *prop_values,
uint32_t *arg_count_props)
@@ -416,6 +417,20 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
continue;
}
+ if (!post_blend_color_pipeline && obj->type == DRM_MODE_OBJECT_CRTC) {
+ struct drm_crtc *crtc = obj_to_crtc(obj);
+
+ if (prop == crtc->color_pipeline_property)
+ continue;
+ }
+
+ if (!post_blend_color_pipeline && obj->type == DRM_MODE_OBJECT_CRTC) {
+ struct drm_crtc *crtc = obj_to_crtc(obj);
+
+ if (prop == crtc->color_pipeline_property)
+ continue;
+ }
+
if (*arg_count_props > count) {
ret = __drm_object_property_get_value(obj, prop, &val);
if (ret)
@@ -475,6 +490,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
ret = drm_mode_object_get_properties(obj, file_priv->atomic,
file_priv->plane_color_pipeline,
+ file_priv->post_blend_color_pipeline,
(uint32_t __user *)(unsigned long)(arg->props_ptr),
(uint64_t __user *)(unsigned long)(arg->prop_values_ptr),
&arg->count_props);
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 43783891d3594be1031e5ba5bde7b02545e08592..673c6eeaaefc8e87c44d85e27be449ec79a7ab36 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -473,6 +473,26 @@ struct drm_atomic_state {
*/
struct drm_device *dev;
+ /**
+ * @post_blend_color_pipeline:
+ *
+ * Indicates whether this atomic state originated with a client that
+ * set the DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE.
+ *
+ * Drivers and helper functions should use this to ignore legacy
+ * properties that are incompatible with the drm_crtc COLOR_PIPELINE
+ * behavior, such as:
+ *
+ * - GAMMA_LUT
+ * - DEGAMMA_LUT
+ * - GAMMA_LUT_SIZE
+ * - CTM
+ *
+ * or any other driver-specific properties that might affect pixel
+ * values.
+ */
+ bool post_blend_color_pipeline : 1;
+
/**
* @allow_modeset:
*
diff --git a/include/drm/drm_atomic_uapi.h b/include/drm/drm_atomic_uapi.h
index 4363155233267b93767c895fa6085544e2277442..4dc191f6f929d73deee9812025c48275a33cf770 100644
--- a/include/drm/drm_atomic_uapi.h
+++ b/include/drm/drm_atomic_uapi.h
@@ -52,6 +52,8 @@ void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
struct drm_framebuffer *fb);
void drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state,
struct drm_colorop *colorop);
+void drm_atomic_set_colorop_for_crtc(struct drm_crtc_state *crtc_state,
+ struct drm_colorop *colorop);
int __must_check
drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
struct drm_crtc *crtc);
diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index a3a32f9f918c73cc2ea9c6d6967d92eca4eff8b8..33cb6a2446dacf612d5f4dc35674e7518dfa9c58 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -31,6 +31,8 @@
#include <drm/drm_mode.h>
#include <drm/drm_property.h>
+struct drm_crtc;
+
/* DRM colorop flags */
#define DRM_COLOROP_FLAG_ALLOW_BYPASS (1<<0) /* Allow bypass on the drm_colorop */
@@ -228,6 +230,8 @@ struct drm_colorop {
*/
struct drm_plane *plane;
+ struct drm_crtc *crtc;
+
/**
* @state:
*
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 66278ffeebd68e69e9d0724ea5a33f93231e3f8b..e58a732b720174135a17d3b4d63c6355d6eddfe4 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -274,6 +274,22 @@ struct drm_crtc_state {
*/
struct drm_property_blob *gamma_lut;
+ /**
+ * @color_pipeline:
+ *
+ * The first colorop of the active color pipeline, or NULL, if no
+ * color pipeline is active.
+ */
+ struct drm_colorop *color_pipeline;
+
+ /**
+ * @color_pipeline_enabled:
+ *
+ * Whether color management should be done based on the &color_pipeline
+ * or the legacy color properties (&ctm, &gamma_lut and °amma_lut).
+ */
+ bool color_pipeline_enabled;
+
/**
* @target_vblank:
*
@@ -1093,6 +1109,14 @@ struct drm_crtc {
/** @properties: property tracking for this CRTC */
struct drm_object_properties properties;
+ /**
+ * @color_pipeline_property:
+ *
+ * Optional "COLOR_PIPELINE" enum property for specifying
+ * a color pipeline to use on the CRTC.
+ */
+ struct drm_property *color_pipeline_property;
+
/**
* @scaling_filter_property: property to apply a particular filter while
* scaling.
@@ -1340,6 +1364,9 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
int drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc,
unsigned int supported_filters);
+int drm_crtc_create_color_pipeline_property(struct drm_crtc *crtc,
+ const struct drm_prop_enum_list *pipelines,
+ int num_pipelines);
bool drm_crtc_in_clone_mode(struct drm_crtc_state *crtc_state);
int drm_crtc_create_sharpness_strength_property(struct drm_crtc *crtc);
#endif /* __DRM_CRTC_H__ */
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 42fc085f986dee9261f8b08c4fc7d93b8d6d9769..6b0f4904e69766232283d430c2540d30afef850f 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -122,6 +122,12 @@ enum drm_driver_feature {
* the cursor planes to work correctly).
*/
DRIVER_CURSOR_HOTSPOT = BIT(9),
+ /**
+ * @DRIVER_POST_BLEND_COLOR_PIPELINE:
+ *
+ * Driver supports post-blend color pipeline.
+ */
+ DRIVER_POST_BLEND_COLOR_PIPELINE = BIT(10),
/* IMPORTANT: Below are all the legacy flags, add new ones above. */
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 1a3018e4a537b3341acb50187d47371f6b781b9d..af848676427291e28c13a8d516e1a3ea00263737 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -206,13 +206,6 @@ struct drm_file {
*/
bool writeback_connectors;
- /**
- * @plane_color_pipeline:
- *
- * True if client understands plane color pipelines
- */
- bool plane_color_pipeline;
-
/**
* @was_master:
*
@@ -224,6 +217,20 @@ struct drm_file {
*/
bool was_master;
+ /**
+ * @plane_color_pipeline:
+ *
+ * True if client understands plane color pipelines
+ */
+ bool plane_color_pipeline;
+
+ /**
+ * @post_blend_color_pipeline:
+ *
+ * True if client understands post-blend color pipelines
+ */
+ bool post_blend_color_pipeline;
+
/**
* @is_master:
*
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 27cc159c1d275c7a7fe057840ef792f30a582bb7..732104ba83ffc5b089dcb1934359eaff11486934 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -812,6 +812,12 @@ struct drm_gem_change_handle {
* commits.
*/
#define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP 0x15
+/**
+ * DRM_CAP_POST_BLEND_COLOR_PIPELINE
+ *
+ * If set to 1, the driver supports post-blend color pipelines.
+ */
+#define DRM_CAP_POST_BLEND_COLOR_PIPELINE 0x16
/* DRM_IOCTL_GET_CAP ioctl argument type */
struct drm_get_cap {
@@ -921,6 +927,44 @@ struct drm_get_cap {
*/
#define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE 7
+/**
+ * DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
+ *
+ * If set to 1 the DRM core will allow setting the COLOR_PIPELINE
+ * property on a &drm_crtc, as well as drm_colorop properties.
+ *
+ * Setting of these crtc properties will be rejected when this client
+ * cap is set:
+ * - GAMMA_LUT
+ * - DEGAMMA_LUT
+ * - CTM
+ *
+ * The client must enable &DRM_CLIENT_CAP_ATOMIC first.
+ *
+ * This client cap can only be set if the driver sets the corresponding driver
+ * cap &DRM_CAP_POST_BLEND_COLOR_PIPELINE.
+ */
+#define DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE 8
+
+/**
+ * DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE
+ *
+ * If set to 1 the DRM core will allow setting the COLOR_PIPELINE
+ * property on a &drm_crtc, as well as drm_colorop properties.
+ *
+ * Setting of these crtc properties will be rejected when this client
+ * cap is set:
+ * - GAMMA_LUT
+ * - DEGAMMA_LUT
+ * - CTM
+ *
+ * The client must enable &DRM_CLIENT_CAP_ATOMIC first.
+ *
+ * This client cap can only be set if the driver sets the corresponding driver
+ * cap &DRM_CAP_POST_BLEND_COLOR_PIPELINE.
+ */
+#define DRM_CLIENT_CAP_POST_BLEND_COLOR_PIPELINE 8
+
/* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
struct drm_set_client_cap {
__u64 capability;
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 02/20] drm: Define histogram structures exposed to user
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 01/20] DO_NOT_REVIEW: plane/crtc color pipeline Arun R Murthy
@ 2025-12-02 6:26 ` Arun R Murthy
2025-12-10 9:35 ` Jani Nikula
2025-12-02 6:26 ` [PATCH [RESEND] v9 03/20] drm: Add new element histogram for colorop Arun R Murthy
` (17 subsequent siblings)
19 siblings, 1 reply; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:26 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Display Histogram is an array of bins and can be generated in many ways
referred to as modes.
Ex: HSV max(RGB), Wighted RGB etc.
Understanding the histogram data format(Ex: HSV max(RGB))
Histogram is just the pixel count.
For a maximum resolution of 10k (10240 x 4320 = 44236800)
25 bits should be sufficient to represent this along with a buffer of 7
bits(future use) u32 is being considered.
max(RGB) can be 255 i.e 0xFF 8 bit, considering the most significant 5
bits, hence 32 bins.
Below mentioned algorithm illustrates the histogram generation in
hardware.
hist[32] = {0};
for (i = 0; i < resolution; i++) {
bin = max(RGB[i]);
bin = bin >> 3; /* consider the most significant bits */
hist[bin]++;
}
If the entire image is Red color then max(255,0,0) is 255 so the pixel
count of each pixels will be placed in the last bin. Hence except
hist[31] all other bins will have a value zero.
Generated histogram in this case would be hist[32] = {0,0,....44236800}
Description of the structures, properties defined are documented in the
header file include/uapi/drm/drm_mode.h
v8: Added doc for HDR planes, removed reserved variables (Dmitry)
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
include/uapi/drm/drm_mode.h | 65 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index cbbbfc1dfe2b806c641c720b0215e825e350bd03..aa24fef15da708f3e6804d07ffae5b0312dfdce0 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -1545,6 +1545,71 @@ struct drm_mode_closefb {
__u32 pad;
};
+/**
+ * enum drm_mode_histogram
+ *
+ * @DRM_MODE_HISTOGRAM_HSV_MAX_RGB:
+ * Maximum resolution at present 10k, 10240x4320 = 44236800
+ * can be denoted in 25bits. With an additional 7 bits in buffer each bin
+ * can be a u32 value.
+ * For SDL, Maximum value of max(RGB) is 255, so max 255 bins.
+ * If the most significant 5 bits are considered, then bins = 2^5
+ * will be 32 bins.
+ * For HDR, maximum value of max(RGB) is 65535, so max 65535 bins.
+ * For illustration consider a full RED image of 10k resolution considering all
+ * 8 bits histogram would look like hist[255] = {0,0,....44236800} with SDR
+ * plane similarly with HDR the same would look like hist[65535] =
+ * {0,0,0,....44236800}
+ */
+enum drm_mode_histogram {
+ DRM_MODE_HISTOGRAM_HSV_MAX_RGB = 0x01,
+};
+
+/**
+ * struct drm_histogram_caps
+ *
+ * @histogram_mode: histogram generation modes, defined in the
+ * enum drm_mode_histogram
+ * @bins_count: number of bins for a chosen histogram mode. For illustration
+ * refer the above defined histogram mode.
+ */
+struct drm_histogram_caps {
+ __u32 histogram_mode;
+ __u32 bins_count;
+};
+
+/**
+ * struct drm_histogram_config
+ *
+ * @hist_mode_data: address to the histogram mode specific data if any
+ * @nr_hist_mode_data: number of elements pointed by the address in
+ * hist_mode_data
+ * @hist_mode: histogram mode(HSV max(RGB), RGB, LUMA etc)
+ * @enable: flag to enable/disable histogram
+ */
+struct drm_histogram_config {
+ __u64 hist_mode_data;
+ __u32 nr_hist_mode_data;
+ enum drm_mode_histogram hist_mode;
+ bool enable;
+};
+
+/**
+ * struct drm_histogram
+ *
+ * @config: histogram configuration data pointed by struct drm_histogram_config
+ * @data_ptr: pointer to the array of histogram.
+ * Histogram is an array of bins. Data format for each bin depends
+ * on the histogram mode. Refer to the above histogram modes for
+ * more information.
+ * @nr_elements: number of bins in the histogram.
+ */
+struct drm_histogram {
+ struct drm_histogram_config config;
+ __u64 data_ptr;
+ __u32 nr_elements;
+};
+
#if defined(__cplusplus)
}
#endif
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 03/20] drm: Add new element histogram for colorop
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 01/20] DO_NOT_REVIEW: plane/crtc color pipeline Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 02/20] drm: Define histogram structures exposed to user Arun R Murthy
@ 2025-12-02 6:26 ` Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 04/20] drm/colorop: Export function to create pipeline element histogram Arun R Murthy
` (16 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:26 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
For crtc color pipeline add an element histogram. This is used to
generate the histogram.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
include/uapi/drm/drm_mode.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index aa24fef15da708f3e6804d07ffae5b0312dfdce0..d92be66813cf667d8361d837110740a521dca6eb 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -964,6 +964,15 @@ enum drm_colorop_type {
* color = lut3d[index]
*/
DRM_COLOROP_3D_LUT,
+
+ /**
+ * @DRM_COLOROP_HISTOGRAM:
+ *
+ * enum string "Histogram"
+ *
+ * Hardware generates the histogram which is an array of bins.
+ */
+ DRM_COLOROP_HISTOGRAM,
};
/**
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 04/20] drm/colorop: Export function to create pipeline element histogram
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (2 preceding siblings ...)
2025-12-02 6:26 ` [PATCH [RESEND] v9 03/20] drm: Add new element histogram for colorop Arun R Murthy
@ 2025-12-02 6:26 ` Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 05/20] drm: Define ImageEnhancemenT LUT structures exposed to user Arun R Murthy
` (15 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:26 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Create properties associated for histogram and then export function to
initialize the color pipeline element histogram. The properties include
histogram capabilities, enable and data.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/drm_atomic_uapi.c | 18 +++++++++
drivers/gpu/drm/drm_colorop.c | 84 +++++++++++++++++++++++++++++++++++++++
include/drm/drm_colorop.h | 55 +++++++++++++++++++++++++
3 files changed, 157 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index f2ba8e4c2bf2317880eed9d17f7ba3b113f2c057..3505c00dfc5168de3476fb94bced123f9c886cb2 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -778,6 +778,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop,
struct drm_property *property,
uint64_t val)
{
+ u32 ret = 0;
+ bool replaced = false;
+
if (property == colorop->bypass_property) {
state->bypass = val;
} else if (property == colorop->lut1d_interpolation_property) {
@@ -788,6 +791,15 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop,
state->multiplier = val;
} else if (property == colorop->lut3d_interpolation_property) {
colorop->lut3d_interpolation = val;
+ } else if (property == colorop->histogram_enable_property) {
+ ret = drm_property_replace_blob_from_id(colorop->dev,
+ &state->histogram_enable,
+ val,
+ -1,
+ sizeof(struct drm_histogram_config),
+ &replaced);
+ state->histogram_updated |= replaced;
+ return ret;
} else if (property == colorop->data_property) {
return drm_atomic_color_set_data_property(colorop, state,
property, val);
@@ -823,6 +835,12 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,
*val = colorop->lut3d_interpolation;
else if (property == colorop->data_property)
*val = (state->data) ? state->data->base.id : 0;
+ else if (property == colorop->histogram_caps_property)
+ *val = (state->histogram_caps) ? state->histogram_caps->base.id : 0;
+ else if (property == colorop->histogram_enable_property)
+ *val = (state->histogram_enable) ? state->histogram_enable->base.id : 0;
+ else if (property == colorop->histogram_data_property)
+ *val = (state->histogram_data) ? state->histogram_data->base.id : 0;
else
return -EINVAL;
diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index 96eaaa078281a48dad057e06900b112ebb032631..e3e22db3b911e79979488b1493e72cd9a11ed418 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -461,6 +461,90 @@ int drm_plane_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *col
}
EXPORT_SYMBOL(drm_plane_colorop_3dlut_init);
+/**
+ * drm_crtc_colorop_histogram_init: create histogram properties
+ *
+ * @colorop: pointer to the color pipeline
+ * @crtc: pointer to the struct drm_crtc.
+ * @caps: pointer to the struct drm_histogram_caps, holds the
+ * histogram hardware capabilities.
+ * @flags: colorop pipeline flags defined in drm_colorop.h
+ *
+ * The property HISTOGRAM_CAPS exposes the hardware capability for
+ * histogram which includes the histogram mode, number of bins etc
+ * The property HISTOGRAM_ENABLE allows user to enable/disable the
+ * histogram feature and also configure the hardware.
+ * Upon KMD enabling by writing to the hardware registers, histogram
+ * is generated. Histogram is composed of 'n' bins with each bin
+ * being an integer(pixel count).
+ * An event HISTOGRAM will be sent to the user. User upon receiving this
+ * event can read the hardware generated histogram using crtc property
+ * DATA.
+ * User can use this histogram data to enhance the image or in shaders.
+ *
+ * Property HISTOGRAM_CAPS is a blob pointing to the struct drm_histogram_caps
+ * Description of the structure is in include/uapi/drm/drm_mode.h
+ * Property HISTOGRAM_ENABLE is a blob pointing to the struct
+ * drm_histogram_config
+ * Description of the structure is in include/uapi/drm/drm_mode.h
+ * Property DATA is a blob pointing to the struct drm_histogram
+ * Description of the structure is in include/uapi/drm/drm_mode.h
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_crtc_colorop_histogram_init(struct drm_colorop *colorop,
+ struct drm_crtc *crtc,
+ struct drm_histogram_caps *caps,
+ uint32_t flags)
+{
+ struct drm_property *prop;
+ struct drm_property_blob *blob;
+ struct drm_histogram_caps *blob_data;
+ int ret;
+
+ ret = drm_crtc_colorop_init(crtc->dev, colorop, crtc,
+ DRM_COLOROP_HISTOGRAM, flags);
+ if (ret)
+ return ret;
+
+ blob = drm_property_create_blob(crtc->dev,
+ sizeof(struct drm_histogram_caps),
+ NULL);
+ if (IS_ERR(blob))
+ return -1;
+ blob_data = blob->data;
+ blob_data->histogram_mode = caps->histogram_mode;
+ blob_data->bins_count = caps->bins_count;
+
+ /* histogram capabilities */
+ prop = drm_property_create(crtc->dev, DRM_MODE_PROP_ATOMIC |
+ DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+ "HISTOGRAM_CAPS", blob->base.id);
+ if (!prop)
+ return -ENOMEM;
+ colorop->histogram_caps_property = prop;
+ drm_object_attach_property(&colorop->base, colorop->histogram_caps_property,
+ 0);
+
+ /* histogram enable */
+ prop = drm_property_create(crtc->dev, DRM_MODE_PROP_ATOMIC |
+ DRM_MODE_PROP_BLOB, "HISTOGRAM_ENABLE", 0);
+ if (!prop)
+ return -ENOMEM;
+ colorop->histogram_enable_property = prop;
+ drm_object_attach_property(&colorop->base, colorop->histogram_enable_property,
+ 0);
+
+ /* histogram data/bins */
+ ret = drm_colorop_create_data_prop(crtc->dev, colorop);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_colorop_histogram_init);
+
static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop,
struct drm_colorop_state *state)
{
diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index 33cb6a2446dacf612d5f4dc35674e7518dfa9c58..4d905c13274c13d8d50e1c9e45a87feec72f82ae 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -185,6 +185,37 @@ struct drm_colorop_state {
*/
struct drm_property_blob *data;
+ /**
+ * @histogram_caps:
+ *
+ * The blob points to the structure drm_histogram_caps.
+ * For more info on the elements of the struct drm_histogram_caps
+ * see include/uapi/drm/drm_mode.h
+ */
+ struct drm_property_blob *histogram_caps;
+ /**
+ * @histogram_enable:
+ *
+ * The blob points to the structure drm_histogram_config.
+ * For more information on the elements of struct drm_histogram_config
+ * see include/uapi/drm/drm_mode.h
+ */
+ struct drm_property_blob *histogram_enable;
+ /**
+ * @histogram_data:
+ *
+ * The blob points to the structure drm_histogram.
+ * For more information on the elements of struct drm_histogram
+ * see include/uapi/drm/drm_mode.h
+ */
+ struct drm_property_blob *histogram_data;
+ /**
+ * @histogram_updated:
+ *
+ * Flag to say that the histogram data is updated by the KMD.
+ */
+ bool histogram_updated;
+
/** @state: backpointer to global drm_atomic_state */
struct drm_atomic_state *state;
};
@@ -348,6 +379,26 @@ struct drm_colorop {
*/
struct drm_property *lut3d_interpolation_property;
+ /**
+ * @histogram_caps_property: Optional CRTC property for getting the
+ * histogram hardware capability.
+ */
+ struct drm_property *histogram_caps_property;
+
+ /**
+ * @histogram_enable_property:
+ *
+ * property to enable hardware histogram
+ */
+ struct drm_property *histogram_enable_property;
+
+ /**
+ * @histogram_data_property
+ *
+ * Read only property for histogram data
+ */
+ struct drm_property *histogram_data_property;
+
/**
* @data_property:
*
@@ -408,6 +459,10 @@ int drm_plane_colorop_3dlut_init(struct drm_device *dev, struct drm_colorop *col
uint32_t lut_size,
enum drm_colorop_lut3d_interpolation_type interpolation,
uint32_t flags);
+int drm_crtc_colorop_histogram_init(struct drm_colorop *colorop,
+ struct drm_crtc *crtc,
+ struct drm_histogram_caps *caps,
+ uint32_t flags);
struct drm_colorop_state *
drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 05/20] drm: Define ImageEnhancemenT LUT structures exposed to user
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (3 preceding siblings ...)
2025-12-02 6:26 ` [PATCH [RESEND] v9 04/20] drm/colorop: Export function to create pipeline element histogram Arun R Murthy
@ 2025-12-02 6:26 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 06/20] drm: Add new element Image EnhancemenT for colorop Arun R Murthy
` (14 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:26 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
ImageEnhancemenT(IET) hardware interpolates the LUT value to generate
the enhanced output image. LUT takes an input value, outputs a new
value based on the data within the LUT. 1D LUT can remap individual
input values to new output values based on the LUT sample. LUT can be
interpolated by the hardware by multiple modes Ex: Direct Lookup LUT,
Multiplicative LUT etc
The list of supported mode by hardware along with the format(exponent
mantissa) is exposed to user by the iet_lut_caps property. Maximum
format being 8.24 i.e 8 exponent and 24 mantissa.
For illustration a hardware supporting 1.9 format denotes this as
0x10001FF. In order to know the exponent do a bitwise AND with
0xF000000. The LUT value to be provided by user would be a 10bit value
with 1 bit integer and 9 bit fractional value.
Multiple formats can be supported, hence pointer is used over here.
User can then provide the LUT with any one of the supported modes in
any of the supported formats.
The entries in the LUT can vary depending on the hardware capability
with max being 255. This will also be exposed as iet_lut_caps so user
can generate a LUT with the specified entries.
v8: define enum for iet_mode, add more doc for iet modes (Dmitry)
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
include/uapi/drm/drm_mode.h | 68 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index d92be66813cf667d8361d837110740a521dca6eb..35d19ccd799b2b0f72174de8987c4482209ff325 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -1619,6 +1619,74 @@ struct drm_histogram {
__u32 nr_elements;
};
+/**
+ * enum drm_iet_mode
+ * @DRM_MODE_IET_LOOKUP_LUT:
+ * LUT values are points on exponential graph with x axis and y-axis y=f(x)
+ * This f(x) can be the algorithm, defined by the user space algorithm.
+ * When this LUT table is passed to the hardware it signifies how the hardware
+ * should use this table to get the LUT values. In this mode its direct lookup
+ * table. x-axis corresponds to input pixel value and y-axis corresponds to
+ * the output pixel value.
+ *
+ * @DRM_MODE_IET_MULTIPLICATIVE:
+ * LUT values, x and y are points on negative exponential graph with
+ * x-axis and y-axis (y = y/x). The value passed by the user will be
+ * in y/x i.e OutPixel/InPixel. X co-ordinate proportional to pixel value
+ * and Y-cordinate is the multiplier factor, i.e x-axis in pixels and
+ * y-axis is OutPixel/InPixel. so upon multiplying x, y is obtained,
+ * hence multiplicative.
+ * The format of LUT can at max be 8.24(8integer 24 fractional)
+ * represented by u32. 32bit is the container and if 16.16 is chosen
+ * then it doesn't make sense to boost the pixel by 2^16. Hence set aside
+ * 8bit for integer 2^8 thereby boosting the pixel by a value 255 which
+ * itself is a huge boost factor. Remaining 24bits out of the 32bit
+ * container is fractional part. This is also optimal for implementing
+ * in the hardware.
+ * Depending on the hardware capability and exponent mantissa can be
+ * chosen within this limits.
+ */
+enum drm_iet_mode {
+ DRM_MODE_IET_LOOKUP_LUT = 0x01,
+ DRM_MODE_IET_MULTIPLICATIVE = 0x02,
+};
+
+/**
+ * struct drm_iet_caps
+ *
+ * @iet_mode: pixel factor enhancement modes defined in enum drm_iet_mode.
+ * Multiple modes can be supported by hardware, the value can be
+ * ORed.
+ * @iet_sample_format: holds the address of an array of u32 LUT sample formats
+ * depending on the hardware capability. Max being 8.24
+ * Doing a bitwise AND will get the present sample.
+ * Ex: for 1 integer 9 fraction AND with 0x10001FF
+ * @nr_iet_sample_formats: number of iet_sample_formsts supported by the
+ * hardware
+ * @nr_iet_lut_entries: number of LUT entries
+ */
+struct drm_iet_caps {
+ __u32 iet_mode;
+ __u64 iet_sample_format;
+ __u32 nr_iet_sample_formats;
+ __u32 nr_iet_lut_entries;
+};
+
+/**
+ * struct drm_iet_1dlut_sample
+ * @iet_lut: the address in the field describes the format of the data
+ * corresponding to the @iet_mode
+ * In case of direct lookup this is NULL, in case of
+ * multiplicative mode LUT exponent and mantissa format.
+ * @nr_elements: number of entries pointed by the data @iet_lut
+ * @iet_mode: image enhancement mode, this will also convey the channel.
+ */
+struct drm_iet_1dlut_sample {
+ __u64 iet_lut;
+ __u32 nr_elements;
+ enum drm_iet_mode iet_mode;
+};
+
#if defined(__cplusplus)
}
#endif
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 06/20] drm: Add new element Image EnhancemenT for colorop
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (4 preceding siblings ...)
2025-12-02 6:26 ` [PATCH [RESEND] v9 05/20] drm: Define ImageEnhancemenT LUT structures exposed to user Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 07/20] drm/colorop: Export function to create pipeline element iet lut Arun R Murthy
` (13 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
For crtc color pipeline add an element Image EnhancemenT LUT. The
histogram generated from the hardware, on feeding to a user space
algorithm can generate an image enhanced LUT that can be fed back to the
hardware to get the enahnced image.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
include/uapi/drm/drm_mode.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 35d19ccd799b2b0f72174de8987c4482209ff325..acd281b295d71517c930adf036eaa006f8ff7182 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -973,6 +973,17 @@ enum drm_colorop_type {
* Hardware generates the histogram which is an array of bins.
*/
DRM_COLOROP_HISTOGRAM,
+
+ /**
+ * @DRM_COLOROP_IET:
+ *
+ * enum string "Image EnhancemenT"
+ *
+ * Image EnhancemenT LUT generated from the histogram is fed back to the
+ * hardware.
+ */
+ DRM_COLOROP_IET,
+
};
/**
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 07/20] drm/colorop: Export function to create pipeline element iet lut
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (5 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 06/20] drm: Add new element Image EnhancemenT for colorop Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 08/20] drm/i915/histogram: Define registers for histogram Arun R Murthy
` (12 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
The generated histogram can be used the user algorithm to generate a
LUT, which is referred as image enhanced LUT. This is fed back to the
hardware to get an enhanced image.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/drm_atomic_uapi.c | 21 +++++++++----
drivers/gpu/drm/drm_colorop.c | 62 +++++++++++++++++++++++++++++++++++++++
include/drm/drm_colorop.h | 17 +++++++++++
3 files changed, 94 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 3505c00dfc5168de3476fb94bced123f9c886cb2..579210be8288d6788a6cfc357394c3794b13a417 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -719,6 +719,7 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,
ssize_t elem_size = -1;
ssize_t size = -1;
bool replaced = false;
+ u32 ret;
switch (colorop->type) {
case DRM_COLOROP_1D_LUT:
@@ -731,17 +732,25 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,
size = colorop->size * colorop->size * colorop->size *
sizeof(struct drm_color_lut32);
break;
+ case DRM_COLOROP_IET:
+ elem_size = state->data->length;
+ break;
default:
/* should never get here */
return -EINVAL;
}
- return drm_property_replace_blob_from_id(colorop->dev,
- &state->data,
- val,
- size,
- elem_size,
- &replaced);
+ ret = drm_property_replace_blob_from_id(colorop->dev,
+ &state->data,
+ val,
+ size,
+ elem_size,
+ &replaced);
+
+ if (colorop->type == DRM_COLOROP_IET && !ret)
+ state->iet_lut_updated |= replaced;
+
+ return ret;
}
/**
diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c
index e3e22db3b911e79979488b1493e72cd9a11ed418..797a6f5ef79c7cc04109e87c44566f2461aee965 100644
--- a/drivers/gpu/drm/drm_colorop.c
+++ b/drivers/gpu/drm/drm_colorop.c
@@ -545,6 +545,68 @@ int drm_crtc_colorop_histogram_init(struct drm_colorop *colorop,
}
EXPORT_SYMBOL(drm_crtc_colorop_histogram_init);
+/**
+ * drm_crtc_colorop_iet_lut_init
+ *
+ * @crtc: pointer to the struct drm_crtc.
+ * @caps: pointer to the struct drm_iet_caps, holds the
+ * image enhancement LUT hardware capabilities.
+ *
+ * This 1DLUT is used by the hardware to enahance the image. Hardware
+ * interpolates this LUT value to generate the enhanced output image.
+ *
+ * The blob property IET_LUT_CAPS points to the struct drm_iet_lut_caps
+ * The blob property DATA points to the struct drm_iet_1dlut_sample
+ * Description of the structure is in include/uapi/drm/drm_mode.h
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_crtc_colorop_iet_lut_init(struct drm_colorop *colorop,
+ struct drm_crtc *crtc,
+ struct drm_iet_caps *caps,
+ uint32_t flags)
+{
+ struct drm_property *prop;
+ struct drm_iet_caps *blob_data;
+ struct drm_property_blob *blob;
+ int ret = 0;
+
+ ret = drm_crtc_colorop_init(crtc->dev, colorop, crtc,
+ DRM_COLOROP_IET, flags);
+ if (ret)
+ return ret;
+
+ blob = drm_property_create_blob(crtc->dev,
+ sizeof(struct drm_iet_caps),
+ NULL);
+ if (IS_ERR(blob))
+ return -1;
+ blob_data = blob->data;
+ blob_data->iet_mode = caps->iet_mode;
+ blob_data->nr_iet_sample_formats = caps->nr_iet_sample_formats;
+ blob_data->nr_iet_lut_entries = caps->nr_iet_lut_entries;
+ blob_data->iet_sample_format = caps->iet_sample_format;
+
+ /* IET LUT Capabilities */
+ prop = drm_property_create(crtc->dev, DRM_MODE_PROP_ATOMIC |
+ DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+ "IET_LUT_CAPS", blob->base.id);
+ if (!prop)
+ return -ENOMEM;
+ colorop->iet_lut_caps_property = prop;
+ drm_object_attach_property(&colorop->base, colorop->iet_lut_caps_property,
+ 0);
+
+ /* IET LUT data */
+ ret = drm_colorop_create_data_prop(crtc->dev, colorop);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_crtc_colorop_iet_lut_init);
+
static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop,
struct drm_colorop_state *state)
{
diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h
index 4d905c13274c13d8d50e1c9e45a87feec72f82ae..fa37277232dbec3c7c58781d27cfaf62163b6922 100644
--- a/include/drm/drm_colorop.h
+++ b/include/drm/drm_colorop.h
@@ -215,6 +215,12 @@ struct drm_colorop_state {
* Flag to say that the histogram data is updated by the KMD.
*/
bool histogram_updated;
+ /**
+ * @iet_lut_updated:
+ *
+ * Boolean flag to say that there are some updates on iet_lut property
+ */
+ bool iet_lut_updated;
/** @state: backpointer to global drm_atomic_state */
struct drm_atomic_state *state;
@@ -399,6 +405,13 @@ struct drm_colorop {
*/
struct drm_property *histogram_data_property;
+ /**
+ * @iet_lut_caps_proeprty
+ * Optional colorpipeline property for writing the
+ * image enhanced LUT
+ */
+ struct drm_property *iet_lut_caps_property;
+
/**
* @data_property:
*
@@ -463,6 +476,10 @@ int drm_crtc_colorop_histogram_init(struct drm_colorop *colorop,
struct drm_crtc *crtc,
struct drm_histogram_caps *caps,
uint32_t flags);
+int drm_crtc_colorop_iet_lut_init(struct drm_colorop *colorop,
+ struct drm_crtc *crtc,
+ struct drm_iet_caps *caps,
+ uint32_t flags);
struct drm_colorop_state *
drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 08/20] drm/i915/histogram: Define registers for histogram
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (6 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 07/20] drm/colorop: Export function to create pipeline element iet lut Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 09/20] drm/i915/histogram: Add support " Arun R Murthy
` (11 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Add the register/bit definitions for global histogram.
v2: Intended the register contents, removed unused regs (Jani)
Bspec: 4270
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
.../gpu/drm/i915/display/intel_histogram_regs.h | 46 ++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_histogram_regs.h b/drivers/gpu/drm/i915/display/intel_histogram_regs.h
new file mode 100644
index 0000000000000000000000000000000000000000..71daf5ac2dd9ac987b256a35161b3b6977992e95
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_histogram_regs.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: MIT */
+/* Copyright © 2025 Intel Corporation */
+
+#ifndef __INTEL_HISTOGRAM_REGS_H__
+#define __INTEL_HISTOGRAM_REGS_H__
+
+#include "intel_display_reg_defs.h"
+
+/* GLOBAL_HIST related registers */
+#define _DPST_CTL_A 0x490C0
+#define _DPST_CTL_B 0x491C0
+#define DPST_CTL(pipe) _MMIO_PIPE(pipe, _DPST_CTL_A, _DPST_CTL_B)
+#define DPST_CTL_IE_HIST_EN REG_BIT(31)
+#define DPST_CTL_RESTORE REG_BIT(28)
+#define DPST_CTL_IE_MODI_TABLE_EN REG_BIT(27)
+#define DPST_CTL_HIST_MODE REG_BIT(24)
+#define DPST_CTL_ENHANCEMENT_MODE_MASK REG_GENMASK(14, 13)
+#define DPST_CTL_EN_MULTIPLICATIVE REG_FIELD_PREP(DPST_CTL_ENHANCEMENT_MODE_MASK, 2)
+#define DPST_CTL_IE_TABLE_VALUE_FORMAT REG_BIT(15)
+#define DPST_CTL_BIN_REG_FUNC_SEL REG_BIT(11)
+#define DPST_CTL_BIN_REG_FUNC_TC REG_FIELD_PREP(DPST_CTL_BIN_REG_FUNC_SEL, 0)
+#define DPST_CTL_BIN_REG_FUNC_IE REG_FIELD_PREP(DPST_CTL_BIN_REG_FUNC_SEL, 1)
+#define DPST_CTL_BIN_REG_MASK REG_GENMASK(6, 0)
+#define DPST_CTL_BIN_REG_CLEAR REG_FIELD_PREP(DPST_CTL_BIN_REG_MASK, 0)
+#define DPST_CTL_IE_TABLE_VALUE_FORMAT_2INT_8FRAC REG_FIELD_PREP(DPST_CTL_IE_TABLE_VALUE_FORMAT, 1)
+#define DPST_CTL_IE_TABLE_VALUE_FORMAT_1INT_9FRAC REG_FIELD_PREP(DPST_CTL_IE_TABLE_VALUE_FORMAT, 0)
+#define DPST_CTL_HIST_MODE_YUV REG_FIELD_PREP(DPST_CTL_HIST_MODE, 0)
+#define DPST_CTL_HIST_MODE_HSV REG_FIELD_PREP(DPST_CTL_HIST_MODE, 1)
+
+#define _DPST_GUARD_A 0x490C8
+#define _DPST_GUARD_B 0x491C8
+#define DPST_GUARD(pipe) _MMIO_PIPE(pipe, _DPST_GUARD_A, _DPST_GUARD_B)
+#define DPST_GUARD_HIST_INT_EN REG_BIT(31)
+#define DPST_GUARD_HIST_EVENT_STATUS REG_BIT(30)
+#define DPST_GUARD_INTERRUPT_DELAY_MASK REG_GENMASK(29, 22)
+#define DPST_GUARD_INTERRUPT_DELAY(val) REG_FIELD_PREP(DPST_GUARD_INTERRUPT_DELAY_MASK, val)
+#define DPST_GUARD_THRESHOLD_GB_MASK REG_GENMASK(21, 0)
+#define DPST_GUARD_THRESHOLD_GB(val) REG_FIELD_PREP(DPST_GUARD_THRESHOLD_GB_MASK, val)
+
+#define _DPST_BIN_A 0x490C4
+#define _DPST_BIN_B 0x491C4
+#define DPST_BIN(pipe) _MMIO_PIPE(pipe, _DPST_BIN_A, _DPST_BIN_B)
+#define DPST_BIN_DATA_MASK REG_GENMASK(23, 0)
+#define DPST_BIN_BUSY REG_BIT(31)
+
+#endif /* __INTEL_HISTOGRAM_REGS_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 09/20] drm/i915/histogram: Add support for histogram
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (7 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 08/20] drm/i915/histogram: Define registers for histogram Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 10/20] drm/xe: Add histogram support to Xe builds Arun R Murthy
` (10 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Statistics is generated from the image frame that is coming to display
and an event is sent to user after reading this histogram data.
v2: forward declaration in header file along with error handling (Jani)
v3: Replaced i915 with intel_display (Suraj)
v4: Removed dithering enable/disable (Vandita)
New patch for histogram register definitions (Suraj)
v5: IET LUT pgm follow the seq in spec and removed change to TC at end
(Suraj)
v8: Retained only the Histogram part and move IET LUT to a different
patch.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/Makefile | 1 +
drivers/gpu/drm/i915/display/intel_display_types.h | 2 +
drivers/gpu/drm/i915/display/intel_histogram.c | 159 +++++++++++++++++++++
drivers/gpu/drm/i915/display/intel_histogram.h | 46 ++++++
4 files changed, 208 insertions(+)
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 2ff8938b3a7cad7829ef31aa69e2d5d189498ae1..004e8fc092a3b9ba7dd907a228b835ceaf8f2ba5 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -279,6 +279,7 @@ i915-y += \
display/intel_hdcp.o \
display/intel_hdcp_gsc.o \
display/intel_hdcp_gsc_message.o \
+ display/intel_histogram.o \
display/intel_hotplug.o \
display/intel_hotplug_irq.o \
display/intel_hti.o \
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 38702a9e0f5084ef0b19e4a577ce07bfc7ce9926..b8a1be24cd0408dfa5377c9afe5309a9f1e743dd 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1518,6 +1518,8 @@ struct intel_crtc {
/* for loading single buffered registers during vblank */
struct pm_qos_request vblank_pm_qos;
+ struct intel_histogram *histogram;
+
#ifdef CONFIG_DEBUG_FS
struct intel_pipe_crc pipe_crc;
#endif
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.c b/drivers/gpu/drm/i915/display/intel_histogram.c
new file mode 100644
index 0000000000000000000000000000000000000000..0d14cd88d1869583a3ade8ded9284425ab217d3e
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_histogram.c
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ *
+ */
+
+#include <drm/drm_device.h>
+#include <drm/drm_file.h>
+#include <drm/drm_vblank.h>
+#include <drm/drm_print.h>
+
+#include "i915_reg.h"
+#include "i915_drv.h"
+#include "intel_de.h"
+#include "intel_display.h"
+#include "intel_display_types.h"
+#include "intel_histogram.h"
+#include "intel_histogram_regs.h"
+
+/* 3.0% of the pipe's current pixel count, hw does x4 */
+#define HISTOGRAM_GUARDBAND_THRESHOLD_DEFAULT 300
+/* Precision factor for threshold guardband */
+#define HISTOGRAM_GUARDBAND_PRECISION_FACTOR 10000
+#define HISTOGRAM_DEFAULT_GUARDBAND_DELAY 0x04
+
+int intel_histogram_atomic_check(struct intel_crtc *intel_crtc)
+{
+ struct intel_histogram *histogram = intel_crtc->histogram;
+
+ /* TODO: Restrictions for enabling histogram */
+ histogram->can_enable = true;
+
+ return 0;
+}
+
+static int intel_histogram_enable(struct intel_crtc *intel_crtc, u8 mode)
+{
+ struct intel_display *display = to_intel_display(intel_crtc);
+ struct intel_histogram *histogram = intel_crtc->histogram;
+ int pipe = intel_crtc->pipe;
+ u64 res;
+ u32 gbandthreshold;
+
+ if (!histogram || !histogram->can_enable)
+ return -EINVAL;
+
+ if (histogram->enable)
+ return 0;
+
+ /* enable histogram, clear DPST_CTL bin reg func select to TC */
+ intel_de_rmw(display, DPST_CTL(pipe),
+ DPST_CTL_BIN_REG_FUNC_SEL | DPST_CTL_IE_HIST_EN |
+ DPST_CTL_HIST_MODE | DPST_CTL_IE_TABLE_VALUE_FORMAT |
+ DPST_CTL_ENHANCEMENT_MODE_MASK | DPST_CTL_IE_MODI_TABLE_EN,
+ ((mode == DRM_MODE_HISTOGRAM_HSV_MAX_RGB) ?
+ DPST_CTL_BIN_REG_FUNC_TC : 0) | DPST_CTL_IE_HIST_EN |
+ DPST_CTL_HIST_MODE_HSV |
+ DPST_CTL_IE_TABLE_VALUE_FORMAT_1INT_9FRAC |
+ DPST_CTL_EN_MULTIPLICATIVE | DPST_CTL_IE_MODI_TABLE_EN);
+
+ /* Re-Visit: check if wait for one vblank is required */
+ drm_crtc_wait_one_vblank(&intel_crtc->base);
+
+ /* TODO: Program GuardBand Threshold needs to be moved to modeset path */
+ res = (intel_crtc->config->hw.adjusted_mode.vtotal *
+ intel_crtc->config->hw.adjusted_mode.htotal);
+
+ gbandthreshold = (res * HISTOGRAM_GUARDBAND_THRESHOLD_DEFAULT) /
+ HISTOGRAM_GUARDBAND_PRECISION_FACTOR;
+
+ /* Enable histogram interrupt mode */
+ intel_de_rmw(display, DPST_GUARD(pipe),
+ DPST_GUARD_THRESHOLD_GB_MASK |
+ DPST_GUARD_INTERRUPT_DELAY_MASK | DPST_GUARD_HIST_INT_EN,
+ DPST_GUARD_THRESHOLD_GB(gbandthreshold) |
+ DPST_GUARD_INTERRUPT_DELAY(HISTOGRAM_DEFAULT_GUARDBAND_DELAY) |
+ DPST_GUARD_HIST_INT_EN);
+
+ /* Clear pending interrupts has to be done on separate write */
+ intel_de_rmw(display, DPST_GUARD(pipe),
+ DPST_GUARD_HIST_EVENT_STATUS, 1);
+
+ histogram->enable = true;
+
+ return 0;
+}
+
+static void intel_histogram_disable(struct intel_crtc *intel_crtc)
+{
+ struct intel_display *display = to_intel_display(intel_crtc);
+ struct intel_histogram *histogram = intel_crtc->histogram;
+ int pipe = intel_crtc->pipe;
+
+ if (!histogram)
+ return;
+
+ /* If already disabled return */
+ if (histogram->enable)
+ return;
+
+ /* Clear pending interrupts and disable interrupts */
+ intel_de_rmw(display, DPST_GUARD(pipe),
+ DPST_GUARD_HIST_INT_EN | DPST_GUARD_HIST_EVENT_STATUS, 0);
+
+ /* disable DPST_CTL Histogram mode */
+ intel_de_rmw(display, DPST_CTL(pipe),
+ DPST_CTL_IE_HIST_EN, 0);
+
+ histogram->enable = false;
+}
+
+int intel_histogram_update(struct intel_crtc *intel_crtc,
+ struct drm_histogram_config *config)
+{
+ struct intel_display *display = to_intel_display(intel_crtc);
+
+ if (config->enable) {
+ if (config->hist_mode != DRM_MODE_HISTOGRAM_HSV_MAX_RGB) {
+ drm_err(display->drm,
+ "Only max(RGB) mode is supported for histogram\n");
+ return -EINVAL;
+ }
+ return intel_histogram_enable(intel_crtc, config->hist_mode);
+ }
+
+ intel_histogram_disable(intel_crtc);
+ return 0;
+}
+
+void intel_histogram_finish(struct intel_crtc *intel_crtc)
+{
+ struct intel_histogram *histogram = intel_crtc->histogram;
+
+ kfree(histogram);
+}
+
+int intel_histogram_init(struct intel_crtc *crtc)
+{
+ struct intel_histogram *histogram;
+ struct drm_histogram_caps *histogram_caps;
+
+ /* Allocate histogram internal struct */
+ histogram = kzalloc(sizeof(*histogram), GFP_KERNEL);
+ if (!histogram)
+ return -ENOMEM;
+ histogram_caps = kzalloc(sizeof(*histogram_caps), GFP_KERNEL);
+ if (!histogram_caps)
+ return -ENOMEM;
+
+ histogram_caps->histogram_mode = DRM_MODE_HISTOGRAM_HSV_MAX_RGB;
+ histogram_caps->bins_count = HISTOGRAM_BIN_COUNT;
+
+ crtc->histogram = histogram;
+ histogram->crtc = crtc;
+ histogram->can_enable = false;
+ histogram->caps = histogram_caps;
+
+ return 0;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.h b/drivers/gpu/drm/i915/display/intel_histogram.h
new file mode 100644
index 0000000000000000000000000000000000000000..71ca706ebef9873c482f9714f614f6f6cc1eb2f0
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_histogram.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: MIT */
+/* Copyright © 2025 Intel Corporation */
+
+#ifndef __INTEL_HISTOGRAM_H__
+#define __INTEL_HISTOGRAM_H__
+
+#include <linux/types.h>
+#include <linux/workqueue.h>
+
+struct delayed_work;
+struct drm_property_blob;
+struct drm_histogram_config;
+struct drm_histogram_caps;
+struct intel_crtc;
+
+#define HISTOGRAM_BIN_COUNT 32
+
+struct intel_histogram {
+ struct drm_histogram_caps *caps;
+ struct intel_crtc *crtc;
+ struct delayed_work work;
+ bool enable;
+ bool can_enable;
+ u32 bin_data[HISTOGRAM_BIN_COUNT];
+};
+
+enum intel_global_hist_status {
+ INTEL_HISTOGRAM_ENABLE,
+ INTEL_HISTOGRAM_DISABLE,
+};
+
+enum intel_global_histogram {
+ INTEL_HISTOGRAM,
+};
+
+enum intel_global_hist_lut {
+ INTEL_HISTOGRAM_PIXEL_FACTOR,
+};
+
+int intel_histogram_atomic_check(struct intel_crtc *intel_crtc);
+int intel_histogram_update(struct intel_crtc *intel_crtc,
+ struct drm_histogram_config *config);
+int intel_histogram_init(struct intel_crtc *intel_crtc);
+void intel_histogram_finish(struct intel_crtc *intel_crtc);
+
+#endif /* __INTEL_HISTOGRAM_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 10/20] drm/xe: Add histogram support to Xe builds
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (8 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 09/20] drm/i915/histogram: Add support " Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 11/20] drm/i915/histogram: histogram interrupt handling Arun R Murthy
` (9 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy,
Dmitry Baryshkov
Histogram added as part of i915/display driver. Adding the same for xe
as well.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
drivers/gpu/drm/xe/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index c9b60e19cecc68ec90e980ede4b92c690133efbe..38008a644a0919868d6ff99fdda024df0eca944e 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -284,6 +284,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
i915-display/intel_hdcp.o \
i915-display/intel_hdcp_gsc_message.o \
i915-display/intel_hdmi.o \
+ i915-display/intel_histogram.o \
i915-display/intel_hotplug.o \
i915-display/intel_hotplug_irq.o \
i915-display/intel_hti.o \
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 11/20] drm/i915/histogram: histogram interrupt handling
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (9 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 10/20] drm/xe: Add histogram support to Xe builds Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH DO_NOT_RTEVIEW [RESEND] v9 12/20] Plane Color Pipeline support for Intel platforms Arun R Murthy
` (8 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Upon enabling histogram an interrupt is triggered after the generation
of the statistics. This patch registers the histogram interrupt and
handles the interrupt.
v2: Added intel_crtc backpointer to intel_histogram struct (Jani)
Removed histogram_wq and instead use dev_priv->unodered_eq (Jani)
v3: Replaced drm_i915_private with intel_display (Suraj)
Refactored the histogram read code (Jani)
v4: Rebased after addressing comments on patch 1
v5: removed the retry logic and moved to patch7 (Jani)
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/display/intel_display_irq.c | 6 +-
drivers/gpu/drm/i915/display/intel_display_regs.h | 5 +-
drivers/gpu/drm/i915/display/intel_histogram.c | 108 +++++++++++++++++++++-
drivers/gpu/drm/i915/display/intel_histogram.h | 3 +
4 files changed, 117 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_display_irq.c b/drivers/gpu/drm/i915/display/intel_display_irq.c
index 9adeebb376b189ef72a97e0206e0c24b0f4e7117..ad1bf8c75fe1e33271ad054407b8ec1239c76064 100644
--- a/drivers/gpu/drm/i915/display/intel_display_irq.c
+++ b/drivers/gpu/drm/i915/display/intel_display_irq.c
@@ -22,6 +22,7 @@
#include "intel_fdi_regs.h"
#include "intel_fifo_underrun.h"
#include "intel_gmbus.h"
+#include "intel_histogram.h"
#include "intel_hotplug_irq.h"
#include "intel_parent.h"
#include "intel_pipe_crc_regs.h"
@@ -1527,6 +1528,9 @@ void gen8_de_irq_handler(struct intel_display *display, u32 master_ctl)
if (iir & GEN8_PIPE_FIFO_UNDERRUN)
intel_cpu_fifo_underrun_irq_handler(display, pipe);
+ if (iir & GEN9_PIPE_HISTOGRAM_EVENT)
+ intel_histogram_irq_handler(display, pipe);
+
fault_errors = iir & gen8_de_pipe_fault_mask(display);
if (fault_errors)
intel_pipe_fault_irq_handler(display,
@@ -2315,7 +2319,7 @@ static void icp_irq_postinstall(struct intel_display *display);
void gen8_de_irq_postinstall(struct intel_display *display)
{
u32 de_pipe_masked = gen8_de_pipe_fault_mask(display) |
- GEN8_PIPE_CDCLK_CRC_DONE;
+ GEN8_PIPE_CDCLK_CRC_DONE | GEN9_PIPE_HISTOGRAM_EVENT;
u32 de_pipe_enables;
u32 de_port_masked = gen8_de_port_aux_mask(display);
u32 de_port_enables;
diff --git a/drivers/gpu/drm/i915/display/intel_display_regs.h b/drivers/gpu/drm/i915/display/intel_display_regs.h
index c14d3caa73a7a3ffa86beca4b05700481c601899..7affc89fbe22fe8e09a733b16578136e96a3d1ba 100644
--- a/drivers/gpu/drm/i915/display/intel_display_regs.h
+++ b/drivers/gpu/drm/i915/display/intel_display_regs.h
@@ -799,7 +799,7 @@
#define PIPE_HOTPLUG_INTERRUPT_ENABLE (1UL << 26)
#define PIPE_VSYNC_INTERRUPT_ENABLE (1UL << 25)
#define PIPE_DISPLAY_LINE_COMPARE_ENABLE (1UL << 24)
-#define PIPE_DPST_EVENT_ENABLE (1UL << 23)
+#define PIPE_HISTOGRAM_EVENT_ENABLE REG_BIT(23)
#define SPRITE0_FLIP_DONE_INT_EN_VLV (1UL << 22)
#define PIPE_LEGACY_BLC_EVENT_ENABLE (1UL << 22)
#define PIPE_ODD_FIELD_INTERRUPT_ENABLE (1UL << 21)
@@ -822,7 +822,7 @@
#define PIPE_HOTPLUG_INTERRUPT_STATUS (1UL << 10)
#define PIPE_VSYNC_INTERRUPT_STATUS (1UL << 9)
#define PIPE_DISPLAY_LINE_COMPARE_STATUS (1UL << 8)
-#define PIPE_DPST_EVENT_STATUS (1UL << 7)
+#define PIPE_HISTOGRAM_EVENT_STATUS REG_BIT(7)
#define PIPE_A_PSR_STATUS_VLV (1UL << 6)
#define PIPE_LEGACY_BLC_EVENT_STATUS (1UL << 6)
#define PIPE_ODD_FIELD_INTERRUPT_STATUS (1UL << 5)
@@ -1255,6 +1255,7 @@
#define GEN12_DSB_1_INT REG_BIT(14) /* tgl+ */
#define GEN12_DSB_0_INT REG_BIT(13) /* tgl+ */
#define GEN12_DSB_INT(dsb_id) REG_BIT(13 + (dsb_id))
+#define GEN9_PIPE_HISTOGRAM_EVENT REG_BIT(12) /* skl+ */
#define GEN9_PIPE_CURSOR_FAULT REG_BIT(11) /* skl+ */
#define GEN9_PIPE_PLANE4_FAULT REG_BIT(10) /* skl+ */
#define GEN8_PIPE_CURSOR_FAULT REG_BIT(10) /* bdw */
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.c b/drivers/gpu/drm/i915/display/intel_histogram.c
index 0d14cd88d1869583a3ade8ded9284425ab217d3e..b42edf7dae7c0b8d083dff81c41a7ed4f7938e84 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram.c
+++ b/drivers/gpu/drm/i915/display/intel_histogram.c
@@ -21,7 +21,106 @@
#define HISTOGRAM_GUARDBAND_THRESHOLD_DEFAULT 300
/* Precision factor for threshold guardband */
#define HISTOGRAM_GUARDBAND_PRECISION_FACTOR 10000
-#define HISTOGRAM_DEFAULT_GUARDBAND_DELAY 0x04
+#define HISTOGRAM_BIN_READ_RETRY_COUNT 5
+
+static bool intel_histogram_get_data(struct intel_crtc *intel_crtc)
+{
+ struct intel_display *display = to_intel_display(intel_crtc);
+ struct intel_histogram *histogram = intel_crtc->histogram;
+ int index;
+ u32 dpstbin;
+
+ for (index = 0; index < ARRAY_SIZE(histogram->bin_data); index++) {
+ dpstbin = intel_de_read(display, DPST_BIN(intel_crtc->pipe));
+ if (!(dpstbin & DPST_BIN_BUSY))
+ histogram->bin_data[index] = dpstbin & DPST_BIN_DATA_MASK;
+ else
+ return false;
+ }
+ return true;
+}
+
+static void intel_histogram_handle_int_work(struct work_struct *work)
+{
+ struct intel_histogram *histogram = container_of(work,
+ struct intel_histogram, work.work);
+ struct intel_crtc *intel_crtc = histogram->crtc;
+ struct intel_display *display = to_intel_display(intel_crtc);
+ struct drm_colorop *colorop;
+ char event[] = "HISTOGRAM=1", pipe_id[21];
+ char *histogram_event[] = { event, pipe_id, NULL };
+ int retry;
+
+ snprintf(pipe_id, sizeof(pipe_id),
+ "PIPE=%u", intel_crtc->base.base.id);
+
+ /*
+ * TODO: PSR to be exited while reading the Histogram data
+ * Set DPST_CTL Bin Reg function select to TC
+ * Set DPST_CTL Bin Register Index to 0
+ */
+ intel_de_rmw(display, DPST_CTL(intel_crtc->pipe),
+ DPST_CTL_BIN_REG_FUNC_SEL | DPST_CTL_BIN_REG_MASK, 0);
+ for (retry = 0; retry < HISTOGRAM_BIN_READ_RETRY_COUNT; retry++) {
+ if (intel_histogram_get_data(intel_crtc)) {
+ u32 *data;
+ struct drm_histogram *hist;
+
+ data = kzalloc(sizeof(data) * sizeof(histogram->bin_data), GFP_KERNEL);
+ if (!data)
+ return;
+ memcpy(histogram->bin_data, data, sizeof(histogram->bin_data));
+ hist = kzalloc(sizeof(*hist), GFP_KERNEL);
+ if (!hist)
+ return;
+ hist->data_ptr = *data;
+ hist->nr_elements = sizeof(histogram->bin_data);
+
+ colorop = intel_crtc->base.state->color_pipeline;
+ /* TODO: fill the drm_histogram_config data back this drm_histogram struct */
+ drm_property_replace_global_blob(display->drm,
+ &colorop->state->histogram_data,
+ sizeof(struct drm_histogram),
+ hist, &intel_crtc->base.base,
+ colorop->histogram_data_property);
+ /* Notify user for Histogram readiness */
+ if (kobject_uevent_env(&display->drm->primary->kdev->kobj,
+ KOBJ_CHANGE, histogram_event))
+ drm_err(display->drm,
+ "Sending HISTOGRAM event failed\n");
+ break;
+ }
+ }
+ if (retry >= HISTOGRAM_BIN_READ_RETRY_COUNT) {
+ drm_err(display->drm, "Histogram bin read failed with max retry\n");
+ return;
+ }
+
+ /* Enable histogram interrupt */
+ intel_de_rmw(display, DPST_GUARD(intel_crtc->pipe), DPST_GUARD_HIST_INT_EN,
+ DPST_GUARD_HIST_INT_EN);
+
+ /* Clear histogram interrupt by setting histogram interrupt status bit*/
+ intel_de_rmw(display, DPST_GUARD(intel_crtc->pipe),
+ DPST_GUARD_HIST_EVENT_STATUS, 1);
+}
+
+void intel_histogram_irq_handler(struct intel_display *display, enum pipe pipe)
+{
+ struct intel_crtc *intel_crtc =
+ to_intel_crtc(drm_crtc_from_index(display->drm, pipe));
+ struct intel_histogram *histogram = intel_crtc->histogram;
+ struct drm_i915_private *i915 = to_i915(intel_crtc->base.dev);
+
+ if (!histogram->enable) {
+ drm_err(display->drm,
+ "Spurious interrupt, histogram not enabled\n");
+ return;
+ }
+
+ queue_delayed_work(i915->unordered_wq,
+ &histogram->work, 0);
+}
int intel_histogram_atomic_check(struct intel_crtc *intel_crtc)
{
@@ -73,7 +172,7 @@ static int intel_histogram_enable(struct intel_crtc *intel_crtc, u8 mode)
DPST_GUARD_THRESHOLD_GB_MASK |
DPST_GUARD_INTERRUPT_DELAY_MASK | DPST_GUARD_HIST_INT_EN,
DPST_GUARD_THRESHOLD_GB(gbandthreshold) |
- DPST_GUARD_INTERRUPT_DELAY(HISTOGRAM_DEFAULT_GUARDBAND_DELAY) |
+ DPST_GUARD_INTERRUPT_DELAY(0x04) |
DPST_GUARD_HIST_INT_EN);
/* Clear pending interrupts has to be done on separate write */
@@ -106,6 +205,7 @@ static void intel_histogram_disable(struct intel_crtc *intel_crtc)
intel_de_rmw(display, DPST_CTL(pipe),
DPST_CTL_IE_HIST_EN, 0);
+ cancel_delayed_work(&histogram->work);
histogram->enable = false;
}
@@ -131,6 +231,7 @@ void intel_histogram_finish(struct intel_crtc *intel_crtc)
{
struct intel_histogram *histogram = intel_crtc->histogram;
+ cancel_delayed_work_sync(&histogram->work);
kfree(histogram);
}
@@ -155,5 +256,8 @@ int intel_histogram_init(struct intel_crtc *crtc)
histogram->can_enable = false;
histogram->caps = histogram_caps;
+ INIT_DEFERRABLE_WORK(&histogram->work,
+ intel_histogram_handle_int_work);
+
return 0;
}
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.h b/drivers/gpu/drm/i915/display/intel_histogram.h
index 71ca706ebef9873c482f9714f614f6f6cc1eb2f0..bd559d90e9b9fc8f5afdbc31c47702a99569b712 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram.h
+++ b/drivers/gpu/drm/i915/display/intel_histogram.h
@@ -12,6 +12,8 @@ struct drm_property_blob;
struct drm_histogram_config;
struct drm_histogram_caps;
struct intel_crtc;
+struct intel_display;
+enum pipe;
#define HISTOGRAM_BIN_COUNT 32
@@ -37,6 +39,7 @@ enum intel_global_hist_lut {
INTEL_HISTOGRAM_PIXEL_FACTOR,
};
+void intel_histogram_irq_handler(struct intel_display *display, enum pipe pipe);
int intel_histogram_atomic_check(struct intel_crtc *intel_crtc);
int intel_histogram_update(struct intel_crtc *intel_crtc,
struct drm_histogram_config *config);
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH DO_NOT_RTEVIEW [RESEND] v9 12/20] Plane Color Pipeline support for Intel platforms
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (10 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 11/20] drm/i915/histogram: histogram interrupt handling Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 13/20] drm/i915/colorop: Add crtc color pipeline for i915 Arun R Murthy
` (7 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
This patch is a squashed series of
https://patchwork.freedesktop.org/series/129811/
Note: The entire series is not taken
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/Makefile | 2 +
.../gpu/drm/i915/display/intel_color_pipeline.c | 156 +++++++++++++++++++++
.../gpu/drm/i915/display/intel_color_pipeline.h | 15 ++
drivers/gpu/drm/i915/display/intel_colorop.c | 35 +++++
drivers/gpu/drm/i915/display/intel_colorop.h | 15 ++
.../gpu/drm/i915/display/intel_display_limits.h | 8 ++
drivers/gpu/drm/i915/display/intel_display_types.h | 5 +
drivers/gpu/drm/xe/Makefile | 2 +
8 files changed, 238 insertions(+)
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 004e8fc092a3b9ba7dd907a228b835ceaf8f2ba5..5088a0ef0be67f5e3851ab8e43b8f661824d561a 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -236,6 +236,8 @@ i915-y += \
display/intel_cdclk.o \
display/intel_cmtg.o \
display/intel_color.o \
+ display/intel_colorop.o \
+ display/intel_color_pipeline.o \
display/intel_combo_phy.o \
display/intel_connector.o \
display/intel_crtc.o \
diff --git a/drivers/gpu/drm/i915/display/intel_color_pipeline.c b/drivers/gpu/drm/i915/display/intel_color_pipeline.c
new file mode 100644
index 0000000000000000000000000000000000000000..f0509b4a55f5840d7e0be0beb52feebe848034f1
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_color_pipeline.c
@@ -0,0 +1,156 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+#include "intel_colorop.h"
+#include "intel_color_pipeline.h"
+#include "intel_de.h"
+#include "intel_display_types.h"
+#include "intel_histogram.h"
+#include "skl_universal_plane.h"
+
+#define MAX_COLOR_PIPELINES 5
+#define PLANE_DEGAMMA_SIZE 128
+#define PLANE_GAMMA_SIZE 32
+
+static
+int _intel_color_pipeline_plane_init(struct drm_plane *plane, struct drm_prop_enum_list *list)
+{
+ struct intel_colorop *colorop;
+ struct drm_device *dev = plane->dev;
+ int ret;
+ struct drm_colorop *prev_op;
+
+ colorop = intel_colorop_create(INTEL_PLANE_CB_PRE_CSC_LUT);
+
+ ret = drm_plane_colorop_curve_1d_lut_init(dev, &colorop->base, plane,
+ PLANE_DEGAMMA_SIZE,
+ DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
+ DRM_COLOROP_FLAG_ALLOW_BYPASS);
+
+ if (ret)
+ return ret;
+
+ list->type = colorop->base.base.id;
+ list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id);
+
+ /* TODO: handle failures and clean up */
+ prev_op = &colorop->base;
+
+ colorop = intel_colorop_create(INTEL_PLANE_CB_CSC);
+ ret = drm_plane_colorop_ctm_3x4_init(dev, &colorop->base, plane,
+ DRM_COLOROP_FLAG_ALLOW_BYPASS);
+ if (ret)
+ return ret;
+
+ drm_colorop_set_next_property(prev_op, &colorop->base);
+ prev_op = &colorop->base;
+
+ colorop = intel_colorop_create(INTEL_PLANE_CB_POST_CSC_LUT);
+ ret = drm_plane_colorop_curve_1d_lut_init(dev, &colorop->base, plane,
+ PLANE_GAMMA_SIZE,
+ DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
+ DRM_COLOROP_FLAG_ALLOW_BYPASS);
+ if (ret)
+ return ret;
+
+ drm_colorop_set_next_property(prev_op, &colorop->base);
+
+ return 0;
+}
+
+int intel_color_pipeline_plane_init(struct drm_plane *plane)
+{
+ struct drm_device *dev = plane->dev;
+ struct intel_display *display = to_intel_display(dev);
+ struct drm_property *prop;
+ struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES];
+ int len = 0;
+ int ret;
+
+ /* Currently expose pipeline only for HDR planes */
+ if (!icl_is_hdr_plane(display, to_intel_plane(plane)->id))
+ return 0;
+
+ /* Add "Bypass" (i.e. NULL) pipeline */
+ pipelines[len].type = 0;
+ pipelines[len].name = "Bypass";
+ len++;
+
+ /* Add pipeline consisting of transfer functions */
+ ret = _intel_color_pipeline_plane_init(plane, &pipelines[len]);
+ if (ret)
+ return ret;
+ len++;
+
+ /* Create COLOR_PIPELINE property and attach */
+ prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
+ "COLOR_PIPELINE",
+ pipelines, len);
+ if (!prop)
+ return -ENOMEM;
+
+ plane->color_pipeline_property = prop;
+
+ drm_object_attach_property(&plane->base, prop, 0);
+
+ /* TODO check if needed */
+ if (plane->state)
+ plane->state->color_pipeline = NULL;
+
+ return 0;
+}
+
+static
+int _intel_color_pipeline_crtc_init(struct drm_crtc *crtc, struct drm_prop_enum_list *list)
+{
+ struct intel_colorop *colorop[INTEL_CRTC_CB_MAX];
+ struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+ struct intel_histogram *histogram = intel_crtc->histogram;
+ struct drm_histogram_caps *caps = histogram->caps;
+ struct drm_iet_caps *iet_caps = histogram->iet_caps;
+ int ret = 0, i = 0;
+
+ colorop[i] = intel_colorop_create(INTEL_CRTC_HISTOGRAM);
+ ret = drm_crtc_colorop_histogram_init(&colorop[i]->base, crtc,
+ caps,
+ DRM_COLOROP_FLAG_ALLOW_BYPASS);
+ if (ret)
+ return ret;
+
+ list->type = colorop[i]->base.base.id;
+ list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop[i]->base.base.id);
+
+ i++;
+
+ colorop[i] = intel_colorop_create(INTEL_CRTC_IET);
+ ret = drm_crtc_colorop_iet_lut_init(&colorop[i]->base, crtc,
+ iet_caps,
+ DRM_COLOROP_FLAG_ALLOW_BYPASS);
+ if (ret)
+ return ret;
+ drm_colorop_set_next_property(&colorop[i - 1]->base, &colorop[i]->base);
+
+ return 0;
+}
+
+int intel_color_pipeline_crtc_init(struct drm_crtc *crtc)
+{
+ struct drm_prop_enum_list crtc_pipelines[INTEL_CRTC_CB_MAX];
+ int len = 0;
+ int ret;
+
+ /* Add crtc pipeline */
+ ret = _intel_color_pipeline_crtc_init(crtc, &crtc_pipelines[len]);
+ if (ret)
+ return ret;
+ len++;
+
+ /* Create COLOR_PIPELINE property and attach */
+ ret = drm_crtc_create_color_pipeline_property(crtc,
+ crtc_pipelines, len);
+ if (ret)
+ return ret;
+
+ return 0;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_color_pipeline.h b/drivers/gpu/drm/i915/display/intel_color_pipeline.h
new file mode 100644
index 0000000000000000000000000000000000000000..56b6dae8c754c31fa1d0814c7ecd643283a72bca
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_color_pipeline.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef __INTEL_COLOR_PIPELINE_H__
+#define __INTEL_COLOR_PIPELINE_H__
+
+struct drm_plane;
+struct drm_crtc;
+
+int intel_color_pipeline_plane_init(struct drm_plane *plane);
+int intel_color_pipeline_crtc_init(struct drm_crtc *crtc);
+
+#endif /* __INTEL_COLOR_PIPELINE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_colorop.c b/drivers/gpu/drm/i915/display/intel_colorop.c
new file mode 100644
index 0000000000000000000000000000000000000000..f2fc0d8780ceea108be5cb2dd5cb020da25cc642
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_colorop.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+#include "intel_colorop.h"
+
+struct intel_colorop *to_intel_colorop(struct drm_colorop *colorop)
+{
+ return container_of(colorop, struct intel_colorop, base);
+}
+
+struct intel_colorop *intel_colorop_alloc(void)
+{
+ struct intel_colorop *colorop;
+
+ colorop = kzalloc(sizeof(*colorop), GFP_KERNEL);
+ if (!colorop)
+ return ERR_PTR(-ENOMEM);
+
+ return colorop;
+}
+
+struct intel_colorop *intel_colorop_create(enum intel_color_block id)
+{
+ struct intel_colorop *colorop;
+
+ colorop = intel_colorop_alloc();
+
+ if (IS_ERR(colorop))
+ return colorop;
+
+ colorop->id = id;
+
+ return colorop;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_colorop.h b/drivers/gpu/drm/i915/display/intel_colorop.h
new file mode 100644
index 0000000000000000000000000000000000000000..21d58eb9f3d0f6518fa7eaaa5202399874002603
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_colorop.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef __INTEL_COLOROP_H__
+#define __INTEL_COLOROP_H__
+
+#include "intel_display_types.h"
+
+struct intel_colorop *to_intel_colorop(struct drm_colorop *colorop);
+struct intel_colorop *intel_colorop_alloc(void);
+struct intel_colorop *intel_colorop_create(enum intel_color_block id);
+
+#endif /* __INTEL_COLOROP_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_display_limits.h b/drivers/gpu/drm/i915/display/intel_display_limits.h
index f0fa27e365ab6d1fad1616266ac2b0508ce92a91..55fd574ba313176b5da637e3623ad106dd27880c 100644
--- a/drivers/gpu/drm/i915/display/intel_display_limits.h
+++ b/drivers/gpu/drm/i915/display/intel_display_limits.h
@@ -138,4 +138,12 @@ enum hpd_pin {
HPD_NUM_PINS
};
+enum intel_color_block {
+ INTEL_PLANE_CB_PRE_CSC_LUT,
+ INTEL_PLANE_CB_CSC,
+ INTEL_PLANE_CB_POST_CSC_LUT,
+
+ INTEL_CB_MAX
+};
+
#endif /* __INTEL_DISPLAY_LIMITS_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index b8a1be24cd0408dfa5377c9afe5309a9f1e743dd..ac5fa0dbffd77dbf927b61d2916a9624eeabac24 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1987,6 +1987,11 @@ struct intel_dp_mst_encoder {
struct intel_connector *connector;
};
+struct intel_colorop {
+ struct drm_colorop base;
+ enum intel_color_block id;
+};
+
static inline struct intel_encoder *
intel_attached_encoder(struct intel_connector *connector)
{
diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index 38008a644a0919868d6ff99fdda024df0eca944e..cd84f2be4ed37847d4da031ad9e330f56982431d 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -230,6 +230,8 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
i915-display/intel_cdclk.o \
i915-display/intel_cmtg.o \
i915-display/intel_color.o \
+ i915-display/intel_colorop.o \
+ i915-display/intel_color_pipeline.o \
i915-display/intel_combo_phy.o \
i915-display/intel_connector.o \
i915-display/intel_crtc.o \
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 13/20] drm/i915/colorop: Add crtc color pipeline for i915
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (11 preceding siblings ...)
2025-12-02 6:27 ` [PATCH DO_NOT_RTEVIEW [RESEND] v9 12/20] Plane Color Pipeline support for Intel platforms Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 14/20] drm/i915/histogram: Hook i915 histogram with drm histogram Arun R Murthy
` (6 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Add crtc color pipeline for i915 with initializing the histogram
transfer function.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/display/intel_display_limits.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_display_limits.h b/drivers/gpu/drm/i915/display/intel_display_limits.h
index 55fd574ba313176b5da637e3623ad106dd27880c..20bb2bd81489b4fed7e550e0b4e0ade6dcf35859 100644
--- a/drivers/gpu/drm/i915/display/intel_display_limits.h
+++ b/drivers/gpu/drm/i915/display/intel_display_limits.h
@@ -146,4 +146,10 @@ enum intel_color_block {
INTEL_CB_MAX
};
+enum intel_crtc_color_block {
+ INTEL_CRTC_HISTOGRAM,
+
+ INTEL_CRTC_CB_MAX
+};
+
#endif /* __INTEL_DISPLAY_LIMITS_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 14/20] drm/i915/histogram: Hook i915 histogram with drm histogram
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (12 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 13/20] drm/i915/colorop: Add crtc color pipeline for i915 Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 15/20] drm/i915/iet: Add support to writing the IET LUT data Arun R Murthy
` (5 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Handle histogram caps and histogram config property in i915 driver. Fill
the histogram hardware capability and act upon the histogram config
property to enable/disable histogram in i915.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/display/intel_crtc.c | 7 +++++++
drivers/gpu/drm/i915/display/intel_display.c | 15 +++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index 2fe645860385df9b64aedc408dc5908b475a0b40..036a347d7540d33faa3f7d7588dc860e6b717a56 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -17,6 +17,7 @@
#include "icl_dsi.h"
#include "intel_atomic.h"
#include "intel_color.h"
+#include "intel_color_pipeline.h"
#include "intel_crtc.h"
#include "intel_cursor.h"
#include "intel_display_debugfs.h"
@@ -26,6 +27,7 @@
#include "intel_drrs.h"
#include "intel_dsi.h"
#include "intel_fifo_underrun.h"
+#include "intel_histogram.h"
#include "intel_parent.h"
#include "intel_pipe_crc.h"
#include "intel_plane.h"
@@ -215,6 +217,7 @@ static struct intel_crtc *intel_crtc_alloc(void)
static void intel_crtc_free(struct intel_crtc *crtc)
{
intel_crtc_destroy_state(&crtc->base, crtc->base.state);
+ intel_histogram_finish(crtc);
kfree(crtc);
}
@@ -387,6 +390,10 @@ int intel_crtc_init(struct intel_display *display, enum pipe pipe)
BIT(DRM_SCALING_FILTER_DEFAULT) |
BIT(DRM_SCALING_FILTER_NEAREST_NEIGHBOR));
+ intel_histogram_init(crtc);
+ if (intel_color_pipeline_crtc_init(&crtc->base))
+ drm_err(display->drm, "Failed to initialize histogram properties\n");
+
intel_color_crtc_init(crtc);
intel_drrs_crtc_init(crtc);
intel_crtc_crc_init(crtc);
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index e5ce47efc809604cf6f7f01bdc9c679d608be3ef..191a830009e78a31e1ad3d9ca8e0596e1a1ff71e 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -99,6 +99,7 @@
#include "intel_flipq.h"
#include "intel_frontbuffer.h"
#include "intel_hdmi.h"
+#include "intel_histogram.h"
#include "intel_hotplug.h"
#include "intel_link_bw.h"
#include "intel_lt_phy.h"
@@ -4252,6 +4253,7 @@ static int intel_crtc_atomic_check(struct intel_atomic_state *state,
struct intel_display *display = to_intel_display(crtc);
struct intel_crtc_state *crtc_state =
intel_atomic_get_new_crtc_state(state, crtc);
+ struct drm_colorop *colorop = crtc_state->uapi.color_pipeline;
int ret;
if (DISPLAY_VER(display) < 5 && !display->platform.g4x &&
@@ -4313,6 +4315,12 @@ static int intel_crtc_atomic_check(struct intel_atomic_state *state,
if (ret)
return ret;
+ if (colorop->state->histogram_updated) {
+ ret = intel_histogram_atomic_check(crtc);
+ if (ret)
+ return ret;
+ }
+
return 0;
}
@@ -7547,6 +7555,8 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)
intel_dbuf_post_plane_update(state);
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+ struct drm_colorop *colorop = new_crtc_state->uapi.color_pipeline;
+
intel_post_plane_update(state, crtc);
intel_modeset_put_crtc_power_domains(crtc, &put_domains[crtc->pipe]);
@@ -7564,6 +7574,11 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)
*/
old_crtc_state->dsb_color = fetch_and_zero(&new_crtc_state->dsb_color);
old_crtc_state->dsb_commit = fetch_and_zero(&new_crtc_state->dsb_commit);
+
+ if (colorop->state->histogram_updated)
+ intel_histogram_update(crtc,
+ (struct drm_histogram_config *)
+ colorop->state->histogram_enable->data);
}
/* Underruns don't always raise interrupts, so check manually */
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 15/20] drm/i915/iet: Add support to writing the IET LUT data
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (13 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 14/20] drm/i915/histogram: Hook i915 histogram with drm histogram Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 16/20] drm/i915/colorop: create IET LUT properties Arun R Murthy
` (4 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
User created LUT can be fed back to the hardware so that the hardware
can apply this LUT data to see the enhancement in the image.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/display/intel_histogram.c | 67 ++++++++++++++++++++++++++
drivers/gpu/drm/i915/display/intel_histogram.h | 4 ++
2 files changed, 71 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.c b/drivers/gpu/drm/i915/display/intel_histogram.c
index b42edf7dae7c0b8d083dff81c41a7ed4f7938e84..cf8aa7b04c4461629b071e49601a0e60d7609a08 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram.c
+++ b/drivers/gpu/drm/i915/display/intel_histogram.c
@@ -22,6 +22,7 @@
/* Precision factor for threshold guardband */
#define HISTOGRAM_GUARDBAND_PRECISION_FACTOR 10000
#define HISTOGRAM_BIN_READ_RETRY_COUNT 5
+#define IET_SAMPLE_FORMAT_1_INT_9_FRACT 0x1000009
static bool intel_histogram_get_data(struct intel_crtc *intel_crtc)
{
@@ -227,6 +228,57 @@ int intel_histogram_update(struct intel_crtc *intel_crtc,
return 0;
}
+int intel_histogram_set_iet_lut(struct intel_crtc *intel_crtc,
+ struct drm_property_blob *blob)
+{
+ struct intel_histogram *histogram = intel_crtc->histogram;
+ struct intel_display *display = to_intel_display(intel_crtc);
+ int pipe = intel_crtc->pipe;
+ int i = 0;
+ struct drm_iet_1dlut_sample *iet;
+ struct drm_colorop *colorop = intel_crtc->base.state->color_pipeline;
+ u32 *data;
+ int ret;
+
+ if (!histogram)
+ return -EINVAL;
+
+ if (!histogram->enable) {
+ drm_err(display->drm, "histogram not enabled");
+ return -EINVAL;
+ }
+
+ data = kcalloc(iet->nr_elements, sizeof(data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ /* Set DPST_CTL Bin Reg function select to IE & wait for a vblabk */
+ intel_de_rmw(display, DPST_CTL(pipe),
+ DPST_CTL_BIN_REG_FUNC_SEL, DPST_CTL_BIN_REG_FUNC_IE);
+
+ drm_crtc_wait_one_vblank(&intel_crtc->base);
+
+ /* Set DPST_CTL Bin Register Index to 0 */
+ intel_de_rmw(display, DPST_CTL(pipe),
+ DPST_CTL_BIN_REG_MASK, DPST_CTL_BIN_REG_CLEAR);
+
+ iet = (struct drm_iet_1dlut_sample *)blob->data;
+ ret = copy_from_user(data, (uint32_t __user *)(unsigned long)iet->iet_lut,
+ sizeof(uint32_t) * iet->nr_elements);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < HISTOGRAM_IET_LENGTH; i++) {
+ intel_de_rmw(display, DPST_BIN(pipe),
+ DPST_BIN_DATA_MASK, data[i]);
+ drm_dbg_atomic(display->drm, "iet_lut[%d]=%x\n", i, data[i]);
+ }
+ drm_property_blob_put(colorop->state->data);
+ kfree(data);
+
+ return 0;
+}
+
void intel_histogram_finish(struct intel_crtc *intel_crtc)
{
struct intel_histogram *histogram = intel_crtc->histogram;
@@ -239,6 +291,8 @@ int intel_histogram_init(struct intel_crtc *crtc)
{
struct intel_histogram *histogram;
struct drm_histogram_caps *histogram_caps;
+ struct drm_iet_caps *iet_caps;
+ u32 *iet_format;
/* Allocate histogram internal struct */
histogram = kzalloc(sizeof(*histogram), GFP_KERNEL);
@@ -251,10 +305,23 @@ int intel_histogram_init(struct intel_crtc *crtc)
histogram_caps->histogram_mode = DRM_MODE_HISTOGRAM_HSV_MAX_RGB;
histogram_caps->bins_count = HISTOGRAM_BIN_COUNT;
+ iet_caps = kzalloc(sizeof(*iet_caps), GFP_KERNEL);
+ if (!iet_caps)
+ return -ENOMEM;
+
+ iet_caps->iet_mode = DRM_MODE_IET_MULTIPLICATIVE;
+ iet_caps->nr_iet_sample_formats = 1;
+ iet_caps->nr_iet_lut_entries = HISTOGRAM_IET_LENGTH;
+ iet_format = kcalloc(iet_caps->nr_iet_sample_formats, sizeof(u32),
+ GFP_KERNEL);
+ *iet_format = IET_SAMPLE_FORMAT_1_INT_9_FRACT;
+ iet_caps->iet_sample_format = *iet_format;
+
crtc->histogram = histogram;
histogram->crtc = crtc;
histogram->can_enable = false;
histogram->caps = histogram_caps;
+ histogram->iet_caps = iet_caps;
INIT_DEFERRABLE_WORK(&histogram->work,
intel_histogram_handle_int_work);
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.h b/drivers/gpu/drm/i915/display/intel_histogram.h
index bd559d90e9b9fc8f5afdbc31c47702a99569b712..d4ddd99bf8c0347cdad23e3d34c14abe0c8ec7ca 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram.h
+++ b/drivers/gpu/drm/i915/display/intel_histogram.h
@@ -16,9 +16,11 @@ struct intel_display;
enum pipe;
#define HISTOGRAM_BIN_COUNT 32
+#define HISTOGRAM_IET_LENGTH 33
struct intel_histogram {
struct drm_histogram_caps *caps;
+ struct drm_iet_caps *iet_caps;
struct intel_crtc *crtc;
struct delayed_work work;
bool enable;
@@ -43,6 +45,8 @@ void intel_histogram_irq_handler(struct intel_display *display, enum pipe pipe);
int intel_histogram_atomic_check(struct intel_crtc *intel_crtc);
int intel_histogram_update(struct intel_crtc *intel_crtc,
struct drm_histogram_config *config);
+int intel_histogram_set_iet_lut(struct intel_crtc *intel_crtc,
+ struct drm_property_blob *blob);
int intel_histogram_init(struct intel_crtc *intel_crtc);
void intel_histogram_finish(struct intel_crtc *intel_crtc);
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 16/20] drm/i915/colorop: create IET LUT properties
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (14 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 15/20] drm/i915/iet: Add support to writing the IET LUT data Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 17/20] drm/i915/crtc: Hook i915 IET LUT with the drm IET properties Arun R Murthy
` (3 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Create IET LUT properties for i915.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/display/intel_display_limits.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/i915/display/intel_display_limits.h b/drivers/gpu/drm/i915/display/intel_display_limits.h
index 20bb2bd81489b4fed7e550e0b4e0ade6dcf35859..cda05e50a30c08fae50af44e5c69e1ea1a0859d8 100644
--- a/drivers/gpu/drm/i915/display/intel_display_limits.h
+++ b/drivers/gpu/drm/i915/display/intel_display_limits.h
@@ -148,6 +148,7 @@ enum intel_color_block {
enum intel_crtc_color_block {
INTEL_CRTC_HISTOGRAM,
+ INTEL_CRTC_IET,
INTEL_CRTC_CB_MAX
};
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 17/20] drm/i915/crtc: Hook i915 IET LUT with the drm IET properties
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (15 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 16/20] drm/i915/colorop: create IET LUT properties Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 18/20] drm/i915/histogram: histogram delay counter doesn't reset Arun R Murthy
` (2 subsequent siblings)
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Upon drm getting the IET LUT value from the user through the IET_LUT
property, i915 driver will write the LUT table to the hardware
registers.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/display/intel_display.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 191a830009e78a31e1ad3d9ca8e0596e1a1ff71e..fd81452483bff1c6542aa95b6e11874fff21bc29 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -7579,6 +7579,9 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)
intel_histogram_update(crtc,
(struct drm_histogram_config *)
colorop->state->histogram_enable->data);
+
+ if (colorop->state->iet_lut_updated)
+ intel_histogram_set_iet_lut(crtc, colorop->state->data);
}
/* Underruns don't always raise interrupts, so check manually */
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 18/20] drm/i915/histogram: histogram delay counter doesn't reset
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (16 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 17/20] drm/i915/crtc: Hook i915 IET LUT with the drm IET properties Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 19/20] drm/i915/histogram: Histogram changes for Display 20+ Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 20/20] drm/i915/histogram: Enable pipe dithering Arun R Murthy
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
The delay counter for histogram does not reset and as a result the
histogram bin never gets updated. Workaround would be to use save and
restore histogram register.
v2: Follow the seq in interrupt handler
Restore DPST bit 0
read/write dpst ctl rg
Restore DPST bit 1 and Guardband Delay Interrupt counter = 0
(Suraj)
v3: updated wa version for display 13 and 14
Wa: 14014889975
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
drivers/gpu/drm/i915/display/intel_histogram.c | 14 ++++++++++++++
drivers/gpu/drm/i915/display/intel_histogram_regs.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.c b/drivers/gpu/drm/i915/display/intel_histogram.c
index cf8aa7b04c4461629b071e49601a0e60d7609a08..2dfc07878ababc11c88468645eae5a58be3b1ee8 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram.c
+++ b/drivers/gpu/drm/i915/display/intel_histogram.c
@@ -55,6 +55,11 @@ static void intel_histogram_handle_int_work(struct work_struct *work)
snprintf(pipe_id, sizeof(pipe_id),
"PIPE=%u", intel_crtc->base.base.id);
+ /* Wa: 14014889975 */
+ if (IS_DISPLAY_VER(display, 13, 14))
+ intel_de_rmw(display, DPST_CTL(intel_crtc->pipe),
+ DPST_CTL_RESTORE, 0);
+
/*
* TODO: PSR to be exited while reading the Histogram data
* Set DPST_CTL Bin Reg function select to TC
@@ -97,6 +102,15 @@ static void intel_histogram_handle_int_work(struct work_struct *work)
return;
}
+ /* Wa: 14014889975 */
+ if (IS_DISPLAY_VER(display, 13, 14))
+ /* Write the value read from DPST_CTL to DPST_CTL.Interrupt Delay Counter(bit 23:16) */
+ intel_de_rmw(display, DPST_CTL(intel_crtc->pipe),
+ DPST_CTL_GUARDBAND_INTERRUPT_DELAY_CNT |
+ DPST_CTL_RESTORE,
+ DPST_CTL_GUARDBAND_INTERRUPT_DELAY(0x0) |
+ DPST_CTL_RESTORE);
+
/* Enable histogram interrupt */
intel_de_rmw(display, DPST_GUARD(intel_crtc->pipe), DPST_GUARD_HIST_INT_EN,
DPST_GUARD_HIST_INT_EN);
diff --git a/drivers/gpu/drm/i915/display/intel_histogram_regs.h b/drivers/gpu/drm/i915/display/intel_histogram_regs.h
index 71daf5ac2dd9ac987b256a35161b3b6977992e95..73d2de05ebe777ca7141eee01ec8ce09b53ee5c8 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram_regs.h
+++ b/drivers/gpu/drm/i915/display/intel_histogram_regs.h
@@ -14,6 +14,8 @@
#define DPST_CTL_RESTORE REG_BIT(28)
#define DPST_CTL_IE_MODI_TABLE_EN REG_BIT(27)
#define DPST_CTL_HIST_MODE REG_BIT(24)
+#define DPST_CTL_GUARDBAND_INTERRUPT_DELAY_CNT REG_GENMASK(23, 16)
+#define DPST_CTL_GUARDBAND_INTERRUPT_DELAY(val) REG_FIELD_PREP(DPST_CTL_GUARDBAND_INTERRUPT_DELAY_CNT, val)
#define DPST_CTL_ENHANCEMENT_MODE_MASK REG_GENMASK(14, 13)
#define DPST_CTL_EN_MULTIPLICATIVE REG_FIELD_PREP(DPST_CTL_ENHANCEMENT_MODE_MASK, 2)
#define DPST_CTL_IE_TABLE_VALUE_FORMAT REG_BIT(15)
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 19/20] drm/i915/histogram: Histogram changes for Display 20+
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (17 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 18/20] drm/i915/histogram: histogram delay counter doesn't reset Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 20/20] drm/i915/histogram: Enable pipe dithering Arun R Murthy
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
In Display 20+, new registers are added for setting index, reading
histogram and writing the IET.
v2: Removed duplicate code (Jani)
v3: Moved histogram core changes to earlier patches (Jani/Suraj)
v4: Rebased after addressing comments on patch 1
v5: Added the retry logic from patch3 and rebased the patch series
v6: optimize wite_iet() (Suraj)
Bspec: 68895
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
drivers/gpu/drm/i915/display/intel_histogram.c | 109 +++++++++++++++------
.../gpu/drm/i915/display/intel_histogram_regs.h | 25 +++++
2 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.c b/drivers/gpu/drm/i915/display/intel_histogram.c
index 2dfc07878ababc11c88468645eae5a58be3b1ee8..1d02f4fdf8549a0fd7a46dbd8fdc218798c2de1b 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram.c
+++ b/drivers/gpu/drm/i915/display/intel_histogram.c
@@ -24,6 +24,37 @@
#define HISTOGRAM_BIN_READ_RETRY_COUNT 5
#define IET_SAMPLE_FORMAT_1_INT_9_FRACT 0x1000009
+static void set_bin_index_0(struct intel_display *display, enum pipe pipe)
+{
+ if (DISPLAY_VER(display) >= 20)
+ intel_de_rmw(display, DPST_IE_INDEX(pipe),
+ DPST_IE_BIN_INDEX_MASK, DPST_IE_BIN_INDEX(0));
+ else
+ intel_de_rmw(display, DPST_CTL(pipe),
+ DPST_CTL_BIN_REG_MASK,
+ DPST_CTL_BIN_REG_CLEAR);
+}
+
+static void write_iet(struct intel_display *display, enum pipe pipe,
+ u32 *data)
+{
+ int i;
+
+ for (i = 0; i < HISTOGRAM_IET_LENGTH; i++) {
+ if (DISPLAY_VER(display) >= 20)
+ intel_de_rmw(display, DPST_IE_BIN(pipe),
+ DPST_IE_BIN_DATA_MASK,
+ DPST_IE_BIN_DATA(data[i]));
+ else
+ intel_de_rmw(display, DPST_BIN(pipe),
+ DPST_BIN_DATA_MASK,
+ DPST_BIN_DATA(data[i]));
+
+ drm_dbg_atomic(display->drm, "iet_lut[%d]=%x\n",
+ i, data[i]);
+ }
+}
+
static bool intel_histogram_get_data(struct intel_crtc *intel_crtc)
{
struct intel_display *display = to_intel_display(intel_crtc);
@@ -31,12 +62,27 @@ static bool intel_histogram_get_data(struct intel_crtc *intel_crtc)
int index;
u32 dpstbin;
+ if (DISPLAY_VER(display) >= 20)
+ intel_de_rmw(display, DPST_HIST_INDEX(intel_crtc->pipe),
+ DPST_HIST_BIN_INDEX_MASK,
+ DPST_HIST_BIN_INDEX(0));
+ else
+ intel_de_rmw(display, DPST_CTL(intel_crtc->pipe),
+ DPST_CTL_BIN_REG_FUNC_SEL | DPST_CTL_BIN_REG_MASK, 0);
+
for (index = 0; index < ARRAY_SIZE(histogram->bin_data); index++) {
- dpstbin = intel_de_read(display, DPST_BIN(intel_crtc->pipe));
+ dpstbin = intel_de_read(display, (DISPLAY_VER(display) >= 20 ?
+ DPST_HIST_BIN(intel_crtc->pipe) :
+ DPST_BIN(intel_crtc->pipe)));
if (!(dpstbin & DPST_BIN_BUSY))
- histogram->bin_data[index] = dpstbin & DPST_BIN_DATA_MASK;
- else
+ histogram->bin_data[index] = dpstbin & (DISPLAY_VER(display) >= 20 ?
+ DPST_HIST_BIN_DATA_MASK :
+ DPST_BIN_DATA_MASK);
+ else {
+ drm_err(display->drm, "Histogram bin busy, retyring\n");
+ fsleep(2);
return false;
+ }
}
return true;
}
@@ -65,8 +111,6 @@ static void intel_histogram_handle_int_work(struct work_struct *work)
* Set DPST_CTL Bin Reg function select to TC
* Set DPST_CTL Bin Register Index to 0
*/
- intel_de_rmw(display, DPST_CTL(intel_crtc->pipe),
- DPST_CTL_BIN_REG_FUNC_SEL | DPST_CTL_BIN_REG_MASK, 0);
for (retry = 0; retry < HISTOGRAM_BIN_READ_RETRY_COUNT; retry++) {
if (intel_histogram_get_data(intel_crtc)) {
u32 *data;
@@ -160,17 +204,27 @@ static int intel_histogram_enable(struct intel_crtc *intel_crtc, u8 mode)
if (histogram->enable)
return 0;
-
- /* enable histogram, clear DPST_CTL bin reg func select to TC */
- intel_de_rmw(display, DPST_CTL(pipe),
- DPST_CTL_BIN_REG_FUNC_SEL | DPST_CTL_IE_HIST_EN |
- DPST_CTL_HIST_MODE | DPST_CTL_IE_TABLE_VALUE_FORMAT |
- DPST_CTL_ENHANCEMENT_MODE_MASK | DPST_CTL_IE_MODI_TABLE_EN,
- ((mode == DRM_MODE_HISTOGRAM_HSV_MAX_RGB) ?
- DPST_CTL_BIN_REG_FUNC_TC : 0) | DPST_CTL_IE_HIST_EN |
- DPST_CTL_HIST_MODE_HSV |
- DPST_CTL_IE_TABLE_VALUE_FORMAT_1INT_9FRAC |
- DPST_CTL_EN_MULTIPLICATIVE | DPST_CTL_IE_MODI_TABLE_EN);
+ /* enable histogram, clear DPST_BIN reg and select TC function */
+ if (DISPLAY_VER(display) >= 20)
+ intel_de_rmw(display, DPST_CTL(pipe),
+ DPST_CTL_IE_HIST_EN |
+ DPST_CTL_HIST_MODE,
+ DPST_CTL_IE_HIST_EN |
+ DPST_CTL_HIST_MODE_HSV);
+ else
+ /* enable histogram, clear DPST_CTL bin reg func select to TC */
+ intel_de_rmw(display, DPST_CTL(pipe),
+ DPST_CTL_BIN_REG_FUNC_SEL | DPST_CTL_IE_HIST_EN |
+ DPST_CTL_HIST_MODE |
+ DPST_CTL_IE_TABLE_VALUE_FORMAT |
+ DPST_CTL_ENHANCEMENT_MODE_MASK |
+ DPST_CTL_IE_MODI_TABLE_EN,
+ ((mode == DRM_MODE_HISTOGRAM_HSV_MAX_RGB) ?
+ DPST_CTL_BIN_REG_FUNC_TC : 0) |
+ DPST_CTL_IE_HIST_EN |
+ DPST_CTL_HIST_MODE_HSV |
+ DPST_CTL_IE_TABLE_VALUE_FORMAT_1INT_9FRAC |
+ DPST_CTL_EN_MULTIPLICATIVE | DPST_CTL_IE_MODI_TABLE_EN);
/* Re-Visit: check if wait for one vblank is required */
drm_crtc_wait_one_vblank(&intel_crtc->base);
@@ -248,7 +302,6 @@ int intel_histogram_set_iet_lut(struct intel_crtc *intel_crtc,
struct intel_histogram *histogram = intel_crtc->histogram;
struct intel_display *display = to_intel_display(intel_crtc);
int pipe = intel_crtc->pipe;
- int i = 0;
struct drm_iet_1dlut_sample *iet;
struct drm_colorop *colorop = intel_crtc->base.state->color_pipeline;
u32 *data;
@@ -266,15 +319,16 @@ int intel_histogram_set_iet_lut(struct intel_crtc *intel_crtc,
if (!data)
return -ENOMEM;
- /* Set DPST_CTL Bin Reg function select to IE & wait for a vblabk */
- intel_de_rmw(display, DPST_CTL(pipe),
- DPST_CTL_BIN_REG_FUNC_SEL, DPST_CTL_BIN_REG_FUNC_IE);
- drm_crtc_wait_one_vblank(&intel_crtc->base);
+ if (DISPLAY_VER(display) < 20) {
+ /* Set DPST_CTL Bin Reg function select to IE & wait for a vblabk */
+ intel_de_rmw(display, DPST_CTL(pipe),
+ DPST_CTL_BIN_REG_FUNC_SEL,
+ DPST_CTL_BIN_REG_FUNC_IE);
+ drm_crtc_wait_one_vblank(&intel_crtc->base);
+ }
- /* Set DPST_CTL Bin Register Index to 0 */
- intel_de_rmw(display, DPST_CTL(pipe),
- DPST_CTL_BIN_REG_MASK, DPST_CTL_BIN_REG_CLEAR);
+ set_bin_index_0(display, pipe);
iet = (struct drm_iet_1dlut_sample *)blob->data;
ret = copy_from_user(data, (uint32_t __user *)(unsigned long)iet->iet_lut,
@@ -282,11 +336,8 @@ int intel_histogram_set_iet_lut(struct intel_crtc *intel_crtc,
if (ret)
return ret;
- for (i = 0; i < HISTOGRAM_IET_LENGTH; i++) {
- intel_de_rmw(display, DPST_BIN(pipe),
- DPST_BIN_DATA_MASK, data[i]);
- drm_dbg_atomic(display->drm, "iet_lut[%d]=%x\n", i, data[i]);
- }
+ write_iet(display, pipe, data);
+
drm_property_blob_put(colorop->state->data);
kfree(data);
diff --git a/drivers/gpu/drm/i915/display/intel_histogram_regs.h b/drivers/gpu/drm/i915/display/intel_histogram_regs.h
index 73d2de05ebe777ca7141eee01ec8ce09b53ee5c8..64a619af519b0e33b06312047def46a210bae53c 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram_regs.h
+++ b/drivers/gpu/drm/i915/display/intel_histogram_regs.h
@@ -43,6 +43,31 @@
#define _DPST_BIN_B 0x491C4
#define DPST_BIN(pipe) _MMIO_PIPE(pipe, _DPST_BIN_A, _DPST_BIN_B)
#define DPST_BIN_DATA_MASK REG_GENMASK(23, 0)
+#define DPST_BIN_DATA(val) REG_FIELD_PREP(DPST_BIN_DATA_MASK, val)
#define DPST_BIN_BUSY REG_BIT(31)
+#define _DPST_HIST_INDEX_A 0x490D8
+#define _DPST_HIST_INDEX_B 0x491D8
+#define DPST_HIST_INDEX(pipe) _MMIO_PIPE(pipe, _DPST_HIST_INDEX_A, _DPST_HIST_INDEX_B)
+#define DPST_HIST_BIN_INDEX_MASK REG_GENMASK(4, 0)
+#define DPST_HIST_BIN_INDEX(val) REG_FIELD_PREP(DPST_HIST_BIN_INDEX_MASK, val)
+
+#define _DPST_HIST_BIN_A 0x490C4
+#define _DPST_HIST_BIN_B 0x491C4
+#define DPST_HIST_BIN(pipe) _MMIO_PIPE(pipe, _DPST_HIST_BIN_A, _DPST_HIST_BIN_B)
+#define DPST_HIST_BIN_BUSY REG_BIT(31)
+#define DPST_HIST_BIN_DATA_MASK REG_GENMASK(30, 0)
+
+#define _DPST_IE_BIN_A 0x490CC
+#define _DPST_IE_BIN_B 0x491CC
+#define DPST_IE_BIN(pipe) _MMIO_PIPE(pipe, _DPST_IE_BIN_A, _DPST_IE_BIN_B)
+#define DPST_IE_BIN_DATA_MASK REG_GENMASK(9, 0)
+#define DPST_IE_BIN_DATA(val) REG_FIELD_PREP(DPST_IE_BIN_DATA_MASK, val)
+
+#define _DPST_IE_INDEX_A 0x490DC
+#define _DPST_IE_INDEX_B 0x491DC
+#define DPST_IE_INDEX(pipe) _MMIO_PIPE(pipe, _DPST_IE_INDEX_A, _DPST_IE_INDEX_B)
+#define DPST_IE_BIN_INDEX_MASK REG_GENMASK(6, 0)
+#define DPST_IE_BIN_INDEX(val) REG_FIELD_PREP(DPST_IE_BIN_INDEX_MASK, val)
+
#endif /* __INTEL_HISTOGRAM_REGS_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH [RESEND] v9 20/20] drm/i915/histogram: Enable pipe dithering
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
` (18 preceding siblings ...)
2025-12-02 6:27 ` [PATCH [RESEND] v9 19/20] drm/i915/histogram: Histogram changes for Display 20+ Arun R Murthy
@ 2025-12-02 6:27 ` Arun R Murthy
19 siblings, 0 replies; 22+ messages in thread
From: Arun R Murthy @ 2025-12-02 6:27 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, Jani Nikula, Rodrigo Vivi,
Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
Enable pipe dithering while enabling histogram to overcome some
atrifacts seen on the screen.
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
drivers/gpu/drm/i915/display/intel_histogram.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/display/intel_histogram.c b/drivers/gpu/drm/i915/display/intel_histogram.c
index 1d02f4fdf8549a0fd7a46dbd8fdc218798c2de1b..152ae1d0393e9b2b331612494e0cf918edc6f999 100644
--- a/drivers/gpu/drm/i915/display/intel_histogram.c
+++ b/drivers/gpu/drm/i915/display/intel_histogram.c
@@ -9,10 +9,10 @@
#include <drm/drm_vblank.h>
#include <drm/drm_print.h>
-#include "i915_reg.h"
#include "i915_drv.h"
#include "intel_de.h"
#include "intel_display.h"
+#include "intel_display_regs.h"
#include "intel_display_types.h"
#include "intel_histogram.h"
#include "intel_histogram_regs.h"
@@ -24,6 +24,13 @@
#define HISTOGRAM_BIN_READ_RETRY_COUNT 5
#define IET_SAMPLE_FORMAT_1_INT_9_FRACT 0x1000009
+static void intel_histogram_enable_dithering(struct intel_display *display,
+ enum pipe pipe)
+{
+ intel_de_rmw(display, PIPE_MISC(pipe), PIPE_MISC_DITHER_ENABLE,
+ PIPE_MISC_DITHER_ENABLE);
+}
+
static void set_bin_index_0(struct intel_display *display, enum pipe pipe)
{
if (DISPLAY_VER(display) >= 20)
@@ -204,6 +211,10 @@ static int intel_histogram_enable(struct intel_crtc *intel_crtc, u8 mode)
if (histogram->enable)
return 0;
+
+ /* Pipe Dithering should be enabled with histogram */
+ intel_histogram_enable_dithering(display, pipe);
+
/* enable histogram, clear DPST_BIN reg and select TC function */
if (DISPLAY_VER(display) >= 20)
intel_de_rmw(display, DPST_CTL(pipe),
--
2.25.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH [RESEND] v9 02/20] drm: Define histogram structures exposed to user
2025-12-02 6:26 ` [PATCH [RESEND] v9 02/20] drm: Define histogram structures exposed to user Arun R Murthy
@ 2025-12-10 9:35 ` Jani Nikula
0 siblings, 0 replies; 22+ messages in thread
From: Jani Nikula @ 2025-12-10 9:35 UTC (permalink / raw)
To: Arun R Murthy, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Harry Wentland,
Leo Li, Rodrigo Siqueira, Alex Deucher, Christian König,
Rodrigo Vivi, Joonas Lahtinen, Tvrtko Ursulin, Lucas De Marchi,
Thomas Hellström, uma.shankar, chaitanya.kumar.borah,
suraj.kandpal
Cc: dri-devel, amd-gfx, intel-gfx, intel-xe, Arun R Murthy
On Tue, 02 Dec 2025, Arun R Murthy <arun.r.murthy@intel.com> wrote:
> Display Histogram is an array of bins and can be generated in many ways
> referred to as modes.
> Ex: HSV max(RGB), Wighted RGB etc.
>
> Understanding the histogram data format(Ex: HSV max(RGB))
> Histogram is just the pixel count.
> For a maximum resolution of 10k (10240 x 4320 = 44236800)
> 25 bits should be sufficient to represent this along with a buffer of 7
> bits(future use) u32 is being considered.
> max(RGB) can be 255 i.e 0xFF 8 bit, considering the most significant 5
> bits, hence 32 bins.
> Below mentioned algorithm illustrates the histogram generation in
> hardware.
>
> hist[32] = {0};
> for (i = 0; i < resolution; i++) {
> bin = max(RGB[i]);
> bin = bin >> 3; /* consider the most significant bits */
> hist[bin]++;
> }
> If the entire image is Red color then max(255,0,0) is 255 so the pixel
> count of each pixels will be placed in the last bin. Hence except
> hist[31] all other bins will have a value zero.
> Generated histogram in this case would be hist[32] = {0,0,....44236800}
>
> Description of the structures, properties defined are documented in the
> header file include/uapi/drm/drm_mode.h
>
> v8: Added doc for HDR planes, removed reserved variables (Dmitry)
>
> Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
> ---
> include/uapi/drm/drm_mode.h | 65 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 65 insertions(+)
>
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index cbbbfc1dfe2b806c641c720b0215e825e350bd03..aa24fef15da708f3e6804d07ffae5b0312dfdce0 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -1545,6 +1545,71 @@ struct drm_mode_closefb {
> __u32 pad;
> };
>
> +/**
> + * enum drm_mode_histogram
> + *
> + * @DRM_MODE_HISTOGRAM_HSV_MAX_RGB:
> + * Maximum resolution at present 10k, 10240x4320 = 44236800
> + * can be denoted in 25bits. With an additional 7 bits in buffer each bin
> + * can be a u32 value.
> + * For SDL, Maximum value of max(RGB) is 255, so max 255 bins.
> + * If the most significant 5 bits are considered, then bins = 2^5
> + * will be 32 bins.
> + * For HDR, maximum value of max(RGB) is 65535, so max 65535 bins.
> + * For illustration consider a full RED image of 10k resolution considering all
> + * 8 bits histogram would look like hist[255] = {0,0,....44236800} with SDR
> + * plane similarly with HDR the same would look like hist[65535] =
> + * {0,0,0,....44236800}
> + */
> +enum drm_mode_histogram {
> + DRM_MODE_HISTOGRAM_HSV_MAX_RGB = 0x01,
> +};
> +
> +/**
> + * struct drm_histogram_caps
> + *
> + * @histogram_mode: histogram generation modes, defined in the
> + * enum drm_mode_histogram
> + * @bins_count: number of bins for a chosen histogram mode. For illustration
> + * refer the above defined histogram mode.
> + */
> +struct drm_histogram_caps {
> + __u32 histogram_mode;
> + __u32 bins_count;
> +};
> +
> +/**
> + * struct drm_histogram_config
> + *
> + * @hist_mode_data: address to the histogram mode specific data if any
> + * @nr_hist_mode_data: number of elements pointed by the address in
> + * hist_mode_data
> + * @hist_mode: histogram mode(HSV max(RGB), RGB, LUMA etc)
> + * @enable: flag to enable/disable histogram
> + */
> +struct drm_histogram_config {
> + __u64 hist_mode_data;
> + __u32 nr_hist_mode_data;
> + enum drm_mode_histogram hist_mode;
> + bool enable;
enums for sure can't be used in UABI structs, and I don't think bools
either.
> +};
> +
> +/**
> + * struct drm_histogram
> + *
> + * @config: histogram configuration data pointed by struct drm_histogram_config
> + * @data_ptr: pointer to the array of histogram.
> + * Histogram is an array of bins. Data format for each bin depends
> + * on the histogram mode. Refer to the above histogram modes for
> + * more information.
> + * @nr_elements: number of bins in the histogram.
> + */
> +struct drm_histogram {
> + struct drm_histogram_config config;
> + __u64 data_ptr;
> + __u32 nr_elements;
> +};
> +
> #if defined(__cplusplus)
> }
> #endif
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2025-12-10 9:35 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 6:26 [PATCH RESEND v9 00/20] Display Global Histogram Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 01/20] DO_NOT_REVIEW: plane/crtc color pipeline Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 02/20] drm: Define histogram structures exposed to user Arun R Murthy
2025-12-10 9:35 ` Jani Nikula
2025-12-02 6:26 ` [PATCH [RESEND] v9 03/20] drm: Add new element histogram for colorop Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 04/20] drm/colorop: Export function to create pipeline element histogram Arun R Murthy
2025-12-02 6:26 ` [PATCH [RESEND] v9 05/20] drm: Define ImageEnhancemenT LUT structures exposed to user Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 06/20] drm: Add new element Image EnhancemenT for colorop Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 07/20] drm/colorop: Export function to create pipeline element iet lut Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 08/20] drm/i915/histogram: Define registers for histogram Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 09/20] drm/i915/histogram: Add support " Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 10/20] drm/xe: Add histogram support to Xe builds Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 11/20] drm/i915/histogram: histogram interrupt handling Arun R Murthy
2025-12-02 6:27 ` [PATCH DO_NOT_RTEVIEW [RESEND] v9 12/20] Plane Color Pipeline support for Intel platforms Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 13/20] drm/i915/colorop: Add crtc color pipeline for i915 Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 14/20] drm/i915/histogram: Hook i915 histogram with drm histogram Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 15/20] drm/i915/iet: Add support to writing the IET LUT data Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 16/20] drm/i915/colorop: create IET LUT properties Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 17/20] drm/i915/crtc: Hook i915 IET LUT with the drm IET properties Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 18/20] drm/i915/histogram: histogram delay counter doesn't reset Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 19/20] drm/i915/histogram: Histogram changes for Display 20+ Arun R Murthy
2025-12-02 6:27 ` [PATCH [RESEND] v9 20/20] drm/i915/histogram: Enable pipe dithering Arun R Murthy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox