drm/i915: Split g4x+ HDMI audio presence detect from port enable
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 21 Nov 2023 05:43:20 +0000 (07:43 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 23 Nov 2023 12:33:20 +0000 (14:33 +0200)
Follow the hsw+ approach toggle the audio presence detect
when we set up the ELD, instead of doing it when turning the
port on/off.

This will facilitate audio enable/disable to happen during
fastsets instead of requiring a full modeset.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231121054324.9988-8-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/g4x_hdmi.c

index 9c70245d8b0a4b80da80e16336b42480c2343ed2..beda6b480bf1c37ec6ceed85165d90f7e0ce1dd5 100644 (file)
@@ -228,8 +228,6 @@ static void g4x_hdmi_enable_port(struct intel_encoder *encoder,
        temp = intel_de_read(dev_priv, intel_hdmi->hdmi_reg);
 
        temp |= SDVO_ENABLE;
-       if (pipe_config->has_audio)
-               temp |= HDMI_AUDIO_ENABLE;
 
        intel_de_write(dev_priv, intel_hdmi->hdmi_reg, temp);
        intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg);
@@ -240,12 +238,16 @@ static void g4x_hdmi_audio_enable(struct intel_encoder *encoder,
                                  const struct drm_connector_state *conn_state)
 {
        struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+       struct intel_hdmi *hdmi = enc_to_intel_hdmi(encoder);
 
        if (!crtc_state->has_audio)
                return;
 
        drm_WARN_ON(&i915->drm, !crtc_state->has_hdmi_sink);
 
+       /* Enable audio presence detect */
+       intel_de_rmw(i915, hdmi->hdmi_reg, 0, HDMI_AUDIO_ENABLE);
+
        intel_audio_codec_enable(encoder, crtc_state, conn_state);
 }
 
@@ -253,10 +255,16 @@ static void g4x_hdmi_audio_disable(struct intel_encoder *encoder,
                                   const struct intel_crtc_state *old_crtc_state,
                                   const struct drm_connector_state *old_conn_state)
 {
+       struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+       struct intel_hdmi *hdmi = enc_to_intel_hdmi(encoder);
+
        if (!old_crtc_state->has_audio)
                return;
 
        intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state);
+
+       /* Disable audio presence detect */
+       intel_de_rmw(i915, hdmi->hdmi_reg, HDMI_AUDIO_ENABLE, 0);
 }
 
 static void g4x_enable_hdmi(struct intel_atomic_state *state,
@@ -282,8 +290,6 @@ static void ibx_enable_hdmi(struct intel_atomic_state *state,
        temp = intel_de_read(dev_priv, intel_hdmi->hdmi_reg);
 
        temp |= SDVO_ENABLE;
-       if (pipe_config->has_audio)
-               temp |= HDMI_AUDIO_ENABLE;
 
        /*
         * HW workaround, need to write this twice for issue
@@ -335,8 +341,6 @@ static void cpt_enable_hdmi(struct intel_atomic_state *state,
        temp = intel_de_read(dev_priv, intel_hdmi->hdmi_reg);
 
        temp |= SDVO_ENABLE;
-       if (pipe_config->has_audio)
-               temp |= HDMI_AUDIO_ENABLE;
 
        /*
         * WaEnableHDMI8bpcBefore12bpc:snb,ivb
@@ -396,7 +400,7 @@ static void intel_disable_hdmi(struct intel_atomic_state *state,
 
        temp = intel_de_read(dev_priv, intel_hdmi->hdmi_reg);
 
-       temp &= ~(SDVO_ENABLE | HDMI_AUDIO_ENABLE);
+       temp &= ~SDVO_ENABLE;
        intel_de_write(dev_priv, intel_hdmi->hdmi_reg, temp);
        intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg);