Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
ALSA: ak411x: Add PM helper functions
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Pavel Hofman <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jan 28, 2015
1 parent a850ef8 commit 1293617
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/sound/ak4113.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

8 changes: 8 additions & 0 deletions include/sound/ak4114.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

16 changes: 16 additions & 0 deletions sound/i2c/other/ak4113.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions sound/i2c/other/ak4114.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion sound/pci/ice1712/juli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1293617

Please sign in to comment.