drm/i915: Add support for audio driver notifications
authorJerome Anand <jerome.anand@intel.com>
Tue, 24 Jan 2017 22:57:50 +0000 (04:27 +0530)
committerTakashi Iwai <tiwai@suse.de>
Wed, 25 Jan 2017 13:23:12 +0000 (14:23 +0100)
Notifiations like mode change, hot plug and edid to
the audio driver are added. This is inturn used by the
audio driver for its functionality.

A new interface file capturing the notifications needed by the
audio driver is added

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jerome Anand <jerome.anand@intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_audio.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_lpe_audio.c

index c55bf144c4e2e8309b5d1aa00f045e5da41354b5..3e3102cedc824f98bfe2ba23d7fc8b117f3701f8 100644 (file)
@@ -3400,6 +3400,8 @@ void i915_teardown_sysfs(struct drm_i915_private *dev_priv);
 int  intel_lpe_audio_init(struct drm_i915_private *dev_priv);
 void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv);
 void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv);
+void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
+                       void *eld, int port, int tmds_clk_speed);
 
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_device *dev);
index 1e93263b4c871c5c150b67cf388fa3f25a3ccfa1..364f96207c4000b34084a060438077cb363caac9 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>
@@ -630,6 +631,9 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder,
        if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
                acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
                                                 (int) port, (int) pipe);
+
+       intel_lpe_audio_notify(dev_priv, connector->eld, port,
+                       crtc_state->port_clock);
 }
 
 /**
@@ -663,6 +667,8 @@ void intel_audio_codec_disable(struct intel_encoder *intel_encoder)
        if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
                acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
                                                 (int) port, (int) pipe);
+
+       intel_lpe_audio_notify(dev_priv, NULL, port, 0);
 }
 
 /**
index fb88e32e25a3de7831b7b61f00f6a463e51698fa..02d50e334ac621adfd3b1dfd4620f90ba18e6876 100644 (file)
@@ -36,6 +36,7 @@
 #include <drm/drm_edid.h>
 #include "intel_drv.h"
 #include <drm/i915_drm.h>
+#include <drm/intel_lpe_audio.h>
 #include "i915_drv.h"
 
 static struct drm_device *intel_hdmi_to_dev(struct intel_hdmi *intel_hdmi)
index 7ce1b5b99275303a322149f0ecba1faed031a624..27d94255872d1b0a94933aeb2ed75cb6bb79feca 100644 (file)
@@ -319,3 +319,52 @@ void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv)
 
        irq_free_desc(dev_priv->lpe_audio.irq);
 }
+
+
+/**
+ * intel_lpe_audio_notify() - notify lpe audio event
+ * audio driver and i915
+ * @dev_priv: the i915 drm device private data
+ * @eld : ELD data
+ * @port: port id
+ * @tmds_clk_speed: tmds clock frequency in Hz
+ *
+ * Notify lpe audio driver of eld change.
+ */
+void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
+                       void *eld, int port, int tmds_clk_speed)
+{
+       unsigned long irq_flags;
+       struct intel_hdmi_lpe_audio_pdata *pdata = NULL;
+
+       if (!HAS_LPE_AUDIO(dev_priv))
+               return;
+
+       pdata = dev_get_platdata(
+               &(dev_priv->lpe_audio.platdev->dev));
+
+       spin_lock_irqsave(&pdata->lpe_audio_slock, irq_flags);
+
+       if (eld != NULL) {
+               memcpy(pdata->eld.eld_data, eld,
+                       HDMI_MAX_ELD_BYTES);
+               pdata->eld.port_id = port;
+               pdata->hdmi_connected = true;
+
+               if (tmds_clk_speed)
+                       pdata->tmds_clock_speed = tmds_clk_speed;
+       } else {
+               memset(pdata->eld.eld_data, 0,
+                       HDMI_MAX_ELD_BYTES);
+               pdata->hdmi_connected = false;
+       }
+
+       if (pdata->notify_audio_lpe)
+               pdata->notify_audio_lpe(
+                       (eld != NULL) ? &pdata->eld : NULL);
+       else
+               pdata->notify_pending = true;
+
+       spin_unlock_irqrestore(&pdata->lpe_audio_slock,
+                       irq_flags);
+}