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

2017-01-24 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/Kconfig|   2 +
 sound/Makefile   |   2 +-
 sound/x86/Kconfig|  15 +
 sound/x86/Makefile   |   4 +
 sound/x86/intel_hdmi_lpe_audio.c | 614 +++
 sound/x86/intel_hdmi_lpe_audio.h | 683 +++
 6 files changed, 1319 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

diff --git a/sound/Kconfig b/sound/Kconfig
index 5a240e0..ee2e69a 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -108,6 +108,8 @@ source "sound/parisc/Kconfig"
 
 source "sound/soc/Kconfig"
 
+source "sound/x86/Kconfig"
+
 endif # SND
 
 menuconfig SOUND_PRIME
diff --git a/sound/Makefile b/sound/Makefile
index c41bdf5..6de45d2 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -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
diff --git a/sound/x86/Kconfig b/sound/x86/Kconfig
new file mode 100644
index 000..30d066e
--- /dev/null
+++ b/sound/x86/Kconfig
@@ -0,0 +1,15 @@
+menuconfig SND_X86
+   tristate "X86 sound devices"
+   depends on X86
+   ---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
+   help
+Choose this option to support HDMI LPE Audio mode
+
+endif  # SND_X86
diff --git a/sound/x86/Makefile b/sound/x86/Makefile
new file mode 100644
index 000..9b87384
--- /dev/null
+++ b/sound/x86/Makefile
@@ -0,0 +1,4 @@
+snd-hdmi-lpe-audio-objs += \
+   intel_hdmi_lpe_audio.o
+
+obj-$(CONFIG_HDMI_LPE_AUDIO) += snd-hdmi-lpe-audio.o
diff --git a/sound/x86/intel_hdmi_lpe_audio.c b/sound/x86/intel_hdmi_lpe_audio.c
new file mode 100644
index 000..a9fd2d3
--- /dev/null
+++ b/sound/x86/intel_hdmi_lpe_audio.c
@@ -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 
+ * Aravind Siddappaji 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_lpe_audio.h"
+
+/* globals*/
+static struct platform_device *hlpe_pdev;
+static int hlpe_state;
+static union otm_hdmi_eld_t hlpe_eld;
+
+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;
+   int hdmi_audio_interrupt_mask;
+   struct work_struct hdmi_audio_wq;
+};
+
+static void hdmi_set_eld(void *eld)
+{
+   int size;
+
+   BUILD_BUG_ON(sizeof(hlpe_eld) > HDMI_MAX_ELD_BYTES);
+
+   size = sizeof(hlpe_eld);
+   memcpy((void *)&hlpe_eld, eld, size);

[Intel-gfx] [PATCH v5 1/5] drm/i915: setup bridge for HDMI LPE audio driver

2017-01-24 Thread 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.

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 Documentation/gpu/i915.rst |   9 +
 drivers/gpu/drm/i915/Makefile  |   3 +
 drivers/gpu/drm/i915/i915_drv.c|   4 +-
 drivers/gpu/drm/i915/i915_drv.h|  11 ++
 drivers/gpu/drm/i915/i915_irq.c|  16 ++
 drivers/gpu/drm/i915/i915_reg.h|   3 +
 drivers/gpu/drm/i915/intel_audio.c |  25 +++
 drivers/gpu/drm/i915/intel_drv.h   |   2 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 321 +
 include/drm/intel_lpe_audio.h  |  46 +
 10 files changed, 438 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lpe_audio.c
 create mode 100644 include/drm/intel_lpe_audio.h

diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 104296d..bd9b767 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -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
 
 
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 74ca2e8..c62ab45 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -129,6 +129,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)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index ca168b2..2e0574c 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1140,7 +1140,7 @@ 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);
+   intel_audio_init(dev_priv);
 
/*
 * Some ports require correctly set-up hpd registers for detection to
@@ -1158,7 +1158,7 @@ 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);
+   intel_audio_deinit(dev_priv);
 
intel_gpu_ips_teardown();
acpi_video_unregister();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2446280..8b68f900 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2454,6 +2454,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.
@@ -3592,6 +3598,11 @@ 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);
 
+/* intel_lpe_audio.c */
+int  intel_lpe_audio_init(struct drm_i915_private *dev_priv);
+void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv);
+void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv);
+
 /* 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);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 6fefc34..47d6131 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1926,6 +1926,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 

[Intel-gfx] [PATCH v5 0/5] Add support for Legacy HDMI audio drivers

2017-01-24 Thread Jerome Anand
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|4 +-
 drivers/gpu/drm/i915/i915_drv.h|   13 +
 drivers/gpu/drm/i915/i915_irq.c|   16 +
 drivers/gpu/drm/i915/i915_reg.h|3 +
 drivers/gpu/drm/i915/intel_audio.c |   31 +
 drivers/gpu/drm/i915/intel_drv.h   |2 +
 drivers/gpu/drm/i915/intel_hdmi.c  |1 +
 drivers/gpu/drm/i915/intel_lpe_audio.c |  370 +++
 include/drm/intel_lpe_audio.h  |   46 +
 sound/Kconfig  |2 +
 sound/Makefile |2 +-
 sound/x86/Kconfig  |   15 +
 sound/x86/Makefile |6 +
 sound/x86/intel_hdmi_audio.c   | 1870 
 sound/x86/intel_hdmi_audio.h   |  197 
 sound/x86/intel_hdmi_audio_if.c|  551 ++
 sound/x86/intel_hdmi_lpe_audio.c   |  617 +++
 sound/x86/intel_hdmi_lpe_audio.h   |  683 
 20 files changed, 4438 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

-- 
2.9.3

base-commit: c34072a82a390d575f7f0394fcf92437898d75d3
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v5 2/5] drm/i915: Add support for audio driver notifications

2017-01-24 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 drivers/gpu/drm/i915/i915_drv.h|  2 ++
 drivers/gpu/drm/i915/intel_audio.c |  6 +
 drivers/gpu/drm/i915/intel_hdmi.c  |  1 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 49 ++
 4 files changed, 58 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 8b68f900..8a57744 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3602,6 +3602,8 @@ void i915_teardown_sysfs(struct drm_i915_private 
*dev_priv);
 int  intel_lpe_audio_init(struct drm_i915_private *dev_priv);
 void intel_lpe_audio_teardown(struct drm_i915_private *dev_priv);
 void intel_lpe_audio_irq_handler(struct drm_i915_private *dev_priv);
+void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
+   void *eld, int port, int tmds_clk_speed);
 
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);
diff --git a/drivers/gpu/drm/i915/intel_audio.c 
b/drivers/gpu/drm/i915/intel_audio.c
index 103159d..45a5406 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "intel_drv.h"
 
 #include 
@@ -630,6 +631,9 @@ void intel_audio_codec_enable(struct intel_encoder 
*intel_encoder,
if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
 (int) port, (int) pipe);
+
+   intel_lpe_audio_notify(dev_priv, connector->eld, port,
+   crtc_state->port_clock);
 }
 
 /**
@@ -663,6 +667,8 @@ void intel_audio_codec_disable(struct intel_encoder 
*intel_encoder)
if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
acomp->audio_ops->pin_eld_notify(acomp->audio_ops->audio_ptr,
 (int) port, (int) pipe);
+
+   intel_lpe_audio_notify(dev_priv, NULL, port, 0);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 0bcfead..377584e1 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -36,6 +36,7 @@
 #include 
 #include "intel_drv.h"
 #include 
+#include 
 #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 7ce1b5b..27d9425 100644
--- a/drivers/gpu/drm/i915/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/intel_lpe_audio.c
@@ -319,3 +319,52 @@ void intel_lpe_audio_teardown(struct drm_i915_private 
*dev_priv)
 
irq_free_desc(dev_priv->lpe_audio.irq);
 }
+
+
+/**
+ * intel_lpe_audio_notify() - notify lpe audio event
+ * audio driver and i915
+ * @dev_priv: the i915 drm device private data
+ * @eld : ELD data
+ * @port: port id
+ * @tmds_clk_speed: tmds clock frequency in Hz
+ *
+ * Notify lpe audio driver of eld change.
+ */
+void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
+   void *eld, int port, int tmds_clk_speed)
+{
+   unsigned long irq_flags;
+   struct intel_hdmi_lpe_audio_pdata *pdata = NULL;
+
+   if (!HAS_LPE_AUDIO(dev_priv))
+   return;
+
+   pdata = dev_get_platdata(
+   &(dev_priv->lpe_audio.platdev->dev));
+
+   spin_lock_irqsave(&pdata->lpe_audio_slock, irq_flags);
+
+   if (eld != NULL) {
+   memcpy(pdata->eld.eld_data, eld,
+   HDMI_MAX_ELD_BYTES);
+   pdata->eld.port_id = port;
+   pdata->hdmi_connected = true;
+
+   if (tmds_clk_speed)
+   pdata->tmds_clock_speed = tmds_clk_speed;
+   } else {
+   memset(pdata->eld.eld_data, 0,
+   HDMI_MAX_ELD_BYTES);
+   pdata->hdmi_connected = false;
+   }
+
+   if (pdata->notify_audio_lpe)
+   pdata->notify_audio_lpe(
+   (eld != NULL) ? &pdata->eld : NULL);
+   else
+   pdata->notify_pending = true;
+
+   spin_unlock_irqrestore(&pdata->lpe_audio_slock,
+   irq_flags);
+}
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v5 5/5] ALSA: x86: hdmi: continue playback even when display resolution changes

2017-01-24 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index b69521a..f301554 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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,
@@ -1052,6 +1053,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);
 
@@ -1445,10 +1447,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)
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v5 4/5] ALSA: x86: hdmi: Add audio support for BYT and CHT

2017-01-24 Thread 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  and is
accomodated in this patch

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/Makefile   |2 +
 sound/x86/intel_hdmi_audio.c | 1855 ++
 sound/x86/intel_hdmi_audio.h |  197 
 sound/x86/intel_hdmi_audio_if.c  |  551 +++
 sound/x86/intel_hdmi_lpe_audio.c |   15 +-
 5 files changed, 2614 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

