Commit 3654a48a authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Convert audio enable/disable into encoder vfuncs

Add encoder vfuncs for audio enable/disable. This will allow
audio to be enabled/disabled during fastsets. An encoder hook
is necessary as on pre-hsw platforms different encoder types
implement audio in different ways.
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231121054324.9988-9-ville.syrjala@linux.intel.com
parent 4645e898
...@@ -516,7 +516,7 @@ static void intel_disable_dp(struct intel_atomic_state *state, ...@@ -516,7 +516,7 @@ static void intel_disable_dp(struct intel_atomic_state *state,
{ {
struct intel_dp *intel_dp = enc_to_intel_dp(encoder); struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
g4x_dp_audio_disable(encoder, old_crtc_state, old_conn_state); encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
intel_dp->link_trained = false; intel_dp->link_trained = false;
...@@ -719,7 +719,7 @@ static void g4x_enable_dp(struct intel_atomic_state *state, ...@@ -719,7 +719,7 @@ static void g4x_enable_dp(struct intel_atomic_state *state,
{ {
intel_enable_dp(state, encoder, pipe_config, conn_state); intel_enable_dp(state, encoder, pipe_config, conn_state);
intel_edp_backlight_on(pipe_config, conn_state); intel_edp_backlight_on(pipe_config, conn_state);
g4x_dp_audio_enable(encoder, pipe_config, conn_state); encoder->audio_enable(encoder, pipe_config, conn_state);
} }
static void vlv_enable_dp(struct intel_atomic_state *state, static void vlv_enable_dp(struct intel_atomic_state *state,
...@@ -728,7 +728,7 @@ static void vlv_enable_dp(struct intel_atomic_state *state, ...@@ -728,7 +728,7 @@ static void vlv_enable_dp(struct intel_atomic_state *state,
const struct drm_connector_state *conn_state) const struct drm_connector_state *conn_state)
{ {
intel_edp_backlight_on(pipe_config, conn_state); intel_edp_backlight_on(pipe_config, conn_state);
g4x_dp_audio_enable(encoder, pipe_config, conn_state); encoder->audio_enable(encoder, pipe_config, conn_state);
} }
static void g4x_pre_enable_dp(struct intel_atomic_state *state, static void g4x_pre_enable_dp(struct intel_atomic_state *state,
...@@ -1357,6 +1357,8 @@ bool g4x_dp_init(struct drm_i915_private *dev_priv, ...@@ -1357,6 +1357,8 @@ bool g4x_dp_init(struct drm_i915_private *dev_priv,
intel_encoder->disable = g4x_disable_dp; intel_encoder->disable = g4x_disable_dp;
intel_encoder->post_disable = g4x_post_disable_dp; intel_encoder->post_disable = g4x_post_disable_dp;
} }
intel_encoder->audio_enable = g4x_dp_audio_enable;
intel_encoder->audio_disable = g4x_dp_audio_disable;
if ((IS_IVYBRIDGE(dev_priv) && port == PORT_A) || if ((IS_IVYBRIDGE(dev_priv) && port == PORT_A) ||
(HAS_PCH_CPT(dev_priv) && port != PORT_A)) (HAS_PCH_CPT(dev_priv) && port != PORT_A))
......
...@@ -274,7 +274,7 @@ static void g4x_enable_hdmi(struct intel_atomic_state *state, ...@@ -274,7 +274,7 @@ static void g4x_enable_hdmi(struct intel_atomic_state *state,
{ {
g4x_hdmi_enable_port(encoder, pipe_config); g4x_hdmi_enable_port(encoder, pipe_config);
g4x_hdmi_audio_enable(encoder, pipe_config, conn_state); encoder->audio_enable(encoder, pipe_config, conn_state);
} }
static void ibx_enable_hdmi(struct intel_atomic_state *state, static void ibx_enable_hdmi(struct intel_atomic_state *state,
...@@ -323,7 +323,7 @@ static void ibx_enable_hdmi(struct intel_atomic_state *state, ...@@ -323,7 +323,7 @@ static void ibx_enable_hdmi(struct intel_atomic_state *state,
intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg); intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg);
} }
g4x_hdmi_audio_enable(encoder, pipe_config, conn_state); encoder->audio_enable(encoder, pipe_config, conn_state);
} }
static void cpt_enable_hdmi(struct intel_atomic_state *state, static void cpt_enable_hdmi(struct intel_atomic_state *state,
...@@ -374,7 +374,7 @@ static void cpt_enable_hdmi(struct intel_atomic_state *state, ...@@ -374,7 +374,7 @@ static void cpt_enable_hdmi(struct intel_atomic_state *state,
TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE, 0); TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE, 0);
} }
g4x_hdmi_audio_enable(encoder, pipe_config, conn_state); encoder->audio_enable(encoder, pipe_config, conn_state);
} }
static void vlv_enable_hdmi(struct intel_atomic_state *state, static void vlv_enable_hdmi(struct intel_atomic_state *state,
...@@ -382,7 +382,7 @@ static void vlv_enable_hdmi(struct intel_atomic_state *state, ...@@ -382,7 +382,7 @@ static void vlv_enable_hdmi(struct intel_atomic_state *state,
const struct intel_crtc_state *pipe_config, const struct intel_crtc_state *pipe_config,
const struct drm_connector_state *conn_state) const struct drm_connector_state *conn_state)
{ {
g4x_hdmi_audio_enable(encoder, pipe_config, conn_state); encoder->audio_enable(encoder, pipe_config, conn_state);
} }
static void intel_disable_hdmi(struct intel_atomic_state *state, static void intel_disable_hdmi(struct intel_atomic_state *state,
...@@ -449,7 +449,7 @@ static void g4x_disable_hdmi(struct intel_atomic_state *state, ...@@ -449,7 +449,7 @@ static void g4x_disable_hdmi(struct intel_atomic_state *state,
const struct intel_crtc_state *old_crtc_state, const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state) const struct drm_connector_state *old_conn_state)
{ {
g4x_hdmi_audio_disable(encoder, old_crtc_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); intel_disable_hdmi(state, encoder, old_crtc_state, old_conn_state);
} }
...@@ -459,7 +459,7 @@ static void pch_disable_hdmi(struct intel_atomic_state *state, ...@@ -459,7 +459,7 @@ static void pch_disable_hdmi(struct intel_atomic_state *state,
const struct intel_crtc_state *old_crtc_state, const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state) const struct drm_connector_state *old_conn_state)
{ {
g4x_hdmi_audio_disable(encoder, old_crtc_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, static void pch_post_disable_hdmi(struct intel_atomic_state *state,
...@@ -766,6 +766,8 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv, ...@@ -766,6 +766,8 @@ void g4x_hdmi_init(struct drm_i915_private *dev_priv,
else else
intel_encoder->enable = g4x_enable_hdmi; intel_encoder->enable = g4x_enable_hdmi;
} }
intel_encoder->audio_enable = g4x_hdmi_audio_enable;
intel_encoder->audio_disable = g4x_hdmi_audio_disable;
intel_encoder->shutdown = intel_hdmi_encoder_shutdown; intel_encoder->shutdown = intel_hdmi_encoder_shutdown;
intel_encoder->type = INTEL_OUTPUT_HDMI; intel_encoder->type = INTEL_OUTPUT_HDMI;
......
...@@ -3359,7 +3359,7 @@ static void intel_enable_ddi(struct intel_atomic_state *state, ...@@ -3359,7 +3359,7 @@ static void intel_enable_ddi(struct intel_atomic_state *state,
intel_hdcp_enable(state, encoder, crtc_state, conn_state); intel_hdcp_enable(state, encoder, crtc_state, conn_state);
intel_audio_codec_enable(encoder, crtc_state, conn_state); encoder->audio_enable(encoder, crtc_state, conn_state);
} }
static void intel_disable_ddi_dp(struct intel_atomic_state *state, static void intel_disable_ddi_dp(struct intel_atomic_state *state,
...@@ -3403,7 +3403,7 @@ static void intel_disable_ddi(struct intel_atomic_state *state, ...@@ -3403,7 +3403,7 @@ static void intel_disable_ddi(struct intel_atomic_state *state,
const struct intel_crtc_state *old_crtc_state, const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state) const struct drm_connector_state *old_conn_state)
{ {
intel_audio_codec_disable(encoder, old_crtc_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_tc_port_link_cancel_reset_work(enc_to_dig_port(encoder));
...@@ -4936,6 +4936,8 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, ...@@ -4936,6 +4936,8 @@ void intel_ddi_init(struct drm_i915_private *dev_priv,
encoder->post_pll_disable = intel_ddi_post_pll_disable; encoder->post_pll_disable = intel_ddi_post_pll_disable;
encoder->post_disable = intel_ddi_post_disable; encoder->post_disable = intel_ddi_post_disable;
encoder->update_pipe = intel_ddi_update_pipe; encoder->update_pipe = intel_ddi_update_pipe;
encoder->audio_enable = intel_audio_codec_enable;
encoder->audio_disable = intel_audio_codec_disable;
encoder->get_hw_state = intel_ddi_get_hw_state; encoder->get_hw_state = intel_ddi_get_hw_state;
encoder->sync_state = intel_ddi_sync_state; encoder->sync_state = intel_ddi_sync_state;
encoder->initial_fastset_check = intel_ddi_initial_fastset_check; encoder->initial_fastset_check = intel_ddi_initial_fastset_check;
......
...@@ -198,6 +198,12 @@ struct intel_encoder { ...@@ -198,6 +198,12 @@ struct intel_encoder {
struct intel_encoder *, struct intel_encoder *,
const struct intel_crtc_state *, const struct intel_crtc_state *,
const struct drm_connector_state *); const struct drm_connector_state *);
void (*audio_enable)(struct intel_encoder *encoder,
const struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state);
void (*audio_disable)(struct intel_encoder *encoder,
const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state);
/* Read out the current hw state of this connector, returning true if /* Read out the current hw state of this connector, returning true if
* the encoder is active. If the encoder is enabled it also set the pipe * the encoder is active. If the encoder is enabled it also set the pipe
* it is connected to in the pipe parameter. */ * it is connected to in the pipe parameter. */
......
...@@ -918,7 +918,7 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state, ...@@ -918,7 +918,7 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state,
drm_dbg_kms(&i915->drm, "active links %d\n", drm_dbg_kms(&i915->drm, "active links %d\n",
intel_dp->active_mst_links); intel_dp->active_mst_links);
intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state); encoder->audio_disable(encoder, old_crtc_state, old_conn_state);
intel_hdcp_disable(intel_mst->connector); intel_hdcp_disable(intel_mst->connector);
...@@ -1166,7 +1166,7 @@ static void intel_mst_enable_dp(struct intel_atomic_state *state, ...@@ -1166,7 +1166,7 @@ static void intel_mst_enable_dp(struct intel_atomic_state *state,
intel_hdcp_enable(state, encoder, pipe_config, conn_state); intel_hdcp_enable(state, encoder, pipe_config, conn_state);
intel_audio_codec_enable(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, static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder,
...@@ -1626,6 +1626,8 @@ intel_dp_create_fake_mst_encoder(struct intel_digital_port *dig_port, enum pipe ...@@ -1626,6 +1626,8 @@ intel_dp_create_fake_mst_encoder(struct intel_digital_port *dig_port, enum pipe
intel_encoder->pre_pll_enable = intel_mst_pre_pll_enable_dp; intel_encoder->pre_pll_enable = intel_mst_pre_pll_enable_dp;
intel_encoder->pre_enable = intel_mst_pre_enable_dp; intel_encoder->pre_enable = intel_mst_pre_enable_dp;
intel_encoder->enable = intel_mst_enable_dp; intel_encoder->enable = intel_mst_enable_dp;
intel_encoder->audio_enable = intel_audio_codec_enable;
intel_encoder->audio_disable = intel_audio_codec_disable;
intel_encoder->get_hw_state = intel_dp_mst_enc_get_hw_state; intel_encoder->get_hw_state = intel_dp_mst_enc_get_hw_state;
intel_encoder->get_config = intel_dp_mst_enc_get_config; intel_encoder->get_config = intel_dp_mst_enc_get_config;
intel_encoder->initial_fastset_check = intel_dp_mst_initial_fastset_check; intel_encoder->initial_fastset_check = intel_dp_mst_initial_fastset_check;
......
...@@ -1787,17 +1787,28 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, ...@@ -1787,17 +1787,28 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
intel_sdvo_get_eld(intel_sdvo, pipe_config); intel_sdvo_get_eld(intel_sdvo, pipe_config);
} }
static void intel_sdvo_disable_audio(struct intel_sdvo *intel_sdvo) static void intel_sdvo_disable_audio(struct intel_encoder *encoder,
const struct intel_crtc_state *old_crtc_state,
const struct drm_connector_state *old_conn_state)
{ {
struct intel_sdvo *intel_sdvo = to_sdvo(encoder);
if (!old_crtc_state->has_audio)
return;
intel_sdvo_set_audio_state(intel_sdvo, 0); intel_sdvo_set_audio_state(intel_sdvo, 0);
} }
static void intel_sdvo_enable_audio(struct intel_sdvo *intel_sdvo, static void intel_sdvo_enable_audio(struct intel_encoder *encoder,
const struct intel_crtc_state *crtc_state, const struct intel_crtc_state *crtc_state,
const struct drm_connector_state *conn_state) const struct drm_connector_state *conn_state)
{ {
struct intel_sdvo *intel_sdvo = to_sdvo(encoder);
const u8 *eld = crtc_state->eld; const u8 *eld = crtc_state->eld;
if (!crtc_state->has_audio)
return;
intel_sdvo_set_audio_state(intel_sdvo, 0); intel_sdvo_set_audio_state(intel_sdvo, 0);
intel_sdvo_write_infoframe(intel_sdvo, SDVO_HBUF_INDEX_ELD, intel_sdvo_write_infoframe(intel_sdvo, SDVO_HBUF_INDEX_ELD,
...@@ -1818,8 +1829,7 @@ static void intel_disable_sdvo(struct intel_atomic_state *state, ...@@ -1818,8 +1829,7 @@ static void intel_disable_sdvo(struct intel_atomic_state *state,
struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc); struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc);
u32 temp; u32 temp;
if (old_crtc_state->has_audio) encoder->audio_disable(encoder, old_crtc_state, conn_state);
intel_sdvo_disable_audio(intel_sdvo);
intel_sdvo_set_active_outputs(intel_sdvo, 0); intel_sdvo_set_active_outputs(intel_sdvo, 0);
if (0) if (0)
...@@ -1913,8 +1923,7 @@ static void intel_enable_sdvo(struct intel_atomic_state *state, ...@@ -1913,8 +1923,7 @@ static void intel_enable_sdvo(struct intel_atomic_state *state,
DRM_MODE_DPMS_ON); DRM_MODE_DPMS_ON);
intel_sdvo_set_active_outputs(intel_sdvo, intel_sdvo_connector->output_flag); intel_sdvo_set_active_outputs(intel_sdvo, intel_sdvo_connector->output_flag);
if (pipe_config->has_audio) encoder->audio_enable(encoder, pipe_config, conn_state);
intel_sdvo_enable_audio(intel_sdvo, pipe_config, conn_state);
} }
static enum drm_mode_status static enum drm_mode_status
...@@ -3390,6 +3399,8 @@ bool intel_sdvo_init(struct drm_i915_private *dev_priv, ...@@ -3390,6 +3399,8 @@ bool intel_sdvo_init(struct drm_i915_private *dev_priv,
} }
intel_encoder->pre_enable = intel_sdvo_pre_enable; intel_encoder->pre_enable = intel_sdvo_pre_enable;
intel_encoder->enable = intel_enable_sdvo; intel_encoder->enable = intel_enable_sdvo;
intel_encoder->audio_enable = intel_sdvo_enable_audio;
intel_encoder->audio_disable = intel_sdvo_disable_audio;
intel_encoder->get_hw_state = intel_sdvo_get_hw_state; intel_encoder->get_hw_state = intel_sdvo_get_hw_state;
intel_encoder->get_config = intel_sdvo_get_config; intel_encoder->get_config = intel_sdvo_get_config;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment