alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v8 1/2] ASoC: hdac_hdmi: Fix to wait for D3 before powering off codec
@ 2016-02-21  6:00 Subhransu S. Prusty
  2016-02-21  6:00 ` [PATCH v8 2/2] ASoC: hdac_hdmi: Add PM support Subhransu S. Prusty
  2016-02-24  3:53 ` Applied "ASoC: hdac_hdmi: Fix to wait for D3 before powering off codec" to the asoc tree Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Subhransu S. Prusty @ 2016-02-21  6:00 UTC (permalink / raw)
  To: alsa-devel
  Cc: tiwai, lgirdwood, patches.audio, broonie, Vinod Koul,
	Subhransu S. Prusty

Powering off codec immediately after sending D3 verb may not set
the node to D3 state. So wait for a confirmation response before
shutting down codec.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 sound/soc/codecs/hdac_hdmi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 2445b43..aa953a5 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1486,6 +1486,7 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
 	struct hdac_ext_device *edev = to_hda_ext_device(dev);
 	struct hdac_device *hdac = &edev->hdac;
 	struct hdac_bus *bus = hdac->bus;
+	unsigned long timeout;
 	int err;
 
 	dev_dbg(dev, "Enter: %s\n", __func__);
@@ -1495,10 +1496,19 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
 		return 0;
 
 	/* Power down afg */
-	if (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D3))
+	if (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D3)) {
 		snd_hdac_codec_write(hdac, hdac->afg, 0,
 			AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
 
+		/* Wait till power state is set to D3 */
+		timeout = jiffies + msecs_to_jiffies(1000);
+		while (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D3)
+				&& time_before(jiffies, timeout)) {
+
+			msleep(50);
+		}
+	}
+
 	err = snd_hdac_display_power(bus, false);
 	if (err < 0) {
 		dev_err(bus->dev, "Cannot turn on display power on i915\n");
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-24  3:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-21  6:00 [PATCH v8 1/2] ASoC: hdac_hdmi: Fix to wait for D3 before powering off codec Subhransu S. Prusty
2016-02-21  6:00 ` [PATCH v8 2/2] ASoC: hdac_hdmi: Add PM support Subhransu S. Prusty
2016-02-21  8:18   ` Takashi Iwai
2016-02-22  2:10     ` Subhransu S. Prusty
2016-02-24  3:53 ` Applied "ASoC: hdac_hdmi: Fix to wait for D3 before powering off codec" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).