MAINTAINERS: change broken url for prism54
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / soc / codecs / ads117x.c
blobf8e75edb27b7ec793f21f32e10200db2d734148c
1 /*
2 * ads117x.c -- Driver for ads1174/8 ADC chips
4 * Copyright 2009 ShotSpotter Inc.
5 * Author: Graeme Gregory <gg@slimlogic.co.uk>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 #include <linux/kernel.h>
14 #include <linux/slab.h>
15 #include <linux/init.h>
16 #include <linux/device.h>
17 #include <sound/core.h>
18 #include <sound/pcm.h>
19 #include <sound/initval.h>
20 #include <sound/soc.h>
22 #include "ads117x.h"
24 #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000)
26 #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
28 struct snd_soc_dai ads117x_dai = {
29 /* ADC */
30 .name = "ADS117X ADC",
31 .id = 1,
32 .capture = {
33 .stream_name = "Capture",
34 .channels_min = 1,
35 .channels_max = 32,
36 .rates = ADS117X_RATES,
37 .formats = ADS117X_FORMATS,},
39 EXPORT_SYMBOL_GPL(ads117x_dai);
41 static int ads117x_probe(struct platform_device *pdev)
43 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
44 struct snd_soc_codec *codec;
45 int ret;
47 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
48 if (codec == NULL)
49 return -ENOMEM;
51 socdev->card->codec = codec;
52 mutex_init(&codec->mutex);
53 INIT_LIST_HEAD(&codec->dapm_widgets);
54 INIT_LIST_HEAD(&codec->dapm_paths);
55 codec->name = "ADS117X";
56 codec->owner = THIS_MODULE;
57 codec->dai = &ads117x_dai;
58 codec->num_dai = 1;
60 /* register pcms */
61 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
62 if (ret < 0) {
63 printk(KERN_ERR "ads117x: failed to create pcms\n");
64 kfree(codec);
65 return ret;
68 return 0;
71 static int ads117x_remove(struct platform_device *pdev)
73 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
74 struct snd_soc_codec *codec = socdev->card->codec;
76 snd_soc_free_pcms(socdev);
77 kfree(codec);
79 return 0;
82 struct snd_soc_codec_device soc_codec_dev_ads117x = {
83 .probe = ads117x_probe,
84 .remove = ads117x_remove,
86 EXPORT_SYMBOL_GPL(soc_codec_dev_ads117x);
88 static __devinit int ads117x_platform_probe(struct platform_device *pdev)
90 ads117x_dai.dev = &pdev->dev;
91 return snd_soc_register_dai(&ads117x_dai);
94 static int __devexit ads117x_platform_remove(struct platform_device *pdev)
96 snd_soc_unregister_dai(&ads117x_dai);
97 return 0;
100 static struct platform_driver ads117x_codec_driver = {
101 .driver = {
102 .name = "ads117x",
103 .owner = THIS_MODULE,
106 .probe = ads117x_platform_probe,
107 .remove = __devexit_p(ads117x_platform_remove),
110 static int __init ads117x_init(void)
112 return platform_driver_register(&ads117x_codec_driver);
114 module_init(ads117x_init);
116 static void __exit ads117x_exit(void)
118 platform_driver_unregister(&ads117x_codec_driver);
120 module_exit(ads117x_exit);
122 MODULE_DESCRIPTION("ASoC ads117x driver");
123 MODULE_AUTHOR("Graeme Gregory");
124 MODULE_LICENSE("GPL");