drm/i915: Extract intel_hdmi_has_audio()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 4 Sep 2020 11:53:51 +0000 (14:53 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 17 Sep 2020 15:38:26 +0000 (18:38 +0300)
Pull the "do we want to enable audio?" computation into a small helper
to make intel_hdmi_compute_config() less messy. Will make it easier to
add more checks for this later (eg. we should actually be checking
at the hblank is long enough for audio transmission).

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200904115354.25336-16-ville.syrjala@linux.intel.com
Reviewed-by: Lyude Paul <lyude@redhat.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/display/intel_hdmi.c

index 40620c3..528d1ae 100644 (file)
@@ -2465,6 +2465,23 @@ bool intel_hdmi_limited_color_range(const struct intel_crtc_state *crtc_state,
        }
 }
 
+static bool intel_hdmi_has_audio(struct intel_encoder *encoder,
+                                const struct intel_crtc_state *crtc_state,
+                                const struct drm_connector_state *conn_state)
+{
+       struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
+       const struct intel_digital_connector_state *intel_conn_state =
+               to_intel_digital_connector_state(conn_state);
+
+       if (!crtc_state->has_hdmi_sink)
+               return false;
+
+       if (intel_conn_state->force_audio == HDMI_AUDIO_AUTO)
+               return intel_hdmi->has_audio;
+       else
+               return intel_conn_state->force_audio == HDMI_AUDIO_ON;
+}
+
 int intel_hdmi_compute_config(struct intel_encoder *encoder,
                              struct intel_crtc_state *pipe_config,
                              struct drm_connector_state *conn_state)
@@ -2474,8 +2491,6 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder,
        struct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode;
        struct drm_connector *connector = conn_state->connector;
        struct drm_scdc *scdc = &connector->display_info.hdmi.scdc;
-       struct intel_digital_connector_state *intel_conn_state =
-               to_intel_digital_connector_state(conn_state);
        int ret;
 
        if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)
@@ -2501,13 +2516,8 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder,
        if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv))
                pipe_config->has_pch_encoder = true;
 
-       if (pipe_config->has_hdmi_sink) {
-               if (intel_conn_state->force_audio == HDMI_AUDIO_AUTO)
-                       pipe_config->has_audio = intel_hdmi->has_audio;
-               else
-                       pipe_config->has_audio =
-                               intel_conn_state->force_audio == HDMI_AUDIO_ON;
-       }
+       pipe_config->has_audio =
+               intel_hdmi_has_audio(encoder, pipe_config, conn_state);
 
        ret = intel_hdmi_compute_clock(encoder, pipe_config);
        if (ret)