~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to sound/soc/codecs/wm8510.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
SOC_SINGLE("Mono Playback Switch", WM8510_MONOMIX, 6, 1, 1),
172
172
};
173
173
 
174
 
/* add non dapm controls */
175
 
static 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
174
/* Speaker Output Mixer */
191
175
static const struct snd_kcontrol_new wm8510_speaker_mixer_controls[] = {
192
176
SOC_DAPM_SINGLE("Line Bypass Switch", WM8510_SPKMIX, 1, 1, 0),
314
298
 
315
299
        if ((Ndiv < 6) || (Ndiv > 12))
316
300
                printk(KERN_WARNING
317
 
                        "WM8510 N value %d outwith recommended range!d\n",
 
301
                        "WM8510 N value %u outwith recommended range!d\n",
318
302
                        Ndiv);
319
303
 
320
304
        pll_div.n = Ndiv;
352
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
341
        wm8510_write(codec, WM8510_PLLN, (pll_div.pre_div << 4) | pll_div.n);
358
342
        wm8510_write(codec, WM8510_PLLK1, pll_div.k >> 18);
383
367
                wm8510_write(codec, WM8510_GPIO, reg | div);
384
368
                break;
385
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
371
                wm8510_write(codec, WM8510_CLOCK, reg | div);
388
372
                break;
389
373
        case WM8510_ADCCLK:
468
452
{
469
453
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
470
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
456
        u16 iface = wm8510_read_reg_cache(codec, WM8510_IFACE) & 0x19f;
473
457
        u16 adn = wm8510_read_reg_cache(codec, WM8510_ADD) & 0x1f1;
474
458
 
570
554
#define WM8510_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
571
555
        SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
572
556
 
 
557
static 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
 
573
565
struct snd_soc_dai wm8510_dai = {
574
566
        .name = "WM8510 HiFi",
575
567
        .playback = {
584
576
                .channels_max = 2,
585
577
                .rates = WM8510_RATES,
586
578
                .formats = WM8510_FORMATS,},
587
 
        .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
 
        },
 
579
        .ops = &wm8510_dai_ops,
594
580
};
595
581
EXPORT_SYMBOL_GPL(wm8510_dai);
596
582
 
597
583
static int wm8510_suspend(struct platform_device *pdev, pm_message_t state)
598
584
{
599
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
588
        wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF);
603
589
        return 0;
606
592
static int wm8510_resume(struct platform_device *pdev)
607
593
{
608
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
596
        int i;
611
597
        u8 data[2];
612
598
        u16 *cache = codec->reg_cache;
628
614
 */
629
615
static 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
618
        int ret = 0;
633
619
 
634
620
        codec->name = "WM8510";
656
642
        /* power on device */
657
643
        codec->bias_level = SND_SOC_BIAS_OFF;
658
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
647
        wm8510_add_widgets(codec);
661
648
        ret = snd_soc_init_card(socdev);
662
649
        if (ret < 0) {
685
672
                            const struct i2c_device_id *id)
686
673
{
687
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
676
        int ret;
690
677
 
691
678
        i2c_set_clientdata(i2c, codec);
766
753
static int __devinit wm8510_spi_probe(struct spi_device *spi)
767
754
{
768
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
757
        int ret;
771
758
 
772
759
        codec->control_data = spi;
832
819
        if (codec == NULL)
833
820
                return -ENOMEM;
834
821
 
835
 
        socdev->codec = codec;
 
822
        socdev->card->codec = codec;
836
823
        mutex_init(&codec->mutex);
837
824
        INIT_LIST_HEAD(&codec->dapm_widgets);
838
825
        INIT_LIST_HEAD(&codec->dapm_paths);
862
849
static int wm8510_remove(struct platform_device *pdev)
863
850
{
864
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
854
        if (codec->control_data)
868
855
                wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF);