[PATCH v5 2/6] display/skl_scaler: Calculate scaler prefill latency

Mitul Golani mitulkumar.ajitkumar.golani at intel.com
Wed Oct 16 09:07:50 UTC 2024


Calculate scaler prefill latency which accounts for time for
each scaler in pipeline.

Signed-off-by: Mitul Golani <mitulkumar.ajitkumar.golani at intel.com>
---
 drivers/gpu/drm/i915/display/skl_scaler.c | 42 +++++++++++++++++++++++
 drivers/gpu/drm/i915/display/skl_scaler.h |  1 +
 2 files changed, 43 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c b/drivers/gpu/drm/i915/display/skl_scaler.c
index baa601d27815..647865ef8d86 100644
--- a/drivers/gpu/drm/i915/display/skl_scaler.c
+++ b/drivers/gpu/drm/i915/display/skl_scaler.c
@@ -6,6 +6,7 @@
 #include "i915_reg.h"
 #include "intel_de.h"
 #include "intel_display_types.h"
+#include "intel_crtc.h"
 #include "intel_fb.h"
 #include "skl_scaler.h"
 #include "skl_universal_plane.h"
@@ -896,3 +897,44 @@ void skl_scaler_get_config(struct intel_crtc_state *crtc_state)
 	else
 		scaler_state->scaler_users &= ~(1 << SKL_CRTC_INDEX);
 }
+
+int calc_scaler_prefill(struct intel_crtc_state *crtc_state)
+{
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+	struct intel_crtc_scaler_state *scaler_state = &crtc_state->scaler_state;
+	struct intel_plane *plane = to_intel_plane(crtc->base.primary);
+	const struct intel_plane_state *plane_state = to_intel_plane_state(plane->base.state);
+	int scaller_prefill[2], i, count, hscale, vscale, tot_scaler_prefill_usec;
+
+	// Number of scalers in use
+	for (i = 0; i < crtc->num_scalers; i++)
+		if (scaler_state->scalers[i].in_use)
+			count++;
+
+	if (!count)
+		return 0;
+
+	if (count == 2) {
+		hscale = drm_rect_calc_hscale(&plane_state->uapi.src,
+					      &plane_state->uapi.dst,
+					      0, INT_MAX);
+		vscale = drm_rect_calc_vscale(&plane_state->uapi.src,
+					      &plane_state->uapi.dst,
+					      0, INT_MAX);
+
+		scaller_prefill[1] =
+			4 * DIV_ROUND_UP(crtc_state->hw.adjusted_mode.htotal * 1000,
+					 intel_crtc_dotclock(crtc_state)) * hscale * vscale;
+	}
+
+	/*
+	 * FIXME : When only 1 scaler used, 1st scaler can be downscale/upscale
+	 */
+	scaller_prefill[0] = 4 * DIV_ROUND_UP(crtc_state->hw.adjusted_mode.htotal * 1000,
+					      intel_crtc_dotclock(crtc_state));
+
+	tot_scaler_prefill_usec = scaller_prefill[0] + scaller_prefill[1];
+
+	return intel_usecs_to_scanlines(&crtc_state->hw.adjusted_mode,
+					tot_scaler_prefill_usec);
+}
diff --git a/drivers/gpu/drm/i915/display/skl_scaler.h b/drivers/gpu/drm/i915/display/skl_scaler.h
index 63f93ca03c89..97ee22d3dd4f 100644
--- a/drivers/gpu/drm/i915/display/skl_scaler.h
+++ b/drivers/gpu/drm/i915/display/skl_scaler.h
@@ -34,4 +34,5 @@ void skl_scaler_disable(const struct intel_crtc_state *old_crtc_state);
 
 void skl_scaler_get_config(struct intel_crtc_state *crtc_state);
 
+int calc_scaler_prefill(struct intel_crtc_state *crtc_state);
 #endif
-- 
2.46.0



More information about the Intel-gfx-trybot mailing list