Skip to contentSkip to conversation

Add support for Legacy HDMI audio drivers

PATCH In review Jerome Anand 4 participants 15 messages Jan 9, 2017 – Jan 20, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 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

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

Jerome Anand (5):
drm/i915: setup bridge for HDMI LPE audio driver drm/i915: Add support for audio driver notifications
ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T
ALSA: x86: hdmi: Add audio support for BYT and CHT
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        |   17 +
 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 |  389 +++++++
 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           | 1932 ++++++++++++++++++++++++++++++++
 sound/x86/intel_hdmi_audio.h           |  201 ++++
 sound/x86/intel_hdmi_audio_if.c        |  551 +++++++++
 sound/x86/intel_hdmi_lpe_audio.c       |  617 ++++++++++
 sound/x86/intel_hdmi_lpe_audio.h       |  685 +++++++++++
 19 files changed, 4511 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: eb5c556a1e5eff388e48e4b7cf61e95783019e83
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v3 1/5 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 | 339 +++++++++++++++++++++++++++++++++
 include/drm/intel_lpe_audio.h          |  46 +++++
 8 files changed, 437 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 f66eeede..cc7033a 100644
@@ -2449,6 +2449,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.
@@ -2848,6 +2854,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
@@ -3609,6 +3617,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 +339 -0

339 lines not on this page · raw message

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

46 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

PATCH v3 2/5 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        |  2 ++
 drivers/gpu/drm/i915/intel_audio.c     |  8 ++++++
 drivers/gpu/drm/i915/intel_hdmi.c      |  1 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 50 ++++++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index cc7033a..601c8ad 100644
