Commit b035ce0f authored by Jaya Kumar's avatar Jaya Kumar Committed by Takashi Iwai

ALSA: cs5535audio: turn off PCM properly if closing the audio device

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: default avatarJaya Kumar <jayakumar.lkml@gmail.com>
Signed-off-by: default avatarAndres Salomon <dilinger@debian.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 0bed7b29
...@@ -159,7 +159,8 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au) ...@@ -159,7 +159,8 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
return err; return err;
memset(&ac97, 0, sizeof(ac97)); 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.private_data = cs5535au;
ac97.pci = cs5535au->pci; ac97.pci = cs5535au->pci;
......
...@@ -78,6 +78,7 @@ struct cs5535audio_dma { ...@@ -78,6 +78,7 @@ struct cs5535audio_dma {
unsigned int buf_addr, buf_bytes; unsigned int buf_addr, buf_bytes;
unsigned int period_bytes, periods; unsigned int period_bytes, periods;
u32 saved_prd; u32 saved_prd;
int pcm_open_flag;
}; };
struct cs5535audio { struct cs5535audio {
......
...@@ -260,6 +260,9 @@ static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream, ...@@ -260,6 +260,9 @@ static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream,
err = cs5535audio_build_dma_packets(cs5535au, dma, substream, err = cs5535audio_build_dma_packets(cs5535au, dma, substream,
params_periods(hw_params), params_periods(hw_params),
params_period_bytes(hw_params)); params_period_bytes(hw_params));
if (!err)
dma->pcm_open_flag = 1;
return err; return err;
} }
...@@ -268,6 +271,15 @@ static int snd_cs5535audio_hw_free(struct snd_pcm_substream *substream) ...@@ -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 *cs5535au = snd_pcm_substream_chip(substream);
struct cs5535audio_dma *dma = substream->runtime->private_data; 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); cs5535audio_clear_dma_packets(cs5535au, dma, substream);
return snd_pcm_lib_free_pages(substream); return snd_pcm_lib_free_pages(substream);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment