[Intel-gfx] [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDA

2013-05-20 Thread Wang Xingchao
For Intel Haswell chip, HDA controller and codec have
power well dependency from GPU side. This patch added support
to request/release power well in audio driver. Power save
feature should be enabled to get runtime power saving.

Signed-off-by: Wang Xingchao 
---
 sound/pci/hda/Kconfig |   10 ++
 sound/pci/hda/Makefile|3 ++
 sound/pci/hda/hda_i915.c  |   75 +
 sound/pci/hda/hda_i915.h  |   35 +
 sound/pci/hda/hda_intel.c |   41 +++--
 5 files changed, 161 insertions(+), 3 deletions(-)
 create mode 100644 sound/pci/hda/hda_i915.c
 create mode 100644 sound/pci/hda/hda_i915.h

diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
index 80a7d44..c5a872c 100644
--- a/sound/pci/hda/Kconfig
+++ b/sound/pci/hda/Kconfig
@@ -152,6 +152,16 @@ config SND_HDA_CODEC_HDMI
  snd-hda-codec-hdmi.
  This module is automatically loaded at probing.
 
+config SND_HDA_I915
+   bool "Build Display HD-audio controller/codec power well support for 
i915 cards"
+   depends on DRM_I915
+   help
+ Say Y here to include full HDMI and DisplayPort HD-audio 
controller/codec
+ power-well support for Intel Haswell graphics cards based on the i915 
driver.
+
+ Note that this option must be enabled for Intel Haswell C+ stepping 
machines, otherwise
+ the GPU audio controller/codecs will not be initialized or damaged 
when exit from S3 mode.
+
 config SND_HDA_CODEC_CIRRUS
bool "Build Cirrus Logic codec support"
default y
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 24a2514..4b0a4bc 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -6,6 +6,9 @@ snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
 snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
 snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
 
+# for haswell power well
+snd-hda-intel-$(CONFIG_SND_HDA_I915) +=hda_i915.o
+
 # for trace-points
 CFLAGS_hda_codec.o := -I$(src)
 CFLAGS_hda_intel.o := -I$(src)
diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
new file mode 100644
index 000..76c13d5
--- /dev/null
+++ b/sound/pci/hda/hda_i915.c
@@ -0,0 +1,75 @@
+/*
+ *  hda_i915.c - routines for Haswell HDA controller power well support
+ *
+ *  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; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  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.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "hda_i915.h"
+
+static void (*get_power)(void);
+static void (*put_power)(void);
+
+void hda_display_power(bool enable)
+{
+   if (!get_power || !put_power)
+   return;
+
+   snd_printdd("HDA display power %s \n",
+   enable ? "Enable" : "Disable");
+   if (enable)
+   get_power();
+   else
+   put_power();
+}
+
+int hda_i915_init(void)
+{
+   int err = 0;
+
+   get_power = symbol_request(i915_request_power_well);
+   if (!get_power) {
+   snd_printk(KERN_WARNING "hda-i915: get_power symbol get 
fail\n");
+   return -ENODEV;
+   }
+
+   put_power = symbol_request(i915_release_power_well);
+   if (!put_power) {
+   symbol_put(i915_request_power_well);
+   get_power = NULL;
+   return -ENODEV;
+   }
+
+   snd_printd("HDA driver get symbol successfully from i915 module\n");
+
+   return err;
+}
+
+int hda_i915_exit(void)
+{
+   if (get_power) {
+   symbol_put(i915_request_power_well);
+   get_power = NULL;
+   }
+   if (put_power) {
+   symbol_put(i915_release_power_well);
+   put_power = NULL;
+   }
+
+   return 0;
+}
diff --git a/sound/pci/hda/hda_i915.h b/sound/pci/hda/hda_i915.h
new file mode 100644
index 000..5a63da2
--- /dev/null
+++ b/sound/pci/hda/hda_i915.h
@@ -0,0 +1,35 @@
+/*
+ *  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; either version 2 of the License, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or

Re: [Intel-gfx] [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDA

2013-05-21 Thread Takashi Iwai
At Mon, 20 May 2013 19:26:58 +0800,
Wang Xingchao wrote:
> 
> For Intel Haswell chip, HDA controller and codec have
> power well dependency from GPU side. This patch added support
> to request/release power well in audio driver. Power save
> feature should be enabled to get runtime power saving.
> 
> Signed-off-by: Wang Xingchao 
> ---
>  sound/pci/hda/Kconfig |   10 ++
>  sound/pci/hda/Makefile|3 ++
>  sound/pci/hda/hda_i915.c  |   75 
> +
>  sound/pci/hda/hda_i915.h  |   35 +
>  sound/pci/hda/hda_intel.c |   41 +++--
>  5 files changed, 161 insertions(+), 3 deletions(-)
>  create mode 100644 sound/pci/hda/hda_i915.c
>  create mode 100644 sound/pci/hda/hda_i915.h
> 
> diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
> index 80a7d44..c5a872c 100644
> --- a/sound/pci/hda/Kconfig
> +++ b/sound/pci/hda/Kconfig
> @@ -152,6 +152,16 @@ config SND_HDA_CODEC_HDMI
> snd-hda-codec-hdmi.
> This module is automatically loaded at probing.
>  
> +config SND_HDA_I915
> + bool "Build Display HD-audio controller/codec power well support for 
> i915 cards"
> + depends on DRM_I915
> + help
> +   Say Y here to include full HDMI and DisplayPort HD-audio 
> controller/codec
> +   power-well support for Intel Haswell graphics cards based on the i915 
> driver.
> +
> +   Note that this option must be enabled for Intel Haswell C+ stepping 
> machines, otherwise
> +   the GPU audio controller/codecs will not be initialized or damaged 
> when exit from S3 mode.
> +
>  config SND_HDA_CODEC_CIRRUS
>   bool "Build Cirrus Logic codec support"
>   default y
> diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
> index 24a2514..4b0a4bc 100644
> --- a/sound/pci/hda/Makefile
> +++ b/sound/pci/hda/Makefile
> @@ -6,6 +6,9 @@ snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
>  snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
>  snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
>  
> +# for haswell power well
> +snd-hda-intel-$(CONFIG_SND_HDA_I915) +=  hda_i915.o
> +
>  # for trace-points
>  CFLAGS_hda_codec.o := -I$(src)
>  CFLAGS_hda_intel.o := -I$(src)
> diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
> new file mode 100644
> index 000..76c13d5
> --- /dev/null
> +++ b/sound/pci/hda/hda_i915.c
> @@ -0,0 +1,75 @@
> +/*
> + *  hda_i915.c - routines for Haswell HDA controller power well support
> + *
> + *  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; either version 2 of the License, or (at your option)
> + *  any later version.
> + *
> + *  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.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software Foundation,
> + *  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "hda_i915.h"
> +
> +static void (*get_power)(void);
> +static void (*put_power)(void);
> +
> +void hda_display_power(bool enable)
> +{
> + if (!get_power || !put_power)
> + return;
> +
> + snd_printdd("HDA display power %s \n",
> + enable ? "Enable" : "Disable");
> + if (enable)
> + get_power();
> + else
> + put_power();
> +}
> +
> +int hda_i915_init(void)
> +{
> + int err = 0;
> +
> + get_power = symbol_request(i915_request_power_well);
> + if (!get_power) {
> + snd_printk(KERN_WARNING "hda-i915: get_power symbol get 
> fail\n");
> + return -ENODEV;
> + }
> +
> + put_power = symbol_request(i915_release_power_well);
> + if (!put_power) {
> + symbol_put(i915_request_power_well);
> + get_power = NULL;
> + return -ENODEV;
> + }
> +
> + snd_printd("HDA driver get symbol successfully from i915 module\n");
> +
> + return err;
> +}
> +
> +int hda_i915_exit(void)
> +{
> + if (get_power) {
> + symbol_put(i915_request_power_well);
> + get_power = NULL;
> + }
> + if (put_power) {
> + symbol_put(i915_release_power_well);
> + put_power = NULL;
> + }
> +
> + return 0;
> +}
> diff --git a/sound/pci/hda/hda_i915.h b/sound/pci/hda/hda_i915.h
> new file mode 100644
> index 000..5a63da2
> --- /dev/null
> +++ b/sound/pci/hda/hda_i915.h
> @@ -0,0 +1,35 @@
> +/*
> + *  This program is free software; you can redistribute it and/or modify it
> + *  under the terms of the GNU General Public License as publish

Re: [Intel-gfx] [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDA

2013-05-21 Thread Wang, Xingchao

> -Original Message-
> From: Takashi Iwai [mailto:ti...@suse.de]
> Sent: Tuesday, May 21, 2013 3:19 PM
> To: Wang Xingchao
> Cc: dan...@ffwll.ch; Girdwood, Liam R; david.hennings...@canonical.com; Lin,
> Mengdong; Li, Jocelyn; alsa-de...@alsa-project.org;
> intel-gfx@lists.freedesktop.org; Barnes, Jesse; Zanoni, Paulo R; Wang,
> Xingchao
> Subject: Re: [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell
> HDA
> 
> At Mon, 20 May 2013 19:26:58 +0800,
> Wang Xingchao wrote:
> >
> > For Intel Haswell chip, HDA controller and codec have power well
> > dependency from GPU side. This patch added support to request/release
> > power well in audio driver. Power save feature should be enabled to
> > get runtime power saving.
> >
> > Signed-off-by: Wang Xingchao 
> > ---
> >  sound/pci/hda/Kconfig |   10 ++
> >  sound/pci/hda/Makefile|3 ++
> >  sound/pci/hda/hda_i915.c  |   75
> +
> >  sound/pci/hda/hda_i915.h  |   35 +
> >  sound/pci/hda/hda_intel.c |   41 +++--
> >  5 files changed, 161 insertions(+), 3 deletions(-)  create mode
> > 100644 sound/pci/hda/hda_i915.c  create mode 100644
> > sound/pci/hda/hda_i915.h
> >
> > diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index
> > 80a7d44..c5a872c 100644
> > --- a/sound/pci/hda/Kconfig
> > +++ b/sound/pci/hda/Kconfig
> > @@ -152,6 +152,16 @@ config SND_HDA_CODEC_HDMI
> >   snd-hda-codec-hdmi.
> >   This module is automatically loaded at probing.
> >
> > +config SND_HDA_I915
> > +   bool "Build Display HD-audio controller/codec power well support for 
> > i915
> cards"
> > +   depends on DRM_I915
> > +   help
> > + Say Y here to include full HDMI and DisplayPort HD-audio
> controller/codec
> > + power-well support for Intel Haswell graphics cards based on the i915
> driver.
> > +
> > + Note that this option must be enabled for Intel Haswell C+ stepping
> machines, otherwise
> > + the GPU audio controller/codecs will not be initialized or damaged 
> > when
> exit from S3 mode.
> > +
> >  config SND_HDA_CODEC_CIRRUS
> > bool "Build Cirrus Logic codec support"
> > default y
> > diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index
> > 24a2514..4b0a4bc 100644
> > --- a/sound/pci/hda/Makefile
> > +++ b/sound/pci/hda/Makefile
> > @@ -6,6 +6,9 @@ snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
> >  snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
> >  snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
> >
> > +# for haswell power well
> > +snd-hda-intel-$(CONFIG_SND_HDA_I915) +=hda_i915.o
> > +
> >  # for trace-points
> >  CFLAGS_hda_codec.o := -I$(src)
> >  CFLAGS_hda_intel.o := -I$(src)
> > diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c new
> > file mode 100644 index 000..76c13d5
> > --- /dev/null
> > +++ b/sound/pci/hda/hda_i915.c
> > @@ -0,0 +1,75 @@
> > +/*
> > + *  hda_i915.c - routines for Haswell HDA controller power well
> > +support
> > + *
> > + *  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; either version 2 of the License, or (at your
> > +option)
> > + *  any later version.
> > + *
> > + *  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.
> > + *
> > + *  You should have received a copy of the GNU General Public License
> > + *  along with this program; if not, write to the Free Software
> > +Foundation,
> > + *  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include "hda_i915.h"
> > +
> > +static void (*get_power)(void);
> > +static void (*put_power)(void);
> > +
> > +void hda_display_power(bool enable)
> > +{
> > +   if (!get_power || !put_power)
> > +   return;
> > +
> > +   snd_printdd("HDA display power %s \n",
> > +   enable ? "Enable" : "Disable");
> > +   if (enable)
> > +   get_power();
> > +   else
> > +   put_power();
> > +}
> > +
> > +int hda_i915_init(void)
> > +{
> > +   int err = 0;
> > +
> > +   get_power = symbol_request(i915_request_power_well);
> > +   if (!get_power) {
> > +   snd_printk(KERN_WARNING "hda-i915: get_power symbol get
> fail\n");
> > +   return -ENODEV;
> > +   }
> > +
> > +   put_power = symbol_request(i915_release_power_well);
> > +   if (!put_power) {
> > +   symbol_put(i915_request_power_well);
> > +   get_power = NULL;
> > +   return -ENODEV;
> > +   }
> > +
> > +   snd_printd("HDA driver get symbol successfully from i915 module\n");
> > +
> > +   return err;
> > +}
> > +

Re: [Intel-gfx] [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell HDA

2013-05-21 Thread Takashi Iwai
At Tue, 21 May 2013 10:58:36 +,
Wang, Xingchao wrote:
> 
> 
> > -Original Message-
> > From: Takashi Iwai [mailto:ti...@suse.de]
> > Sent: Tuesday, May 21, 2013 3:19 PM
> > To: Wang Xingchao
> > Cc: dan...@ffwll.ch; Girdwood, Liam R; david.hennings...@canonical.com; Lin,
> > Mengdong; Li, Jocelyn; alsa-de...@alsa-project.org;
> > intel-gfx@lists.freedesktop.org; Barnes, Jesse; Zanoni, Paulo R; Wang,
> > Xingchao
> > Subject: Re: [PATCH 2/2 V4] ALSA: hda - Add power-welll support for haswell
> > HDA
> > 
> > At Mon, 20 May 2013 19:26:58 +0800,
> > Wang Xingchao wrote:
> > >
> > > For Intel Haswell chip, HDA controller and codec have power well
> > > dependency from GPU side. This patch added support to request/release
> > > power well in audio driver. Power save feature should be enabled to
> > > get runtime power saving.
> > >
> > > Signed-off-by: Wang Xingchao 
> > > ---
> > >  sound/pci/hda/Kconfig |   10 ++
> > >  sound/pci/hda/Makefile|3 ++
> > >  sound/pci/hda/hda_i915.c  |   75
> > +
> > >  sound/pci/hda/hda_i915.h  |   35 +
> > >  sound/pci/hda/hda_intel.c |   41 +++--
> > >  5 files changed, 161 insertions(+), 3 deletions(-)  create mode
> > > 100644 sound/pci/hda/hda_i915.c  create mode 100644
> > > sound/pci/hda/hda_i915.h
> > >
> > > diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index
> > > 80a7d44..c5a872c 100644
> > > --- a/sound/pci/hda/Kconfig
> > > +++ b/sound/pci/hda/Kconfig
> > > @@ -152,6 +152,16 @@ config SND_HDA_CODEC_HDMI
> > > snd-hda-codec-hdmi.
> > > This module is automatically loaded at probing.
> > >
> > > +config SND_HDA_I915
> > > + bool "Build Display HD-audio controller/codec power well support for 
> > > i915
> > cards"
> > > + depends on DRM_I915
> > > + help
> > > +   Say Y here to include full HDMI and DisplayPort HD-audio
> > controller/codec
> > > +   power-well support for Intel Haswell graphics cards based on the i915
> > driver.
> > > +
> > > +   Note that this option must be enabled for Intel Haswell C+ stepping
> > machines, otherwise
> > > +   the GPU audio controller/codecs will not be initialized or damaged 
> > > when
> > exit from S3 mode.
> > > +
> > >  config SND_HDA_CODEC_CIRRUS
> > >   bool "Build Cirrus Logic codec support"
> > >   default y
> > > diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index
> > > 24a2514..4b0a4bc 100644
> > > --- a/sound/pci/hda/Makefile
> > > +++ b/sound/pci/hda/Makefile
> > > @@ -6,6 +6,9 @@ snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
> > >  snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
> > >  snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
> > >
> > > +# for haswell power well
> > > +snd-hda-intel-$(CONFIG_SND_HDA_I915) +=  hda_i915.o
> > > +
> > >  # for trace-points
> > >  CFLAGS_hda_codec.o := -I$(src)
> > >  CFLAGS_hda_intel.o := -I$(src)
> > > diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c new
> > > file mode 100644 index 000..76c13d5
> > > --- /dev/null
> > > +++ b/sound/pci/hda/hda_i915.c
> > > @@ -0,0 +1,75 @@
> > > +/*
> > > + *  hda_i915.c - routines for Haswell HDA controller power well
> > > +support
> > > + *
> > > + *  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; either version 2 of the License, or (at your
> > > +option)
> > > + *  any later version.
> > > + *
> > > + *  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.
> > > + *
> > > + *  You should have received a copy of the GNU General Public License
> > > + *  along with this program; if not, write to the Free Software
> > > +Foundation,
> > > + *  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
> > > + */
> > > +
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include "hda_i915.h"
> > > +
> > > +static void (*get_power)(void);
> > > +static void (*put_power)(void);
> > > +
> > > +void hda_display_power(bool enable)
> > > +{
> > > + if (!get_power || !put_power)
> > > + return;
> > > +
> > > + snd_printdd("HDA display power %s \n",
> > > + enable ? "Enable" : "Disable");
> > > + if (enable)
> > > + get_power();
> > > + else
> > > + put_power();
> > > +}
> > > +
> > > +int hda_i915_init(void)
> > > +{
> > > + int err = 0;
> > > +
> > > + get_power = symbol_request(i915_request_power_well);
> > > + if (!get_power) {
> > > + snd_printk(KERN_WARNING "hda-i915: get_power symbol get
> > fail\n");
> > > + return -ENODEV;
> > > + }
> > > +
> > > + put_power = symbol_request(i915_release_power