diff mbox series

[09/11] drm/i915: Hoist the encoder->audio_{enable, disable}() calls higher up

Message ID 20231106211915.13406-10-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Audio fastset, and some fixes | expand

Commit Message

Ville Syrjälä Nov. 6, 2023, 9:19 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Push he encoder->audio_{enable,disable}() calls out from the
encoder->{enable,disable}() hooks. Moving towards audio fastset.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/g4x_dp.c        |  2 -
 drivers/gpu/drm/i915/display/g4x_hdmi.c      | 10 ----
 drivers/gpu/drm/i915/display/intel_ddi.c     |  3 --
 drivers/gpu/drm/i915/display/intel_display.c | 49 ++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_dp_mst.c  |  4 --
 5 files changed, 49 insertions(+), 19 deletions(-)

Comments

Jani Nikula Nov. 13, 2023, 3:47 p.m. UTC | #1
On Mon, 06 Nov 2023, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Push he encoder->audio_{enable,disable}() calls out from the
> encoder->{enable,disable}() hooks. Moving towards audio fastset.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/display/g4x_dp.c        |  2 -
>  drivers/gpu/drm/i915/display/g4x_hdmi.c      | 10 ----
>  drivers/gpu/drm/i915/display/intel_ddi.c     |  3 --
>  drivers/gpu/drm/i915/display/intel_display.c | 49 ++++++++++++++++++++
>  drivers/gpu/drm/i915/display/intel_dp_mst.c  |  4 --
>  5 files changed, 49 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/g4x_dp.c b/drivers/gpu/drm/i915/display/g4x_dp.c
> index 96232af42db2..dfe0b07a122d 100644
> --- a/drivers/gpu/drm/i915/display/g4x_dp.c
> +++ b/drivers/gpu/drm/i915/display/g4x_dp.c
> @@ -516,8 +516,6 @@ static void intel_disable_dp(struct intel_atomic_state *state,
>  {
>  	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
>  
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> -
>  	intel_dp->link_trained = false;
>  
>  	/*
> diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.c b/drivers/gpu/drm/i915/display/g4x_hdmi.c
> index 26a0981102ff..8096492b3fad 100644
> --- a/drivers/gpu/drm/i915/display/g4x_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/g4x_hdmi.c
> @@ -273,8 +273,6 @@ static void g4x_enable_hdmi(struct intel_atomic_state *state,
>  			    const struct drm_connector_state *conn_state)
>  {
>  	g4x_hdmi_enable_port(encoder, pipe_config);
> -
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static void ibx_enable_hdmi(struct intel_atomic_state *state,
> @@ -322,8 +320,6 @@ static void ibx_enable_hdmi(struct intel_atomic_state *state,
>  		intel_de_write(dev_priv, intel_hdmi->hdmi_reg, temp);
>  		intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg);
>  	}
> -
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static void cpt_enable_hdmi(struct intel_atomic_state *state,
> @@ -373,8 +369,6 @@ static void cpt_enable_hdmi(struct intel_atomic_state *state,
>  		intel_de_rmw(dev_priv, TRANS_CHICKEN1(pipe),
>  			     TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE, 0);
>  	}
> -
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static void vlv_enable_hdmi(struct intel_atomic_state *state,
> @@ -382,7 +376,6 @@ static void vlv_enable_hdmi(struct intel_atomic_state *state,
>  			    const struct intel_crtc_state *pipe_config,
>  			    const struct drm_connector_state *conn_state)
>  {
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static void intel_disable_hdmi(struct intel_atomic_state *state,
> @@ -449,8 +442,6 @@ static void g4x_disable_hdmi(struct intel_atomic_state *state,
>  			     const struct intel_crtc_state *old_crtc_state,
>  			     const struct drm_connector_state *old_conn_state)
>  {
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> -
>  	intel_disable_hdmi(state, encoder, old_crtc_state, old_conn_state);
>  }
>  
> @@ -459,7 +450,6 @@ static void pch_disable_hdmi(struct intel_atomic_state *state,
>  			     const struct intel_crtc_state *old_crtc_state,
>  			     const struct drm_connector_state *old_conn_state)
>  {
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
>  }
>  
>  static void pch_post_disable_hdmi(struct intel_atomic_state *state,
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index 2e4920d70105..97569423f430 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -3266,7 +3266,6 @@ static void intel_enable_ddi(struct intel_atomic_state *state,
>  
>  	intel_hdcp_enable(state, encoder, crtc_state, conn_state);
>  
> -	encoder->audio_enable(encoder, crtc_state, conn_state);
>  }
>  
>  static void intel_disable_ddi_dp(struct intel_atomic_state *state,
> @@ -3308,8 +3307,6 @@ static void intel_disable_ddi(struct intel_atomic_state *state,
>  			      const struct intel_crtc_state *old_crtc_state,
>  			      const struct drm_connector_state *old_conn_state)
>  {
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> -
>  	intel_tc_port_link_cancel_reset_work(enc_to_dig_port(encoder));
>  
>  	intel_hdcp_disable(to_intel_connector(old_conn_state->connector));
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index ec76006b1756..d606befa007c 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -889,6 +889,48 @@ static bool needs_async_flip_vtd_wa(const struct intel_crtc_state *crtc_state)
>  		(DISPLAY_VER(i915) == 9 || IS_BROADWELL(i915) || IS_HASWELL(i915));
>  }
>  
> +static void intel_encoders_audio_enable(struct intel_atomic_state *state,
> +					struct intel_crtc *crtc)
> +{
> +	const struct intel_crtc_state *crtc_state =
> +		intel_atomic_get_new_crtc_state(state, crtc);
> +	const struct drm_connector_state *conn_state;
> +	struct drm_connector *conn;
> +	int i;
> +
> +	for_each_new_connector_in_state(&state->base, conn, conn_state, i) {
> +		struct intel_encoder *encoder =
> +			to_intel_encoder(conn_state->best_encoder);
> +
> +		if (conn_state->crtc != &crtc->base)
> +			continue;
> +
> +		if (encoder->audio_enable)
> +			encoder->audio_enable(encoder, crtc_state, conn_state);
> +	}
> +}
> +
> +static void intel_encoders_audio_disable(struct intel_atomic_state *state,
> +					 struct intel_crtc *crtc)
> +{
> +	const struct intel_crtc_state *old_crtc_state =
> +		intel_atomic_get_old_crtc_state(state, crtc);
> +	const struct drm_connector_state *old_conn_state;
> +	struct drm_connector *conn;
> +	int i;
> +
> +	for_each_old_connector_in_state(&state->base, conn, old_conn_state, i) {
> +		struct intel_encoder *encoder =
> +			to_intel_encoder(old_conn_state->best_encoder);
> +
> +		if (old_conn_state->crtc != &crtc->base)
> +			continue;
> +
> +		if (encoder->audio_disable)
> +			encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> +	}
> +}
> +
>  #define is_enabling(feature, old_crtc_state, new_crtc_state) \
>  	((!(old_crtc_state)->feature || intel_crtc_needs_modeset(new_crtc_state)) && \
>  	 (new_crtc_state)->feature)
> @@ -1461,6 +1503,7 @@ static void ilk_crtc_enable(struct intel_atomic_state *state,
>  	intel_crtc_vblank_on(new_crtc_state);
>  
>  	intel_encoders_enable(state, crtc);
> +	intel_encoders_audio_enable(state, crtc);
>  
>  	if (HAS_PCH_CPT(dev_priv))
>  		intel_wait_for_pipe_scanline_moving(crtc);
> @@ -1634,6 +1677,7 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,
>  		intel_crtc_vblank_on(new_crtc_state);
>  
>  	intel_encoders_enable(state, crtc);
> +	intel_encoders_audio_enable(state, crtc);
>  
>  	if (psl_clkgate_wa) {
>  		intel_crtc_wait_for_next_vblank(crtc);
> @@ -1685,6 +1729,7 @@ static void ilk_crtc_disable(struct intel_atomic_state *state,
>  	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
>  	intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, false);
>  
> +	intel_encoders_audio_disable(state, crtc);
>  	intel_encoders_disable(state, crtc);
>  
>  	intel_crtc_vblank_off(old_crtc_state);
> @@ -1719,6 +1764,7 @@ static void hsw_crtc_disable(struct intel_atomic_state *state,
>  	 * Need care with mst->ddi interactions.
>  	 */
>  	if (!intel_crtc_is_bigjoiner_slave(old_crtc_state)) {
> +		intel_encoders_audio_disable(state, crtc);
>  		intel_encoders_disable(state, crtc);
>  		intel_encoders_post_disable(state, crtc);
>  	}
> @@ -1988,6 +2034,7 @@ static void valleyview_crtc_enable(struct intel_atomic_state *state,
>  	intel_crtc_vblank_on(new_crtc_state);
>  
>  	intel_encoders_enable(state, crtc);
> +	intel_encoders_audio_enable(state, crtc);
>  }
>  
>  static void i9xx_crtc_enable(struct intel_atomic_state *state,
> @@ -2029,6 +2076,7 @@ static void i9xx_crtc_enable(struct intel_atomic_state *state,
>  	intel_crtc_vblank_on(new_crtc_state);
>  
>  	intel_encoders_enable(state, crtc);
> +	intel_encoders_audio_enable(state, crtc);
>  
>  	/* prevents spurious underruns */
>  	if (DISPLAY_VER(dev_priv) == 2)
> @@ -2065,6 +2113,7 @@ static void i9xx_crtc_disable(struct intel_atomic_state *state,
>  	if (DISPLAY_VER(dev_priv) == 2)
>  		intel_crtc_wait_for_next_vblank(crtc);
>  
> +	intel_encoders_audio_disable(state, crtc);
>  	intel_encoders_disable(state, crtc);
>  
>  	intel_crtc_vblank_off(old_crtc_state);
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> index 5f0ccab5ab1f..70ab93b3f141 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> @@ -608,8 +608,6 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state,
>  	drm_dbg_kms(&i915->drm, "active links %d\n",
>  		    intel_dp->active_mst_links);
>  
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> -
>  	intel_hdcp_disable(intel_mst->connector);
>  }
>  
> @@ -845,8 +843,6 @@ static void intel_mst_enable_dp(struct intel_atomic_state *state,
>  	intel_crtc_vblank_on(pipe_config);
>  
>  	intel_hdcp_enable(state, encoder, pipe_config, conn_state);
> -
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder,
Jani Nikula Nov. 13, 2023, 3:47 p.m. UTC | #2
On Mon, 06 Nov 2023, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Push he encoder->audio_{enable,disable}() calls out from the

*the

> encoder->{enable,disable}() hooks. Moving towards audio fastset.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/g4x_dp.c        |  2 -
>  drivers/gpu/drm/i915/display/g4x_hdmi.c      | 10 ----
>  drivers/gpu/drm/i915/display/intel_ddi.c     |  3 --
>  drivers/gpu/drm/i915/display/intel_display.c | 49 ++++++++++++++++++++
>  drivers/gpu/drm/i915/display/intel_dp_mst.c  |  4 --
>  5 files changed, 49 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/g4x_dp.c b/drivers/gpu/drm/i915/display/g4x_dp.c
> index 96232af42db2..dfe0b07a122d 100644
> --- a/drivers/gpu/drm/i915/display/g4x_dp.c
> +++ b/drivers/gpu/drm/i915/display/g4x_dp.c
> @@ -516,8 +516,6 @@ static void intel_disable_dp(struct intel_atomic_state *state,
>  {
>  	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
>  
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> -
>  	intel_dp->link_trained = false;
>  
>  	/*
> diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.c b/drivers/gpu/drm/i915/display/g4x_hdmi.c
> index 26a0981102ff..8096492b3fad 100644
> --- a/drivers/gpu/drm/i915/display/g4x_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/g4x_hdmi.c
> @@ -273,8 +273,6 @@ static void g4x_enable_hdmi(struct intel_atomic_state *state,
>  			    const struct drm_connector_state *conn_state)
>  {
>  	g4x_hdmi_enable_port(encoder, pipe_config);
> -
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static void ibx_enable_hdmi(struct intel_atomic_state *state,
> @@ -322,8 +320,6 @@ static void ibx_enable_hdmi(struct intel_atomic_state *state,
>  		intel_de_write(dev_priv, intel_hdmi->hdmi_reg, temp);
>  		intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg);
>  	}
> -
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static void cpt_enable_hdmi(struct intel_atomic_state *state,
> @@ -373,8 +369,6 @@ static void cpt_enable_hdmi(struct intel_atomic_state *state,
>  		intel_de_rmw(dev_priv, TRANS_CHICKEN1(pipe),
>  			     TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE, 0);
>  	}
> -
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static void vlv_enable_hdmi(struct intel_atomic_state *state,
> @@ -382,7 +376,6 @@ static void vlv_enable_hdmi(struct intel_atomic_state *state,
>  			    const struct intel_crtc_state *pipe_config,
>  			    const struct drm_connector_state *conn_state)
>  {
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static void intel_disable_hdmi(struct intel_atomic_state *state,
> @@ -449,8 +442,6 @@ static void g4x_disable_hdmi(struct intel_atomic_state *state,
>  			     const struct intel_crtc_state *old_crtc_state,
>  			     const struct drm_connector_state *old_conn_state)
>  {
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> -
>  	intel_disable_hdmi(state, encoder, old_crtc_state, old_conn_state);
>  }
>  
> @@ -459,7 +450,6 @@ static void pch_disable_hdmi(struct intel_atomic_state *state,
>  			     const struct intel_crtc_state *old_crtc_state,
>  			     const struct drm_connector_state *old_conn_state)
>  {
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
>  }
>  
>  static void pch_post_disable_hdmi(struct intel_atomic_state *state,
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index 2e4920d70105..97569423f430 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -3266,7 +3266,6 @@ static void intel_enable_ddi(struct intel_atomic_state *state,
>  
>  	intel_hdcp_enable(state, encoder, crtc_state, conn_state);
>  
> -	encoder->audio_enable(encoder, crtc_state, conn_state);
>  }
>  
>  static void intel_disable_ddi_dp(struct intel_atomic_state *state,
> @@ -3308,8 +3307,6 @@ static void intel_disable_ddi(struct intel_atomic_state *state,
>  			      const struct intel_crtc_state *old_crtc_state,
>  			      const struct drm_connector_state *old_conn_state)
>  {
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> -
>  	intel_tc_port_link_cancel_reset_work(enc_to_dig_port(encoder));
>  
>  	intel_hdcp_disable(to_intel_connector(old_conn_state->connector));
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index ec76006b1756..d606befa007c 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -889,6 +889,48 @@ static bool needs_async_flip_vtd_wa(const struct intel_crtc_state *crtc_state)
>  		(DISPLAY_VER(i915) == 9 || IS_BROADWELL(i915) || IS_HASWELL(i915));
>  }
>  
> +static void intel_encoders_audio_enable(struct intel_atomic_state *state,
> +					struct intel_crtc *crtc)
> +{
> +	const struct intel_crtc_state *crtc_state =
> +		intel_atomic_get_new_crtc_state(state, crtc);
> +	const struct drm_connector_state *conn_state;
> +	struct drm_connector *conn;
> +	int i;
> +
> +	for_each_new_connector_in_state(&state->base, conn, conn_state, i) {
> +		struct intel_encoder *encoder =
> +			to_intel_encoder(conn_state->best_encoder);
> +
> +		if (conn_state->crtc != &crtc->base)
> +			continue;
> +
> +		if (encoder->audio_enable)
> +			encoder->audio_enable(encoder, crtc_state, conn_state);
> +	}
> +}
> +
> +static void intel_encoders_audio_disable(struct intel_atomic_state *state,
> +					 struct intel_crtc *crtc)
> +{
> +	const struct intel_crtc_state *old_crtc_state =
> +		intel_atomic_get_old_crtc_state(state, crtc);
> +	const struct drm_connector_state *old_conn_state;
> +	struct drm_connector *conn;
> +	int i;
> +
> +	for_each_old_connector_in_state(&state->base, conn, old_conn_state, i) {
> +		struct intel_encoder *encoder =
> +			to_intel_encoder(old_conn_state->best_encoder);
> +
> +		if (old_conn_state->crtc != &crtc->base)
> +			continue;
> +
> +		if (encoder->audio_disable)
> +			encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> +	}
> +}
> +
>  #define is_enabling(feature, old_crtc_state, new_crtc_state) \
>  	((!(old_crtc_state)->feature || intel_crtc_needs_modeset(new_crtc_state)) && \
>  	 (new_crtc_state)->feature)
> @@ -1461,6 +1503,7 @@ static void ilk_crtc_enable(struct intel_atomic_state *state,
>  	intel_crtc_vblank_on(new_crtc_state);
>  
>  	intel_encoders_enable(state, crtc);
> +	intel_encoders_audio_enable(state, crtc);
>  
>  	if (HAS_PCH_CPT(dev_priv))
>  		intel_wait_for_pipe_scanline_moving(crtc);
> @@ -1634,6 +1677,7 @@ static void hsw_crtc_enable(struct intel_atomic_state *state,
>  		intel_crtc_vblank_on(new_crtc_state);
>  
>  	intel_encoders_enable(state, crtc);
> +	intel_encoders_audio_enable(state, crtc);
>  
>  	if (psl_clkgate_wa) {
>  		intel_crtc_wait_for_next_vblank(crtc);
> @@ -1685,6 +1729,7 @@ static void ilk_crtc_disable(struct intel_atomic_state *state,
>  	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
>  	intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, false);
>  
> +	intel_encoders_audio_disable(state, crtc);
>  	intel_encoders_disable(state, crtc);
>  
>  	intel_crtc_vblank_off(old_crtc_state);
> @@ -1719,6 +1764,7 @@ static void hsw_crtc_disable(struct intel_atomic_state *state,
>  	 * Need care with mst->ddi interactions.
>  	 */
>  	if (!intel_crtc_is_bigjoiner_slave(old_crtc_state)) {
> +		intel_encoders_audio_disable(state, crtc);
>  		intel_encoders_disable(state, crtc);
>  		intel_encoders_post_disable(state, crtc);
>  	}
> @@ -1988,6 +2034,7 @@ static void valleyview_crtc_enable(struct intel_atomic_state *state,
>  	intel_crtc_vblank_on(new_crtc_state);
>  
>  	intel_encoders_enable(state, crtc);
> +	intel_encoders_audio_enable(state, crtc);
>  }
>  
>  static void i9xx_crtc_enable(struct intel_atomic_state *state,
> @@ -2029,6 +2076,7 @@ static void i9xx_crtc_enable(struct intel_atomic_state *state,
>  	intel_crtc_vblank_on(new_crtc_state);
>  
>  	intel_encoders_enable(state, crtc);
> +	intel_encoders_audio_enable(state, crtc);
>  
>  	/* prevents spurious underruns */
>  	if (DISPLAY_VER(dev_priv) == 2)
> @@ -2065,6 +2113,7 @@ static void i9xx_crtc_disable(struct intel_atomic_state *state,
>  	if (DISPLAY_VER(dev_priv) == 2)
>  		intel_crtc_wait_for_next_vblank(crtc);
>  
> +	intel_encoders_audio_disable(state, crtc);
>  	intel_encoders_disable(state, crtc);
>  
>  	intel_crtc_vblank_off(old_crtc_state);
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> index 5f0ccab5ab1f..70ab93b3f141 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> @@ -608,8 +608,6 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state,
>  	drm_dbg_kms(&i915->drm, "active links %d\n",
>  		    intel_dp->active_mst_links);
>  
> -	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
> -
>  	intel_hdcp_disable(intel_mst->connector);
>  }
>  
> @@ -845,8 +843,6 @@ static void intel_mst_enable_dp(struct intel_atomic_state *state,
>  	intel_crtc_vblank_on(pipe_config);
>  
>  	intel_hdcp_enable(state, encoder, pipe_config, conn_state);
> -
> -	encoder->audio_enable(encoder, pipe_config, conn_state);
>  }
>  
>  static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/g4x_dp.c b/drivers/gpu/drm/i915/display/g4x_dp.c
index 96232af42db2..dfe0b07a122d 100644
--- a/drivers/gpu/drm/i915/display/g4x_dp.c
+++ b/drivers/gpu/drm/i915/display/g4x_dp.c
@@ -516,8 +516,6 @@  static void intel_disable_dp(struct intel_atomic_state *state,
 {
 	struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
-
 	intel_dp->link_trained = false;
 
 	/*
diff --git a/drivers/gpu/drm/i915/display/g4x_hdmi.c b/drivers/gpu/drm/i915/display/g4x_hdmi.c
index 26a0981102ff..8096492b3fad 100644
--- a/drivers/gpu/drm/i915/display/g4x_hdmi.c
+++ b/drivers/gpu/drm/i915/display/g4x_hdmi.c
@@ -273,8 +273,6 @@  static void g4x_enable_hdmi(struct intel_atomic_state *state,
 			    const struct drm_connector_state *conn_state)
 {
 	g4x_hdmi_enable_port(encoder, pipe_config);
-
-	encoder->audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void ibx_enable_hdmi(struct intel_atomic_state *state,
@@ -322,8 +320,6 @@  static void ibx_enable_hdmi(struct intel_atomic_state *state,
 		intel_de_write(dev_priv, intel_hdmi->hdmi_reg, temp);
 		intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg);
 	}
-
-	encoder->audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void cpt_enable_hdmi(struct intel_atomic_state *state,
@@ -373,8 +369,6 @@  static void cpt_enable_hdmi(struct intel_atomic_state *state,
 		intel_de_rmw(dev_priv, TRANS_CHICKEN1(pipe),
 			     TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE, 0);
 	}
-
-	encoder->audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void vlv_enable_hdmi(struct intel_atomic_state *state,
@@ -382,7 +376,6 @@  static void vlv_enable_hdmi(struct intel_atomic_state *state,
 			    const struct intel_crtc_state *pipe_config,
 			    const struct drm_connector_state *conn_state)
 {
-	encoder->audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void intel_disable_hdmi(struct intel_atomic_state *state,
@@ -449,8 +442,6 @@  static void g4x_disable_hdmi(struct intel_atomic_state *state,
 			     const struct intel_crtc_state *old_crtc_state,
 			     const struct drm_connector_state *old_conn_state)
 {
-	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
-
 	intel_disable_hdmi(state, encoder, old_crtc_state, old_conn_state);
 }
 
@@ -459,7 +450,6 @@  static void pch_disable_hdmi(struct intel_atomic_state *state,
 			     const struct intel_crtc_state *old_crtc_state,
 			     const struct drm_connector_state *old_conn_state)
 {
-	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
 }
 
 static void pch_post_disable_hdmi(struct intel_atomic_state *state,
diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
index 2e4920d70105..97569423f430 100644
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -3266,7 +3266,6 @@  static void intel_enable_ddi(struct intel_atomic_state *state,
 
 	intel_hdcp_enable(state, encoder, crtc_state, conn_state);
 
-	encoder->audio_enable(encoder, crtc_state, conn_state);
 }
 
 static void intel_disable_ddi_dp(struct intel_atomic_state *state,
@@ -3308,8 +3307,6 @@  static void intel_disable_ddi(struct intel_atomic_state *state,
 			      const struct intel_crtc_state *old_crtc_state,
 			      const struct drm_connector_state *old_conn_state)
 {
-	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
-
 	intel_tc_port_link_cancel_reset_work(enc_to_dig_port(encoder));
 
 	intel_hdcp_disable(to_intel_connector(old_conn_state->connector));
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index ec76006b1756..d606befa007c 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -889,6 +889,48 @@  static bool needs_async_flip_vtd_wa(const struct intel_crtc_state *crtc_state)
 		(DISPLAY_VER(i915) == 9 || IS_BROADWELL(i915) || IS_HASWELL(i915));
 }
 
+static void intel_encoders_audio_enable(struct intel_atomic_state *state,
+					struct intel_crtc *crtc)
+{
+	const struct intel_crtc_state *crtc_state =
+		intel_atomic_get_new_crtc_state(state, crtc);
+	const struct drm_connector_state *conn_state;
+	struct drm_connector *conn;
+	int i;
+
+	for_each_new_connector_in_state(&state->base, conn, conn_state, i) {
+		struct intel_encoder *encoder =
+			to_intel_encoder(conn_state->best_encoder);
+
+		if (conn_state->crtc != &crtc->base)
+			continue;
+
+		if (encoder->audio_enable)
+			encoder->audio_enable(encoder, crtc_state, conn_state);
+	}
+}
+
+static void intel_encoders_audio_disable(struct intel_atomic_state *state,
+					 struct intel_crtc *crtc)
+{
+	const struct intel_crtc_state *old_crtc_state =
+		intel_atomic_get_old_crtc_state(state, crtc);
+	const struct drm_connector_state *old_conn_state;
+	struct drm_connector *conn;
+	int i;
+
+	for_each_old_connector_in_state(&state->base, conn, old_conn_state, i) {
+		struct intel_encoder *encoder =
+			to_intel_encoder(old_conn_state->best_encoder);
+
+		if (old_conn_state->crtc != &crtc->base)
+			continue;
+
+		if (encoder->audio_disable)
+			encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
+	}
+}
+
 #define is_enabling(feature, old_crtc_state, new_crtc_state) \
 	((!(old_crtc_state)->feature || intel_crtc_needs_modeset(new_crtc_state)) && \
 	 (new_crtc_state)->feature)
@@ -1461,6 +1503,7 @@  static void ilk_crtc_enable(struct intel_atomic_state *state,
 	intel_crtc_vblank_on(new_crtc_state);
 
 	intel_encoders_enable(state, crtc);
+	intel_encoders_audio_enable(state, crtc);
 
 	if (HAS_PCH_CPT(dev_priv))
 		intel_wait_for_pipe_scanline_moving(crtc);
@@ -1634,6 +1677,7 @@  static void hsw_crtc_enable(struct intel_atomic_state *state,
 		intel_crtc_vblank_on(new_crtc_state);
 
 	intel_encoders_enable(state, crtc);
+	intel_encoders_audio_enable(state, crtc);
 
 	if (psl_clkgate_wa) {
 		intel_crtc_wait_for_next_vblank(crtc);
@@ -1685,6 +1729,7 @@  static void ilk_crtc_disable(struct intel_atomic_state *state,
 	intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
 	intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, false);
 
+	intel_encoders_audio_disable(state, crtc);
 	intel_encoders_disable(state, crtc);
 
 	intel_crtc_vblank_off(old_crtc_state);
@@ -1719,6 +1764,7 @@  static void hsw_crtc_disable(struct intel_atomic_state *state,
 	 * Need care with mst->ddi interactions.
 	 */
 	if (!intel_crtc_is_bigjoiner_slave(old_crtc_state)) {
+		intel_encoders_audio_disable(state, crtc);
 		intel_encoders_disable(state, crtc);
 		intel_encoders_post_disable(state, crtc);
 	}
@@ -1988,6 +2034,7 @@  static void valleyview_crtc_enable(struct intel_atomic_state *state,
 	intel_crtc_vblank_on(new_crtc_state);
 
 	intel_encoders_enable(state, crtc);
+	intel_encoders_audio_enable(state, crtc);
 }
 
 static void i9xx_crtc_enable(struct intel_atomic_state *state,
@@ -2029,6 +2076,7 @@  static void i9xx_crtc_enable(struct intel_atomic_state *state,
 	intel_crtc_vblank_on(new_crtc_state);
 
 	intel_encoders_enable(state, crtc);
+	intel_encoders_audio_enable(state, crtc);
 
 	/* prevents spurious underruns */
 	if (DISPLAY_VER(dev_priv) == 2)
@@ -2065,6 +2113,7 @@  static void i9xx_crtc_disable(struct intel_atomic_state *state,
 	if (DISPLAY_VER(dev_priv) == 2)
 		intel_crtc_wait_for_next_vblank(crtc);
 
+	intel_encoders_audio_disable(state, crtc);
 	intel_encoders_disable(state, crtc);
 
 	intel_crtc_vblank_off(old_crtc_state);
diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
index 5f0ccab5ab1f..70ab93b3f141 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -608,8 +608,6 @@  static void intel_mst_disable_dp(struct intel_atomic_state *state,
 	drm_dbg_kms(&i915->drm, "active links %d\n",
 		    intel_dp->active_mst_links);
 
-	encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
-
 	intel_hdcp_disable(intel_mst->connector);
 }
 
@@ -845,8 +843,6 @@  static void intel_mst_enable_dp(struct intel_atomic_state *state,
 	intel_crtc_vblank_on(pipe_config);
 
 	intel_hdcp_enable(state, encoder, pipe_config, conn_state);
-
-	encoder->audio_enable(encoder, pipe_config, conn_state);
 }
 
 static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder,