aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8510.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wm8510.c')
-rw-r--r--sound/soc/codecs/wm8510.c55
1 files changed, 21 insertions, 34 deletions
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c
index 40f8238df717..6a4cea09c45d 100644
--- a/sound/soc/codecs/wm8510.c
+++ b/sound/soc/codecs/wm8510.c
@@ -171,22 +171,6 @@ SOC_SINGLE("Capture Boost(+20dB)", WM8510_ADCBOOST, 8, 1, 0),
171SOC_SINGLE("Mono Playback Switch", WM8510_MONOMIX, 6, 1, 1), 171SOC_SINGLE("Mono Playback Switch", WM8510_MONOMIX, 6, 1, 1),
172}; 172};
173 173
174/* add non dapm controls */
175static int wm8510_add_controls(struct snd_soc_codec *codec)
176{
177 int err, i;
178
179 for (i = 0; i < ARRAY_SIZE(wm8510_snd_controls); i++) {
180 err = snd_ctl_add(codec->card,
181 snd_soc_cnew(&wm8510_snd_controls[i], codec,
182 NULL));
183 if (err < 0)
184 return err;
185 }
186
187 return 0;
188}
189
190/* Speaker Output Mixer */ 174/* Speaker Output Mixer */
191static const struct snd_kcontrol_new wm8510_speaker_mixer_controls[] = { 175static const struct snd_kcontrol_new wm8510_speaker_mixer_controls[] = {
192SOC_DAPM_SINGLE("Line Bypass Switch", WM8510_SPKMIX, 1, 1, 0), 176SOC_DAPM_SINGLE("Line Bypass Switch", WM8510_SPKMIX, 1, 1, 0),
@@ -352,7 +336,7 @@ static int wm8510_set_dai_pll(struct snd_soc_dai *codec_dai,
352 return 0; 336 return 0;
353 } 337 }
354 338
355 pll_factors(freq_out*8, freq_in); 339 pll_factors(freq_out*4, freq_in);
356 340
357 wm8510_write(codec, WM8510_PLLN, (pll_div.pre_div << 4) | pll_div.n); 341 wm8510_write(codec, WM8510_PLLN, (pll_div.pre_div << 4) | pll_div.n);
358 wm8510_write(codec, WM8510_PLLK1, pll_div.k >> 18); 342 wm8510_write(codec, WM8510_PLLK1, pll_div.k >> 18);
@@ -383,7 +367,7 @@ static int wm8510_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
383 wm8510_write(codec, WM8510_GPIO, reg | div); 367 wm8510_write(codec, WM8510_GPIO, reg | div);
384 break; 368 break;
385 case WM8510_MCLKDIV: 369 case WM8510_MCLKDIV:
386 reg = wm8510_read_reg_cache(codec, WM8510_CLOCK) & 0x1f; 370 reg = wm8510_read_reg_cache(codec, WM8510_CLOCK) & 0x11f;
387 wm8510_write(codec, WM8510_CLOCK, reg | div); 371 wm8510_write(codec, WM8510_CLOCK, reg | div);
388 break; 372 break;
389 case WM8510_ADCCLK: 373 case WM8510_ADCCLK:
@@ -468,7 +452,7 @@ static int wm8510_pcm_hw_params(struct snd_pcm_substream *substream,
468{ 452{
469 struct snd_soc_pcm_runtime *rtd = substream->private_data; 453 struct snd_soc_pcm_runtime *rtd = substream->private_data;
470 struct snd_soc_device *socdev = rtd->socdev; 454 struct snd_soc_device *socdev = rtd->socdev;
471 struct snd_soc_codec *codec = socdev->codec; 455 struct snd_soc_codec *codec = socdev->card->codec;
472 u16 iface = wm8510_read_reg_cache(codec, WM8510_IFACE) & 0x19f; 456 u16 iface = wm8510_read_reg_cache(codec, WM8510_IFACE) & 0x19f;
473 u16 adn = wm8510_read_reg_cache(codec, WM8510_ADD) & 0x1f1; 457 u16 adn = wm8510_read_reg_cache(codec, WM8510_ADD) & 0x1f1;
474 458
@@ -570,6 +554,14 @@ static int wm8510_set_bias_level(struct snd_soc_codec *codec,
570#define WM8510_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 554#define WM8510_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
571 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 555 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
572 556
557static struct snd_soc_dai_ops wm8510_dai_ops = {
558 .hw_params = wm8510_pcm_hw_params,
559 .digital_mute = wm8510_mute,
560 .set_fmt = wm8510_set_dai_fmt,
561 .set_clkdiv = wm8510_set_dai_clkdiv,
562 .set_pll = wm8510_set_dai_pll,
563};
564
573struct snd_soc_dai wm8510_dai = { 565struct snd_soc_dai wm8510_dai = {
574 .name = "WM8510 HiFi", 566 .name = "WM8510 HiFi",
575 .playback = { 567 .playback = {
@@ -584,20 +576,14 @@ struct snd_soc_dai wm8510_dai = {
584 .channels_max = 2, 576 .channels_max = 2,
585 .rates = WM8510_RATES, 577 .rates = WM8510_RATES,
586 .formats = WM8510_FORMATS,}, 578 .formats = WM8510_FORMATS,},
587 .ops = { 579 .ops = &wm8510_dai_ops,
588 .hw_params = wm8510_pcm_hw_params,
589 .digital_mute = wm8510_mute,
590 .set_fmt = wm8510_set_dai_fmt,
591 .set_clkdiv = wm8510_set_dai_clkdiv,
592 .set_pll = wm8510_set_dai_pll,
593 },
594}; 580};
595EXPORT_SYMBOL_GPL(wm8510_dai); 581EXPORT_SYMBOL_GPL(wm8510_dai);
596 582
597static int wm8510_suspend(struct platform_device *pdev, pm_message_t state) 583static int wm8510_suspend(struct platform_device *pdev, pm_message_t state)
598{ 584{
599 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 585 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
600 struct snd_soc_codec *codec = socdev->codec; 586 struct snd_soc_codec *codec = socdev->card->codec;
601 587
602 wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF); 588 wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF);
603 return 0; 589 return 0;
@@ -606,7 +592,7 @@ static int wm8510_suspend(struct platform_device *pdev, pm_message_t state)
606static int wm8510_resume(struct platform_device *pdev) 592static int wm8510_resume(struct platform_device *pdev)
607{ 593{
608 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 594 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
609 struct snd_soc_codec *codec = socdev->codec; 595 struct snd_soc_codec *codec = socdev->card->codec;
610 int i; 596 int i;
611 u8 data[2]; 597 u8 data[2];
612 u16 *cache = codec->reg_cache; 598 u16 *cache = codec->reg_cache;
@@ -628,7 +614,7 @@ static int wm8510_resume(struct platform_device *pdev)
628 */ 614 */
629static int wm8510_init(struct snd_soc_device *socdev) 615static int wm8510_init(struct snd_soc_device *socdev)
630{ 616{
631 struct snd_soc_codec *codec = socdev->codec; 617 struct snd_soc_codec *codec = socdev->card->codec;
632 int ret = 0; 618 int ret = 0;
633 619
634 codec->name = "WM8510"; 620 codec->name = "WM8510";
@@ -656,7 +642,8 @@ static int wm8510_init(struct snd_soc_device *socdev)
656 /* power on device */ 642 /* power on device */
657 codec->bias_level = SND_SOC_BIAS_OFF; 643 codec->bias_level = SND_SOC_BIAS_OFF;
658 wm8510_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 644 wm8510_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
659 wm8510_add_controls(codec); 645 snd_soc_add_controls(codec, wm8510_snd_controls,
646 ARRAY_SIZE(wm8510_snd_controls));
660 wm8510_add_widgets(codec); 647 wm8510_add_widgets(codec);
661 ret = snd_soc_init_card(socdev); 648 ret = snd_soc_init_card(socdev);
662 if (ret < 0) { 649 if (ret < 0) {
@@ -685,7 +672,7 @@ static int wm8510_i2c_probe(struct i2c_client *i2c,
685 const struct i2c_device_id *id) 672 const struct i2c_device_id *id)
686{ 673{
687 struct snd_soc_device *socdev = wm8510_socdev; 674 struct snd_soc_device *socdev = wm8510_socdev;
688 struct snd_soc_codec *codec = socdev->codec; 675 struct snd_soc_codec *codec = socdev->card->codec;
689 int ret; 676 int ret;
690 677
691 i2c_set_clientdata(i2c, codec); 678 i2c_set_clientdata(i2c, codec);
@@ -766,7 +753,7 @@ err_driver:
766static int __devinit wm8510_spi_probe(struct spi_device *spi) 753static int __devinit wm8510_spi_probe(struct spi_device *spi)
767{ 754{
768 struct snd_soc_device *socdev = wm8510_socdev; 755 struct snd_soc_device *socdev = wm8510_socdev;
769 struct snd_soc_codec *codec = socdev->codec; 756 struct snd_soc_codec *codec = socdev->card->codec;
770 int ret; 757 int ret;
771 758
772 codec->control_data = spi; 759 codec->control_data = spi;
@@ -832,7 +819,7 @@ static int wm8510_probe(struct platform_device *pdev)
832 if (codec == NULL) 819 if (codec == NULL)
833 return -ENOMEM; 820 return -ENOMEM;
834 821
835 socdev->codec = codec; 822 socdev->card->codec = codec;
836 mutex_init(&codec->mutex); 823 mutex_init(&codec->mutex);
837 INIT_LIST_HEAD(&codec->dapm_widgets); 824 INIT_LIST_HEAD(&codec->dapm_widgets);
838 INIT_LIST_HEAD(&codec->dapm_paths); 825 INIT_LIST_HEAD(&codec->dapm_paths);
@@ -862,7 +849,7 @@ static int wm8510_probe(struct platform_device *pdev)
862static int wm8510_remove(struct platform_device *pdev) 849static int wm8510_remove(struct platform_device *pdev)
863{ 850{
864 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 851 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
865 struct snd_soc_codec *codec = socdev->codec; 852 struct snd_soc_codec *codec = socdev->card->codec;
866 853
867 if (codec->control_data) 854 if (codec->control_data)
868 wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF); 855 wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF);