summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_local.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2013-01-24 17:47:17 +0100
committerTakashi Iwai <tiwai@suse.de>2013-01-24 17:47:17 +0100
commit9040d102da5635abc306372bb4dbffaba92c478e (patch)
treeb6674ae2c98ab64d78c78b7623e51e676bacd55f /sound/pci/hda/hda_local.h
parentALSA: hda - Synchronize the power state at the end of codec init (diff)
downloadlinux-9040d102da5635abc306372bb4dbffaba92c478e.tar.xz
linux-9040d102da5635abc306372bb4dbffaba92c478e.zip
ALSA: hda - Add snd_hda_check_power_state() helper function
... for small refactoring. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_local.h')
-rw-r--r--sound/pci/hda/hda_local.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 2ff62dcf2fcb..05f1d594d17b 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -657,6 +657,19 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
struct hda_loopback_check *check,
hda_nid_t nid);
+/* check whether the actual power state matches with the target state */
+static inline bool
+snd_hda_check_power_state(struct hda_codec *codec, hda_nid_t nid,
+ unsigned int target_state)
+{
+ unsigned int state = snd_hda_codec_read(codec, nid, 0,
+ AC_VERB_GET_POWER_STATE, 0);
+ if (state & AC_PWRST_ERROR)
+ return true;
+ state = (state >> 4) & 0x0f;
+ return (state != target_state);
+}
+
/*
* AMP control callbacks
*/