@@ -3623,6 +3623,8 @@ 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);
 
 /* 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..00a485e 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);
 }
 
 /**
@@ -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);
 }
 
 /**
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 +50 -0

53 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
#4 lore raw

PATCH v3 3/5 ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

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 Additional indirections in the code will be cleaned up in the next series to aid smoother DP integration

---
 sound/Kconfig                    |   2 +
 sound/Makefile                   |   2 +-
 sound/x86/Kconfig                |  16 +
 sound/x86/Makefile               |   6 +
 sound/x86/intel_hdmi_lpe_audio.c | 614 +++++++++++++++++++++++++++++++++++
 sound/x86/intel_hdmi_lpe_audio.h | 685 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 1324 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..54d002d
@@ -0,0 +1,6 @@
+ccflags-y += -Iinclude/drm
+
+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 +614 -0

614 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
#10 lore raw

PATCH v3 4/5 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

The changes to calculate sub-period positions was triggered by David Henningsson <[email protected]> and is accomodated in this patch

---
 sound/x86/Makefile               |    2 +
 sound/x86/intel_hdmi_audio.c     | 1917 ++++++++++++++++++++++++++++++++++++++
 sound/x86/intel_hdmi_audio.h     |  201 ++++
 sound/x86/intel_hdmi_audio_if.c  |  551 +++++++++++
 sound/x86/intel_hdmi_lpe_audio.c |   15 +-
 5 files changed, 2680 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 54d002d..a8d1a8a 100644
@@ -1,6 +1,8 @@
 ccflags-y += -Iinclude/drm
 
 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 +1917 -0

1,917 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 +9 -6
index c2ebce1..cf177e9 100644
@@ -34,6 +34,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;
@@ -453,9 +454,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)
 {
@@ -497,8 +498,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) {
 		dev_err(&hlpe_pdev->dev, "Could not get ioremap\n");
 		return -EACCES;
@@ -548,11 +549,11 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ctx);
 
+	ret = hdmi_audio_probe((void *)pdev);
 	dev_dbg(&hlpe_pdev->dev, "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) {
 
 		dev_dbg(&hlpe_pdev->dev, "%s: handle pending notification\n", __func__);
@@ -576,6 +577,8 @@ static int hdmi_lpe_audio_remove(struct platform_device *pdev)
 
 	dev_dbg(&hlpe_pdev->dev, "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
#13 lore raw

PATCH v3 5/5 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 5305c5c..d33be3c 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);
 
@@ -1507,10 +1509,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
#14 lore raw

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

In reply to Jerome Anand
== Series Details ==

== Series Details ==

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

== Summary ==

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

Test kms_force_connector_basic:

        Subgroup force-connector-state:
                dmesg-warn -> PASS       (fi-snb-2520m)
        Subgroup prune-stale-modes:
                skip       -> PASS       (fi-ivb-3520m)
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-byt-j1900     total:246  pass:219  dwarn:0   dfail:0   fail:0   skip:27 
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 

9ea6a075c23ea914695d57944c0e74cff0c6bff4 drm-tip: 2017y-01m-09d-16h-11m-21s UTC integration manifest 2b22a38 ALSA: x86: hdmi: continue playback even when display resolution changes 1691f04 ALSA: x86: hdmi: Add audio support for BYT and CHT
5e02f67 ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T
53f9a8e drm/i915: Add support for audio driver notifications
1716e88 drm/i915: setup bridge for HDMI LPE audio driver

== Logs ==

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

#3 lore raw

Re: [PATCH V3 2/5] drm/i915: Add support for audio driver notifications

In reply to Jerome Anand
url: https://github.com/0day-ci/linux/commits/Jerome-Anand/Add-support-for-Legacy-HDMI-audio-drivers/20170110-062228 base: reproduce: make htmldocs

Hi Jerome,

[auto build test WARNING on ]

url: https://github.com/0day-ci/linux/commits/Jerome-Anand/Add-support-for-Legacy-HDMI-audio-drivers/20170110-062228
base:
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule. include/linux/init.h:1: warning: no structured comments found include/linux/kthread.h:26: warning: Excess function parameter '...' description in 'kthread_create' kernel/sys.c:1: warning: no structured comments found drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found include/drm/drm_drv.h:444: warning: No description found for parameter 'firstopen' include/drm/drm_drv.h:444: warning: No description found for parameter 'open' include/drm/drm_drv.h:444: warning: No description found for parameter 'preclose' include/drm/drm_drv.h:444: warning: No description found for parameter 'postclose' include/drm/drm_drv.h:444: warning: No description found for parameter 'lastclose' include/drm/drm_drv.h:444: warning: No description found for parameter 'dma_ioctl' include/drm/drm_drv.h:444: warning: No description found for parameter 'dma_quiescent' include/drm/drm_drv.h:444: warning: No description found for parameter 'context_dtor' include/drm/drm_drv.h:444: warning: No description found for parameter 'set_busid' include/drm/drm_drv.h:444: warning: No description found for parameter 'irq_handler' include/drm/drm_drv.h:444: warning: No description found for parameter 'irq_preinstall' include/drm/drm_drv.h:444: warning: No description found for parameter 'irq_postinstall' include/drm/drm_drv.h:444: warning: No description found for parameter 'irq_uninstall' include/drm/drm_drv.h:444: warning: No description found for parameter 'debugfs_init' include/drm/drm_drv.h:444: warning: No description found for parameter 'debugfs_cleanup' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_open_object' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_close_object' include/drm/drm_drv.h:444: warning: No description found for parameter 'prime_handle_to_fd' include/drm/drm_drv.h:444: warning: No description found for parameter 'prime_fd_to_handle' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_export' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_import' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_pin' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_unpin' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_res_obj' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_get_sg_table' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_import_sg_table' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_vmap' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_vunmap' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_prime_mmap' include/drm/drm_drv.h:444: warning: No description found for parameter 'vgaarb_irq' include/drm/drm_drv.h:444: warning: No description found for parameter 'gem_vm_ops' include/drm/drm_drv.h:444: warning: No description found for parameter 'major' include/drm/drm_drv.h:444: warning: No description found for parameter 'minor' include/drm/drm_drv.h:444: warning: No description found for parameter 'patchlevel' include/drm/drm_drv.h:444: warning: No description found for parameter 'name' include/drm/drm_drv.h:444: warning: No description found for parameter 'desc' include/drm/drm_drv.h:444: warning: No description found for parameter 'date' include/drm/drm_drv.h:444: warning: No description found for parameter 'driver_features' include/drm/drm_drv.h:444: warning: No description found for parameter 'dev_priv_size' include/drm/drm_drv.h:444: warning: No description found for parameter 'ioctls' include/drm/drm_drv.h:444: warning: No description found for parameter 'num_ioctls' include/drm/drm_drv.h:444: warning: No description found for parameter 'fops' include/drm/drm_drv.h:444: warning: No description found for parameter 'legacy_dev_list'

>> drivers/gpu/drm/i915/intel_lpe_audio.c:355: warning: Excess function parameter 'connected' description in 'intel_lpe_audio_notify'

drivers/gpu/drm/i915/intel_lpe_audio.c:356: warning: Excess function parameter 'connected' description in 'intel_lpe_audio_notify' drivers/media/dvb-core/dvb_frontend.h:677: warning: No description found for parameter 'refcount' drivers/char/tpm/tpm_vtpm_proxy.c:73: warning: No description found for parameter 'filp' drivers/char/tpm/tpm_vtpm_proxy.c:73: warning: No description found for parameter 'buf' drivers/char/tpm/tpm_vtpm_proxy.c:73: warning: No description found for parameter 'count' drivers/char/tpm/tpm_vtpm_proxy.c:73: warning: No description found for parameter 'off' drivers/char/tpm/tpm_vtpm_proxy.c:123: warning: No description found for parameter 'filp' drivers/char/tpm/tpm_vtpm_proxy.c:123: warning: No description found for parameter 'buf' drivers/char/tpm/tpm_vtpm_proxy.c:123: warning: No description found for parameter 'count' drivers/char/tpm/tpm_vtpm_proxy.c:123: warning: No description found for parameter 'off' drivers/char/tpm/tpm_vtpm_proxy.c:203: warning: No description found for parameter 'proxy_dev' sound/soc/soc-core.c:994: warning: No description found for parameter 'stream_name' Documentation/core-api/assoc_array.rst:13: WARNING: Enumerated list ends without a blank line; unexpected unindent. Documentation/doc-guide/sphinx.rst:110: ERROR: Unknown target name: "sphinx c domain". include/net/cfg80211.h:3154: ERROR: Unexpected indentation.
include/net/mac80211.h:3214: ERROR: Unexpected indentation.
include/net/mac80211.h:3217: WARNING: Block quote ends without a blank line; unexpected unindent. include/net/mac80211.h:3219: ERROR: Unexpected indentation.
include/net/mac80211.h:3220: WARNING: Block quote ends without a blank line; unexpected unindent. include/net/mac80211.h:1773: ERROR: Unexpected indentation.
include/net/mac80211.h:1777: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/sched/fair.c:7587: WARNING: Inline emphasis start-string without end-string. kernel/time/timer.c:1240: ERROR: Unexpected indentation.
kernel/time/timer.c:1242: ERROR: Unexpected indentation.
kernel/time/timer.c:1243: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/wait.h:121: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/wait.h:124: ERROR: Unexpected indentation.
include/linux/wait.h:126: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/time/hrtimer.c:1021: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/signal.c:317: WARNING: Inline literal start-string without end-string. drivers/message/fusion/mptbase.c:5051: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/tty/serial/serial_core.c:1897: WARNING: Definition list ends without a blank line; unexpected unindent. include/linux/spi/spi.h:369: ERROR: Unexpected indentation.
drivers/usb/core/message.c:481: ERROR: Unexpected indentation.
drivers/usb/core/message.c:482: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/driver-api/usb.rst:623: ERROR: Unknown target name: "usb_type". Documentation/driver-api/usb.rst:623: ERROR: Unknown target name: "usb_dir". Documentation/driver-api/usb.rst:623: ERROR: Unknown target name: "usb_recip". Documentation/driver-api/usb.rst:689: ERROR: Unknown target name: "usbdevfs_urb_type". sound/soc/soc-core.c:2508: ERROR: Unknown target name: "snd_soc_daifmt".
sound/core/jack.c:312: ERROR: Unknown target name: "snd_jack_btn". Documentation/translations/ko_KR/howto.rst:293: WARNING: Inline emphasis start-string without end-string.
WARNING: dvipng command 'dvipng' cannot be run (needed for math display), check the imgmath_dvipng setting

vim +355 drivers/gpu/drm/i915/intel_lpe_audio.c

339 }
340
341
342 /**
343 * intel_lpe_audio_notify() - notify lpe audio event
344 * audio driver and i915
345 * @dev_priv: the i915 drm device private data
346 * @eld : ELD data
347 * @port: port id
348 * @tmds_clk_speed: tmds clock frequency in Hz
349 * @connected: hdmi connected/disconnected
350 *
351 * Notify lpe audio driver of eld change.
352 */
353 void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
354 void *eld, int port, int tmds_clk_speed)

 > 355	{

356 unsigned long irq_flags;
357 struct intel_hdmi_lpe_audio_pdata *pdata = NULL;
358
359 if (!HAS_LPE_AUDIO(dev_priv))
360 return;
361
362 pdata = dev_get_platdata(
363 &(dev_priv->lpe_audio.platdev->dev));

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

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

#5 lore raw

Re: [PATCH V3 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

In reply to Jerome Anand
Quoted 13 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.

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

Quoted 6 lines

Since this driver is neither SoC nor PCI, a new x86 folder is added Additional indirections in the code will be cleaned up in the next series to aid smoother DP integration

Just a few knitpicks below:

Quoted 17 lines
sound/Makefile +1 -1
@@ -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 +0 -0
new file mode 100644
index 0000000..e9297d0

sound/x86/Kconfig line 2

Quoted 2 lines
sound/x86/Kconfig new file +2 -0
@@ -0,0 +1,16 @@
+menuconfig SND_X86
+	tristate "X86 sound devices"

This should depends on X86.

sound/x86/Kconfig line 12

Quoted 10 lines
sound/x86/Kconfig new file +10 -0
+	---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

default=n is superfluous.

sound/x86/Makefile line 1

Quoted 11 lines
sound/x86/Kconfig new file +4 -0
+	help
+	 Choose this option to support HDMI LPE Audio mode
+
+endif	# SND_X86
sound/x86/Makefile new file +1 -0
new file mode 100644
index 0000000..54d002d
@@ -0,0 +1,6 @@
+ccflags-y += -Iinclude/drm

Do we really need this?

Quoted 30 lines
sound/x86/Makefile new file +4 -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 +20 -0
new file mode 100644
index 0000000..c2ebce1
@@ -0,0 +1,614 @@
+/*
+ *  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.
+ *
+ *  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.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */

sound/x86/intel_hdmi_lpe_audio.c line 30

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+
+#include <linux/platform_device.h>
+#include <linux/irqreturn.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <sound/pcm.h>
+#include <sound/core.h>

Usually sound/core.h comes before other sound/* inclusions.

sound/x86/intel_hdmi_lpe_audio.c line 41

Quoted 11 lines
sound/x86/intel_hdmi_lpe_audio.c new file +11 -0
+#include <sound/pcm_params.h>
+#include <sound/initval.h>
+#include <sound/control.h>
+#include <sound/initval.h>
+#include <drm/intel_lpe_audio.h>
+#include "intel_hdmi_lpe_audio.h"
+
+/* globals*/
+struct platform_device *hlpe_pdev;
+int hlpe_state;
+union otm_hdmi_eld_t hlpe_eld;

Are these really globals? I couldn't find the reference from others in the patchset.

Quoted 4 lines
sound/x86/intel_hdmi_lpe_audio.c new file +4 -0
+
+struct hdmi_lpe_audio_ctx {
+	int irq;
+	void __iomem *mmio_start;

sound/x86/intel_hdmi_lpe_audio.c line 55

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+	had_event_call_back had_event_callbacks;
+	struct snd_intel_had_interface *had_interface;
+	void *had_pvt_data;
+	int tmds_clock_speed;
+	unsigned int had_config_offset;
+	int hdmi_audio_interrupt_mask;
+	struct work_struct hdmi_audio_wq;
+};
+
+static inline void hdmi_set_eld(void *eld)

You need no inline unless it's really mandatory. Let compiler optimize. It's often smarter than us.

Quoted 49 lines
sound/x86/intel_hdmi_lpe_audio.c new file +49 -0
+{
+	int size;
+
+	BUILD_BUG_ON(sizeof(hlpe_eld) > HDMI_MAX_ELD_BYTES);
+
+	size = sizeof(hlpe_eld);
+	memcpy((void *)&hlpe_eld, eld, size);
+}
+
+static inline int hdmi_get_eld(void *eld)
+{
+	uint8_t *eld_data = (uint8_t *)&hlpe_eld;
+
+	memcpy(eld, (void *)&hlpe_eld, sizeof(hlpe_eld));
+
+	print_hex_dump_bytes("eld: ", DUMP_PREFIX_NONE, eld_data,
+			sizeof(hlpe_eld));
+	return 0;
+}
+
+
+static inline struct hdmi_lpe_audio_ctx *get_hdmi_context(void)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	return ctx;
+}
+
+/*
+ * return whether HDMI audio device is busy.
+ */
+bool mid_hdmi_audio_is_busy(void *ddev)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+	int hdmi_audio_busy = 0;
+	struct hdmi_audio_event hdmi_audio_event;
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter",  __func__);
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (hlpe_state == hdmi_connector_status_disconnected) {
+		/* HDMI is not connected, assuming audio device is idle. */
+		return false;
+	}
+
+	if (ctx->had_interface) {
+		hdmi_audio_event.type = HAD_EVENT_QUERY_IS_AUDIO_BUSY;

sound/x86/intel_hdmi_lpe_audio.c line 114

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+		hdmi_audio_busy = ctx->had_interface->query(
+				ctx->had_pvt_data,
+				hdmi_audio_event);
+		return hdmi_audio_busy != 0;
+	}
+	return false;
+}
+
+/*
+ * return whether HDMI audio device is suspended.

It's a bit confusing description. The function does suspend and returns true if it has suspended, or disconnected / IF doesn't exist.

IMO, a standard negative error code or zero return value would be more straightforward in such a case.

Quoted 48 lines
sound/x86/intel_hdmi_lpe_audio.c new file +48 -0
+ */
+bool mid_hdmi_audio_suspend(void *ddev)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+	struct hdmi_audio_event hdmi_audio_event;
+	int ret = 0;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (hlpe_state == hdmi_connector_status_disconnected) {
+		/* HDMI is not connected, assuming audio device
+		 * is suspended already.
+		 */
+		return true;
+	}
+
+	dev_dbg(&hlpe_pdev->dev, "%s: hlpe_state %d",  __func__,
+			hlpe_state);
+
+	if (ctx->had_interface) {
+		hdmi_audio_event.type = 0;
+		ret = ctx->had_interface->suspend(ctx->had_pvt_data,
+				hdmi_audio_event);
+		return (ret == 0) ? true : false;
+	}
+	return true;
+}
+
+void mid_hdmi_audio_resume(void *ddev)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (hlpe_state == hdmi_connector_status_disconnected) {
+		/* HDMI is not connected, there is no need
+		 * to resume audio device.
+		 */
+		return;
+	}
+
+	dev_dbg(&hlpe_pdev->dev, "%s: hlpe_state %d",  __func__, hlpe_state);
+
+	if (ctx->had_interface)
+		ctx->had_interface->resume(ctx->had_pvt_data);
+}
+
+void mid_hdmi_audio_signal_event(enum had_event_type event)

