[Intel-gfx] [PATCH v2 08/15] drm/i915: Check pfit scaling factors

Ville Syrjala ville.syrjala at linux.intel.com
Thu Sep 5 10:37:42 UTC 2019


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Make sure we're not exceeding the max scaling factors for the panel
fitter.

v2: Rebase due to crtc enable check

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 46 +++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index ccec2b54677d..f7f93af55ec5 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -11810,13 +11810,57 @@ static int intel_pch_pfit_check_src_size(const struct intel_crtc_state *crtc_sta
 	return 0;
 }
 
+static int intel_pch_pfit_check_scaling(const struct intel_crtc_state *crtc_state)
+{
+	struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
+	struct drm_rect src = {
+		.x2 = crtc_state->pipe_src_w << 16,
+		.y2 = crtc_state->pipe_src_h << 16,
+	};
+	const struct drm_rect *dst = &crtc_state->pch_pfit.dst;
+	int ret, max_scale;
+
+	if (INTEL_GEN(dev_priv) >= 9) {
+		if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
+			max_scale = 0x18000 - 1; /* < 1.5 */
+		else
+			max_scale = 0x30000 - 1; /* < 3.0 */
+	} else {
+		max_scale = 0x12000; /* 1.125 */
+	}
+
+	ret = drm_rect_calc_hscale(&src, dst, 0, max_scale);
+	if (ret < 0) {
+		DRM_DEBUG_KMS("pfit horizontal downscale (%d->%d) exceeds max (0x%x)\n",
+			      crtc_state->pipe_src_w,
+			      drm_rect_width(dst), max_scale);
+		return ret;
+	}
+
+	ret = drm_rect_calc_vscale(&src, dst, 0, max_scale);
+	if (ret < 0) {
+		DRM_DEBUG_KMS("pfit vertical downscale (%d->%d) exceeds max (0x%x)\n",
+			      crtc_state->pipe_src_h,
+			      drm_rect_height(dst), max_scale);
+		return ret;
+	}
+
+	return 0;
+}
+
 static int intel_pch_pfit_check(const struct intel_crtc_state *crtc_state)
 {
+	int ret;
+
 	if (!crtc_state->base.enable ||
 	    !crtc_state->pch_pfit.enabled)
 		return 0;
 
-	return intel_pch_pfit_check_src_size(crtc_state);
+	ret = intel_pch_pfit_check_src_size(crtc_state);
+	if (ret)
+		return ret;
+
+	return intel_pch_pfit_check_scaling(crtc_state);
 }
 
 static int intel_crtc_atomic_check(struct drm_crtc *crtc,
-- 
2.21.0



More information about the Intel-gfx mailing list