]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ALSA: cs5535audio: turn off PCM properly if closing the audio device
authorJaya Kumar <jayakumar.lkml@gmail.com>
Wed, 5 Nov 2008 22:30:08 +0000 (17:30 -0500)
committerTakashi Iwai <tiwai@suse.de>
Wed, 10 Dec 2008 16:14:37 +0000 (17:14 +0100)
As per <http://dev.laptop.org/ticket/1420>, we need to properly turn off
the PCM if we're closing the device in order to save power.  This also
causes the MIC led to turn off properly.

Signed-off-by: Jaya Kumar <jayakumar.lkml@gmail.com>
Signed-off-by: Andres Salomon <dilinger@debian.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/cs5535audio/cs5535audio.c
sound/pci/cs5535audio/cs5535audio.h
sound/pci/cs5535audio/cs5535audio_pcm.c

index 1d8b160525355e21eb7ee5c5dcd3a18d5877b313..6c886edd06db1fa5f223e6eea6b23239a3a64d95 100644 (file)
@@ -159,7 +159,8 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
                return err;
 
        memset(&ac97, 0, sizeof(ac97));
-       ac97.scaps = AC97_SCAP_AUDIO|AC97_SCAP_SKIP_MODEM;
+       ac97.scaps = AC97_SCAP_AUDIO | AC97_SCAP_SKIP_MODEM
+                       | AC97_SCAP_POWER_SAVE;
        ac97.private_data = cs5535au;
        ac97.pci = cs5535au->pci;
 
index 66bae7664193115c9c365a96d34e88175679965a..57e9c65e685443fded1c533db7a858b7087c19f2 100644 (file)
@@ -78,6 +78,7 @@ struct cs5535audio_dma {
        unsigned int buf_addr, buf_bytes;
        unsigned int period_bytes, periods;
        u32 saved_prd;
+       int pcm_open_flag;
 };
 
 struct cs5535audio {
index cdcda87116c34bc895b49e8def2ffa28a4c22491..6aa0c19390d7bdd870be469fdcaa1757aeb33c19 100644 (file)
@@ -260,6 +260,9 @@ static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream,
        err = cs5535audio_build_dma_packets(cs5535au, dma, substream,
                                            params_periods(hw_params),
                                            params_period_bytes(hw_params));
+       if (!err)
+               dma->pcm_open_flag = 1;
+
        return err;
 }
 
@@ -268,6 +271,15 @@ static int snd_cs5535audio_hw_free(struct snd_pcm_substream *substream)
        struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
        struct cs5535audio_dma *dma = substream->runtime->private_data;
 
+       if (dma->pcm_open_flag) {
+               if (substream == cs5535au->playback_substream)
+                       snd_ac97_update_power(cs5535au->ac97,
+                                       AC97_PCM_FRONT_DAC_RATE, 0);
+               else
+                       snd_ac97_update_power(cs5535au->ac97,
+                                       AC97_PCM_LR_ADC_RATE, 0);
+               dma->pcm_open_flag = 0;
+       }
        cs5535audio_clear_dma_packets(cs5535au, dma, substream);
        return snd_pcm_lib_free_pages(substream);
 }