Commit ede9771d authored by Ville Syrjälä's avatar Ville Syrjälä
Browse files

drm/i915: Pass atomic state to encoder hooks



We're going to want access to the atomic state for iterating
the slave crtcs when enabling the port sync master crtc. Pass
the atomic state all the way down.

The alternative would be yet another encoder hook which we'll
have to call after all the normal modeset stuff is done. Not
really a fan of yet another hook just for this.

Note that during readout state sanitation we are now going
to pass NULL as the atomic state since we don't have one.
We need to change that and then we can also s/crtc_state/crtc/
and s/conn_state/conn/ for the encoder hooks as well.

Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200313164831.5980-13-ville.syrjala@linux.intel.com


Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
parent 1ff241ea
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1156,7 +1156,8 @@ static void gen11_dsi_powerup_panel(struct intel_encoder *encoder)
	wait_for_cmds_dispatched_to_panel(encoder);
}

static void gen11_dsi_pre_pll_enable(struct intel_encoder *encoder,
static void gen11_dsi_pre_pll_enable(struct intel_atomic_state *state,
				     struct intel_encoder *encoder,
				     const struct intel_crtc_state *crtc_state,
				     const struct drm_connector_state *conn_state)
{
@@ -1167,7 +1168,8 @@ static void gen11_dsi_pre_pll_enable(struct intel_encoder *encoder,
	gen11_dsi_program_esc_clk_div(encoder, crtc_state);
}

static void gen11_dsi_pre_enable(struct intel_encoder *encoder,
static void gen11_dsi_pre_enable(struct intel_atomic_state *state,
				 struct intel_encoder *encoder,
				 const struct intel_crtc_state *pipe_config,
				 const struct drm_connector_state *conn_state)
{
@@ -1186,7 +1188,8 @@ static void gen11_dsi_pre_enable(struct intel_encoder *encoder,
	gen11_dsi_set_transcoder_timings(encoder, pipe_config);
}

static void gen11_dsi_enable(struct intel_encoder *encoder,
static void gen11_dsi_enable(struct intel_atomic_state *state,
			     struct intel_encoder *encoder,
			     const struct intel_crtc_state *crtc_state,
			     const struct drm_connector_state *conn_state)
{
@@ -1341,7 +1344,8 @@ static void gen11_dsi_disable_io_power(struct intel_encoder *encoder)
	}
}

static void gen11_dsi_disable(struct intel_encoder *encoder,
static void gen11_dsi_disable(struct intel_atomic_state *state,
			      struct intel_encoder *encoder,
			      const struct intel_crtc_state *old_crtc_state,
			      const struct drm_connector_state *old_conn_state)
{
@@ -1369,7 +1373,8 @@ static void gen11_dsi_disable(struct intel_encoder *encoder,
	gen11_dsi_disable_io_power(encoder);
}

static void gen11_dsi_post_disable(struct intel_encoder *encoder,
static void gen11_dsi_post_disable(struct intel_atomic_state *state,
				   struct intel_encoder *encoder,
				   const struct intel_crtc_state *old_crtc_state,
				   const struct drm_connector_state *old_conn_state)
{
+21 −12
Original line number Diff line number Diff line
@@ -203,27 +203,31 @@ static void intel_crt_set_dpms(struct intel_encoder *encoder,
	intel_de_write(dev_priv, crt->adpa_reg, adpa);
}

static void intel_disable_crt(struct intel_encoder *encoder,
static void intel_disable_crt(struct intel_atomic_state *state,
			      struct intel_encoder *encoder,
			      const struct intel_crtc_state *old_crtc_state,
			      const struct drm_connector_state *old_conn_state)
{
	intel_crt_set_dpms(encoder, old_crtc_state, DRM_MODE_DPMS_OFF);
}

static void pch_disable_crt(struct intel_encoder *encoder,
static void pch_disable_crt(struct intel_atomic_state *state,
			    struct intel_encoder *encoder,
			    const struct intel_crtc_state *old_crtc_state,
			    const struct drm_connector_state *old_conn_state)
{
}

static void pch_post_disable_crt(struct intel_encoder *encoder,
static void pch_post_disable_crt(struct intel_atomic_state *state,
				 struct intel_encoder *encoder,
				 const struct intel_crtc_state *old_crtc_state,
				 const struct drm_connector_state *old_conn_state)
{
	intel_disable_crt(encoder, old_crtc_state, old_conn_state);
	intel_disable_crt(state, encoder, old_crtc_state, old_conn_state);
}

static void hsw_disable_crt(struct intel_encoder *encoder,
static void hsw_disable_crt(struct intel_atomic_state *state,
			    struct intel_encoder *encoder,
			    const struct intel_crtc_state *old_crtc_state,
			    const struct drm_connector_state *old_conn_state)
{
@@ -234,7 +238,8 @@ static void hsw_disable_crt(struct intel_encoder *encoder,
	intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, false);
}

static void hsw_post_disable_crt(struct intel_encoder *encoder,
static void hsw_post_disable_crt(struct intel_atomic_state *state,
				 struct intel_encoder *encoder,
				 const struct intel_crtc_state *old_crtc_state,
				 const struct drm_connector_state *old_conn_state)
{
@@ -250,19 +255,20 @@ static void hsw_post_disable_crt(struct intel_encoder *encoder,

	intel_ddi_disable_pipe_clock(old_crtc_state);

	pch_post_disable_crt(encoder, old_crtc_state, old_conn_state);
	pch_post_disable_crt(state, encoder, old_crtc_state, old_conn_state);

	lpt_disable_pch_transcoder(dev_priv);
	lpt_disable_iclkip(dev_priv);

	intel_ddi_fdi_post_disable(encoder, old_crtc_state, old_conn_state);
	intel_ddi_fdi_post_disable(state, encoder, old_crtc_state, old_conn_state);

	drm_WARN_ON(&dev_priv->drm, !old_crtc_state->has_pch_encoder);

	intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, true);
}

static void hsw_pre_pll_enable_crt(struct intel_encoder *encoder,
static void hsw_pre_pll_enable_crt(struct intel_atomic_state *state,
				   struct intel_encoder *encoder,
				   const struct intel_crtc_state *crtc_state,
				   const struct drm_connector_state *conn_state)
{
@@ -273,7 +279,8 @@ static void hsw_pre_pll_enable_crt(struct intel_encoder *encoder,
	intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, false);
}

static void hsw_pre_enable_crt(struct intel_encoder *encoder,
static void hsw_pre_enable_crt(struct intel_atomic_state *state,
			       struct intel_encoder *encoder,
			       const struct intel_crtc_state *crtc_state,
			       const struct drm_connector_state *conn_state)
{
@@ -290,7 +297,8 @@ static void hsw_pre_enable_crt(struct intel_encoder *encoder,
	intel_ddi_enable_pipe_clock(crtc_state);
}

static void hsw_enable_crt(struct intel_encoder *encoder,
static void hsw_enable_crt(struct intel_atomic_state *state,
			   struct intel_encoder *encoder,
			   const struct intel_crtc_state *crtc_state,
			   const struct drm_connector_state *conn_state)
{
@@ -314,7 +322,8 @@ static void hsw_enable_crt(struct intel_encoder *encoder,
	intel_set_pch_fifo_underrun_reporting(dev_priv, PIPE_A, true);
}

static void intel_enable_crt(struct intel_encoder *encoder,
static void intel_enable_crt(struct intel_atomic_state *state,
			     struct intel_encoder *encoder,
			     const struct intel_crtc_state *crtc_state,
			     const struct drm_connector_state *conn_state)
{
+56 −33
Original line number Diff line number Diff line
@@ -3089,7 +3089,8 @@ static void intel_ddi_disable_fec_state(struct intel_encoder *encoder,
	intel_de_posting_read(dev_priv, intel_dp->regs.dp_tp_ctl);
}

static void tgl_ddi_pre_enable_dp(struct intel_encoder *encoder,
static void tgl_ddi_pre_enable_dp(struct intel_atomic_state *state,
				  struct intel_encoder *encoder,
				  const struct intel_crtc_state *crtc_state,
				  const struct drm_connector_state *conn_state)
{
@@ -3229,7 +3230,8 @@ static void tgl_ddi_pre_enable_dp(struct intel_encoder *encoder,
	intel_dsc_enable(encoder, crtc_state);
}

static void hsw_ddi_pre_enable_dp(struct intel_encoder *encoder,
static void hsw_ddi_pre_enable_dp(struct intel_atomic_state *state,
				  struct intel_encoder *encoder,
				  const struct intel_crtc_state *crtc_state,
				  const struct drm_connector_state *conn_state)
{
@@ -3302,16 +3304,17 @@ static void hsw_ddi_pre_enable_dp(struct intel_encoder *encoder,
	intel_dsc_enable(encoder, crtc_state);
}

static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
static void intel_ddi_pre_enable_dp(struct intel_atomic_state *state,
				    struct intel_encoder *encoder,
				    const struct intel_crtc_state *crtc_state,
				    const struct drm_connector_state *conn_state)
{
	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);

	if (INTEL_GEN(dev_priv) >= 12)
		tgl_ddi_pre_enable_dp(encoder, crtc_state, conn_state);
		tgl_ddi_pre_enable_dp(state, encoder, crtc_state, conn_state);
	else
		hsw_ddi_pre_enable_dp(encoder, crtc_state, conn_state);
		hsw_ddi_pre_enable_dp(state, encoder, crtc_state, conn_state);

	/* MST will call a setting of MSA after an allocating of Virtual Channel
	 * from MST encoder pre_enable callback.
@@ -3323,7 +3326,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder,
	}
}

static void intel_ddi_pre_enable_hdmi(struct intel_encoder *encoder,
static void intel_ddi_pre_enable_hdmi(struct intel_atomic_state *state,
				      struct intel_encoder *encoder,
				      const struct intel_crtc_state *crtc_state,
				      const struct drm_connector_state *conn_state)
{
@@ -3363,7 +3367,8 @@ static void intel_ddi_pre_enable_hdmi(struct intel_encoder *encoder,
				       crtc_state, conn_state);
}

static void intel_ddi_pre_enable(struct intel_encoder *encoder,
static void intel_ddi_pre_enable(struct intel_atomic_state *state,
				 struct intel_encoder *encoder,
				 const struct intel_crtc_state *crtc_state,
				 const struct drm_connector_state *conn_state)
{
@@ -3392,12 +3397,14 @@ static void intel_ddi_pre_enable(struct intel_encoder *encoder,
	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true);

	if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
		intel_ddi_pre_enable_hdmi(encoder, crtc_state, conn_state);
		intel_ddi_pre_enable_hdmi(state, encoder, crtc_state,
					  conn_state);
	} else {
		struct intel_lspcon *lspcon =
				enc_to_intel_lspcon(encoder);

		intel_ddi_pre_enable_dp(encoder, crtc_state, conn_state);
		intel_ddi_pre_enable_dp(state, encoder, crtc_state,
					conn_state);
		if (lspcon->active) {
			struct intel_digital_port *dig_port =
					enc_to_dig_port(encoder);
@@ -3440,7 +3447,8 @@ static void intel_disable_ddi_buf(struct intel_encoder *encoder,
		intel_wait_ddi_buf_idle(dev_priv, port);
}

static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
static void intel_ddi_post_disable_dp(struct intel_atomic_state *state,
				      struct intel_encoder *encoder,
				      const struct intel_crtc_state *old_crtc_state,
				      const struct drm_connector_state *old_conn_state)
{
@@ -3496,7 +3504,8 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder,
	intel_ddi_clk_disable(encoder);
}

static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
static void intel_ddi_post_disable_hdmi(struct intel_atomic_state *state,
					struct intel_encoder *encoder,
					const struct intel_crtc_state *old_crtc_state,
					const struct drm_connector_state *old_conn_state)
{
@@ -3519,7 +3528,8 @@ static void intel_ddi_post_disable_hdmi(struct intel_encoder *encoder,
	intel_dp_dual_mode_set_tmds_output(intel_hdmi, false);
}

static void intel_ddi_post_disable(struct intel_encoder *encoder,
static void intel_ddi_post_disable(struct intel_atomic_state *state,
				   struct intel_encoder *encoder,
				   const struct intel_crtc_state *old_crtc_state,
				   const struct drm_connector_state *old_conn_state)
{
@@ -3557,11 +3567,11 @@ static void intel_ddi_post_disable(struct intel_encoder *encoder,
	 */

	if (intel_crtc_has_type(old_crtc_state, INTEL_OUTPUT_HDMI))
		intel_ddi_post_disable_hdmi(encoder,
					    old_crtc_state, old_conn_state);
		intel_ddi_post_disable_hdmi(state, encoder, old_crtc_state,
					    old_conn_state);
	else
		intel_ddi_post_disable_dp(encoder,
					  old_crtc_state, old_conn_state);
		intel_ddi_post_disable_dp(state, encoder, old_crtc_state,
					  old_conn_state);

	if (INTEL_GEN(dev_priv) >= 11)
		icl_unmap_plls_to_ports(encoder);
@@ -3574,7 +3584,8 @@ static void intel_ddi_post_disable(struct intel_encoder *encoder,
		intel_tc_port_put_link(dig_port);
}

void intel_ddi_fdi_post_disable(struct intel_encoder *encoder,
void intel_ddi_fdi_post_disable(struct intel_atomic_state *state,
				struct intel_encoder *encoder,
				const struct intel_crtc_state *old_crtc_state,
				const struct drm_connector_state *old_conn_state)
{
@@ -3608,7 +3619,8 @@ void intel_ddi_fdi_post_disable(struct intel_encoder *encoder,
	intel_de_write(dev_priv, FDI_RX_CTL(PIPE_A), val);
}

static void intel_enable_ddi_dp(struct intel_encoder *encoder,
static void intel_enable_ddi_dp(struct intel_atomic_state *state,
				struct intel_encoder *encoder,
				const struct intel_crtc_state *crtc_state,
				const struct drm_connector_state *conn_state)
{
@@ -3649,7 +3661,8 @@ gen9_chicken_trans_reg_by_port(struct drm_i915_private *dev_priv,
	return CHICKEN_TRANS(trans[port]);
}

static void intel_enable_ddi_hdmi(struct intel_encoder *encoder,
static void intel_enable_ddi_hdmi(struct intel_atomic_state *state,
				  struct intel_encoder *encoder,
				  const struct intel_crtc_state *crtc_state,
				  const struct drm_connector_state *conn_state)
{
@@ -3711,7 +3724,8 @@ static void intel_enable_ddi_hdmi(struct intel_encoder *encoder,
		intel_audio_codec_enable(encoder, crtc_state, conn_state);
}

static void intel_enable_ddi(struct intel_encoder *encoder,
static void intel_enable_ddi(struct intel_atomic_state *state,
			     struct intel_encoder *encoder,
			     const struct intel_crtc_state *crtc_state,
			     const struct drm_connector_state *conn_state)
{
@@ -3722,9 +3736,9 @@ static void intel_enable_ddi(struct intel_encoder *encoder,
	intel_crtc_vblank_on(crtc_state);

	if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
		intel_enable_ddi_hdmi(encoder, crtc_state, conn_state);
		intel_enable_ddi_hdmi(state, encoder, crtc_state, conn_state);
	else
		intel_enable_ddi_dp(encoder, crtc_state, conn_state);
		intel_enable_ddi_dp(state, encoder, crtc_state, conn_state);

	/* Enable hdcp if it's desired */
	if (conn_state->content_protection ==
@@ -3734,7 +3748,8 @@ static void intel_enable_ddi(struct intel_encoder *encoder,
				  (u8)conn_state->hdcp_content_type);
}

static void intel_disable_ddi_dp(struct intel_encoder *encoder,
static void intel_disable_ddi_dp(struct intel_atomic_state *state,
				 struct intel_encoder *encoder,
				 const struct intel_crtc_state *old_crtc_state,
				 const struct drm_connector_state *old_conn_state)
{
@@ -3754,7 +3769,8 @@ static void intel_disable_ddi_dp(struct intel_encoder *encoder,
					      false);
}

static void intel_disable_ddi_hdmi(struct intel_encoder *encoder,
static void intel_disable_ddi_hdmi(struct intel_atomic_state *state,
				   struct intel_encoder *encoder,
				   const struct intel_crtc_state *old_crtc_state,
				   const struct drm_connector_state *old_conn_state)
{
@@ -3772,19 +3788,23 @@ static void intel_disable_ddi_hdmi(struct intel_encoder *encoder,
			    connector->base.id, connector->name);
}

static void intel_disable_ddi(struct intel_encoder *encoder,
static void intel_disable_ddi(struct intel_atomic_state *state,
			      struct intel_encoder *encoder,
			      const struct intel_crtc_state *old_crtc_state,
			      const struct drm_connector_state *old_conn_state)
{
	intel_hdcp_disable(to_intel_connector(old_conn_state->connector));

	if (intel_crtc_has_type(old_crtc_state, INTEL_OUTPUT_HDMI))
		intel_disable_ddi_hdmi(encoder, old_crtc_state, old_conn_state);
		intel_disable_ddi_hdmi(state, encoder, old_crtc_state,
				       old_conn_state);
	else
		intel_disable_ddi_dp(encoder, old_crtc_state, old_conn_state);
		intel_disable_ddi_dp(state, encoder, old_crtc_state,
				     old_conn_state);
}

static void intel_ddi_update_pipe_dp(struct intel_encoder *encoder,
static void intel_ddi_update_pipe_dp(struct intel_atomic_state *state,
				     struct intel_encoder *encoder,
				     const struct intel_crtc_state *crtc_state,
				     const struct drm_connector_state *conn_state)
{
@@ -3795,18 +3815,20 @@ static void intel_ddi_update_pipe_dp(struct intel_encoder *encoder,
	intel_psr_update(intel_dp, crtc_state);
	intel_edp_drrs_enable(intel_dp, crtc_state);

	intel_panel_update_backlight(encoder, crtc_state, conn_state);
	intel_panel_update_backlight(state, encoder, crtc_state, conn_state);
}

static void intel_ddi_update_pipe(struct intel_encoder *encoder,
static void intel_ddi_update_pipe(struct intel_atomic_state *state,
				  struct intel_encoder *encoder,
				  const struct intel_crtc_state *crtc_state,
				  const struct drm_connector_state *conn_state)
{

	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
		intel_ddi_update_pipe_dp(encoder, crtc_state, conn_state);
		intel_ddi_update_pipe_dp(state, encoder, crtc_state,
					 conn_state);

	intel_hdcp_update_pipe(encoder, crtc_state, conn_state);
	intel_hdcp_update_pipe(state, encoder, crtc_state, conn_state);
}

static void
@@ -3835,7 +3857,8 @@ intel_ddi_update_complete(struct intel_atomic_state *state,
}

static void
intel_ddi_pre_pll_enable(struct intel_encoder *encoder,
intel_ddi_pre_pll_enable(struct intel_atomic_state *state,
			 struct intel_encoder *encoder,
			 const struct intel_crtc_state *crtc_state,
			 const struct drm_connector_state *conn_state)
{
+2 −1
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@ struct intel_dp;
struct intel_dpll_hw_state;
struct intel_encoder;

void intel_ddi_fdi_post_disable(struct intel_encoder *intel_encoder,
void intel_ddi_fdi_post_disable(struct intel_atomic_state *state,
				struct intel_encoder *intel_encoder,
				const struct intel_crtc_state *old_crtc_state,
				const struct drm_connector_state *old_conn_state);
void hsw_fdi_link_train(struct intel_encoder *encoder,
+17 −9
Original line number Diff line number Diff line
@@ -6689,7 +6689,8 @@ static void intel_encoders_pre_pll_enable(struct intel_atomic_state *state,
			continue;
		if (encoder->pre_pll_enable)
			encoder->pre_pll_enable(encoder, crtc_state, conn_state);
			encoder->pre_pll_enable(state, encoder,
						crtc_state, conn_state);
	}
}
@@ -6710,7 +6711,8 @@ static void intel_encoders_pre_enable(struct intel_atomic_state *state,
			continue;
		if (encoder->pre_enable)
			encoder->pre_enable(encoder, crtc_state, conn_state);
			encoder->pre_enable(state, encoder,
					    crtc_state, conn_state);
	}
}
@@ -6731,7 +6733,8 @@ static void intel_encoders_enable(struct intel_atomic_state *state,
			continue;
		if (encoder->enable)
			encoder->enable(encoder, crtc_state, conn_state);
			encoder->enable(state, encoder,
					crtc_state, conn_state);
		intel_opregion_notify_encoder(encoder, true);
	}
}
@@ -6754,7 +6757,8 @@ static void intel_encoders_disable(struct intel_atomic_state *state,
		intel_opregion_notify_encoder(encoder, false);
		if (encoder->disable)
			encoder->disable(encoder, old_crtc_state, old_conn_state);
			encoder->disable(state, encoder,
					 old_crtc_state, old_conn_state);
	}
}
@@ -6775,7 +6779,8 @@ static void intel_encoders_post_disable(struct intel_atomic_state *state,
			continue;
		if (encoder->post_disable)
			encoder->post_disable(encoder, old_crtc_state, old_conn_state);
			encoder->post_disable(state, encoder,
					      old_crtc_state, old_conn_state);
	}
}
@@ -6796,7 +6801,8 @@ static void intel_encoders_post_pll_disable(struct intel_atomic_state *state,
			continue;
		if (encoder->post_pll_disable)
			encoder->post_pll_disable(encoder, old_crtc_state, old_conn_state);
			encoder->post_pll_disable(state, encoder,
						  old_crtc_state, old_conn_state);
	}
}
@@ -6817,7 +6823,8 @@ static void intel_encoders_update_pipe(struct intel_atomic_state *state,
			continue;
		if (encoder->update_pipe)
			encoder->update_pipe(encoder, crtc_state, conn_state);
			encoder->update_pipe(state, encoder,
					     crtc_state, conn_state);
	}
}
@@ -18126,11 +18133,12 @@ static void intel_sanitize_encoder(struct intel_encoder *encoder)
			best_encoder = connector->base.state->best_encoder;
			connector->base.state->best_encoder = &encoder->base;
			/* FIXME NULL atomic state passed! */
			if (encoder->disable)
				encoder->disable(encoder, crtc_state,
				encoder->disable(NULL, encoder, crtc_state,
						 connector->base.state);
			if (encoder->post_disable)
				encoder->post_disable(encoder, crtc_state,
				encoder->post_disable(NULL, encoder, crtc_state,
						      connector->base.state);
			connector->base.state->best_encoder = best_encoder;
Loading