diff options
Diffstat (limited to 'sound/soc/codecs/ad1980.c')
-rw-r--r-- | sound/soc/codecs/ad1980.c | 113 |
1 files changed, 47 insertions, 66 deletions
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index 70cfaec3be2c..410ccd5d41cd 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c | |||
@@ -33,11 +33,6 @@ | |||
33 | 33 | ||
34 | #include "ad1980.h" | 34 | #include "ad1980.h" |
35 | 35 | ||
36 | static unsigned int ac97_read(struct snd_soc_codec *codec, | ||
37 | unsigned int reg); | ||
38 | static int ac97_write(struct snd_soc_codec *codec, | ||
39 | unsigned int reg, unsigned int val); | ||
40 | |||
41 | /* | 36 | /* |
42 | * AD1980 register cache | 37 | * AD1980 register cache |
43 | */ | 38 | */ |
@@ -138,8 +133,8 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, | |||
138 | return 0; | 133 | return 0; |
139 | } | 134 | } |
140 | 135 | ||
141 | struct snd_soc_dai ad1980_dai = { | 136 | static struct snd_soc_dai_driver ad1980_dai = { |
142 | .name = "AC97", | 137 | .name = "ad1980-hifi", |
143 | .ac97_control = 1, | 138 | .ac97_control = 1, |
144 | .playback = { | 139 | .playback = { |
145 | .stream_name = "Playback", | 140 | .stream_name = "Playback", |
@@ -185,53 +180,20 @@ err: | |||
185 | return -EIO; | 180 | return -EIO; |
186 | } | 181 | } |
187 | 182 | ||
188 | static int ad1980_soc_probe(struct platform_device *pdev) | 183 | static int ad1980_soc_probe(struct snd_soc_codec *codec) |
189 | { | 184 | { |
190 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 185 | int ret; |
191 | struct snd_soc_codec *codec; | ||
192 | int ret = 0; | ||
193 | u16 vendor_id2; | 186 | u16 vendor_id2; |
194 | u16 ext_status; | 187 | u16 ext_status; |
195 | 188 | ||
196 | printk(KERN_INFO "AD1980 SoC Audio Codec\n"); | 189 | printk(KERN_INFO "AD1980 SoC Audio Codec\n"); |
197 | 190 | ||
198 | socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); | ||
199 | if (socdev->card->codec == NULL) | ||
200 | return -ENOMEM; | ||
201 | codec = socdev->card->codec; | ||
202 | mutex_init(&codec->mutex); | ||
203 | |||
204 | codec->reg_cache = | ||
205 | kzalloc(sizeof(u16) * ARRAY_SIZE(ad1980_reg), GFP_KERNEL); | ||
206 | if (codec->reg_cache == NULL) { | ||
207 | ret = -ENOMEM; | ||
208 | goto cache_err; | ||
209 | } | ||
210 | memcpy(codec->reg_cache, ad1980_reg, sizeof(u16) * \ | ||
211 | ARRAY_SIZE(ad1980_reg)); | ||
212 | codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(ad1980_reg); | ||
213 | codec->reg_cache_step = 2; | ||
214 | codec->name = "AD1980"; | ||
215 | codec->owner = THIS_MODULE; | ||
216 | codec->dai = &ad1980_dai; | ||
217 | codec->num_dai = 1; | ||
218 | codec->write = ac97_write; | ||
219 | codec->read = ac97_read; | ||
220 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
221 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
222 | |||
223 | ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); | 191 | ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); |
224 | if (ret < 0) { | 192 | if (ret < 0) { |
225 | printk(KERN_ERR "ad1980: failed to register AC97 codec\n"); | 193 | printk(KERN_ERR "ad1980: failed to register AC97 codec\n"); |
226 | goto codec_err; | 194 | return ret; |
227 | } | 195 | } |
228 | 196 | ||
229 | /* register pcms */ | ||
230 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
231 | if (ret < 0) | ||
232 | goto pcm_err; | ||
233 | |||
234 | |||
235 | ret = ad1980_reset(codec, 0); | 197 | ret = ad1980_reset(codec, 0); |
236 | if (ret < 0) { | 198 | if (ret < 0) { |
237 | printk(KERN_ERR "Failed to reset AD1980: AC97 link error\n"); | 199 | printk(KERN_ERR "Failed to reset AD1980: AC97 link error\n"); |
@@ -270,41 +232,60 @@ static int ad1980_soc_probe(struct platform_device *pdev) | |||
270 | return 0; | 232 | return 0; |
271 | 233 | ||
272 | reset_err: | 234 | reset_err: |
273 | snd_soc_free_pcms(socdev); | ||
274 | |||
275 | pcm_err: | ||
276 | snd_soc_free_ac97_codec(codec); | 235 | snd_soc_free_ac97_codec(codec); |
277 | |||
278 | codec_err: | ||
279 | kfree(codec->reg_cache); | ||
280 | |||
281 | cache_err: | ||
282 | kfree(socdev->card->codec); | ||
283 | socdev->card->codec = NULL; | ||
284 | return ret; | 236 | return ret; |
285 | } | 237 | } |
286 | 238 | ||
287 | static int ad1980_soc_remove(struct platform_device *pdev) | 239 | static int ad1980_soc_remove(struct snd_soc_codec *codec) |
288 | { | 240 | { |
289 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
290 | struct snd_soc_codec *codec = socdev->card->codec; | ||
291 | |||
292 | if (codec == NULL) | ||
293 | return 0; | ||
294 | |||
295 | snd_soc_dapm_free(socdev); | ||
296 | snd_soc_free_pcms(socdev); | ||
297 | snd_soc_free_ac97_codec(codec); | 241 | snd_soc_free_ac97_codec(codec); |
298 | kfree(codec->reg_cache); | ||
299 | kfree(codec); | ||
300 | return 0; | 242 | return 0; |
301 | } | 243 | } |
302 | 244 | ||
303 | struct snd_soc_codec_device soc_codec_dev_ad1980 = { | 245 | static struct snd_soc_codec_driver soc_codec_dev_ad1980 = { |
304 | .probe = ad1980_soc_probe, | 246 | .probe = ad1980_soc_probe, |
305 | .remove = ad1980_soc_remove, | 247 | .remove = ad1980_soc_remove, |
248 | .reg_cache_size = ARRAY_SIZE(ad1980_reg), | ||
249 | .reg_word_size = sizeof(u16), | ||
250 | .reg_cache_default = ad1980_reg, | ||
251 | .reg_cache_step = 2, | ||
252 | .write = ac97_write, | ||
253 | .read = ac97_read, | ||
306 | }; | 254 | }; |
307 | EXPORT_SYMBOL_GPL(soc_codec_dev_ad1980); | 255 | |
256 | static __devinit int ad1980_probe(struct platform_device *pdev) | ||
257 | { | ||
258 | return snd_soc_register_codec(&pdev->dev, | ||
259 | &soc_codec_dev_ad1980, &ad1980_dai, 1); | ||
260 | } | ||
261 | |||
262 | static int __devexit ad1980_remove(struct platform_device *pdev) | ||
263 | { | ||
264 | snd_soc_unregister_codec(&pdev->dev); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static struct platform_driver ad1980_codec_driver = { | ||
269 | .driver = { | ||
270 | .name = "ad1980-codec", | ||
271 | .owner = THIS_MODULE, | ||
272 | }, | ||
273 | |||
274 | .probe = ad1980_probe, | ||
275 | .remove = __devexit_p(ad1980_remove), | ||
276 | }; | ||
277 | |||
278 | static int __init ad1980_init(void) | ||
279 | { | ||
280 | return platform_driver_register(&ad1980_codec_driver); | ||
281 | } | ||
282 | module_init(ad1980_init); | ||
283 | |||
284 | static void __exit ad1980_exit(void) | ||
285 | { | ||
286 | platform_driver_unregister(&ad1980_codec_driver); | ||
287 | } | ||
288 | module_exit(ad1980_exit); | ||
308 | 289 | ||
309 | MODULE_DESCRIPTION("ASoC ad1980 driver (Obsolete)"); | 290 | MODULE_DESCRIPTION("ASoC ad1980 driver (Obsolete)"); |
310 | MODULE_AUTHOR("Roy Huang, Cliff Cai"); | 291 | MODULE_AUTHOR("Roy Huang, Cliff Cai"); |