sound/x86/intel_hdmi_lpe_audio.c line 172

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (ctx->had_event_callbacks)
+		(*ctx->had_event_callbacks)(event,
+			ctx->had_pvt_data);

Isn't this racy? This dispatcher seems called from multiple places including the interrupt handler below.

sound/x86/intel_hdmi_lpe_audio.c line 177

Quoted 5 lines
sound/x86/intel_hdmi_lpe_audio.c new file +5 -0
+}
+
+/**
+ * hdmi_audio_write:
+ * used to write into display controller HDMI audio registers.

No need to use kernel-doc style comments here unless you really want to list in the kernel API documentation.

sound/x86/intel_hdmi_lpe_audio.c line 180

Quoted 3 lines
sound/x86/intel_hdmi_lpe_audio.c new file +3 -0
+ *
+ */
+static int hdmi_audio_write(uint32_t reg, uint32_t val)

We don't use uint32_t in kernel codes, but a simpler form, u32, is preferred in most cases. uint32_t is still allowed, but it's usually only for user API definitions.

Quoted 61 lines
sound/x86/intel_hdmi_lpe_audio.c new file +61 -0
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	dev_dbg(&hlpe_pdev->dev, "%s: reg[0x%x] = 0x%x\n", __func__, reg, val);
+
+	iowrite32(val, (ctx->mmio_start+reg));
+
+	return 0;
+}
+
+/**
+ * hdmi_audio_read:
+ * used to get the register value read from
+ * display controller HDMI audio registers.
+ */
+static int hdmi_audio_read(uint32_t reg, uint32_t *val)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	*val = ioread32(ctx->mmio_start+reg);
+	dev_dbg(&hlpe_pdev->dev, "%s: reg[0x%x] = 0x%x\n", __func__, reg, *val);
+	return 0;
+}
+
+/**
+ * hdmi_audio_rmw:
+ * used to update the masked bits in display controller HDMI
+ * audio registers.
+ */
+static int hdmi_audio_rmw(uint32_t reg, uint32_t val, uint32_t mask)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+	uint32_t val_tmp = 0;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	val_tmp = (val & mask) |
+			((ioread32(ctx->mmio_start + reg)) & ~mask);
+
+	iowrite32(val_tmp, (ctx->mmio_start+reg));
+	dev_dbg(&hlpe_pdev->dev, "%s: reg[0x%x] = 0x%x\n", __func__, reg, val_tmp);
+
+	return 0;
+}
+
+/**
+ * hdmi_audio_get_caps:
+ * used to return the HDMI audio capabilities.
+ * e.g. resolution, frame rate.
+ */
+static int hdmi_audio_get_caps(enum had_caps_list get_element,
+			void *capabilities)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+	int ret = 0;
+
+	ctx = get_hdmi_context();
+

sound/x86/intel_hdmi_lpe_audio.c line 251

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
+	switch (get_element) {
+	case HAD_GET_ELD:
+		ret = hdmi_get_eld(capabilities);
+		break;
+	case HAD_GET_DISPLAY_RATE:
+		/* ToDo: Verify if sampling freq logic is correct */
+		memcpy(capabilities, &(ctx->tmds_clock_speed),
+			sizeof(uint32_t));

Why memcpy? Both source and destination are 32bit int, no?

Quoted 15 lines
sound/x86/intel_hdmi_lpe_audio.c new file +15 -0
+		dev_dbg(&hlpe_pdev->dev, "%s: tmds_clock_speed = 0x%x\n", __func__,
+				ctx->tmds_clock_speed);
+		break;
+	default:
+		break;
+	}
+
+	return ret;
+}
+
+/**
+ * hdmi_audio_get_register_base
+ * used to get the current hdmi base address
+ */
+int hdmi_audio_get_register_base(uint32_t **reg_base,

sound/x86/intel_hdmi_lpe_audio.c line 276

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+		uint32_t *config_offset)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	*reg_base = (uint32_t *)(ctx->mmio_start);
+	*config_offset = ctx->had_config_offset;
+	dev_dbg(&hlpe_pdev->dev, "%s: reg_base = 0x%p, cfg_off = 0x%x\n", __func__,
+			*reg_base, *config_offset);
+	return 0;

Well, I see no reason why this function / callback is needed. The base address is never referred in other codes, and the config_offset is always passed to read/write accessors, so it can be calculated there directly.

Any other missing cases?