diff --git a/sound/x86/Makefile b/sound/x86/Makefile
index 9b87384..85ea22a 100644
--- a/sound/x86/Makefile
+++ b/sound/x86/Makefile
@@ -1,4 +1,6 @@
 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
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
new file mode 100644
index 000..b69521a
--- /dev/null
+++ b/sound/x86/intel_hdmi_audio.c
@@ -0,0 +1,1855 @@
+/*
+ *   intel_hdmi_audio.c - Intel HDMI audio driver
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:   Sailaja Bandarupalli 
+ * Ramesh Babu K V 
+ * Vaibhav Agarwal 
+ * Jerome Anand 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ * ALSA driver for Intel HDMI audio
+ */
+
+#define pr_fmt(fmt)"had: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_audio.h"
+
+static DEFINE_MUTEX(had_mutex);
+
+/*standard module options for ALSA. This module supports only one card*/
+static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
+static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
+static struct snd_intelhad *had_data;
+
+module_param_named(index, hdmi_card_index, int, 0444);
+MODULE_PARM_DESC(index,
+   "Index value for INTEL Intel HDMI Audio controller.");
+module_param_named(id, hdmi_card_id, charp, 0444);
+MODULE_PARM_DESC(id,
+   "ID string for INTEL Intel HDMI Audio controller.");
+
+/*
+ * ELD SA bits in the CEA Speaker Allocation data block
+ */
+static int eld_speaker_allocation_bits[] = {
+   [0] = FL | FR,
+   [1] = LFE,
+   [2] = FC,
+   [3] = RL | RR,
+   [4] = RC,
+   [5] = FLC | FRC,
+   [6] = RLC | RRC,
+   /* the following are not defined in ELD yet */
+   [7] = 0,
+};
+
+/*
+ * This is an ordered list!
+ *
+ * The preceding ones have better chances to be selected by
+ * hdmi_channel_allocation().
+ */
+static struct cea_channel_speaker_allocation channel_allocations[] = {
+/*channel:   7 6543 210  */
+{ .ca_index = 0x00,  .speakers = {   0,0,   0,   0,   0,0,  FR,  FL } 
},
+   /* 2.1 */
+{ .ca_index = 0x01,  .speakers = {   0,0,   0,   0,   0,  LFE,  FR,  FL } 
},
+   /* Dolby Surround */
+{ .ca_index = 0x02,  .speakers = {   0,0,   0,   0,  FC,0,  FR,  FL } 
},
+   /* surround40 */
+{ .ca_index = 0x08,  .speakers = {   0,0,  RR,  RL,   0,0,  FR,  FL } 
},
+   /* surround41 */
+{ .ca_index = 0x09,  .speakers = {   0,0,  RR,  RL,   0,  LFE,  FR,  FL } 
},
+   /* surround50 */
+{ .ca_index = 0x0a,  .speakers = {   0,0,  RR,  RL,  FC,0,  FR,  FL } 
},
+   /* surround51 */
+{ .ca_index = 0x0b,  .speakers = {   0,0,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* 6.1 */
+{ .ca_index = 0x0f,  .speakers = {   0,   RC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* surround71 */
+{ .ca_index = 0x13,  .speakers = { RRC,  RLC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+
+{ .ca_index = 0x03,  .speakers = { 

[Intel-gfx] [PATCH v4 4/5] ALSA: x86: hdmi: Add audio support for BYT and CHT

2017-01-20 Thread 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  and is
accomodated in this patch

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/Makefile   |2 +
 sound/x86/intel_hdmi_audio.c | 1855 ++
 sound/x86/intel_hdmi_audio.h |  197 
 sound/x86/intel_hdmi_audio_if.c  |  551 +++
 sound/x86/intel_hdmi_lpe_audio.c |   15 +-
 5 files changed, 2614 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

diff --git a/sound/x86/Makefile b/sound/x86/Makefile
index 9b87384..85ea22a 100644
--- a/sound/x86/Makefile
+++ b/sound/x86/Makefile
@@ -1,4 +1,6 @@
 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
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
new file mode 100644
index 000..b69521a
--- /dev/null
+++ b/sound/x86/intel_hdmi_audio.c
@@ -0,0 +1,1855 @@
+/*
+ *   intel_hdmi_audio.c - Intel HDMI audio driver
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:   Sailaja Bandarupalli 
+ * Ramesh Babu K V 
+ * Vaibhav Agarwal 
+ * Jerome Anand 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ * ALSA driver for Intel HDMI audio
+ */
+
+#define pr_fmt(fmt)"had: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_audio.h"
+
+static DEFINE_MUTEX(had_mutex);
+
+/*standard module options for ALSA. This module supports only one card*/
+static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
+static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
+static struct snd_intelhad *had_data;
+
+module_param_named(index, hdmi_card_index, int, 0444);
+MODULE_PARM_DESC(index,
+   "Index value for INTEL Intel HDMI Audio controller.");
+module_param_named(id, hdmi_card_id, charp, 0444);
+MODULE_PARM_DESC(id,
+   "ID string for INTEL Intel HDMI Audio controller.");
+
+/*
+ * ELD SA bits in the CEA Speaker Allocation data block
+ */
+static int eld_speaker_allocation_bits[] = {
+   [0] = FL | FR,
+   [1] = LFE,
+   [2] = FC,
+   [3] = RL | RR,
+   [4] = RC,
+   [5] = FLC | FRC,
+   [6] = RLC | RRC,
+   /* the following are not defined in ELD yet */
+   [7] = 0,
+};
+
+/*
+ * This is an ordered list!
+ *
+ * The preceding ones have better chances to be selected by
+ * hdmi_channel_allocation().
+ */
+static struct cea_channel_speaker_allocation channel_allocations[] = {
+/*channel:   7 6543 210  */
+{ .ca_index = 0x00,  .speakers = {   0,0,   0,   0,   0,0,  FR,  FL } 
},
+   /* 2.1 */
+{ .ca_index = 0x01,  .speakers = {   0,0,   0,   0,   0,  LFE,  FR,  FL } 
},
+   /* Dolby Surround */
+{ .ca_index = 0x02,  .speakers = {   0,0,   0,   0,  FC,0,  FR,  FL } 
},
+   /* surround40 */
+{ .ca_index = 0x08,  .speakers = {   0,0,  RR,  RL,   0,0,  FR,  FL } 
},
+   /* surround41 */
+{ .ca_index = 0x09,  .speakers = {   0,0,  RR,  RL,   0,  LFE,  FR,  FL } 
},
+   /* surround50 */
+{ .ca_index = 0x0a,  .speakers = {   0,0,  RR,  RL,  FC,0,  FR,  FL } 
},
+   /* surround51 */
+{ .ca_index = 0x0b,  .speakers = {   0,0,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* 6.1 */
+{ .ca_index = 0x0f,  .speakers = {   0,   RC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* surround71 */
+{ .ca_index = 0x13,  .speakers = { RRC,  RLC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+
+{ .ca_index = 0x03,  .speakers = { 

[Intel-gfx] [PATCH v4 5/5] ALSA: x86: hdmi: continue playback even when display resolution changes

2017-01-20 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index b69521a..f301554 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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,
@@ -1052,6 +1053,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);
 
@@ -1445,10 +1447,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)
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v4 0/5] Add support for Legacy HDMI audio drivers

2017-01-20 Thread Jerome Anand
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 |  388 +++
 include/drm/intel_lpe_audio.h  |   46 +
 sound/Kconfig  |2 +
 sound/Makefile |2 +-
 sound/x86/Kconfig  |   15 +
 sound/x86/Makefile |6 +
 sound/x86/intel_hdmi_audio.c   | 1870 
 sound/x86/intel_hdmi_audio.h   |  197 
 sound/x86/intel_hdmi_audio_if.c|  551 ++
 sound/x86/intel_hdmi_lpe_audio.c   |  617 +++
 sound/x86/intel_hdmi_lpe_audio.h   |  683 
 19 files changed, 4439 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

-- 
2.9.3

base-commit: eb5c556a1e5eff388e48e4b7cf61e95783019e83
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


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

2017-01-20 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/Kconfig|   2 +
 sound/Makefile   |   2 +-
 sound/x86/Kconfig|  15 +
 sound/x86/Makefile   |   4 +
 sound/x86/intel_hdmi_lpe_audio.c | 614 +++
 sound/x86/intel_hdmi_lpe_audio.h | 683 +++
 6 files changed, 1319 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

diff --git a/sound/Kconfig b/sound/Kconfig
index 5a240e0..ee2e69a 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -108,6 +108,8 @@ source "sound/parisc/Kconfig"
 
 source "sound/soc/Kconfig"
 
+source "sound/x86/Kconfig"
+
 endif # SND
 
 menuconfig SOUND_PRIME
diff --git a/sound/Makefile b/sound/Makefile
index c41bdf5..6de45d2 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -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
diff --git a/sound/x86/Kconfig b/sound/x86/Kconfig
new file mode 100644
index 000..30d066e
--- /dev/null
+++ b/sound/x86/Kconfig
@@ -0,0 +1,15 @@
+menuconfig SND_X86
+   tristate "X86 sound devices"
+   depends on X86
+   ---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
+   help
+Choose this option to support HDMI LPE Audio mode
+
+endif  # SND_X86
diff --git a/sound/x86/Makefile b/sound/x86/Makefile
new file mode 100644
index 000..9b87384
--- /dev/null
+++ b/sound/x86/Makefile
@@ -0,0 +1,4 @@
+snd-hdmi-lpe-audio-objs += \
+   intel_hdmi_lpe_audio.o
+
+obj-$(CONFIG_HDMI_LPE_AUDIO) += snd-hdmi-lpe-audio.o
diff --git a/sound/x86/intel_hdmi_lpe_audio.c b/sound/x86/intel_hdmi_lpe_audio.c
new file mode 100644
index 000..a9fd2d3
--- /dev/null
+++ b/sound/x86/intel_hdmi_lpe_audio.c
@@ -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 
+ * Aravind Siddappaji 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_lpe_audio.h"
+
+/* globals*/
+static struct platform_device *hlpe_pdev;
+static int hlpe_state;
+static union otm_hdmi_eld_t hlpe_eld;
+
+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;
+   int hdmi_audio_interrupt_mask;
+   struct work_struct hdmi_audio_wq;
+};
+
+static void hdmi_set_eld(void *eld)
+{
+   int size;
+
+   BUILD_BUG_ON(sizeof(hlpe_eld) > HDMI_MAX_ELD_BYTES);
+
+   size = sizeof(hlpe_eld);
+   memcpy((void *)&hlpe_eld, eld, size);

[Intel-gfx] [PATCH v4 2/5] drm/i915: Add support for audio driver notifications

2017-01-20 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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 | 49 ++
 4 files changed, 60 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index cc7033a..601c8ad 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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);
diff --git a/drivers/gpu/drm/i915/intel_audio.c 
b/drivers/gpu/drm/i915/intel_audio.c
index 16c2027..00a485e 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "intel_drv.h"
 
 #include 
@@ -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);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 0bcfead..377584e1 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -36,6 +36,7 @@
 #include 
 #include "intel_drv.h"
 #include 
+#include 
 #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 099732c..293084d 100644
--- a/drivers/gpu/drm/i915/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/intel_lpe_audio.c
@@ -337,3 +337,52 @@ void intel_lpe_audio_teardown(struct drm_i915_private 
*dev_priv)
 
irq_free_desc(dev_priv->lpe_audio.irq);
 }
+
+
+/**
+ * intel_lpe_audio_notify() - notify lpe audio event
+ * audio driver and i915
+ * @dev_priv: the i915 drm device private data
+ * @eld : ELD data
+ * @port: port id
+ * @tmds_clk_speed: tmds clock frequency in Hz
+ *
+ * Notify lpe audio driver of eld change.
+ */
+void intel_lpe_audio_notify(struct drm_i915_private *dev_priv,
+   void *eld, int port, int tmds_clk_speed)
+{
+   unsigned long irq_flags;
+   struct intel_hdmi_lpe_audio_pdata *pdata = NULL;
+
+   if (!HAS_LPE_AUDIO(dev_priv))
+   return;
+
+   pdata = dev_get_platdata(
+   &(dev_priv->lpe_audio.platdev->dev));
+
+   spin_lock_irqsave(&pdata->lpe_audio_slock, irq_flags);
+
+   if (eld != NULL) {
+   memcpy(pdata->eld.eld_data, eld,
+   HDMI_MAX_ELD_BYTES);
+   pdata->eld.port_id = port;
+   pdata->hdmi_connected = true;
+
+   if (tmds_clk_speed)
+   pdata->tmds_clock_speed = tmds_clk_speed;
+   } else {
+   memset(pdata->eld.eld_data, 0,
+   HDMI_MAX_ELD_BYTES);
+   pdata->hdmi_connected = false;
+   }
+
+   if (pdata->notify_audio_lpe)
+   pdata->notify_audio_lpe(
+   (eld != NULL) ? &pdata->eld : NULL);
+   else
+   pdata->notify_pending = true;
+
+   spin_unlock_irqrestore(&pdata->lpe_audio_slock,
+   irq_flags);
+}
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH v4 1/5] drm/i915: setup bridge for HDMI LPE audio driver

2017-01-20 Thread 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.

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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

diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 104296d..bd9b767 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -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
 
 
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 5196509..2bca239 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -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)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 4d22b4b..70d728b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -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();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f66eeede..cc7033a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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);
diff --git a/driver

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

2017-01-09 Thread 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  and is
accomodated in this patch

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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

diff --git a/sound/x86/Makefile b/sound/x86/Makefile
index 54d002d..a8d1a8a 100644
--- a/sound/x86/Makefile
+++ b/sound/x86/Makefile
@@ -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
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
new file mode 100644
index 000..5305c5c
--- /dev/null
+++ b/sound/x86/intel_hdmi_audio.c
@@ -0,0 +1,1917 @@
+/*
+ *   intel_hdmi_audio.c - Intel HDMI audio driver
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:   Sailaja Bandarupalli 
+ * Ramesh Babu K V 
+ * Vaibhav Agarwal 
+ * Jerome Anand 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ * ALSA driver for Intel HDMI audio
+ */
+
+#define pr_fmt(fmt)"had: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_audio.h"
+
+static DEFINE_MUTEX(had_mutex);
+
+/*standard module options for ALSA. This module supports only one card*/
+static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
+static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
+static struct snd_intelhad *had_data;
+
+module_param_named(index, hdmi_card_index, int, 0444);
+MODULE_PARM_DESC(index,
+   "Index value for INTEL Intel HDMI Audio controller.");
+module_param_named(id, hdmi_card_id, charp, 0444);
+MODULE_PARM_DESC(id,
+   "ID string for INTEL Intel HDMI Audio controller.");
+
+/*
+ * ELD SA bits in the CEA Speaker Allocation data block
+*/
+static int eld_speaker_allocation_bits[] = {
+   [0] = FL | FR,
+   [1] = LFE,
+   [2] = FC,
+   [3] = RL | RR,
+   [4] = RC,
+   [5] = FLC | FRC,
+   [6] = RLC | RRC,
+   /* the following are not defined in ELD yet */
+   [7] = 0,
+};
+
+/*
+ * This is an ordered list!
+ *
+ * The preceding ones have better chances to be selected by
+ * hdmi_channel_allocation().
+ */
+static struct cea_channel_speaker_allocation channel_allocations[] = {
+/*channel:   7 6543 210  */
+{ .ca_index = 0x00,  .speakers = {   0,0,   0,   0,   0,0,  FR,  FL } 
},
+   /* 2.1 */
+{ .ca_index = 0x01,  .speakers = {   0,0,   0,   0,   0,  LFE,  FR,  FL } 
},
+   /* Dolby Surround */
+{ .ca_index = 0x02,  .speakers = {   0,0,   0,   0,  FC,0,  FR,  FL } 
},
+   /* surround40 */
+{ .ca_index = 0x08,  .speakers = {   0,0,  RR,  RL,   0,0,  FR,  FL } 
},
+   /* surround41 */
+{ .ca_index = 0x09,  .speakers = {   0,0,  RR,  RL,   0,  LFE,  FR,  FL } 
},
+   /* surround50 */
+{ .ca_index = 0x0a,  .speakers = {   0,0,  RR,  RL,  FC,0,  FR,  FL } 
},
+   /* surround51 */
+{ .ca_index = 0x0b,  .speakers = {   0,0,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* 6.1 */
+{ .ca_index = 0x0f,  .speakers = {   0,   RC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* surround71 */
+{ .ca_index = 0x13,  .speakers = { RRC,  RLC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+
+{ .ca_ind

[Intel-gfx] [PATCH V3 1/5] drm/i915: setup bridge for HDMI LPE audio driver

2017-01-09 Thread 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.

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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

diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 104296d..bd9b767 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -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
 
 
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 5196509..2bca239 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -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)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 4d22b4b..70d728b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -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();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f66eeede..cc7033a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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);
diff --git a/driver

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

2017-01-09 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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

diff --git a/sound/Kconfig b/sound/Kconfig
index 5a240e0..ee2e69a 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -108,6 +108,8 @@ source "sound/parisc/Kconfig"
 
 source "sound/soc/Kconfig"
 
+source "sound/x86/Kconfig"
+
 endif # SND
 
 menuconfig SOUND_PRIME
diff --git a/sound/Makefile b/sound/Makefile
index c41bdf5..6de45d2 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -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
diff --git a/sound/x86/Kconfig b/sound/x86/Kconfig
new file mode 100644
index 000..e9297d0
--- /dev/null
+++ b/sound/x86/Kconfig
@@ -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
diff --git a/sound/x86/Makefile b/sound/x86/Makefile
new file mode 100644
index 000..54d002d
--- /dev/null
+++ b/sound/x86/Makefile
@@ -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
diff --git a/sound/x86/intel_hdmi_lpe_audio.c b/sound/x86/intel_hdmi_lpe_audio.c
new file mode 100644
index 000..c2ebce1
--- /dev/null
+++ b/sound/x86/intel_hdmi_lpe_audio.c
@@ -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 
+ * Aravind Siddappaji 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_lpe_audio.h"
+
+/* globals*/
+struct platform_device *hlpe_pdev;
+int hlpe_state;
+union otm_hdmi_eld_t hlpe_eld;
+
+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;
+   int hdmi_audio_interrupt_mask;
+   struct work_struct hdmi_audio_wq;
+};
+
+static inline void hdmi_set_eld(void *eld)
+{
+   int size;
+
+   BUILD_BUG_ON(sizeof(hlpe_eld) > HDMI_MAX_ELD_BYTES);
+
+   size = sizeof(hlpe_eld);
+   memcpy((void *)&hlpe_eld, eld, s

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

2017-01-09 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index cc7033a..601c8ad 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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);
diff --git a/drivers/gpu/drm/i915/intel_audio.c 
b/drivers/gpu/drm/i915/intel_audio.c
index 16c2027..00a485e 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "intel_drv.h"
 
 #include 
@@ -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);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 0bcfead..377584e1 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -36,6 +36,7 @@
 #include 
 #include "intel_drv.h"
 #include 
+#include 
 #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 55be191..3b7fe8e 100644
--- a/drivers/gpu/drm/i915/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/intel_lpe_audio.c
@@ -337,3 +337,53 @@ void intel_lpe_audio_teardown(struct drm_i915_private 
*dev_priv)
 
irq_free_desc(dev_priv->lpe_audio.irq);
 }
+
+
+/**
+ * intel_lpe_audio_notify() - notify lpe audio event
+ * audio driver and i915
+ * @dev_priv: the i915 drm device private data
+ * @eld : ELD data
+ * @port: port id
+ * @tmds_clk_speed: tmds clock frequency in Hz
+ * @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)
+{
+   unsigned long irq_flags;
+   struct intel_hdmi_lpe_audio_pdata *pdata = NULL;
+
+   if (!HAS_LPE_AUDIO(dev_priv))
+   return;
+
+   pdata = dev_get_platdata(
+   &(dev_priv->lpe_audio.platdev->dev));
+
+   spin_lock_irqsave(&pdata->lpe_audio_slock, irq_flags);
+
+   if (eld != NULL) {
+   memcpy(pdata->eld.eld_data, eld,
+   HDMI_MAX_ELD_BYTES);
+   pdata->eld.port_id = port;
+   pdata->hdmi_connected = true;
+
+   if (tmds_clk_speed)
+   pdata->tmds_clock_speed = tmds_clk_speed;
+   } else {
+   memset(pdata->eld.eld_data, 0,
+   HDMI_MAX_ELD_BYTES);
+   pdata->hdmi_connected = false;
+   }
+
+   if (pdata->notify_audio_lpe)
+   pdata->notify_audio_lpe(
+   (eld != NULL) ? &pdata->eld : NULL);
+   else
+   pdata->notify_pending = true;
+
+   spin_unlock_irqrestore(&pdata->lpe_audio_slock,
+   irq_flags);
+}
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH V3 5/5] ALSA: x86: hdmi: continue playback even when display resolution changes

2017-01-09 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 5305c5c..d33be3c 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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)
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH V3 0/5] Add support for Legacy HDMI audio drivers

2017-01-09 Thread Jerome Anand
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

-- 
2.9.3

base-commit: eb5c556a1e5eff388e48e4b7cf61e95783019e83
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH V2 6/7] ALSA: x86: hdmi: Fixup some monitor

2017-01-06 Thread 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.

Signed-off-by: David Henningsson 
Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index d2036bc..91efbeb 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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;
 }
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH V2 4/7] ALSA: x86: hdmi: Add audio support for BYT and CHT

2017-01-06 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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

diff --git a/sound/x86/Makefile b/sound/x86/Makefile
index baa6333..e405280 100644
--- a/sound/x86/Makefile
+++ b/sound/x86/Makefile
@@ -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
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
new file mode 100644
index 000..d7b57658
--- /dev/null
+++ b/sound/x86/intel_hdmi_audio.c
@@ -0,0 +1,1903 @@
+/*
+ *   intel_hdmi_audio.c - Intel HDMI audio driver
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:   Sailaja Bandarupalli 
+ * Ramesh Babu K V 
+ * Vaibhav Agarwal 
+ * Jerome Anand 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ * ALSA driver for Intel HDMI audio
+ */
+
+#define pr_fmt(fmt)"had: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_audio.h"
+
+static DEFINE_MUTEX(had_mutex);
+
+/*standard module options for ALSA. This module supports only one card*/
+static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
+static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
+static struct snd_intelhad *had_data;
+
+module_param_named(index, hdmi_card_index, int, 0444);
+MODULE_PARM_DESC(index,
+   "Index value for INTEL Intel HDMI Audio controller.");
+module_param_named(id, hdmi_card_id, charp, 0444);
+MODULE_PARM_DESC(id,
+   "ID string for INTEL Intel HDMI Audio controller.");
+
+/*
+ * ELD SA bits in the CEA Speaker Allocation data block
+*/
+static int eld_speaker_allocation_bits[] = {
+   [0] = FL | FR,
+   [1] = LFE,
+   [2] = FC,
+   [3] = RL | RR,
+   [4] = RC,
+   [5] = FLC | FRC,
+   [6] = RLC | RRC,
+   /* the following are not defined in ELD yet */
+   [7] = 0,
+};
+
+/*
+ * This is an ordered list!
+ *
+ * The preceding ones have better chances to be selected by
+ * hdmi_channel_allocation().
+ */
+static struct cea_channel_speaker_allocation channel_allocations[] = {
+/*channel:   7 6543 210  */
+{ .ca_index = 0x00,  .speakers = {   0,0,   0,   0,   0,0,  FR,  FL } 
},
+   /* 2.1 */
+{ .ca_index = 0x01,  .speakers = {   0,0,   0,   0,   0,  LFE,  FR,  FL } 
},
+   /* Dolby Surround */
+{ .ca_index = 0x02,  .speakers = {   0,0,   0,   0,  FC,0,  FR,  FL } 
},
+   /* surround40 */
+{ .ca_index = 0x08,  .speakers = {   0,0,  RR,  RL,   0,0,  FR,  FL } 
},
+   /* surround41 */
+{ .ca_index = 0x09,  .speakers = {   0,0,  RR,  RL,   0,  LFE,  FR,  FL } 
},
+   /* surround50 */
+{ .ca_index = 0x0a,  .speakers = {   0,0,  RR,  RL,  FC,0,  FR,  FL } 
},
+   /* surround51 */
+{ .ca_index = 0x0b,  .speakers = {   0,0,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* 6.1 */
+{ .ca_index = 0x0f,  .speakers = {   0,   RC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* surround71 */
+{ .ca_index = 0x13,  .speakers = { RRC,  RLC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+
+{ .ca_index = 0x03,  .speakers = {   0,0,   0,   0,  FC,  LFE,  FR,  FL } 
},
+{ .ca_index = 0x04,  .speakers

[Intel-gfx] [PATCH V2 7/7] ALSA: x86: hdmi: continue playback even when display resolution changes

2017-01-06 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 91efbeb..f4042f8 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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)
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH V2 1/7] drm/i915: setup bridge for HDMI LPE audio driver

2017-01-06 Thread 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.

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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

diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 104296d..bd9b767 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -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
 
 
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 5196509..2bca239 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -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)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 4d22b4b..70d728b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -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();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 7b43662..2f8165e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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);
diff --git a/drivers/gpu/drm/i

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

2017-01-06 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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

diff --git a/sound/Kconfig b/sound/Kconfig
index 5a240e0..ee2e69a 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -108,6 +108,8 @@ source "sound/parisc/Kconfig"
 
 source "sound/soc/Kconfig"
 
+source "sound/x86/Kconfig"
+
 endif # SND
 
 menuconfig SOUND_PRIME
diff --git a/sound/Makefile b/sound/Makefile
index c41bdf5..6de45d2 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -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
diff --git a/sound/x86/Kconfig b/sound/x86/Kconfig
new file mode 100644
index 000..e9297d0
--- /dev/null
+++ b/sound/x86/Kconfig
@@ -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
diff --git a/sound/x86/Makefile b/sound/x86/Makefile
new file mode 100644
index 000..baa6333
--- /dev/null
+++ b/sound/x86/Makefile
@@ -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
diff --git a/sound/x86/intel_hdmi_lpe_audio.c b/sound/x86/intel_hdmi_lpe_audio.c
new file mode 100644
index 000..61347ab
--- /dev/null
+++ b/sound/x86/intel_hdmi_lpe_audio.c
@@ -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 
+ * Aravind Siddappaji 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ */
+
+#define pr_fmt(fmt)"hdmi_lpe_audio: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_lpe_audio.h"
+
+/* globals*/
+struct platform_device *hlpe_pdev;
+int hlpe_state;
+union otm_hdmi_eld_t hlpe_eld;
+
+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;
+   int hdmi_audio_interrupt_mask;
+   struct work_struct hdmi_audio_wq;
+};
+
+static inline void hdmi_set_eld(void *eld)
+{
+   int size;
+
+   BUILD_BUG_ON(sizeof(hlpe_eld) > HDMI_MAX_ELD_BYTES);
+
+   size = sizeof(hlpe_eld);
+   memcpy((void *)&hlpe_eld, eld, size);
+}
+
+static 

[Intel-gfx] [PATCH V2 2/7] drm/i915: Add support for audio driver notifications

2017-01-06 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2f8165e..263bc48 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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);
diff --git a/drivers/gpu/drm/i915/intel_audio.c 
b/drivers/gpu/drm/i915/intel_audio.c
index 16c2027..aeb37c2 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "intel_drv.h"
 
 #include 
@@ -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);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 0bcfead..377584e1 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -36,6 +36,7 @@
 #include 
 #include "intel_drv.h"
 #include 
+#include 
 #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
--- a/drivers/gpu/drm/i915/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/intel_lpe_audio.c
@@ -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));
+
+   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;
+   }
+   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);
+}
diff --git a/include/drm/intel_lpe_audio.h b/include/drm/intel_lpe_audio.h
index a64c449.

[Intel-gfx] [PATCH V2 0/7] Add support for Legacy HDMI audio drivers

2017-01-06 Thread Jerome Anand
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

-- 
2.9.3

base-commit: 362e5ebefe40f1f00a7075ad2e472ef44a36a7da
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH V2 5/7] ALSA: x86: hdmi: Improve position reporting

2017-01-06 Thread Jerome Anand
Use a hw register to calculate sub-period position reports.
This makes PulseAudio happier.

Signed-off-by: David Henningsson 
Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index d7b57658..d2036bc 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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;
 }
 
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 6/7] ALSA: x86: hdmi: Fixup some monitor

2016-12-11 Thread 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.

Signed-off-by: David Henningsson 
Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index d9ce750..9249521 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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;
 }
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 5/7] ALSA: x86: hdmi: Improve position reporting

2016-12-11 Thread Jerome Anand
Use a hw register to calculate sub-period position reports.
This makes PulseAudio happier.

Signed-off-by: David Henningsson 
Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 461b7d7..d9ce750 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1492,6 +1492,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"); */
 
@@ -1502,6 +1504,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,
@@ -1509,7 +1519,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;
 }
 
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 2/7] drm/i915: Add support for audio driver notifications

2016-12-11 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 1317834..0dbe91a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3696,6 +3696,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);
diff --git a/drivers/gpu/drm/i915/intel_audio.c 
b/drivers/gpu/drm/i915/intel_audio.c
index 3bbc96c..77cd086 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "intel_drv.h"
 
 #include 
@@ -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, true);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 0bcfead..377584e1 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -36,6 +36,7 @@
 #include 
 #include "intel_drv.h"
 #include 
