diff options
author | Seungwhan Youn <sw.youn@samsung.com> | 2010-05-27 05:13:48 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-05-31 07:08:33 -0400 |
commit | 3a642915ada4b7df9440a7bbed35cea94a5ccfe0 (patch) | |
tree | 867acc1fdb978a18f27c8997252470e62be31460 /sound/soc/codecs | |
parent | e37c83c06c2690157a989df40dc99a6b61c9ea15 (diff) |
ASoC: spdif: Add codec driver to use spdif stand-alone
This patch adds spdif dummy codec driver for using spdif-dit as
a stand-alone. Until this, spdif-dit can be used only with other
codecs like tlv320aci3x in davinci platform.
Signed-off-by: Seungwhan Youn <sw.youn@samsung.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/spdif_transciever.c | 93 |
1 files changed, 92 insertions, 1 deletions
diff --git a/sound/soc/codecs/spdif_transciever.c b/sound/soc/codecs/spdif_transciever.c index a63191141052..f0945ab2002e 100644 --- a/sound/soc/codecs/spdif_transciever.c +++ b/sound/soc/codecs/spdif_transciever.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/moduleparam.h> | 18 | #include <linux/moduleparam.h> |
19 | #include <sound/soc.h> | 19 | #include <sound/soc.h> |
20 | #include <sound/pcm.h> | 20 | #include <sound/pcm.h> |
21 | #include <sound/initval.h> | ||
21 | 22 | ||
22 | #include "spdif_transciever.h" | 23 | #include "spdif_transciever.h" |
23 | 24 | ||
@@ -26,6 +27,48 @@ MODULE_LICENSE("GPL"); | |||
26 | #define STUB_RATES SNDRV_PCM_RATE_8000_96000 | 27 | #define STUB_RATES SNDRV_PCM_RATE_8000_96000 |
27 | #define STUB_FORMATS SNDRV_PCM_FMTBIT_S16_LE | 28 | #define STUB_FORMATS SNDRV_PCM_FMTBIT_S16_LE |
28 | 29 | ||
30 | static struct snd_soc_codec *spdif_dit_codec; | ||
31 | |||
32 | static int spdif_dit_codec_probe(struct platform_device *pdev) | ||
33 | { | ||
34 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
35 | struct snd_soc_codec *codec; | ||
36 | int ret; | ||
37 | |||
38 | if (spdif_dit_codec == NULL) { | ||
39 | dev_err(&pdev->dev, "Codec device not registered\n"); | ||
40 | return -ENODEV; | ||
41 | } | ||
42 | |||
43 | socdev->card->codec = spdif_dit_codec; | ||
44 | codec = spdif_dit_codec; | ||
45 | |||
46 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
47 | if (ret < 0) { | ||
48 | dev_err(codec->dev, "failed to create pcms: %d\n", ret); | ||
49 | goto err_create_pcms; | ||
50 | } | ||
51 | |||
52 | return 0; | ||
53 | |||
54 | err_create_pcms: | ||
55 | return ret; | ||
56 | } | ||
57 | |||
58 | static int spdif_dit_codec_remove(struct platform_device *pdev) | ||
59 | { | ||
60 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
61 | |||
62 | snd_soc_free_pcms(socdev); | ||
63 | |||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | struct snd_soc_codec_device soc_codec_dev_spdif_dit = { | ||
68 | .probe = spdif_dit_codec_probe, | ||
69 | .remove = spdif_dit_codec_remove, | ||
70 | }; EXPORT_SYMBOL_GPL(soc_codec_dev_spdif_dit); | ||
71 | |||
29 | struct snd_soc_dai dit_stub_dai = { | 72 | struct snd_soc_dai dit_stub_dai = { |
30 | .name = "DIT", | 73 | .name = "DIT", |
31 | .playback = { | 74 | .playback = { |
@@ -40,13 +83,61 @@ EXPORT_SYMBOL_GPL(dit_stub_dai); | |||
40 | 83 | ||
41 | static int spdif_dit_probe(struct platform_device *pdev) | 84 | static int spdif_dit_probe(struct platform_device *pdev) |
42 | { | 85 | { |
86 | struct snd_soc_codec *codec; | ||
87 | int ret; | ||
88 | |||
89 | if (spdif_dit_codec) { | ||
90 | dev_err(&pdev->dev, "Another Codec is registered\n"); | ||
91 | ret = -EINVAL; | ||
92 | goto err_reg_codec; | ||
93 | } | ||
94 | |||
95 | codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); | ||
96 | if (codec == NULL) | ||
97 | return -ENOMEM; | ||
98 | |||
99 | codec->dev = &pdev->dev; | ||
100 | |||
101 | mutex_init(&codec->mutex); | ||
102 | |||
103 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
104 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
105 | |||
106 | codec->name = "spdif-dit"; | ||
107 | codec->owner = THIS_MODULE; | ||
108 | codec->dai = &dit_stub_dai; | ||
109 | codec->num_dai = 1; | ||
110 | |||
111 | spdif_dit_codec = codec; | ||
112 | |||
113 | ret = snd_soc_register_codec(codec); | ||
114 | if (ret < 0) { | ||
115 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | ||
116 | goto err_reg_codec; | ||
117 | } | ||
118 | |||
43 | dit_stub_dai.dev = &pdev->dev; | 119 | dit_stub_dai.dev = &pdev->dev; |
44 | return snd_soc_register_dai(&dit_stub_dai); | 120 | ret = snd_soc_register_dai(&dit_stub_dai); |
121 | if (ret < 0) { | ||
122 | dev_err(codec->dev, "Failed to register dai: %d\n", ret); | ||
123 | goto err_reg_dai; | ||
124 | } | ||
125 | |||
126 | return 0; | ||
127 | |||
128 | err_reg_dai: | ||
129 | snd_soc_unregister_codec(codec); | ||
130 | err_reg_codec: | ||
131 | kfree(spdif_dit_codec); | ||
132 | return ret; | ||
45 | } | 133 | } |
46 | 134 | ||
47 | static int spdif_dit_remove(struct platform_device *pdev) | 135 | static int spdif_dit_remove(struct platform_device *pdev) |
48 | { | 136 | { |
49 | snd_soc_unregister_dai(&dit_stub_dai); | 137 | snd_soc_unregister_dai(&dit_stub_dai); |
138 | snd_soc_unregister_codec(spdif_dit_codec); | ||
139 | kfree(spdif_dit_codec); | ||
140 | spdif_dit_codec = NULL; | ||
50 | return 0; | 141 | return 0; |
51 | } | 142 | } |
52 | 143 | ||