Quoted 71 lines
sound/x86/intel_hdmi_lpe_audio.c new file +71 -0
+}
+
+/**
+ * hdmi_audio_set_caps:
+ * used to set the HDMI audio capabilities.
+ * e.g. Audio INT.
+ */
+int hdmi_audio_set_caps(enum had_caps_list set_element,
+			void *capabilties)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	dev_dbg(&hlpe_pdev->dev, "%s: cap_id = 0x%x\n", __func__, set_element);
+
+	switch (set_element) {
+	case HAD_SET_ENABLE_AUDIO_INT:
+		{
+			uint32_t status_reg;
+
+			hdmi_audio_read(AUD_HDMI_STATUS_v2 +
+				ctx->had_config_offset, &status_reg);
+			status_reg |=
+				HDMI_AUDIO_BUFFER_DONE | HDMI_AUDIO_UNDERRUN;
+			hdmi_audio_write(AUD_HDMI_STATUS_v2 +
+				ctx->had_config_offset, status_reg);
+			hdmi_audio_read(AUD_HDMI_STATUS_v2 +
+				ctx->had_config_offset, &status_reg);
+
+		}
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static struct  hdmi_audio_registers_ops hdmi_audio_reg_ops = {
+	.hdmi_audio_get_register_base = hdmi_audio_get_register_base,
+	.hdmi_audio_read_register = hdmi_audio_read,
+	.hdmi_audio_write_register = hdmi_audio_write,
+	.hdmi_audio_read_modify = hdmi_audio_rmw,
+};
+
+static struct hdmi_audio_query_set_ops hdmi_audio_get_set_ops = {
+	.hdmi_audio_get_caps = hdmi_audio_get_caps,
+	.hdmi_audio_set_caps = hdmi_audio_set_caps,
+};
+
+int mid_hdmi_audio_setup(
+		had_event_call_back audio_callbacks,
+		struct hdmi_audio_registers_ops *reg_ops,
+		struct hdmi_audio_query_set_ops *query_ops)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	dev_dbg(&hlpe_pdev->dev, "%s: called\n",  __func__);
+
+	reg_ops->hdmi_audio_get_register_base =
+		(hdmi_audio_reg_ops.hdmi_audio_get_register_base);
+	reg_ops->hdmi_audio_read_register =
+		(hdmi_audio_reg_ops.hdmi_audio_read_register);
+	reg_ops->hdmi_audio_write_register =
+		(hdmi_audio_reg_ops.hdmi_audio_write_register);
+	reg_ops->hdmi_audio_read_modify =
+		(hdmi_audio_reg_ops.hdmi_audio_read_modify);
+	query_ops->hdmi_audio_get_caps =

sound/x86/intel_hdmi_lpe_audio.c line 357

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+		hdmi_audio_get_set_ops.hdmi_audio_get_caps;
+	query_ops->hdmi_audio_set_caps =
+		hdmi_audio_get_set_ops.hdmi_audio_set_caps;
+
+	ctx->had_event_callbacks = audio_callbacks;
+
+	return 0;
+}
+
+void _had_wq(struct work_struct *work)

Missing static.

thanks,

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

#11 lore raw

Re: [PATCH V3 4/5] ALSA: x86: hdmi: Add audio support for BYT and CHT

In reply to Jerome Anand
Quoted 11 lines · 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

Quoted 6 lines

The changes to calculate sub-period positions was triggered by David Henningsson <[email protected]> and is accomodated in this patch

Again some knitpicks:

sound/x86/intel_hdmi_audio.c line 162

Quoted 3 lines
sound/x86/intel_hdmi_audio.c new file +3 -0
+/* Register access functions */
+
+inline int had_get_hwstate(struct snd_intelhad *intelhaddata)

Don't use external inline. Drop inline if this is no static. Ditto for the rest.

Quoted 2 lines

+/**
+ * had_read_modify_aud_config_v2 - Specific function to read-modify

No need for kernel doc comments for such local functions.

Quoted 17 lines

+ * AUD_CONFIG register on VLV2.The had_read_modify() function should not
+ * directly be used on VLV2 for updating AUD_CONFIG register.
+ * This is because:
+ * Bit6 of AUD_CONFIG register is writeonly due to a silicon bug on VLV2
+ * HDMI IP. As a result a read-modify of AUD_CONFIG regiter will always
+ * clear bit6. AUD_CONFIG[6:4] represents the "channels" field of the
+ * register. This field should be 1xy binary for configuration with 6 or
+ * more channels. Read-modify of AUD_CONFIG (Eg. for enabling audio)
+ * causes the "channels" field to be updated as 0xy binary resulting in
+ * bad audio. The fix is to always write the AUD_CONFIG[6:4] with
+ * appropriate value when doing read-modify of AUD_CONFIG register.
+ *
+ * @substream: the current substream or NULL if no active substream
+ * @data : data to be written
+ * @mask : mask
+ *
+ */

sound/x86/intel_hdmi_audio.c line 259

Quoted 2 lines
sound/x86/intel_hdmi_audio.c new file +2 -0
+inline int had_read_modify_aud_config_v2(struct snd_pcm_substream *substream,
+					uint32_t data, uint32_t mask)

Is this really external? Or can it be static?
(Ditto for some others *_v1 and *_v2.)

Quoted 3 lines

+/*
+ ** ALSA API channel-map control callbacks
+ **/

Avoid such a confusing comment style.

Quoted 19 lines
sound/x86/intel_hdmi_audio.c new file +19 -0
+static int had_chmap_ctl_info(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_info *uinfo)
+{
+	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
+	struct snd_intelhad *intelhaddata = info->private_data;
+
+	if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED)
+		return -ENODEV;
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+	uinfo->count = HAD_MAX_CHANNEL;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = SNDRV_CHMAP_LAST;
+	return 0;
+}
+
+#ifndef USE_ALSA_DEFAULT_TLV
+static int had_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
+				unsigned int size, unsigned int __user *tlv)
+{

sound/x86/intel_hdmi_audio.c line 667

Quoted 10 lines
sound/x86/intel_hdmi_audio.c new file +10 -0
+	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
+	struct snd_intelhad *intelhaddata = info->private_data;
+
+	if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED)
+		return -ENODEV;
+
+	/* TODO: Fix for query channel map */
+	return -EPERM;
+}
+#endif

For what reason is this dummy implementation provided?

Quoted 18 lines
sound/x86/intel_hdmi_audio.c new file +18 -0
+
+static int had_chmap_ctl_get(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
+	struct snd_intelhad *intelhaddata = info->private_data;
+	int i = 0;
+	const struct snd_pcm_chmap_elem *chmap;
+
+	if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED)
+		return -ENODEV;
+	if (intelhaddata->chmap->chmap ==  NULL)
+		return -ENODATA;
+	chmap = intelhaddata->chmap->chmap;
+	for (i = 0; i < chmap->channels; i++) {
+		ucontrol->value.integer.value[i] = chmap->map[i];
+		pr_debug("chmap->map[%d] = %d\n", i, chmap->map[i]);
+	}

sound/x86/intel_hdmi_audio.c line 695

Quoted 10 lines
sound/x86/intel_hdmi_audio.c new file +10 -0
+
+	return 0;
+}
+
+static int had_chmap_ctl_put(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	/* TODO: Get channel map and set swap register */
+	return -EPERM;
+}

The standard chmap doesn't support write unless explicitly changed. So you can drop the callback as well.

thanks,

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

#6 lore raw

