aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda
diff options
context:
space:
mode:
authorDylan Reid <dgreid@chromium.org>2012-06-15 22:36:23 -0400
committerTakashi Iwai <tiwai@suse.de>2012-06-18 03:35:21 -0400
commitb4a91cf05c33d4ab5b2b3738a257a3fe49b462bd (patch)
tree4c249b184e000997bd2db10a74f2463654a33e05 /sound/pci/hda
parentafe25967ecf66b38d94d374f0fcb5f4add458a4c (diff)
ALSA: hda - Handle open while transitioning to D3.
This addresses an issue encountered when a pcm is opened while transitioning to low power state (codec->power_on == 1 && codec->power_transition == -1). Add snd_pcm_power_up_d3wait to hda_codec. This function is used to power up from azx_open as opposed to snd_hda_power_up used from codec_exec_verb. When powering up from azx_open, wait for pending power downs to complete, avoiding the power up continuing in parallel with the power down on the work queue. The specific issue seen was with the CS4210 codec, it powers off the ADC and DAC nid in its suspend handler. If it is re-opened before the ~100ms power down process completes, the ADC and DAC nid are initialized while powered down and audio is lost until another suspend/resume cycle. Signed-off-by: Dylan Reid <dgreid@chromium.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda')
-rw-r--r--sound/pci/hda/hda_codec.c46
-rw-r--r--sound/pci/hda/hda_codec.h2
-rw-r--r--sound/pci/hda/hda_intel.c2
3 files changed, 40 insertions, 10 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 41ca803a1fff..7504e62188d6 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4393,20 +4393,19 @@ void snd_hda_update_power_acct(struct hda_codec *codec)
4393 codec->power_jiffies += delta; 4393 codec->power_jiffies += delta;
4394} 4394}
4395 4395
4396/** 4396/* Transition to powered up, if wait_power_down then wait for a pending
4397 * snd_hda_power_up - Power-up the codec 4397 * transition to D3 to complete. A pending D3 transition is indicated
4398 * @codec: HD-audio codec 4398 * with power_transition == -1. */
4399 * 4399static void __snd_hda_power_up(struct hda_codec *codec, bool wait_power_down)
4400 * Increment the power-up counter and power up the hardware really when
4401 * not turned on yet.
4402 */
4403void snd_hda_power_up(struct hda_codec *codec)
4404{ 4400{
4405 struct hda_bus *bus = codec->bus; 4401 struct hda_bus *bus = codec->bus;
4406 4402
4407 spin_lock(&codec->power_lock); 4403 spin_lock(&codec->power_lock);
4408 codec->power_count++; 4404 codec->power_count++;
4409 if (codec->power_on || codec->power_transition > 0) { 4405 /* Return if power_on or transitioning to power_on, unless currently
4406 * powering down. */
4407 if ((codec->power_on || codec->power_transition > 0) &&
4408 !(wait_power_down && codec->power_transition < 0)) {
4410 spin_unlock(&codec->power_lock); 4409 spin_unlock(&codec->power_lock);
4411 return; 4410 return;
4412 } 4411 }
@@ -4430,8 +4429,37 @@ void snd_hda_power_up(struct hda_codec *codec)
4430 codec->power_transition = 0; 4429 codec->power_transition = 0;
4431 spin_unlock(&codec->power_lock); 4430 spin_unlock(&codec->power_lock);
4432} 4431}
4432
4433/**
4434 * snd_hda_power_up - Power-up the codec
4435 * @codec: HD-audio codec
4436 *
4437 * Increment the power-up counter and power up the hardware really when
4438 * not turned on yet.
4439 */
4440void snd_hda_power_up(struct hda_codec *codec)
4441{
4442 __snd_hda_power_up(codec, false);
4443}
4433EXPORT_SYMBOL_HDA(snd_hda_power_up); 4444EXPORT_SYMBOL_HDA(snd_hda_power_up);
4434 4445
4446/**
4447 * snd_hda_power_up_d3wait - Power-up the codec after waiting for any pending
4448 * D3 transition to complete. This differs from snd_hda_power_up() when
4449 * power_transition == -1. snd_hda_power_up sees this case as a nop,
4450 * snd_hda_power_up_d3wait waits for the D3 transition to complete then powers
4451 * back up.
4452 * @codec: HD-audio codec
4453 *
4454 * Cancel any power down operation hapenning on the work queue, then power up.
4455 */
4456void snd_hda_power_up_d3wait(struct hda_codec *codec)
4457{
4458 /* This will cancel and wait for pending power_work to complete. */
4459 __snd_hda_power_up(codec, true);
4460}
4461EXPORT_SYMBOL_HDA(snd_hda_power_up_d3wait);
4462
4435#define power_save(codec) \ 4463#define power_save(codec) \
4436 ((codec)->bus->power_save ? *(codec)->bus->power_save : 0) 4464 ((codec)->bus->power_save ? *(codec)->bus->power_save : 0)
4437 4465
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 4fc3960c8591..2fdaadbb4326 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -1056,10 +1056,12 @@ const char *snd_hda_get_jack_location(u32 cfg);
1056 */ 1056 */
1057#ifdef CONFIG_SND_HDA_POWER_SAVE 1057#ifdef CONFIG_SND_HDA_POWER_SAVE
1058void snd_hda_power_up(struct hda_codec *codec); 1058void snd_hda_power_up(struct hda_codec *codec);
1059void snd_hda_power_up_d3wait(struct hda_codec *codec);
1059void snd_hda_power_down(struct hda_codec *codec); 1060void snd_hda_power_down(struct hda_codec *codec);
1060void snd_hda_update_power_acct(struct hda_codec *codec); 1061void snd_hda_update_power_acct(struct hda_codec *codec);
1061#else 1062#else
1062static inline void snd_hda_power_up(struct hda_codec *codec) {} 1063static inline void snd_hda_power_up(struct hda_codec *codec) {}
1064static inline void snd_hda_power_up_d3wait(struct hda_codec *codec) {}
1063static inline void snd_hda_power_down(struct hda_codec *codec) {} 1065static inline void snd_hda_power_down(struct hda_codec *codec) {}
1064#endif 1066#endif
1065 1067
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 02763827dde0..7757536b9d5f 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1766,7 +1766,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
1766 buff_step); 1766 buff_step);
1767 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 1767 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
1768 buff_step); 1768 buff_step);
1769 snd_hda_power_up(apcm->codec); 1769 snd_hda_power_up_d3wait(apcm->codec);
1770 err = hinfo->ops.open(hinfo, apcm->codec, substream); 1770 err = hinfo->ops.open(hinfo, apcm->codec, substream);
1771 if (err < 0) { 1771 if (err < 0) {
1772 azx_release_device(azx_dev); 1772 azx_release_device(azx_dev);