static inline void snd_hdac_power_down(struct hdac_device *codec) {}
#endif
+/**
+ * snd_hdac_power_up_pm - power up the codec
+ * @codec: the codec object
+ *
+ * This function can be called in a recursive code path like init code
+ * which may be called by PM suspend/resume again. OTOH, if a power-up
+ * call must wake up the sleeper (e.g. in a kctl callback), use
+ * snd_hdac_power_up() instead.
+ */
+static inline void snd_hdac_power_up_pm(struct hdac_device *codec)
+{
+ if (!atomic_read(&codec->in_pm))
+ snd_hdac_power_up(codec);
+}
+
+/**
+ * snd_hdac_power_down_pm - power down the codec
+ * @codec: the codec object
+ *
+ * Like snd_hdac_power_up_pm(), this function is used in a recursive
+ * code path like init code which may be called by PM suspend/resume again.
+ */
+static inline void snd_hdac_power_down_pm(struct hdac_device *codec)
+{
+ if (!atomic_read(&codec->in_pm))
+ snd_hdac_power_down(codec);
+}
+
/*
* HD-audio codec base driver
*/
#ifdef CONFIG_PM
/**
- * snd_hdac_power_up - increment the runtime pm counter
+ * snd_hdac_power_up - power up the codec
* @codec: the codec object
+ *
+ * This function calls the runtime PM helper to power up the given codec.
+ * Unlike snd_hdac_power_up_pm(), you should call this only for the code
+ * path that isn't included in PM path. Otherwise it gets stuck.
*/
void snd_hdac_power_up(struct hdac_device *codec)
{
- struct device *dev = &codec->dev;
-
- if (atomic_read(&codec->in_pm))
- return;
- pm_runtime_get_sync(dev);
+ pm_runtime_get_sync(&codec->dev);
}
EXPORT_SYMBOL_GPL(snd_hdac_power_up);
/**
- * snd_hdac_power_up - decrement the runtime pm counter
+ * snd_hdac_power_down - power down the codec
* @codec: the codec object
*/
void snd_hdac_power_down(struct hdac_device *codec)
{
struct device *dev = &codec->dev;
- if (atomic_read(&codec->in_pm))
- return;
pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
}
err = reg_raw_write(codec, reg, val);
if (err == -EAGAIN) {
- snd_hdac_power_up(codec);
+ snd_hdac_power_up_pm(codec);
err = reg_raw_write(codec, reg, val);
- snd_hdac_power_down(codec);
+ snd_hdac_power_down_pm(codec);
}
return err;
}
err = reg_raw_read(codec, reg, val);
if (err == -EAGAIN) {
- snd_hdac_power_up(codec);
+ snd_hdac_power_up_pm(codec);
err = reg_raw_read(codec, reg, val);
- snd_hdac_power_down(codec);
+ snd_hdac_power_down_pm(codec);
}
return err;
}
return -1;
again:
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
mutex_lock(&bus->core.cmd_mutex);
if (flags & HDA_RW_NO_RESPONSE_FALLBACK)
bus->no_response_fallback = 1;
cmd, res);
bus->no_response_fallback = 0;
mutex_unlock(&bus->core.cmd_mutex);
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
if (!codec_in_pm(codec) && res && err < 0 && bus->rirb_error) {
if (bus->response_reset) {
codec_dbg(codec,
if (!(v & HDA_AMP_MUTE) && v > 0) {
if (!check->power_on) {
check->power_on = 1;
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
}
return 1;
}
}
if (check->power_on) {
check->power_on = 0;
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
}
return 0;
}
* power saving
*/
#define snd_hda_power_up(codec) snd_hdac_power_up(&(codec)->core)
+#define snd_hda_power_up_pm(codec) snd_hdac_power_up_pm(&(codec)->core)
#define snd_hda_power_down(codec) snd_hdac_power_down(&(codec)->core)
+#define snd_hda_power_down_pm(codec) snd_hdac_power_down_pm(&(codec)->core)
#ifdef CONFIG_PM
void snd_hda_set_power_save(struct hda_bus *bus, int delay);
void snd_hda_update_power_acct(struct hda_codec *codec);
codec_dbg(codec, "ca0132_select_out\n");
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
auto_jack = spec->vnode_lswitch[VNID_HP_ASEL - VNODE_START_NID];
}
exit:
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
return err < 0 ? err : 0;
}
codec_dbg(codec, "ca0132_select_mic\n");
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
auto_jack = spec->vnode_lswitch[VNID_AMIC1_ASEL - VNODE_START_NID];
ca0132_effects_set(codec, VOICE_FOCUS, 0);
}
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
return 0;
}
spec->dsp_state = DSP_DOWNLOAD_INIT;
spec->curr_chip_addx = INVALID_CHIP_ADDRESS;
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
ca0132_init_unsol(codec);
snd_hda_jack_report_sync(codec);
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
return 0;
}
bool eld_changed = false;
bool ret;
- snd_hda_power_up(codec);
+ snd_hda_power_up_pm(codec);
present = snd_hda_pin_sense(codec, pin_nid);
mutex_lock(&per_pin->lock);
jack->block_report = !ret;
mutex_unlock(&per_pin->lock);
- snd_hda_power_down(codec);
+ snd_hda_power_down_pm(codec);
return ret;
}