Re: [PATCH V3 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

In reply to Takashi Iwai
Quoted 33 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, January 18, 2017 5:16 PM
To: Anand, Jerome <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; Ughreja, Rakesh A <[email protected]>
Subject: Re: [PATCH V3 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

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 8 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 Additional indirections in the code will be cleaned up in the next series to aid smoother DP integration

Quoted 6 lines
Quoted 3 lines

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

Just a few knitpicks below:

Thank you for the detailed review.

Quoted 11 lines

sound/Makefile obj-$(CONFIG_SOUND) += soundcore.o · line 7

Quoted 6 lines
sound/Makefile +0 -0
@@ -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/ \

Quoted 4 lines
sound/Makefile +1 -1
-	firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/ hda/
+	firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/ hda/ x86/
 obj-$(CONFIG_SND_AOA) += aoa/
 
Quoted 11 lines

sound/x86/Kconfig line 2

Quoted 8 lines
sound/Makefile +0 -1
 # This one must be compilable even if sound is configured out diff
--git a/sound/x86/Kconfig b/sound/x86/Kconfig new file mode 100644

index 0000000..e9297d0

sound/x86/Kconfig new file +2 -0
@@ -0,0 +1,16 @@
+menuconfig SND_X86
+	tristate "X86 sound devices"

This should depends on X86.

Ok will add it

Quoted 14 lines

sound/x86/Kconfig line 12

Quoted 11 lines
sound/x86/Kconfig new file +10 -0
+	---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

default=n is superfluous.

Ok will remove it

Quoted 4 lines
Quoted 4 lines
sound/x86/Kconfig new file +4 -0
+	help
+	 Choose this option to support HDMI LPE Audio mode
+
+endif	# SND_X86
Quoted 9 lines

sound/x86/Makefile line 1

Quoted 6 lines
sound/x86/Makefile new file mode renamed from sound/x86/Makefile +0 -0

100644 index 0000000..54d002d

sound/x86/Makefile new file +1 -0
@@ -0,0 +1,6 @@
+ccflags-y += -Iinclude/drm

Do we really need this?

Not needed now I believe , will remove it

Quoted 42 lines
Quoted 12 lines
sound/x86/Makefile new file +4 -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..c2ebce1

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,614 @@
+/*
+ *  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.
+ *
+ *

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

Quoted 15 lines

sound/x86/intel_hdmi_lpe_audio.c line 30

Quoted 12 lines
sound/x86/intel_hdmi_lpe_audio.c new file +12 -0
+~~~~~
+ */
+
+#include <linux/platform_device.h>
+#include <linux/irqreturn.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <sound/pcm.h>
+#include <sound/core.h>

Usually sound/core.h comes before other sound/* inclusions.

OK, will move it up

Quoted 6 lines
Quoted 6 lines
sound/x86/intel_hdmi_lpe_audio.c new file +6 -0
+#include <sound/pcm_params.h>
+#include <sound/initval.h>
+#include <sound/control.h>
+#include <sound/initval.h>
+#include <drm/intel_lpe_audio.h>
+#include "intel_hdmi_lpe_audio.h"
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 41

Quoted 5 lines
sound/x86/intel_hdmi_lpe_audio.c new file +5 -0
+
+/* globals*/
+struct platform_device *hlpe_pdev;
+int hlpe_state;
+union otm_hdmi_eld_t hlpe_eld;

Are these really globals? I couldn't find the reference from others in the patchset.

These are internal to the file. I'll make them static.

Quoted 9 lines
Quoted 9 lines
sound/x86/intel_hdmi_lpe_audio.c new file +9 -0
+
+struct hdmi_lpe_audio_ctx {
+	int irq;
+	void __iomem *mmio_start;
+	had_event_call_back had_event_callbacks;
+	struct snd_intel_had_interface *had_interface;
+	void *had_pvt_data;
+	int tmds_clock_speed;
+	unsigned int had_config_offset;
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 55

Quoted 5 lines
sound/x86/intel_hdmi_lpe_audio.c new file +5 -0
+	int hdmi_audio_interrupt_mask;
+	struct work_struct hdmi_audio_wq;
+};
+
+static inline void hdmi_set_eld(void *eld)

You need no inline unless it's really mandatory. Let compiler optimize. It's often smarter than us.

Ok, will remove inline from the code

Quoted 60 lines
Quoted 35 lines
sound/x86/intel_hdmi_lpe_audio.c new file +35 -0
+{
+	int size;
+
+	BUILD_BUG_ON(sizeof(hlpe_eld) > HDMI_MAX_ELD_BYTES);
+
+	size = sizeof(hlpe_eld);
+	memcpy((void *)&hlpe_eld, eld, size); }
+
+static inline int hdmi_get_eld(void *eld) {
+	uint8_t *eld_data = (uint8_t *)&hlpe_eld;
+
+	memcpy(eld, (void *)&hlpe_eld, sizeof(hlpe_eld));
+
+	print_hex_dump_bytes("eld: ", DUMP_PREFIX_NONE, eld_data,
+			sizeof(hlpe_eld));
+	return 0;
+}
+
+
+static inline struct hdmi_lpe_audio_ctx *get_hdmi_context(void) {
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	return ctx;
+}
+
+/*
+ * return whether HDMI audio device is busy.
+ */
+bool mid_hdmi_audio_is_busy(void *ddev) {
+	struct hdmi_lpe_audio_ctx *ctx;
+	int hdmi_audio_busy = 0;
+	struct hdmi_audio_event hdmi_audio_event;
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter",  __func__);

sound/x86/intel_hdmi_lpe_audio.c

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (hlpe_state == hdmi_connector_status_disconnected) {
+		/* HDMI is not connected, assuming audio device is idle. */
+		return false;
+	}
+
+	if (ctx->had_interface) {
+		hdmi_audio_event.type =

HAD_EVENT_QUERY_IS_AUDIO_BUSY;

sound/x86/intel_hdmi_lpe_audio.c line 114

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+		hdmi_audio_busy = ctx->had_interface->query(
+				ctx->had_pvt_data,
+				hdmi_audio_event);
+		return hdmi_audio_busy != 0;
+	}
+	return false;
+}
+
+/*
+ * return whether HDMI audio device is suspended.

It's a bit confusing description. The function does suspend and returns true if it has suspended, or disconnected / IF doesn't exist.

Quoted 3 lines

IMO, a standard negative error code or zero return value would be more straightforward in such a case.

Ok, I'll change the description to accommodate disconnected state too

Quoted 51 lines
Quoted 51 lines
sound/x86/intel_hdmi_lpe_audio.c new file +51 -0
+ */
+bool mid_hdmi_audio_suspend(void *ddev) {
+	struct hdmi_lpe_audio_ctx *ctx;
+	struct hdmi_audio_event hdmi_audio_event;
+	int ret = 0;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (hlpe_state == hdmi_connector_status_disconnected) {
+		/* HDMI is not connected, assuming audio device
+		 * is suspended already.
+		 */
+		return true;
+	}
+
+	dev_dbg(&hlpe_pdev->dev, "%s: hlpe_state %d",  __func__,
+			hlpe_state);
+
+	if (ctx->had_interface) {
+		hdmi_audio_event.type = 0;
+		ret = ctx->had_interface->suspend(ctx->had_pvt_data,
+				hdmi_audio_event);
+		return (ret == 0) ? true : false;
+	}
+	return true;
+}
+
+void mid_hdmi_audio_resume(void *ddev) {
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (hlpe_state == hdmi_connector_status_disconnected) {
+		/* HDMI is not connected, there is no need
+		 * to resume audio device.
+		 */
+		return;
+	}
+
+	dev_dbg(&hlpe_pdev->dev, "%s: hlpe_state %d",  __func__,
+hlpe_state);
+
+	if (ctx->had_interface)
+		ctx->had_interface->resume(ctx->had_pvt_data);
+}
+
+void mid_hdmi_audio_signal_event(enum had_event_type event) {
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 172

Quoted 5 lines
sound/x86/intel_hdmi_lpe_audio.c new file +5 -0
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (ctx->had_event_callbacks)
+		(*ctx->had_event_callbacks)(event,
+			ctx->had_pvt_data);

Isn't this racy? This dispatcher seems called from multiple places including the interrupt handler below.

No, It's taken care of in the respective callbacks based on the event

Quoted 10 lines

sound/x86/intel_hdmi_lpe_audio.c line 177

Quoted 6 lines
sound/x86/intel_hdmi_lpe_audio.c new file +5 -0
+}
+
+/**
+ * hdmi_audio_write:
+ * used to write into display controller HDMI audio registers.

No need to use kernel-doc style comments here unless you really want to list in the kernel API documentation.

Ok, will remove the comments

Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 180

Quoted 4 lines
sound/x86/intel_hdmi_lpe_audio.c new file +3 -0
+ *
+ */
+static int hdmi_audio_write(uint32_t reg, uint32_t val)

We don't use uint32_t in kernel codes, but a simpler form, u32, is preferred in most cases. uint32_t is still allowed, but it's usually only for user API definitions.

Ok, will change to u32, u16 and u8 respectively

Quoted 70 lines

sound/x86/intel_hdmi_lpe_audio.c

Quoted 7 lines
sound/x86/intel_hdmi_lpe_audio.c new file +6 -0
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	dev_dbg(&hlpe_pdev->dev, "%s: reg[0x%x] = 0x%x\n", __func__,

reg,

Quoted 8 lines
sound/x86/intel_hdmi_lpe_audio.c new file +8 -0
+val);
+
+	iowrite32(val, (ctx->mmio_start+reg));
+
+	return 0;
+}
+
+/**

sound/x86/intel_hdmi_lpe_audio.c

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+ * hdmi_audio_read:
+ * used to get the register value read from
+ * display controller HDMI audio registers.
+ */
+static int hdmi_audio_read(uint32_t reg, uint32_t *val) {
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	*val = ioread32(ctx->mmio_start+reg);
+	dev_dbg(&hlpe_pdev->dev, "%s: reg[0x%x] = 0x%x\n", __func__,

reg, *val);

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+	return 0;
+}
+
+/**
+ * hdmi_audio_rmw:
+ * used to update the masked bits in display controller HDMI
+ * audio registers.
+ */
+static int hdmi_audio_rmw(uint32_t reg, uint32_t val, uint32_t mask)
+{

sound/x86/intel_hdmi_lpe_audio.c

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+	struct hdmi_lpe_audio_ctx *ctx;
+	uint32_t val_tmp = 0;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	val_tmp = (val & mask) |
+			((ioread32(ctx->mmio_start + reg)) & ~mask);
+
+	iowrite32(val_tmp, (ctx->mmio_start+reg));
+	dev_dbg(&hlpe_pdev->dev, "%s: reg[0x%x] = 0x%x\n", __func__,

reg,

Quoted 22 lines
sound/x86/intel_hdmi_lpe_audio.c new file +22 -0
+val_tmp);
+
+	return 0;
+}
+
+/**
+ * hdmi_audio_get_caps:
+ * used to return the HDMI audio capabilities.
+ * e.g. resolution, frame rate.
+ */
+static int hdmi_audio_get_caps(enum had_caps_list get_element,
+			void *capabilities)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+	int ret = 0;
+
+	ctx = get_hdmi_context();
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
+	switch (get_element) {
+	case HAD_GET_ELD:
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 251

Quoted 6 lines
sound/x86/intel_hdmi_lpe_audio.c new file +6 -0
+		ret = hdmi_get_eld(capabilities);
+		break;
+	case HAD_GET_DISPLAY_RATE:
+		/* ToDo: Verify if sampling freq logic is correct */
+		memcpy(capabilities, &(ctx->tmds_clock_speed),
+			sizeof(uint32_t));

Why memcpy? Both source and destination are 32bit int, no?

Do you think *(int *)capabilities = ctx->tmds_clock_speed is better than memcpy?

Quoted 24 lines

sound/x86/intel_hdmi_lpe_audio.c line 253

Quoted 1 line
sound/x86/intel_hdmi_lpe_audio.c new file +1 -0
+		dev_dbg(&hlpe_pdev->dev, "%s: tmds_clock_speed =

0x%x\n", __func__,

Quoted 11 lines
sound/x86/intel_hdmi_lpe_audio.c new file +11 -0
+				ctx->tmds_clock_speed);
+		break;
+	default:
+		break;
+	}
+
+	return ret;
+}
+
+/**
+ * hdmi_audio_get_register_base

sound/x86/intel_hdmi_lpe_audio.c

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+ * used to get the current hdmi base address  */ int
+hdmi_audio_get_register_base(uint32_t **reg_base,
+		uint32_t *config_offset)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	*reg_base = (uint32_t *)(ctx->mmio_start);
+	*config_offset = ctx->had_config_offset;
+	dev_dbg(&hlpe_pdev->dev, "%s: reg_base = 0x%p, cfg_off =

0x%x\n", __func__,

Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 276

Quoted 2 lines
sound/x86/intel_hdmi_lpe_audio.c new file +2 -0
+			*reg_base, *config_offset);
+	return 0;

