]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/drm/i915/intel_audio.c
Merge tag 'drm-for-v4.11-less-shouty' of git://people.freedesktop.org/~airlied/linux
[karo-tx-linux.git] / drivers / gpu / drm / i915 / intel_audio.c
index 892169b7952b09647757e4116b890de72810989d..d76f3033e890b6da60ae6b017dab311e9a29c8da 100644 (file)
@@ -755,25 +755,49 @@ static int i915_audio_component_get_cdclk_freq(struct device *kdev)
        return dev_priv->cdclk_freq;
 }
 
+/*
+ * get the intel_encoder according to the parameter port and pipe
+ * intel_encoder is saved by the index of pipe
+ * MST & (pipe >= 0): return the av_enc_map[pipe],
+ *   when port is matched
+ * MST & (pipe < 0): this is invalid
+ * Non-MST & (pipe >= 0): only pipe = 0 (the first device entry)
+ *   will get the right intel_encoder with port matched
+ * Non-MST & (pipe < 0): get the right intel_encoder with port matched
+ */
 static struct intel_encoder *get_saved_enc(struct drm_i915_private *dev_priv,
                                               int port, int pipe)
 {
+       struct intel_encoder *encoder;
 
        if (WARN_ON(pipe >= I915_MAX_PIPES))
                return NULL;
 
        /* MST */
-       if (pipe >= 0)
-               return dev_priv->av_enc_map[pipe];
+       if (pipe >= 0) {
+               encoder = dev_priv->av_enc_map[pipe];
+               /*
+                * when bootup, audio driver may not know it is
+                * MST or not. So it will poll all the port & pipe
+                * combinations
+                */
+               if (encoder != NULL && encoder->port == port &&
+                   encoder->type == INTEL_OUTPUT_DP_MST)
+                       return encoder;
+       }
 
        /* Non-MST */
-       for_each_pipe(dev_priv, pipe) {
-               struct intel_encoder *encoder;
+       if (pipe > 0)
+               return NULL;
 
+       for_each_pipe(dev_priv, pipe) {
                encoder = dev_priv->av_enc_map[pipe];
                if (encoder == NULL)
                        continue;
 
+               if (encoder->type == INTEL_OUTPUT_DP_MST)
+                       continue;
+
                if (port == encoder->port)
                        return encoder;
        }
@@ -799,9 +823,7 @@ static int i915_audio_component_sync_audio_rate(struct device *kdev, int port,
 
        /* 1. get the pipe */
        intel_encoder = get_saved_enc(dev_priv, port, pipe);
-       if (!intel_encoder || !intel_encoder->base.crtc ||
-           (intel_encoder->type != INTEL_OUTPUT_HDMI &&
-            intel_encoder->type != INTEL_OUTPUT_DP)) {
+       if (!intel_encoder || !intel_encoder->base.crtc) {
                DRM_DEBUG_KMS("Not valid for port %c\n", port_name(port));
                err = -ENODEV;
                goto unlock;
@@ -924,6 +946,9 @@ void i915_audio_component_init(struct drm_i915_private *dev_priv)
 {
        int ret;
 
+       if (INTEL_INFO(dev_priv)->num_pipes == 0)
+               return;
+
        ret = component_add(dev_priv->drm.dev, &i915_audio_component_bind_ops);
        if (ret < 0) {
                DRM_ERROR("failed to add audio component (%d)\n", ret);