Skip to contentSkip to conversation

Add support for Legacy HDMI audio drivers

PATCH Superseded Jerome Anand 3 participants 20 messages Jan 6, 2017 – Jan 7, 2017

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for Legacy HDMI audio drivers

Legacy (CherryTrail/ Baytrail) HDMI audio drivers added

Legacy hdmi audio-Gfx interaction/ interfacing is updated to use irq chip framework

Jerome Anand (7):
drm/i915: setup bridge for HDMI LPE audio driver drm/i915: Add support for audio driver notifications
ALSA: add shell for Intel HDMI LPE audio driver
ALSA: x86: hdmi: Add audio support for BYT and CHT
ALSA: x86: hdmi: Improve position reporting
ALSA: x86: hdmi: Fixup some monitor
ALSA: x86: hdmi: continue playback even when display resolution
changes

 Documentation/gpu/i915.rst             |    9 +
 drivers/gpu/drm/i915/Makefile          |    3 +
 drivers/gpu/drm/i915/i915_drv.c        |    8 +-
 drivers/gpu/drm/i915/i915_drv.h        |   18 +
 drivers/gpu/drm/i915/i915_irq.c        |   16 +
 drivers/gpu/drm/i915/i915_reg.h        |    3 +
 drivers/gpu/drm/i915/intel_audio.c     |    8 +
 drivers/gpu/drm/i915/intel_hdmi.c      |    1 +
 drivers/gpu/drm/i915/intel_lpe_audio.c |  401 +++++++
 include/drm/intel_lpe_audio.h          |   46 +
 sound/Kconfig                          |    2 +
 sound/Makefile                         |    2 +-
 sound/x86/Kconfig                      |   16 +
 sound/x86/Makefile                     |    8 +
 sound/x86/intel_hdmi_audio.c           | 1928 ++++++++++++++++++++++++++++++++
 sound/x86/intel_hdmi_audio.h           |  201 ++++
 sound/x86/intel_hdmi_audio_if.c        |  551 +++++++++
 sound/x86/intel_hdmi_lpe_audio.c       |  627 +++++++++++
 sound/x86/intel_hdmi_lpe_audio.h       |  685 ++++++++++++
 19 files changed, 4530 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lpe_audio.c
 create mode 100644 include/drm/intel_lpe_audio.h
 create mode 100644 sound/x86/Kconfig
 create mode 100644 sound/x86/Makefile
 create mode 100644 sound/x86/intel_hdmi_audio.c
 create mode 100644 sound/x86/intel_hdmi_audio.h
 create mode 100644 sound/x86/intel_hdmi_audio_if.c
 create mode 100644 sound/x86/intel_hdmi_lpe_audio.c
 create mode 100644 sound/x86/intel_hdmi_lpe_audio.h
Signature · 7 lines
2.9.3

base-commit: 362e5ebefe40f1f00a7075ad2e472ef44a36a7da
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v2 1/7 drm/i915: setup bridge for HDMI LPE audio driver

Enable support for HDMI LPE audio mode on Baytrail and Cherrytrail when HDaudio controller is not detected

Setup minimum required resources during i915_driver_load:
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 HDMI LPE audio irqs.

HDMI LPE audio driver (a standalone sound driver) probes the LPE audio device and creates a new sound card.

---
 Documentation/gpu/i915.rst             |   9 +
 drivers/gpu/drm/i915/Makefile          |   3 +
 drivers/gpu/drm/i915/i915_drv.c        |   8 +-
 drivers/gpu/drm/i915/i915_drv.h        |  15 ++
 drivers/gpu/drm/i915/i915_irq.c        |  16 ++
 drivers/gpu/drm/i915/i915_reg.h        |   3 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 355 +++++++++++++++++++++++++++++++++
 include/drm/intel_lpe_audio.h          |  45 +++++
 8 files changed, 452 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lpe_audio.c
 create mode 100644 include/drm/intel_lpe_audio.h
Documentation/gpu/i915.rst +9 -0
index 104296d..bd9b767 100644
@@ -225,6 +225,15 @@ Display PLLs
 .. kernel-doc:: drivers/gpu/drm/i915/intel_dpll_mgr.h
    :internal:
 
+intel hdmi lpe audio support
+----------------------------
+
+.. kernel-doc:: drivers/gpu/drm/i915/intel_lpe_audio.c
+   :doc:  LPE Audio integration for HDMI or DP playback
+
+.. kernel-doc:: drivers/gpu/drm/i915/intel_lpe_audio.c
+   :internal:
+
 Memory Management and Command Submission
 ========================================
 
drivers/gpu/drm/i915/Makefile +3 -0
index 5196509..2bca239 100644
@@ -127,6 +127,9 @@ i915-y += intel_gvt.o
 include $(src)/gvt/Makefile
 endif
 
+# LPE Audio for VLV and CHT
+i915-y += intel_lpe_audio.o
+
 obj-$(CONFIG_DRM_I915) += i915.o
 
 CFLAGS_i915_trace_points.o := -I$(src)
drivers/gpu/drm/i915/i915_drv.c +6 -2
index 4d22b4b..70d728b 100644
@@ -1131,7 +1131,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 	if (IS_GEN5(dev_priv))
 		intel_gpu_ips_init(dev_priv);
 
