blob: 2ad7f3e03beb8fe5b52a2aab033c31306359431b [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,
120 .formats = SNDRV_PCM_FMTBIT_S16_LE,
121 .channels_min = 1,
122 .channels_max = 2,
123 .rate_min = 8000,
124 .rate_max = 48000,
125 },
126 .capture = {
127 .stream_name = "VoIP Capture",
128 .rates = SNDRV_PCM_RATE_8000_48000,
129 .formats = SNDRV_PCM_FMTBIT_S16_LE,
130 .channels_min = 1,
131 .channels_max = 2,
132 .rate_min = 8000,
133 .rate_max = 48000,
134 },
135 .ops = &msm_fe_dai_ops,
136 .name = "VoIP",
137 },
138 {
139 .playback = {
140 .stream_name = "MultiMedia3 Playback",
Asish Bhattacharyad69d2842011-10-14 14:53:30 +0530141 .rates = (SNDRV_PCM_RATE_8000_48000 |
142 SNDRV_PCM_RATE_KNOT),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700143 .formats = SNDRV_PCM_FMTBIT_S16_LE,
144 .channels_min = 1,
145 .channels_max = 2,
146 .rate_min = 8000,
147 .rate_max = 48000,
148 },
Asish Bhattacharyad69d2842011-10-14 14:53:30 +0530149 .ops = &msm_fe_Multimedia_dai_ops,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150 .name = "MultiMedia3",
151 },
152 /* FE DAIs created for hostless operation purpose */
153 {
154 .playback = {
155 .stream_name = "SLIMBUS0 Hostless Playback",
156 .rates = SNDRV_PCM_RATE_8000_48000,
157 .formats = SNDRV_PCM_FMTBIT_S16_LE,
158 .channels_min = 1,
159 .channels_max = 2,
160 .rate_min = 8000,
161 .rate_max = 48000,
162 },
163 .capture = {
164 .stream_name = "SLIMBUS0 Hostless Capture",
165 .rates = SNDRV_PCM_RATE_8000_48000,
166 .formats = SNDRV_PCM_FMTBIT_S16_LE,
167 .channels_min = 1,
168 .channels_max = 2,
169 .rate_min = 8000,
170 .rate_max = 48000,
171 },
172 .ops = &msm_fe_dai_ops,
173 .name = "SLIMBUS0_HOSTLESS",
174 },
175 {
176 .playback = {
177 .stream_name = "INT_FM Hostless Playback",
178 .rates = SNDRV_PCM_RATE_8000_48000,
179 .formats = SNDRV_PCM_FMTBIT_S16_LE,
180 .channels_min = 1,
181 .channels_max = 2,
182 .rate_min = 8000,
183 .rate_max = 48000,
184 },
185 .capture = {
186 .stream_name = "INT_FM Hostless Capture",
187 .rates = SNDRV_PCM_RATE_8000_48000,
188 .formats = SNDRV_PCM_FMTBIT_S16_LE,
189 .channels_min = 1,
190 .channels_max = 2,
191 .rate_min = 8000,
192 .rate_max = 48000,
193 },
194 .ops = &msm_fe_dai_ops,
195 .name = "INT_FM_HOSTLESS",
196 },
Laxminath Kasam32657ec2011-08-01 19:26:57 +0530197 {
198 .playback = {
199 .stream_name = "AFE-PROXY Playback",
200 .rates = (SNDRV_PCM_RATE_8000 |
201 SNDRV_PCM_RATE_16000 |
202 SNDRV_PCM_RATE_48000),
203 .formats = SNDRV_PCM_FMTBIT_S16_LE,
204 .channels_min = 1,
205 .channels_max = 2,
206 .rate_min = 8000,
207 .rate_max = 48000,
208 },
209 .capture = {
210 .stream_name = "AFE-PROXY Capture",
211 .rates = (SNDRV_PCM_RATE_8000 |
212 SNDRV_PCM_RATE_16000 |
213 SNDRV_PCM_RATE_48000),
214 .formats = SNDRV_PCM_FMTBIT_S16_LE,
215 .channels_min = 1,
216 .channels_max = 2,
217 .rate_min = 8000,
218 .rate_max = 48000,
219 },
220 .ops = &msm_fe_dai_ops,
221 .name = "AFE-PROXY",
222 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700223};
224
225static __devinit int msm_fe_dai_dev_probe(struct platform_device *pdev)
226{
227 dev_dbg(&pdev->dev, "%s: dev name %s\n", __func__,
228 dev_name(&pdev->dev));
229 return snd_soc_register_dais(&pdev->dev, msm_fe_dais,
230 ARRAY_SIZE(msm_fe_dais));
231}
232
233static __devexit int msm_fe_dai_dev_remove(struct platform_device *pdev)
234{
235 snd_soc_unregister_dai(&pdev->dev);
236 return 0;
237}
238
239static struct platform_driver msm_fe_dai_driver = {
240 .probe = msm_fe_dai_dev_probe,
241 .remove = msm_fe_dai_dev_remove,
242 .driver = {
243 .name = "msm-dai-fe",
244 .owner = THIS_MODULE,
245 },
246};
247
248static int __init msm_fe_dai_init(void)
249{
250 return platform_driver_register(&msm_fe_dai_driver);
251}
252module_init(msm_fe_dai_init);
253
254static void __exit msm_fe_dai_exit(void)
255{
256 platform_driver_unregister(&msm_fe_dai_driver);
257}
258module_exit(msm_fe_dai_exit);
259
260/* Module information */
261MODULE_DESCRIPTION("MSM Frontend DAI driver");
262MODULE_LICENSE("GPL v2");