From: abhijeet.kumar@intel.com
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Abhijeet Kumar <abhijeet.kumar@intel.com>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>,
Bhumika Goyal <bhumirks@gmail.com>,
Wang YanQing <udknight@gmail.com>, Jeeja KP <jeeja.kp@intel.com>,
Vinod Koul <vinod.koul@intel.com>,
"Subhransu S. Prusty" <subhransu.s.prusty@intel.com>,
Guneshwor Singh <guneshwor.o.singh@intel.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] ALSA: hda: Copying sync power state helper to core
Date: Tue, 23 Jan 2018 23:00:51 +0530 [thread overview]
Message-ID: <1516728657-21522-1-git-send-email-abhijeet.kumar@intel.com> (raw)
In-Reply-To: <1515670468-9198-1-git-send-email-abhijeet.kumar@intel.com>
From: Abhijeet Kumar <abhijeet.kumar@intel.com>
The current sync_power_state is local to hda code, moving it
core so that other users apart from hda legacy can use it.
The helper function ensures the actual state reaches the target state.
Signed-off-by: Abhijeet Kumar <abhijeet.kumar@intel.com>
---
include/sound/hdaudio.h | 2 ++
sound/hda/hdac_device.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 68169e3749de..4c93ff5301bd 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -146,6 +146,8 @@ int snd_hdac_codec_write(struct hdac_device *hdac, hda_nid_t nid,
int flags, unsigned int verb, unsigned int parm);
bool snd_hdac_check_power_state(struct hdac_device *hdac,
hda_nid_t nid, unsigned int target_state);
+unsigned int snd_hdac_sync_power_state(struct hdac_device *hdac,
+ hda_nid_t nid, unsigned int target_state);
/**
* snd_hdac_read_parm - read a codec parameter
* @codec: the codec object
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index 06f845e293cb..7ba100bb1c3f 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -3,6 +3,7 @@
*/
#include <linux/init.h>
+#include <linux/delay.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/module.h>
@@ -1064,3 +1065,37 @@ bool snd_hdac_check_power_state(struct hdac_device *hdac,
return (state == target_state);
}
EXPORT_SYMBOL_GPL(snd_hdac_check_power_state);
+/**
+ * snd_hdac_sync_power_state - wait until actual power state matches
+ * with the target state
+ *
+ * @hdac: the HDAC device
+ * @nid: NID to send the command
+ * @target_state: target state to check for
+ *
+ * Return power state or PS_ERROR if codec rejects GET verb.
+ */
+unsigned int snd_hdac_sync_power_state(struct hdac_device *codec,
+ hda_nid_t nid, unsigned int power_state)
+{
+ unsigned long end_time = jiffies + msecs_to_jiffies(500);
+ unsigned int state, actual_state, count;
+
+ for (count = 0; count < 500; count++) {
+ state = snd_hdac_codec_read(codec, nid, 0,
+ AC_VERB_GET_POWER_STATE, 0);
+ if (state & AC_PWRST_ERROR) {
+ msleep(20);
+ break;
+ }
+ actual_state = (state >> 4) & 0x0f;
+ if (actual_state == power_state)
+ break;
+ if (time_after_eq(jiffies, end_time))
+ break;
+ /* wait until the codec reachs to the target state */
+ msleep(1);
+ }
+ return state;
+}
+EXPORT_SYMBOL_GPL(snd_hdac_sync_power_state);
--
1.9.1
next prev parent reply other threads:[~2018-01-23 17:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-11 11:34 [PATCH] ASoC: hdac_hdmi: Ensuring proper setting of output widget power state abhijeet.kumar
2018-01-12 5:46 ` Vinod Koul
2018-01-12 8:25 ` Kumar, Abhijeet
2018-01-12 9:26 ` Takashi Iwai
2018-01-12 10:37 ` Kumar, Abhijeet
2018-01-12 11:09 ` Takashi Iwai
2018-01-12 8:36 ` Kumar, Abhijeet
2018-01-12 8:27 ` [PATCH v2] " abhijeet.kumar
2018-01-12 21:08 ` Applied "ASoC: hdac_hdmi: Ensuring proper setting of output widget power state" to the asoc tree Mark Brown
2018-01-12 21:20 ` Mark Brown
2018-01-13 4:49 ` Kumar, Abhijeet
2018-01-15 6:12 ` Vinod Koul
2018-01-15 10:30 ` Mark Brown
2018-01-15 10:41 ` Vinod Koul
2018-01-25 13:13 ` Kumar, Abhijeet
2018-01-23 17:30 ` abhijeet.kumar [this message]
2018-01-23 17:30 ` [PATCH 2/3] ALSA: hda: Make use of core codec functions to sync power state abhijeet.kumar
2018-01-23 17:30 ` [PATCH 3/3] ASoC: hdac_hdmi : Ensuring proper setting of output widget " abhijeet.kumar
2018-02-12 13:04 ` Takashi Iwai
2018-02-14 16:20 ` Mark Brown
2018-02-15 8:30 ` Kumar, Abhijeet
2018-02-15 8:35 ` [PATCH] " abhijeet.kumar
2018-02-15 15:34 ` Applied "ASoC: hdac_hdmi : Ensuring proper setting of output widget power state" to the asoc tree Mark Brown
2018-02-15 16:56 ` [PATCH v2] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state abhijeet.kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1516728657-21522-1-git-send-email-abhijeet.kumar@intel.com \
--to=abhijeet.kumar@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=bhumirks@gmail.com \
--cc=broonie@kernel.org \
--cc=guneshwor.o.singh@intel.com \
--cc=jeeja.kp@intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=o-takashi@sakamocchi.jp \
--cc=perex@perex.cz \
--cc=subhransu.s.prusty@intel.com \
--cc=tiwai@suse.com \
--cc=udknight@gmail.com \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).