/* * Copyright © 2016 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * * Authors: * Pierre-Louis Bossart <[email protected]> * Jerome Anand <[email protected]> * based on VED patches * */ /** * DOC: LPE Audio integration for HDMI or DP playback * * Motivation: * Atom platforms (e.g. valleyview and cherryTrail) integrates a DMA-based * interface as an alternative to the traditional HDaudio path. While this * mode is unrelated to the LPE aka SST audio engine, the documentation refers * to this mode as LPE so we keep this notation for the sake of consistency. * * The interface is handled by a separate standalone driver maintained in the * ALSA subsystem for simplicity. To minimize the interaction between the two * subsystems, a bridge is setup between the hdmi-lpe-audio and i915: * 1. Create a platform device to share MMIO/IRQ resources * 2. Make the platform device child of i915 device for runtime PM. * 3. Create IRQ chip to forward the LPE audio irqs. * the hdmi-lpe-audio driver probes the lpe audio device and creates a new * sound card * * Threats: * Due to the restriction in Linux platform device model, user need manually * uninstall the hdmi-lpe-audio driver before uninstalling i915 module, * otherwise we might run into use-after-free issues after i915 removes the * platform device: even though hdmi-lpe-audio driver is released, the modules * is still in "installed" status. * * Implementation: * The MMIO/REG platform resources are created according to the registers * specification. * When forwarding LPE audio irqs, the flow control handler selection depends * on the platform, for example on valleyview handle_simple_irq is enough. * */ #include <linux/acpi.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/irq.h> #include <linux/pci.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <drm/intel/intel_lpe_audio.h> #include "i915_drv.h" #include "i915_irq.h" #include "intel_audio_regs.h" #include "intel_de.h" #include "intel_lpe_audio.h" #include "intel_pci_config.h" #define HAS_LPE_AUDIO(dev_priv) … static struct platform_device * lpe_audio_platdev_create(struct drm_i915_private *dev_priv) { … } static void lpe_audio_platdev_destroy(struct drm_i915_private *dev_priv) { … } static void lpe_audio_irq_unmask(struct irq_data *d) { … } static void lpe_audio_irq_mask(struct irq_data *d) { … } static struct irq_chip lpe_audio_irqchip = …; static int lpe_audio_irq_init(struct drm_i915_private *dev_priv) { … } static bool lpe_audio_detect(struct drm_i915_private *dev_priv) { … } static int lpe_audio_setup(struct drm_i915_private *dev_priv) { … } /** * intel_lpe_audio_irq_handler() - forwards the LPE audio irq * @dev_priv: the i915 drm device private data * * the LPE Audio irq is forwarded to the irq handler registered by LPE audio * driver. */ void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv) { … } /** * intel_lpe_audio_init() - detect and setup the bridge between HDMI LPE Audio * driver and i915 * @dev_priv: the i915 drm device private data * * Return: 0 if successful. non-zero if detection or * llocation/initialization fails */ int intel_lpe_audio_init(struct drm_i915_private *dev_priv) { … } /** * intel_lpe_audio_teardown() - destroy the bridge between HDMI LPE * audio driver and i915 * @dev_priv: the i915 drm device private data * * release all the resources for LPE audio <-> i915 bridge. */ void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv) { … } /** * intel_lpe_audio_notify() - notify lpe audio event * audio driver and i915 * @dev_priv: the i915 drm device private data * @cpu_transcoder: CPU transcoder * @port: port * @eld : ELD data * @ls_clock: Link symbol clock in kHz * @dp_output: Driving a DP output? * * Notify lpe audio driver of eld change. */ void intel_lpe_audio_notify(struct drm_i915_private *dev_priv, enum transcoder cpu_transcoder, enum port port, const void *eld, int ls_clock, bool dp_output) { … }