A few HD-audio things for 3.14
cover A few HD-audio things for 3.14
Hi,
here are a few patches that are targeted for 3.14. So they are not urgently needed, mostly clean ups, but also includes some runtime PM changes as we're discussing now.
The patches are found in sound-unstable git tree test/hda branch, too.
Takashi
PATCH 1/5 ALSA: hda - Split the generic parser as an individual module
Drop the hard dependency on the generic parser code and load / unload the generic parser code dynamically if built as a module. This allows us to avoid the generic parser if only HDMI/DP codecs are found.
--- sound/pci/hda/Makefile | 5 +++- sound/pci/hda/hda_codec.c | 67 +++++++++++++++++++++++++++++++++------------ sound/pci/hda/hda_codec.h | 1 + sound/pci/hda/hda_generic.c | 4 +++ sound/pci/hda/hda_local.h | 7 ----- 5 files changed, 58 insertions(+), 26 deletions(-)
sound/pci/hda/Makefile +4 -1
@@ -3,7 +3,6 @@ snd-hda-intel-objs := hda_intel.o snd-hda-intel-$(CONFIG_SND_HDA_I915) += hda_i915.o snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o -snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o 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
@@ -12,6 +11,7 @@ snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o CFLAGS_hda_codec.o := -I$(src) CFLAGS_hda_intel.o := -I$(src) +snd-hda-codec-generic-objs := hda_generic.o snd-hda-codec-realtek-objs := patch_realtek.o snd-hda-codec-cmedia-objs := patch_cmedia.o snd-hda-codec-analog-objs := patch_analog.o
@@ -28,6 +28,9 @@ snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o # codec drivers (note: CONFIG_SND_HDA_CODEC_XXX are booleans) +ifdef CONFIG_SND_HDA_GENERIC +obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-generic.o +endif ifdef CONFIG_SND_HDA_CODEC_REALTEK obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-realtek.o endif
sound/pci/hda/hda_codec.c +49 -18
111 lines not on this page · raw message
sound/pci/hda/hda_codec.h +1 -0
@@ -835,6 +835,7 @@ struct hda_codec {/* detected preset */ const struct hda_codec_preset *preset;struct module *owner; +int (*parser)(struct hda_codec *codec);const char *vendor_name;/* codec vendor name */ const char *chip_name;/* codec chip name */ const char *modelname;/* model name for preset */
sound/pci/hda/hda_generic.c +4 -0
@@ -28,6 +28,7 @@#include <linux/ctype.h> #include <linux/string.h> #include <linux/bitops.h> +#include <linux/module.h> #include <sound/core.h> #include <sound/jack.h> #include "hda_codec.h"
@@ -5291,3 +5292,6 @@ error:return err; }EXPORT_SYMBOL_HDA (snd_hda_parse_generic_codec); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Generic HD-audio codec parser" );
sound/pci/hda/hda_local.h +0 -7
@@ -352,14 +352,7 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,/* * generic codec parser */ -#ifdef CONFIG_SND_HDA_GENERIC int snd_hda_parse_generic_codec (struct hda_codec *codec); -#else -static inline int snd_hda_parse_generic_codec (struct hda_codec *codec) -{ -return -ENODEV ; -} -#endif /* * generic proc interface
Signature · 1 line
1.8.4.3
PATCH 2/5 ALSA: hda - Bind with HDMI codec parser automatically
In reply to Takashi IwaiIf a codec contains only the digital outputs, it's very likely a HDMI/DP codec, which isn't supported by the generic parser but via HDMI codec parser code. Detect such a case and bind with the proper parser object if available.
--- sound/pci/hda/hda_codec.c | 27 +++++++++++++++++++++++++++ sound/pci/hda/hda_local.h | 1 + sound/pci/hda/patch_hdmi.c | 9 +++++++++ 3 files changed, 37 insertions(+)
sound/pci/hda/hda_codec.c +27 -0
@@ -1557,6 +1557,31 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec)EXPORT_SYMBOL_HDA (snd_hda_codec_update_widgets); +#ifdef CONFIG_SND_HDA_CODEC_HDMI +/* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */ +static bool is_likely_hdmi_codec (struct hda_codec *codec) +{ +hda_nid_t nid = codec->start_nid; +int i; + +for (i =0 ; i < codec->num_nodes; i++, nid++) { +unsigned int wcaps =get_wcaps (codec, nid); +switch (get_wcaps_type (wcaps)) { +case AC_WID_AUD_IN : +return false;/* HDMI parser supports only HDMI out */ +case AC_WID_AUD_OUT : +if (!(wcaps &AC_WCAP_DIGITAL )) +return false; +break ; + } + } +return true; +} +#else +/* no HDMI codec parser support */ +#define is_likely_hdmi_codec (codec) false +#endif /* CONFIG_SND_HDA_CODEC_HDMI */ +/** * snd_hda_codec_configure - (Re-)configure the HD-audio codec * @codec: the HDA codec
@@ -1582,6 +1607,8 @@ int snd_hda_codec_configure(struct hda_codec *codec) patch = codec->preset->patch;if (!patch) {unload_parser (codec);/* to be sure */ +if (is_likely_hdmi_codec (codec)) + patch =load_parser (codec, snd_hda_parse_hdmi_codec);#ifdef CONFIG_SND_HDA_GENERIC if (!patch) patch =load_parser (codec, snd_hda_parse_generic_codec);
sound/pci/hda/hda_local.h +1 -0
@@ -353,6 +353,7 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,* generic codec parser */ int snd_hda_parse_generic_codec (struct hda_codec *codec); +int snd_hda_parse_hdmi_codec (struct hda_codec *codec);/* * generic proc interface
sound/pci/hda/patch_hdmi.c +9 -0
@@ -3214,6 +3214,15 @@ static int patch_via_hdmi(struct hda_codec *codec) }/* +* called from hda_codec.c for generic HDMI support +*/ +int snd_hda_parse_hdmi_codec (struct hda_codec *codec) +{ +return patch_generic_hdmi (codec); +} +EXPORT_SYMBOL_HDA (snd_hda_parse_hdmi_codec); + +/* * patch entries */ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
Signature · 1 line
1.8.4.3
PATCH 3/5 ALSA: hda - Refactor pm notification in hda_codec.c
In reply to Takashi IwaiNo functional change.
- codec->pm_down_notified flag is renamed to codec->pm_up_notified flag (and takes the reversed meaning), which is managed solely in hda_call_pm_notify() now.
- The explicit call of hda_call_pm_notify() is moved into hda_keep_power_on().
- Removed a redundant call of hda_call_pm_notify() in snd_hda_power_up(), as it's called in hda_call_codec_resume() anyway.
--- sound/pci/hda/hda_codec.c | 37 ++++++++++++++----------------------- sound/pci/hda/hda_codec.h | 2 +- 2 files changed, 15 insertions(+), 24 deletions(-)
sound/pci/hda/hda_codec.c +14 -23
@@ -99,16 +99,24 @@ EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset);static void hda_power_work (struct work_struct *work);static void hda_keep_power_on (struct hda_codec *codec);#define hda_codec_is_power_on (codec) ((codec)->power_on) -static inline void hda_call_pm_notify (struct hda_bus *bus,bool power_up) + +static void hda_call_pm_notify (struct hda_codec *codec,bool power_up) { +struct hda_bus *bus = codec->bus; + +if ((power_up && codec->pm_up_notified) || + (!power_up && !codec->pm_up_notified)) +return ;if (bus->ops.pm_notify) bus->ops.pm_notify (bus, power_up); + codec->pm_up_notified = power_up; } +#else #define codec_in_pm (codec) 0static inline void hda_keep_power_on (struct hda_codec *codec) {}#define hda_codec_is_power_on (codec) 1 -#define hda_call_pm_notify (bus, state) {} +#define hda_call_pm_notify (codec, state) {}#endif /**
@@ -1371,10 +1379,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) codec->bus->caddr_tbl[codec->addr] =NULL ;if (codec->patch_ops.free) codec->patch_ops.free (codec); -#ifdef CONFIG_PM -if (!codec->pm_down_notified)/* cancel leftover refcounts */ -hda_call_pm_notify (codec->bus, false); -#endif +hda_call_pm_notify (codec, false);/* cancel leftover refcounts */ unload_parser (codec);module_put (codec->owner);free_hda_cache (&codec->amp_cache);
@@ -1453,7 +1458,6 @@ int snd_hda_codec_new(struct hda_bus *bus,* phase. */ hda_keep_power_on (codec); -hda_call_pm_notify (bus, true);#endif if (codec->bus->modelname) {
@@ -4058,10 +4062,6 @@ static void hda_call_codec_resume(struct hda_codec *codec)* in the resume / power-save sequence */ hda_keep_power_on (codec); -if (codec->pm_down_notified) { - codec->pm_down_notified =0 ; -hda_call_pm_notify (codec->bus, true); - }hda_set_power_state (codec,AC_PWRST_D0 );restore_shutup_pins (codec);hda_exec_init_verbs (codec);
@@ -4935,11 +4935,8 @@ static void hda_power_work(struct work_struct *work)spin_unlock (&codec->power_lock); state =hda_call_codec_suspend (codec, true); -if (!codec->pm_down_notified && - !bus->power_keep_link_on && (state &AC_PWRST_CLK_STOP_OK )) { - codec->pm_down_notified =1 ; -hda_call_pm_notify (bus, false); - } +if (!bus->power_keep_link_on && (state &AC_PWRST_CLK_STOP_OK )) +hda_call_pm_notify (codec, false); }static void hda_keep_power_on (struct hda_codec *codec)
@@ -4949,6 +4946,7 @@ static void hda_keep_power_on(struct hda_codec *codec) codec->power_on =1 ; codec->power_jiffies = jiffies;spin_unlock (&codec->power_lock); +hda_call_pm_notify (codec, true); }/* update the power on/off account with the current jiffies */
@@ -4968,8 +4966,6 @@ void snd_hda_update_power_acct(struct hda_codec *codec)/* call this with codec->power_lock held! */ static void __snd_hda_power_up (struct hda_codec *codec,bool wait_power_down) { -struct hda_bus *bus = codec->bus; -/* Return if power_on or transitioning to power_on, unless currently * powering down. */ if ((codec->power_on || codec->power_transition > 0) &&
@@ -4996,11 +4992,6 @@ static void __snd_hda_power_up(struct hda_codec *codec, bool wait_power_down) codec->power_transition =1 ;/* avoid reentrance */ spin_unlock (&codec->power_lock); -if (codec->pm_down_notified) { - codec->pm_down_notified =0 ; -hda_call_pm_notify (bus, true); - } -hda_call_codec_resume (codec);spin_lock (&codec->power_lock);
sound/pci/hda/hda_codec.h +1 -1
@@ -909,7 +909,7 @@ struct hda_codec {#ifdef CONFIG_PM unsigned int power_on :1; /* current (global) power-state */ unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */ - unsigned int pm_down_notified:1; /* PM notified to controller */ + unsigned int pm_up_notified:1; /* PM notified to controller */ unsigned int in_pm:1; /* suspend/resume being performed */int power_transition;/* power-state in transition */ int power_count;/* current (global) power refcount */
Signature · 1 line
1.8.4.3
PATCH 4/5 ALSA: hda - Enable runtime PM on Panther Point
In reply to Takashi IwaiNow we fixed the long-standing bugs of runtime PM, let's enable Panther Point again. The runtime PM was disabled in the HDMI codec driver due to the S3 issue, and this should have been fixed now.
--- sound/pci/hda/hda_intel.c | 2 +- sound/pci/hda/patch_hdmi.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-)
sound/pci/hda/hda_intel.c +1 -1
@@ -3979,7 +3979,7 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH_NOPM },/* Panther Point */ { PCI_DEVICE(0x8086, 0x1e20), - .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH_NOPM }, + .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, /* Lynx Point */ { PCI_DEVICE(0x8086, 0x8c20), .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
sound/pci/hda/patch_hdmi.c +1 -5
@@ -1693,16 +1693,12 @@ static int hdmi_parse_codec(struct hda_codec *codec) }#ifdef CONFIG_PM -/* We're seeing some problems with unsolicited hot plug events on -* PantherPoint after S3, if this is not enabled */ -if (codec->vendor_id ==0x80862806 ) - codec->bus->power_keep_link_on =1 ;/* * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event * can be lost and presence sense verb will become inaccurate if the * HDA link is powered off at hot plug or hw initialization time. */ -else if (!(snd_hda_param_read (codec, codec->afg,AC_PAR_POWER_STATE ) & +if (!(snd_hda_param_read (codec, codec->afg,AC_PAR_POWER_STATE ) &AC_PWRST_EPSS )) codec->bus->power_keep_link_on =1 ;#endif
Signature · 1 line
1.8.4.3
PATCH 5/5 ALSA: hda - Make device D3 during runtime suspend
In reply to Takashi IwaiWe can make the device D3 for saving more power during the runtime suspend. Meanwhile, I observed that Haswell HDMI codecs gets corrupted ELD bytes when woken up from runtime suspend with D3. As a quick workaround, exclude these chips from D3.
--- sound/pci/hda/hda_intel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/pci/hda/hda_intel.c +12 -0
@@ -2997,6 +2997,13 @@ static int azx_runtime_suspend(struct device *dev)if (!chip->bus->avoid_link_reset)azx_enter_link_reset (chip);azx_clear_irq_pending (chip); + +/* Haswell HDMI/DP shows the broken ELD read after runtime PM */ +if (chip->driver_type !=AZX_DRIVER_HDMI ) { +pci_save_state (chip->pci); +pci_set_power_state (chip->pci, PCI_D3hot); + } +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL )hda_display_power (false);return 0 ;
@@ -3019,6 +3026,11 @@ static int azx_runtime_resume(struct device *dev)if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL )hda_display_power (true); +if (chip->driver_type !=AZX_DRIVER_HDMI ) { +pci_set_power_state (chip->pci,PCI_D0 ); +pci_restore_state (chip->pci); + } +/* Read STATESTS before controller reset */ status =azx_readw (chip,STATESTS );
Signature · 1 line
1.8.4.3
Re: [PATCH 5/5] ALSA: hda - Make device D3 during runtime suspend
At Tue, 26 Nov 2013 09:29:13 +0100,
Quoted 5 lines · Takashi Iwai
We can make the device D3 for saving more power during the runtime suspend. Meanwhile, I observed that Haswell HDMI codecs gets corrupted ELD bytes when woken up from runtime suspend with D3. As a quick workaround, exclude these chips from D3.
Scratch this. After reading the PCI core code, I found this patch is just a nonsense.
Takashi
Quoted 44 lines
Signed-off-by Takashi Iwai <[email protected]>--- sound/pci/hda/hda_intel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)sound/pci/hda/hda_intel.c +12
-0@@ -2997,6 +2997,13 @@ static int azx_runtime_suspend(struct device *dev)if (!chip->bus->avoid_link_reset)azx_enter_link_reset (chip);azx_clear_irq_pending (chip); + +/* Haswell HDMI/DP shows the broken ELD read after runtime PM */ +if (chip->driver_type !=AZX_DRIVER_HDMI ) { +pci_save_state (chip->pci); +pci_set_power_state (chip->pci, PCI_D3hot); + } +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL )hda_display_power (false);return 0 ;@@ -3019,6 +3026,11 @@ static int azx_runtime_resume(struct device *dev)if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL )hda_display_power (true); +if (chip->driver_type !=AZX_DRIVER_HDMI ) { +pci_set_power_state (chip->pci,PCI_D0 ); +pci_restore_state (chip->pci); + } +/* Read STATESTS before controller reset */ status =azx_readw (chip,STATESTS );Signature · 6 lines
1.8.4.3 _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [PATCH 5/5] ALSA: hda - Make device D3 during runtime suspend
Quoted 11 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Takashi Iwai
Sent: Tuesday, November 26, 2013 8:34 PM
To: [email protected]
Subject: Re: [alsa-devel] [PATCH 5/5] ALSA: hda - Make device D3 during runtime suspendAt Tue, 26 Nov 2013 09:29:13 +0100,
Quoted 1 line · Takashi Iwai
Quoted 7 lines
Quoted 4 lines
We can make the device D3 for saving more power during the runtime suspend. Meanwhile, I observed that Haswell HDMI codecs gets corrupted ELD bytes when woken up from runtime suspend with D3. As a quick workaround, exclude these chips from D3.
Scratch this. After reading the PCI core code, I found this patch is just a nonsense.
Could you share more info here?
On Haswell, the HDMI audio controller (PCI device 3) and codec are in display power well, so the power saving is achieved by releasing and turning off the display power well.
But at least for legacy audio, we need the controller (PCI device 1b) to enter D3 at runtime so PCI driver will call ACPI and BIOS can know the legacy audio controller is in D3 and power down the on-board codec.
Thanks
Mengdong
Quoted 50 lines
sound/pci/hda/hda_intel.c static int azx_runtime_suspend(struct device
Quoted 11 lines
Signed-off-by Takashi Iwai <[email protected]>--- sound/pci/hda/hda_intel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)sound/pci/hda/hda_intel.c +0
-0@@ -2997,6 +2997,13 @@ static int azx_runtime_suspend(struct device*dev)
sound/pci/hda/hda_intel.c static int azx_runtime_resume(struct device
Quoted 14 lines
sound/pci/hda/hda_intel.c +7
-0if (!chip->bus->avoid_link_reset)azx_enter_link_reset (chip);azx_clear_irq_pending (chip); + +/* Haswell HDMI/DP shows the broken ELD read after runtime PM */ +if (chip->driver_type !=AZX_DRIVER_HDMI ) { +pci_save_state (chip->pci); +pci_set_power_state (chip->pci, PCI_D3hot); + } +if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL )hda_display_power (false);return 0 ;@@ -3019,6 +3026,11 @@ static int azx_runtime_resume(struct device*dev)
Quoted 14 lines
sound/pci/hda/hda_intel.c +5
-1if (chip->driver_caps &AZX_DCAPS_I915_POWERWELL )hda_display_power (true); +if (chip->driver_type !=AZX_DRIVER_HDMI ) { +pci_set_power_state (chip->pci,PCI_D0 ); +pci_restore_state (chip->pci); + } +/* Read STATESTS before controller reset */ status =azx_readw (chip,STATESTS ); --1.8.4.3
Quoted 5 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [PATCH 5/5] ALSA: hda - Make device D3 during runtime suspend
At Tue, 26 Nov 2013 13:32:11 +0000,
Quoted 17 lines · Mengdong
Quoted 17 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Takashi Iwai
Sent: Tuesday, November 26, 2013 8:34 PM
To: [email protected]
Subject: Re: [alsa-devel] [PATCH 5/5] ALSA: hda - Make device D3 during runtime suspendAt Tue, 26 Nov 2013 09:29:13 +0100,
Quoted 5 lines · Takashi Iwai
We can make the device D3 for saving more power during the runtime suspend. Meanwhile, I observed that Haswell HDMI codecs gets corrupted ELD bytes when woken up from runtime suspend with D3. As a quick workaround, exclude these chips from D3.
Quoted 8 lines
Quoted 2 lines
Scratch this. After reading the PCI core code, I found this patch is just a nonsense.
Could you share more info here?
On Haswell, the HDMI audio controller (PCI device 3) and codec are in display power well, so the power saving is achieved by releasing and turning off the display power well.
But at least for legacy audio, we need the controller (PCI device 1b) to enter D3 at runtime so PCI driver will call ACPI and BIOS can know the legacy audio controller is in D3 and power down the on-board codec.
The D3 state should be achieved by the runtime suspend code of PCI driver itself, thus the driver doesn't have to do it. For details, look at pci_pm_runtime_suspend() and pci_finish_runtime_suspend().
Takashi