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