diff options
Diffstat (limited to 'sound/soc/codecs/ads117x.c')
-rw-r--r-- | sound/soc/codecs/ads117x.c | 72 |
1 files changed, 11 insertions, 61 deletions
diff --git a/sound/soc/codecs/ads117x.c b/sound/soc/codecs/ads117x.c index f8e75edb27b7..8402854ec15e 100644 --- a/sound/soc/codecs/ads117x.c +++ b/sound/soc/codecs/ads117x.c | |||
@@ -19,16 +19,12 @@ | |||
19 | #include <sound/initval.h> | 19 | #include <sound/initval.h> |
20 | #include <sound/soc.h> | 20 | #include <sound/soc.h> |
21 | 21 | ||
22 | #include "ads117x.h" | ||
23 | |||
24 | #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000) | 22 | #define ADS117X_RATES (SNDRV_PCM_RATE_8000_48000) |
25 | |||
26 | #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) | 23 | #define ADS117X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE) |
27 | 24 | ||
28 | struct snd_soc_dai ads117x_dai = { | 25 | static struct snd_soc_dai_driver ads117x_dai = { |
29 | /* ADC */ | 26 | /* ADC */ |
30 | .name = "ADS117X ADC", | 27 | .name = "ads117x-hifi", |
31 | .id = 1, | ||
32 | .capture = { | 28 | .capture = { |
33 | .stream_name = "Capture", | 29 | .stream_name = "Capture", |
34 | .channels_min = 1, | 30 | .channels_min = 1, |
@@ -36,75 +32,29 @@ struct snd_soc_dai ads117x_dai = { | |||
36 | .rates = ADS117X_RATES, | 32 | .rates = ADS117X_RATES, |
37 | .formats = ADS117X_FORMATS,}, | 33 | .formats = ADS117X_FORMATS,}, |
38 | }; | 34 | }; |
39 | EXPORT_SYMBOL_GPL(ads117x_dai); | ||
40 | |||
41 | static int ads117x_probe(struct platform_device *pdev) | ||
42 | { | ||
43 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
44 | struct snd_soc_codec *codec; | ||
45 | int ret; | ||
46 | |||
47 | codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); | ||
48 | if (codec == NULL) | ||
49 | return -ENOMEM; | ||
50 | 35 | ||
51 | socdev->card->codec = codec; | 36 | static struct snd_soc_codec_driver soc_codec_dev_ads117x; |
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; | ||
59 | |||
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; | ||
66 | } | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static int ads117x_remove(struct platform_device *pdev) | ||
72 | { | ||
73 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
74 | struct snd_soc_codec *codec = socdev->card->codec; | ||
75 | |||
76 | snd_soc_free_pcms(socdev); | ||
77 | kfree(codec); | ||
78 | |||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | struct snd_soc_codec_device soc_codec_dev_ads117x = { | ||
83 | .probe = ads117x_probe, | ||
84 | .remove = ads117x_remove, | ||
85 | }; | ||
86 | EXPORT_SYMBOL_GPL(soc_codec_dev_ads117x); | ||
87 | 37 | ||
88 | static __devinit int ads117x_platform_probe(struct platform_device *pdev) | 38 | static __devinit int ads117x_probe(struct platform_device *pdev) |
89 | { | 39 | { |
90 | ads117x_dai.dev = &pdev->dev; | 40 | return snd_soc_register_codec(&pdev->dev, |
91 | return snd_soc_register_dai(&ads117x_dai); | 41 | &soc_codec_dev_ads117x, &ads117x_dai, 1); |
92 | } | 42 | } |
93 | 43 | ||
94 | static int __devexit ads117x_platform_remove(struct platform_device *pdev) | 44 | static int __devexit ads117x_remove(struct platform_device *pdev) |
95 | { | 45 | { |
96 | snd_soc_unregister_dai(&ads117x_dai); | 46 | snd_soc_unregister_codec(&pdev->dev); |
97 | return 0; | 47 | return 0; |
98 | } | 48 | } |
99 | 49 | ||
100 | static struct platform_driver ads117x_codec_driver = { | 50 | static struct platform_driver ads117x_codec_driver = { |
101 | .driver = { | 51 | .driver = { |
102 | .name = "ads117x", | 52 | .name = "ads117x-codec", |
103 | .owner = THIS_MODULE, | 53 | .owner = THIS_MODULE, |
104 | }, | 54 | }, |
105 | 55 | ||
106 | .probe = ads117x_platform_probe, | 56 | .probe = ads117x_probe, |
107 | .remove = __devexit_p(ads117x_platform_remove), | 57 | .remove = __devexit_p(ads117x_remove), |
108 | }; | 58 | }; |
109 | 59 | ||
110 | static int __init ads117x_init(void) | 60 | static int __init ads117x_init(void) |