blob: 16d149e5053af572ee0a4fcaa998e77cd7499ef1 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13
14#include <linux/init.h>
15#include <linux/module.h>
16#include <linux/device.h>
17#include <linux/platform_device.h>
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/soc.h>
21
22static struct snd_soc_dai_ops msm_fe_dai_ops = {};
23
Asish Bhattacharyad69d2842011-10-14 14:53:30 +053024/* Conventional and unconventional sample rate supported */
25static unsigned int supported_sample_rates[] = {
26 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
27};
28
29static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
30 .count = ARRAY_SIZE(supported_sample_rates),
31 .list = supported_sample_rates,
32 .mask = 0,
33};
34
35static int multimedia_startup(struct snd_pcm_substream *substream,
36 struct snd_soc_dai *dai)
37{
38 snd_pcm_hw_constraint_list(substream->runtime, 0,
39 SNDRV_PCM_HW_PARAM_RATE,
40 &constraints_sample_rates);
41
42 return 0;
43}
44
45static struct snd_soc_dai_ops msm_fe_Multimedia_dai_ops = {
46 .startup = multimedia_startup,
47};
48
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049static struct snd_soc_dai_driver msm_fe_dais[] = {
50 {
51 .playback = {
52 .stream_name = "Multimedia1 Playback",
53 .rates = SNDRV_PCM_RATE_8000_48000,
54 .formats = SNDRV_PCM_FMTBIT_S16_LE,
55 .channels_min = 1,
56 .channels_max = 2,
57 .rate_min = 8000,
58 .rate_max = 48000,
59 },
60 .capture = {
61 .stream_name = "Multimedia1 Capture",
62 .rates = SNDRV_PCM_RATE_8000_48000,
63 .formats = SNDRV_PCM_FMTBIT_S16_LE,
64 .channels_min = 1,
65 .channels_max = 2,
66 .rate_min = 8000,
67 .rate_max = 48000,
68 },
69 .ops = &msm_fe_dai_ops,
70 .name = "MultiMedia1",
71 },
72 {
73 .playback = {
74 .stream_name = "Multimedia2 Playback",
75 .rates = SNDRV_PCM_RATE_8000_48000,
76 .formats = SNDRV_PCM_FMTBIT_S16_LE,
77 .channels_min = 1,
78 .channels_max = 2,
79 .rate_min = 8000,
80 .rate_max = 48000,
81 },
82 .capture = {
83 .stream_name = "Multimedia2 Capture",
84 .rates = SNDRV_PCM_RATE_8000_48000,
85 .formats = SNDRV_PCM_FMTBIT_S16_LE,
86 .channels_min = 1,
87 .channels_max = 2,
88 .rate_min = 8000,
89 .rate_max = 48000,
90 },
91 .ops = &msm_fe_dai_ops,
92 .name = "MultiMedia2",
93 },
94 {
95 .playback = {
96 .stream_name = "Voice Playback",
97 .rates = SNDRV_PCM_RATE_8000_48000,
98 .formats = SNDRV_PCM_FMTBIT_S16_LE,
99 .channels_min = 1,
100 .channels_max = 2,
101 .rate_min = 8000,
102 .rate_max = 48000,
103 },
104 .capture = {
105 .stream_name = "Voice Capture",
106 .rates = SNDRV_PCM_RATE_8000_48000,
107 .formats = SNDRV_PCM_FMTBIT_S16_LE,
108 .channels_min = 1,
109 .channels_max = 2,
110 .rate_min = 8000,
111 .rate_max = 48000,
112 },
113 .ops = &msm_fe_dai_ops,
114 .name = "CS-VOICE",
115 },
116 {
117 .playback = {
118 .stream_name = "VoIP Playback",
119 .rates = SNDRV_PCM_RATE_8000_48000,
Helen Zengb9d00ce2011-10-13 17:25:50 -0700120 .formats = SNDRV_PCM_FMTBIT_S16_LE |
121 SNDRV_PCM_FMTBIT_SPECIAL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700122 .channels_min = 1,
123 .channels_max = 2,
124 .rate_min = 8000,
125 .rate_max = 48000,
126 },
127 .capture = {
128 .stream_name = "VoIP Capture",
129 .rates = SNDRV_PCM_RATE_8000_48000,
Helen Zengb9d00ce2011-10-13 17:25:50 -0700130 .formats = SNDRV_PCM_FMTBIT_S16_LE |
131 SNDRV_PCM_FMTBIT_SPECIAL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700132 .channels_min = 1,
133 .channels_max = 2,
134 .rate_min = 8000,
135 .rate_max = 48000,
136 },
137 .ops = &msm_fe_dai_ops,
138 .name = "VoIP",
139 },
140 {
141 .playback = {
142 .stream_name = "MultiMedia3 Playback",
Asish Bhattacharyad69d2842011-10-14 14:53:30 +0530143 .rates = (SNDRV_PCM_RATE_8000_48000 |
144 SNDRV_PCM_RATE_KNOT),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700145 .formats = SNDRV_PCM_FMTBIT_S16_LE,
146 .channels_min = 1,
147 .channels_max = 2,
148 .rate_min = 8000,
149 .rate_max = 48000,
150 },
Asish Bhattacharyad69d2842011-10-14 14:53:30 +0530151 .ops = &msm_fe_Multimedia_dai_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700152 .name = "MultiMedia3",
153 },
Asish Bhattacharya305d1752011-11-01 20:38:26 +0530154 {
155 .playback = {
156 .stream_name = "MultiMedia4 Playback",
157 .rates = (SNDRV_PCM_RATE_8000_48000 |
158 SNDRV_PCM_RATE_KNOT),
159 .formats = SNDRV_PCM_FMTBIT_S16_LE,
160 .channels_min = 1,
161 .channels_max = 2,
162 .rate_min = 8000,
163 .rate_max = 48000,
164 },
165 .ops = &msm_fe_Multimedia_dai_ops,
166 .name = "MultiMedia4",
167 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168 /* FE DAIs created for hostless operation purpose */
169 {
170 .playback = {
171 .stream_name = "SLIMBUS0 Hostless Playback",
172 .rates = SNDRV_PCM_RATE_8000_48000,
173 .formats = SNDRV_PCM_FMTBIT_S16_LE,
174 .channels_min = 1,
175 .channels_max = 2,
176 .rate_min = 8000,
177 .rate_max = 48000,
178 },
179 .capture = {
180 .stream_name = "SLIMBUS0 Hostless Capture",
181 .rates = SNDRV_PCM_RATE_8000_48000,
182 .formats = SNDRV_PCM_FMTBIT_S16_LE,
183 .channels_min = 1,
184 .channels_max = 2,
185 .rate_min = 8000,
186 .rate_max = 48000,
187 },
188 .ops = &msm_fe_dai_ops,
189 .name = "SLIMBUS0_HOSTLESS",
190 },
191 {
192 .playback = {
193 .stream_name = "INT_FM Hostless Playback",
194 .rates = SNDRV_PCM_RATE_8000_48000,
195 .formats = SNDRV_PCM_FMTBIT_S16_LE,
196 .channels_min = 1,
197 .channels_max = 2,
198 .rate_min = 8000,
199 .rate_max = 48000,
200 },
201 .capture = {
202 .stream_name = "INT_FM Hostless Capture",
203 .rates = SNDRV_PCM_RATE_8000_48000,
204 .formats = SNDRV_PCM_FMTBIT_S16_LE,
205 .channels_min = 1,
206 .channels_max = 2,
207 .rate_min = 8000,
208 .rate_max = 48000,
209 },
210 .ops = &msm_fe_dai_ops,
211 .name = "INT_FM_HOSTLESS",
212 },
Laxminath Kasam32657ec2011-08-01 19:26:57 +0530213 {
214 .playback = {
215 .stream_name = "AFE-PROXY Playback",
216 .rates = (SNDRV_PCM_RATE_8000 |
217 SNDRV_PCM_RATE_16000 |
218 SNDRV_PCM_RATE_48000),
219 .formats = SNDRV_PCM_FMTBIT_S16_LE,
220 .channels_min = 1,
221 .channels_max = 2,
222 .rate_min = 8000,
223 .rate_max = 48000,
224 },
225 .capture = {
226 .stream_name = "AFE-PROXY Capture",
227 .rates = (SNDRV_PCM_RATE_8000 |
228 SNDRV_PCM_RATE_16000 |
229 SNDRV_PCM_RATE_48000),
230 .formats = SNDRV_PCM_FMTBIT_S16_LE,
231 .channels_min = 1,
232 .channels_max = 2,
233 .rate_min = 8000,
234 .rate_max = 48000,
235 },
236 .ops = &msm_fe_dai_ops,
237 .name = "AFE-PROXY",
238 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700239};
240
241static __devinit int msm_fe_dai_dev_probe(struct platform_device *pdev)
242{
243 dev_dbg(&pdev->dev, "%s: dev name %s\n", __func__,
244 dev_name(&pdev->dev));
245 return snd_soc_register_dais(&pdev->dev, msm_fe_dais,
246 ARRAY_SIZE(msm_fe_dais));
247}
248
249static __devexit int msm_fe_dai_dev_remove(struct platform_device *pdev)
250{
251 snd_soc_unregister_dai(&pdev->dev);
252 return 0;
253}
254
255static struct platform_driver msm_fe_dai_driver = {
256 .probe = msm_fe_dai_dev_probe,
257 .remove = msm_fe_dai_dev_remove,
258 .driver = {
259 .name = "msm-dai-fe",
260 .owner = THIS_MODULE,
261 },
262};
263
264static int __init msm_fe_dai_init(void)
265{
266 return platform_driver_register(&msm_fe_dai_driver);
267}
268module_init(msm_fe_dai_init);
269
270static void __exit msm_fe_dai_exit(void)
271{
272 platform_driver_unregister(&msm_fe_dai_driver);
273}
274module_exit(msm_fe_dai_exit);
275
276/* Module information */
277MODULE_DESCRIPTION("MSM Frontend DAI driver");
278MODULE_LICENSE("GPL v2");