Well, I see no reason why this function / callback is needed.
The base address is never referred in other codes, and the config_offset is always passed to read/write accessors, so it can be calculated there directly.

Any other missing cases?

I wanted to have a cleaner separation, hence added this function in this file rather Than deriving it. So would prefer to keep it.

Quoted 75 lines
Quoted 17 lines
sound/x86/intel_hdmi_lpe_audio.c new file +16 -0
+}
+
+/**
+ * hdmi_audio_set_caps:
+ * used to set the HDMI audio capabilities.
+ * e.g. Audio INT.
+ */
+int hdmi_audio_set_caps(enum had_caps_list set_element,
+			void *capabilties)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	dev_dbg(&hlpe_pdev->dev, "%s: cap_id = 0x%x\n", __func__,
+set_element);

sound/x86/intel_hdmi_lpe_audio.c

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+
+	switch (set_element) {
+	case HAD_SET_ENABLE_AUDIO_INT:
+		{
+			uint32_t status_reg;
+
+			hdmi_audio_read(AUD_HDMI_STATUS_v2 +
+				ctx->had_config_offset, &status_reg);
+			status_reg |=
+				HDMI_AUDIO_BUFFER_DONE |

HDMI_AUDIO_UNDERRUN;

Quoted 47 lines
sound/x86/intel_hdmi_lpe_audio.c new file +47 -0
+			hdmi_audio_write(AUD_HDMI_STATUS_v2 +
+				ctx->had_config_offset, status_reg);
+			hdmi_audio_read(AUD_HDMI_STATUS_v2 +
+				ctx->had_config_offset, &status_reg);
+
+		}
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+static struct  hdmi_audio_registers_ops hdmi_audio_reg_ops = {
+	.hdmi_audio_get_register_base = hdmi_audio_get_register_base,
+	.hdmi_audio_read_register = hdmi_audio_read,
+	.hdmi_audio_write_register = hdmi_audio_write,
+	.hdmi_audio_read_modify = hdmi_audio_rmw, };
+
+static struct hdmi_audio_query_set_ops hdmi_audio_get_set_ops = {
+	.hdmi_audio_get_caps = hdmi_audio_get_caps,
+	.hdmi_audio_set_caps = hdmi_audio_set_caps, };
+
+int mid_hdmi_audio_setup(
+		had_event_call_back audio_callbacks,
+		struct hdmi_audio_registers_ops *reg_ops,
+		struct hdmi_audio_query_set_ops *query_ops) {
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	dev_dbg(&hlpe_pdev->dev, "%s: called\n",  __func__);
+
+	reg_ops->hdmi_audio_get_register_base =
+		(hdmi_audio_reg_ops.hdmi_audio_get_register_base);
+	reg_ops->hdmi_audio_read_register =
+		(hdmi_audio_reg_ops.hdmi_audio_read_register);
+	reg_ops->hdmi_audio_write_register =
+		(hdmi_audio_reg_ops.hdmi_audio_write_register);
+	reg_ops->hdmi_audio_read_modify =
+		(hdmi_audio_reg_ops.hdmi_audio_read_modify);
+	query_ops->hdmi_audio_get_caps =
+		hdmi_audio_get_set_ops.hdmi_audio_get_caps;
+	query_ops->hdmi_audio_set_caps =
+		hdmi_audio_get_set_ops.hdmi_audio_set_caps;
+
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 357

Quoted 6 lines
sound/x86/intel_hdmi_lpe_audio.c new file +6 -0
+	ctx->had_event_callbacks = audio_callbacks;
+
+	return 0;
+}
+
+void _had_wq(struct work_struct *work)

Missing static.

Ok, will add

Quoted 4 lines

thanks,

Takashi

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

#12 lore raw

Re: [PATCH V3 4/5] ALSA: x86: hdmi: Add audio support for BYT and CHT

In reply to Takashi Iwai
Quoted 32 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Wednesday, January 18, 2017 5:33 PM
To: Anand, Jerome <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; pierre- [email protected]; Ughreja, Rakesh A <[email protected]>
Subject: Re: [PATCH V3 4/5] ALSA: x86: hdmi: Add audio support for BYT and CHT

Quoted 9 lines · 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

Quoted 7 lines

The changes to calculate sub-period positions was triggered by David Henningsson <[email protected]> and is accomodated in this patch

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

Quoted 9 lines

Again some knitpicks:

sound/x86/intel_hdmi_audio.c line 162

Quoted 3 lines
sound/x86/intel_hdmi_audio.c new file +3 -0
+/* Register access functions */
+
+inline int had_get_hwstate(struct snd_intelhad *intelhaddata)

Don't use external inline. Drop inline if this is no static. Ditto for the rest.

Ok, will remove inline

Quoted 5 lines
Quoted 2 lines

+/**
+ * had_read_modify_aud_config_v2 - Specific function to read-modify

No need for kernel doc comments for such local functions.

Ok, will remove the comments

Quoted 24 lines
Quoted 13 lines

+ * AUD_CONFIG register on VLV2.The had_read_modify() function should

sound/x86/intel_hdmi_audio.c new file +12 -0
+not
+ * directly be used on VLV2 for updating AUD_CONFIG register.
+ * This is because:
+ * Bit6 of AUD_CONFIG register is writeonly due to a silicon bug on
+VLV2
+ * HDMI IP. As a result a read-modify of AUD_CONFIG regiter will
+always
+ * clear bit6. AUD_CONFIG[6:4] represents the "channels" field of the
+ * register. This field should be 1xy binary for configuration with 6
+or
+ * more channels. Read-modify of AUD_CONFIG (Eg. for enabling audio)
+ * causes the "channels" field to be updated as 0xy binary resulting

sound/x86/intel_hdmi_audio.c

Quoted 10 lines
sound/x86/intel_hdmi_audio.c new file +10 -0
+in
+ * bad audio. The fix is to always write the AUD_CONFIG[6:4] with
+ * appropriate value when doing read-modify of AUD_CONFIG register.
+ *
+ * @substream: the current substream or NULL if no active substream
+ * @data : data to be written
+ * @mask : mask
+ *
+ */
+inline int had_read_modify_aud_config_v2(struct snd_pcm_substream

*substream,

Quoted 5 lines

sound/x86/intel_hdmi_audio.c line 259

Quoted 1 line
sound/x86/intel_hdmi_audio.c new file +1 -0
+					uint32_t data, uint32_t mask)

Is this really external? Or can it be static?
(Ditto for some others *_v1 and *_v2.)

Will make it static

Quoted 5 lines
Quoted 2 lines

+/*
+ ** ALSA API channel-map control callbacks **/

Avoid such a confusing comment style.

Ok, will change the comment

Quoted 22 lines
Quoted 22 lines
sound/x86/intel_hdmi_audio.c new file +22 -0
+static int had_chmap_ctl_info(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_info *uinfo)
+{
+	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
+	struct snd_intelhad *intelhaddata = info->private_data;
+
+	if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED)
+		return -ENODEV;
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+	uinfo->count = HAD_MAX_CHANNEL;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = SNDRV_CHMAP_LAST;
+	return 0;
+}
+
+#ifndef USE_ALSA_DEFAULT_TLV
+static int had_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
+				unsigned int size, unsigned int __user *tlv) {
+	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
+	struct snd_intelhad *intelhaddata = info->private_data;
+
+	if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED)
Quoted 9 lines

