[PATCH 05/15] drm/i915: Introduce intel_crtc_readout_derived_state()

Aaron Ma aaron.ma at canonical.com
Fri Mar 26 07:29:59 UTC 2021


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

BugLink: https://bugs.launchpad.net/bugs/1921318

Collect up a bunch of derived state "readout" into
a common helper, which we can call from both
intel_encoder_get_config() and intel_crtc_get_pipe_config().

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
Reviewed-by: Manasi Navare <manasi.d.navare at intel.com>
Signed-off-by: Manasi Navare <manasi.d.navare at intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201112191718.16683-6-ville.syrjala@linux.intel.com
(cherry picked from commit c42773b67d82e62e4b30103f26169b3e02ad06ee)
Signed-off-by: Aaron Ma <aaron.ma at canonical.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 34 +++++++++++---------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 921fc7130a7b..89a51b8b2b00 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -8089,10 +8089,26 @@ static void intel_crtc_compute_pixel_rate(struct intel_crtc_state *crtc_state)
 			ilk_pipe_pixel_rate(crtc_state);
 }
 
+static void intel_crtc_readout_derived_state(struct intel_crtc_state *crtc_state)
+{
+	struct drm_display_mode *mode = &crtc_state->hw.mode;
+	struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode;
+
+	intel_mode_from_crtc_timings(adjusted_mode, adjusted_mode);
+
+	intel_crtc_compute_pixel_rate(crtc_state);
+
+	drm_mode_copy(mode, adjusted_mode);
+	mode->hdisplay = crtc_state->pipe_src_w;
+	mode->vdisplay = crtc_state->pipe_src_h;
+}
+
 static void intel_encoder_get_config(struct intel_encoder *encoder,
 				     struct intel_crtc_state *crtc_state)
 {
 	encoder->get_config(encoder, crtc_state);
+
+	intel_crtc_readout_derived_state(crtc_state);
 }
 
 static int intel_crtc_compute_config(struct intel_crtc *crtc,
@@ -8973,9 +8989,6 @@ static void intel_get_pipe_src_size(struct intel_crtc *crtc,
 	tmp = intel_de_read(dev_priv, PIPESRC(crtc->pipe));
 	pipe_config->pipe_src_h = (tmp & 0xffff) + 1;
 	pipe_config->pipe_src_w = ((tmp >> 16) & 0xffff) + 1;
-
-	pipe_config->hw.mode.vdisplay = pipe_config->pipe_src_h;
-	pipe_config->hw.mode.hdisplay = pipe_config->pipe_src_w;
 }
 
 static void i9xx_set_pipeconf(const struct intel_crtc_state *crtc_state)
@@ -11334,6 +11347,8 @@ static bool intel_crtc_get_pipe_config(struct intel_crtc_state *crtc_state)
 
 	crtc_state->hw.active = true;
 
+	intel_crtc_readout_derived_state(crtc_state);
+
 	return true;
 }
 
@@ -14373,8 +14388,6 @@ verify_crtc_state(struct intel_crtc *crtc,
 			intel_encoder_get_config(encoder, pipe_config);
 	}
 
-	intel_crtc_compute_pixel_rate(pipe_config);
-
 	if (!new_crtc_state->hw.active)
 		return;
 
@@ -18594,15 +18607,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
 		int min_cdclk = 0;
 
 		if (crtc_state->hw.active) {
-			struct drm_display_mode *mode = &crtc_state->hw.mode;
-
-			intel_mode_from_crtc_timings(&crtc_state->hw.adjusted_mode,
-						     &crtc_state->hw.adjusted_mode);
-
-			*mode = crtc_state->hw.adjusted_mode;
-			mode->hdisplay = crtc_state->pipe_src_w;
-			mode->vdisplay = crtc_state->pipe_src_h;
-
 			/*
 			 * The initial mode needs to be set in order to keep
 			 * the atomic core happy. It wants a valid mode if the
@@ -18614,8 +18618,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
 			 */
 			crtc_state->inherited = true;
 
-			intel_crtc_compute_pixel_rate(crtc_state);
-
 			intel_crtc_update_active_timings(crtc_state);
 
 			intel_crtc_copy_hw_to_uapi_state(crtc_state);
-- 
2.25.1




More information about the kernel-team mailing list