Commit bb682f7a authored by Cezary Rojewski's avatar Cezary Rojewski Committed by Takashi Iwai
Browse files

ALSA: hda: Expose codec cleanup and power-save functions



With few changes, snd_hda_codec_set_power_save() and
snd_hda_codec_cleanup_for_unbind() can be re-used by ASoC drivers.
While at it, provide kernel doc for the exposed functions.

Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220214101404.4074026-5-cezary.rojewski@intel.com


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 17e0c4cb
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -318,6 +318,7 @@ int snd_hda_codec_configure(struct hda_codec *codec);
int snd_hda_codec_update_widgets(struct hda_codec *codec);
void snd_hda_codec_register(struct hda_codec *codec);
void snd_hda_codec_unregister(struct hda_codec *codec);
void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec);

/*
 * low level functions
@@ -496,9 +497,11 @@ int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid)
#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_codec_set_power_save(struct hda_codec *codec, int delay);
void snd_hda_set_power_save(struct hda_bus *bus, int delay);
void snd_hda_update_power_acct(struct hda_codec *codec);
#else
static inline void snd_hda_codec_set_power_save(struct hda_codec *codec, int delay) {}
static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {}
#endif

+12 −2
Original line number Diff line number Diff line
@@ -766,6 +766,10 @@ static void codec_release_pcms(struct hda_codec *codec)
	}
}

/**
 * snd_hda_codec_cleanup_for_unbind - Prepare codec for removal
 * @codec: codec device to cleanup
 */
void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
{
	if (codec->registered) {
@@ -3401,7 +3405,12 @@ int snd_hda_add_new_ctls(struct hda_codec *codec,
EXPORT_SYMBOL_GPL(snd_hda_add_new_ctls);

#ifdef CONFIG_PM
static void codec_set_power_save(struct hda_codec *codec, int delay)
/**
 * snd_hda_codec_set_power_save - Configure codec's runtime PM
 * @codec: codec device to configure
 * @delay: autosuspend delay
 */
void snd_hda_codec_set_power_save(struct hda_codec *codec, int delay)
{
	struct device *dev = hda_codec_dev(codec);

@@ -3419,6 +3428,7 @@ static void codec_set_power_save(struct hda_codec *codec, int delay)
		pm_runtime_forbid(dev);
	}
}
EXPORT_SYMBOL_GPL(snd_hda_codec_set_power_save);

/**
 * snd_hda_set_power_save - reprogram autosuspend for the given delay
@@ -3432,7 +3442,7 @@ void snd_hda_set_power_save(struct hda_bus *bus, int delay)
	struct hda_codec *c;

	list_for_each_codec(c, bus)
		codec_set_power_save(c, delay);
		snd_hda_codec_set_power_save(c, delay);
}
EXPORT_SYMBOL_GPL(snd_hda_set_power_save);

+0 −1
Original line number Diff line number Diff line
@@ -135,7 +135,6 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
#define snd_hda_add_vmaster(codec, name, tlv, followers, suffix, access) \
	__snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, access, NULL)
int snd_hda_codec_reset(struct hda_codec *codec);
void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec);
void snd_hda_codec_disconnect_pcms(struct hda_codec *codec);

#define snd_hda_regmap_sync(codec)	snd_hdac_regmap_sync(&(codec)->core)