aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/pcm3008.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/pcm3008.c')
-rw-r--r--sound/soc/codecs/pcm3008.c92
1 files changed, 38 insertions, 54 deletions
diff --git a/sound/soc/codecs/pcm3008.c b/sound/soc/codecs/pcm3008.c
index 5a5f187a2657..bd8f26e41602 100644
--- a/sound/soc/codecs/pcm3008.c
+++ b/sound/soc/codecs/pcm3008.c
@@ -32,8 +32,8 @@
32#define PCM3008_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ 32#define PCM3008_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
33 SNDRV_PCM_RATE_48000) 33 SNDRV_PCM_RATE_48000)
34 34
35struct snd_soc_dai pcm3008_dai = { 35static struct snd_soc_dai_driver pcm3008_dai = {
36 .name = "PCM3008 HiFi", 36 .name = "pcm3008-hifi",
37 .playback = { 37 .playback = {
38 .stream_name = "PCM3008 Playback", 38 .stream_name = "PCM3008 Playback",
39 .channels_min = 1, 39 .channels_min = 1,
@@ -49,7 +49,6 @@ struct snd_soc_dai pcm3008_dai = {
49 .formats = SNDRV_PCM_FMTBIT_S16_LE, 49 .formats = SNDRV_PCM_FMTBIT_S16_LE,
50 }, 50 },
51}; 51};
52EXPORT_SYMBOL_GPL(pcm3008_dai);
53 52
54static void pcm3008_gpio_free(struct pcm3008_setup_data *setup) 53static void pcm3008_gpio_free(struct pcm3008_setup_data *setup)
55{ 54{
@@ -59,38 +58,13 @@ static void pcm3008_gpio_free(struct pcm3008_setup_data *setup)
59 gpio_free(setup->pdda_pin); 58 gpio_free(setup->pdda_pin);
60} 59}
61 60
62static int pcm3008_soc_probe(struct platform_device *pdev) 61static int pcm3008_soc_probe(struct snd_soc_codec *codec)
63{ 62{
64 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 63 struct pcm3008_setup_data *setup = codec->dev->platform_data;
65 struct snd_soc_codec *codec;
66 struct pcm3008_setup_data *setup = socdev->codec_data;
67 int ret = 0; 64 int ret = 0;
68 65
69 printk(KERN_INFO "PCM3008 SoC Audio Codec %s\n", PCM3008_VERSION); 66 printk(KERN_INFO "PCM3008 SoC Audio Codec %s\n", PCM3008_VERSION);
70 67
71 socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
72 if (!socdev->card->codec)
73 return -ENOMEM;
74
75 codec = socdev->card->codec;
76 mutex_init(&codec->mutex);
77
78 codec->name = "PCM3008";
79 codec->owner = THIS_MODULE;
80 codec->dai = &pcm3008_dai;
81 codec->num_dai = 1;
82 codec->write = NULL;
83 codec->read = NULL;
84 INIT_LIST_HEAD(&codec->dapm_widgets);
85 INIT_LIST_HEAD(&codec->dapm_paths);
86
87 /* Register PCMs. */
88 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
89 if (ret < 0) {
90 printk(KERN_ERR "pcm3008: failed to create pcms\n");
91 goto pcm_err;
92 }
93
94 /* DEM1 DEM0 DE-EMPHASIS_MODE 68 /* DEM1 DEM0 DE-EMPHASIS_MODE
95 * Low Low De-emphasis 44.1 kHz ON 69 * Low Low De-emphasis 44.1 kHz ON
96 * Low High De-emphasis OFF 70 * Low High De-emphasis OFF
@@ -130,33 +104,22 @@ static int pcm3008_soc_probe(struct platform_device *pdev)
130 104
131gpio_err: 105gpio_err:
132 pcm3008_gpio_free(setup); 106 pcm3008_gpio_free(setup);
133pcm_err:
134 kfree(socdev->card->codec);
135 107
136 return ret; 108 return ret;
137} 109}
138 110
139static int pcm3008_soc_remove(struct platform_device *pdev) 111static int pcm3008_soc_remove(struct snd_soc_codec *codec)
140{ 112{
141 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 113 struct pcm3008_setup_data *setup = codec->dev->platform_data;
142 struct snd_soc_codec *codec = socdev->card->codec;
143 struct pcm3008_setup_data *setup = socdev->codec_data;
144
145 if (!codec)
146 return 0;
147 114
148 pcm3008_gpio_free(setup); 115 pcm3008_gpio_free(setup);
149 snd_soc_free_pcms(socdev);
150 kfree(socdev->card->codec);
151
152 return 0; 116 return 0;
153} 117}
154 118
155#ifdef CONFIG_PM 119#ifdef CONFIG_PM
156static int pcm3008_soc_suspend(struct platform_device *pdev, pm_message_t msg) 120static int pcm3008_soc_suspend(struct snd_soc_codec *codec, pm_message_t msg)
157{ 121{
158 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 122 struct pcm3008_setup_data *setup = codec->dev->platform_data;
159 struct pcm3008_setup_data *setup = socdev->codec_data;
160 123
161 gpio_set_value(setup->pdad_pin, 0); 124 gpio_set_value(setup->pdad_pin, 0);
162 gpio_set_value(setup->pdda_pin, 0); 125 gpio_set_value(setup->pdda_pin, 0);
@@ -164,10 +127,9 @@ static int pcm3008_soc_suspend(struct platform_device *pdev, pm_message_t msg)
164 return 0; 127 return 0;
165} 128}
166 129
167static int pcm3008_soc_resume(struct platform_device *pdev) 130static int pcm3008_soc_resume(struct snd_soc_codec *codec)
168{ 131{
169 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 132 struct pcm3008_setup_data *setup = codec->dev->platform_data;
170 struct pcm3008_setup_data *setup = socdev->codec_data;
171 133
172 gpio_set_value(setup->pdad_pin, 1); 134 gpio_set_value(setup->pdad_pin, 1);
173 gpio_set_value(setup->pdda_pin, 1); 135 gpio_set_value(setup->pdda_pin, 1);
@@ -179,23 +141,45 @@ static int pcm3008_soc_resume(struct platform_device *pdev)
179#define pcm3008_soc_resume NULL 141#define pcm3008_soc_resume NULL
180#endif 142#endif
181 143
182struct snd_soc_codec_device soc_codec_dev_pcm3008 = { 144static struct snd_soc_codec_driver soc_codec_dev_pcm3008 = {
183 .probe = pcm3008_soc_probe, 145 .probe = pcm3008_soc_probe,
184 .remove = pcm3008_soc_remove, 146 .remove = pcm3008_soc_remove,
185 .suspend = pcm3008_soc_suspend, 147 .suspend = pcm3008_soc_suspend,
186 .resume = pcm3008_soc_resume, 148 .resume = pcm3008_soc_resume,
187}; 149};
188EXPORT_SYMBOL_GPL(soc_codec_dev_pcm3008);
189 150
190static int __init pcm3008_init(void) 151static int __devinit pcm3008_codec_probe(struct platform_device *pdev)
152{
153 return snd_soc_register_codec(&pdev->dev,
154 &soc_codec_dev_pcm3008, &pcm3008_dai, 1);
155}
156
157static int __devexit pcm3008_codec_remove(struct platform_device *pdev)
158{
159 snd_soc_unregister_codec(&pdev->dev);
160 return 0;
161}
162
163MODULE_ALIAS("platform:pcm3008-codec");
164
165static struct platform_driver pcm3008_codec_driver = {
166 .probe = pcm3008_codec_probe,
167 .remove = __devexit_p(pcm3008_codec_remove),
168 .driver = {
169 .name = "pcm3008-codec",
170 .owner = THIS_MODULE,
171 },
172};
173
174static int __init pcm3008_modinit(void)
191{ 175{
192 return snd_soc_register_dai(&pcm3008_dai); 176 return platform_driver_register(&pcm3008_codec_driver);
193} 177}
194module_init(pcm3008_init); 178module_init(pcm3008_modinit);
195 179
196static void __exit pcm3008_exit(void) 180static void __exit pcm3008_exit(void)
197{ 181{
198 snd_soc_unregister_dai(&pcm3008_dai); 182 platform_driver_unregister(&pcm3008_codec_driver);
199} 183}
200module_exit(pcm3008_exit); 184module_exit(pcm3008_exit);
201 185