-	i915_audio_component_init(dev_priv);
+	if (intel_lpe_audio_init(dev_priv) < 0)
+		i915_audio_component_init(dev_priv);
 
 	/*
 	 * Some ports require correctly set-up hpd registers for detection to
@@ -1149,7 +1150,10 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
  */
 static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 {
-	i915_audio_component_cleanup(dev_priv);
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_teardown(dev_priv);
+	else
+		i915_audio_component_cleanup(dev_priv);
 
 	intel_gpu_ips_teardown();
 	acpi_video_unregister();
drivers/gpu/drm/i915/i915_drv.h +15 -0
index 7b43662..2f8165e 100644
@@ -2460,6 +2460,12 @@ struct drm_i915_private {
 	/* Used to save the pipe-to-encoder mapping for audio */
 	struct intel_encoder *av_enc_map[I915_MAX_PIPES];
 
+	/* necessary resource sharing with HDMI LPE audio driver. */
+	struct {
+		struct platform_device *platdev;
+		int	irq;
+	} lpe_audio;
+
 	/*
 	 * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch
 	 * will be rejected. Instead look for a better place.
@@ -2859,6 +2865,8 @@ intel_info(const struct drm_i915_private *dev_priv)
 
 #define HAS_POOLED_EU(dev_priv)	((dev_priv)->info.has_pooled_eu)
 
+#define HAS_LPE_AUDIO(dev_priv) ((dev_priv)->lpe_audio.platdev != NULL)
+
 #define INTEL_PCH_DEVICE_ID_MASK		0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE		0x3b00
 #define INTEL_PCH_CPT_DEVICE_ID_TYPE		0x1c00
@@ -3620,6 +3628,13 @@ extern int i915_restore_state(struct drm_i915_private *dev_priv);
 void i915_setup_sysfs(struct drm_i915_private *dev_priv);
 void i915_teardown_sysfs(struct drm_i915_private *dev_priv);
 
+/* i915_lpe_audio.c */
+int  intel_lpe_audio_init(struct drm_i915_private *dev_priv);
+int  intel_lpe_audio_setup(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);
+bool intel_lpe_audio_detect(struct drm_i915_private *dev_priv);
+
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);
 extern void intel_teardown_gmbus(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_irq.c +16 -0
index a0e70f5..d9393d6a 100644
@@ -1893,6 +1893,10 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
 		 * signalled in iir */
 		valleyview_pipestat_irq_ack(dev_priv, iir, pipe_stats);
 
+		if (iir & (I915_LPE_PIPE_A_INTERRUPT |
+			   I915_LPE_PIPE_B_INTERRUPT))
+			intel_lpe_audio_irq_handler(dev_priv);
+
 		/*
 		 * VLV_IIR is single buffered, and reflects the level
 		 * from PIPESTAT/PORT_HOTPLUG_STAT, hence clear it last.
@@ -1973,6 +1977,11 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)
 		 * signalled in iir */
 		valleyview_pipestat_irq_ack(dev_priv, iir, pipe_stats);
 
+		if (iir & (I915_LPE_PIPE_A_INTERRUPT |
+			   I915_LPE_PIPE_B_INTERRUPT |
+			   I915_LPE_PIPE_C_INTERRUPT))
+			intel_lpe_audio_irq_handler(dev_priv);
+
 		/*
 		 * VLV_IIR is single buffered, and reflects the level
 		 * from PIPESTAT/PORT_HOTPLUG_STAT, hence clear it last.
@@ -2914,6 +2923,7 @@ static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv)
 	u32 pipestat_mask;
 	u32 enable_mask;
 	enum pipe pipe;
+	u32 val;
 
 	pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV |
 			PIPE_CRC_DONE_INTERRUPT_STATUS;
@@ -2930,6 +2940,12 @@ static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv)
 
 	WARN_ON(dev_priv->irq_mask != ~0);
 
+	val = (I915_LPE_PIPE_A_INTERRUPT |
+		I915_LPE_PIPE_B_INTERRUPT |
+		I915_LPE_PIPE_C_INTERRUPT);
+
+	enable_mask |= val;
+
 	dev_priv->irq_mask = ~enable_mask;
 
 	GEN5_IRQ_INIT(VLV_, dev_priv->irq_mask, enable_mask);
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 00970aa..643bc6e 100644
@@ -2428,6 +2428,9 @@ enum skl_disp_power_wells {
 #define I915_ASLE_INTERRUPT				(1<<0)
 #define I915_BSD_USER_INTERRUPT				(1<<25)
 
+#define I915_HDMI_LPE_AUDIO_BASE	(VLV_DISPLAY_BASE + 0x65000)
+#define I915_HDMI_LPE_AUDIO_SIZE	0x1000
+
 #define GEN6_BSD_RNCID			_MMIO(0x12198)
 
 #define GEN7_FF_THREAD_MODE		_MMIO(0x20a0)
drivers/gpu/drm/i915/intel_lpe_audio.c new file +355 -0

355 lines not on this page · raw message

include/drm/intel_lpe_audio.h new file +45 -0

45 lines not on this page · raw message

Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [alsa-devel] [PATCH V2 1/7] drm/i915: setup bridge for HDMI LPE audio driver

Thanks for the update Jerome. Looks like you missed a couple of agreed comments from the last round?

Quoted 266 lines · Jerome Anand

Enable support for HDMI LPE audio mode on Baytrail and Cherrytrail when HDaudio controller is not detected

Setup minimum required resources during i915_driver_load:
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 HDMI LPE audio irqs.

HDMI LPE audio driver (a standalone sound driver) probes the LPE audio device and creates a new sound card.

---
 Documentation/gpu/i915.rst             |   9 +
 drivers/gpu/drm/i915/Makefile          |   3 +
 drivers/gpu/drm/i915/i915_drv.c        |   8 +-
 drivers/gpu/drm/i915/i915_drv.h        |  15 ++
 drivers/gpu/drm/i915/i915_irq.c        |  16 ++
 drivers/gpu/drm/i915/i915_reg.h        |   3 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 355 +++++++++++++++++++++++++++++++++
 include/drm/intel_lpe_audio.h          |  45 +++++
 8 files changed, 452 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lpe_audio.c
 create mode 100644 include/drm/intel_lpe_audio.h
Documentation/gpu/i915.rst +9 -0
index 104296d..bd9b767 100644
@@ -225,6 +225,15 @@ Display PLLs
 .. kernel-doc:: drivers/gpu/drm/i915/intel_dpll_mgr.h
    :internal:
 
+intel hdmi lpe audio support
+----------------------------
+
+.. kernel-doc:: drivers/gpu/drm/i915/intel_lpe_audio.c
+   :doc:  LPE Audio integration for HDMI or DP playback
+
+.. kernel-doc:: drivers/gpu/drm/i915/intel_lpe_audio.c
+   :internal:
+
 Memory Management and Command Submission
 ========================================
 
drivers/gpu/drm/i915/Makefile +3 -0
index 5196509..2bca239 100644
@@ -127,6 +127,9 @@ i915-y += intel_gvt.o
 include $(src)/gvt/Makefile
 endif
 
+# LPE Audio for VLV and CHT
+i915-y += intel_lpe_audio.o
+
 obj-$(CONFIG_DRM_I915) += i915.o
 
 CFLAGS_i915_trace_points.o := -I$(src)
drivers/gpu/drm/i915/i915_drv.c +6 -2
index 4d22b4b..70d728b 100644
@@ -1131,7 +1131,8 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 	if (IS_GEN5(dev_priv))
 		intel_gpu_ips_init(dev_priv);
 
-	i915_audio_component_init(dev_priv);
+	if (intel_lpe_audio_init(dev_priv) < 0)
+		i915_audio_component_init(dev_priv);
 
 	/*
 	 * Some ports require correctly set-up hpd registers for detection to
@@ -1149,7 +1150,10 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
  */
 static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 {
-	i915_audio_component_cleanup(dev_priv);
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_teardown(dev_priv);
+	else
+		i915_audio_component_cleanup(dev_priv);
 
 	intel_gpu_ips_teardown();
 	acpi_video_unregister();
drivers/gpu/drm/i915/i915_drv.h +15 -0
index 7b43662..2f8165e 100644
@@ -2460,6 +2460,12 @@ struct drm_i915_private {
 	/* Used to save the pipe-to-encoder mapping for audio */
 	struct intel_encoder *av_enc_map[I915_MAX_PIPES];
 
+	/* necessary resource sharing with HDMI LPE audio driver. */
+	struct {
+		struct platform_device *platdev;
+		int	irq;
+	} lpe_audio;
+
 	/*
 	 * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch
 	 * will be rejected. Instead look for a better place.
@@ -2859,6 +2865,8 @@ intel_info(const struct drm_i915_private *dev_priv)
 
 #define HAS_POOLED_EU(dev_priv)	((dev_priv)->info.has_pooled_eu)
 
+#define HAS_LPE_AUDIO(dev_priv) ((dev_priv)->lpe_audio.platdev != NULL)
+
 #define INTEL_PCH_DEVICE_ID_MASK		0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE		0x3b00
 #define INTEL_PCH_CPT_DEVICE_ID_TYPE		0x1c00
@@ -3620,6 +3628,13 @@ extern int i915_restore_state(struct drm_i915_private *dev_priv);
 void i915_setup_sysfs(struct drm_i915_private *dev_priv);
 void i915_teardown_sysfs(struct drm_i915_private *dev_priv);
 
+/* i915_lpe_audio.c */
+int  intel_lpe_audio_init(struct drm_i915_private *dev_priv);
+int  intel_lpe_audio_setup(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);
+bool intel_lpe_audio_detect(struct drm_i915_private *dev_priv);
+
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);
 extern void intel_teardown_gmbus(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_irq.c +16 -0
index a0e70f5..d9393d6a 100644
@@ -1893,6 +1893,10 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
 		 * signalled in iir */
 		valleyview_pipestat_irq_ack(dev_priv, iir, pipe_stats);
 
+		if (iir & (I915_LPE_PIPE_A_INTERRUPT |
+			   I915_LPE_PIPE_B_INTERRUPT))
+			intel_lpe_audio_irq_handler(dev_priv);
+
 		/*
 		 * VLV_IIR is single buffered, and reflects the level
 		 * from PIPESTAT/PORT_HOTPLUG_STAT, hence clear it last.
@@ -1973,6 +1977,11 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)
 		 * signalled in iir */
 		valleyview_pipestat_irq_ack(dev_priv, iir, pipe_stats);
 
+		if (iir & (I915_LPE_PIPE_A_INTERRUPT |
+			   I915_LPE_PIPE_B_INTERRUPT |
+			   I915_LPE_PIPE_C_INTERRUPT))
+			intel_lpe_audio_irq_handler(dev_priv);
+
 		/*
 		 * VLV_IIR is single buffered, and reflects the level
 		 * from PIPESTAT/PORT_HOTPLUG_STAT, hence clear it last.
@@ -2914,6 +2923,7 @@ static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv)
 	u32 pipestat_mask;
 	u32 enable_mask;
 	enum pipe pipe;
+	u32 val;
 
 	pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV |
 			PIPE_CRC_DONE_INTERRUPT_STATUS;
@@ -2930,6 +2940,12 @@ static void vlv_display_irq_postinstall(struct drm_i915_private *dev_priv)
 
 	WARN_ON(dev_priv->irq_mask != ~0);
 
+	val = (I915_LPE_PIPE_A_INTERRUPT |
+		I915_LPE_PIPE_B_INTERRUPT |
+		I915_LPE_PIPE_C_INTERRUPT);
+
+	enable_mask |= val;
+
 	dev_priv->irq_mask = ~enable_mask;
 
 	GEN5_IRQ_INIT(VLV_, dev_priv->irq_mask, enable_mask);
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 00970aa..643bc6e 100644
@@ -2428,6 +2428,9 @@ enum skl_disp_power_wells {
 #define I915_ASLE_INTERRUPT				(1<<0)
 #define I915_BSD_USER_INTERRUPT				(1<<25)
 
+#define I915_HDMI_LPE_AUDIO_BASE	(VLV_DISPLAY_BASE + 0x65000)
+#define I915_HDMI_LPE_AUDIO_SIZE	0x1000
+
 #define GEN6_BSD_RNCID			_MMIO(0x12198)
 
 #define GEN7_FF_THREAD_MODE		_MMIO(0x20a0)
drivers/gpu/drm/i915/intel_lpe_audio.c new file +72 -0
new file mode 100644
index 0000000..05f5e4e
@@ -0,0 +1,355 @@
+/*
+ * 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/device.h>
+#include <linux/pci.h>
+
+#include "i915_drv.h"
+#include <linux/delay.h>
+#include <drm/intel_lpe_audio.h>
+
+static struct platform_device *
+lpe_audio_platdev_create(struct drm_i915_private *dev_priv)

drivers/gpu/drm/i915/intel_lpe_audio.c line 82

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+{
+	struct drm_device *dev = &dev_priv->drm;
+	int ret;
+	struct resource rsc[2] = {};
+	struct platform_device *platdev;
+	u64 *dma_mask;
+	struct intel_hdmi_lpe_audio_pdata *pdata;
+
+	if (dev_priv->lpe_audio.irq < 0)
+		return ERR_PTR(-EINVAL);

from Takashi: This was already tested, no?
JA: OK - can be removed

Quoted 52 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +52 -0
+
+	platdev = platform_device_alloc("hdmi-lpe-audio", -1);
+	if (!platdev) {
+		ret = -ENOMEM;
+		DRM_ERROR("Failed to allocate LPE audio platform device\n");
+		goto err;
+	}
+
+	/* to work-around check_addr in nommu_map_sg() */
+	dma_mask = kmalloc(sizeof(*platdev->dev.dma_mask), GFP_KERNEL);
+	if (!dma_mask) {
+		ret = -ENOMEM;
+		DRM_ERROR("Failed to allocate dma_mask\n");
+		goto err_put_dev;
+	}
+	*dma_mask = DMA_BIT_MASK(32);
+	platdev->dev.dma_mask = dma_mask;
+	platdev->dev.coherent_dma_mask = *dma_mask;
+
+	rsc[0].start    = rsc[0].end = dev_priv->lpe_audio.irq;
+	rsc[0].flags    = IORESOURCE_IRQ;
+	rsc[0].name     = "hdmi-lpe-audio-irq";
+
+	rsc[1].start    = pci_resource_start(dev->pdev, 0) +
+		I915_HDMI_LPE_AUDIO_BASE;
+	rsc[1].end      = pci_resource_start(dev->pdev, 0) +
+		I915_HDMI_LPE_AUDIO_BASE + I915_HDMI_LPE_AUDIO_SIZE - 1;
+	rsc[1].flags    = IORESOURCE_MEM;
+	rsc[1].name     = "hdmi-lpe-audio-mmio";
+
+	ret = platform_device_add_resources(platdev, rsc, 2);
+	if (ret) {
+		DRM_ERROR("Failed to add resource for platform device: %d\n",
+			ret);
+		goto err_put_dev;
+	}
+
+	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+
+	if (pdata == NULL) {
+		ret = -ENOMEM;
+		goto err_put_dev;
+	}
+	platdev->dev.platform_data = pdata;
+	spin_lock_init(&pdata->lpe_audio_slock);
+
+	/* for LPE audio driver's runtime-PM */
+	platdev->dev.parent = dev->dev;
+	ret = platform_device_add(platdev);
+	if (ret) {
+		DRM_ERROR("Failed to add LPE audio platform device: %d\n",
+			ret);

drivers/gpu/drm/i915/intel_lpe_audio.c line 144

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+		goto err_put_dev;
+	}
+
+	return platdev;
+err_put_dev:
+	platform_device_put(platdev);
+	kfree(dma_mask);
+err:
+	return ERR_PTR(ret);
+}

from Takashi:
guess using platform_device_register_full() makes the code a bit
simpler.
JA: OK - agreed, but will keep it since its acked by Daniel. -> what's the downside to using simpler code?

drivers/gpu/drm/i915/intel_lpe_audio.c line 157

Quoted 13 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +13 -0
+
+static void lpe_audio_platdev_destroy(struct drm_i915_private *dev_priv)
+{
+	platform_device_unregister(dev_priv->lpe_audio.platdev);
+	kfree(dev_priv->lpe_audio.platdev->dev.dma_mask);
+}
+
+static void lpe_audio_irq_unmask(struct irq_data *d)
+{
+	struct drm_i915_private *dev_priv = d->chip_data;
+	unsigned long irqflags;
+	u32 val = (I915_LPE_PIPE_A_INTERRUPT |
+		I915_LPE_PIPE_B_INTERRUPT);

From Daniel: PIPE_C missing?
-> Yes for CherryTrail

Quoted 8 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +8 -0
+
+	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
+
+	dev_priv->irq_mask &= ~val;
+	I915_WRITE(VLV_IIR, val);
+	I915_WRITE(VLV_IIR, val);
+	I915_WRITE(VLV_IMR, dev_priv->irq_mask);
+	POSTING_READ(VLV_IMR);

drivers/gpu/drm/i915/intel_lpe_audio.c line 175

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+
+	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
+}
+
+static void lpe_audio_irq_mask(struct irq_data *d)
+{
+	struct drm_i915_private *dev_priv = d->chip_data;
+	unsigned long irqflags;
+	u32 val = (I915_LPE_PIPE_A_INTERRUPT |
+		I915_LPE_PIPE_B_INTERRUPT);

From Daniel: PIPE_C missing?
-> Yes for CherryTrail

Quoted 65 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +65 -0
+
+	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
+
+	dev_priv->irq_mask |= val;
+	I915_WRITE(VLV_IMR, dev_priv->irq_mask);
+	I915_WRITE(VLV_IIR, val);
+	I915_WRITE(VLV_IIR, val);
+	POSTING_READ(VLV_IIR);
+
+	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
+}
+
+static struct irq_chip lpe_audio_irqchip = {
+	.name = "hdmi_lpe_audio_irqchip",
+	.irq_mask = lpe_audio_irq_mask,
+	.irq_unmask = lpe_audio_irq_unmask,
+};
+
+static int lpe_audio_irq_init(struct drm_i915_private *dev_priv)
+{
+	int irq = dev_priv->lpe_audio.irq;
+
+	WARN_ON(!intel_irqs_enabled(dev_priv));
+	irq_set_chip_and_handler_name(irq,
+				&lpe_audio_irqchip,
+				handle_simple_irq,
+				"hdmi_lpe_audio_irq_handler");
+
+	return irq_set_chip_data(irq, 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)
+{
+	int ret;
+
+	if (!HAS_LPE_AUDIO(dev_priv))
+		return;
+
+	ret = generic_handle_irq(dev_priv->lpe_audio.irq);
+	if (ret)
+		DRM_ERROR_RATELIMITED("error handling LPE audio irq: %d\n",
+				ret);
+}
+
+/**
+ * intel_lpe_audio_detect() - check & setup lpe audio if present
+ * @dev_priv: the i915 drm device private data
+ *
+ * Detect if lpe audio is present
+ *
+ * Return: true if lpe audio present else Return = false
+ */
+bool intel_lpe_audio_detect(struct drm_i915_private *dev_priv)
+{
+	int lpe_present = false;
+
+	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
+		static const struct pci_device_id atom_hdaudio_ids[] = {

drivers/gpu/drm/i915/intel_lpe_audio.c line 250

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+			/* Baytrail */
+			{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0f04)},
+			/* Braswell */
+			{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2284)},
+			{}
+		};
+
+		if (!pci_dev_present(atom_hdaudio_ids)) {
+			DRM_INFO("%s%s\n", "HDaudio controller not detected,",
+				"using LPE audio instead\n");

From Takashi:
Why %s%s? Just keep one line without line breakage. The 80 chars rule is just a suggestion, no strict rule at all.
JA: OK

Quoted 94 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +94 -0
+			lpe_present = true;
+		}
+	}
+	return lpe_present;
+}
+
+/**
+ * intel_lpe_audio_setup() - setup the bridge between HDMI LPE Audio
+ * driver and i915
+ * @dev_priv: the i915 drm device private data
+ *
+ * set up the minimum required resources for the bridge: irq chip,
+ * platform resource and platform device. i915 device is set as parent
+ * of the new platform device.
+ *
+ * Return: 0 if successful. non-zero if allocation/initialization fails
+ */
+int intel_lpe_audio_setup(struct drm_i915_private *dev_priv)
+{
+	int ret;
+
+	dev_priv->lpe_audio.irq = irq_alloc_desc(0);
+	if (dev_priv->lpe_audio.irq < 0) {
+		DRM_ERROR("Failed to allocate IRQ desc: %d\n",
+			dev_priv->lpe_audio.irq);
+		ret = dev_priv->lpe_audio.irq;
+		goto err;
+	}
+
+	DRM_DEBUG("irq = %d\n", dev_priv->lpe_audio.irq);
+
+	ret = lpe_audio_irq_init(dev_priv);
+
+	if (ret) {
+		DRM_ERROR("Failed to initialize irqchip for lpe audio: %d\n",
+			ret);
+		goto err_free_irq;
+	}
+
+	dev_priv->lpe_audio.platdev = lpe_audio_platdev_create(dev_priv);
+
+	if (IS_ERR(dev_priv->lpe_audio.platdev)) {
+		ret = PTR_ERR(dev_priv->lpe_audio.platdev);
+		DRM_ERROR("Failed to create lpe audio platform device: %d\n",
+			ret);
+		goto err_free_irq;
+	}
+
+	return 0;
+err_free_irq:
+	irq_free_desc(dev_priv->lpe_audio.irq);
+err:
+	dev_priv->lpe_audio.irq = -1;
+	dev_priv->lpe_audio.platdev = NULL;
+	return ret;
+}
+
+
+/**
+ * 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)
+{
+	int ret = -ENODEV;
+
+	if (intel_lpe_audio_detect(dev_priv)) {
+		ret = intel_lpe_audio_setup(dev_priv);
+		if (ret < 0)
+			DRM_ERROR("failed to setup LPE Audio bridge\n");
+	}
+	return ret;
+}
+
+/**
+ * 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)
+{
+	unsigned long irqflags;
+	struct irq_desc *desc;
+
+	if (!HAS_LPE_AUDIO(dev_priv))
+		return;
+
+	desc = irq_to_desc(dev_priv->lpe_audio.irq);

drivers/gpu/drm/i915/intel_lpe_audio.c line 354

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+
+	lpe_audio_irq_mask(&desc->irq_data);
+
+	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
+
+	lpe_audio_platdev_destroy(dev_priv);
+
+	irq_free_desc(dev_priv->lpe_audio.irq);
+
+	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);

From Takashi: What's the reason of this spinlock?
JA: JIC - probably not needed now

Quoted 43 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +1 -0
+}
include/drm/intel_lpe_audio.h new file +35 -0
new file mode 100644
index 0000000..a64c449
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#ifndef _INTEL_LPE_AUDIO_H_
+#define _INTEL_LPE_AUDIO_H_
+
+#include <linux/types.h>
+
+#define HDMI_MAX_ELD_BYTES	128
+
+struct intel_hdmi_lpe_audio_eld {
+	int port_id;
+	unsigned char eld_data[HDMI_MAX_ELD_BYTES];
+};
+

include/drm/intel_lpe_audio.h line 45

Quoted 10 lines
include/drm/intel_lpe_audio.h new file +10 -0
+struct intel_hdmi_lpe_audio_pdata {
+	bool notify_pending;
+	int tmds_clock_speed;
+	bool hdmi_connected;
+	struct intel_hdmi_lpe_audio_eld eld;
+	void (*notify_audio_lpe)(void *audio_ptr);
+	spinlock_t lpe_audio_slock;
+};
+
+#endif /* _I915_LPE_AUDIO_H_ */

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

Re: [alsa-devel] [PATCH V2 1/7] drm/i915: setup bridge for HDMI LPE audio driver

Quoted 12 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Saturday, January 7, 2017 1:43 AM
To: Anand, Jerome <[email protected]>; intel- [email protected]; [email protected]
Cc: [email protected]; [email protected]; Ughreja, Rakesh A <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH V2 1/7] drm/i915: setup bridge for HDMI LPE audio driver

