Merge tag 'drm-intel-next-2017-03-06' of git://anongit.freedesktop.org/git/drm-intel...
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / drivers / gpu / drm / i915 / intel_audio.c
index 1ab401faed34a9b262d58bbbbafe41cc6064317f..52c207e81f413a4465bec60098fedf09efea59cb 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/kernel.h>
 #include <linux/component.h>
 #include <drm/i915_component.h>
+#include <drm/intel_lpe_audio.h>
 #include "intel_drv.h"
 
 #include <drm/drmP.h>
@@ -623,13 +624,28 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder,
        dev_priv->av_enc_map[pipe] = intel_encoder;
        mutex_unlock(&dev_priv->av_mutex);
 
-       /* audio drivers expect pipe = -1 to indicate Non-MST cases */
-       if (intel_encoder->type != INTEL_OUTPUT_DP_MST)
-               pipe = -1;
-
-       if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
+       if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) {
+               /* audio drivers expect pipe = -1 to indicate Non-MST cases */
+               if (intel_encoder->type != INTEL_OUTPUT_DP_MST)
+                       pipe = -1;
                acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
                                                 (int) port, (int) pipe);
+       }
+
+       switch (intel_encoder->type) {
+       case INTEL_OUTPUT_HDMI:
+               intel_lpe_audio_notify(dev_priv, connector->eld, port, pipe,
+                                      crtc_state->port_clock,
+                                      false, 0);
+               break;
+       case INTEL_OUTPUT_DP:
+               intel_lpe_audio_notify(dev_priv, connector->eld, port, pipe,
+                                      adjusted_mode->crtc_clock,
+                                      true, crtc_state->port_clock);
+               break;
+       default:
+               break;
+       }
 }
 
 /**
@@ -656,13 +672,15 @@ void intel_audio_codec_disable(struct intel_encoder *intel_encoder)
        dev_priv->av_enc_map[pipe] = NULL;
        mutex_unlock(&dev_priv->av_mutex);
 
-       /* audio drivers expect pipe = -1 to indicate Non-MST cases */
-       if (intel_encoder->type != INTEL_OUTPUT_DP_MST)
-               pipe = -1;
-
-       if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
+       if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify) {
+               /* audio drivers expect pipe = -1 to indicate Non-MST cases */
+               if (intel_encoder->type != INTEL_OUTPUT_DP_MST)
+                       pipe = -1;
                acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
                                                 (int) port, (int) pipe);
+       }
+
+       intel_lpe_audio_notify(dev_priv, NULL, port, pipe, 0, false, 0);
 }
 
 /**
@@ -956,3 +974,28 @@ void i915_audio_component_cleanup(struct drm_i915_private *dev_priv)
        component_del(dev_priv->drm.dev, &i915_audio_component_bind_ops);
        dev_priv->audio_component_registered = false;
 }
+
+/**
+ * intel_audio_init() - Initialize the audio driver either using
+ * component framework or using lpe audio bridge
+ * @dev_priv: the i915 drm device private data
+ *
+ */
+void intel_audio_init(struct drm_i915_private *dev_priv)
+{
+       if (intel_lpe_audio_init(dev_priv) < 0)
+               i915_audio_component_init(dev_priv);
+}
+
+/**
+ * intel_audio_deinit() - deinitialize the audio driver
+ * @dev_priv: the i915 drm device private data
+ *
+ */
+void intel_audio_deinit(struct drm_i915_private *dev_priv)
+{
+       if ((dev_priv)->lpe_audio.platdev != NULL)
+               intel_lpe_audio_teardown(dev_priv);
+       else
+               i915_audio_component_cleanup(dev_priv);
+}