aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-08-10 11:21:45 -0400
committerJaroslav Kysela <perex@perex.cz>2007-10-16 09:58:46 -0400
commitcb53c626e1145edf1d619bc4953f6293d3a77ace (patch)
tree715c2ef3d56a5ac7c79498800e888f562c1aa961 /sound/pci/hda/hda_codec.h
parentcca3b3718ca96dca51daf1129ac03003bcede751 (diff)
[ALSA] hda-intel - Add POWER_SAVE option
Added CONFIG_SND_HDA_POWER_SAVE kconfig. It's an experimental option to achieve an aggressive power-saving. With this option, the driver will turn on/off the power of each codec and controller chip dynamically on demand. The patch introduces a new module option 'power_save'. It specifies the second of time-out for automatic power-down. As default, it's 10 seconds. Setting 0 means to suppress the power-saving feature. The codec may have analog-input loopbacks, which are usually represented by mixer elements such as 'Mic Playback Switch' or 'CD Playback Switch'. When these are on, we cannot turn off the mixer and the codec chip has to be kept on. For bookkeeping these states, a new codec-callback is introduced. For the bus-controller side, a new callback pm_notify is introduced, which can be used to turn on/off the contoller appropriately. Note that this power-saving might cause slight click-noise at power-on/off. Also, it might take some time to wake up the codec, and might even drop some tones at the very beginning. This seems to be the side-effect of turning off the controller chip. This turn-off of the controller can be disabled by undefining HDA_POWER_SAVE_RESET_CONTOLLER in hda_intel.c. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/hda/hda_codec.h')
-rw-r--r--sound/pci/hda/hda_codec.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 92938d2a52e2..1ffffaa3a30d 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -26,6 +26,10 @@
26#include <sound/pcm.h> 26#include <sound/pcm.h>
27#include <sound/hwdep.h> 27#include <sound/hwdep.h>
28 28
29#if defined(CONFIG_PM) || defined(CONFIG_SND_HDA_POWER_SAVE)
30#define SND_HDA_NEEDS_RESUME /* resume control code is required */
31#endif
32
29/* 33/*
30 * nodes 34 * nodes
31 */ 35 */
@@ -412,6 +416,10 @@ struct hda_bus_ops {
412 unsigned int (*get_response)(struct hda_codec *codec); 416 unsigned int (*get_response)(struct hda_codec *codec);
413 /* free the private data */ 417 /* free the private data */
414 void (*private_free)(struct hda_bus *); 418 void (*private_free)(struct hda_bus *);
419#ifdef CONFIG_SND_HDA_POWER_SAVE
420 /* notify power-up/down from codec to contoller */
421 void (*pm_notify)(struct hda_codec *codec);
422#endif
415}; 423};
416 424
417/* template to pass to the bus constructor */ 425/* template to pass to the bus constructor */
@@ -473,10 +481,13 @@ struct hda_codec_ops {
473 int (*init)(struct hda_codec *codec); 481 int (*init)(struct hda_codec *codec);
474 void (*free)(struct hda_codec *codec); 482 void (*free)(struct hda_codec *codec);
475 void (*unsol_event)(struct hda_codec *codec, unsigned int res); 483 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
476#ifdef CONFIG_PM 484#ifdef SND_HDA_NEEDS_RESUME
477 int (*suspend)(struct hda_codec *codec, pm_message_t state); 485 int (*suspend)(struct hda_codec *codec, pm_message_t state);
478 int (*resume)(struct hda_codec *codec); 486 int (*resume)(struct hda_codec *codec);
479#endif 487#endif
488#ifdef CONFIG_SND_HDA_POWER_SAVE
489 int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid);
490#endif
480}; 491};
481 492
482/* record for amp information cache */ 493/* record for amp information cache */
@@ -573,6 +584,12 @@ struct hda_codec {
573 unsigned int spdif_in_enable; /* SPDIF input enable? */ 584 unsigned int spdif_in_enable; /* SPDIF input enable? */
574 585
575 struct snd_hwdep *hwdep; /* assigned hwdep device */ 586 struct snd_hwdep *hwdep; /* assigned hwdep device */
587
588#ifdef CONFIG_SND_HDA_POWER_SAVE
589 int power_on; /* current (global) power-state */
590 int power_count; /* current (global) power refcount */
591 struct delayed_work power_work; /* delayed task for powerdown */
592#endif
576}; 593};
577 594
578/* direction */ 595/* direction */
@@ -617,7 +634,7 @@ void snd_hda_sequence_write(struct hda_codec *codec,
617int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex); 634int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex);
618 635
619/* cached write */ 636/* cached write */
620#ifdef CONFIG_PM 637#ifdef SND_HDA_NEEDS_RESUME
621int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, 638int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
622 int direct, unsigned int verb, unsigned int parm); 639 int direct, unsigned int verb, unsigned int parm);
623void snd_hda_sequence_write_cache(struct hda_codec *codec, 640void snd_hda_sequence_write_cache(struct hda_codec *codec,
@@ -662,4 +679,15 @@ int snd_hda_suspend(struct hda_bus *bus, pm_message_t state);
662int snd_hda_resume(struct hda_bus *bus); 679int snd_hda_resume(struct hda_bus *bus);
663#endif 680#endif
664 681
682/*
683 * power saving
684 */
685#ifdef CONFIG_SND_HDA_POWER_SAVE
686void snd_hda_power_up(struct hda_codec *codec);
687void snd_hda_power_down(struct hda_codec *codec);
688#else
689static inline void snd_hda_power_up(struct hda_codec *codec) {}
690static inline void snd_hda_power_down(struct hda_codec *codec) {}
691#endif
692
665#endif /* __SOUND_HDA_CODEC_H */ 693#endif /* __SOUND_HDA_CODEC_H */