Quoted 3 lines

Thanks for the update Jerome. Looks like you missed a couple of agreed comments from the last round?

Thanks Pierre for the quick feedback. I though I replied to some of the Comments previously.

Quoted 317 lines · Jerome Anand
Quoted 14 lines

Enable support for HDMI LPE audio mode on Baytrail and Cherrytrail when HDaudio controller is not detected

Setup minimum required resources during i915_driver_load:
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 HDMI LPE audio irqs.

HDMI LPE audio driver (a standalone sound driver) probes the LPE audio device and creates a new sound card.

Signed-off-by: Pierre-Louis Bossart
<[email protected]>

Quoted 8 lines
---
 Documentation/gpu/i915.rst             |   9 +
 drivers/gpu/drm/i915/Makefile          |   3 +
 drivers/gpu/drm/i915/i915_drv.c        |   8 +-
 drivers/gpu/drm/i915/i915_drv.h        |  15 ++
 drivers/gpu/drm/i915/i915_irq.c        |  16 ++
 drivers/gpu/drm/i915/i915_reg.h        |   3 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 355

+++++++++++++++++++++++++++++++++

drivers/gpu/drm/i915/i915_drv.c static void i915_driver_register(struct

Quoted 43 lines
 include/drm/intel_lpe_audio.h          |  45 +++++
 8 files changed, 452 insertions(+), 2 deletions(-)  create mode
100644 drivers/gpu/drm/i915/intel_lpe_audio.c
 create mode 100644 include/drm/intel_lpe_audio.h
Documentation/gpu/i915.rst +9 -0
index 104296d..bd9b767 100644
@@ -225,6 +225,15 @@ Display PLLs
 .. kernel-doc:: drivers/gpu/drm/i915/intel_dpll_mgr.h
    :internal:
 
+intel hdmi lpe audio support
+----------------------------
+
+.. kernel-doc:: drivers/gpu/drm/i915/intel_lpe_audio.c
+   :doc:  LPE Audio integration for HDMI or DP playback
+
+.. kernel-doc:: drivers/gpu/drm/i915/intel_lpe_audio.c
+   :internal:
+
 Memory Management and Command Submission

========================================

(quoted diff) +0 -0

b/drivers/gpu/drm/i915/Makefile index 5196509..2bca239 100644

drivers/gpu/drm/i915/Makefile +0 -0
@@ -127,6 +127,9 @@ i915-y += intel_gvt.o  include $(src)/gvt/Makefile

endif

drivers/gpu/drm/i915/Makefile +3 -0
+# LPE Audio for VLV and CHT
+i915-y += intel_lpe_audio.o
+
 obj-$(CONFIG_DRM_I915) += i915.o
 
 CFLAGS_i915_trace_points.o := -I$(src) diff --git

a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 4d22b4b..70d728b 100644

drivers/gpu/drm/i915/i915_drv.c +0 -0
@@ -1131,7 +1131,8 @@ static void i915_driver_register(struct

drm_i915_private *dev_priv)

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.c +2 -1
 	if (IS_GEN5(dev_priv))
 		intel_gpu_ips_init(dev_priv);
 
-	i915_audio_component_init(dev_priv);
+	if (intel_lpe_audio_init(dev_priv) < 0)
+		i915_audio_component_init(dev_priv);
 
 	/*
 	 * Some ports require correctly set-up hpd registers for detection

to @@ -1149,7 +1150,10 @@ static void i915_driver_register(struct

drm_i915_private *dev_priv)

Quoted 17 lines

*/
static void i915_driver_unregister(struct drm_i915_private *dev_priv)
{

drivers/gpu/drm/i915/i915_drv.c +4 -1
-	i915_audio_component_cleanup(dev_priv);
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_teardown(dev_priv);
+	else
+		i915_audio_component_cleanup(dev_priv);
 
 	intel_gpu_ips_teardown();
 	acpi_video_unregister();
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 7b43662..2f8165e 100644

drivers/gpu/drm/i915/i915_drv.h +0 -0
@@ -2460,6 +2460,12 @@ struct drm_i915_private {
 	/* Used to save the pipe-to-encoder mapping for audio */

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private { · line 2470

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +6 -0
 	struct intel_encoder *av_enc_map[I915_MAX_PIPES];
 
+	/* necessary resource sharing with HDMI LPE audio driver. */
+	struct {
+		struct platform_device *platdev;
+		int	irq;
+	} lpe_audio;
+
 	/*
 	 * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your

patch

drivers/gpu/drm/i915/i915_irq.c static irqreturn_t valleyview_irq_handler(int irq,

Quoted 32 lines
drivers/gpu/drm/i915/i915_drv.h +3 -0
 	 * will be rejected. Instead look for a better place.
@@ -2859,6 +2865,8 @@ intel_info(const struct drm_i915_private
 *dev_priv)
 
 #define HAS_POOLED_EU(dev_priv)	((dev_priv)->info.has_pooled_eu)
 
+#define HAS_LPE_AUDIO(dev_priv) ((dev_priv)->lpe_audio.platdev !=
+NULL)
+
 #define INTEL_PCH_DEVICE_ID_MASK		0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE		0x3b00
 #define INTEL_PCH_CPT_DEVICE_ID_TYPE		0x1c00
@@ -3620,6 +3628,13 @@ extern int i915_restore_state(struct

drm_i915_private *dev_priv); void i915_setup_sysfs(struct drm_i915_private *dev_priv); void i915_teardown_sysfs(struct drm_i915_private *dev_priv);

drivers/gpu/drm/i915/i915_drv.h +7 -0
+/* i915_lpe_audio.c */
+int  intel_lpe_audio_init(struct drm_i915_private *dev_priv); int
+intel_lpe_audio_setup(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); bool
+intel_lpe_audio_detect(struct drm_i915_private *dev_priv);
+
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);

extern void intel_teardown_gmbus(struct drm_i915_private *dev_priv);

(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_irq.c index a0e70f5..d9393d6a 100644

drivers/gpu/drm/i915/i915_irq.c +0 -0
@@ -1893,6 +1893,10 @@ static irqreturn_t valleyview_irq_handler(int irq,

void *arg)

drivers/gpu/drm/i915/i915_irq.c static irqreturn_t cherryview_irq_handler(int irq,

Quoted 11 lines
drivers/gpu/drm/i915/i915_irq.c +4 -0
 		 * signalled in iir */
 		valleyview_pipestat_irq_ack(dev_priv, iir, pipe_stats);
 
+		if (iir & (I915_LPE_PIPE_A_INTERRUPT |
+			   I915_LPE_PIPE_B_INTERRUPT))
+			intel_lpe_audio_irq_handler(dev_priv);
+
 		/*
 		 * VLV_IIR is single buffered, and reflects the level
 		 * from PIPESTAT/PORT_HOTPLUG_STAT, hence clear it last.
@@ -1973,6 +1977,11 @@ static irqreturn_t cherryview_irq_handler(int irq,

void *arg)

drivers/gpu/drm/i915/i915_irq.c static void vlv_display_irq_postinstall(struct

Quoted 12 lines
drivers/gpu/drm/i915/i915_irq.c +5 -0
 		 * signalled in iir */
 		valleyview_pipestat_irq_ack(dev_priv, iir, pipe_stats);
 
+		if (iir & (I915_LPE_PIPE_A_INTERRUPT |
+			   I915_LPE_PIPE_B_INTERRUPT |
+			   I915_LPE_PIPE_C_INTERRUPT))
+			intel_lpe_audio_irq_handler(dev_priv);
+
 		/*
 		 * VLV_IIR is single buffered, and reflects the level
 		 * from PIPESTAT/PORT_HOTPLUG_STAT, hence clear it last.
@@ -2914,6 +2923,7 @@ static void vlv_display_irq_postinstall(struct

drm_i915_private *dev_priv)

Quoted 26 lines
drivers/gpu/drm/i915/i915_irq.c +7 -0
 	u32 pipestat_mask;
 	u32 enable_mask;
 	enum pipe pipe;
+	u32 val;
 
 	pipestat_mask = PLANE_FLIP_DONE_INT_STATUS_VLV |
 			PIPE_CRC_DONE_INTERRUPT_STATUS;
@@ -2930,6 +2940,12 @@ static void vlv_display_irq_postinstall(struct
 drm_i915_private *dev_priv)
 
 	WARN_ON(dev_priv->irq_mask != ~0);
 
+	val = (I915_LPE_PIPE_A_INTERRUPT |
+		I915_LPE_PIPE_B_INTERRUPT |
+		I915_LPE_PIPE_C_INTERRUPT);
+
+	enable_mask |= val;
+
 	dev_priv->irq_mask = ~enable_mask;
 

GEN5_IRQ_INIT(VLV_, dev_priv->irq_mask, enable_mask); diff --git
a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 00970aa..643bc6e 100644

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 2429

Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +0 -0
@@ -2428,6 +2428,9 @@ enum skl_disp_power_wells {
 #define I915_ASLE_INTERRUPT				(1<<0)
 #define I915_BSD_USER_INTERRUPT
	(1<<25)

drivers/gpu/drm/i915/i915_reg.h enum skl_disp_power_wells { · line 2430

Quoted 2 lines
drivers/gpu/drm/i915/i915_reg.h +1 -0
+#define I915_HDMI_LPE_AUDIO_BASE	(VLV_DISPLAY_BASE +

0x65000)

Quoted 24 lines
drivers/gpu/drm/i915/i915_reg.h +2 -0
+#define I915_HDMI_LPE_AUDIO_SIZE	0x1000
+
 #define GEN6_BSD_RNCID			_MMIO(0x12198)
 
 #define GEN7_FF_THREAD_MODE		_MMIO(0x20a0)
drivers/gpu/drm/i915/intel_lpe_audio.c new file +12 -0
new file mode 100644
index 0000000..05f5e4e
@@ -0,0 +1,355 @@
+/*
+ * 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

drivers/gpu/drm/i915/intel_lpe_audio.c line 22

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+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,

drivers/gpu/drm/i915/intel_lpe_audio.c line 26

Quoted 4 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +4 -0
+EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN

NO EVENT

drivers/gpu/drm/i915/intel_lpe_audio.c line 28

Quoted 2 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +2 -0
+SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,

DAMAGES

drivers/gpu/drm/i915/intel_lpe_audio.c line 30

Quoted 2 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +2 -0
+OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR

OTHERWISE,

drivers/gpu/drm/i915/intel_lpe_audio.c line 32

Quoted 2 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +2 -0
+ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE

OR

Quoted 11 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +11 -0
+OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Pierre-Louis Bossart <[email protected]>
+ *    Jerome Anand <[email protected]>
+ *    based on VED patches
+ *
+ */
+
+/**

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+ * 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.

Quoted 21 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +21 -0
+ *
+ * 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,

drivers/gpu/drm/i915/intel_lpe_audio.c line 84

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+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.

Quoted 17 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +17 -0
+ *
+ */
+
+#include <linux/acpi.h>
+#include <linux/device.h>
+#include <linux/pci.h>
+
+#include "i915_drv.h"
+#include <linux/delay.h>
+#include <drm/intel_lpe_audio.h>
+
+static struct platform_device *
+lpe_audio_platdev_create(struct drm_i915_private *dev_priv) {
+	struct drm_device *dev = &dev_priv->drm;
+	int ret;
+	struct resource rsc[2] = {};
+	struct platform_device *platdev;
Quoted 9 lines

drivers/gpu/drm/i915/intel_lpe_audio.c line 82

Quoted 5 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +5 -0
+	u64 *dma_mask;
+	struct intel_hdmi_lpe_audio_pdata *pdata;
+
+	if (dev_priv->lpe_audio.irq < 0)
+		return ERR_PTR(-EINVAL);

from Takashi: This was already tested, no?
JA: OK - can be removed

Sorry missed it.

Quoted 65 lines

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 5 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +5 -0
+
+	platdev = platform_device_alloc("hdmi-lpe-audio", -1);
+	if (!platdev) {
+		ret = -ENOMEM;
+		DRM_ERROR("Failed to allocate LPE audio platform

device\n");

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 5 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +5 -0
+		goto err;
+	}
+
+	/* to work-around check_addr in nommu_map_sg() */
+	dma_mask = kmalloc(sizeof(*platdev->dev.dma_mask),

GFP_KERNEL);

Quoted 7 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +7 -0
+	if (!dma_mask) {
+		ret = -ENOMEM;
+		DRM_ERROR("Failed to allocate dma_mask\n");
+		goto err_put_dev;
+	}
+	*dma_mask = DMA_BIT_MASK(32);
+	platdev->dev.dma_mask = dma_mask;

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+	platdev->dev.coherent_dma_mask = *dma_mask;
+
+	rsc[0].start    = rsc[0].end = dev_priv->lpe_audio.irq;
+	rsc[0].flags    = IORESOURCE_IRQ;
+	rsc[0].name     = "hdmi-lpe-audio-irq";
+
+	rsc[1].start    = pci_resource_start(dev->pdev, 0) +
+		I915_HDMI_LPE_AUDIO_BASE;
+	rsc[1].end      = pci_resource_start(dev->pdev, 0) +
+		I915_HDMI_LPE_AUDIO_BASE +

I915_HDMI_LPE_AUDIO_SIZE - 1;

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 6 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +6 -0
+	rsc[1].flags    = IORESOURCE_MEM;
+	rsc[1].name     = "hdmi-lpe-audio-mmio";
+
+	ret = platform_device_add_resources(platdev, rsc, 2);
+	if (ret) {
+		DRM_ERROR("Failed to add resource for platform device:

%d\n",

Quoted 8 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +8 -0
+			ret);
+		goto err_put_dev;
+	}
+
+	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+
+	if (pdata == NULL) {
+		ret = -ENOMEM;

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+		goto err_put_dev;
+	}
+	platdev->dev.platform_data = pdata;
+	spin_lock_init(&pdata->lpe_audio_slock);
+
+	/* for LPE audio driver's runtime-PM */
+	platdev->dev.parent = dev->dev;
+	ret = platform_device_add(platdev);
+	if (ret) {
+		DRM_ERROR("Failed to add LPE audio platform device:

%d\n",

Quoted 9 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +9 -0
+			ret);
+		goto err_put_dev;
+	}
+
+	return platdev;
+err_put_dev:
+	platform_device_put(platdev);
+	kfree(dma_mask);
+err:
Quoted 9 lines

drivers/gpu/drm/i915/intel_lpe_audio.c line 168

Quoted 2 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +2 -0
+	return ERR_PTR(ret);
+}

from Takashi:
guess using platform_device_register_full() makes the code a bit simpler.
JA: OK - agreed, but will keep it since its acked by Daniel.
-> what's the downside to using simpler code?

I felt the existing implementation is also simple and would like to keep it. I don’t see any advantage with the proposed change.

Quoted 17 lines

drivers/gpu/drm/i915/intel_lpe_audio.c line 157

Quoted 13 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +12 -0
+
+static void lpe_audio_platdev_destroy(struct drm_i915_private
+*dev_priv) {
+	platform_device_unregister(dev_priv->lpe_audio.platdev);
+	kfree(dev_priv->lpe_audio.platdev->dev.dma_mask);
+}
+
+static void lpe_audio_irq_unmask(struct irq_data *d) {
+	struct drm_i915_private *dev_priv = d->chip_data;
+	unsigned long irqflags;
+	u32 val = (I915_LPE_PIPE_A_INTERRUPT |
+		I915_LPE_PIPE_B_INTERRUPT);

From Daniel: PIPE_C missing?
-> Yes for CherryTrail

This was asked by Ville to remove it since there is no PIPE C in VLV. So I believe it shouldn't make any difference

Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +11 -0
+
+	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
+
+	dev_priv->irq_mask &= ~val;
+	I915_WRITE(VLV_IIR, val);
+	I915_WRITE(VLV_IIR, val);
+	I915_WRITE(VLV_IMR, dev_priv->irq_mask);
+	POSTING_READ(VLV_IMR);
+
+	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); }
+
Quoted 9 lines

drivers/gpu/drm/i915/intel_lpe_audio.c line 157

Quoted 5 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +5 -0
+static void lpe_audio_irq_mask(struct irq_data *d) {
+	struct drm_i915_private *dev_priv = d->chip_data;
+	unsigned long irqflags;
+	u32 val = (I915_LPE_PIPE_A_INTERRUPT |
+		I915_LPE_PIPE_B_INTERRUPT);

From Daniel: PIPE_C missing?
-> Yes for CherryTrail

This was asked by Ville to remove it since there is no PIPE C in VLV. So I believe it shouldn't make any difference

Quoted 71 lines
Quoted 35 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +35 -0
+
+	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
+
+	dev_priv->irq_mask |= val;
+	I915_WRITE(VLV_IMR, dev_priv->irq_mask);
+	I915_WRITE(VLV_IIR, val);
+	I915_WRITE(VLV_IIR, val);
+	POSTING_READ(VLV_IIR);
+
+	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); }
+
+static struct irq_chip lpe_audio_irqchip = {
+	.name = "hdmi_lpe_audio_irqchip",
+	.irq_mask = lpe_audio_irq_mask,
+	.irq_unmask = lpe_audio_irq_unmask,
+};
+
+static int lpe_audio_irq_init(struct drm_i915_private *dev_priv) {
+	int irq = dev_priv->lpe_audio.irq;
+
+	WARN_ON(!intel_irqs_enabled(dev_priv));
+	irq_set_chip_and_handler_name(irq,
+				&lpe_audio_irqchip,
+				handle_simple_irq,
+				"hdmi_lpe_audio_irq_handler");
+
+	return irq_set_chip_data(irq, 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.

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+ */
+void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv) {
+	int ret;
+
+	if (!HAS_LPE_AUDIO(dev_priv))
+		return;
+
+	ret = generic_handle_irq(dev_priv->lpe_audio.irq);
+	if (ret)
+		DRM_ERROR_RATELIMITED("error handling LPE audio irq:

%d\n",

Quoted 14 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +14 -0
+				ret);
+}
+
+/**
+ * intel_lpe_audio_detect() - check & setup lpe audio if present
+ * @dev_priv: the i915 drm device private data
+ *
+ * Detect if lpe audio is present
+ *
+ * Return: true if lpe audio present else Return = false  */ bool
+intel_lpe_audio_detect(struct drm_i915_private *dev_priv) {
+	int lpe_present = false;
+
+	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+		static const struct pci_device_id atom_hdaudio_ids[] = {
+			/* Baytrail */
+			{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0f04)},
+			/* Braswell */
+			{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2284)},
+			{}
+		};
+
+		if (!pci_dev_present(atom_hdaudio_ids)) {
+			DRM_INFO("%s%s\n", "HDaudio controller not

detected,",

Quoted 7 lines

drivers/gpu/drm/i915/intel_lpe_audio.c line 250

Quoted 1 line
drivers/gpu/drm/i915/intel_lpe_audio.c new file +1 -0
+				"using LPE audio instead\n");

From Takashi:
Why %s%s? Just keep one line without line breakage. The 80 chars rule is just a suggestion, no strict rule at all.
JA: OK

Logging should be fine. I prefer to keep this.

Quoted 100 lines
Quoted 35 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +34 -0
+			lpe_present = true;
+		}
+	}
+	return lpe_present;
+}
+
+/**
+ * intel_lpe_audio_setup() - setup the bridge between HDMI LPE Audio
+ * driver and i915
+ * @dev_priv: the i915 drm device private data
+ *
+ * set up the minimum required resources for the bridge: irq chip,
+ * platform resource and platform device. i915 device is set as
+parent
+ * of the new platform device.
+ *
+ * Return: 0 if successful. non-zero if allocation/initialization
+fails  */ int intel_lpe_audio_setup(struct drm_i915_private
+*dev_priv) {
+	int ret;
+
+	dev_priv->lpe_audio.irq = irq_alloc_desc(0);
+	if (dev_priv->lpe_audio.irq < 0) {
+		DRM_ERROR("Failed to allocate IRQ desc: %d\n",
+			dev_priv->lpe_audio.irq);
+		ret = dev_priv->lpe_audio.irq;
+		goto err;
+	}
+
+	DRM_DEBUG("irq = %d\n", dev_priv->lpe_audio.irq);
+
+	ret = lpe_audio_irq_init(dev_priv);
+
+	if (ret) {

drivers/gpu/drm/i915/intel_lpe_audio.c

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +10 -0
+		DRM_ERROR("Failed to initialize irqchip for lpe audio: %d\n",
+			ret);
+		goto err_free_irq;
+	}
+
+	dev_priv->lpe_audio.platdev = lpe_audio_platdev_create(dev_priv);
+
+	if (IS_ERR(dev_priv->lpe_audio.platdev)) {
+		ret = PTR_ERR(dev_priv->lpe_audio.platdev);
+		DRM_ERROR("Failed to create lpe audio platform device:

%d\n",

Quoted 54 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +54 -0
+			ret);
+		goto err_free_irq;
+	}
+
+	return 0;
+err_free_irq:
+	irq_free_desc(dev_priv->lpe_audio.irq);
+err:
+	dev_priv->lpe_audio.irq = -1;
+	dev_priv->lpe_audio.platdev = NULL;
+	return ret;
+}
+
+
+/**
+ * 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) {
+	int ret = -ENODEV;
+
+	if (intel_lpe_audio_detect(dev_priv)) {
+		ret = intel_lpe_audio_setup(dev_priv);
+		if (ret < 0)
+			DRM_ERROR("failed to setup LPE Audio bridge\n");
+	}
+	return ret;
+}
+
+/**
+ * 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) {
+	unsigned long irqflags;
+	struct irq_desc *desc;
+
+	if (!HAS_LPE_AUDIO(dev_priv))
+		return;
+
+	desc = irq_to_desc(dev_priv->lpe_audio.irq);
+
+	lpe_audio_irq_mask(&desc->irq_data);
+
+	spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
+
Quoted 9 lines

drivers/gpu/drm/i915/intel_lpe_audio.c line 354

Quoted 5 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +5 -0
+	lpe_audio_platdev_destroy(dev_priv);
+
+	irq_free_desc(dev_priv->lpe_audio.irq);
+
+	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);

From Takashi: What's the reason of this spinlock?
JA: JIC - probably not needed now

Kept this for the irq free.
Will remove it and test once

Quoted 62 lines
Quoted 19 lines
drivers/gpu/drm/i915/intel_lpe_audio.c new file +1 -0
+}
(quoted diff) +0 -0

b/include/drm/intel_lpe_audio.h new file mode 100644 index 0000000..a64c449

include/drm/intel_lpe_audio.h new file +12 -0
@@ -0,0 +1,45 @@
+/*
+ * 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

include/drm/intel_lpe_audio.h line 22

Quoted 10 lines
include/drm/intel_lpe_audio.h new file +10 -0
+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,

include/drm/intel_lpe_audio.h line 26

Quoted 4 lines
include/drm/intel_lpe_audio.h new file +4 -0
+EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN

NO EVENT

include/drm/intel_lpe_audio.h line 28

Quoted 2 lines
include/drm/intel_lpe_audio.h new file +2 -0
+SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,

DAMAGES

include/drm/intel_lpe_audio.h line 30

Quoted 2 lines
include/drm/intel_lpe_audio.h new file +2 -0
+OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR

OTHERWISE,

include/drm/intel_lpe_audio.h line 32

Quoted 2 lines
include/drm/intel_lpe_audio.h new file +2 -0
+ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE

OR

Quoted 18 lines
include/drm/intel_lpe_audio.h new file +18 -0
+OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef _INTEL_LPE_AUDIO_H_
+#define _INTEL_LPE_AUDIO_H_
+
+#include <linux/types.h>
+
+#define HDMI_MAX_ELD_BYTES	128
+
+struct intel_hdmi_lpe_audio_eld {
+	int port_id;
+	unsigned char eld_data[HDMI_MAX_ELD_BYTES]; };
+
+struct intel_hdmi_lpe_audio_pdata {
+	bool notify_pending;
+	int tmds_clock_speed;
Quoted 8 lines

include/drm/intel_lpe_audio.h line 45

Quoted 8 lines
include/drm/intel_lpe_audio.h new file +7 -0
+	bool hdmi_connected;
+	struct intel_hdmi_lpe_audio_eld eld;
+	void (*notify_audio_lpe)(void *audio_ptr);
+	spinlock_t lpe_audio_slock;
+};
+
+#endif /* _I915_LPE_AUDIO_H_ */

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

PATCH v2 2/7 drm/i915: Add support for audio driver notifications

In reply to Jerome Anand

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

---
 drivers/gpu/drm/i915/i915_drv.h        |  3 +++
 drivers/gpu/drm/i915/intel_audio.c     |  8 ++++++
 drivers/gpu/drm/i915/intel_hdmi.c      |  1 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 46 ++++++++++++++++++++++++++++++++++
 include/drm/intel_lpe_audio.h          |  1 +
 5 files changed, 59 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 2f8165e..263bc48 100644
@@ -3634,6 +3634,9 @@ int  intel_lpe_audio_setup(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);
 bool intel_lpe_audio_detect(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,
+			bool connected);
 
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_audio.c +8 -0
index 16c2027..aeb37c2 100644
@@ -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,10 @@ 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);
+
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_notify(dev_priv, connector->eld, port,
+			crtc_state->port_clock, true);
 }
 
 /**
@@ -663,6 +668,9 @@ 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);
+
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_notify(dev_priv, NULL, port, 0, false);
 }
 
 /**
drivers/gpu/drm/i915/intel_hdmi.c +1 -0
index 0bcfead..377584e1 100644
@@ -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)
drivers/gpu/drm/i915/intel_lpe_audio.c +46 -0

49 lines not on this page · raw message

include/drm/intel_lpe_audio.h +1 -0
index a64c449..952de05 100644
@@ -25,6 +25,7 @@
 #define _INTEL_LPE_AUDIO_H_
 
 #include <linux/types.h>
+#include <linux/spinlock_types.h>
 
 #define HDMI_MAX_ELD_BYTES	128
 
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [alsa-devel] [PATCH V2 2/7] drm/i915: Add support for audio driver notifications

Same here, missing fixes on agreed comments?

Quoted 55 lines · Jerome Anand

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

---
 drivers/gpu/drm/i915/i915_drv.h        |  3 +++
 drivers/gpu/drm/i915/intel_audio.c     |  8 ++++++
 drivers/gpu/drm/i915/intel_hdmi.c      |  1 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 46 ++++++++++++++++++++++++++++++++++
 include/drm/intel_lpe_audio.h          |  1 +
 5 files changed, 59 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 2f8165e..263bc48 100644
@@ -3634,6 +3634,9 @@ int  intel_lpe_audio_setup(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);
 bool intel_lpe_audio_detect(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,
+			bool connected);
 
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_audio.c +5 -0
index 16c2027..aeb37c2 100644
@@ -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,10 @@ 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);
+
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_notify(dev_priv, connector->eld, port,
+			crtc_state->port_clock, true);
 }
 
 /**

drivers/gpu/drm/i915/intel_audio.c void intel_audio_codec_disable(struct intel_encoder *intel_encoder) · line 674

Quoted 7 lines
drivers/gpu/drm/i915/intel_audio.c +3 -0
@@ -663,6 +668,9 @@ 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);
+
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_notify(dev_priv, NULL, port, 0, false);
 }

From Ville: The entire 'connected' parameter seems superfluous. Also why aren't we passing 'pipe' along here? How is the audio driver supposed to find the right thing to use?

Quoted 48 lines
drivers/gpu/drm/i915/intel_audio.c +0 -0
 /**
drivers/gpu/drm/i915/intel_hdmi.c +1 -0
index 0bcfead..377584e1 100644
@@ -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)
drivers/gpu/drm/i915/intel_lpe_audio.c +26 -0
index 05f5e4e..2a3c1e8 100644
@@ -353,3 +353,49 @@ void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv)
 
 	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
 }
+
+
+/**
+ * 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
+ * @connected: hdmi connected/disconnected
+ *
+ * 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,
+			bool connected)
+{
+	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));
+

drivers/gpu/drm/i915/intel_lpe_audio.c void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv) · line 391

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c +10 -0
+	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;
+
+		if (tmds_clk_speed)
+			pdata->tmds_clock_speed = tmds_clk_speed;
+	}

From Takashi: If eld==NULL means that no ELD is found (or disconnected), it's better to clear pdata eld as well, so that we don't leak the previous ELD.

JA: OK

Quoted 15 lines
drivers/gpu/drm/i915/intel_lpe_audio.c +10 -0
+	pdata->hdmi_connected = connected;
+	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);
+}
include/drm/intel_lpe_audio.h +0 -0
index a64c449..952de05 100644

include/drm/intel_lpe_audio.h line 28

Quoted 4 lines
include/drm/intel_lpe_audio.h +1 -0
@@ -25,6 +25,7 @@
 #define _INTEL_LPE_AUDIO_H_
 
 #include <linux/types.h>
+#include <linux/spinlock_types.h>

From Takashi: Why do we need to add a header at this point out of sudden?

JA: It was for some warning removal. I'll try to remove this if not applicable now.

include/drm/intel_lpe_audio.h

Quoted 4 lines
include/drm/intel_lpe_audio.h +0 -0
 #define HDMI_MAX_ELD_BYTES	128
 
 

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

Re: [alsa-devel] [PATCH V2 2/7] drm/i915: Add support for audio driver notifications

Quoted 12 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Saturday, January 7, 2017 1:50 AM
To: Anand, Jerome <[email protected]>; intel- [email protected]; [email protected]
Cc: [email protected]; [email protected]; Ughreja, Rakesh A <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH V2 2/7] drm/i915: Add support for audio driver notifications

Quoted 2 lines

Same here, missing fixes on agreed comments?

I have left some since it was addressed already. Comments inline.

Quoted 64 lines · Jerome Anand
Quoted 7 lines

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

Quoted 8 lines

Signed-off-by: Pierre-Louis Bossart
<[email protected]>

---
 drivers/gpu/drm/i915/i915_drv.h        |  3 +++
 drivers/gpu/drm/i915/intel_audio.c     |  8 ++++++
 drivers/gpu/drm/i915/intel_hdmi.c      |  1 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 46

++++++++++++++++++++++++++++++++++

drivers/gpu/drm/i915/intel_audio.c void intel_audio_codec_enable(struct

Quoted 32 lines
 include/drm/intel_lpe_audio.h          |  1 +
 5 files changed, 59 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 2f8165e..263bc48 100644

drivers/gpu/drm/i915/i915_drv.h +0 -0
@@ -3634,6 +3634,9 @@ int  intel_lpe_audio_setup(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);  bool intel_lpe_audio_detect(struct

drm_i915_private *dev_priv);

drivers/gpu/drm/i915/i915_drv.h +3 -1
+void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
+			void *eld, int port, int tmds_clk_speed,
+			bool connected);
 
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_i915_private *dev_priv); diff
--git a/drivers/gpu/drm/i915/intel_audio.c

b/drivers/gpu/drm/i915/intel_audio.c
index 16c2027..aeb37c2 100644

drivers/gpu/drm/i915/intel_audio.c +1 -0
@@ -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,10 @@ void intel_audio_codec_enable(struct

intel_encoder *intel_encoder,

drivers/gpu/drm/i915/intel_audio.c void intel_audio_codec_disable(struct

Quoted 13 lines
drivers/gpu/drm/i915/intel_audio.c +4 -0
 	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);
+
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_notify(dev_priv, connector->eld, port,
+			crtc_state->port_clock, true);
 }

/**

drivers/gpu/drm/i915/intel_audio.c +0 -0
@@ -663,6 +668,9 @@ void intel_audio_codec_disable(struct

intel_encoder *intel_encoder)

Quoted 15 lines

drivers/gpu/drm/i915/intel_audio.c void intel_audio_codec_disable(struct intel_encoder *intel_encoder) · line 674

Quoted 9 lines
drivers/gpu/drm/i915/intel_audio.c +3 -0
 	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);
+
+	if (HAS_LPE_AUDIO(dev_priv))
+		intel_lpe_audio_notify(dev_priv, NULL, port, 0, false);
 }

From Ville: The entire 'connected' parameter seems superfluous. Also why
aren't we passing 'pipe' along here? How is the audio driver supposed to find the right thing to use?

I thought we discussed this already. Audio need not know about the PIPE/ gfx design. I prefer to keep this 'connected' parameter.

Quoted 64 lines
Quoted 50 lines

/**

drivers/gpu/drm/i915/intel_hdmi.c +1 -0
index 0bcfead..377584e1 100644
@@ -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) diff --git a/drivers/gpu/drm/i915/intel_lpe_audio.c b/drivers/gpu/drm/i915/intel_lpe_audio.c
index 05f5e4e..2a3c1e8 100644

drivers/gpu/drm/i915/intel_lpe_audio.c +26 -0
@@ -353,3 +353,49 @@ void intel_lpe_audio_teardown(struct
 drm_i915_private *dev_priv)
 
 	spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);  }
+
+
+/**
+ * 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
+ * @connected: hdmi connected/disconnected
+ *
+ * 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,
+			bool connected)
+{
+	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));
+

drivers/gpu/drm/i915/intel_lpe_audio.c void intel_lpe_audio_teardown(struct · line 391

Quoted 10 lines
drivers/gpu/drm/i915/intel_lpe_audio.c +10 -0
+	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;
+
+		if (tmds_clk_speed)
+			pdata->tmds_clock_speed = tmds_clk_speed;
+	}

From Takashi: If eld==NULL means that no ELD is found (or disconnected),
it's better to clear pdata eld as well, so that we don't leak the previous ELD.

Quoted 2 lines

JA: OK

Eld is sent as NULL if unavailable. So leak is not possible. Hence ignored it.

Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/i915/intel_lpe_audio.c +10 -0
+	pdata->hdmi_connected = connected;
+	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);
+}
(quoted diff) +0 -0

b/include/drm/intel_lpe_audio.h index a64c449..952de05 100644

include/drm/intel_lpe_audio.h +0 -0
@@ -25,6 +25,7 @@
 #define _INTEL_LPE_AUDIO_H_
 
Quoted 8 lines

include/drm/intel_lpe_audio.h line 28

Quoted 2 lines
include/drm/intel_lpe_audio.h +1 -0
 #include <linux/types.h>
+#include <linux/spinlock_types.h>

From Takashi: Why do we need to add a header at this point out of sudden?

JA: It was for some warning removal. I'll try to remove this if not applicable now.

This is needed since we use spin lock in the code.

Quoted 5 lines

include/drm/intel_lpe_audio.h

Quoted 5 lines
include/drm/intel_lpe_audio.h +0 -0
 #define HDMI_MAX_ELD_BYTES	128
 
 

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

PATCH v2 3/7 ALSA: add shell for Intel HDMI LPE audio driver

In reply to Jerome Anand

On Baytrail and Cherrytrail, HDaudio may be fused out or disabled by the BIOS. This driver enables an alternate path to the i915 display registers and DMA.

Although there is no hardware path between i915 display and LPE/SST audio clusters, this HDMI capability is referred to in the documentation as "HDMI LPE Audio" so we keep the name for consistency. There is no hardware path or control dependencies with the LPE/SST DSP functionality.

The hdmi-lpe-audio driver will be probed when the i915 driver creates a child platform device.

Since this driver is neither SoC nor PCI, a new x86 folder is added

---
 sound/Kconfig                    |   2 +
 sound/Makefile                   |   2 +-
 sound/x86/Kconfig                |  16 +
 sound/x86/Makefile               |   6 +
 sound/x86/intel_hdmi_lpe_audio.c | 623 +++++++++++++++++++++++++++++++++++
 sound/x86/intel_hdmi_lpe_audio.h | 685 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 1333 insertions(+), 1 deletion(-)
 create mode 100644 sound/x86/Kconfig
 create mode 100644 sound/x86/Makefile
 create mode 100644 sound/x86/intel_hdmi_lpe_audio.c
 create mode 100644 sound/x86/intel_hdmi_lpe_audio.h
sound/Kconfig +2 -0
index 5a240e0..ee2e69a 100644
@@ -108,6 +108,8 @@ source "sound/parisc/Kconfig"
 
 source "sound/soc/Kconfig"
 
+source "sound/x86/Kconfig"
+
 endif # SND
 
 menuconfig SOUND_PRIME
sound/Makefile +1 -1
index c41bdf5..6de45d2 100644
@@ -5,7 +5,7 @@ obj-$(CONFIG_SOUND) += soundcore.o
 obj-$(CONFIG_SOUND_PRIME) += oss/
 obj-$(CONFIG_DMASOUND) += oss/
 obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \
-	firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/ hda/
+	firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/ hda/ x86/
 obj-$(CONFIG_SND_AOA) += aoa/
 
 # This one must be compilable even if sound is configured out
sound/x86/Kconfig new file +16 -0
new file mode 100644
index 0000000..e9297d0
@@ -0,0 +1,16 @@
+menuconfig SND_X86
+	tristate "X86 sound devices"
+	---help---
+
+	  X86 sound devices that don't fall under SoC or PCI categories
+
+if SND_X86
+
+config HDMI_LPE_AUDIO
+	tristate "HDMI audio without HDaudio on Intel Atom platforms"
+	depends on DRM_I915
+	default n
+	help
+	 Choose this option to support HDMI LPE Audio mode
+
+endif	# SND_X86
sound/x86/Makefile new file +6 -0
new file mode 100644
index 0000000..baa6333
@@ -0,0 +1,6 @@
+ccflags-y += -Idrivers/gpu/drm/i915
+
+snd-hdmi-lpe-audio-objs += \
+	intel_hdmi_lpe_audio.o
+
+obj-$(CONFIG_HDMI_LPE_AUDIO) += snd-hdmi-lpe-audio.o
sound/x86/intel_hdmi_lpe_audio.c new file +623 -0

623 lines not on this page · raw message

sound/x86/intel_hdmi_lpe_audio.h new file +685 -0

685 lines not on this page · raw message

Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

Re: [alsa-devel] [PATCH V2 3/7] ALSA: add shell for Intel HDMI LPE audio driver

Minor misses here as well.

Quoted 9 lines · Jerome Anand

On Baytrail and Cherrytrail, HDaudio may be fused out or disabled by the BIOS. This driver enables an alternate path to the i915 display registers and DMA.

Although there is no hardware path between i915 display and LPE/SST audio clusters, this HDMI capability is referred to in the documentation as "HDMI LPE Audio" so we keep the name for consistency. There is no hardware path or control dependencies with the LPE/SST DSP functionality.

Quoted 7 lines

The hdmi-lpe-audio driver will be probed when the i915 driver creates a child platform device.

Since this driver is neither SoC nor PCI, a new x86 folder is added

Change the commit title to remove 'shell', e.g. 'add BYT/CHT-T HDMI LPE audio driver' and mention that indirect calls will be removed later (to help with DP integration)

Quoted 28 lines
sound/x86/Kconfig new file +16 -0
new file mode 100644
index 0000000..e9297d0
@@ -0,0 +1,16 @@
+menuconfig SND_X86
+	tristate "X86 sound devices"
+	---help---
+
+	  X86 sound devices that don't fall under SoC or PCI categories
+
+if SND_X86
+
+config HDMI_LPE_AUDIO
+	tristate "HDMI audio without HDaudio on Intel Atom platforms"
+	depends on DRM_I915
+	default n
+	help
+	 Choose this option to support HDMI LPE Audio mode
+
+endif	# SND_X86
sound/x86/Makefile new file +0 -0
new file mode 100644
index 0000000..baa6333

sound/x86/Makefile line 1

Quoted 1 line
sound/x86/Makefile new file +1 -0
@@ -0,0 +1,6 @@
+ccflags-y += -Idrivers/gpu/drm/i915

from Takashi: Is it just for intel_lpe_audio.h? Then rather put intel_lpe_audio.h to include/drm.
JA: OK

Quoted 23 lines
sound/x86/Makefile new file +5 -0
+
+snd-hdmi-lpe-audio-objs += \
+	intel_hdmi_lpe_audio.o
+
+obj-$(CONFIG_HDMI_LPE_AUDIO) += snd-hdmi-lpe-audio.o
sound/x86/intel_hdmi_lpe_audio.c new file +12 -0
new file mode 100644
index 0000000..61347ab
@@ -0,0 +1,623 @@
+/*
+ *  intel_hdmi_lpe_audio.c - Intel HDMI LPE audio driver for Atom platforms
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:
+ *		Jerome Anand <[email protected]>
+ *		Aravind Siddappaji <[email protected]>
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.

sound/x86/intel_hdmi_lpe_audio.c line 22

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#define pr_fmt(fmt)	"hdmi_lpe_audio: " fmt

From Takashi: Better to use dev_*() variant.
JA: OK

Quoted 6 lines
sound/x86/intel_hdmi_lpe_audio.c new file +6 -0
+static inline int hdmi_get_eld(void *eld)
+{
+	memcpy(eld, (void *)&hlpe_eld, sizeof(hlpe_eld));
+
+	{
+		int i;

sound/x86/intel_hdmi_lpe_audio.c line 82

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+		uint8_t *eld_data = (uint8_t *)&hlpe_eld;
+
+		pr_debug("hdmi_get_eld:\n{{");
+
+		for (i = 0; i < sizeof(hlpe_eld); i++)
+			pr_debug("0x%x, ", eld_data[i]);
+
+		pr_debug("}}\n");
+	}
+	return 0;

From Takashi: There is a hexdump debug print helper, too.
JA: OK

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

Re: [alsa-devel] [PATCH V2 3/7] ALSA: add shell for Intel HDMI LPE audio driver

Quoted 12 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Saturday, January 7, 2017 2:03 AM
To: Anand, Jerome <[email protected]>; intel- [email protected]; [email protected]
Cc: [email protected]; [email protected]; Ughreja, Rakesh A <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH V2 3/7] ALSA: add shell for Intel HDMI LPE audio driver

Quoted 2 lines

Minor misses here as well.

Ignored it since it was mostly cosmetic.

Quoted 16 lines · Jerome Anand
Quoted 8 lines

On Baytrail and Cherrytrail, HDaudio may be fused out or disabled by the BIOS. This driver enables an alternate path to the i915 display registers and DMA.

Although there is no hardware path between i915 display and LPE/SST audio clusters, this HDMI capability is referred to in the documentation as "HDMI LPE Audio" so we keep the name for consistency. There is no hardware path or control dependencies with the LPE/SST DSP

functionality.

Quoted 6 lines

The hdmi-lpe-audio driver will be probed when the i915 driver creates a child platform device.

Since this driver is neither SoC nor PCI, a new x86 folder is added

Quoted 8 lines
Quoted 3 lines

Signed-off-by: Pierre-Louis Bossart
<[email protected]>

Change the commit title to remove 'shell', e.g. 'add BYT/CHT-T HDMI LPE audio driver' and mention that indirect calls will be removed later (to help with DP integration)

OK

Quoted 94 lines
Quoted 27 lines
sound/x86/Kconfig new file mode renamed from sound/x86/Kconfig +0 -0

100644 index 0000000..e9297d0

sound/x86/Kconfig new file +16 -0
@@ -0,0 +1,16 @@
+menuconfig SND_X86
+	tristate "X86 sound devices"
+	---help---
+
+	  X86 sound devices that don't fall under SoC or PCI categories
+
+if SND_X86
+
+config HDMI_LPE_AUDIO
+	tristate "HDMI audio without HDaudio on Intel Atom platforms"
+	depends on DRM_I915
+	default n
+	help
+	 Choose this option to support HDMI LPE Audio mode
+
+endif	# SND_X86
sound/x86/Makefile new file mode renamed from sound/x86/Makefile +0 -0

100644 index 0000000..baa6333

sound/x86/Makefile line 1

Quoted 1 line
sound/x86/Makefile new file +1 -0
@@ -0,0 +1,6 @@
+ccflags-y += -Idrivers/gpu/drm/i915

from Takashi: Is it just for intel_lpe_audio.h? Then rather put intel_lpe_audio.h to include/drm.
JA: OK

Quoted 13 lines
sound/x86/Makefile new file +5 -0
+
+snd-hdmi-lpe-audio-objs += \
+	intel_hdmi_lpe_audio.o
+
+obj-$(CONFIG_HDMI_LPE_AUDIO) += snd-hdmi-lpe-audio.o
sound/x86/intel_hdmi_lpe_audio.c new file +0 -0
new file mode 100644
index 0000000..61347ab

sound/x86/intel_hdmi_lpe_audio.c line 9

Quoted 9 lines
sound/x86/intel_hdmi_lpe_audio.c new file +9 -0
@@ -0,0 +1,623 @@
+/*
+ *  intel_hdmi_lpe_audio.c - Intel HDMI LPE audio driver for Atom
+platforms
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:
+ *		Jerome Anand <[email protected]>
+ *		Aravind Siddappaji <[email protected]>
+ *

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~

sound/x86/intel_hdmi_lpe_audio.c line 21

Quoted 12 lines
sound/x86/intel_hdmi_lpe_audio.c new file +12 -0
+~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or
+modify
+ *  it under the terms of the GNU General Public License as published
+by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

GNU

sound/x86/intel_hdmi_lpe_audio.c

Quoted 4 lines
sound/x86/intel_hdmi_lpe_audio.c new file +3 -0
+ *  General Public License for more details.
+ *
+ *

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~

sound/x86/intel_hdmi_lpe_audio.c line 22

Quoted 4 lines
sound/x86/intel_hdmi_lpe_audio.c new file +4 -0
+~~~~~
+ */
+
+#define pr_fmt(fmt)	"hdmi_lpe_audio: " fmt

