aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/tlv320aic26.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-09-25 08:14:41 -0400
committerMark Brown <broonie@linaro.org>2013-09-25 08:30:59 -0400
commit5b0959d472c215e6d712ac47e64110bd125ddd07 (patch)
tree9623fca8f2a2219cf37de7c7855466dae40b0bd2 /sound/soc/codecs/tlv320aic26.c
parent806955dd9cf071ecd99acbaa8c73ae1f34dcf83d (diff)
ASoC: tlv320aic26: Use snd_soc_update_bits()
Use snd_soc_update_bits() rather than open coding. Since the register cache is currently only used where update_bits() is used this means the current register cache can be removed entirely. Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/codecs/tlv320aic26.c')
-rw-r--r--sound/soc/codecs/tlv320aic26.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
index 32c6b0768e56..4d8244750f23 100644
--- a/sound/soc/codecs/tlv320aic26.c
+++ b/sound/soc/codecs/tlv320aic26.c
@@ -74,19 +74,6 @@ static unsigned int aic26_reg_read(struct snd_soc_codec *codec,
74 return value; 74 return value;
75} 75}
76 76
77static unsigned int aic26_reg_read_cache(struct snd_soc_codec *codec,
78 unsigned int reg)
79{
80 u16 *cache = codec->reg_cache;
81
82 if (reg >= AIC26_NUM_REGS) {
83 WARN_ON_ONCE(1);
84 return 0;
85 }
86
87 return cache[reg];
88}
89
90static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg, 77static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg,
91 unsigned int value) 78 unsigned int value)
92{ 79{
@@ -195,19 +182,15 @@ static int aic26_hw_params(struct snd_pcm_substream *substream,
195 snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); 182 snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg);
196 183
197 /* Audio Control 3 (master mode, fsref rate) */ 184 /* Audio Control 3 (master mode, fsref rate) */
198 reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL3);
199 reg &= ~0xf800;
200 if (aic26->master) 185 if (aic26->master)
201 reg |= 0x0800; 186 reg = 0x0800;
202 if (fsref == 48000) 187 if (fsref == 48000)
203 reg |= 0x2000; 188 reg = 0x2000;
204 snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); 189 snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg);
205 190
206 /* Audio Control 1 (FSref divisor) */ 191 /* Audio Control 1 (FSref divisor) */
207 reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL1); 192 reg = wlen | aic26->datfm | (divisor << 3) | divisor;
208 reg &= ~0x0fff; 193 snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg);
209 reg |= wlen | aic26->datfm | (divisor << 3) | divisor;
210 snd_soc_write(codec, AIC26_REG_AUDIO_CTRL1, reg);
211 194
212 return 0; 195 return 0;
213} 196}
@@ -219,16 +202,16 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute)
219{ 202{
220 struct snd_soc_codec *codec = dai->codec; 203 struct snd_soc_codec *codec = dai->codec;
221 struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); 204 struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec);
222 u16 reg = aic26_reg_read_cache(codec, AIC26_REG_DAC_GAIN); 205 u16 reg;
223 206
224 dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", 207 dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n",
225 dai, mute); 208 dai, mute);
226 209
227 if (mute) 210 if (mute)
228 reg |= 0x8080; 211 reg = 0x8080;
229 else 212 else
230 reg &= ~0x8080; 213 reg = 0;
231 snd_soc_write(codec, AIC26_REG_DAC_GAIN, reg); 214 snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg);
232 215
233 return 0; 216 return 0;
234} 217}
@@ -346,7 +329,7 @@ static ssize_t aic26_keyclick_show(struct device *dev,
346 struct aic26 *aic26 = dev_get_drvdata(dev); 329 struct aic26 *aic26 = dev_get_drvdata(dev);
347 int val, amp, freq, len; 330 int val, amp, freq, len;
348 331
349 val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); 332 val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2);
350 amp = (val >> 12) & 0x7; 333 amp = (val >> 12) & 0x7;
351 freq = (125 << ((val >> 8) & 0x7)) >> 1; 334 freq = (125 << ((val >> 8) & 0x7)) >> 1;
352 len = 2 * (1 + ((val >> 4) & 0xf)); 335 len = 2 * (1 + ((val >> 4) & 0xf));
@@ -360,11 +343,9 @@ static ssize_t aic26_keyclick_set(struct device *dev,
360 const char *buf, size_t count) 343 const char *buf, size_t count)
361{ 344{
362 struct aic26 *aic26 = dev_get_drvdata(dev); 345 struct aic26 *aic26 = dev_get_drvdata(dev);
363 int val;
364 346
365 val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); 347 snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2,
366 val |= 0x8000; 348 0x8000, 0x800);
367 snd_soc_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val);
368 349
369 return count; 350 return count;
370} 351}
@@ -377,7 +358,7 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
377static int aic26_probe(struct snd_soc_codec *codec) 358static int aic26_probe(struct snd_soc_codec *codec)
378{ 359{
379 struct aic26 *aic26 = dev_get_drvdata(codec->dev); 360 struct aic26 *aic26 = dev_get_drvdata(codec->dev);
380 int ret, i, reg; 361 int ret, reg;
381 362
382 aic26->codec = codec; 363 aic26->codec = codec;
383 364
@@ -393,10 +374,6 @@ static int aic26_probe(struct snd_soc_codec *codec)
393 reg |= 0x0800; /* set master mode */ 374 reg |= 0x0800; /* set master mode */
394 snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); 375 snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg);
395 376
396 /* Fill register cache */
397 for (i = 0; i < codec->driver->reg_cache_size; i++)
398 snd_soc_read(codec, i);
399
400 /* Register the sysfs files for debugging */ 377 /* Register the sysfs files for debugging */
401 /* Create SysFS files */ 378 /* Create SysFS files */
402 ret = device_create_file(codec->dev, &dev_attr_keyclick); 379 ret = device_create_file(codec->dev, &dev_attr_keyclick);
@@ -410,8 +387,6 @@ static struct snd_soc_codec_driver aic26_soc_codec_dev = {
410 .probe = aic26_probe, 387 .probe = aic26_probe,
411 .read = aic26_reg_read, 388 .read = aic26_reg_read,
412 .write = aic26_reg_write, 389 .write = aic26_reg_write,
413 .reg_cache_size = AIC26_NUM_REGS,
414 .reg_word_size = sizeof(u16),
415 .controls = aic26_snd_controls, 390 .controls = aic26_snd_controls,
416 .num_controls = ARRAY_SIZE(aic26_snd_controls), 391 .num_controls = ARRAY_SIZE(aic26_snd_controls),
417 .dapm_widgets = tlv320aic26_dapm_widgets, 392 .dapm_widgets = tlv320aic26_dapm_widgets,