aboutsummaryrefslogtreecommitdiffstats
path: root/sound/i2c/other/ak4114.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/i2c/other/ak4114.c')
-rw-r--r--sound/i2c/other/ak4114.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index b70e6eccbd03..5a4cf3fab4ae 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -100,6 +100,7 @@ int snd_ak4114_create(struct snd_card *card,
100 chip->private_data = private_data; 100 chip->private_data = private_data;
101 INIT_DELAYED_WORK(&chip->work, ak4114_stats); 101 INIT_DELAYED_WORK(&chip->work, ak4114_stats);
102 atomic_set(&chip->wq_processing, 0); 102 atomic_set(&chip->wq_processing, 0);
103 mutex_init(&chip->reinit_mutex);
103 104
104 for (reg = 0; reg < 6; reg++) 105 for (reg = 0; reg < 6; reg++)
105 chip->regmap[reg] = pgm[reg]; 106 chip->regmap[reg] = pgm[reg];
@@ -122,6 +123,7 @@ int snd_ak4114_create(struct snd_card *card,
122 snd_ak4114_free(chip); 123 snd_ak4114_free(chip);
123 return err < 0 ? err : -EIO; 124 return err < 0 ? err : -EIO;
124} 125}
126EXPORT_SYMBOL(snd_ak4114_create);
125 127
126void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char mask, unsigned char val) 128void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char mask, unsigned char val)
127{ 129{
@@ -131,6 +133,7 @@ void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char
131 reg_write(chip, reg, 133 reg_write(chip, reg,
132 (chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val); 134 (chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val);
133} 135}
136EXPORT_SYMBOL(snd_ak4114_reg_write);
134 137
135static void ak4114_init_regs(struct ak4114 *chip) 138static void ak4114_init_regs(struct ak4114 *chip)
136{ 139{
@@ -154,11 +157,14 @@ void snd_ak4114_reinit(struct ak4114 *chip)
154{ 157{
155 if (atomic_inc_return(&chip->wq_processing) == 1) 158 if (atomic_inc_return(&chip->wq_processing) == 1)
156 cancel_delayed_work_sync(&chip->work); 159 cancel_delayed_work_sync(&chip->work);
160 mutex_lock(&chip->reinit_mutex);
157 ak4114_init_regs(chip); 161 ak4114_init_regs(chip);
162 mutex_unlock(&chip->reinit_mutex);
158 /* bring up statistics / event queing */ 163 /* bring up statistics / event queing */
159 if (atomic_dec_and_test(&chip->wq_processing)) 164 if (atomic_dec_and_test(&chip->wq_processing))
160 schedule_delayed_work(&chip->work, HZ / 10); 165 schedule_delayed_work(&chip->work, HZ / 10);
161} 166}
167EXPORT_SYMBOL(snd_ak4114_reinit);
162 168
163static unsigned int external_rate(unsigned char rcs1) 169static unsigned int external_rate(unsigned char rcs1)
164{ 170{
@@ -503,6 +509,7 @@ int snd_ak4114_build(struct ak4114 *ak4114,
503 schedule_delayed_work(&ak4114->work, HZ / 10); 509 schedule_delayed_work(&ak4114->work, HZ / 10);
504 return 0; 510 return 0;
505} 511}
512EXPORT_SYMBOL(snd_ak4114_build);
506 513
507/* notify kcontrols if any parameters are changed */ 514/* notify kcontrols if any parameters are changed */
508static void ak4114_notify(struct ak4114 *ak4114, 515static void ak4114_notify(struct ak4114 *ak4114,
@@ -558,6 +565,7 @@ int snd_ak4114_external_rate(struct ak4114 *ak4114)
558 rcs1 = reg_read(ak4114, AK4114_REG_RCS1); 565 rcs1 = reg_read(ak4114, AK4114_REG_RCS1);
559 return external_rate(rcs1); 566 return external_rate(rcs1);
560} 567}
568EXPORT_SYMBOL(snd_ak4114_external_rate);
561 569
562int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags) 570int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags)
563{ 571{
@@ -605,6 +613,7 @@ int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags)
605 } 613 }
606 return res; 614 return res;
607} 615}
616EXPORT_SYMBOL(snd_ak4114_check_rate_and_errors);
608 617
609static void ak4114_stats(struct work_struct *work) 618static void ak4114_stats(struct work_struct *work)
610{ 619{
@@ -616,9 +625,18 @@ static void ak4114_stats(struct work_struct *work)
616 schedule_delayed_work(&chip->work, HZ / 10); 625 schedule_delayed_work(&chip->work, HZ / 10);
617} 626}
618 627
619EXPORT_SYMBOL(snd_ak4114_create); 628#ifdef CONFIG_PM
620EXPORT_SYMBOL(snd_ak4114_reg_write); 629void snd_ak4114_suspend(struct ak4114 *chip)
621EXPORT_SYMBOL(snd_ak4114_reinit); 630{
622EXPORT_SYMBOL(snd_ak4114_build); 631 atomic_inc(&chip->wq_processing); /* don't schedule new work */
623EXPORT_SYMBOL(snd_ak4114_external_rate); 632 cancel_delayed_work_sync(&chip->work);
624EXPORT_SYMBOL(snd_ak4114_check_rate_and_errors); 633}
634EXPORT_SYMBOL(snd_ak4114_suspend);
635
636void snd_ak4114_resume(struct ak4114 *chip)
637{
638 atomic_dec(&chip->wq_processing);
639 snd_ak4114_reinit(chip);
640}
641EXPORT_SYMBOL(snd_ak4114_resume);
642#endif