From Takashi: Better to use dev_*() variant.
JA: OK

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+static inline int hdmi_get_eld(void *eld) {
+	memcpy(eld, (void *)&hlpe_eld, sizeof(hlpe_eld));
+
+	{
+		int i;
+		uint8_t *eld_data = (uint8_t *)&hlpe_eld;
+
+		pr_debug("hdmi_get_eld:\n{{");
+
+		for (i = 0; i < sizeof(hlpe_eld); i++)
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 82

Quoted 5 lines
sound/x86/intel_hdmi_lpe_audio.c new file +5 -0
+			pr_debug("0x%x, ", eld_data[i]);
+
+		pr_debug("}}\n");
+	}
+	return 0;

From Takashi: There is a hexdump debug print helper, too.
JA: OK

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

PATCH v2 4/7 ALSA: x86: hdmi: Add audio support for BYT and CHT

In reply to Jerome Anand

Hdmi audio driver based on the child platform device created by gfx driver is implemented.
This audio driver is derived from legacy intel hdmi audio driver.

The interfaces for interaction between gfx and audio are updated and the driver implementation updated to derive interrupts in its own address space based on irq chip framework

---
 sound/x86/Makefile               |    2 +
 sound/x86/intel_hdmi_audio.c     | 1903 ++++++++++++++++++++++++++++++++++++++
 sound/x86/intel_hdmi_audio.h     |  201 ++++
 sound/x86/intel_hdmi_audio_if.c  |  551 +++++++++++
 sound/x86/intel_hdmi_lpe_audio.c |   16 +-
 5 files changed, 2667 insertions(+), 6 deletions(-)
 create mode 100644 sound/x86/intel_hdmi_audio.c
 create mode 100644 sound/x86/intel_hdmi_audio.h
 create mode 100644 sound/x86/intel_hdmi_audio_if.c
sound/x86/Makefile +2 -0
index baa6333..e405280 100644
@@ -1,6 +1,8 @@
 ccflags-y += -Idrivers/gpu/drm/i915
 
 snd-hdmi-lpe-audio-objs += \
+	intel_hdmi_audio.o \
+	intel_hdmi_audio_if.o \
 	intel_hdmi_lpe_audio.o
 
 obj-$(CONFIG_HDMI_LPE_AUDIO) += snd-hdmi-lpe-audio.o
sound/x86/intel_hdmi_audio.c new file +1903 -0

1,903 lines not on this page · raw message

sound/x86/intel_hdmi_audio.h new file +201 -0

201 lines not on this page · raw message

sound/x86/intel_hdmi_audio_if.c new file +551 -0

551 lines not on this page · raw message

sound/x86/intel_hdmi_lpe_audio.c +10 -6
index 61347ab..bee1bb4 100644
@@ -36,6 +36,7 @@
 #include <sound/initval.h>
 #include <drm/intel_lpe_audio.h>
 #include "intel_hdmi_lpe_audio.h"
+#include "intel_hdmi_audio.h"
 
 /* globals*/
 struct platform_device *hlpe_pdev;
@@ -462,9 +463,9 @@ static void notify_audio_lpe(void *audio_ptr)
 /**
  * hdmi_lpe_audio_probe - start bridge with i915
  *
- * This function is called when the i915 driver creates the hdmi-lpe-audio
- * platform device. Card creation is deferred until a hot plug event is
- * received
+ * This function is called when the i915 driver creates the
+ * hdmi-lpe-audio platform device. Card creation is deferred until a
+ * hot plug event is received
  */
 static int hdmi_lpe_audio_probe(struct platform_device *pdev)
 {
@@ -506,8 +507,8 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
 		(unsigned int)res_mmio->start, (unsigned int)res_mmio->end);
 
 	mmio_start = ioremap_nocache(res_mmio->start,
-				(size_t)((res_mmio->end - res_mmio->start)
-						+ 1));
+				(size_t)((res_mmio->end -
+					res_mmio->start) + 1));
 	if (!mmio_start) {
 		pr_err("Could not get ioremap\n");
 		return -EACCES;
@@ -557,11 +558,12 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ctx);
 