sound/x86/intel_hdmi_audio.c line 667

Quoted 6 lines
sound/x86/intel_hdmi_audio.c new file +6 -0
+		return -ENODEV;
+
+	/* TODO: Fix for query channel map */
+	return -EPERM;
+}
+#endif

For what reason is this dummy implementation provided?

This was taken from legacy to support chmap setting from above layers. I'll remove this as well

Quoted 21 lines
Quoted 21 lines
sound/x86/intel_hdmi_audio.c new file +21 -0
+
+static int had_chmap_ctl_get(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol) {
+	struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
+	struct snd_intelhad *intelhaddata = info->private_data;
+	int i = 0;
+	const struct snd_pcm_chmap_elem *chmap;
+
+	if (intelhaddata->drv_status == HAD_DRV_DISCONNECTED)
+		return -ENODEV;
+	if (intelhaddata->chmap->chmap ==  NULL)
+		return -ENODATA;
+	chmap = intelhaddata->chmap->chmap;
+	for (i = 0; i < chmap->channels; i++) {
+		ucontrol->value.integer.value[i] = chmap->map[i];
+		pr_debug("chmap->map[%d] = %d\n", i, chmap->map[i]);
+	}
+
+	return 0;
+}
+
Quoted 9 lines

sound/x86/intel_hdmi_audio.c line 695

Quoted 5 lines
sound/x86/intel_hdmi_audio.c new file +5 -0
+static int had_chmap_ctl_put(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol) {
+	/* TODO: Get channel map and set swap register */
+	return -EPERM;
+}

The standard chmap doesn't support write unless explicitly changed. So you can drop the callback as well.

Ok, will remove this.

Quoted 4 lines

thanks,

Takashi

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

#7 lore raw

