[ALSA] ak4531 - Add PM support
authorTakashi Iwai <tiwai@suse.de>
Thu, 17 Nov 2005 15:13:05 +0000 (16:13 +0100)
committerJaroslav Kysela <perex@suse.cz>
Tue, 3 Jan 2006 11:27:55 +0000 (12:27 +0100)
Modules: AK4531 codec

Add PM support to AK4531 codec driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/ak4531_codec.h
sound/pci/ac97/ak4531_codec.c

index 4e7c661af484126f91213a5f1bd1ae21507a076b..edf04070ce7c44e98606fa2e68003ac1bd64a5e8 100644 (file)
@@ -77,4 +77,9 @@ struct snd_ak4531 {
 int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531,
                     struct snd_ak4531 **rak4531);
 
+#ifdef CONFIG_PM
+void snd_ak4531_suspend(struct snd_ak4531 *ak4531);
+void snd_ak4531_resume(struct snd_ak4531 *ak4531);
+#endif
+
 #endif /* __SOUND_AK4531_CODEC_H */
index 088d8dc336be0deb5250a7fe7f3622ef3f86a887..3eb885584e9a8fb83292a6513f2ccf93586455d2 100644 (file)
@@ -371,7 +371,7 @@ int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531,
        ak4531->write(ak4531, AK4531_RESET, 0x03);      /* no RST, PD */
        udelay(100);
        ak4531->write(ak4531, AK4531_CLOCK, 0x00);      /* CODEC ADC and CODEC DAC use {LR,B}CLK2 and run off LRCLK2 PLL */
-       for (idx = 0; idx < 0x19; idx++) {
+       for (idx = 0; idx <= 0x19; idx++) {
                if (idx == AK4531_RESET || idx == AK4531_CLOCK)
                        continue;
                ak4531->write(ak4531, idx, ak4531->regs[idx] = snd_ak4531_initial_map[idx]);    /* recording source is mixer */
@@ -395,6 +395,36 @@ int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531,
        return 0;
 }
 
+/*
+ * power management
+ */
+#ifdef CONFIG_PM
+void snd_ak4531_suspend(struct snd_ak4531 *ak4531)
+{
+       /* mute */
+       ak4531->write(ak4531, AK4531_LMASTER, 0x9f);
+       ak4531->write(ak4531, AK4531_RMASTER, 0x9f);
+       /* powerdown */
+       ak4531->write(ak4531, AK4531_RESET, 0x01);
+}
+
+void snd_ak4531_resume(struct snd_ak4531 *ak4531)
+{
+       int idx;
+
+       /* initialize */
+       ak4531->write(ak4531, AK4531_RESET, 0x03);
+       udelay(100);
+       ak4531->write(ak4531, AK4531_CLOCK, 0x00);
+       /* restore mixer registers */
+       for (idx = 0; idx <= 0x19; idx++) {
+               if (idx == AK4531_RESET || idx == AK4531_CLOCK)
+                       continue;
+               ak4531->write(ak4531, idx, ak4531->regs[idx]);
+       }
+}
+#endif
+
 /*
 
  */
@@ -420,6 +450,10 @@ static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak453
 }
 
 EXPORT_SYMBOL(snd_ak4531_mixer);
+#ifdef CONFIG_PM
+EXPORT_SYMBOL(snd_ak4531_suspend);
+EXPORT_SYMBOL(snd_ak4531_resume);
+#endif
 
 /*
  *  INIT part