+	ret = hdmi_audio_probe((void *)pdev);
+
 	pr_debug("hdmi lpe audio: setting pin eld notify callback\n");
 
 	spin_lock_irqsave(&pdata->lpe_audio_slock, flag_irq);
 	pdata->notify_audio_lpe = notify_audio_lpe;
-
 	if (pdata->notify_pending) {
 
 		pr_debug("%s: handle pending notification\n", __func__);
@@ -585,6 +587,8 @@ static int hdmi_lpe_audio_remove(struct platform_device *pdev)
 
 	pr_debug("Enter %s\n", __func__);
 
+	hdmi_audio_remove(pdev);
+
 	/* get context, release resources */
 	ctx = platform_get_drvdata(pdev);
 	iounmap(ctx->mmio_start);
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

PATCH v2 5/7 ALSA: x86: hdmi: Improve position reporting

In reply to Jerome Anand

Use a hw register to calculate sub-period position reports. This makes PulseAudio happier.

---
 sound/x86/intel_hdmi_audio.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
sound/x86/intel_hdmi_audio.c +11 -1
index d7b57658..d2036bc 100644
@@ -1489,6 +1489,8 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 {
 	struct snd_intelhad *intelhaddata;
 	u32 bytes_rendered = 0;
+	u32 t;
+	int buf_id;
 
 	/* pr_debug("snd_intelhad_pcm_pointer called\n"); */
 
@@ -1499,6 +1501,14 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 		return SNDRV_PCM_POS_XRUN;
 	}
 
+	buf_id = intelhaddata->curr_buf % 4;
+	had_read_register(AUD_BUF_A_LENGTH + (buf_id * HAD_REG_WIDTH), &t);
+	if (t == 0) {
+		pr_debug("discovered buffer done for buf %d\n", buf_id);
+		/* had_process_buffer_done(intelhaddata); */
+	}
+	t = intelhaddata->buf_info[buf_id].buf_size - t;
+
 	if (intelhaddata->stream_info.buffer_rendered)
 		div_u64_rem(intelhaddata->stream_info.buffer_rendered,
 			intelhaddata->stream_info.ring_buf_size,
@@ -1506,7 +1516,7 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 
 	intelhaddata->stream_info.buffer_ptr = bytes_to_frames(
 						substream->runtime,
-						bytes_rendered);
+						bytes_rendered + t);
 	return intelhaddata->stream_info.buffer_ptr;
 }
 
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