Re: [PATCH V3 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

In reply to Anand, Jerome
Quoted 15 lines · Jerome
Quoted 5 lines
Quoted 5 lines
sound/x86/intel_hdmi_lpe_audio.c new file +5 -0
+void mid_hdmi_audio_signal_event(enum had_event_type event) {
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 172

Quoted 5 lines
sound/x86/intel_hdmi_lpe_audio.c new file +5 -0
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (ctx->had_event_callbacks)
+		(*ctx->had_event_callbacks)(event,
+			ctx->had_pvt_data);

Isn't this racy? This dispatcher seems called from multiple places including the interrupt handler below.

Quoted 1 line

No, It's taken care of in the respective callbacks based on the event

If the race protection must be handled inside the callback, please describe it.

Quoted 27 lines
Quoted 17 lines
Quoted 17 lines
sound/x86/intel_hdmi_lpe_audio.c new file +17 -0
+/**
+ * hdmi_audio_get_caps:
+ * used to return the HDMI audio capabilities.
+ * e.g. resolution, frame rate.
+ */
+static int hdmi_audio_get_caps(enum had_caps_list get_element,
+			void *capabilities)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+	int ret = 0;
+
+	ctx = get_hdmi_context();
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
+	switch (get_element) {
+	case HAD_GET_ELD:
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 251

Quoted 6 lines
sound/x86/intel_hdmi_lpe_audio.c new file +6 -0
+		ret = hdmi_get_eld(capabilities);
+		break;
+	case HAD_GET_DISPLAY_RATE:
+		/* ToDo: Verify if sampling freq logic is correct */
+		memcpy(capabilities, &(ctx->tmds_clock_speed),
+			sizeof(uint32_t));

Why memcpy? Both source and destination are 32bit int, no?

Quoted 1 line

Do you think *(int *)capabilities = ctx->tmds_clock_speed is better than memcpy?

Why not simply substitution:

	capabilities = ctx->tmds_clock_speed;

?

Quoted 20 lines
Quoted 20 lines

sound/x86/intel_hdmi_lpe_audio.c

Quoted 12 lines
sound/x86/intel_hdmi_lpe_audio.c new file +12 -0
+/**
+ * hdmi_audio_get_register_base
+ * used to get the current hdmi base address  */ int
+hdmi_audio_get_register_base(uint32_t **reg_base,
+		uint32_t *config_offset)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	*reg_base = (uint32_t *)(ctx->mmio_start);
+	*config_offset = ctx->had_config_offset;
+	dev_dbg(&hlpe_pdev->dev, "%s: reg_base = 0x%p, cfg_off =

0x%x\n", __func__,

Review

Quoted 2 lines
(quoted diff) +2 -0
+			*reg_base, *config_offset);
+	return 0;

Well, I see no reason why this function / callback is needed.
The base address is never referred in other codes, and the config_offset is always passed to read/write accessors, so it can be calculated there directly.

Quoted 5 lines
Quoted 2 lines

Any other missing cases?

I wanted to have a cleaner separation, hence added this function in this file rather Than deriving it. So would prefer to keep it.

Passing the base register address and the offset is never a "clean" separation from the abstraction POV. It's just a passthrough of the lowlevel interface. If you want an abstraction layer, such a lowlevel information should be protected inside.

IOW, why does th upper layer need to know these address and offset, if the lowlevel read/write accessor itself already knows of them?

thanks,

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

#8 lore raw

Re: [alsa-devel] [PATCH V3 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

Quoted 29 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, January 19, 2017 4:22 PM
To: Anand, Jerome <[email protected]>
Cc: [email protected]; [email protected]; pierre- [email protected]; [email protected]; Ughreja, Rakesh A <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH V3 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

Quoted 15 lines · Jerome
Quoted 14 lines

sound/x86/intel_hdmi_lpe_audio.c line 172

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+void mid_hdmi_audio_signal_event(enum had_event_type event) {
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (ctx->had_event_callbacks)
+		(*ctx->had_event_callbacks)(event,
+			ctx->had_pvt_data);

Isn't this racy? This dispatcher seems called from multiple places including the interrupt handler below.

Quoted 4 lines
Quoted 1 line

No, It's taken care of in the respective callbacks based on the event

If the race protection must be handled inside the callback, please describe it.

Ok, will add a comment along with this code

Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 14 lines
sound/x86/intel_hdmi_lpe_audio.c new file +13 -0
+/**
+ * hdmi_audio_get_caps:
+ * used to return the HDMI audio capabilities.
+ * e.g. resolution, frame rate.
+ */
+static int hdmi_audio_get_caps(enum had_caps_list get_element,
+			void *capabilities)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+	int ret = 0;
+
+	ctx = get_hdmi_context();
+

sound/x86/intel_hdmi_lpe_audio.c line 251

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
+	switch (get_element) {
+	case HAD_GET_ELD:
+		ret = hdmi_get_eld(capabilities);
+		break;
+	case HAD_GET_DISPLAY_RATE:
+		/* ToDo: Verify if sampling freq logic is correct */
+		memcpy(capabilities, &(ctx->tmds_clock_speed),
+			sizeof(uint32_t));

Why memcpy? Both source and destination are 32bit int, no?

Quoted 7 lines
Quoted 1 line

Do you think *(int *)capabilities = ctx->tmds_clock_speed is better than

memcpy?

Why not simply substitution:

	capabilities = ctx->tmds_clock_speed;

?

Capabilities is a void *.

Quoted 28 lines
Quoted 14 lines
Quoted 14 lines

sound/x86/intel_hdmi_lpe_audio.c

Quoted 13 lines
sound/x86/intel_hdmi_lpe_audio.c new file +12 -0
+/**
+ * hdmi_audio_get_register_base
+ * used to get the current hdmi base address  */ int
+hdmi_audio_get_register_base(uint32_t **reg_base,
+		uint32_t *config_offset)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	*reg_base = (uint32_t *)(ctx->mmio_start);
+	*config_offset = ctx->had_config_offset;
+	dev_dbg(&hlpe_pdev->dev, "%s: reg_base = 0x%p, cfg_off =

0x%x\n", __func__,

Quoted 6 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+			*reg_base, *config_offset);
+	return 0;

Well, I see no reason why this function / callback is needed. The base address is never referred in other codes, and the config_offset is always passed to read/write accessors, so it can be

calculated there directly.

Quoted 6 lines
Quoted 3 lines

Any other missing cases?

I wanted to have a cleaner separation, hence added this function in this file rather Than deriving it. So would prefer to keep it.

Quoted 8 lines

Passing the base register address and the offset is never a "clean" separation from the abstraction POV. It's just a passthrough of the lowlevel interface. If you want an abstraction layer, such a lowlevel information should be protected inside.

IOW, why does th upper layer need to know these address and offset, if the lowlevel read/write accessor itself already knows of them?

Am maintaining the driver context along with the registers in one abstraction and read/write accesses in another; Hence this indirection is needed.

As already stated previously, once we deliver you the next patch series after DP integration, one level of indirection can be removed. As of now, I propose to keep it this way.

Quoted 4 lines

thanks,

Takashi

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

#9 lore raw

Re: [alsa-devel] [PATCH V3 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

Quoted 66 lines · Jerome
Quoted 30 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Thursday, January 19, 2017 4:22 PM
To: Anand, Jerome <[email protected]>
Cc: [email protected]; [email protected]; pierre- [email protected]; [email protected]; Ughreja, Rakesh A <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [PATCH V3 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T

Quoted 15 lines · Jerome
Quoted 14 lines

sound/x86/intel_hdmi_lpe_audio.c line 172

Quoted 10 lines
sound/x86/intel_hdmi_lpe_audio.c new file +10 -0
+void mid_hdmi_audio_signal_event(enum had_event_type event) {
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+
+	if (ctx->had_event_callbacks)
+		(*ctx->had_event_callbacks)(event,
+			ctx->had_pvt_data);

Isn't this racy? This dispatcher seems called from multiple places including the interrupt handler below.

Quoted 4 lines
Quoted 1 line

No, It's taken care of in the respective callbacks based on the event

If the race protection must be handled inside the callback, please describe it.

Ok, will add a comment along with this code

Quoted 29 lines
Quoted 29 lines
Quoted 18 lines
Quoted 18 lines
sound/x86/intel_hdmi_lpe_audio.c new file +17 -0
+/**
+ * hdmi_audio_get_caps:
+ * used to return the HDMI audio capabilities.
+ * e.g. resolution, frame rate.
+ */
+static int hdmi_audio_get_caps(enum had_caps_list get_element,
+			void *capabilities)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+	int ret = 0;
+
+	ctx = get_hdmi_context();
+
+	dev_dbg(&hlpe_pdev->dev, "%s: Enter\n", __func__);
+
+	switch (get_element) {
+	case HAD_GET_ELD:
Quoted 9 lines

sound/x86/intel_hdmi_lpe_audio.c line 251

Quoted 6 lines
sound/x86/intel_hdmi_lpe_audio.c new file +6 -0
+		ret = hdmi_get_eld(capabilities);
+		break;
+	case HAD_GET_DISPLAY_RATE:
+		/* ToDo: Verify if sampling freq logic is correct */
+		memcpy(capabilities, &(ctx->tmds_clock_speed),
+			sizeof(uint32_t));

Why memcpy? Both source and destination are 32bit int, no?

Do you think *(int *)capabilities = ctx->tmds_clock_speed is better than

Quoted 8 lines
Quoted 6 lines

memcpy?

Why not simply substitution:

	capabilities = ctx->tmds_clock_speed;

?

Capabilities is a void *.

Ah yes, then a cast is needed.

Quoted 32 lines
Quoted 32 lines
Quoted 13 lines
Quoted 13 lines

sound/x86/intel_hdmi_lpe_audio.c

Quoted 12 lines
sound/x86/intel_hdmi_lpe_audio.c new file +12 -0
+/**
+ * hdmi_audio_get_register_base
+ * used to get the current hdmi base address  */ int
+hdmi_audio_get_register_base(uint32_t **reg_base,
+		uint32_t *config_offset)
+{
+	struct hdmi_lpe_audio_ctx *ctx;
+
+	ctx = platform_get_drvdata(hlpe_pdev);
+	*reg_base = (uint32_t *)(ctx->mmio_start);
+	*config_offset = ctx->had_config_offset;
+	dev_dbg(&hlpe_pdev->dev, "%s: reg_base = 0x%p, cfg_off =

0x%x\n", __func__,

Quoted 6 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+			*reg_base, *config_offset);
+	return 0;

Well, I see no reason why this function / callback is needed. The base address is never referred in other codes, and the config_offset is always passed to read/write accessors, so it can be

calculated there directly.

Quoted 6 lines
Quoted 3 lines

Any other missing cases?

I wanted to have a cleaner separation, hence added this function in this file rather Than deriving it. So would prefer to keep it.

Passing the base register address and the offset is never a "clean" separation from the abstraction POV. It's just a passthrough of the lowlevel interface. If you want an abstraction layer, such a lowlevel information should be protected inside.

Quoted 6 lines
Quoted 3 lines

IOW, why does th upper layer need to know these address and offset, if the lowlevel read/write accessor itself already knows of them?

Am maintaining the driver context along with the registers in one abstraction and read/write accesses in another; Hence this indirection is needed.

I don't mean about the separated layers (although I prefer removing it). My only question in the context above is why you have to pass the I/O-mapped address back to the upper layer at all.

From the abstraction POV, passing the raw address to the upper layer
makes no sense at all. If the raw address is available in the upper layer, it can access directly by itself, so it doesn't need the lower layer any longer. That is, passing such information breaks the existence of the layer by itself.

Quoted 2 lines

As already stated previously, once we deliver you the next patch series after DP integration, one level of indirection can be removed. As of now, I propose to keep it this way.

OK. Once when DP works, I can test it locally, so start working on cleanup.

thanks,

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