static void hda_power_work(struct work_struct *work);
static void hda_keep_power_on(struct hda_codec *codec);
#define hda_codec_is_power_on(codec) ((codec)->power_on)
+static inline void hda_call_pm_notify(struct hda_bus *bus, bool power_up)
+{
+ if (bus->ops.pm_notify)
+ bus->ops.pm_notify(bus, power_up);
+}
#else
static inline void hda_keep_power_on(struct hda_codec *codec) {}
#define hda_codec_is_power_on(codec) 1
+#define hda_call_pm_notify(bus, state) {}
#endif
/**
codec->bus->caddr_tbl[codec->addr] = NULL;
if (codec->patch_ops.free)
codec->patch_ops.free(codec);
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+ if (codec->power_on)
+ hda_call_pm_notify(codec->bus, false);
+#endif
module_put(codec->owner);
free_hda_cache(&codec->amp_cache);
free_hda_cache(&codec->cmd_cache);
* phase.
*/
hda_keep_power_on(codec);
+ hda_call_pm_notify(bus, true);
#endif
if (codec->bus->modelname) {
}
#ifdef CONFIG_SND_HDA_POWER_SAVE
- if ((power_state == AC_PWRST_D3)
+ if (!codec->bus->power_keep_link_on && power_state == AC_PWRST_D3
&& codec->d3_stop_clk && (state & AC_PWRST_CLK_STOP_OK))
codec->d3_stop_clk_ok = 1;
#endif
spin_unlock(&codec->power_lock);
hda_call_codec_suspend(codec);
- if (bus->ops.pm_notify)
- bus->ops.pm_notify(bus, codec);
+ if (codec->d3_stop_clk_ok)
+ hda_call_pm_notify(bus, false);
}
static void hda_keep_power_on(struct hda_codec *codec)
codec->power_transition = 1; /* avoid reentrance */
spin_unlock(&codec->power_lock);
- if (bus->ops.pm_notify)
- bus->ops.pm_notify(bus, codec);
+ if (codec->d3_stop_clk_ok) /* flag set at suspend */
+ hda_call_pm_notify(bus, true);
hda_call_codec_resume(codec);
spin_lock(&codec->power_lock);
}
#ifdef CONFIG_SND_HDA_POWER_SAVE
-static void azx_power_notify(struct hda_bus *bus, struct hda_codec *codec);
+static void azx_power_notify(struct hda_bus *bus, bool power_up);
#endif
/* reset codec link */
#ifdef CONFIG_SND_HDA_POWER_SAVE
/* power-up/down the controller */
-static void azx_power_notify(struct hda_bus *bus, struct hda_codec *codec)
+static void azx_power_notify(struct hda_bus *bus, bool power_up)
{
struct azx *chip = bus->private_data;
- if (bus->power_keep_link_on || !codec->d3_stop_clk_ok)
- return;
-
- if (codec->power_on)
+ if (power_up)
pm_runtime_get_sync(&chip->pci->dev);
else
pm_runtime_put_sync(&chip->pci->dev);
}
#endif
-static void rpm_get_all_codecs(struct azx *chip)
-{
- struct hda_codec *codec;
-
- list_for_each_entry(codec, &chip->bus->codec_list, list) {
- pm_runtime_get_noresume(&chip->pci->dev);
- }
-}
-
static int __devinit azx_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{
goto out_free;
chip->running = 1;
- rpm_get_all_codecs(chip); /* all codecs are active */
power_down_all_codecs(chip);
azx_notifier_register(chip);
azx_add_card_list(chip);