Re: [alsa-devel] [PATCH V2 5/7] ALSA: x86: hdmi: Improve position reporting

Quoted 2 lines · Jerome Anand

Use a hw register to calculate sub-period position reports. This makes PulseAudio happier.

From Takashi: There is no big merit to keep this a separate patch. Please fold into the main patch. You can put some comment in the code for explanation.

Quoted 38 lines
---
 sound/x86/intel_hdmi_audio.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
sound/x86/intel_hdmi_audio.c +10 -0
index d7b57658..d2036bc 100644
@@ -1489,6 +1489,8 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 {
 	struct snd_intelhad *intelhaddata;
 	u32 bytes_rendered = 0;
+	u32 t;
+	int buf_id;
 
 	/* pr_debug("snd_intelhad_pcm_pointer called\n"); */
 
@@ -1499,6 +1501,14 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 		return SNDRV_PCM_POS_XRUN;
 	}
 
+	buf_id = intelhaddata->curr_buf % 4;
+	had_read_register(AUD_BUF_A_LENGTH + (buf_id * HAD_REG_WIDTH), &t);
+	if (t == 0) {
+		pr_debug("discovered buffer done for buf %d\n", buf_id);
+		/* had_process_buffer_done(intelhaddata); */
+	}
+	t = intelhaddata->buf_info[buf_id].buf_size - t;
+
 	if (intelhaddata->stream_info.buffer_rendered)
 		div_u64_rem(intelhaddata->stream_info.buffer_rendered,
 			intelhaddata->stream_info.ring_buf_size,

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t snd_intelhad_pcm_pointer( · line 1522

Quoted 8 lines
sound/x86/intel_hdmi_audio.c +1 -1
@@ -1506,7 +1516,7 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 
 	intelhaddata->stream_info.buffer_ptr = bytes_to_frames(
 						substream->runtime,
-						bytes_rendered);
+						bytes_rendered + t);
 	return intelhaddata->stream_info.buffer_ptr;
 }
 

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#13 lore raw

