Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: sound/soc/codecs/ad193x.c

Issue 6577007: CHROMIUM: ASoC: Import entire upstream ASoC tree (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sound/soc/codecs/ad1836.c ('k') | sound/soc/codecs/ad1980.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * AD193X Audio Codec driver supporting AD1936/7/8/9 2 * AD193X Audio Codec driver supporting AD1936/7/8/9
3 * 3 *
4 * Copyright 2010 Analog Devices Inc. 4 * Copyright 2010 Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
8 8
9 #include <linux/init.h> 9 #include <linux/init.h>
10 #include <linux/module.h> 10 #include <linux/module.h>
11 #include <linux/kernel.h> 11 #include <linux/kernel.h>
12 #include <linux/device.h> 12 #include <linux/device.h>
13 #include <linux/i2c.h> 13 #include <linux/i2c.h>
14 #include <linux/spi/spi.h> 14 #include <linux/spi/spi.h>
15 #include <linux/slab.h> 15 #include <linux/slab.h>
16 #include <sound/core.h> 16 #include <sound/core.h>
17 #include <sound/pcm.h> 17 #include <sound/pcm.h>
18 #include <sound/pcm_params.h> 18 #include <sound/pcm_params.h>
19 #include <sound/initval.h> 19 #include <sound/initval.h>
20 #include <sound/soc.h> 20 #include <sound/soc.h>
21 #include <sound/tlv.h> 21 #include <sound/tlv.h>
22 #include <sound/soc-dapm.h>
23 #include "ad193x.h" 22 #include "ad193x.h"
24 23
25 /* codec private data */ 24 /* codec private data */
26 struct ad193x_priv { 25 struct ad193x_priv {
27 u8 reg_cache[AD193X_NUM_REGS];
28 enum snd_soc_control_type bus_type; 26 enum snd_soc_control_type bus_type;
29 void *control_data; 27 void *control_data;
30 int sysclk; 28 int sysclk;
31 }; 29 };
32 30
33 /* ad193x register cache & default register settings */ 31 /* ad193x register cache & default register settings */
34 static const u8 ad193x_reg[AD193X_NUM_REGS] = { 32 static const u8 ad193x_reg[AD193X_NUM_REGS] = {
35 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 33 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0,
36 }; 34 };
37 35
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 .rates = SNDRV_PCM_RATE_48000, 344 .rates = SNDRV_PCM_RATE_48000,
347 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | 345 .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE |
348 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, 346 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
349 }, 347 },
350 .ops = &ad193x_dai_ops, 348 .ops = &ad193x_dai_ops,
351 }; 349 };
352 350
353 static int ad193x_probe(struct snd_soc_codec *codec) 351 static int ad193x_probe(struct snd_soc_codec *codec)
354 { 352 {
355 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); 353 struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec);
354 struct snd_soc_dapm_context *dapm = &codec->dapm;
356 int ret; 355 int ret;
357 356
358 codec->control_data = ad193x->control_data; 357 codec->control_data = ad193x->control_data;
359 if (ad193x->bus_type == SND_SOC_I2C) 358 if (ad193x->bus_type == SND_SOC_I2C)
360 ret = snd_soc_codec_set_cache_io(codec, 8, 8, ad193x->bus_type); 359 ret = snd_soc_codec_set_cache_io(codec, 8, 8, ad193x->bus_type);
361 else 360 else
362 ret = snd_soc_codec_set_cache_io(codec, 16, 8, ad193x->bus_type) ; 361 ret = snd_soc_codec_set_cache_io(codec, 16, 8, ad193x->bus_type) ;
363 if (ret < 0) { 362 if (ret < 0) {
364 dev_err(codec->dev, "failed to set cache I/O: %d\n", 363 dev_err(codec->dev, "failed to set cache I/O: %d\n",
365 ret); 364 ret);
366 kfree(ad193x);
367 return ret; 365 return ret;
368 } 366 }
369 367
370 /* default setting for ad193x */ 368 /* default setting for ad193x */
371 369
372 /* unmute dac channels */ 370 /* unmute dac channels */
373 snd_soc_write(codec, AD193X_DAC_CHNL_MUTE, 0x0); 371 snd_soc_write(codec, AD193X_DAC_CHNL_MUTE, 0x0);
374 /* de-emphasis: 48kHz, powedown dac */ 372 /* de-emphasis: 48kHz, powedown dac */
375 snd_soc_write(codec, AD193X_DAC_CTRL2, 0x1A); 373 snd_soc_write(codec, AD193X_DAC_CTRL2, 0x1A);
376 /* powerdown dac, dac in tdm mode */ 374 /* powerdown dac, dac in tdm mode */
377 snd_soc_write(codec, AD193X_DAC_CTRL0, 0x41); 375 snd_soc_write(codec, AD193X_DAC_CTRL0, 0x41);
378 /* high-pass filter enable */ 376 /* high-pass filter enable */
379 snd_soc_write(codec, AD193X_ADC_CTRL0, 0x3); 377 snd_soc_write(codec, AD193X_ADC_CTRL0, 0x3);
380 /* sata delay=1, adc aux mode */ 378 /* sata delay=1, adc aux mode */
381 snd_soc_write(codec, AD193X_ADC_CTRL1, 0x43); 379 snd_soc_write(codec, AD193X_ADC_CTRL1, 0x43);
382 /* pll input: mclki/xi */ 380 /* pll input: mclki/xi */
383 snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9 D; mclk=12.288Mhz: 0x99 */ 381 snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9 D; mclk=12.288Mhz: 0x99 */
384 snd_soc_write(codec, AD193X_PLL_CLK_CTRL1, 0x04); 382 snd_soc_write(codec, AD193X_PLL_CLK_CTRL1, 0x04);
385 383
386 snd_soc_add_controls(codec, ad193x_snd_controls, 384 snd_soc_add_controls(codec, ad193x_snd_controls,
387 ARRAY_SIZE(ad193x_snd_controls)); 385 ARRAY_SIZE(ad193x_snd_controls));
388 » snd_soc_dapm_new_controls(codec, ad193x_dapm_widgets, 386 » snd_soc_dapm_new_controls(dapm, ad193x_dapm_widgets,
389 ARRAY_SIZE(ad193x_dapm_widgets)); 387 ARRAY_SIZE(ad193x_dapm_widgets));
390 » snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); 388 » snd_soc_dapm_add_routes(dapm, audio_paths, ARRAY_SIZE(audio_paths));
391 389
392 return ret; 390 return ret;
393 } 391 }
394 392
395 static struct snd_soc_codec_driver soc_codec_dev_ad193x = { 393 static struct snd_soc_codec_driver soc_codec_dev_ad193x = {
396 .probe = ad193x_probe, 394 .probe = ad193x_probe,
397 .reg_cache_default = ad193x_reg, 395 .reg_cache_default = ad193x_reg,
398 .reg_cache_size = AD193X_NUM_REGS, 396 .reg_cache_size = AD193X_NUM_REGS,
399 .reg_word_size = sizeof(u16), 397 .reg_word_size = sizeof(u16),
400 }; 398 };
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 512
515 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 513 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
516 i2c_del_driver(&ad193x_i2c_driver); 514 i2c_del_driver(&ad193x_i2c_driver);
517 #endif 515 #endif
518 } 516 }
519 module_exit(ad193x_modexit); 517 module_exit(ad193x_modexit);
520 518
521 MODULE_DESCRIPTION("ASoC ad193x driver"); 519 MODULE_DESCRIPTION("ASoC ad193x driver");
522 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); 520 MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
523 MODULE_LICENSE("GPL"); 521 MODULE_LICENSE("GPL");
OLDNEW
« no previous file with comments | « sound/soc/codecs/ad1836.c ('k') | sound/soc/codecs/ad1980.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698