+#include 
 #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 e12e5f7..a141a9c 100644
--- a/drivers/gpu/drm/i915/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/intel_lpe_audio.c
@@ -361,3 +361,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;
+
+   if (HAS_LPE_AUDIO(dev_priv)) {
+   struct intel_hdmi_lpe_audio_pdata *pdata = dev_get_platdata(
+   &(dev_priv->lpe_audio.platdev->dev));
+
+   spin_lock_irqsave(&pdata->lpe_audio_slock,
+   irq_flags);
+
+   if (eld != NULL) {
+   memcpy(pdata->eld.eld_data, eld,
+   HDMI_MAX_ELD_BYTES);
+   pdata->eld.port_id = port;
+
+   if (tmds_clk_speed)
+   pdata->tmds_clock_speed =
+   tmds_clk_speed;
+   }
+   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_aud

[Intel-gfx] [PATCH 7/7] ALSA: x86: hdmi: continue playback even when display resolution changes

2016-12-11 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 9249521..d6fd638 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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(hdmi_card_index, int, 0444);
 MODULE_PARM_DESC(hdmi_card_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);
 
@@ -1506,10 +1508,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)
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 3/7] ALSA: add shell for Intel HDMI LPE audio driver

2016-12-11 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/Kconfig|   2 +
 sound/Makefile   |   2 +-
 sound/x86/Kconfig|  16 +
 sound/x86/Makefile   |   8 +
 sound/x86/intel_hdmi_lpe_audio.c | 622 +++
 sound/x86/intel_hdmi_lpe_audio.h | 692 +++
 6 files changed, 1341 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

diff --git a/sound/Kconfig b/sound/Kconfig
index 5a240e0..ee2e69a 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -108,6 +108,8 @@ source "sound/parisc/Kconfig"
 
 source "sound/soc/Kconfig"
 
+source "sound/x86/Kconfig"
+
 endif # SND
 
 menuconfig SOUND_PRIME
diff --git a/sound/Makefile b/sound/Makefile
index c41bdf5..6de45d2 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -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
diff --git a/sound/x86/Kconfig b/sound/x86/Kconfig
new file mode 100644
index 000..182adf3
--- /dev/null
+++ b/sound/x86/Kconfig
@@ -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
diff --git a/sound/x86/Makefile b/sound/x86/Makefile
new file mode 100644
index 000..78b2ae1
--- /dev/null
+++ b/sound/x86/Makefile
@@ -0,0 +1,8 @@
+DRIVER_NAME := hdmi_lpe_audio
+
+ccflags-y += -Idrivers/gpu/drm/i915
+
+$(DRIVER_NAME)-objs += \
+   intel_hdmi_lpe_audio.o
+
+obj-$(CONFIG_HDMI_LPE_AUDIO) += $(DRIVER_NAME).o
diff --git a/sound/x86/intel_hdmi_lpe_audio.c b/sound/x86/intel_hdmi_lpe_audio.c
new file mode 100644
index 000..f31ab72
--- /dev/null
+++ b/sound/x86/intel_hdmi_lpe_audio.c
@@ -0,0 +1,622 @@
+/*
+ *  intel_hdmi_lpe_audio.c - Intel HDMI LPE audio driver for Atom platforms
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:
+ * Jerome Anand 
+ * Aravind Siddappaji 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ */
+
+#define pr_fmt(fmt)"hdmi_lpe_audio: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_lpe_audio.h"
+
+/* globals*/
+struct platform_device *gpdev;
+int _hdmi_state;
+union otm_hdmi_eld_t hdmi_eld;
+
+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;
+   int hdmi_audio_interrupt_mask;
+   struct work_struct hdmi_audio_wq;
+};
+
+static inline void hdmi_set_eld(void *eld)
+{
+   int size = (sizeof(hdmi_eld)) > HDMI_MAX_ELD_BYTES ?
+   HDMI_MAX_ELD_BYTES :
+   (sizeof(hdmi_eld));
+
+   

[Intel-gfx] [PATCH 4/7] ALSA: x86: hdmi: Add audio support for BYT and CHT

2016-12-11 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/Makefile   |2 +
 sound/x86/intel_hdmi_audio.c | 1907 ++
 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, 2671 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

diff --git a/sound/x86/Makefile b/sound/x86/Makefile
index 78b2ae1..bc074d0 100644
--- a/sound/x86/Makefile
+++ b/sound/x86/Makefile
@@ -3,6 +3,8 @@ DRIVER_NAME := hdmi_lpe_audio
 ccflags-y += -Idrivers/gpu/drm/i915
 
 $(DRIVER_NAME)-objs += \
+   intel_hdmi_audio.o \
+   intel_hdmi_audio_if.o \
intel_hdmi_lpe_audio.o
 
 obj-$(CONFIG_HDMI_LPE_AUDIO) += $(DRIVER_NAME).o
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
new file mode 100644
index 000..461b7d7
--- /dev/null
+++ b/sound/x86/intel_hdmi_audio.c
@@ -0,0 +1,1907 @@
+/*
+ *   intel_hdmi_audio.c - Intel HDMI audio driver
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:   Sailaja Bandarupalli 
+ * Ramesh Babu K V 
+ * Vaibhav Agarwal 
+ * Jerome Anand 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ * ALSA driver for Intel HDMI audio
+ */
+
+#define pr_fmt(fmt)"had: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_audio.h"
+
+static DEFINE_MUTEX(had_mutex);
+
+/*standard module options for ALSA. This module supports only one card*/
+static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
+static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
+static struct snd_intelhad *had_data;
+
+module_param(hdmi_card_index, int, 0444);
+MODULE_PARM_DESC(hdmi_card_index,
+   "Index value for INTEL Intel HDMI Audio controller.");
+module_param(hdmi_card_id, charp, 0444);
+MODULE_PARM_DESC(hdmi_card_id,
+   "ID string for INTEL Intel HDMI Audio controller.");
+
+/*
+ * ELD SA bits in the CEA Speaker Allocation data block
+*/
+static int eld_speaker_allocation_bits[] = {
+   [0] = FL | FR,
+   [1] = LFE,
+   [2] = FC,
+   [3] = RL | RR,
+   [4] = RC,
+   [5] = FLC | FRC,
+   [6] = RLC | RRC,
+   /* the following are not defined in ELD yet */
+   [7] = 0,
+};
+
+/*
+ * This is an ordered list!
+ *
+ * The preceding ones have better chances to be selected by
+ * hdmi_channel_allocation().
+ */
+static struct cea_channel_speaker_allocation channel_allocations[] = {
+/*channel:   7 6543 210  */
+{ .ca_index = 0x00,  .speakers = {   0,0,   0,   0,   0,0,  FR,  FL } 
},
+   /* 2.1 */
+{ .ca_index = 0x01,  .speakers = {   0,0,   0,   0,   0,  LFE,  FR,  FL } 
},
+   /* Dolby Surround */
+{ .ca_index = 0x02,  .speakers = {   0,0,   0,   0,  FC,0,  FR,  FL } 
},
+   /* surround40 */
+{ .ca_index = 0x08,  .speakers = {   0,0,  RR,  RL,   0,0,  FR,  FL } 
},
+   /* surround41 */
+{ .ca_index = 0x09,  .speakers = {   0,0,  RR,  RL,   0,  LFE,  FR,  FL } 
},
+   /* surround50 */
+{ .ca_index = 0x0a,  .speakers = {   0,0,  RR,  RL,  FC,0,  FR,  FL } 
},
+   /* surround51 */
+{ .ca_index = 0x0b,  .speakers = {   0,0,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* 6.1 */
+{ .ca_index = 0x0f,  .speakers = {   0,   RC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* surround71 */
+{ .ca_index = 0x13,  .speakers = { RRC,  RLC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+
+{ .ca_index = 0x03,  .speakers = {   0,0,   0,   0,  FC,  LFE,  FR,  FL } 
},
+{ .ca_index = 

[Intel-gfx] [PATCH 0/7] Add support for Legacy HDMI audio drivers

2016-12-11 Thread Jerome Anand
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|   27 +
 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 |  409 +++
 include/drm/intel_lpe_audio.h  |   46 +
 sound/Kconfig  |2 +
 sound/Makefile |2 +-
 sound/x86/Kconfig  |   16 +
 sound/x86/Makefile |   10 +
 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   |  626 +++
 sound/x86/intel_hdmi_lpe_audio.h   |  692 
 19 files changed, 4561 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

-- 
2.9.3

base-commit: f6a248e2507f98d7eb1f4fec8cfcbf685a33d289
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 1/7] drm/i915: setup bridge for HDMI LPE audio driver

2016-12-11 Thread 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.

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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|  27 +++
 drivers/gpu/drm/i915/i915_reg.h|   3 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 363 +
 include/drm/intel_lpe_audio.h  |  45 
 8 files changed, 471 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lpe_audio.c
 create mode 100644 include/drm/intel_lpe_audio.h

diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 3843ef6..f94a4e5 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -213,6 +213,15 @@ Video BIOS Table (VBT)
 .. kernel-doc:: drivers/gpu/drm/i915/intel_vbt_defs.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
 
 
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 3c30916..9d478c4 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -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)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 6428588..92796fd 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1132,7 +1132,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
@@ -1150,7 +1151,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();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 40c55c9..1317834 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2514,6 +2514,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.
@@ -2912,6 +2918,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
@@ -3682,6 +3690,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);
diff --git a/driver

[Intel-gfx] [RFC PATCH v4 7/7] ALSA: x86: hdmi: continue playback even when display resolution changes

2016-12-02 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 9249521..d6fd638 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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(hdmi_card_index, int, 0444);
 MODULE_PARM_DESC(hdmi_card_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);
 
@@ -1506,10 +1508,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)
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH v4 6/7] ALSA: x86: hdmi: Fixup some monitor

2016-12-02 Thread 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.

Signed-off-by: David Henningsson 
Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index d9ce750..9249521 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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;
 }
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH v4 5/7] ALSA: x86: hdmi: Improve position reporting

2016-12-02 Thread Jerome Anand
Use a hw register to calculate sub-period position reports.
This makes PulseAudio happier.

Signed-off-by: David Henningsson 
Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 461b7d7..d9ce750 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1492,6 +1492,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"); */
 
@@ -1502,6 +1504,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,
@@ -1509,7 +1519,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;
 }
 
-- 
2.9.3

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH v4 4/7] ALSA: x86: hdmi: Add audio support for BYT and CHT

2016-12-02 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/Makefile   |2 +
 sound/x86/intel_hdmi_audio.c | 1907 ++
 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, 2671 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

diff --git a/sound/x86/Makefile b/sound/x86/Makefile
index 78b2ae1..bc074d0 100644
--- a/sound/x86/Makefile
+++ b/sound/x86/Makefile
@@ -3,6 +3,8 @@ DRIVER_NAME := hdmi_lpe_audio
 ccflags-y += -Idrivers/gpu/drm/i915
 
 $(DRIVER_NAME)-objs += \
+   intel_hdmi_audio.o \
+   intel_hdmi_audio_if.o \
intel_hdmi_lpe_audio.o
 
 obj-$(CONFIG_HDMI_LPE_AUDIO) += $(DRIVER_NAME).o
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
new file mode 100644
index 000..461b7d7
--- /dev/null
+++ b/sound/x86/intel_hdmi_audio.c
@@ -0,0 +1,1907 @@
+/*
+ *   intel_hdmi_audio.c - Intel HDMI audio driver
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:   Sailaja Bandarupalli 
+ * Ramesh Babu K V 
+ * Vaibhav Agarwal 
+ * Jerome Anand 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ * ALSA driver for Intel HDMI audio
+ */
+
+#define pr_fmt(fmt)"had: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_audio.h"
+
+static DEFINE_MUTEX(had_mutex);
+
+/*standard module options for ALSA. This module supports only one card*/
+static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
+static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
+static struct snd_intelhad *had_data;
+
+module_param(hdmi_card_index, int, 0444);
+MODULE_PARM_DESC(hdmi_card_index,
+   "Index value for INTEL Intel HDMI Audio controller.");
+module_param(hdmi_card_id, charp, 0444);
+MODULE_PARM_DESC(hdmi_card_id,
+   "ID string for INTEL Intel HDMI Audio controller.");
+
+/*
+ * ELD SA bits in the CEA Speaker Allocation data block
+*/
+static int eld_speaker_allocation_bits[] = {
+   [0] = FL | FR,
+   [1] = LFE,
+   [2] = FC,
+   [3] = RL | RR,
+   [4] = RC,
+   [5] = FLC | FRC,
+   [6] = RLC | RRC,
+   /* the following are not defined in ELD yet */
+   [7] = 0,
+};
+
+/*
+ * This is an ordered list!
+ *
+ * The preceding ones have better chances to be selected by
+ * hdmi_channel_allocation().
+ */
+static struct cea_channel_speaker_allocation channel_allocations[] = {
+/*channel:   7 6543 210  */
+{ .ca_index = 0x00,  .speakers = {   0,0,   0,   0,   0,0,  FR,  FL } 
},
+   /* 2.1 */
+{ .ca_index = 0x01,  .speakers = {   0,0,   0,   0,   0,  LFE,  FR,  FL } 
},
+   /* Dolby Surround */
+{ .ca_index = 0x02,  .speakers = {   0,0,   0,   0,  FC,0,  FR,  FL } 
},
+   /* surround40 */
+{ .ca_index = 0x08,  .speakers = {   0,0,  RR,  RL,   0,0,  FR,  FL } 
},
+   /* surround41 */
+{ .ca_index = 0x09,  .speakers = {   0,0,  RR,  RL,   0,  LFE,  FR,  FL } 
},
+   /* surround50 */
+{ .ca_index = 0x0a,  .speakers = {   0,0,  RR,  RL,  FC,0,  FR,  FL } 
},
+   /* surround51 */
+{ .ca_index = 0x0b,  .speakers = {   0,0,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* 6.1 */
+{ .ca_index = 0x0f,  .speakers = {   0,   RC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* surround71 */
+{ .ca_index = 0x13,  .speakers = { RRC,  RLC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+
+{ .ca_index = 0x03,  .speakers = {   0,0,   0,   0,  FC,  LFE,  FR,  FL } 
},
+{ .ca_index = 

[Intel-gfx] [RFC PATCH v4 3/7] ALSA: add shell for Intel HDMI LPE audio driver

2016-12-02 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/Kconfig|   2 +
 sound/Makefile   |   2 +-
 sound/x86/Kconfig|  16 +
 sound/x86/Makefile   |   8 +
 sound/x86/intel_hdmi_lpe_audio.c | 622 +++
 sound/x86/intel_hdmi_lpe_audio.h | 692 +++
 6 files changed, 1341 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

diff --git a/sound/Kconfig b/sound/Kconfig
index 5a240e0..ee2e69a 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -108,6 +108,8 @@ source "sound/parisc/Kconfig"
 
 source "sound/soc/Kconfig"
 
+source "sound/x86/Kconfig"
+
 endif # SND
 
 menuconfig SOUND_PRIME
diff --git a/sound/Makefile b/sound/Makefile
index c41bdf5..6de45d2 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -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
diff --git a/sound/x86/Kconfig b/sound/x86/Kconfig
new file mode 100644
index 000..182adf3
--- /dev/null
+++ b/sound/x86/Kconfig
@@ -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
diff --git a/sound/x86/Makefile b/sound/x86/Makefile
new file mode 100644
index 000..78b2ae1
--- /dev/null
+++ b/sound/x86/Makefile
@@ -0,0 +1,8 @@
+DRIVER_NAME := hdmi_lpe_audio
+
+ccflags-y += -Idrivers/gpu/drm/i915
+
+$(DRIVER_NAME)-objs += \
+   intel_hdmi_lpe_audio.o
+
+obj-$(CONFIG_HDMI_LPE_AUDIO) += $(DRIVER_NAME).o
diff --git a/sound/x86/intel_hdmi_lpe_audio.c b/sound/x86/intel_hdmi_lpe_audio.c
new file mode 100644
index 000..f31ab72
--- /dev/null
+++ b/sound/x86/intel_hdmi_lpe_audio.c
@@ -0,0 +1,622 @@
+/*
+ *  intel_hdmi_lpe_audio.c - Intel HDMI LPE audio driver for Atom platforms
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:
+ * Jerome Anand 
+ * Aravind Siddappaji 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ */
+
+#define pr_fmt(fmt)"hdmi_lpe_audio: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_lpe_audio.h"
+
+/* globals*/
+struct platform_device *gpdev;
+int _hdmi_state;
+union otm_hdmi_eld_t hdmi_eld;
+
+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;
+   int hdmi_audio_interrupt_mask;
+   struct work_struct hdmi_audio_wq;
+};
+
+static inline void hdmi_set_eld(void *eld)
+{
+   int size = (sizeof(hdmi_eld)) > HDMI_MAX_ELD_BYTES ?
+   HDMI_MAX_ELD_BYTES :
+   (sizeof(hdmi_eld));
+
+   

[Intel-gfx] [RFC PATCH v4 2/7] drm/i915: Add support for audio driver notifications

2016-12-02 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2a79048..33bc44c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3561,6 +3561,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_device *dev);
diff --git a/drivers/gpu/drm/i915/intel_audio.c 
b/drivers/gpu/drm/i915/intel_audio.c
index 1c509f7..55a6831 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "intel_drv.h"
 
 #include 
@@ -627,6 +628,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);
 }
 
 /**
@@ -660,6 +665,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, true);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index fb88e32..02d50e3 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -36,6 +36,7 @@
 #include 
 #include "intel_drv.h"
 #include 
+#include 
 #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 e12e5f7..a141a9c 100644
--- a/drivers/gpu/drm/i915/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/intel_lpe_audio.c
@@ -361,3 +361,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;
+
+   if (HAS_LPE_AUDIO(dev_priv)) {
+   struct intel_hdmi_lpe_audio_pdata *pdata = dev_get_platdata(
+   &(dev_priv->lpe_audio.platdev->dev));
+
+   spin_lock_irqsave(&pdata->lpe_audio_slock,
+   irq_flags);
+
+   if (eld != NULL) {
+   memcpy(pdata->eld.eld_data, eld,
+   HDMI_MAX_ELD_BYTES);
+   pdata->eld.port_id = port;
+
+   if (tmds_clk_speed)
+   pdata->tmds_clock_speed =
+   tmds_clk_speed;
+   }
+   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,
+ 

[Intel-gfx] [RFC PATCH v4 1/7] drm/i915: setup bridge for HDMI LPE audio driver

2016-12-02 Thread 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.

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 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|  27 +++
 drivers/gpu/drm/i915/i915_reg.h|   3 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 363 +
 include/drm/intel_lpe_audio.h  |  45 
 8 files changed, 471 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lpe_audio.c
 create mode 100644 include/drm/intel_lpe_audio.h

diff --git a/Documentation/gpu/i915.rst b/Documentation/gpu/i915.rst
index 117d2ab..a671eee 100644
--- a/Documentation/gpu/i915.rst
+++ b/Documentation/gpu/i915.rst
@@ -213,6 +213,15 @@ Video BIOS Table (VBT)
 .. kernel-doc:: drivers/gpu/drm/i915/intel_vbt_defs.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
 
 
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 580602d..3a2369c 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -126,6 +126,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)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index b893e67..93811ed 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1144,7 +1144,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
@@ -1162,7 +1163,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();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 970e50b..2a79048 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2284,6 +2284,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.
@@ -2773,6 +2779,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
@@ -3547,6 +3555,13 @@ extern int i915_restore_state(struct drm_device *dev);
 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_device *dev);
 extern void intel_teardown_gmbus(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/driver

[Intel-gfx] [RFC PATCH v4 0/7] Add support for Legacy HDMI audio drivers

2016-12-02 Thread Jerome Anand
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|   27 +
 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 |  409 +++
 include/drm/intel_lpe_audio.h  |   46 +
 sound/Kconfig  |2 +
 sound/Makefile |2 +-
 sound/x86/Kconfig  |   16 +
 sound/x86/Makefile |   10 +
 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   |  626 +++
 sound/x86/intel_hdmi_lpe_audio.h   |  692 
 19 files changed, 4561 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

-- 
2.9.3

base-commit: b34f27e00c9a21d2078062da760e24fd4a620391
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH v2 4/8] drm/i915: Add support for enabling/disabling hdmi audio interrupts

2016-10-12 Thread Jerome Anand
API definitions for enabling/disabling hdmi audio interrupts in
different hdmi pipes are implemented.

Signed-off-by: Jerome Anand 
---
 drivers/gpu/drm/i915/i915_irq.c  | 69 
 drivers/gpu/drm/i915/intel_drv.h |  2 ++
 2 files changed, 71 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index d8f515f..1e3663f 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -2867,6 +2867,67 @@ static void gen8_disable_vblank(struct drm_device *dev, 
unsigned int pipe)
spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
 }
 
+/* Added for HDMI Audio */
+int i915_enable_hdmi_audio_int(struct drm_i915_private *dev_priv)
+{
+   unsigned long irqflags;
+   u32 imr, int_bit;
+   int pipe = -1;
+
+   spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
+
+   imr = I915_READ(VLV_IMR);
+
+   if (IS_CHERRYVIEW(&dev_priv->drm)) {
+   pipe = PIPE_C;
+   int_bit = (pipe ? (I915_LPE_PIPE_B_INTERRUPT >>
+   ((pipe - 1) * 9)) :
+   I915_LPE_PIPE_A_INTERRUPT);
+   imr &= ~int_bit;
+   } else {
+   /* Audio is on Stream A but uses HDMI PIPE B */
+   pipe = PIPE_B;
+   imr &= ~I915_LPE_PIPE_B_INTERRUPT;
+   }
+
+   I915_WRITE(VLV_IMR, imr);
+   I915_WRITE(VLV_IER, ~imr);
+   POSTING_READ(VLV_IER);
+   spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
+
+   return 0;
+}
+
+/* Added for HDMI Audio */
+int i915_disable_hdmi_audio_int(struct drm_i915_private *dev_priv)
+{
+   unsigned long irqflags;
+   u32 imr, int_bit;
+   int pipe = -1;
+
+   spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
+   imr = I915_READ(VLV_IMR);
+
+   if (IS_CHERRYVIEW(&dev_priv->drm)) {
+   pipe = PIPE_C;
+   int_bit = (pipe ? (I915_LPE_PIPE_B_INTERRUPT >>
+   ((pipe - 1) * 9)) :
+   I915_LPE_PIPE_A_INTERRUPT);
+   imr |= int_bit;
+   } else {
+   pipe = PIPE_B;
+   imr |= I915_LPE_PIPE_B_INTERRUPT;
+   }
+
+   I915_WRITE(VLV_IER, ~imr);
+   I915_WRITE(VLV_IMR, imr);
+   POSTING_READ(VLV_IMR);
+
+   spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
+
+   return 0;
+}
+
 static bool
 ipehr_is_semaphore_wait(struct intel_engine_cs *engine, u32 ipehr)
 {
@@ -3364,6 +3425,14 @@ static void vlv_display_irq_postinstall(struct 
drm_i915_private *dev_priv)
 
WARN_ON(dev_priv->irq_mask != ~0);
 
+   if (IS_LPE_AUDIO_ENABLED(dev_priv)) {
+   u32 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/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 30e3f49..e6504ea 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1116,6 +1116,8 @@ void gen6_disable_rps_interrupts(struct drm_i915_private 
*dev_priv);
 u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask);
 void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
 void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
+int i915_enable_hdmi_audio_int(struct drm_i915_private *dev_priv);
+int i915_disable_hdmi_audio_int(struct drm_i915_private *dev_priv);
 static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
 {
/*
-- 
2.9.3
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH v2 2/8] ALSA: add shell for Intel HDMI LPE audio driver

2016-10-12 Thread 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

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/Kconfig|   2 +
 sound/Makefile   |   2 +-
 sound/x86/Kconfig|  16 +
 sound/x86/Makefile   |   8 +
 sound/x86/intel_hdmi_lpe_audio.c | 622 +++
 sound/x86/intel_hdmi_lpe_audio.h | 692 +++
 6 files changed, 1341 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

diff --git a/sound/Kconfig b/sound/Kconfig
index 5a240e0..ee2e69a 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -108,6 +108,8 @@ source "sound/parisc/Kconfig"
 
 source "sound/soc/Kconfig"
 
+source "sound/x86/Kconfig"
+
 endif # SND
 
 menuconfig SOUND_PRIME
diff --git a/sound/Makefile b/sound/Makefile
index c41bdf5..6de45d2 100644
--- a/sound/Makefile
+++ b/sound/Makefile
@@ -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
diff --git a/sound/x86/Kconfig b/sound/x86/Kconfig
new file mode 100644
index 000..182adf3
--- /dev/null
+++ b/sound/x86/Kconfig
@@ -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
diff --git a/sound/x86/Makefile b/sound/x86/Makefile
new file mode 100644
index 000..78b2ae1
--- /dev/null
+++ b/sound/x86/Makefile
@@ -0,0 +1,8 @@
+DRIVER_NAME := hdmi_lpe_audio
+
+ccflags-y += -Idrivers/gpu/drm/i915
+
+$(DRIVER_NAME)-objs += \
+   intel_hdmi_lpe_audio.o
+
+obj-$(CONFIG_HDMI_LPE_AUDIO) += $(DRIVER_NAME).o
diff --git a/sound/x86/intel_hdmi_lpe_audio.c b/sound/x86/intel_hdmi_lpe_audio.c
new file mode 100644
index 000..f31ab72
--- /dev/null
+++ b/sound/x86/intel_hdmi_lpe_audio.c
@@ -0,0 +1,622 @@
+/*
+ *  intel_hdmi_lpe_audio.c - Intel HDMI LPE audio driver for Atom platforms
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:
+ * Jerome Anand 
+ * Aravind Siddappaji 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ */
+
+#define pr_fmt(fmt)"hdmi_lpe_audio: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_lpe_audio.h"
+
+/* globals*/
+struct platform_device *gpdev;
+int _hdmi_state;
+union otm_hdmi_eld_t hdmi_eld;
+
+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;
+   int hdmi_audio_interrupt_mask;
+   struct work_struct hdmi_audio_wq;
+};
+
+static inline void hdmi_set_eld(void *eld)
+{
+   int size = (sizeof(hdmi_eld)) > HDMI_MAX_ELD_BYTES ?
+   HDMI_MAX_ELD_BYTES :
+   (sizeof(hdmi_eld));
+
+   

[Intel-gfx] [RFC PATCH v2 8/8] hdmi_audio: continue audio playback even when display resolution changes

2016-10-12 Thread 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

Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 7fd90ff..8415a32 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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(hdmi_card_index, int, 0444);
 MODULE_PARM_DESC(hdmi_card_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);
 
@@ -1505,10 +1507,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)
-- 
2.9.3
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH v2 1/8] drm/i915: setup bridge for HDMI LPE audio driver

2016-10-12 Thread 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.

Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 drivers/gpu/drm/i915/Makefile  |   3 +
 drivers/gpu/drm/i915/i915_drv.c|  13 +-
 drivers/gpu/drm/i915/i915_drv.h|  19 ++
 drivers/gpu/drm/i915/i915_irq.c|  14 ++
 drivers/gpu/drm/i915/i915_reg.h|   3 +
 drivers/gpu/drm/i915/intel_lpe_audio.c | 357 +
 include/drm/intel_lpe_audio.h  |  45 +
 7 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

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index e6fe004..11f9741 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -115,6 +115,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)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 31b2b63..ab1e4768 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1141,7 +1141,13 @@ 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_detect(dev_priv)) {
+   if (intel_lpe_audio_setup(dev_priv) < 0)
+   DRM_ERROR("failed to setup LPE Audio bridge\n");
+   }
+
+   if (!IS_LPE_AUDIO_ENABLED(dev_priv))
+   i915_audio_component_init(dev_priv);
 
/*
 * Some ports require correctly set-up hpd registers for detection to
@@ -1159,7 +1165,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 (IS_LPE_AUDIO_ENABLED(dev_priv))
+   intel_lpe_audio_teardown(dev_priv);
+   else
+   i915_audio_component_cleanup(dev_priv);
 
intel_gpu_ips_teardown();
acpi_video_unregister();
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 91ff3d7..399a8ee 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2087,6 +2087,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.
@@ -2827,6 +2833,13 @@ struct drm_i915_cmd_table {
 
 #define HAS_POOLED_EU(dev) (INTEL_INFO(dev)->has_pooled_eu)
 
+#define HAS_LPE_AUDIO(dev) (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
+#define IS_LPE_AUDIO_ENABLED(dev_priv) \
+   (__I915__(dev_priv)->lpe_audio.platdev != NULL)
+#define IS_LPE_AUDIO_IRQ_VALID(dev_priv) \
+   (__I915__(dev_priv)->lpe_audio.irq >= 0)
+
+
 #define INTEL_PCH_DEVICE_ID_MASK   0xff00
 #define INTEL_PCH_IBX_DEVICE_ID_TYPE   0x3b00
 #define INTEL_PCH_CPT_DEVICE_ID_TYPE   0x1c00
@@ -3579,6 +3592,12 @@ extern int i915_restore_state(struct drm_device *dev);
 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_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);
+int intel_lpe_audio_detect(struct drm_i915_private *dev_priv);
+
 /* intel_i2c.c */
 extern int intel_setup_gmbus(struct drm_device *dev);
 extern void intel_teardown_gmbus(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 6ed5b24..d8f515f 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1827,6 +1827,13 @@ static irqreturn_t valleyview_irq_handler(int irq, void 
*arg)
 * signalled in iir */
valleyview_pipestat_irq

[Intel-gfx] [RFC PATCH v2 7/8] hdmi_audio: Fixup some monitor

2016-10-12 Thread Jerome Anand
I think this change was given to us, and they claimed it fixed an issue
on some monitor brand. I'm not sure what this patch actually does.

Signed-off-by: David Henningsson 
Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 0802b29..7fd90ff 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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;
 }
-- 
2.9.3
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH v2 3/8] ALSA: Add support for hdmi audio driver

2016-10-12 Thread 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

Signed-off-by: Jerome Anand 
---
 sound/x86/Makefile   |2 +
 sound/x86/intel_hdmi_audio.c | 1904 ++
 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, 2668 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

diff --git a/sound/x86/Makefile b/sound/x86/Makefile
index 78b2ae1..bc074d0 100644
--- a/sound/x86/Makefile
+++ b/sound/x86/Makefile
@@ -3,6 +3,8 @@ DRIVER_NAME := hdmi_lpe_audio
 ccflags-y += -Idrivers/gpu/drm/i915
 
 $(DRIVER_NAME)-objs += \
+   intel_hdmi_audio.o \
+   intel_hdmi_audio_if.o \
intel_hdmi_lpe_audio.o
 
 obj-$(CONFIG_HDMI_LPE_AUDIO) += $(DRIVER_NAME).o
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
new file mode 100644
index 000..2dc0881
--- /dev/null
+++ b/sound/x86/intel_hdmi_audio.c
@@ -0,0 +1,1904 @@
+/*
+ *   intel_hdmi_audio.c - Intel HDMI audio driver
+ *
+ *  Copyright (C) 2016 Intel Corp
+ *  Authors:   Sailaja Bandarupalli 
+ * Ramesh Babu K V 
+ * Vaibhav Agarwal 
+ * Jerome Anand 
+ *  ~~
+ *
+ *  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.
+ *
+ * ~~
+ * ALSA driver for Intel HDMI audio
+ */
+
+#define pr_fmt(fmt)"had: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "intel_hdmi_audio.h"
+
+static DEFINE_MUTEX(had_mutex);
+
+/*standard module options for ALSA. This module supports only one card*/
+static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
+static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
+static struct snd_intelhad *had_data;
+
+module_param(hdmi_card_index, int, 0444);
+MODULE_PARM_DESC(hdmi_card_index,
+   "Index value for INTEL Intel HDMI Audio controller.");
+module_param(hdmi_card_id, charp, 0444);
+MODULE_PARM_DESC(hdmi_card_id,
+   "ID string for INTEL Intel HDMI Audio controller.");
+
+/*
+ * ELD SA bits in the CEA Speaker Allocation data block
+*/
+static int eld_speaker_allocation_bits[] = {
+   [0] = FL | FR,
+   [1] = LFE,
+   [2] = FC,
+   [3] = RL | RR,
+   [4] = RC,
+   [5] = FLC | FRC,
+   [6] = RLC | RRC,
+   /* the following are not defined in ELD yet */
+   [7] = 0,
+};
+
+/*
+ * This is an ordered list!
+ *
+ * The preceding ones have better chances to be selected by
+ * hdmi_channel_allocation().
+ */
+static struct cea_channel_speaker_allocation channel_allocations[] = {
+/*channel:   7 6543 210  */
+{ .ca_index = 0x00,  .speakers = {   0,0,   0,   0,   0,0,  FR,  FL } 
},
+   /* 2.1 */
+{ .ca_index = 0x01,  .speakers = {   0,0,   0,   0,   0,  LFE,  FR,  FL } 
},
+   /* Dolby Surround */
+{ .ca_index = 0x02,  .speakers = {   0,0,   0,   0,  FC,0,  FR,  FL } 
},
+   /* surround40 */
+{ .ca_index = 0x08,  .speakers = {   0,0,  RR,  RL,   0,0,  FR,  FL } 
},
+   /* surround41 */
+{ .ca_index = 0x09,  .speakers = {   0,0,  RR,  RL,   0,  LFE,  FR,  FL } 
},
+   /* surround50 */
+{ .ca_index = 0x0a,  .speakers = {   0,0,  RR,  RL,  FC,0,  FR,  FL } 
},
+   /* surround51 */
+{ .ca_index = 0x0b,  .speakers = {   0,0,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* 6.1 */
+{ .ca_index = 0x0f,  .speakers = {   0,   RC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+   /* surround71 */
+{ .ca_index = 0x13,  .speakers = { RRC,  RLC,  RR,  RL,  FC,  LFE,  FR,  FL } 
},
+
+{ .ca_index = 0x03,  .speakers = {   0,0,   0,   0,  FC,  LFE,  FR,  FL } 
},
+{ .ca_index = 0x04,  .speakers = { 

[Intel-gfx] [RFC PATCH v2 5/8] drm/i915: Add support for audio driver notifications

2016-10-12 Thread 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

Signed-off-by: Jerome Anand 
---
 drivers/gpu/drm/i915/i915_drv.h|  3 +++
 drivers/gpu/drm/i915/intel_audio.c |  8 ++
 drivers/gpu/drm/i915/intel_hdmi.c  | 18 -
 drivers/gpu/drm/i915/intel_lpe_audio.c | 49 ++
 include/drm/intel_lpe_audio.h  |  1 +
 5 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 399a8ee..51a6d71 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3597,6 +3597,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);
 int 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_device *dev);
diff --git a/drivers/gpu/drm/i915/intel_audio.c 
b/drivers/gpu/drm/i915/intel_audio.c
index 9583f43..61a9a98 100644
--- a/drivers/gpu/drm/i915/intel_audio.c
+++ b/drivers/gpu/drm/i915/intel_audio.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "intel_drv.h"
 
 #include 
@@ -528,6 +529,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 (IS_LPE_AUDIO_ENABLED(dev_priv))
+   intel_lpe_audio_notify(dev_priv, connector->eld, port,
+   crtc->config->port_clock, true);
 }
 
 /**
@@ -561,6 +566,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 (IS_LPE_AUDIO_ENABLED(dev_priv))
+   intel_lpe_audio_notify(dev_priv, NULL, port, 0, true);
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 8d46f58..0e20788 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -36,6 +36,7 @@
 #include 
 #include "intel_drv.h"
 #include 
+#include 
 #include "i915_drv.h"
 
 static struct drm_device *intel_hdmi_to_dev(struct intel_hdmi *intel_hdmi)
@@ -1501,9 +1502,24 @@ intel_hdmi_detect(struct drm_connector *connector, bool 
force)
 
hdmi_to_dig_port(intel_hdmi)->base.type = INTEL_OUTPUT_HDMI;
status = connector_status_connected;
-   } else
+
+   i915_enable_hdmi_audio_int(dev_priv);
+
+   if (IS_LPE_AUDIO_ENABLED(dev_priv))
+   intel_lpe_audio_notify(dev_priv,
+   connector->eld, 0,
+   0, true);
+   } else {
status = connector_status_disconnected;
 
+   i915_disable_hdmi_audio_int(dev_priv);
+
+   if (IS_LPE_AUDIO_ENABLED(dev_priv))
+   intel_lpe_audio_notify(dev_priv,
+   NULL, 0,
+   0, false);
+   }
+
intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
 
return status;
diff --git a/drivers/gpu/drm/i915/intel_lpe_audio.c 
b/drivers/gpu/drm/i915/intel_lpe_audio.c
index acfe22f..28266e4 100644
--- a/drivers/gpu/drm/i915/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/intel_lpe_audio.c
@@ -355,3 +355,52 @@ 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;
+
+   if (IS_LPE_AUDIO_ENABLED(dev_priv)) {
+   struct intel_hdmi_lpe_au

[Intel-gfx] [RFC PATCH v2 6/8] hdmi_audio: Improve position reporting Using a hw register to calculate sub-period position reports.

2016-10-12 Thread Jerome Anand
This makes PulseAudio happier.

Signed-off-by: David Henningsson 
Signed-off-by: Pierre-Louis Bossart 
Signed-off-by: Jerome Anand 
---
 sound/x86/intel_hdmi_audio.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 2dc0881..0802b29 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1491,6 +1491,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"); */
 
@@ -1501,6 +1503,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,
@@ -1508,7 +1518,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;
 }
 
-- 
2.9.3
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [RFC PATCH v2 0/8] Add support for Legacy Hdmi audio

2016-10-12 Thread Jerome Anand
Legacy Hdmi audio drivers are added.
Added support for audio/ gfx interface using irq chip framework

Jerome Anand (8):
  drm/i915: setup bridge for HDMI LPE audio driver
  ALSA: add shell for Intel HDMI LPE audio driver
  ALSA: Add support for hdmi audio driver
  drm/i915: Add support for enabling/disabling hdmi audio interrupts
  drm/i915: Add support for audio driver notifications
  hdmi_audio: Improve position reporting Using a hw register to
calculate sub-period position reports.
  hdmi_audio: Fixup some monitor
  hdmi_audio: continue audio playback even when display resolution
changes

 drivers/gpu/drm/i915/Makefile  |3 +
 drivers/gpu/drm/i915/i915_drv.c|   13 +-
 drivers/gpu/drm/i915/i915_drv.h|   22 +
 drivers/gpu/drm/i915/i915_irq.c|   83 ++
 drivers/gpu/drm/i915/i915_reg.h|3 +
 drivers/gpu/drm/i915/intel_audio.c |8 +
 drivers/gpu/drm/i915/intel_drv.h   |2 +
 drivers/gpu/drm/i915/intel_hdmi.c  |   18 +-
 drivers/gpu/drm/i915/intel_lpe_audio.c |  406 +++
 include/drm/intel_lpe_audio.h  |   46 +
 sound/Kconfig  |2 +
 sound/Makefile |2 +-
 sound/x86/Kconfig  |   16 +
 sound/x86/Makefile |   10 +
 sound/x86/intel_hdmi_audio.c   | 1929 
 sound/x86/intel_hdmi_audio.h   |  201 
 sound/x86/intel_hdmi_audio_if.c|  551 +
 sound/x86/intel_hdmi_lpe_audio.c   |  626 +++
 sound/x86/intel_hdmi_lpe_audio.h   |  692 
 19 files changed, 4629 insertions(+), 4 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

-- 
2.9.3

base-commit: 2fbc239494fa3883e164cc89d35f54d22f0c9e1f
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx