ALSA: hda - Add snd_hda_check_power_state() helper function
... for small refactoring. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
b9c590bbf1
commit
9040d102da
@ -3779,18 +3779,13 @@ static void sync_power_up_states(struct hda_codec *codec)
|
|||||||
|
|
||||||
for (i = 0; i < codec->num_nodes; i++, nid++) {
|
for (i = 0; i < codec->num_nodes; i++, nid++) {
|
||||||
unsigned int wcaps = get_wcaps(codec, nid);
|
unsigned int wcaps = get_wcaps(codec, nid);
|
||||||
unsigned int state, target;
|
unsigned int target;
|
||||||
if (!(wcaps & AC_WCAP_POWER))
|
if (!(wcaps & AC_WCAP_POWER))
|
||||||
continue;
|
continue;
|
||||||
target = codec->power_filter(codec, nid, AC_PWRST_D0);
|
target = codec->power_filter(codec, nid, AC_PWRST_D0);
|
||||||
if (target == AC_PWRST_D0)
|
if (target == AC_PWRST_D0)
|
||||||
continue;
|
continue;
|
||||||
state = snd_hda_codec_read(codec, nid, 0,
|
if (!snd_hda_check_power_state(codec, nid, target))
|
||||||
AC_VERB_GET_POWER_STATE, 0);
|
|
||||||
if (state & AC_PWRST_ERROR)
|
|
||||||
continue;
|
|
||||||
state = (state >> 4) & 0x0f;
|
|
||||||
if (state != target)
|
|
||||||
snd_hda_codec_write(codec, nid, 0,
|
snd_hda_codec_write(codec, nid, 0,
|
||||||
AC_VERB_SET_POWER_STATE, target);
|
AC_VERB_SET_POWER_STATE, target);
|
||||||
}
|
}
|
||||||
|
@ -657,6 +657,19 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
|
|||||||
struct hda_loopback_check *check,
|
struct hda_loopback_check *check,
|
||||||
hda_nid_t nid);
|
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
|
* AMP control callbacks
|
||||||
*/
|
*/
|
||||||
|
@ -240,10 +240,7 @@ static void set_widgets_power_state(struct hda_codec *codec)
|
|||||||
static void update_power_state(struct hda_codec *codec, hda_nid_t nid,
|
static void update_power_state(struct hda_codec *codec, hda_nid_t nid,
|
||||||
unsigned int parm)
|
unsigned int parm)
|
||||||
{
|
{
|
||||||
unsigned int state = snd_hda_codec_read(codec, nid, 0,
|
if (snd_hda_check_power_state(codec, nid, parm))
|
||||||
AC_VERB_GET_POWER_STATE, 0);
|
|
||||||
state = (state >> 4) & 0x0f;
|
|
||||||
if (state == parm)
|
|
||||||
return;
|
return;
|
||||||
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, parm);
|
snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, parm);
|
||||||
}
|
}
|
||||||
@ -253,10 +250,8 @@ static void update_conv_power_state(struct hda_codec *codec, hda_nid_t nid,
|
|||||||
{
|
{
|
||||||
struct via_spec *spec = codec->spec;
|
struct via_spec *spec = codec->spec;
|
||||||
unsigned int format;
|
unsigned int format;
|
||||||
unsigned int state = snd_hda_codec_read(codec, nid, 0,
|
|
||||||
AC_VERB_GET_POWER_STATE, 0);
|
if (snd_hda_check_power_state(codec, nid, parm))
|
||||||
state = (state >> 4) & 0x0f;
|
|
||||||
if (state == parm)
|
|
||||||
return;
|
return;
|
||||||
format = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
|
format = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
|
||||||
if (format && (spec->dac_stream_tag[index] != format))
|
if (format && (spec->dac_stream_tag[index] != format))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user