blob: 14d9adf3d4761f800025326061809f9df0135bfc [file] [log] [blame]
Alex Wongb3d06a02012-01-12 10:00:41 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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,
Kiran Kandi5e809b02012-01-31 00:24:33 -080078 .channels_max = 6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079 .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 },
Alex Wongb3d06a02012-01-12 10:00:41 -0800239 {
240 .playback = {
241 .stream_name = "HDMI_Rx Hostless Playback",
242 .rates = SNDRV_PCM_RATE_8000_48000,
243 .formats = SNDRV_PCM_FMTBIT_S16_LE,
244 .channels_min = 1,
245 .channels_max = 2,
246 .rate_min = 8000,
247 .rate_max = 48000,
248 },
249 .ops = &msm_fe_dai_ops,
250 .name = "HDMI_HOSTLESS"
251 },
Patrick Laie66c31a2012-01-22 22:00:45 -0800252 {
253 .playback = {
254 .stream_name = "AUXPCM Hostless Playback",
255 .rates = SNDRV_PCM_RATE_8000,
256 .formats = SNDRV_PCM_FMTBIT_S16_LE,
257 .channels_min = 1,
258 .channels_max = 1,
259 .rate_min = 8000,
260 .rate_max = 8000,
261 },
262 .capture = {
263 .stream_name = "AUXPCM Hostless Capture",
264 .rates = SNDRV_PCM_RATE_8000,
265 .formats = SNDRV_PCM_FMTBIT_S16_LE,
266 .channels_min = 1,
267 .channels_max = 1,
268 .rate_min = 8000,
269 .rate_max = 48000,
270 },
271 .ops = &msm_fe_dai_ops,
272 .name = "AUXPCM_HOSTLESS",
273 },
Neema Shetty2ced1ba2012-02-16 12:10:05 -0800274 {
275 .playback = {
276 .stream_name = "Voice Stub Playback",
277 .rates = SNDRV_PCM_RATE_8000_48000,
278 .formats = SNDRV_PCM_FMTBIT_S16_LE,
279 .channels_min = 1,
280 .channels_max = 2,
281 .rate_min = 8000,
282 .rate_max = 48000,
283 },
284 .capture = {
285 .stream_name = "Voice Stub Capture",
286 .rates = SNDRV_PCM_RATE_8000_48000,
287 .formats = SNDRV_PCM_FMTBIT_S16_LE,
288 .channels_min = 1,
289 .channels_max = 2,
290 .rate_min = 8000,
291 .rate_max = 48000,
292 },
293 .ops = &msm_fe_dai_ops,
294 .name = "VOICE_STUB",
295 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700296};
297
298static __devinit int msm_fe_dai_dev_probe(struct platform_device *pdev)
299{
300 dev_dbg(&pdev->dev, "%s: dev name %s\n", __func__,
301 dev_name(&pdev->dev));
302 return snd_soc_register_dais(&pdev->dev, msm_fe_dais,
303 ARRAY_SIZE(msm_fe_dais));
304}
305
306static __devexit int msm_fe_dai_dev_remove(struct platform_device *pdev)
307{
308 snd_soc_unregister_dai(&pdev->dev);
309 return 0;
310}
311
312static struct platform_driver msm_fe_dai_driver = {
313 .probe = msm_fe_dai_dev_probe,
314 .remove = msm_fe_dai_dev_remove,
315 .driver = {
316 .name = "msm-dai-fe",
317 .owner = THIS_MODULE,
318 },
319};
320
321static int __init msm_fe_dai_init(void)
322{
323 return platform_driver_register(&msm_fe_dai_driver);
324}
325module_init(msm_fe_dai_init);
326
327static void __exit msm_fe_dai_exit(void)
328{
329 platform_driver_unregister(&msm_fe_dai_driver);
330}
331module_exit(msm_fe_dai_exit);
332
333/* Module information */
334MODULE_DESCRIPTION("MSM Frontend DAI driver");
335MODULE_LICENSE("GPL v2");