blob: 401c1a984fe8483282979d35c8e01421c8f7448d [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 },
154 /* FE DAIs created for hostless operation purpose */
155 {
156 .playback = {
157 .stream_name = "SLIMBUS0 Hostless Playback",
158 .rates = SNDRV_PCM_RATE_8000_48000,
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 .capture = {
166 .stream_name = "SLIMBUS0 Hostless Capture",
167 .rates = SNDRV_PCM_RATE_8000_48000,
168 .formats = SNDRV_PCM_FMTBIT_S16_LE,
169 .channels_min = 1,
170 .channels_max = 2,
171 .rate_min = 8000,
172 .rate_max = 48000,
173 },
174 .ops = &msm_fe_dai_ops,
175 .name = "SLIMBUS0_HOSTLESS",
176 },
177 {
178 .playback = {
179 .stream_name = "INT_FM Hostless Playback",
180 .rates = SNDRV_PCM_RATE_8000_48000,
181 .formats = SNDRV_PCM_FMTBIT_S16_LE,
182 .channels_min = 1,
183 .channels_max = 2,
184 .rate_min = 8000,
185 .rate_max = 48000,
186 },
187 .capture = {
188 .stream_name = "INT_FM Hostless Capture",
189 .rates = SNDRV_PCM_RATE_8000_48000,
190 .formats = SNDRV_PCM_FMTBIT_S16_LE,
191 .channels_min = 1,
192 .channels_max = 2,
193 .rate_min = 8000,
194 .rate_max = 48000,
195 },
196 .ops = &msm_fe_dai_ops,
197 .name = "INT_FM_HOSTLESS",
198 },
Laxminath Kasam32657ec2011-08-01 19:26:57 +0530199 {
200 .playback = {
201 .stream_name = "AFE-PROXY Playback",
202 .rates = (SNDRV_PCM_RATE_8000 |
203 SNDRV_PCM_RATE_16000 |
204 SNDRV_PCM_RATE_48000),
205 .formats = SNDRV_PCM_FMTBIT_S16_LE,
206 .channels_min = 1,
207 .channels_max = 2,
208 .rate_min = 8000,
209 .rate_max = 48000,
210 },
211 .capture = {
212 .stream_name = "AFE-PROXY Capture",
213 .rates = (SNDRV_PCM_RATE_8000 |
214 SNDRV_PCM_RATE_16000 |
215 SNDRV_PCM_RATE_48000),
216 .formats = SNDRV_PCM_FMTBIT_S16_LE,
217 .channels_min = 1,
218 .channels_max = 2,
219 .rate_min = 8000,
220 .rate_max = 48000,
221 },
222 .ops = &msm_fe_dai_ops,
223 .name = "AFE-PROXY",
224 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700225};
226
227static __devinit int msm_fe_dai_dev_probe(struct platform_device *pdev)
228{
229 dev_dbg(&pdev->dev, "%s: dev name %s\n", __func__,
230 dev_name(&pdev->dev));
231 return snd_soc_register_dais(&pdev->dev, msm_fe_dais,
232 ARRAY_SIZE(msm_fe_dais));
233}
234
235static __devexit int msm_fe_dai_dev_remove(struct platform_device *pdev)
236{
237 snd_soc_unregister_dai(&pdev->dev);
238 return 0;
239}
240
241static struct platform_driver msm_fe_dai_driver = {
242 .probe = msm_fe_dai_dev_probe,
243 .remove = msm_fe_dai_dev_remove,
244 .driver = {
245 .name = "msm-dai-fe",
246 .owner = THIS_MODULE,
247 },
248};
249
250static int __init msm_fe_dai_init(void)
251{
252 return platform_driver_register(&msm_fe_dai_driver);
253}
254module_init(msm_fe_dai_init);
255
256static void __exit msm_fe_dai_exit(void)
257{
258 platform_driver_unregister(&msm_fe_dai_driver);
259}
260module_exit(msm_fe_dai_exit);
261
262/* Module information */
263MODULE_DESCRIPTION("MSM Frontend DAI driver");
264MODULE_LICENSE("GPL v2");