mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
Merge branch 'topic/ak411x-fix' into for-next
This commit is contained in:
commit
d832f3dcb6
@ -286,7 +286,8 @@ struct ak4113 {
|
||||
ak4113_write_t *write;
|
||||
ak4113_read_t *read;
|
||||
void *private_data;
|
||||
unsigned int init:1;
|
||||
atomic_t wq_processing;
|
||||
struct mutex reinit_mutex;
|
||||
spinlock_t lock;
|
||||
unsigned char regmap[AK4113_WRITABLE_REGS];
|
||||
struct snd_kcontrol *kctls[AK4113_CONTROLS];
|
||||
@ -317,5 +318,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 */
|
||||
|
||||
|
@ -168,7 +168,8 @@ struct ak4114 {
|
||||
ak4114_write_t * write;
|
||||
ak4114_read_t * read;
|
||||
void * private_data;
|
||||
unsigned int init: 1;
|
||||
atomic_t wq_processing;
|
||||
struct mutex reinit_mutex;
|
||||
spinlock_t lock;
|
||||
unsigned char regmap[6];
|
||||
unsigned char txcsb[5];
|
||||
@ -199,5 +200,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 */
|
||||
|
||||
|
@ -56,8 +56,7 @@ static inline unsigned char reg_read(struct ak4113 *ak4113, unsigned char reg)
|
||||
|
||||
static void snd_ak4113_free(struct ak4113 *chip)
|
||||
{
|
||||
chip->init = 1; /* don't schedule new work */
|
||||
mb();
|
||||
atomic_inc(&chip->wq_processing); /* don't schedule new work */
|
||||
cancel_delayed_work_sync(&chip->work);
|
||||
kfree(chip);
|
||||
}
|
||||
@ -89,6 +88,8 @@ int snd_ak4113_create(struct snd_card *card, ak4113_read_t *read,
|
||||
chip->write = write;
|
||||
chip->private_data = private_data;
|
||||
INIT_DELAYED_WORK(&chip->work, ak4113_stats);
|
||||
atomic_set(&chip->wq_processing, 0);
|
||||
mutex_init(&chip->reinit_mutex);
|
||||
|
||||
for (reg = 0; reg < AK4113_WRITABLE_REGS ; reg++)
|
||||
chip->regmap[reg] = pgm[reg];
|
||||
@ -139,13 +140,13 @@ static void ak4113_init_regs(struct ak4113 *chip)
|
||||
|
||||
void snd_ak4113_reinit(struct ak4113 *chip)
|
||||
{
|
||||
chip->init = 1;
|
||||
mb();
|
||||
flush_delayed_work(&chip->work);
|
||||
if (atomic_inc_return(&chip->wq_processing) == 1)
|
||||
cancel_delayed_work_sync(&chip->work);
|
||||
mutex_lock(&chip->reinit_mutex);
|
||||
ak4113_init_regs(chip);
|
||||
mutex_unlock(&chip->reinit_mutex);
|
||||
/* bring up statistics / event queing */
|
||||
chip->init = 0;
|
||||
if (chip->kctls[0])
|
||||
if (atomic_dec_and_test(&chip->wq_processing))
|
||||
schedule_delayed_work(&chip->work, HZ / 10);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_ak4113_reinit);
|
||||
@ -632,8 +633,25 @@ static void ak4113_stats(struct work_struct *work)
|
||||
{
|
||||
struct ak4113 *chip = container_of(work, struct ak4113, work.work);
|
||||
|
||||
if (!chip->init)
|
||||
if (atomic_inc_return(&chip->wq_processing) == 1)
|
||||
snd_ak4113_check_rate_and_errors(chip, chip->check_flags);
|
||||
|
||||
schedule_delayed_work(&chip->work, HZ / 10);
|
||||
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
|
||||
|
@ -66,8 +66,7 @@ static void reg_dump(struct ak4114 *ak4114)
|
||||
|
||||
static void snd_ak4114_free(struct ak4114 *chip)
|
||||
{
|
||||
chip->init = 1; /* don't schedule new work */
|
||||
mb();
|
||||
atomic_inc(&chip->wq_processing); /* don't schedule new work */
|
||||
cancel_delayed_work_sync(&chip->work);
|
||||
kfree(chip);
|
||||
}
|
||||
@ -100,6 +99,8 @@ int snd_ak4114_create(struct snd_card *card,
|
||||
chip->write = write;
|
||||
chip->private_data = private_data;
|
||||
INIT_DELAYED_WORK(&chip->work, ak4114_stats);
|
||||
atomic_set(&chip->wq_processing, 0);
|
||||
mutex_init(&chip->reinit_mutex);
|
||||
|
||||
for (reg = 0; reg < 6; reg++)
|
||||
chip->regmap[reg] = pgm[reg];
|
||||
@ -122,6 +123,7 @@ int snd_ak4114_create(struct snd_card *card,
|
||||
snd_ak4114_free(chip);
|
||||
return err < 0 ? err : -EIO;
|
||||
}
|
||||
EXPORT_SYMBOL(snd_ak4114_create);
|
||||
|
||||
void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char mask, unsigned char val)
|
||||
{
|
||||
@ -131,6 +133,7 @@ void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char
|
||||
reg_write(chip, reg,
|
||||
(chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val);
|
||||
}
|
||||
EXPORT_SYMBOL(snd_ak4114_reg_write);
|
||||
|
||||
static void ak4114_init_regs(struct ak4114 *chip)
|
||||
{
|
||||
@ -152,15 +155,16 @@ static void ak4114_init_regs(struct ak4114 *chip)
|
||||
|
||||
void snd_ak4114_reinit(struct ak4114 *chip)
|
||||
{
|
||||
chip->init = 1;
|
||||
mb();
|
||||
flush_delayed_work(&chip->work);
|
||||
if (atomic_inc_return(&chip->wq_processing) == 1)
|
||||
cancel_delayed_work_sync(&chip->work);
|
||||
mutex_lock(&chip->reinit_mutex);
|
||||
ak4114_init_regs(chip);
|
||||
mutex_unlock(&chip->reinit_mutex);
|
||||
/* bring up statistics / event queing */
|
||||
chip->init = 0;
|
||||
if (chip->kctls[0])
|
||||
if (atomic_dec_and_test(&chip->wq_processing))
|
||||
schedule_delayed_work(&chip->work, HZ / 10);
|
||||
}
|
||||
EXPORT_SYMBOL(snd_ak4114_reinit);
|
||||
|
||||
static unsigned int external_rate(unsigned char rcs1)
|
||||
{
|
||||
@ -505,6 +509,7 @@ int snd_ak4114_build(struct ak4114 *ak4114,
|
||||
schedule_delayed_work(&ak4114->work, HZ / 10);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(snd_ak4114_build);
|
||||
|
||||
/* notify kcontrols if any parameters are changed */
|
||||
static void ak4114_notify(struct ak4114 *ak4114,
|
||||
@ -560,6 +565,7 @@ int snd_ak4114_external_rate(struct ak4114 *ak4114)
|
||||
rcs1 = reg_read(ak4114, AK4114_REG_RCS1);
|
||||
return external_rate(rcs1);
|
||||
}
|
||||
EXPORT_SYMBOL(snd_ak4114_external_rate);
|
||||
|
||||
int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags)
|
||||
{
|
||||
@ -607,20 +613,30 @@ int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags)
|
||||
}
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(snd_ak4114_check_rate_and_errors);
|
||||
|
||||
static void ak4114_stats(struct work_struct *work)
|
||||
{
|
||||
struct ak4114 *chip = container_of(work, struct ak4114, work.work);
|
||||
|
||||
if (!chip->init)
|
||||
if (atomic_inc_return(&chip->wq_processing) == 1)
|
||||
snd_ak4114_check_rate_and_errors(chip, chip->check_flags);
|
||||
|
||||
schedule_delayed_work(&chip->work, HZ / 10);
|
||||
if (atomic_dec_and_test(&chip->wq_processing))
|
||||
schedule_delayed_work(&chip->work, HZ / 10);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(snd_ak4114_create);
|
||||
EXPORT_SYMBOL(snd_ak4114_reg_write);
|
||||
EXPORT_SYMBOL(snd_ak4114_reinit);
|
||||
EXPORT_SYMBOL(snd_ak4114_build);
|
||||
EXPORT_SYMBOL(snd_ak4114_external_rate);
|
||||
EXPORT_SYMBOL(snd_ak4114_check_rate_and_errors);
|
||||
#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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user