asoc: codecs: spdif: Add support for setting bias level
[linux-2.6.git] / sound / soc / codecs / spdif_transciever.c
1 /*
2  * ALSA SoC SPDIF DIT driver
3  *
4  *  This driver is used by controllers which can operate in DIT (SPDI/F) where
5  *  no codec is needed.  This file provides stub codec that can be used
6  *  in these configurations. TI DaVinci Audio controller uses this driver.
7  *
8  * Author:      Steve Chen,  <schen@mvista.com>
9  * Copyright:   (C) 2009 MontaVista Software, Inc., <source@mvista.com>
10  * Copyright:   (C) 2009  Texas Instruments, India
11  * Copyright:   (C) 2009-2012, NVIDIA Corporation.
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License version 2 as
15  * published by the Free Software Foundation.
16  */
17
18
19 #include <asm/mach-types.h>
20 #include <linux/module.h>
21 #include <linux/moduleparam.h>
22 #include <linux/slab.h>
23 #include <sound/soc.h>
24 #include <sound/pcm.h>
25 #include <sound/initval.h>
26
27 #define DRV_NAME "spdif-dit"
28
29 #define STUB_RATES      SNDRV_PCM_RATE_8000_96000
30 #define STUB_FORMATS    SNDRV_PCM_FMTBIT_S16_LE
31
32 static struct snd_soc_codec_driver soc_codec_spdif_dit;
33
34 static int spdif_probe(struct snd_soc_codec *codec) {
35         codec->dapm.idle_bias_off = 1;
36         return 0;
37 }
38
39 static const struct snd_soc_dapm_widget spdif_dapm_widgets[] = {
40         SND_SOC_DAPM_VMID("spdif dummy Vmid"),
41 };
42
43 static int spdif_write(struct snd_soc_codec * codec, unsigned int reg,
44                                                         unsigned int val){
45         return 0;
46 }
47
48 static int spdif_read(struct snd_soc_codec * codec, unsigned int reg){
49         return 0;
50 }
51
52 static struct snd_soc_codec_driver soc_codec_spdif_dit1 = {
53         .probe = spdif_probe,
54         .dapm_widgets = spdif_dapm_widgets,
55         .num_dapm_widgets = ARRAY_SIZE(spdif_dapm_widgets),
56         .read = spdif_read,
57         .write = spdif_write,
58 };
59
60 static struct snd_soc_dai_driver dit_stub_dai = {
61         .name           = "dit-hifi",
62         .playback       = {
63                 .stream_name    = "Playback",
64                 .channels_min   = 1,
65                 .channels_max   = 384,
66                 .rates          = STUB_RATES,
67                 .formats        = STUB_FORMATS,
68         },
69         .capture        = {
70                 .stream_name    = "Capture",
71                 .channels_min   = 1,
72                 .channels_max   = 384,
73                 .rates          = STUB_RATES,
74                 .formats        = STUB_FORMATS,
75         },
76 };
77
78 static int spdif_dit_probe(struct platform_device *pdev)
79 {
80         if(machine_is_kai() || machine_is_tegra_enterprise())
81                 return snd_soc_register_codec(&pdev->dev,
82                         &soc_codec_spdif_dit1, &dit_stub_dai, 1);
83         else
84                 return snd_soc_register_codec(&pdev->dev,
85                          &soc_codec_spdif_dit, &dit_stub_dai, 1);
86 }
87
88 static int spdif_dit_remove(struct platform_device *pdev)
89 {
90         snd_soc_unregister_codec(&pdev->dev);
91         return 0;
92 }
93
94 static struct platform_driver spdif_dit_driver = {
95         .probe          = spdif_dit_probe,
96         .remove         = spdif_dit_remove,
97         .driver         = {
98                 .name   = DRV_NAME,
99                 .owner  = THIS_MODULE,
100         },
101 };
102
103 static int __init dit_modinit(void)
104 {
105         return platform_driver_register(&spdif_dit_driver);
106 }
107
108 static void __exit dit_exit(void)
109 {
110         platform_driver_unregister(&spdif_dit_driver);
111 }
112
113 module_init(dit_modinit);
114 module_exit(dit_exit);
115
116 MODULE_AUTHOR("Steve Chen <schen@mvista.com>");
117 MODULE_DESCRIPTION("SPDIF dummy codec driver");
118 MODULE_LICENSE("GPL");
119 MODULE_ALIAS("platform:" DRV_NAME);