Re: [alsa-devel] [PATCH V2 5/7] ALSA: x86: hdmi: Improve position reporting

Quoted 12 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Saturday, January 7, 2017 2:10 AM
To: Anand, Jerome <[email protected]>; intel- [email protected]; [email protected]
Cc: [email protected]; [email protected]; Ughreja, Rakesh A <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH V2 5/7] ALSA: x86: hdmi: Improve position reporting

Quoted 8 lines
Quoted 2 lines · Jerome Anand

Use a hw register to calculate sub-period position reports. This makes PulseAudio happier.

From Takashi: There is no big merit to keep this a separate patch.
Please fold into the main patch. You can put some comment in the code for explanation.

Misread the final comments. Thought we will be having it as separate patches only Do you still think we can merge these changes to the main file ?

Quoted 45 lines

Review

Quoted 11 lines
---
 sound/x86/intel_hdmi_audio.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/sound/x86/intel_hdmi_audio.c

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t

Quoted 4 lines

index d7b57658..d2036bc 100644

sound/x86/intel_hdmi_audio.c +0 -0
@@ -1489,6 +1489,8 @@ static snd_pcm_uframes_t

snd_intelhad_pcm_pointer(

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t

Quoted 9 lines
sound/x86/intel_hdmi_audio.c +2 -0
 {
 	struct snd_intelhad *intelhaddata;
 	u32 bytes_rendered = 0;
+	u32 t;
+	int buf_id;
 
 	/* pr_debug("snd_intelhad_pcm_pointer called\n"); */
 
@@ -1499,6 +1501,14 @@ static snd_pcm_uframes_t

snd_intelhad_pcm_pointer(

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t snd_intelhad_pcm_pointer(

Quoted 5 lines
sound/x86/intel_hdmi_audio.c +2 -0
 		return SNDRV_PCM_POS_XRUN;
 	}
 
+	buf_id = intelhaddata->curr_buf % 4;
+	had_read_register(AUD_BUF_A_LENGTH + (buf_id *

HAD_REG_WIDTH), &t);

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t

Quoted 10 lines
sound/x86/intel_hdmi_audio.c +6 -0
+	if (t == 0) {
+		pr_debug("discovered buffer done for buf %d\n", buf_id);
+		/* had_process_buffer_done(intelhaddata); */
+	}
+	t = intelhaddata->buf_info[buf_id].buf_size - t;
+
 	if (intelhaddata->stream_info.buffer_rendered)
 		div_u64_rem(intelhaddata->stream_info.buffer_rendered,
 			intelhaddata->stream_info.ring_buf_size,
@@ -1506,7 +1516,7 @@ static snd_pcm_uframes_t

snd_intelhad_pcm_pointer(

Quoted 1 line
Quoted 8 lines

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t snd_intelhad_pcm_pointer( · line 1521

Quoted 8 lines
sound/x86/intel_hdmi_audio.c +1 -1
 	intelhaddata->stream_info.buffer_ptr = bytes_to_frames(
 						substream->runtime,
-						bytes_rendered);
+						bytes_rendered + t);
 	return intelhaddata->stream_info.buffer_ptr;
 }

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw

PATCH v2 6/7 ALSA: x86: hdmi: Fixup some monitor

In reply to Jerome Anand

This change was given to Canonical apparently to fix an issue with on some monitor brand. It's not clear what this patch does but it doesn't seem to have side effects.

---
 sound/x86/intel_hdmi_audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/x86/intel_hdmi_audio.c +2 -2
index d2036bc..91efbeb 100644
@@ -337,6 +337,7 @@ static void snd_intelhad_reset_audio_v2(u8 reset)
 static int had_prog_status_reg(struct snd_pcm_substream *substream,
 			struct snd_intelhad *intelhaddata)
 {
+	union aud_cfg cfg_val = {.cfg_regval = 0};
 	union aud_ch_status_0 ch_stat0 = {.status_0_regval = 0};
 	union aud_ch_status_1 ch_stat1 = {.status_1_regval = 0};
 	int format;
@@ -347,6 +348,7 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream,
 						IEC958_AES0_NONAUDIO)>>1;
 	ch_stat0.status_0_regx.clk_acc = (intelhaddata->aes_bits &
 						IEC958_AES3_CON_CLOCK)>>4;
+	cfg_val.cfg_regx.val_bit = ch_stat0.status_0_regx.lpcm_id;
 
 	switch (substream->runtime->rate) {
 	case AUD_SAMPLE_RATE_32:
@@ -426,7 +428,6 @@ int snd_intelhad_prog_audio_ctrl_v2(struct snd_pcm_substream *substream,
 	else
 		cfg_val.cfg_regx_v2.layout = LAYOUT1;
 
-	cfg_val.cfg_regx_v2.val_bit = 1;
 	had_write_register(AUD_CONFIG, cfg_val.cfg_regval);
 	return 0;
 }
@@ -482,7 +483,6 @@ int snd_intelhad_prog_audio_ctrl_v1(struct snd_pcm_substream *substream,
 
 	}
 
-	cfg_val.cfg_regx.val_bit = 1;
 	had_write_register(AUD_CONFIG, cfg_val.cfg_regval);
 	return 0;
 }
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

Re: [alsa-devel] [PATCH V2 6/7] ALSA: x86: hdmi: Fixup some monitor

Quoted 3 lines · Jerome Anand

This change was given to Canonical apparently to fix an issue with on some monitor brand. It's not clear what this patch does but it doesn't seem to have side effects.

From Takashi:please fold into the main patch and give the comments in the code instead.

Quoted 38 lines
---
 sound/x86/intel_hdmi_audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/x86/intel_hdmi_audio.c +2 -1
index d2036bc..91efbeb 100644
@@ -337,6 +337,7 @@ static void snd_intelhad_reset_audio_v2(u8 reset)
 static int had_prog_status_reg(struct snd_pcm_substream *substream,
 			struct snd_intelhad *intelhaddata)
 {
+	union aud_cfg cfg_val = {.cfg_regval = 0};
 	union aud_ch_status_0 ch_stat0 = {.status_0_regval = 0};
 	union aud_ch_status_1 ch_stat1 = {.status_1_regval = 0};
 	int format;
@@ -347,6 +348,7 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream,
 						IEC958_AES0_NONAUDIO)>>1;
 	ch_stat0.status_0_regx.clk_acc = (intelhaddata->aes_bits &
 						IEC958_AES3_CON_CLOCK)>>4;
+	cfg_val.cfg_regx.val_bit = ch_stat0.status_0_regx.lpcm_id;
 
 	switch (substream->runtime->rate) {
 	case AUD_SAMPLE_RATE_32:
@@ -426,7 +428,6 @@ int snd_intelhad_prog_audio_ctrl_v2(struct snd_pcm_substream *substream,
 	else
 		cfg_val.cfg_regx_v2.layout = LAYOUT1;
 
-	cfg_val.cfg_regx_v2.val_bit = 1;
 	had_write_register(AUD_CONFIG, cfg_val.cfg_regval);
 	return 0;
 }

sound/x86/intel_hdmi_audio.c int snd_intelhad_prog_audio_ctrl_v1(struct snd_pcm_substream *substream, · line 488

Quoted 7 lines
sound/x86/intel_hdmi_audio.c +0 -1
@@ -482,7 +483,6 @@ int snd_intelhad_prog_audio_ctrl_v1(struct snd_pcm_substream *substream,
 
 	}
 
-	cfg_val.cfg_regx.val_bit = 1;
 	had_write_register(AUD_CONFIG, cfg_val.cfg_regval);
 	return 0;
 }

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#16 lore raw

PATCH v2 7/7 ALSA: x86: hdmi: continue playback even when display resolution changes

In reply to Jerome Anand

When the display resolution changes, the drm disables the display pipes due to which audio rendering stops. At this time, we need to ensure the existing audio pointers and buffers are cleared out so that the playback can restarted once the display pipe is enabled with a different N/CTS values

---
 sound/x86/intel_hdmi_audio.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
sound/x86/intel_hdmi_audio.c +18 -3
index 91efbeb..f4042f8 100644
@@ -43,6 +43,7 @@ static DEFINE_MUTEX(had_mutex);
 static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
 static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
 static struct snd_intelhad *had_data;
+static int underrun_count;
 
 module_param_named(index, hdmi_card_index, int, 0444);
 MODULE_PARM_DESC(index,
@@ -1114,6 +1115,7 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream)
 	intelhaddata = snd_pcm_substream_chip(substream);
 	had_stream = intelhaddata->private_data;
 	runtime = substream->runtime;
+	underrun_count = 0;
 
 	pm_runtime_get(intelhaddata->dev);
 
@@ -1503,10 +1505,23 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 
 	buf_id = intelhaddata->curr_buf % 4;
 	had_read_register(AUD_BUF_A_LENGTH + (buf_id * HAD_REG_WIDTH), &t);
-	if (t == 0) {
-		pr_debug("discovered buffer done for buf %d\n", buf_id);
-		/* had_process_buffer_done(intelhaddata); */
+
+	if ((t == 0) || (t == ((u32)-1L))) {
+		underrun_count++;
+		pr_debug("discovered buffer done for buf %d, count = %d\n",
+			buf_id, underrun_count);
+
+		if (underrun_count > (HAD_MIN_PERIODS/2)) {
+			pr_debug("assume audio_codec_reset, underrun = %d - do xrun\n",
+				underrun_count);
+			underrun_count = 0;
+			return SNDRV_PCM_POS_XRUN;
+		}
+	} else {
+		/* Reset Counter */
+		underrun_count = 0;
 	}
+
 	t = intelhaddata->buf_info[buf_id].buf_size - t;
 
 	if (intelhaddata->stream_info.buffer_rendered)
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

Re: [alsa-devel] [PATCH V2 7/7] ALSA: x86: hdmi: continue playback even when display resolution changes

Quoted 5 lines · Jerome Anand

When the display resolution changes, the drm disables the display pipes due to which audio rendering stops. At this time, we need to ensure the existing audio pointers and buffers are cleared out so that the playback can restarted once the display pipe is enabled with a different N/CTS values

Add comment that this patch series has only been tested on hardware with a single HDMI connector/pipe and additional work may be needed for newer machines with 2 connectors.

Quoted 45 lines
---
 sound/x86/intel_hdmi_audio.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
sound/x86/intel_hdmi_audio.c +12 -3
index 91efbeb..f4042f8 100644
@@ -43,6 +43,7 @@ static DEFINE_MUTEX(had_mutex);
 static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
 static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
 static struct snd_intelhad *had_data;
+static int underrun_count;
 
 module_param_named(index, hdmi_card_index, int, 0444);
 MODULE_PARM_DESC(index,
@@ -1114,6 +1115,7 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream)
 	intelhaddata = snd_pcm_substream_chip(substream);
 	had_stream = intelhaddata->private_data;
 	runtime = substream->runtime;
+	underrun_count = 0;
 
 	pm_runtime_get(intelhaddata->dev);
 
@@ -1503,10 +1505,23 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 
 	buf_id = intelhaddata->curr_buf % 4;
 	had_read_register(AUD_BUF_A_LENGTH + (buf_id * HAD_REG_WIDTH), &t);
-	if (t == 0) {
-		pr_debug("discovered buffer done for buf %d\n", buf_id);
-		/* had_process_buffer_done(intelhaddata); */
+
+	if ((t == 0) || (t == ((u32)-1L))) {
+		underrun_count++;
+		pr_debug("discovered buffer done for buf %d, count = %d\n",
+			buf_id, underrun_count);
+
+		if (underrun_count > (HAD_MIN_PERIODS/2)) {
+			pr_debug("assume audio_codec_reset, underrun = %d - do xrun\n",
+				underrun_count);
+			underrun_count = 0;

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t snd_intelhad_pcm_pointer( · line 1527

Quoted 10 lines
sound/x86/intel_hdmi_audio.c +6 -0
+			return SNDRV_PCM_POS_XRUN;
+		}
+	} else {
+		/* Reset Counter */
+		underrun_count = 0;
 	}
+
 	t = intelhaddata->buf_info[buf_id].buf_size - t;
 
 	if (intelhaddata->stream_info.buffer_rendered)

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

Re: [alsa-devel] [PATCH V2 7/7] ALSA: x86: hdmi: continue playback even when display resolution changes

Quoted 19 lines

-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Saturday, January 7, 2017 2:13 AM
To: Anand, Jerome <[email protected]>; intel- [email protected]; [email protected]
Cc: [email protected]; [email protected]; Ughreja, Rakesh A <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH V2 7/7] ALSA: x86: hdmi: continue playback even when display resolution changes

Quoted 5 lines · Jerome Anand

When the display resolution changes, the drm disables the display pipes due to which audio rendering stops. At this time, we need to ensure the existing audio pointers and buffers are cleared out so that the playback can restarted once the display pipe is enabled with a different N/CTS values

Quoted 4 lines

Add comment that this patch series has only been tested on hardware with a single HDMI connector/pipe and additional work may be needed for newer machines with 2 connectors.

OK

Quoted 59 lines

Review

Quoted 8 lines
---
 sound/x86/intel_hdmi_audio.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/sound/x86/intel_hdmi_audio.c

sound/x86/intel_hdmi_audio.c static int snd_intelhad_open(struct

Quoted 12 lines

index 91efbeb..f4042f8 100644

sound/x86/intel_hdmi_audio.c +1 -0
@@ -43,6 +43,7 @@ static DEFINE_MUTEX(had_mutex);
 static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
 static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
 static struct snd_intelhad *had_data;
+static int underrun_count;
 
 module_param_named(index, hdmi_card_index, int, 0444);
 MODULE_PARM_DESC(index,
@@ -1114,6 +1115,7 @@ static int snd_intelhad_open(struct

snd_pcm_substream *substream)

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t

Quoted 8 lines
sound/x86/intel_hdmi_audio.c +1 -0
 	intelhaddata = snd_pcm_substream_chip(substream);
 	had_stream = intelhaddata->private_data;
 	runtime = substream->runtime;
+	underrun_count = 0;
 
 	pm_runtime_get(intelhaddata->dev);
 
@@ -1503,10 +1505,23 @@ static snd_pcm_uframes_t

snd_intelhad_pcm_pointer(

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t · line 1506

Quoted 3 lines
sound/x86/intel_hdmi_audio.c +0 -0
 	buf_id = intelhaddata->curr_buf % 4;
 	had_read_register(AUD_BUF_A_LENGTH + (buf_id *

HAD_REG_WIDTH), &t);

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t snd_intelhad_pcm_pointer(

Quoted 7 lines
sound/x86/intel_hdmi_audio.c +4 -3
-	if (t == 0) {
-		pr_debug("discovered buffer done for buf %d\n", buf_id);
-		/* had_process_buffer_done(intelhaddata); */
+
+	if ((t == 0) || (t == ((u32)-1L))) {
+		underrun_count++;
+		pr_debug("discovered buffer done for buf %d, count =

%d\n",

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t snd_intelhad_pcm_pointer(

Quoted 4 lines
sound/x86/intel_hdmi_audio.c +4 -0
+			buf_id, underrun_count);
+
+		if (underrun_count > (HAD_MIN_PERIODS/2)) {
+			pr_debug("assume audio_codec_reset, underrun =

%d - do xrun\n",

Quoted 11 lines
sound/x86/intel_hdmi_audio.c +8 -0
+				underrun_count);
+			underrun_count = 0;
+			return SNDRV_PCM_POS_XRUN;
+		}
+	} else {
+		/* Reset Counter */
+		underrun_count = 0;
 	}
+
 	t = intelhaddata->buf_info[buf_id].buf_size - t;
 
Quoted 2 lines

sound/x86/intel_hdmi_audio.c static snd_pcm_uframes_t · line 1527

Quoted 2 lines
sound/x86/intel_hdmi_audio.c +0 -0
 	if (intelhaddata->stream_info.buffer_rendered)
 

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#19 lore raw

✓ Fi.CI.BAT: success for Add support for Legacy HDMI audio drivers (rev3)

In reply to Jerome Anand
== Series Details ==

== Series Details ==

Series: Add support for Legacy HDMI audio drivers (rev3)
URL : https://patchwork.freedesktop.org/series/16254/
State : success

== Summary ==

Series 16254v3 Add support for Legacy HDMI audio drivers
https://patchwork.freedesktop.org/api/1.0/series/16254/revisions/3/mbox/

fi-bdw-5557u     total:246  pass:232  dwarn:0   dfail:0   fail:0   skip:14 
fi-bsw-n3050     total:246  pass:207  dwarn:0   dfail:0   fail:0   skip:39 
fi-bxt-j4205     total:246  pass:224  dwarn:0   dfail:0   fail:0   skip:22 
fi-bxt-t5700     total:82   pass:69   dwarn:0   dfail:0   fail:0   skip:12 
fi-byt-n2820     total:246  pass:215  dwarn:0   dfail:0   fail:0   skip:31 
fi-hsw-4770      total:246  pass:227  dwarn:0   dfail:0   fail:0   skip:19 
fi-hsw-4770r     total:246  pass:227  dwarn:0   dfail:0   fail:0   skip:19 
fi-ivb-3520m     total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-ivb-3770      total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-kbl-7500u     total:246  pass:225  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6260u     total:246  pass:233  dwarn:0   dfail:0   fail:0   skip:13 
fi-skl-6700hq    total:246  pass:226  dwarn:0   dfail:0   fail:0   skip:20 
fi-skl-6700k     total:246  pass:222  dwarn:3   dfail:0   fail:0   skip:21 
fi-skl-6770hq    total:246  pass:233  dwarn:0   dfail:0   fail:0   skip:13 
fi-snb-2520m     total:246  pass:215  dwarn:0   dfail:0   fail:0   skip:31 
fi-snb-2600      total:246  pass:214  dwarn:0   dfail:0   fail:0   skip:32 

fi-byt-j1900 failed to collect. IGT log at Patchwork_3445/fi-byt-j1900/igt.log

88c0b7de9157d1f7824dee04d4ad04dbd9c802fb drm-tip: 2017y-01m-06d-10h-07m-28s UTC integration manifest 2e6ba90 ALSA: x86: hdmi: continue playback even when display resolution changes 67ba4fc ALSA: x86: hdmi: Fixup some monitor
c28f8da ALSA: x86: hdmi: Improve position reporting
5da9ca6 ALSA: x86: hdmi: Add audio support for BYT and CHT
d52c9ab ALSA: add shell for Intel HDMI LPE audio driver
4b66d4c drm/i915: Add support for audio driver notifications
82f2da1 drm/i915: setup bridge for HDMI LPE audio driver

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3445/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx