ALSA: ak411x: Add PM helper functions
authorTakashi Iwai <tiwai@suse.de>
Tue, 13 Jan 2015 10:24:08 +0000 (11:24 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 28 Jan 2015 21:30:12 +0000 (22:30 +0100)
Define snd_ak4114_suspend() and snd_ak4114_resume() functions to
handle PM properly, stopping and restarting the work at PM.
Currently only ice1712/juli.c deals with the PM and ak4114, so fix the
calls there appropriately.

The same PM functions are defined in ak4113.c, too, although they
aren't currently called yet (ice1712/quartet.c may be enhanced to
support PM later).

Acked-by: Jaroslav Kysela <perex@perex.cz>
Tested-by: Pavel Hofman <pavel.hofman@ivitera.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/ak4113.h
include/sound/ak4114.h
sound/i2c/other/ak4113.c
sound/i2c/other/ak4114.c
sound/pci/ice1712/juli.c

index 3a34f6edc2d1ff6bb9280b3bd9b1a203c5393c68..f4fbf6888e781a7f228691f8eee9ada0c1678f41 100644 (file)
@@ -317,5 +317,13 @@ int snd_ak4113_build(struct ak4113 *ak4113,
 int snd_ak4113_external_rate(struct ak4113 *ak4113);
 int snd_ak4113_check_rate_and_errors(struct ak4113 *ak4113, unsigned int flags);
 
+#ifdef CONFIG_PM
+void snd_ak4113_suspend(struct ak4113 *chip);
+void snd_ak4113_resume(struct ak4113 *chip);
+#else
+static inline void snd_ak4113_suspend(struct ak4113 *chip) {}
+static inline void snd_ak4113_resume(struct ak4113 *chip) {}
+#endif
+
 #endif /* __SOUND_AK4113_H */
 
index 069299a88915b6f27506c06471b08a7519590e88..e681df2c95e1efc28b5a232d92479b241ca4d03b 100644 (file)
@@ -199,5 +199,13 @@ int snd_ak4114_build(struct ak4114 *ak4114,
 int snd_ak4114_external_rate(struct ak4114 *ak4114);
 int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags);
 
+#ifdef CONFIG_PM
+void snd_ak4114_suspend(struct ak4114 *chip);
+void snd_ak4114_resume(struct ak4114 *chip);
+#else
+static inline void snd_ak4114_suspend(struct ak4114 *chip) {}
+static inline void snd_ak4114_resume(struct ak4114 *chip) {}
+#endif
+
 #endif /* __SOUND_AK4114_H */
 
index c6bba99a90b285a939865eb57bd97de3d7646d31..c2b14d981fa1fb0dc3634688045148a8eaf07885 100644 (file)
@@ -636,3 +636,19 @@ static void ak4113_stats(struct work_struct *work)
        if (atomic_dec_and_test(&chip->wq_processing))
                schedule_delayed_work(&chip->work, HZ / 10);
 }
+
+#ifdef CONFIG_PM
+void snd_ak4113_suspend(struct ak4113 *chip)
+{
+       atomic_inc(&chip->wq_processing); /* don't schedule new work */
+       cancel_delayed_work_sync(&chip->work);
+}
+EXPORT_SYMBOL(snd_ak4113_suspend);
+
+void snd_ak4113_resume(struct ak4113 *chip)
+{
+       atomic_dec(&chip->wq_processing);
+       snd_ak4113_reinit(chip);
+}
+EXPORT_SYMBOL(snd_ak4113_resume);
+#endif
index f6ee1e7a9bbd169cd1d3881a5c3e673181aa2f16..ee639f57b664a88d04419429ef0fc7b91093e9d8 100644 (file)
@@ -621,3 +621,19 @@ static void ak4114_stats(struct work_struct *work)
        if (atomic_dec_and_test(&chip->wq_processing))
                schedule_delayed_work(&chip->work, HZ / 10);
 }
+
+#ifdef CONFIG_PM
+void snd_ak4114_suspend(struct ak4114 *chip)
+{
+       atomic_inc(&chip->wq_processing); /* don't schedule new work */
+       cancel_delayed_work_sync(&chip->work);
+}
+EXPORT_SYMBOL(snd_ak4114_suspend);
+
+void snd_ak4114_resume(struct ak4114 *chip)
+{
+       atomic_dec(&chip->wq_processing);
+       snd_ak4114_reinit(chip);
+}
+EXPORT_SYMBOL(snd_ak4114_resume);
+#endif
index a1536c1a7ed457c7b41d9648de55614e1edccc7c..4f0213427152afcfb389e01192ec4b8a5dfef631 100644 (file)
@@ -491,15 +491,17 @@ static int juli_resume(struct snd_ice1712 *ice)
        /* akm4358 un-reset, un-mute */
        snd_akm4xxx_reset(ak, 0);
        /* reinit ak4114 */
-       snd_ak4114_reinit(spec->ak4114);
+       snd_ak4114_resume(spec->ak4114);
        return 0;
 }
 
 static int juli_suspend(struct snd_ice1712 *ice)
 {
        struct snd_akm4xxx *ak = ice->akm;
+       struct juli_spec *spec = ice->spec;
        /* akm4358 reset and soft-mute */
        snd_akm4xxx_reset(ak, 1);
+       snd_ak4114_suspend(spec->ak4114);
        return 0;
 }
 #endif