]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915/dp: Extract intel_dp_has_audio()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 22 Mar 2022 12:00:06 +0000 (14:00 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 5 Apr 2022 08:13:40 +0000 (11:13 +0300)
Declutter intel_dp_compute_config() a bit by moving the
has_audio computation into a helper. HDMI already does the same thing.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220322120015.28074-4-ville.syrjala@linux.intel.com
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
drivers/gpu/drm/i915/display/intel_dp.c

index 186b50aa87df2f173287c2a6712c126a34e71aea..a05c62cc8292463c029da728fd03ff9ebdabaf32 100644 (file)
@@ -1849,6 +1849,24 @@ intel_dp_drrs_compute_config(struct intel_connector *connector,
                pipe_config->dp_m2_n2.data_m *= pipe_config->splitter.link_count;
 }
 
+static bool intel_dp_has_audio(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);
+       struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
+       const struct intel_digital_connector_state *intel_conn_state =
+               to_intel_digital_connector_state(conn_state);
+
+       if (!intel_dp_port_has_audio(i915, encoder->port))
+               return false;
+
+       if (intel_conn_state->force_audio == HDMI_AUDIO_AUTO)
+               return intel_dp->has_audio;
+       else
+               return intel_conn_state->force_audio == HDMI_AUDIO_ON;
+}
+
 int
 intel_dp_compute_config(struct intel_encoder *encoder,
                        struct intel_crtc_state *pipe_config,
@@ -1858,14 +1876,11 @@ intel_dp_compute_config(struct intel_encoder *encoder,
        struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode;
        struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
        const struct drm_display_mode *fixed_mode;
-       enum port port = encoder->port;
        struct intel_connector *intel_connector = intel_dp->attached_connector;
-       struct intel_digital_connector_state *intel_conn_state =
-               to_intel_digital_connector_state(conn_state);
        bool constant_n = drm_dp_has_quirk(&intel_dp->desc, DP_DPCD_QUIRK_CONSTANT_N);
        int ret = 0, output_bpp;
 
-       if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv) && port != PORT_A)
+       if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv) && encoder->port != PORT_A)
                pipe_config->has_pch_encoder = true;
 
        pipe_config->output_format = intel_dp_output_format(&intel_connector->base,
@@ -1877,12 +1892,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
                        return ret;
        }
 
-       if (!intel_dp_port_has_audio(dev_priv, port))
-               pipe_config->has_audio = false;
-       else if (intel_conn_state->force_audio == HDMI_AUDIO_AUTO)
-               pipe_config->has_audio = intel_dp->has_audio;
-       else
-               pipe_config->has_audio = intel_conn_state->force_audio == HDMI_AUDIO_ON;
+       pipe_config->has_audio = intel_dp_has_audio(encoder, pipe_config, conn_state);
 
        fixed_mode = intel_panel_fixed_mode(intel_connector, adjusted_mode);
        if (intel_dp_is_edp(intel_dp) && fixed_mode) {