aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/hdaudio.h32
-rw-r--r--sound/hda/hdac_device.c30
2 files changed, 34 insertions, 28 deletions
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 30446f17c6a6..2a8aa9dfb83d 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -139,39 +139,15 @@ static inline int snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid,
139#ifdef CONFIG_PM 139#ifdef CONFIG_PM
140void snd_hdac_power_up(struct hdac_device *codec); 140void snd_hdac_power_up(struct hdac_device *codec);
141void snd_hdac_power_down(struct hdac_device *codec); 141void snd_hdac_power_down(struct hdac_device *codec);
142void snd_hdac_power_up_pm(struct hdac_device *codec);
143void snd_hdac_power_down_pm(struct hdac_device *codec);
142#else 144#else
143static inline void snd_hdac_power_up(struct hdac_device *codec) {} 145static inline void snd_hdac_power_up(struct hdac_device *codec) {}
144static inline void snd_hdac_power_down(struct hdac_device *codec) {} 146static inline void snd_hdac_power_down(struct hdac_device *codec) {}
147static inline void snd_hdac_power_up_pm(struct hdac_device *codec) {}
148static inline void snd_hdac_power_down_pm(struct hdac_device *codec) {}
145#endif 149#endif
146 150
147/**
148 * snd_hdac_power_up_pm - power up the codec
149 * @codec: the codec object
150 *
151 * This function can be called in a recursive code path like init code
152 * which may be called by PM suspend/resume again. OTOH, if a power-up
153 * call must wake up the sleeper (e.g. in a kctl callback), use
154 * snd_hdac_power_up() instead.
155 */
156static inline void snd_hdac_power_up_pm(struct hdac_device *codec)
157{
158 if (!atomic_read(&codec->in_pm))
159 snd_hdac_power_up(codec);
160}
161
162/**
163 * snd_hdac_power_down_pm - power down the codec
164 * @codec: the codec object
165 *
166 * Like snd_hdac_power_up_pm(), this function is used in a recursive
167 * code path like init code which may be called by PM suspend/resume again.
168 */
169static inline void snd_hdac_power_down_pm(struct hdac_device *codec)
170{
171 if (!atomic_read(&codec->in_pm))
172 snd_hdac_power_down(codec);
173}
174
175/* 151/*
176 * HD-audio codec base driver 152 * HD-audio codec base driver
177 */ 153 */
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index 92604bbcee5f..f75bf5622687 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -519,6 +519,36 @@ void snd_hdac_power_down(struct hdac_device *codec)
519 pm_runtime_put_autosuspend(dev); 519 pm_runtime_put_autosuspend(dev);
520} 520}
521EXPORT_SYMBOL_GPL(snd_hdac_power_down); 521EXPORT_SYMBOL_GPL(snd_hdac_power_down);
522
523/**
524 * snd_hdac_power_up_pm - power up the codec
525 * @codec: the codec object
526 *
527 * This function can be called in a recursive code path like init code
528 * which may be called by PM suspend/resume again. OTOH, if a power-up
529 * call must wake up the sleeper (e.g. in a kctl callback), use
530 * snd_hdac_power_up() instead.
531 */
532void snd_hdac_power_up_pm(struct hdac_device *codec)
533{
534 if (!atomic_inc_not_zero(&codec->in_pm))
535 snd_hdac_power_up(codec);
536}
537EXPORT_SYMBOL_GPL(snd_hdac_power_up_pm);
538
539/**
540 * snd_hdac_power_down_pm - power down the codec
541 * @codec: the codec object
542 *
543 * Like snd_hdac_power_up_pm(), this function is used in a recursive
544 * code path like init code which may be called by PM suspend/resume again.
545 */
546void snd_hdac_power_down_pm(struct hdac_device *codec)
547{
548 if (atomic_dec_if_positive(&codec->in_pm) < 0)
549 snd_hdac_power_down(codec);
550}
551EXPORT_SYMBOL_GPL(snd_hdac_power_down_pm);
522#endif 552#endif
523 553
524/* codec vendor labels */ 554/* codec vendor labels */