import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / soc / mediatek / mt_soc_audio_v2 / mt_soc_dai_routing.c
1 /*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 /*******************************************************************************
17 *
18 * Filename:
19 * ---------
20 * mtk_routing
21 *
22 * Project:
23 * --------
24 *
25 *
26 * Description:
27 * ------------
28 * Audio routing path
29 *
30 * Author:
31 * -------
32 * Chipeng Chang
33 *
34 *------------------------------------------------------------------------------
35 * $Revision: #1 $
36 * $Modtime:$
37 * $Log:$
38 *
39 *
40 *******************************************************************************/
41
42
43 /*****************************************************************************
44 * C O M P I L E R F L A G S
45 *****************************************************************************/
46
47
48 /*****************************************************************************
49 * E X T E R N A L R E F E R E N C E S
50 *****************************************************************************/
51
52 #include <linux/dma-mapping.h>
53 #include <linux/init.h>
54 #include <linux/module.h>
55 #include <linux/device.h>
56 #include <linux/platform_device.h>
57 #include <sound/core.h>
58 #include <sound/pcm.h>
59 #include <sound/soc.h>
60
61 #include "AudDrv_Common.h"
62 #include "AudDrv_Def.h"
63 #include "AudDrv_Afe.h"
64 #include "AudDrv_Ana.h"
65 #include "AudDrv_Clk.h"
66 #include "AudDrv_Kernel.h"
67
68
69 /* Conventional and unconventional sample rate supported */
70 #if 0 //not used
71 static unsigned int supported_sample_rates[] =
72 {
73 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
74 96000
75 };
76 #endif
77 static int mt6589_routing_startup(struct snd_pcm_substream *substream , struct snd_soc_dai *Daiport)
78 {
79 printk("mt6589_routing_startup \n");
80 return 0;
81 }
82
83 static int mt6589_routing_prepare(struct snd_pcm_substream *substream , struct snd_soc_dai *Daiport)
84 {
85 printk("mt6589_routing_prepare \n ");
86 return 0;
87 }
88
89 static int mt6589_routing_trigger(struct snd_pcm_substream *substream , int command ,struct snd_soc_dai *Daiport)
90 {
91 printk("mt6589_routing_trigger command = %d\n ",command);
92 return 0;
93 }
94
95 static const struct snd_soc_dai_ops mtk_routing_ops =
96 {
97 .startup = mt6589_routing_startup,
98 .prepare = mt6589_routing_prepare,
99 .trigger = mt6589_routing_trigger,
100 };
101
102 static struct snd_soc_dai_driver mtk_routing_dai[] =
103 {
104 {
105 .playback = {
106 .stream_name = MT_SOC_ROUTING_STREAM_NAME,
107 .rates = SNDRV_PCM_RATE_8000_48000,
108 .formats = SNDRV_PCM_FMTBIT_S16_LE,
109 .channels_min = 1,
110 .channels_max = 2,
111 .rate_min = 8000,
112 .rate_max = 48000,
113 },
114 /*
115 .capture = {
116 .stream_name = MT_SOC_ROUTING_STREAM_NAME,
117 .rates = SNDRV_PCM_RATE_8000_48000,
118 .formats = SNDRV_PCM_FMTBIT_S16_LE,
119 .channels_min = 1,
120 .channels_max = 2,
121 .rate_min = 8000,
122 .rate_max = 48000,
123 },
124 */
125 .name = "PLATOFRM_CONTROL",
126 .ops = &mtk_routing_ops,
127 },
128 };
129
130 static const struct snd_soc_component_driver dai_routing_component = {
131 .name = "PLATOFRM_CONTROL",
132 };
133
134 static int mtk_routing_dev_probe(struct platform_device *pdev)
135 {
136 int rc = 0;
137
138 printk("mtk_routing_dev_probe name %s\n", dev_name(&pdev->dev));
139
140 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
141 if (pdev->dev.dma_mask == NULL)
142 {
143 pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
144 }
145
146 if (pdev->dev.of_node)
147 {
148 dev_set_name(&pdev->dev, "%s", MT_SOC_ROUTING_DAI_NAME);
149 }
150 printk("%s: dev name %s\n", __func__, dev_name(&pdev->dev));
151
152 rc = snd_soc_register_component(&pdev->dev, &dai_routing_component,
153 mtk_routing_dai, ARRAY_SIZE(mtk_routing_dai));
154 return rc;
155 }
156
157 static int mtk_routing_dev_remove(struct platform_device *pdev)
158 {
159 printk("%s:\n", __func__);
160
161 snd_soc_unregister_component(&pdev->dev);
162
163 return 0;
164 }
165
166 #ifdef CONFIG_OF
167 static const struct of_device_id mt_soc_dai_routing_of_ids[] =
168 {
169 { .compatible = "mediatek,mt_soc_dai_routing", },
170 {}
171 };
172 #endif
173
174 static struct platform_driver mtk_routing_driver =
175 {
176 .probe = mtk_routing_dev_probe,
177 .remove = mtk_routing_dev_remove,
178 .driver = {
179 .name = MT_SOC_ROUTING_DAI_NAME,
180 .owner = THIS_MODULE,
181 #ifdef CONFIG_OF
182 .of_match_table = mt_soc_dai_routing_of_ids,
183 #endif
184 },
185 };
186
187 #ifndef CONFIG_OF
188 static struct platform_device *soc_routing_dev;
189 #endif
190
191 static int __init mtk_routing_init(void)
192 {
193 printk("%s:\n", __func__);
194 #ifndef CONFIG_OF
195 int ret;
196 soc_routing_dev = platform_device_alloc(MT_SOC_ROUTING_DAI_NAME, -1);
197 if (!soc_routing_dev)
198 {
199 return -ENOMEM;
200 }
201
202 ret = platform_device_add(soc_routing_dev);
203 if (ret != 0)
204 {
205 platform_device_put(soc_routing_dev);
206 return ret;
207 }
208 #endif
209 return platform_driver_register(&mtk_routing_driver);
210 }
211 module_init(mtk_routing_init);
212
213 static void __exit mtk_routing_exit(void)
214 {
215 printk("%s:\n", __func__);
216
217 platform_driver_unregister(&mtk_routing_driver);
218 }
219
220 module_exit(mtk_routing_exit);
221
222 /* Module information */
223 MODULE_DESCRIPTION("MTK Routing driver");
224 MODULE_LICENSE("GPL v2");
225