for (i = 0; i < path->depth; i++) {
nid = path->path[i];
+ if (!(get_wcaps(codec, nid) & AC_WCAP_POWER))
+ continue;
if (nid == codec->core.afg)
continue;
if (!allow_powerdown || is_active_nid_for_any(codec, nid))
snd_hda_codec_write(codec, nid, 0,
AC_VERB_SET_POWER_STATE, state);
changed = nid;
- /* here we assume that widget attributes (e.g. amp,
- * pinctl connection) don't change with local power
- * state change. If not, need to sync the cache.
- */
+ if (state == AC_PWRST_D0)
+ snd_hdac_regmap_sync_node(&codec->core, nid);
}
}
return changed;
return changed;
}
+/* check the jack status for power control */
+static bool detect_pin_state(struct hda_codec *codec, hda_nid_t pin)
+{
+ if (!is_jack_detectable(codec, pin))
+ return true;
+ return snd_hda_jack_detect_state(codec, pin) != HDA_JACK_NOT_PRESENT;
+}
+
/* power up/down the paths of the given pin according to the jack state;
* power = 0/1 : only power up/down if it matches with the jack state,
* < 0 : force power up/down to follow the jack sate
if (!codec->power_save_node)
return 0;
- on = snd_hda_jack_detect_state(codec, pin) != HDA_JACK_NOT_PRESENT;
+ on = detect_pin_state(codec, pin);
+
if (power >= 0 && on != power)
return 0;
return set_path_power(codec, pin, on, -1);
if (codec->power_save_node) {
bool on = !mute;
if (on)
- on = snd_hda_jack_detect_state(codec, nid)
- != HDA_JACK_NOT_PRESENT;
+ on = detect_pin_state(codec, nid);
set_path_power(codec, nid, on, -1);
}
}
hda_nid_t nid,
unsigned int power_state)
{
+ struct hda_gen_spec *spec = codec->spec;
+
+ if (!spec->power_down_unused && !codec->power_save_node)
+ return power_state;
if (power_state != AC_PWRST_D0 || nid == codec->core.afg)
return power_state;
if (get_wcaps_type(get_wcaps(codec, nid)) >= AC_WID_POWER)
parse_digital(codec);
if (spec->power_down_unused || codec->power_save_node)
- codec->power_filter = snd_hda_gen_path_power_filter;
+ if (!codec->power_filter)
+ codec->power_filter = snd_hda_gen_path_power_filter;
if (!spec->no_analog && spec->beep_nid) {
err = snd_hda_attach_beep_device(codec, spec->beep_nid);