[PATCH 14/36] drm/i915: Check pfit minimum timings

Ville Syrjala ville.syrjala at linux.intel.com
Wed Dec 18 16:10:31 UTC 2019


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

Transcoder hdisplay/vdisplay have documented minimum limits
when using the panel fitter. Enforce those limits.

v2: Skip the checks if the crtc is disabled
    Add debugs for the failures
v3: Reformat debug msg

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

diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c
index c0e42d9b9ef7..9c7d070c286a 100644
--- a/drivers/gpu/drm/i915/display/intel_panel.c
+++ b/drivers/gpu/drm/i915/display/intel_panel.c
@@ -242,6 +242,22 @@ static int intel_pch_pfit_check_scaling(const struct intel_crtc_state *crtc_stat
 	return 0;
 }
 
+static int intel_pch_pfit_check_timings(const struct intel_crtc_state *crtc_state)
+{
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+	const struct drm_display_mode *adjusted_mode =
+		&crtc_state->hw.adjusted_mode;
+
+	if (adjusted_mode->crtc_vdisplay < 7) {
+		DRM_DEBUG_KMS("[CRTC:%d:%s] vertical active (%d) below minimum (%d) for pfit\n",
+			      crtc->base.base.id, crtc->base.name,
+			      adjusted_mode->crtc_vdisplay, 7);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /* adjusted_mode has been preset to be the panel's fixed mode */
 int intel_pch_panel_fitting(struct intel_crtc_state *crtc_state,
 			    const struct drm_connector_state *conn_state)
@@ -329,6 +345,10 @@ int intel_pch_panel_fitting(struct intel_crtc_state *crtc_state,
 	if (ret)
 		return ret;
 
+	ret = intel_pch_pfit_check_timings(crtc_state);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
@@ -466,6 +486,36 @@ static void i9xx_scale_aspect(struct intel_crtc_state *crtc_state,
 	}
 }
 
+static int intel_gmch_pfit_check_timings(const struct intel_crtc_state *crtc_state)
+{
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
+	const struct drm_display_mode *adjusted_mode =
+		&crtc_state->hw.adjusted_mode;
+	int min;
+
+	if (INTEL_GEN(dev_priv) >= 4)
+		min = 3;
+	else
+		min = 2;
+
+	if (adjusted_mode->crtc_hdisplay < min) {
+		DRM_DEBUG_KMS("[CRTC:%d:%s] horizontal active (%d) below minimum (%d) for pfit\n",
+			      crtc->base.base.id, crtc->base.name,
+			      adjusted_mode->crtc_hdisplay, min);
+		return -EINVAL;
+	}
+
+	if (adjusted_mode->crtc_vdisplay < min) {
+		DRM_DEBUG_KMS("[CRTC:%d:%s] vertical active (%d) below minimum (%d) for pfit\n",
+			      crtc->base.base.id, crtc->base.name,
+			      adjusted_mode->crtc_vdisplay, min);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 int intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state,
 			     const struct drm_connector_state *conn_state)
 {
@@ -538,7 +588,10 @@ int intel_gmch_panel_fitting(struct intel_crtc_state *crtc_state,
 	crtc_state->gmch_pfit.pgm_ratios = pfit_pgm_ratios;
 	crtc_state->gmch_pfit.lvds_border_bits = border;
 
-	return 0;
+	if ((pfit_control & PFIT_ENABLE) == 0)
+		return 0;
+
+	return intel_gmch_pfit_check_timings(crtc_state);
 }
 
 /**
-- 
2.23.0



More information about the Intel-gfx-trybot mailing list