diff mbox series

[5/6] drm/i915/display: crtc property for global hist selective fetch

Message ID 20230518094916.1142812-5-arun.r.murthy@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/6] drm/i915/display: Add support for global histogram | expand

Commit Message

Arun R Murthy May 18, 2023, 9:49 a.m. UTC
User can provide the selective fetch co-ordinates for global histogram
using crtc blob property. This patch adds the crtc blob property.
The selective fetch can be done only on the y co-ordinate and cannot be
done on the x co-ordinate.

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
 drivers/gpu/drm/i915/display/intel_crtc.c     | 45 +++++++++++++++++++
 .../drm/i915/display/intel_display_types.h    |  3 ++
 2 files changed, 48 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_crtc.c b/drivers/gpu/drm/i915/display/intel_crtc.c
index 501bcf732aba..2a9dcf3b1a19 100644
--- a/drivers/gpu/drm/i915/display/intel_crtc.c
+++ b/drivers/gpu/drm/i915/display/intel_crtc.c
@@ -236,6 +236,9 @@  int intel_crtc_get_property(struct drm_crtc *crtc,
 	else if (property == intel_crtc->global_hist_property)
 		*val = (intel_crtc_state->global_hist) ?
 			intel_crtc_state->global_hist->base.id : 0;
+	else if (property == intel_crtc->global_hist_sf_clips_property)
+		*val = (intel_crtc_state->global_hist_sf_clips) ?
+			intel_crtc_state->global_hist_sf_clips->base.id : 0;
 	else {
 		drm_err(&i915->drm,
 			       "Unknown property [PROP:%d:%s]\n",
@@ -306,6 +309,18 @@  int intel_crtc_set_property(struct drm_crtc *crtc,
 		return 0;
 	}
 
+	if (property == intel_crtc->global_hist_sf_clips_property) {
+		intel_atomic_replace_property_blob_from_id(crtc->dev,
+					&intel_crtc_state->global_hist_sf_clips,
+					val,
+					-1,
+					sizeof(struct drm_rect),
+					&replaced);
+		if (replaced)
+			intel_crtc_state->global_hist_sf_clips_updates = true;
+		return 0;
+	}
+
 	drm_dbg_atomic(&i915->drm, "Unknown property [PROP:%d:%s]\n",
 		       property->base.id, property->name);
 	return -EINVAL;
@@ -903,11 +918,41 @@  void intel_attach_global_hist_property(struct intel_crtc *intel_crtc)
 	drm_object_attach_property(&crtc->base, prop, blob->base.id);
 }
 
+/**
+ * intel_attach_global_hist_sf_seg_property() - selective fetch segment property
+ * @intel_crtc: pointer to struct intel_crtc on which global histogram is enabled
+ *
+ * "Global Histogram SF CLIPS" is the crtc porperty used to provide the
+ * co-ordinates of the damage clips.
+ */
+void intel_attach_global_hist_sf_seg_property(struct intel_crtc * intel_crtc)
+{
+	struct drm_crtc *crtc = &intel_crtc->base;
+	struct drm_device *dev = crtc->dev;
+	struct drm_property *prop;
+	struct drm_property_blob *blob;
+
+	prop = intel_crtc->global_hist_sf_clips_property;
+	if (prop == NULL) {
+		prop = drm_property_create(dev,
+			DRM_MODE_PROP_ATOMIC | DRM_MODE_PROP_BLOB,
+			"Global Histogram SF CLIPS", 0);
+		if (prop == NULL)
+			return;
+		intel_crtc->global_hist_sf_clips_property = prop;
+	}
+	blob = drm_property_create_blob(dev, sizeof(struct drm_rect *), NULL);
+	intel_crtc->config->global_hist_sf_clips = blob;
+
+	drm_object_attach_property(&crtc->base, prop, blob->base.id);
+}
+
 int intel_crtc_add_property(struct intel_crtc *intel_crtc)
 {
 	intel_attach_global_hist_en_property(intel_crtc);
 	intel_attach_global_hist_property(intel_crtc);
 	intel_attach_global_iet_property(intel_crtc);
+	intel_attach_global_hist_sf_seg_property(intel_crtc);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 15d28e2305da..703593d4a52f 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1371,8 +1371,10 @@  struct intel_crtc_state {
 	int global_hist_en;
 	struct drm_property_blob *global_iet;
 	struct drm_property_blob *global_hist;
+	struct drm_property_blob *global_hist_sf_clips;
 	bool global_iet_changed;
 	bool global_hist_en_changed;
+	bool global_hist_sf_clips_updates;
 };
 
 enum intel_pipe_crc_source {
@@ -1480,6 +1482,7 @@  struct intel_crtc {
 	struct drm_property *global_hist_en_property;
 	struct drm_property *global_iet_property;
 	struct drm_property *global_hist_property;
+	struct drm_property *global_hist_sf_clips_property;
 #ifdef CONFIG_DEBUG_FS
 	struct intel_pipe_crc pipe_crc;
 	u32 cpu_fifo_underrun_count;