Skip to content

Commit 3b5b899

Browse files
Abhijeet Kumartiwai
authored andcommitted
ALSA: hda: Make use of core codec functions to sync power state
Since sync_power_state is moved to core it's better to use the helper function to ensure the actual power state reaches target instead of using the local helper functions already exsisting in hda code. Signed-off-by: Abhijeet Kumar <abhijeet.kumar@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 0978749 commit 3b5b899

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

sound/pci/hda/hda_codec.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,32 +2702,6 @@ void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg,
27022702
}
27032703
EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_to_all);
27042704

2705-
/*
2706-
* wait until the state is reached, returns the current state
2707-
*/
2708-
static unsigned int hda_sync_power_state(struct hda_codec *codec,
2709-
hda_nid_t fg,
2710-
unsigned int power_state)
2711-
{
2712-
unsigned long end_time = jiffies + msecs_to_jiffies(500);
2713-
unsigned int state, actual_state;
2714-
2715-
for (;;) {
2716-
state = snd_hda_codec_read(codec, fg, 0,
2717-
AC_VERB_GET_POWER_STATE, 0);
2718-
if (state & AC_PWRST_ERROR)
2719-
break;
2720-
actual_state = (state >> 4) & 0x0f;
2721-
if (actual_state == power_state)
2722-
break;
2723-
if (time_after_eq(jiffies, end_time))
2724-
break;
2725-
/* wait until the codec reachs to the target state */
2726-
msleep(1);
2727-
}
2728-
return state;
2729-
}
2730-
27312705
/**
27322706
* snd_hda_codec_eapd_power_filter - A power filter callback for EAPD
27332707
* @codec: the HDA codec
@@ -2790,7 +2764,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
27902764
state);
27912765
snd_hda_codec_set_power_to_all(codec, fg, power_state);
27922766
}
2793-
state = hda_sync_power_state(codec, fg, power_state);
2767+
state = snd_hda_sync_power_state(codec, fg, power_state);
27942768
if (!(state & AC_PWRST_ERROR))
27952769
break;
27962770
}

sound/pci/hda/hda_local.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,11 @@ snd_hda_check_power_state(struct hda_codec *codec, hda_nid_t nid,
622622
{
623623
return snd_hdac_check_power_state(&codec->core, nid, target_state);
624624
}
625-
625+
static inline bool snd_hda_sync_power_state(struct hda_codec *codec,
626+
hda_nid_t nid, unsigned int target_state)
627+
{
628+
return snd_hdac_sync_power_state(&codec->core, nid, target_state);
629+
}
626630
unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec,
627631
hda_nid_t nid,
628632
unsigned int power_state);

0 commit comments

Comments
 (0)