]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915: Wrap g4x+ DP/HDMI audio enable/disable
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 21 Nov 2023 05:43:18 +0000 (07:43 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 23 Nov 2023 12:33:15 +0000 (14:33 +0200)
Put a wrapper around the intel_audio_codec_{enable,disable}()
calls in the g4x+ DP/HDMI code. We shall move the presence
detect enable/disable into the wrappers later.

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-6-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/g4x_dp.c
drivers/gpu/drm/i915/display/g4x_hdmi.c

index 79ef2b435bebd015bc7babd89eb91598e3b8b57c..ecc2ec866424557f37ddcd3feef14610c6bf2b1a 100644 (file)
@@ -475,6 +475,26 @@ intel_dp_link_down(struct intel_encoder *encoder,
        }
 }
 
+static void g4x_dp_audio_enable(struct intel_encoder *encoder,
+                               const struct intel_crtc_state *crtc_state,
+                               const struct drm_connector_state *conn_state)
+{
+       if (!crtc_state->has_audio)
+               return;
+
+       intel_audio_codec_enable(encoder, crtc_state, conn_state);
+}
+
+static void g4x_dp_audio_disable(struct intel_encoder *encoder,
+                                const struct intel_crtc_state *old_crtc_state,
+                                const struct drm_connector_state *old_conn_state)
+{
+       if (!old_crtc_state->has_audio)
+               return;
+
+       intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state);
+}
+
 static void intel_disable_dp(struct intel_atomic_state *state,
                             struct intel_encoder *encoder,
                             const struct intel_crtc_state *old_crtc_state,
@@ -482,7 +502,7 @@ static void intel_disable_dp(struct intel_atomic_state *state,
 {
        struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
 
-       intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state);
+       g4x_dp_audio_disable(encoder, old_crtc_state, old_conn_state);
 
        intel_dp->link_trained = false;
 
@@ -687,7 +707,7 @@ static void g4x_enable_dp(struct intel_atomic_state *state,
 {
        intel_enable_dp(state, encoder, pipe_config, conn_state);
        intel_edp_backlight_on(pipe_config, conn_state);
-       intel_audio_codec_enable(encoder, pipe_config, conn_state);
+       g4x_dp_audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void vlv_enable_dp(struct intel_atomic_state *state,
@@ -696,7 +716,7 @@ static void vlv_enable_dp(struct intel_atomic_state *state,
                          const struct drm_connector_state *conn_state)
 {
        intel_edp_backlight_on(pipe_config, conn_state);
-       intel_audio_codec_enable(encoder, pipe_config, conn_state);
+       g4x_dp_audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void g4x_pre_enable_dp(struct intel_atomic_state *state,
index 45e044b4a88dbf45fbe5431fd7f1dfdbd5da4c75..9c70245d8b0a4b80da80e16336b42480c2343ed2 100644 (file)
@@ -235,18 +235,38 @@ static void g4x_hdmi_enable_port(struct intel_encoder *encoder,
        intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg);
 }
 
+static void g4x_hdmi_audio_enable(struct intel_encoder *encoder,
+                                 const struct intel_crtc_state *crtc_state,
+                                 const struct drm_connector_state *conn_state)
+{
+       struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+
+       if (!crtc_state->has_audio)
+               return;
+
+       drm_WARN_ON(&i915->drm, !crtc_state->has_hdmi_sink);
+
+       intel_audio_codec_enable(encoder, crtc_state, conn_state);
+}
+
+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)
+{
+       if (!old_crtc_state->has_audio)
+               return;
+
+       intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state);
+}
+
 static void g4x_enable_hdmi(struct intel_atomic_state *state,
                            struct intel_encoder *encoder,
                            const struct intel_crtc_state *pipe_config,
                            const struct drm_connector_state *conn_state)
 {
-       struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
-
        g4x_hdmi_enable_port(encoder, pipe_config);
 
-       drm_WARN_ON(&dev_priv->drm, pipe_config->has_audio &&
-                   !pipe_config->has_hdmi_sink);
-       intel_audio_codec_enable(encoder, pipe_config, conn_state);
+       g4x_hdmi_audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void ibx_enable_hdmi(struct intel_atomic_state *state,
@@ -297,9 +317,7 @@ static void ibx_enable_hdmi(struct intel_atomic_state *state,
                intel_de_posting_read(dev_priv, intel_hdmi->hdmi_reg);
        }
 
-       drm_WARN_ON(&dev_priv->drm, pipe_config->has_audio &&
-                   !pipe_config->has_hdmi_sink);
-       intel_audio_codec_enable(encoder, pipe_config, conn_state);
+       g4x_hdmi_audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void cpt_enable_hdmi(struct intel_atomic_state *state,
@@ -352,9 +370,7 @@ static void cpt_enable_hdmi(struct intel_atomic_state *state,
                             TRANS_CHICKEN1_HDMIUNIT_GC_DISABLE, 0);
        }
 
-       drm_WARN_ON(&dev_priv->drm, pipe_config->has_audio &&
-                   !pipe_config->has_hdmi_sink);
-       intel_audio_codec_enable(encoder, pipe_config, conn_state);
+       g4x_hdmi_audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void vlv_enable_hdmi(struct intel_atomic_state *state,
@@ -362,11 +378,7 @@ static void vlv_enable_hdmi(struct intel_atomic_state *state,
                            const struct intel_crtc_state *pipe_config,
                            const struct drm_connector_state *conn_state)
 {
-       struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
-
-       drm_WARN_ON(&dev_priv->drm, pipe_config->has_audio &&
-                   !pipe_config->has_hdmi_sink);
-       intel_audio_codec_enable(encoder, pipe_config, conn_state);
+       g4x_hdmi_audio_enable(encoder, pipe_config, conn_state);
 }
 
 static void intel_disable_hdmi(struct intel_atomic_state *state,
@@ -433,7 +445,7 @@ 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)
 {
-       intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state);
+       g4x_hdmi_audio_disable(encoder, old_crtc_state, old_conn_state);
 
        intel_disable_hdmi(state, encoder, old_crtc_state, old_conn_state);
 }
@@ -443,7 +455,7 @@ 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)
 {
-       intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state);
+       g4x_hdmi_audio_disable(encoder, old_crtc_state, old_conn_state);
 }
 
 static void pch_post_disable_hdmi(struct intel_atomic_state *state,