xref: /openbmc/linux/sound/soc/qcom/qdsp6/q6routing.c (revision 6f4eaea2)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
3 // Copyright (c) 2018, Linaro Limited
4 
5 #include <linux/init.h>
6 #include <linux/err.h>
7 #include <linux/module.h>
8 #include <linux/platform_device.h>
9 #include <linux/of_platform.h>
10 #include <linux/bitops.h>
11 #include <linux/mutex.h>
12 #include <linux/of_device.h>
13 #include <linux/slab.h>
14 #include <sound/core.h>
15 #include <sound/soc.h>
16 #include <sound/soc-dapm.h>
17 #include <sound/pcm.h>
18 #include <sound/control.h>
19 #include <sound/asound.h>
20 #include <sound/pcm_params.h>
21 #include "q6afe.h"
22 #include "q6asm.h"
23 #include "q6adm.h"
24 #include "q6routing.h"
25 
26 #define DRV_NAME "q6routing-component"
27 
28 #define Q6ROUTING_RX_MIXERS(id)						\
29 	SOC_SINGLE_EXT("MultiMedia1", id,				\
30 	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,\
31 	msm_routing_put_audio_mixer),					\
32 	SOC_SINGLE_EXT("MultiMedia2", id,				\
33 	MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,\
34 	msm_routing_put_audio_mixer),					\
35 	SOC_SINGLE_EXT("MultiMedia3", id,				\
36 	MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,\
37 	msm_routing_put_audio_mixer),					\
38 	SOC_SINGLE_EXT("MultiMedia4", id,				\
39 	MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,\
40 	msm_routing_put_audio_mixer),					\
41 	SOC_SINGLE_EXT("MultiMedia5", id,				\
42 	MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,\
43 	msm_routing_put_audio_mixer),					\
44 	SOC_SINGLE_EXT("MultiMedia6", id,				\
45 	MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,\
46 	msm_routing_put_audio_mixer),					\
47 	SOC_SINGLE_EXT("MultiMedia7", id,				\
48 	MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,\
49 	msm_routing_put_audio_mixer),					\
50 	SOC_SINGLE_EXT("MultiMedia8", id,				\
51 	MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,\
52 	msm_routing_put_audio_mixer),
53 
54 #define Q6ROUTING_RX_DAPM_ROUTE(mix_name, s)	\
55 	{ mix_name, "MultiMedia1", "MM_DL1" },	\
56 	{ mix_name, "MultiMedia2", "MM_DL2" },	\
57 	{ mix_name, "MultiMedia3", "MM_DL3" },	\
58 	{ mix_name, "MultiMedia4", "MM_DL4" },	\
59 	{ mix_name, "MultiMedia5", "MM_DL5" },	\
60 	{ mix_name, "MultiMedia6", "MM_DL6" },	\
61 	{ mix_name, "MultiMedia7", "MM_DL7" },	\
62 	{ mix_name, "MultiMedia8", "MM_DL8" },	\
63 	{ s, NULL, mix_name }
64 
65 #define Q6ROUTING_TX_DAPM_ROUTE(mix_name)		\
66 	{ mix_name, "PRI_MI2S_TX", "PRI_MI2S_TX" },	\
67 	{ mix_name, "SEC_MI2S_TX", "SEC_MI2S_TX" },	\
68 	{ mix_name, "QUAT_MI2S_TX", "QUAT_MI2S_TX" },	\
69 	{ mix_name, "TERT_MI2S_TX", "TERT_MI2S_TX" },		\
70 	{ mix_name, "SLIMBUS_0_TX", "SLIMBUS_0_TX" },		\
71 	{ mix_name, "SLIMBUS_1_TX", "SLIMBUS_1_TX" },		\
72 	{ mix_name, "SLIMBUS_2_TX", "SLIMBUS_2_TX" },		\
73 	{ mix_name, "SLIMBUS_3_TX", "SLIMBUS_3_TX" },		\
74 	{ mix_name, "SLIMBUS_4_TX", "SLIMBUS_4_TX" },		\
75 	{ mix_name, "SLIMBUS_5_TX", "SLIMBUS_5_TX" },		\
76 	{ mix_name, "SLIMBUS_6_TX", "SLIMBUS_6_TX" },		\
77 	{ mix_name, "PRIMARY_TDM_TX_0", "PRIMARY_TDM_TX_0"},	\
78 	{ mix_name, "PRIMARY_TDM_TX_1", "PRIMARY_TDM_TX_1"},	\
79 	{ mix_name, "PRIMARY_TDM_TX_2", "PRIMARY_TDM_TX_2"},	\
80 	{ mix_name, "PRIMARY_TDM_TX_3", "PRIMARY_TDM_TX_3"},	\
81 	{ mix_name, "PRIMARY_TDM_TX_4", "PRIMARY_TDM_TX_4"},	\
82 	{ mix_name, "PRIMARY_TDM_TX_5", "PRIMARY_TDM_TX_5"},	\
83 	{ mix_name, "PRIMARY_TDM_TX_6", "PRIMARY_TDM_TX_6"},	\
84 	{ mix_name, "PRIMARY_TDM_TX_7", "PRIMARY_TDM_TX_7"},	\
85 	{ mix_name, "SEC_TDM_TX_0", "SEC_TDM_TX_0"},		\
86 	{ mix_name, "SEC_TDM_TX_1", "SEC_TDM_TX_1"},		\
87 	{ mix_name, "SEC_TDM_TX_2", "SEC_TDM_TX_2"},		\
88 	{ mix_name, "SEC_TDM_TX_3", "SEC_TDM_TX_3"},		\
89 	{ mix_name, "SEC_TDM_TX_4", "SEC_TDM_TX_4"},		\
90 	{ mix_name, "SEC_TDM_TX_5", "SEC_TDM_TX_5"},		\
91 	{ mix_name, "SEC_TDM_TX_6", "SEC_TDM_TX_6"},		\
92 	{ mix_name, "SEC_TDM_TX_7", "SEC_TDM_TX_7"},		\
93 	{ mix_name, "TERT_TDM_TX_0", "TERT_TDM_TX_0"},		\
94 	{ mix_name, "TERT_TDM_TX_1", "TERT_TDM_TX_1"},		\
95 	{ mix_name, "TERT_TDM_TX_2", "TERT_TDM_TX_2"},		\
96 	{ mix_name, "TERT_TDM_TX_3", "TERT_TDM_TX_3"},		\
97 	{ mix_name, "TERT_TDM_TX_4", "TERT_TDM_TX_4"},		\
98 	{ mix_name, "TERT_TDM_TX_5", "TERT_TDM_TX_5"},		\
99 	{ mix_name, "TERT_TDM_TX_6", "TERT_TDM_TX_6"},		\
100 	{ mix_name, "TERT_TDM_TX_7", "TERT_TDM_TX_7"},		\
101 	{ mix_name, "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"},		\
102 	{ mix_name, "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"},		\
103 	{ mix_name, "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"},		\
104 	{ mix_name, "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"},		\
105 	{ mix_name, "QUAT_TDM_TX_4", "QUAT_TDM_TX_4"},		\
106 	{ mix_name, "QUAT_TDM_TX_5", "QUAT_TDM_TX_5"},		\
107 	{ mix_name, "QUAT_TDM_TX_6", "QUAT_TDM_TX_6"},		\
108 	{ mix_name, "QUAT_TDM_TX_7", "QUAT_TDM_TX_7"},		\
109 	{ mix_name, "QUIN_TDM_TX_0", "QUIN_TDM_TX_0"},		\
110 	{ mix_name, "QUIN_TDM_TX_1", "QUIN_TDM_TX_1"},		\
111 	{ mix_name, "QUIN_TDM_TX_2", "QUIN_TDM_TX_2"},		\
112 	{ mix_name, "QUIN_TDM_TX_3", "QUIN_TDM_TX_3"},		\
113 	{ mix_name, "QUIN_TDM_TX_4", "QUIN_TDM_TX_4"},		\
114 	{ mix_name, "QUIN_TDM_TX_5", "QUIN_TDM_TX_5"},		\
115 	{ mix_name, "QUIN_TDM_TX_6", "QUIN_TDM_TX_6"},		\
116 	{ mix_name, "QUIN_TDM_TX_7", "QUIN_TDM_TX_7"},		\
117 	{ mix_name, "WSA_CODEC_DMA_TX_0", "WSA_CODEC_DMA_TX_0"},	\
118 	{ mix_name, "WSA_CODEC_DMA_TX_1", "WSA_CODEC_DMA_TX_1"},	\
119 	{ mix_name, "WSA_CODEC_DMA_TX_2", "WSA_CODEC_DMA_TX_2"},	\
120 	{ mix_name, "VA_CODEC_DMA_TX_0", "VA_CODEC_DMA_TX_0"},	\
121 	{ mix_name, "VA_CODEC_DMA_TX_1", "VA_CODEC_DMA_TX_1"},	\
122 	{ mix_name, "VA_CODEC_DMA_TX_2", "VA_CODEC_DMA_TX_2"},	\
123 	{ mix_name, "TX_CODEC_DMA_TX_0", "TX_CODEC_DMA_TX_0"},	\
124 	{ mix_name, "TX_CODEC_DMA_TX_1", "TX_CODEC_DMA_TX_1"},	\
125 	{ mix_name, "TX_CODEC_DMA_TX_2", "TX_CODEC_DMA_TX_2"},	\
126 	{ mix_name, "TX_CODEC_DMA_TX_3", "TX_CODEC_DMA_TX_3"},	\
127 	{ mix_name, "TX_CODEC_DMA_TX_4", "TX_CODEC_DMA_TX_4"},	\
128 	{ mix_name, "TX_CODEC_DMA_TX_5", "TX_CODEC_DMA_TX_5"}
129 
130 #define Q6ROUTING_TX_MIXERS(id)						\
131 	SOC_SINGLE_EXT("PRI_MI2S_TX", PRIMARY_MI2S_TX,			\
132 		id, 1, 0, msm_routing_get_audio_mixer,			\
133 		msm_routing_put_audio_mixer),				\
134 	SOC_SINGLE_EXT("SEC_MI2S_TX", SECONDARY_MI2S_TX,		\
135 		id, 1, 0, msm_routing_get_audio_mixer,			\
136 		msm_routing_put_audio_mixer),				\
137 	SOC_SINGLE_EXT("TERT_MI2S_TX", TERTIARY_MI2S_TX,		\
138 		id, 1, 0, msm_routing_get_audio_mixer,			\
139 		msm_routing_put_audio_mixer),				\
140 	SOC_SINGLE_EXT("QUAT_MI2S_TX", QUATERNARY_MI2S_TX,		\
141 		id, 1, 0, msm_routing_get_audio_mixer,			\
142 		msm_routing_put_audio_mixer),				\
143 	SOC_SINGLE_EXT("SLIMBUS_0_TX", SLIMBUS_0_TX,			\
144 		id, 1, 0, msm_routing_get_audio_mixer,			\
145 		msm_routing_put_audio_mixer),				\
146 	SOC_SINGLE_EXT("SLIMBUS_1_TX", SLIMBUS_1_TX,			\
147 		id, 1, 0, msm_routing_get_audio_mixer,			\
148 		msm_routing_put_audio_mixer),				\
149 	SOC_SINGLE_EXT("SLIMBUS_2_TX", SLIMBUS_2_TX,			\
150 		id, 1, 0, msm_routing_get_audio_mixer,			\
151 		msm_routing_put_audio_mixer),				\
152 	SOC_SINGLE_EXT("SLIMBUS_3_TX", SLIMBUS_3_TX,			\
153 		id, 1, 0, msm_routing_get_audio_mixer,			\
154 		msm_routing_put_audio_mixer),				\
155 	SOC_SINGLE_EXT("SLIMBUS_4_TX", SLIMBUS_4_TX,			\
156 		id, 1, 0, msm_routing_get_audio_mixer,			\
157 		msm_routing_put_audio_mixer),				\
158 	SOC_SINGLE_EXT("SLIMBUS_5_TX", SLIMBUS_5_TX,			\
159 		id, 1, 0, msm_routing_get_audio_mixer,			\
160 		msm_routing_put_audio_mixer),				\
161 	SOC_SINGLE_EXT("SLIMBUS_6_TX", SLIMBUS_6_TX,			\
162 		id, 1, 0, msm_routing_get_audio_mixer,			\
163 		msm_routing_put_audio_mixer),				\
164 	SOC_SINGLE_EXT("PRIMARY_TDM_TX_0", PRIMARY_TDM_TX_0,		\
165 		id, 1, 0, msm_routing_get_audio_mixer,			\
166 		msm_routing_put_audio_mixer),				\
167 	SOC_SINGLE_EXT("PRIMARY_TDM_TX_1", PRIMARY_TDM_TX_1,		\
168 		id, 1, 0, msm_routing_get_audio_mixer,			\
169 		msm_routing_put_audio_mixer),				\
170 	SOC_SINGLE_EXT("PRIMARY_TDM_TX_2", PRIMARY_TDM_TX_2,		\
171 		id, 1, 0, msm_routing_get_audio_mixer,			\
172 		msm_routing_put_audio_mixer),				\
173 	SOC_SINGLE_EXT("PRIMARY_TDM_TX_3", PRIMARY_TDM_TX_3,		\
174 		id, 1, 0, msm_routing_get_audio_mixer,			\
175 		msm_routing_put_audio_mixer),				\
176 	SOC_SINGLE_EXT("PRIMARY_TDM_TX_4", PRIMARY_TDM_TX_4,		\
177 		id, 1, 0, msm_routing_get_audio_mixer,			\
178 		msm_routing_put_audio_mixer),				\
179 	SOC_SINGLE_EXT("PRIMARY_TDM_TX_5", PRIMARY_TDM_TX_5,		\
180 		id, 1, 0, msm_routing_get_audio_mixer,			\
181 		msm_routing_put_audio_mixer),				\
182 	SOC_SINGLE_EXT("PRIMARY_TDM_TX_6", PRIMARY_TDM_TX_6,		\
183 		id, 1, 0, msm_routing_get_audio_mixer,			\
184 		msm_routing_put_audio_mixer),				\
185 	SOC_SINGLE_EXT("PRIMARY_TDM_TX_7", PRIMARY_TDM_TX_7,		\
186 		id, 1, 0, msm_routing_get_audio_mixer,			\
187 		msm_routing_put_audio_mixer),				\
188 	SOC_SINGLE_EXT("SEC_TDM_TX_0", SECONDARY_TDM_TX_0,		\
189 		id, 1, 0, msm_routing_get_audio_mixer,			\
190 		msm_routing_put_audio_mixer),				\
191 	SOC_SINGLE_EXT("SEC_TDM_TX_1", SECONDARY_TDM_TX_1,		\
192 		id, 1, 0, msm_routing_get_audio_mixer,			\
193 		msm_routing_put_audio_mixer),				\
194 	SOC_SINGLE_EXT("SEC_TDM_TX_2", SECONDARY_TDM_TX_2,		\
195 		id, 1, 0, msm_routing_get_audio_mixer,			\
196 		msm_routing_put_audio_mixer),				\
197 	SOC_SINGLE_EXT("SEC_TDM_TX_3", SECONDARY_TDM_TX_3,		\
198 		id, 1, 0, msm_routing_get_audio_mixer,			\
199 		msm_routing_put_audio_mixer),				\
200 	SOC_SINGLE_EXT("SEC_TDM_TX_4", SECONDARY_TDM_TX_4,		\
201 		id, 1, 0, msm_routing_get_audio_mixer,			\
202 		msm_routing_put_audio_mixer),				\
203 	SOC_SINGLE_EXT("SEC_TDM_TX_5", SECONDARY_TDM_TX_5,		\
204 		id, 1, 0, msm_routing_get_audio_mixer,			\
205 		msm_routing_put_audio_mixer),				\
206 	SOC_SINGLE_EXT("SEC_TDM_TX_6", SECONDARY_TDM_TX_6,		\
207 		id, 1, 0, msm_routing_get_audio_mixer,			\
208 		msm_routing_put_audio_mixer),				\
209 	SOC_SINGLE_EXT("SEC_TDM_TX_7", SECONDARY_TDM_TX_7,		\
210 		id, 1, 0, msm_routing_get_audio_mixer,			\
211 		msm_routing_put_audio_mixer),				\
212 	SOC_SINGLE_EXT("TERT_TDM_TX_0", TERTIARY_TDM_TX_0,		\
213 		id, 1, 0, msm_routing_get_audio_mixer,			\
214 		msm_routing_put_audio_mixer),				\
215 	SOC_SINGLE_EXT("TERT_TDM_TX_1", TERTIARY_TDM_TX_1,		\
216 		id, 1, 0, msm_routing_get_audio_mixer,			\
217 		msm_routing_put_audio_mixer),				\
218 	SOC_SINGLE_EXT("TERT_TDM_TX_2", TERTIARY_TDM_TX_2,		\
219 		id, 1, 0, msm_routing_get_audio_mixer,			\
220 		msm_routing_put_audio_mixer),				\
221 	SOC_SINGLE_EXT("TERT_TDM_TX_3", TERTIARY_TDM_TX_3,		\
222 		id, 1, 0, msm_routing_get_audio_mixer,			\
223 		msm_routing_put_audio_mixer),				\
224 	SOC_SINGLE_EXT("TERT_TDM_TX_4", TERTIARY_TDM_TX_4,		\
225 		id, 1, 0, msm_routing_get_audio_mixer,			\
226 		msm_routing_put_audio_mixer),				\
227 	SOC_SINGLE_EXT("TERT_TDM_TX_5", TERTIARY_TDM_TX_5,		\
228 		id, 1, 0, msm_routing_get_audio_mixer,			\
229 		msm_routing_put_audio_mixer),				\
230 	SOC_SINGLE_EXT("TERT_TDM_TX_6", TERTIARY_TDM_TX_6,		\
231 		id, 1, 0, msm_routing_get_audio_mixer,			\
232 		msm_routing_put_audio_mixer),				\
233 	SOC_SINGLE_EXT("TERT_TDM_TX_7", TERTIARY_TDM_TX_7,		\
234 		id, 1, 0, msm_routing_get_audio_mixer,			\
235 		msm_routing_put_audio_mixer),				\
236 	SOC_SINGLE_EXT("QUAT_TDM_TX_0", QUATERNARY_TDM_TX_0,		\
237 		id, 1, 0, msm_routing_get_audio_mixer,			\
238 		msm_routing_put_audio_mixer),				\
239 	SOC_SINGLE_EXT("QUAT_TDM_TX_1", QUATERNARY_TDM_TX_1,		\
240 		id, 1, 0, msm_routing_get_audio_mixer,			\
241 		msm_routing_put_audio_mixer),				\
242 	SOC_SINGLE_EXT("QUAT_TDM_TX_2", QUATERNARY_TDM_TX_2,		\
243 		id, 1, 0, msm_routing_get_audio_mixer,			\
244 		msm_routing_put_audio_mixer),				\
245 	SOC_SINGLE_EXT("QUAT_TDM_TX_3", QUATERNARY_TDM_TX_3,		\
246 		id, 1, 0, msm_routing_get_audio_mixer,			\
247 		msm_routing_put_audio_mixer),				\
248 	SOC_SINGLE_EXT("QUAT_TDM_TX_4", QUATERNARY_TDM_TX_4,		\
249 		id, 1, 0, msm_routing_get_audio_mixer,			\
250 		msm_routing_put_audio_mixer),				\
251 	SOC_SINGLE_EXT("QUAT_TDM_TX_5", QUATERNARY_TDM_TX_5,		\
252 		id, 1, 0, msm_routing_get_audio_mixer,			\
253 		msm_routing_put_audio_mixer),				\
254 	SOC_SINGLE_EXT("QUAT_TDM_TX_6", QUATERNARY_TDM_TX_6,		\
255 		id, 1, 0, msm_routing_get_audio_mixer,			\
256 		msm_routing_put_audio_mixer),				\
257 	SOC_SINGLE_EXT("QUAT_TDM_TX_7", QUATERNARY_TDM_TX_7,		\
258 		id, 1, 0, msm_routing_get_audio_mixer,			\
259 		msm_routing_put_audio_mixer),				\
260 	SOC_SINGLE_EXT("QUIN_TDM_TX_0", QUINARY_TDM_TX_0,		\
261 		id, 1, 0, msm_routing_get_audio_mixer,			\
262 		msm_routing_put_audio_mixer),				\
263 	SOC_SINGLE_EXT("QUIN_TDM_TX_1", QUINARY_TDM_TX_1,		\
264 		id, 1, 0, msm_routing_get_audio_mixer,			\
265 		msm_routing_put_audio_mixer),				\
266 	SOC_SINGLE_EXT("QUIN_TDM_TX_2", QUINARY_TDM_TX_2,		\
267 		id, 1, 0, msm_routing_get_audio_mixer,			\
268 		msm_routing_put_audio_mixer),				\
269 	SOC_SINGLE_EXT("QUIN_TDM_TX_3", QUINARY_TDM_TX_3,		\
270 		id, 1, 0, msm_routing_get_audio_mixer,			\
271 		msm_routing_put_audio_mixer),				\
272 	SOC_SINGLE_EXT("QUIN_TDM_TX_4", QUINARY_TDM_TX_4,		\
273 		id, 1, 0, msm_routing_get_audio_mixer,			\
274 		msm_routing_put_audio_mixer),				\
275 	SOC_SINGLE_EXT("QUIN_TDM_TX_5", QUINARY_TDM_TX_5,		\
276 		id, 1, 0, msm_routing_get_audio_mixer,			\
277 		msm_routing_put_audio_mixer),				\
278 	SOC_SINGLE_EXT("QUIN_TDM_TX_6", QUINARY_TDM_TX_6,		\
279 		id, 1, 0, msm_routing_get_audio_mixer,			\
280 		msm_routing_put_audio_mixer),				\
281 	SOC_SINGLE_EXT("QUIN_TDM_TX_7", QUINARY_TDM_TX_7,		\
282 		id, 1, 0, msm_routing_get_audio_mixer,			\
283 		msm_routing_put_audio_mixer),				\
284 	SOC_SINGLE_EXT("WSA_CODEC_DMA_TX_0", WSA_CODEC_DMA_TX_0,	\
285 		id, 1, 0, msm_routing_get_audio_mixer,			\
286 		msm_routing_put_audio_mixer),				\
287 	SOC_SINGLE_EXT("WSA_CODEC_DMA_TX_1", WSA_CODEC_DMA_TX_1,	\
288 		id, 1, 0, msm_routing_get_audio_mixer,			\
289 		msm_routing_put_audio_mixer),				\
290 	SOC_SINGLE_EXT("WSA_CODEC_DMA_TX_2", WSA_CODEC_DMA_TX_2,	\
291 		id, 1, 0, msm_routing_get_audio_mixer,			\
292 		msm_routing_put_audio_mixer),				\
293 	SOC_SINGLE_EXT("VA_CODEC_DMA_TX_0", VA_CODEC_DMA_TX_0,		\
294 		id, 1, 0, msm_routing_get_audio_mixer,			\
295 		msm_routing_put_audio_mixer),				\
296 	SOC_SINGLE_EXT("VA_CODEC_DMA_TX_1", VA_CODEC_DMA_TX_1,		\
297 		id, 1, 0, msm_routing_get_audio_mixer,			\
298 		msm_routing_put_audio_mixer),				\
299 	SOC_SINGLE_EXT("VA_CODEC_DMA_TX_2", VA_CODEC_DMA_TX_2,		\
300 		id, 1, 0, msm_routing_get_audio_mixer,			\
301 		msm_routing_put_audio_mixer),				\
302 	SOC_SINGLE_EXT("TX_CODEC_DMA_TX_0", TX_CODEC_DMA_TX_0,		\
303 		id, 1, 0, msm_routing_get_audio_mixer,			\
304 		msm_routing_put_audio_mixer),				\
305 	SOC_SINGLE_EXT("TX_CODEC_DMA_TX_1", TX_CODEC_DMA_TX_1,		\
306 		id, 1, 0, msm_routing_get_audio_mixer,			\
307 		msm_routing_put_audio_mixer),				\
308 	SOC_SINGLE_EXT("TX_CODEC_DMA_TX_2", TX_CODEC_DMA_TX_2,		\
309 		id, 1, 0, msm_routing_get_audio_mixer,			\
310 		msm_routing_put_audio_mixer),				\
311 	SOC_SINGLE_EXT("TX_CODEC_DMA_TX_3", TX_CODEC_DMA_TX_3,		\
312 		id, 1, 0, msm_routing_get_audio_mixer,			\
313 		msm_routing_put_audio_mixer),				\
314 	SOC_SINGLE_EXT("TX_CODEC_DMA_TX_4", TX_CODEC_DMA_TX_4,		\
315 		id, 1, 0, msm_routing_get_audio_mixer,			\
316 		msm_routing_put_audio_mixer),				\
317 	SOC_SINGLE_EXT("TX_CODEC_DMA_TX_5", TX_CODEC_DMA_TX_5,		\
318 		id, 1, 0, msm_routing_get_audio_mixer,			\
319 		msm_routing_put_audio_mixer),
320 
321 struct session_data {
322 	int state;
323 	int port_id;
324 	int path_type;
325 	int app_type;
326 	int acdb_id;
327 	int sample_rate;
328 	int bits_per_sample;
329 	int channels;
330 	int perf_mode;
331 	int numcopps;
332 	int fedai_id;
333 	unsigned long copp_map;
334 	struct q6copp *copps[MAX_COPPS_PER_PORT];
335 };
336 
337 struct msm_routing_data {
338 	struct session_data sessions[MAX_SESSIONS];
339 	struct session_data port_data[AFE_MAX_PORTS];
340 	struct device *dev;
341 	struct mutex lock;
342 };
343 
344 static struct msm_routing_data *routing_data;
345 
346 /**
347  * q6routing_stream_open() - Register a new stream for route setup
348  *
349  * @fedai_id: Frontend dai id.
350  * @perf_mode: Performance mode.
351  * @stream_id: ASM stream id to map.
352  * @stream_type: Direction of stream
353  *
354  * Return: Will be an negative on error or a zero on success.
355  */
356 int q6routing_stream_open(int fedai_id, int perf_mode,
357 			   int stream_id, int stream_type)
358 {
359 	int j, topology, num_copps = 0;
360 	struct route_payload payload;
361 	struct q6copp *copp;
362 	int copp_idx;
363 	struct session_data *session, *pdata;
364 
365 	if (!routing_data) {
366 		pr_err("Routing driver not yet ready\n");
367 		return -EINVAL;
368 	}
369 
370 	session = &routing_data->sessions[stream_id - 1];
371 	pdata = &routing_data->port_data[session->port_id];
372 
373 	mutex_lock(&routing_data->lock);
374 	session->fedai_id = fedai_id;
375 
376 	session->path_type = pdata->path_type;
377 	session->sample_rate = pdata->sample_rate;
378 	session->channels = pdata->channels;
379 	session->bits_per_sample = pdata->bits_per_sample;
380 
381 	payload.num_copps = 0; /* only RX needs to use payload */
382 	topology = NULL_COPP_TOPOLOGY;
383 	copp = q6adm_open(routing_data->dev, session->port_id,
384 			      session->path_type, session->sample_rate,
385 			      session->channels, topology, perf_mode,
386 			      session->bits_per_sample, 0, 0);
387 
388 	if (IS_ERR_OR_NULL(copp)) {
389 		mutex_unlock(&routing_data->lock);
390 		return -EINVAL;
391 	}
392 
393 	copp_idx = q6adm_get_copp_id(copp);
394 	set_bit(copp_idx, &session->copp_map);
395 	session->copps[copp_idx] = copp;
396 
397 	for_each_set_bit(j, &session->copp_map, MAX_COPPS_PER_PORT) {
398 		payload.port_id[num_copps] = session->port_id;
399 		payload.copp_idx[num_copps] = j;
400 		num_copps++;
401 	}
402 
403 	if (num_copps) {
404 		payload.num_copps = num_copps;
405 		payload.session_id = stream_id;
406 		q6adm_matrix_map(routing_data->dev, session->path_type,
407 				 payload, perf_mode);
408 	}
409 	mutex_unlock(&routing_data->lock);
410 
411 	return 0;
412 }
413 EXPORT_SYMBOL_GPL(q6routing_stream_open);
414 
415 static struct session_data *get_session_from_id(struct msm_routing_data *data,
416 						int fedai_id)
417 {
418 	int i;
419 
420 	for (i = 0; i < MAX_SESSIONS; i++) {
421 		if (fedai_id == data->sessions[i].fedai_id)
422 			return &data->sessions[i];
423 	}
424 
425 	return NULL;
426 }
427 /**
428  * q6routing_stream_close() - Deregister a stream
429  *
430  * @fedai_id: Frontend dai id.
431  * @stream_type: Direction of stream
432  *
433  * Return: Will be an negative on error or a zero on success.
434  */
435 void q6routing_stream_close(int fedai_id, int stream_type)
436 {
437 	struct session_data *session;
438 	int idx;
439 
440 	session = get_session_from_id(routing_data, fedai_id);
441 	if (!session)
442 		return;
443 
444 	for_each_set_bit(idx, &session->copp_map, MAX_COPPS_PER_PORT) {
445 		if (session->copps[idx]) {
446 			q6adm_close(routing_data->dev, session->copps[idx]);
447 			session->copps[idx] = NULL;
448 		}
449 	}
450 
451 	session->fedai_id = -1;
452 	session->copp_map = 0;
453 }
454 EXPORT_SYMBOL_GPL(q6routing_stream_close);
455 
456 static int msm_routing_get_audio_mixer(struct snd_kcontrol *kcontrol,
457 				       struct snd_ctl_elem_value *ucontrol)
458 {
459 	struct snd_soc_dapm_context *dapm =
460 	    snd_soc_dapm_kcontrol_dapm(kcontrol);
461 	struct soc_mixer_control *mc =
462 	    (struct soc_mixer_control *)kcontrol->private_value;
463 	int session_id = mc->shift;
464 	struct snd_soc_component *c = snd_soc_dapm_to_component(dapm);
465 	struct msm_routing_data *priv = dev_get_drvdata(c->dev);
466 	struct session_data *session = &priv->sessions[session_id];
467 
468 	if (session->port_id == mc->reg)
469 		ucontrol->value.integer.value[0] = 1;
470 	else
471 		ucontrol->value.integer.value[0] = 0;
472 
473 	return 0;
474 }
475 
476 static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol,
477 				       struct snd_ctl_elem_value *ucontrol)
478 {
479 	struct snd_soc_dapm_context *dapm =
480 				    snd_soc_dapm_kcontrol_dapm(kcontrol);
481 	struct snd_soc_component *c = snd_soc_dapm_to_component(dapm);
482 	struct msm_routing_data *data = dev_get_drvdata(c->dev);
483 	struct soc_mixer_control *mc =
484 		    (struct soc_mixer_control *)kcontrol->private_value;
485 	struct snd_soc_dapm_update *update = NULL;
486 	int be_id = mc->reg;
487 	int session_id = mc->shift;
488 	struct session_data *session = &data->sessions[session_id];
489 
490 	if (ucontrol->value.integer.value[0]) {
491 		session->port_id = be_id;
492 		snd_soc_dapm_mixer_update_power(dapm, kcontrol, 1, update);
493 	} else {
494 		session->port_id = -1;
495 		snd_soc_dapm_mixer_update_power(dapm, kcontrol, 0, update);
496 	}
497 
498 	return 1;
499 }
500 
501 static const struct snd_kcontrol_new hdmi_mixer_controls[] = {
502 	Q6ROUTING_RX_MIXERS(HDMI_RX) };
503 
504 static const struct snd_kcontrol_new display_port_mixer_controls[] = {
505 	Q6ROUTING_RX_MIXERS(DISPLAY_PORT_RX) };
506 
507 static const struct snd_kcontrol_new primary_mi2s_rx_mixer_controls[] = {
508 	Q6ROUTING_RX_MIXERS(PRIMARY_MI2S_RX) };
509 
510 static const struct snd_kcontrol_new secondary_mi2s_rx_mixer_controls[] = {
511 	Q6ROUTING_RX_MIXERS(SECONDARY_MI2S_RX) };
512 
513 static const struct snd_kcontrol_new quaternary_mi2s_rx_mixer_controls[] = {
514 	Q6ROUTING_RX_MIXERS(QUATERNARY_MI2S_RX) };
515 
516 static const struct snd_kcontrol_new tertiary_mi2s_rx_mixer_controls[] = {
517 	Q6ROUTING_RX_MIXERS(TERTIARY_MI2S_RX) };
518 
519 static const struct snd_kcontrol_new slimbus_rx_mixer_controls[] = {
520 	Q6ROUTING_RX_MIXERS(SLIMBUS_0_RX) };
521 
522 static const struct snd_kcontrol_new slimbus_1_rx_mixer_controls[] = {
523 	Q6ROUTING_RX_MIXERS(SLIMBUS_1_RX) };
524 
525 static const struct snd_kcontrol_new slimbus_2_rx_mixer_controls[] = {
526 	Q6ROUTING_RX_MIXERS(SLIMBUS_2_RX) };
527 
528 static const struct snd_kcontrol_new slimbus_3_rx_mixer_controls[] = {
529 	Q6ROUTING_RX_MIXERS(SLIMBUS_3_RX) };
530 
531 static const struct snd_kcontrol_new slimbus_4_rx_mixer_controls[] = {
532 	Q6ROUTING_RX_MIXERS(SLIMBUS_4_RX) };
533 
534 static const struct snd_kcontrol_new slimbus_5_rx_mixer_controls[] = {
535 	Q6ROUTING_RX_MIXERS(SLIMBUS_5_RX) };
536 
537 static const struct snd_kcontrol_new slimbus_6_rx_mixer_controls[] = {
538 	Q6ROUTING_RX_MIXERS(SLIMBUS_6_RX) };
539 
540 static const struct snd_kcontrol_new pri_tdm_rx_0_mixer_controls[] = {
541 	Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_0) };
542 
543 static const struct snd_kcontrol_new pri_tdm_rx_1_mixer_controls[] = {
544 	Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_1) };
545 
546 static const struct snd_kcontrol_new pri_tdm_rx_2_mixer_controls[] = {
547 	Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_2) };
548 
549 static const struct snd_kcontrol_new pri_tdm_rx_3_mixer_controls[] = {
550 	Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_3) };
551 
552 static const struct snd_kcontrol_new pri_tdm_rx_4_mixer_controls[] = {
553 	Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_4) };
554 
555 static const struct snd_kcontrol_new pri_tdm_rx_5_mixer_controls[] = {
556 	Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_5) };
557 
558 static const struct snd_kcontrol_new pri_tdm_rx_6_mixer_controls[] = {
559 	Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_6) };
560 
561 static const struct snd_kcontrol_new pri_tdm_rx_7_mixer_controls[] = {
562 	Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_7) };
563 
564 static const struct snd_kcontrol_new sec_tdm_rx_0_mixer_controls[] = {
565 	Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_0) };
566 
567 static const struct snd_kcontrol_new sec_tdm_rx_1_mixer_controls[] = {
568 	Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_1) };
569 
570 static const struct snd_kcontrol_new sec_tdm_rx_2_mixer_controls[] = {
571 	Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_2) };
572 
573 static const struct snd_kcontrol_new sec_tdm_rx_3_mixer_controls[] = {
574 	Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_3) };
575 
576 static const struct snd_kcontrol_new sec_tdm_rx_4_mixer_controls[] = {
577 	Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_4) };
578 
579 static const struct snd_kcontrol_new sec_tdm_rx_5_mixer_controls[] = {
580 	Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_5) };
581 
582 static const struct snd_kcontrol_new sec_tdm_rx_6_mixer_controls[] = {
583 	Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_6) };
584 
585 static const struct snd_kcontrol_new sec_tdm_rx_7_mixer_controls[] = {
586 	Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_7) };
587 
588 static const struct snd_kcontrol_new tert_tdm_rx_0_mixer_controls[] = {
589 	Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_0) };
590 
591 static const struct snd_kcontrol_new tert_tdm_rx_1_mixer_controls[] = {
592 	Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_1) };
593 
594 static const struct snd_kcontrol_new tert_tdm_rx_2_mixer_controls[] = {
595 	Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_2) };
596 
597 static const struct snd_kcontrol_new tert_tdm_rx_3_mixer_controls[] = {
598 	Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_3) };
599 
600 static const struct snd_kcontrol_new tert_tdm_rx_4_mixer_controls[] = {
601 	Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_4) };
602 
603 static const struct snd_kcontrol_new tert_tdm_rx_5_mixer_controls[] = {
604 	Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_5) };
605 
606 static const struct snd_kcontrol_new tert_tdm_rx_6_mixer_controls[] = {
607 	Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_6) };
608 
609 static const struct snd_kcontrol_new tert_tdm_rx_7_mixer_controls[] = {
610 	Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_7) };
611 
612 static const struct snd_kcontrol_new quat_tdm_rx_0_mixer_controls[] = {
613 	Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_0) };
614 
615 static const struct snd_kcontrol_new quat_tdm_rx_1_mixer_controls[] = {
616 	Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_1) };
617 
618 static const struct snd_kcontrol_new quat_tdm_rx_2_mixer_controls[] = {
619 	Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_2) };
620 
621 static const struct snd_kcontrol_new quat_tdm_rx_3_mixer_controls[] = {
622 	Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_3) };
623 
624 static const struct snd_kcontrol_new quat_tdm_rx_4_mixer_controls[] = {
625 	Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_4) };
626 
627 static const struct snd_kcontrol_new quat_tdm_rx_5_mixer_controls[] = {
628 	Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_5) };
629 
630 static const struct snd_kcontrol_new quat_tdm_rx_6_mixer_controls[] = {
631 	Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_6) };
632 
633 static const struct snd_kcontrol_new quat_tdm_rx_7_mixer_controls[] = {
634 	Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_7) };
635 
636 static const struct snd_kcontrol_new quin_tdm_rx_0_mixer_controls[] = {
637 	Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_0) };
638 
639 static const struct snd_kcontrol_new quin_tdm_rx_1_mixer_controls[] = {
640 	Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_1) };
641 
642 static const struct snd_kcontrol_new quin_tdm_rx_2_mixer_controls[] = {
643 	Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_2) };
644 
645 static const struct snd_kcontrol_new quin_tdm_rx_3_mixer_controls[] = {
646 	Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_3) };
647 
648 static const struct snd_kcontrol_new quin_tdm_rx_4_mixer_controls[] = {
649 	Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_4) };
650 
651 static const struct snd_kcontrol_new quin_tdm_rx_5_mixer_controls[] = {
652 	Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_5) };
653 
654 static const struct snd_kcontrol_new quin_tdm_rx_6_mixer_controls[] = {
655 	Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_6) };
656 
657 static const struct snd_kcontrol_new quin_tdm_rx_7_mixer_controls[] = {
658 	Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_7) };
659 
660 static const struct snd_kcontrol_new wsa_codec_dma_rx_0_mixer_controls[] = {
661 	Q6ROUTING_RX_MIXERS(WSA_CODEC_DMA_RX_0) };
662 
663 static const struct snd_kcontrol_new wsa_codec_dma_rx_1_mixer_controls[] = {
664 	Q6ROUTING_RX_MIXERS(WSA_CODEC_DMA_RX_1) };
665 
666 static const struct snd_kcontrol_new rx_codec_dma_rx_0_mixer_controls[] = {
667 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_0) };
668 
669 static const struct snd_kcontrol_new rx_codec_dma_rx_1_mixer_controls[] = {
670 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_1) };
671 
672 static const struct snd_kcontrol_new rx_codec_dma_rx_2_mixer_controls[] = {
673 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_2) };
674 
675 static const struct snd_kcontrol_new rx_codec_dma_rx_3_mixer_controls[] = {
676 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_3) };
677 
678 static const struct snd_kcontrol_new rx_codec_dma_rx_4_mixer_controls[] = {
679 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_4) };
680 
681 static const struct snd_kcontrol_new rx_codec_dma_rx_5_mixer_controls[] = {
682 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_5) };
683 
684 static const struct snd_kcontrol_new rxcodec_dma_rx_6_mixer_controls[] = {
685 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_6) };
686 
687 static const struct snd_kcontrol_new rx_codec_dma_rx_7_mixer_controls[] = {
688 	Q6ROUTING_RX_MIXERS(RX_CODEC_DMA_RX_7) };
689 
690 
691 static const struct snd_kcontrol_new mmul1_mixer_controls[] = {
692 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA1) };
693 
694 static const struct snd_kcontrol_new mmul2_mixer_controls[] = {
695 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA2) };
696 
697 static const struct snd_kcontrol_new mmul3_mixer_controls[] = {
698 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA3) };
699 
700 static const struct snd_kcontrol_new mmul4_mixer_controls[] = {
701 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA4) };
702 
703 static const struct snd_kcontrol_new mmul5_mixer_controls[] = {
704 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA5) };
705 
706 static const struct snd_kcontrol_new mmul6_mixer_controls[] = {
707 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA6) };
708 
709 static const struct snd_kcontrol_new mmul7_mixer_controls[] = {
710 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA7) };
711 
712 static const struct snd_kcontrol_new mmul8_mixer_controls[] = {
713 	Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA8) };
714 
715 static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
716 	/* Mixer definitions */
717 	SND_SOC_DAPM_MIXER("HDMI Mixer", SND_SOC_NOPM, 0, 0,
718 			   hdmi_mixer_controls,
719 			   ARRAY_SIZE(hdmi_mixer_controls)),
720 
721 	SND_SOC_DAPM_MIXER("DISPLAY_PORT_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
722 			   display_port_mixer_controls,
723 			   ARRAY_SIZE(display_port_mixer_controls)),
724 
725 	SND_SOC_DAPM_MIXER("SLIMBUS_0_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
726 			   slimbus_rx_mixer_controls,
727 			   ARRAY_SIZE(slimbus_rx_mixer_controls)),
728 	SND_SOC_DAPM_MIXER("SLIMBUS_1_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
729 			   slimbus_1_rx_mixer_controls,
730 			   ARRAY_SIZE(slimbus_1_rx_mixer_controls)),
731 	SND_SOC_DAPM_MIXER("SLIMBUS_2_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
732 			   slimbus_2_rx_mixer_controls,
733 			   ARRAY_SIZE(slimbus_2_rx_mixer_controls)),
734 	SND_SOC_DAPM_MIXER("SLIMBUS_3_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
735 			   slimbus_3_rx_mixer_controls,
736 			   ARRAY_SIZE(slimbus_3_rx_mixer_controls)),
737 	SND_SOC_DAPM_MIXER("SLIMBUS_4_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
738 			   slimbus_4_rx_mixer_controls,
739 			   ARRAY_SIZE(slimbus_4_rx_mixer_controls)),
740 	SND_SOC_DAPM_MIXER("SLIMBUS_5_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
741 			   slimbus_5_rx_mixer_controls,
742 			    ARRAY_SIZE(slimbus_5_rx_mixer_controls)),
743 	SND_SOC_DAPM_MIXER("SLIMBUS_6_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
744 			   slimbus_6_rx_mixer_controls,
745 			   ARRAY_SIZE(slimbus_6_rx_mixer_controls)),
746 	SND_SOC_DAPM_MIXER("PRI_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
747 			   primary_mi2s_rx_mixer_controls,
748 			   ARRAY_SIZE(primary_mi2s_rx_mixer_controls)),
749 	SND_SOC_DAPM_MIXER("SEC_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
750 			   secondary_mi2s_rx_mixer_controls,
751 			   ARRAY_SIZE(secondary_mi2s_rx_mixer_controls)),
752 	SND_SOC_DAPM_MIXER("QUAT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
753 			   quaternary_mi2s_rx_mixer_controls,
754 			   ARRAY_SIZE(quaternary_mi2s_rx_mixer_controls)),
755 	SND_SOC_DAPM_MIXER("TERT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0,
756 			   tertiary_mi2s_rx_mixer_controls,
757 			   ARRAY_SIZE(tertiary_mi2s_rx_mixer_controls)),
758 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
759 				pri_tdm_rx_0_mixer_controls,
760 				ARRAY_SIZE(pri_tdm_rx_0_mixer_controls)),
761 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
762 				pri_tdm_rx_1_mixer_controls,
763 				ARRAY_SIZE(pri_tdm_rx_1_mixer_controls)),
764 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
765 				pri_tdm_rx_2_mixer_controls,
766 				ARRAY_SIZE(pri_tdm_rx_2_mixer_controls)),
767 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
768 				pri_tdm_rx_3_mixer_controls,
769 				ARRAY_SIZE(pri_tdm_rx_3_mixer_controls)),
770 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0,
771 				pri_tdm_rx_4_mixer_controls,
772 				ARRAY_SIZE(pri_tdm_rx_4_mixer_controls)),
773 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0,
774 				pri_tdm_rx_5_mixer_controls,
775 				ARRAY_SIZE(pri_tdm_rx_5_mixer_controls)),
776 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0,
777 				pri_tdm_rx_6_mixer_controls,
778 				ARRAY_SIZE(pri_tdm_rx_6_mixer_controls)),
779 	SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0,
780 				pri_tdm_rx_7_mixer_controls,
781 				ARRAY_SIZE(pri_tdm_rx_7_mixer_controls)),
782 
783 	SND_SOC_DAPM_MIXER("SEC_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
784 				sec_tdm_rx_0_mixer_controls,
785 				ARRAY_SIZE(sec_tdm_rx_0_mixer_controls)),
786 	SND_SOC_DAPM_MIXER("SEC_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
787 				sec_tdm_rx_1_mixer_controls,
788 				ARRAY_SIZE(sec_tdm_rx_1_mixer_controls)),
789 	SND_SOC_DAPM_MIXER("SEC_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
790 				sec_tdm_rx_2_mixer_controls,
791 				ARRAY_SIZE(sec_tdm_rx_2_mixer_controls)),
792 	SND_SOC_DAPM_MIXER("SEC_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
793 				sec_tdm_rx_3_mixer_controls,
794 				ARRAY_SIZE(sec_tdm_rx_3_mixer_controls)),
795 	SND_SOC_DAPM_MIXER("SEC_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0,
796 				sec_tdm_rx_4_mixer_controls,
797 				ARRAY_SIZE(sec_tdm_rx_4_mixer_controls)),
798 	SND_SOC_DAPM_MIXER("SEC_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0,
799 				sec_tdm_rx_5_mixer_controls,
800 				ARRAY_SIZE(sec_tdm_rx_5_mixer_controls)),
801 	SND_SOC_DAPM_MIXER("SEC_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0,
802 				sec_tdm_rx_6_mixer_controls,
803 				ARRAY_SIZE(sec_tdm_rx_6_mixer_controls)),
804 	SND_SOC_DAPM_MIXER("SEC_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0,
805 				sec_tdm_rx_7_mixer_controls,
806 				ARRAY_SIZE(sec_tdm_rx_7_mixer_controls)),
807 
808 	SND_SOC_DAPM_MIXER("TERT_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
809 				tert_tdm_rx_0_mixer_controls,
810 				ARRAY_SIZE(tert_tdm_rx_0_mixer_controls)),
811 	SND_SOC_DAPM_MIXER("TERT_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
812 				tert_tdm_rx_1_mixer_controls,
813 				ARRAY_SIZE(tert_tdm_rx_1_mixer_controls)),
814 	SND_SOC_DAPM_MIXER("TERT_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
815 				tert_tdm_rx_2_mixer_controls,
816 				ARRAY_SIZE(tert_tdm_rx_2_mixer_controls)),
817 	SND_SOC_DAPM_MIXER("TERT_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
818 				tert_tdm_rx_3_mixer_controls,
819 				ARRAY_SIZE(tert_tdm_rx_3_mixer_controls)),
820 	SND_SOC_DAPM_MIXER("TERT_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0,
821 				tert_tdm_rx_4_mixer_controls,
822 				ARRAY_SIZE(tert_tdm_rx_4_mixer_controls)),
823 	SND_SOC_DAPM_MIXER("TERT_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0,
824 				tert_tdm_rx_5_mixer_controls,
825 				ARRAY_SIZE(tert_tdm_rx_5_mixer_controls)),
826 	SND_SOC_DAPM_MIXER("TERT_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0,
827 				tert_tdm_rx_6_mixer_controls,
828 				ARRAY_SIZE(tert_tdm_rx_6_mixer_controls)),
829 	SND_SOC_DAPM_MIXER("TERT_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0,
830 				tert_tdm_rx_7_mixer_controls,
831 				ARRAY_SIZE(tert_tdm_rx_7_mixer_controls)),
832 
833 	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
834 				quat_tdm_rx_0_mixer_controls,
835 				ARRAY_SIZE(quat_tdm_rx_0_mixer_controls)),
836 	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
837 				quat_tdm_rx_1_mixer_controls,
838 				ARRAY_SIZE(quat_tdm_rx_1_mixer_controls)),
839 	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
840 				quat_tdm_rx_2_mixer_controls,
841 				ARRAY_SIZE(quat_tdm_rx_2_mixer_controls)),
842 	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
843 				quat_tdm_rx_3_mixer_controls,
844 				ARRAY_SIZE(quat_tdm_rx_3_mixer_controls)),
845 	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0,
846 				quat_tdm_rx_4_mixer_controls,
847 				ARRAY_SIZE(quat_tdm_rx_4_mixer_controls)),
848 	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0,
849 				quat_tdm_rx_5_mixer_controls,
850 				ARRAY_SIZE(quat_tdm_rx_5_mixer_controls)),
851 	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0,
852 				quat_tdm_rx_6_mixer_controls,
853 				ARRAY_SIZE(quat_tdm_rx_6_mixer_controls)),
854 	SND_SOC_DAPM_MIXER("QUAT_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0,
855 				quat_tdm_rx_7_mixer_controls,
856 				ARRAY_SIZE(quat_tdm_rx_7_mixer_controls)),
857 
858 	SND_SOC_DAPM_MIXER("QUIN_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
859 				quin_tdm_rx_0_mixer_controls,
860 				ARRAY_SIZE(quin_tdm_rx_0_mixer_controls)),
861 	SND_SOC_DAPM_MIXER("QUIN_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
862 				quin_tdm_rx_1_mixer_controls,
863 				ARRAY_SIZE(quin_tdm_rx_1_mixer_controls)),
864 	SND_SOC_DAPM_MIXER("QUIN_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
865 				quin_tdm_rx_2_mixer_controls,
866 				ARRAY_SIZE(quin_tdm_rx_2_mixer_controls)),
867 	SND_SOC_DAPM_MIXER("QUIN_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
868 				quin_tdm_rx_3_mixer_controls,
869 				ARRAY_SIZE(quin_tdm_rx_3_mixer_controls)),
870 	SND_SOC_DAPM_MIXER("QUIN_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0,
871 				quin_tdm_rx_4_mixer_controls,
872 				ARRAY_SIZE(quin_tdm_rx_4_mixer_controls)),
873 	SND_SOC_DAPM_MIXER("QUIN_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0,
874 				quin_tdm_rx_5_mixer_controls,
875 				ARRAY_SIZE(quin_tdm_rx_5_mixer_controls)),
876 	SND_SOC_DAPM_MIXER("QUIN_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0,
877 				quin_tdm_rx_6_mixer_controls,
878 				ARRAY_SIZE(quin_tdm_rx_6_mixer_controls)),
879 	SND_SOC_DAPM_MIXER("QUIN_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0,
880 				quin_tdm_rx_7_mixer_controls,
881 				ARRAY_SIZE(quin_tdm_rx_7_mixer_controls)),
882 
883 	SND_SOC_DAPM_MIXER("WSA_CODEC_DMA_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
884 		wsa_codec_dma_rx_0_mixer_controls,
885 		ARRAY_SIZE(wsa_codec_dma_rx_0_mixer_controls)),
886 	SND_SOC_DAPM_MIXER("WSA_CODEC_DMA_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
887 		wsa_codec_dma_rx_1_mixer_controls,
888 		ARRAY_SIZE(wsa_codec_dma_rx_1_mixer_controls)),
889 	SND_SOC_DAPM_MIXER("RX_CODEC_DMA_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0,
890 		rx_codec_dma_rx_0_mixer_controls,
891 		ARRAY_SIZE(rx_codec_dma_rx_0_mixer_controls)),
892 	SND_SOC_DAPM_MIXER("RX_CODEC_DMA_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0,
893 		rx_codec_dma_rx_1_mixer_controls,
894 		ARRAY_SIZE(rx_codec_dma_rx_1_mixer_controls)),
895 	SND_SOC_DAPM_MIXER("RX_CODEC_DMA_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0,
896 		rx_codec_dma_rx_2_mixer_controls,
897 		ARRAY_SIZE(rx_codec_dma_rx_2_mixer_controls)),
898 	SND_SOC_DAPM_MIXER("RX_CODEC_DMA_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0,
899 		rx_codec_dma_rx_3_mixer_controls,
900 		ARRAY_SIZE(rx_codec_dma_rx_3_mixer_controls)),
901 	SND_SOC_DAPM_MIXER("RX_CODEC_DMA_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0,
902 		rx_codec_dma_rx_4_mixer_controls,
903 		ARRAY_SIZE(rx_codec_dma_rx_4_mixer_controls)),
904 	SND_SOC_DAPM_MIXER("RX_CODEC_DMA_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0,
905 		rx_codec_dma_rx_5_mixer_controls,
906 		ARRAY_SIZE(rx_codec_dma_rx_5_mixer_controls)),
907 	SND_SOC_DAPM_MIXER("RX_CODEC_DMA_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0,
908 		rxcodec_dma_rx_6_mixer_controls,
909 		ARRAY_SIZE(rxcodec_dma_rx_6_mixer_controls)),
910 	SND_SOC_DAPM_MIXER("RX_CODEC_DMA_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0,
911 		rx_codec_dma_rx_7_mixer_controls,
912 		ARRAY_SIZE(rx_codec_dma_rx_7_mixer_controls)),
913 	SND_SOC_DAPM_MIXER("MultiMedia1 Mixer", SND_SOC_NOPM, 0, 0,
914 		mmul1_mixer_controls, ARRAY_SIZE(mmul1_mixer_controls)),
915 	SND_SOC_DAPM_MIXER("MultiMedia2 Mixer", SND_SOC_NOPM, 0, 0,
916 		mmul2_mixer_controls, ARRAY_SIZE(mmul2_mixer_controls)),
917 	SND_SOC_DAPM_MIXER("MultiMedia3 Mixer", SND_SOC_NOPM, 0, 0,
918 		mmul3_mixer_controls, ARRAY_SIZE(mmul3_mixer_controls)),
919 	SND_SOC_DAPM_MIXER("MultiMedia4 Mixer", SND_SOC_NOPM, 0, 0,
920 		mmul4_mixer_controls, ARRAY_SIZE(mmul4_mixer_controls)),
921 	SND_SOC_DAPM_MIXER("MultiMedia5 Mixer", SND_SOC_NOPM, 0, 0,
922 		mmul5_mixer_controls, ARRAY_SIZE(mmul5_mixer_controls)),
923 	SND_SOC_DAPM_MIXER("MultiMedia6 Mixer", SND_SOC_NOPM, 0, 0,
924 		mmul6_mixer_controls, ARRAY_SIZE(mmul6_mixer_controls)),
925 	SND_SOC_DAPM_MIXER("MultiMedia7 Mixer", SND_SOC_NOPM, 0, 0,
926 		mmul7_mixer_controls, ARRAY_SIZE(mmul7_mixer_controls)),
927 	SND_SOC_DAPM_MIXER("MultiMedia8 Mixer", SND_SOC_NOPM, 0, 0,
928 		mmul8_mixer_controls, ARRAY_SIZE(mmul8_mixer_controls)),
929 
930 };
931 
932 static const struct snd_soc_dapm_route intercon[] = {
933 	Q6ROUTING_RX_DAPM_ROUTE("HDMI Mixer", "HDMI_RX"),
934 	Q6ROUTING_RX_DAPM_ROUTE("DISPLAY_PORT_RX Audio Mixer",
935 				"DISPLAY_PORT_RX"),
936 	Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_0_RX Audio Mixer", "SLIMBUS_0_RX"),
937 	Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_1_RX Audio Mixer", "SLIMBUS_1_RX"),
938 	Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_2_RX Audio Mixer", "SLIMBUS_2_RX"),
939 	Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_3_RX Audio Mixer", "SLIMBUS_3_RX"),
940 	Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_4_RX Audio Mixer", "SLIMBUS_4_RX"),
941 	Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_5_RX Audio Mixer", "SLIMBUS_5_RX"),
942 	Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_6_RX Audio Mixer", "SLIMBUS_6_RX"),
943 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_MI2S_RX Audio Mixer", "QUAT_MI2S_RX"),
944 	Q6ROUTING_RX_DAPM_ROUTE("TERT_MI2S_RX Audio Mixer", "TERT_MI2S_RX"),
945 	Q6ROUTING_RX_DAPM_ROUTE("SEC_MI2S_RX Audio Mixer", "SEC_MI2S_RX"),
946 	Q6ROUTING_RX_DAPM_ROUTE("PRI_MI2S_RX Audio Mixer", "PRI_MI2S_RX"),
947 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_0 Audio Mixer",
948 				"PRIMARY_TDM_RX_0"),
949 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_1 Audio Mixer",
950 				"PRIMARY_TDM_RX_1"),
951 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_2 Audio Mixer",
952 				"PRIMARY_TDM_RX_2"),
953 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_3 Audio Mixer",
954 				"PRIMARY_TDM_RX_3"),
955 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_4 Audio Mixer",
956 				"PRIMARY_TDM_RX_4"),
957 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_5 Audio Mixer",
958 				"PRIMARY_TDM_RX_5"),
959 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_6 Audio Mixer",
960 				"PRIMARY_TDM_RX_6"),
961 	Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_7 Audio Mixer",
962 				"PRIMARY_TDM_RX_7"),
963 	Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_0 Audio Mixer", "SEC_TDM_RX_0"),
964 	Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_1 Audio Mixer", "SEC_TDM_RX_1"),
965 	Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_2 Audio Mixer", "SEC_TDM_RX_2"),
966 	Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_3 Audio Mixer", "SEC_TDM_RX_3"),
967 	Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_4 Audio Mixer", "SEC_TDM_RX_4"),
968 	Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_5 Audio Mixer", "SEC_TDM_RX_5"),
969 	Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_6 Audio Mixer", "SEC_TDM_RX_6"),
970 	Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_7 Audio Mixer", "SEC_TDM_RX_7"),
971 	Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_0 Audio Mixer", "TERT_TDM_RX_0"),
972 	Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_1 Audio Mixer", "TERT_TDM_RX_1"),
973 	Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_2 Audio Mixer", "TERT_TDM_RX_2"),
974 	Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_3 Audio Mixer", "TERT_TDM_RX_3"),
975 	Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_4 Audio Mixer", "TERT_TDM_RX_4"),
976 	Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_5 Audio Mixer", "TERT_TDM_RX_5"),
977 	Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_6 Audio Mixer", "TERT_TDM_RX_6"),
978 	Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_7 Audio Mixer", "TERT_TDM_RX_7"),
979 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_0 Audio Mixer", "QUAT_TDM_RX_0"),
980 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_1 Audio Mixer", "QUAT_TDM_RX_1"),
981 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_2 Audio Mixer", "QUAT_TDM_RX_2"),
982 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_3 Audio Mixer", "QUAT_TDM_RX_3"),
983 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_4 Audio Mixer", "QUAT_TDM_RX_4"),
984 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_5 Audio Mixer", "QUAT_TDM_RX_5"),
985 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_6 Audio Mixer", "QUAT_TDM_RX_6"),
986 	Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_7 Audio Mixer", "QUAT_TDM_RX_7"),
987 	Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_0 Audio Mixer", "QUIN_TDM_RX_0"),
988 	Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_1 Audio Mixer", "QUIN_TDM_RX_1"),
989 	Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_2 Audio Mixer", "QUIN_TDM_RX_2"),
990 	Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_3 Audio Mixer", "QUIN_TDM_RX_3"),
991 	Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_4 Audio Mixer", "QUIN_TDM_RX_4"),
992 	Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_5 Audio Mixer", "QUIN_TDM_RX_5"),
993 	Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_6 Audio Mixer", "QUIN_TDM_RX_6"),
994 	Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_7 Audio Mixer", "QUIN_TDM_RX_7"),
995 	Q6ROUTING_RX_DAPM_ROUTE("WSA_CODEC_DMA_RX_0 Audio Mixer", "WSA_CODEC_DMA_RX_0"),
996 	Q6ROUTING_RX_DAPM_ROUTE("WSA_CODEC_DMA_RX_1 Audio Mixer", "WSA_CODEC_DMA_RX_1"),
997 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_0 Audio Mixer", "RX_CODEC_DMA_RX_0"),
998 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_1 Audio Mixer", "RX_CODEC_DMA_RX_1"),
999 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_2 Audio Mixer", "RX_CODEC_DMA_RX_2"),
1000 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_3 Audio Mixer", "RX_CODEC_DMA_RX_3"),
1001 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_4 Audio Mixer", "RX_CODEC_DMA_RX_4"),
1002 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_5 Audio Mixer", "RX_CODEC_DMA_RX_5"),
1003 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_6 Audio Mixer", "RX_CODEC_DMA_RX_6"),
1004 	Q6ROUTING_RX_DAPM_ROUTE("RX_CODEC_DMA_RX_7 Audio Mixer", "RX_CODEC_DMA_RX_7"),
1005 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia1 Mixer"),
1006 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia2 Mixer"),
1007 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia3 Mixer"),
1008 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia4 Mixer"),
1009 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia5 Mixer"),
1010 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia6 Mixer"),
1011 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia7 Mixer"),
1012 	Q6ROUTING_TX_DAPM_ROUTE("MultiMedia8 Mixer"),
1013 
1014 	{"MM_UL1", NULL, "MultiMedia1 Mixer"},
1015 	{"MM_UL2", NULL, "MultiMedia2 Mixer"},
1016 	{"MM_UL3", NULL, "MultiMedia3 Mixer"},
1017 	{"MM_UL4", NULL, "MultiMedia4 Mixer"},
1018 	{"MM_UL5", NULL, "MultiMedia5 Mixer"},
1019 	{"MM_UL6", NULL, "MultiMedia6 Mixer"},
1020 	{"MM_UL7", NULL, "MultiMedia7 Mixer"},
1021 	{"MM_UL8", NULL, "MultiMedia8 Mixer"},
1022 };
1023 
1024 static int routing_hw_params(struct snd_soc_component *component,
1025 			     struct snd_pcm_substream *substream,
1026 			     struct snd_pcm_hw_params *params)
1027 {
1028 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
1029 	struct msm_routing_data *data = dev_get_drvdata(component->dev);
1030 	unsigned int be_id = asoc_rtd_to_cpu(rtd, 0)->id;
1031 	struct session_data *session;
1032 	int path_type;
1033 
1034 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
1035 		path_type = ADM_PATH_PLAYBACK;
1036 	else
1037 		path_type = ADM_PATH_LIVE_REC;
1038 
1039 	if (be_id >= AFE_MAX_PORTS)
1040 		return -EINVAL;
1041 
1042 	session = &data->port_data[be_id];
1043 
1044 	mutex_lock(&data->lock);
1045 
1046 	session->path_type = path_type;
1047 	session->sample_rate = params_rate(params);
1048 	session->channels = params_channels(params);
1049 
1050 	switch (params_format(params)) {
1051 	case SNDRV_PCM_FORMAT_S16_LE:
1052 			session->bits_per_sample = 16;
1053 		break;
1054 	case SNDRV_PCM_FORMAT_S24_LE:
1055 			session->bits_per_sample = 24;
1056 		break;
1057 	default:
1058 		break;
1059 	}
1060 
1061 	mutex_unlock(&data->lock);
1062 	return 0;
1063 }
1064 
1065 static int msm_routing_probe(struct snd_soc_component *c)
1066 {
1067 	int i;
1068 
1069 	for (i = 0; i < MAX_SESSIONS; i++) {
1070 		routing_data->sessions[i].port_id = -1;
1071 		routing_data->sessions[i].fedai_id = -1;
1072 	}
1073 
1074 	return 0;
1075 }
1076 
1077 static unsigned int q6routing_reg_read(struct snd_soc_component *component,
1078 				       unsigned int reg)
1079 {
1080 	/* default value */
1081 	return 0;
1082 }
1083 
1084 static int q6routing_reg_write(struct snd_soc_component *component,
1085 			       unsigned int reg, unsigned int val)
1086 {
1087 	/* dummy */
1088 	return 0;
1089 }
1090 
1091 static const struct snd_soc_component_driver msm_soc_routing_component = {
1092 	.probe = msm_routing_probe,
1093 	.name = DRV_NAME,
1094 	.hw_params = routing_hw_params,
1095 	.dapm_widgets = msm_qdsp6_widgets,
1096 	.num_dapm_widgets = ARRAY_SIZE(msm_qdsp6_widgets),
1097 	.dapm_routes = intercon,
1098 	.num_dapm_routes = ARRAY_SIZE(intercon),
1099 	.read = q6routing_reg_read,
1100 	.write = q6routing_reg_write,
1101 };
1102 
1103 static int q6pcm_routing_probe(struct platform_device *pdev)
1104 {
1105 	struct device *dev = &pdev->dev;
1106 
1107 	routing_data = kzalloc(sizeof(*routing_data), GFP_KERNEL);
1108 	if (!routing_data)
1109 		return -ENOMEM;
1110 
1111 	routing_data->dev = dev;
1112 
1113 	mutex_init(&routing_data->lock);
1114 	dev_set_drvdata(dev, routing_data);
1115 
1116 	return devm_snd_soc_register_component(dev, &msm_soc_routing_component,
1117 					  NULL, 0);
1118 }
1119 
1120 static int q6pcm_routing_remove(struct platform_device *pdev)
1121 {
1122 	kfree(routing_data);
1123 	routing_data = NULL;
1124 
1125 	return 0;
1126 }
1127 
1128 #ifdef CONFIG_OF
1129 static const struct of_device_id q6pcm_routing_device_id[] = {
1130 	{ .compatible = "qcom,q6adm-routing" },
1131 	{},
1132 };
1133 MODULE_DEVICE_TABLE(of, q6pcm_routing_device_id);
1134 #endif
1135 
1136 static struct platform_driver q6pcm_routing_platform_driver = {
1137 	.driver = {
1138 		.name = "q6routing",
1139 		.of_match_table = of_match_ptr(q6pcm_routing_device_id),
1140 	},
1141 	.probe = q6pcm_routing_probe,
1142 	.remove = q6pcm_routing_remove,
1143 };
1144 module_platform_driver(q6pcm_routing_platform_driver);
1145 
1146 MODULE_DESCRIPTION("Q6 Routing platform");
1147 MODULE_LICENSE("GPL v2");
1148