blob: 93a306fe8eb11907d614b4e21a692489ef8187d6 [file] [log] [blame]
Anver sadhique276e2a42021-02-16 11:35:57 +05301/* Copyright (c) 2012-2017, 2021, The Linux Foundation. All rights reserved.
Alexander Martinz28de9412021-09-09 17:05:05 +02002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/slab.h>
14#include <linux/wait.h>
15#include <linux/sched.h>
16#include <linux/jiffies.h>
17#include <linux/uaccess.h>
18#include <linux/atomic.h>
19#include <dsp/q6afe-v2.h>
20#include <dsp/q6audio-v2.h>
21
22int q6audio_get_port_index(u16 port_id)
23{
24 switch (port_id) {
25 case PRIMARY_I2S_RX: return IDX_PRIMARY_I2S_RX;
26 case PRIMARY_I2S_TX: return IDX_PRIMARY_I2S_TX;
27 case AFE_PORT_ID_PRIMARY_PCM_RX:
28 return IDX_AFE_PORT_ID_PRIMARY_PCM_RX;
29 case AFE_PORT_ID_PRIMARY_PCM_TX:
30 return IDX_AFE_PORT_ID_PRIMARY_PCM_TX;
31 case AFE_PORT_ID_SECONDARY_PCM_RX:
32 return IDX_AFE_PORT_ID_SECONDARY_PCM_RX;
33 case AFE_PORT_ID_SECONDARY_PCM_TX:
34 return IDX_AFE_PORT_ID_SECONDARY_PCM_TX;
35 case AFE_PORT_ID_TERTIARY_PCM_RX:
36 return IDX_AFE_PORT_ID_TERTIARY_PCM_RX;
37 case AFE_PORT_ID_TERTIARY_PCM_TX:
38 return IDX_AFE_PORT_ID_TERTIARY_PCM_TX;
39 case AFE_PORT_ID_QUATERNARY_PCM_RX:
40 return IDX_AFE_PORT_ID_QUATERNARY_PCM_RX;
41 case AFE_PORT_ID_QUATERNARY_PCM_TX:
42 return IDX_AFE_PORT_ID_QUATERNARY_PCM_TX;
43 case AFE_PORT_ID_QUINARY_PCM_RX:
44 return IDX_AFE_PORT_ID_QUINARY_PCM_RX;
45 case AFE_PORT_ID_QUINARY_PCM_TX:
46 return IDX_AFE_PORT_ID_QUINARY_PCM_TX;
47 case SECONDARY_I2S_RX: return IDX_SECONDARY_I2S_RX;
48 case SECONDARY_I2S_TX: return IDX_SECONDARY_I2S_TX;
49 case MI2S_RX: return IDX_MI2S_RX;
50 case MI2S_TX: return IDX_MI2S_TX;
51 case HDMI_RX: return IDX_HDMI_RX;
52 case DISPLAY_PORT_RX: return IDX_DISPLAY_PORT_RX;
53 case AFE_PORT_ID_SPDIF_RX: return IDX_SPDIF_RX;
54 case RSVD_2: return IDX_RSVD_2;
55 case RSVD_3: return IDX_RSVD_3;
56 case DIGI_MIC_TX: return IDX_DIGI_MIC_TX;
57 case VOICE_RECORD_RX: return IDX_VOICE_RECORD_RX;
58 case VOICE_RECORD_TX: return IDX_VOICE_RECORD_TX;
59 case VOICE_PLAYBACK_TX: return IDX_VOICE_PLAYBACK_TX;
60 case VOICE2_PLAYBACK_TX: return IDX_VOICE2_PLAYBACK_TX;
61 case SLIMBUS_0_RX: return IDX_SLIMBUS_0_RX;
62 case SLIMBUS_0_TX: return IDX_SLIMBUS_0_TX;
63 case SLIMBUS_1_RX: return IDX_SLIMBUS_1_RX;
64 case SLIMBUS_1_TX: return IDX_SLIMBUS_1_TX;
65 case SLIMBUS_2_RX: return IDX_SLIMBUS_2_RX;
66 case SLIMBUS_2_TX: return IDX_SLIMBUS_2_TX;
67 case SLIMBUS_3_RX: return IDX_SLIMBUS_3_RX;
68 case SLIMBUS_3_TX: return IDX_SLIMBUS_3_TX;
69 case SLIMBUS_4_RX: return IDX_SLIMBUS_4_RX;
70 case SLIMBUS_4_TX: return IDX_SLIMBUS_4_TX;
71 case SLIMBUS_5_RX: return IDX_SLIMBUS_5_RX;
72 case SLIMBUS_5_TX: return IDX_SLIMBUS_5_TX;
73 case SLIMBUS_6_RX: return IDX_SLIMBUS_6_RX;
74 case SLIMBUS_6_TX: return IDX_SLIMBUS_6_TX;
75 case SLIMBUS_7_RX: return IDX_SLIMBUS_7_RX;
76 case SLIMBUS_7_TX: return IDX_SLIMBUS_7_TX;
77 case SLIMBUS_8_RX: return IDX_SLIMBUS_8_RX;
78 case SLIMBUS_8_TX: return IDX_SLIMBUS_8_TX;
79 case INT_BT_SCO_RX: return IDX_INT_BT_SCO_RX;
80 case INT_BT_SCO_TX: return IDX_INT_BT_SCO_TX;
81 case INT_BT_A2DP_RX: return IDX_INT_BT_A2DP_RX;
82 case INT_FM_RX: return IDX_INT_FM_RX;
83 case INT_FM_TX: return IDX_INT_FM_TX;
84 case RT_PROXY_PORT_001_RX: return IDX_RT_PROXY_PORT_001_RX;
85 case RT_PROXY_PORT_001_TX: return IDX_RT_PROXY_PORT_001_TX;
86 case AFE_PORT_ID_PRIMARY_MI2S_RX:
87 return IDX_AFE_PORT_ID_PRIMARY_MI2S_RX;
88 case AFE_PORT_ID_PRIMARY_MI2S_TX:
89 return IDX_AFE_PORT_ID_PRIMARY_MI2S_TX;
90 case AFE_PORT_ID_QUATERNARY_MI2S_RX:
91 return IDX_AFE_PORT_ID_QUATERNARY_MI2S_RX;
92 case AFE_PORT_ID_QUATERNARY_MI2S_TX:
93 return IDX_AFE_PORT_ID_QUATERNARY_MI2S_TX;
94 case AFE_PORT_ID_SECONDARY_MI2S_RX:
95 return IDX_AFE_PORT_ID_SECONDARY_MI2S_RX;
96 case AFE_PORT_ID_SECONDARY_MI2S_TX:
97 return IDX_AFE_PORT_ID_SECONDARY_MI2S_TX;
98 case AFE_PORT_ID_TERTIARY_MI2S_RX:
99 return IDX_AFE_PORT_ID_TERTIARY_MI2S_RX;
100 case AFE_PORT_ID_TERTIARY_MI2S_TX:
101 return IDX_AFE_PORT_ID_TERTIARY_MI2S_TX;
102 case AFE_PORT_ID_QUINARY_MI2S_RX:
103 return IDX_AFE_PORT_ID_QUINARY_MI2S_RX;
104 case AFE_PORT_ID_QUINARY_MI2S_TX:
105 return IDX_AFE_PORT_ID_QUINARY_MI2S_TX;
106 case AUDIO_PORT_ID_I2S_RX:
107 return IDX_AUDIO_PORT_ID_I2S_RX;
108 case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
109 return IDX_AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
110 case AFE_PORT_ID_PRIMARY_TDM_RX:
111 return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_0;
112 case AFE_PORT_ID_PRIMARY_TDM_TX:
113 return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_0;
114 case AFE_PORT_ID_PRIMARY_TDM_RX_1:
115 return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_1;
116 case AFE_PORT_ID_PRIMARY_TDM_TX_1:
117 return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_1;
118 case AFE_PORT_ID_PRIMARY_TDM_RX_2:
119 return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_2;
120 case AFE_PORT_ID_PRIMARY_TDM_TX_2:
121 return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_2;
122 case AFE_PORT_ID_PRIMARY_TDM_RX_3:
123 return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_3;
124 case AFE_PORT_ID_PRIMARY_TDM_TX_3:
125 return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_3;
126 case AFE_PORT_ID_PRIMARY_TDM_RX_4:
127 return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_4;
128 case AFE_PORT_ID_PRIMARY_TDM_TX_4:
129 return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_4;
130 case AFE_PORT_ID_PRIMARY_TDM_RX_5:
131 return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_5;
132 case AFE_PORT_ID_PRIMARY_TDM_TX_5:
133 return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_5;
134 case AFE_PORT_ID_PRIMARY_TDM_RX_6:
135 return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_6;
136 case AFE_PORT_ID_PRIMARY_TDM_TX_6:
137 return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_6;
138 case AFE_PORT_ID_PRIMARY_TDM_RX_7:
139 return IDX_AFE_PORT_ID_PRIMARY_TDM_RX_7;
140 case AFE_PORT_ID_PRIMARY_TDM_TX_7:
141 return IDX_AFE_PORT_ID_PRIMARY_TDM_TX_7;
142 case AFE_PORT_ID_SECONDARY_TDM_RX:
143 return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_0;
144 case AFE_PORT_ID_SECONDARY_TDM_TX:
145 return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_0;
146 case AFE_PORT_ID_SECONDARY_TDM_RX_1:
147 return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_1;
148 case AFE_PORT_ID_SECONDARY_TDM_TX_1:
149 return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_1;
150 case AFE_PORT_ID_SECONDARY_TDM_RX_2:
151 return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_2;
152 case AFE_PORT_ID_SECONDARY_TDM_TX_2:
153 return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_2;
154 case AFE_PORT_ID_SECONDARY_TDM_RX_3:
155 return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_3;
156 case AFE_PORT_ID_SECONDARY_TDM_TX_3:
157 return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_3;
158 case AFE_PORT_ID_SECONDARY_TDM_RX_4:
159 return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_4;
160 case AFE_PORT_ID_SECONDARY_TDM_TX_4:
161 return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_4;
162 case AFE_PORT_ID_SECONDARY_TDM_RX_5:
163 return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_5;
164 case AFE_PORT_ID_SECONDARY_TDM_TX_5:
165 return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_5;
166 case AFE_PORT_ID_SECONDARY_TDM_RX_6:
167 return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_6;
168 case AFE_PORT_ID_SECONDARY_TDM_TX_6:
169 return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_6;
170 case AFE_PORT_ID_SECONDARY_TDM_RX_7:
171 return IDX_AFE_PORT_ID_SECONDARY_TDM_RX_7;
172 case AFE_PORT_ID_SECONDARY_TDM_TX_7:
173 return IDX_AFE_PORT_ID_SECONDARY_TDM_TX_7;
174 case AFE_PORT_ID_TERTIARY_TDM_RX:
175 return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_0;
176 case AFE_PORT_ID_TERTIARY_TDM_TX:
177 return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_0;
178 case AFE_PORT_ID_TERTIARY_TDM_RX_1:
179 return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_1;
180 case AFE_PORT_ID_TERTIARY_TDM_TX_1:
181 return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_1;
182 case AFE_PORT_ID_TERTIARY_TDM_RX_2:
183 return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_2;
184 case AFE_PORT_ID_TERTIARY_TDM_TX_2:
185 return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_2;
186 case AFE_PORT_ID_TERTIARY_TDM_RX_3:
187 return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_3;
188 case AFE_PORT_ID_TERTIARY_TDM_TX_3:
189 return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_3;
190 case AFE_PORT_ID_TERTIARY_TDM_RX_4:
191 return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_4;
192 case AFE_PORT_ID_TERTIARY_TDM_TX_4:
193 return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_4;
194 case AFE_PORT_ID_TERTIARY_TDM_RX_5:
195 return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_5;
196 case AFE_PORT_ID_TERTIARY_TDM_TX_5:
197 return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_5;
198 case AFE_PORT_ID_TERTIARY_TDM_RX_6:
199 return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_6;
200 case AFE_PORT_ID_TERTIARY_TDM_TX_6:
201 return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_6;
202 case AFE_PORT_ID_TERTIARY_TDM_RX_7:
203 return IDX_AFE_PORT_ID_TERTIARY_TDM_RX_7;
204 case AFE_PORT_ID_TERTIARY_TDM_TX_7:
205 return IDX_AFE_PORT_ID_TERTIARY_TDM_TX_7;
206 case AFE_PORT_ID_QUATERNARY_TDM_RX:
207 return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_0;
208 case AFE_PORT_ID_QUATERNARY_TDM_TX:
209 return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_0;
210 case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
211 return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_1;
212 case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
213 return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_1;
214 case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
215 return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_2;
216 case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
217 return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_2;
218 case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
219 return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_3;
220 case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
221 return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_3;
222 case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
223 return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_4;
224 case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
225 return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_4;
226 case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
227 return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_5;
228 case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
229 return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_5;
230 case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
231 return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_6;
232 case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
233 return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_6;
234 case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
235 return IDX_AFE_PORT_ID_QUATERNARY_TDM_RX_7;
236 case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
237 return IDX_AFE_PORT_ID_QUATERNARY_TDM_TX_7;
238 case AFE_PORT_ID_QUINARY_TDM_RX:
239 return IDX_AFE_PORT_ID_QUINARY_TDM_RX_0;
240 case AFE_PORT_ID_QUINARY_TDM_TX:
241 return IDX_AFE_PORT_ID_QUINARY_TDM_TX_0;
242 case AFE_PORT_ID_QUINARY_TDM_RX_1:
243 return IDX_AFE_PORT_ID_QUINARY_TDM_RX_1;
244 case AFE_PORT_ID_QUINARY_TDM_TX_1:
245 return IDX_AFE_PORT_ID_QUINARY_TDM_TX_1;
246 case AFE_PORT_ID_QUINARY_TDM_RX_2:
247 return IDX_AFE_PORT_ID_QUINARY_TDM_RX_2;
248 case AFE_PORT_ID_QUINARY_TDM_TX_2:
249 return IDX_AFE_PORT_ID_QUINARY_TDM_TX_2;
250 case AFE_PORT_ID_QUINARY_TDM_RX_3:
251 return IDX_AFE_PORT_ID_QUINARY_TDM_RX_3;
252 case AFE_PORT_ID_QUINARY_TDM_TX_3:
253 return IDX_AFE_PORT_ID_QUINARY_TDM_TX_3;
254 case AFE_PORT_ID_QUINARY_TDM_RX_4:
255 return IDX_AFE_PORT_ID_QUINARY_TDM_RX_4;
256 case AFE_PORT_ID_QUINARY_TDM_TX_4:
257 return IDX_AFE_PORT_ID_QUINARY_TDM_TX_4;
258 case AFE_PORT_ID_QUINARY_TDM_RX_5:
259 return IDX_AFE_PORT_ID_QUINARY_TDM_RX_5;
260 case AFE_PORT_ID_QUINARY_TDM_TX_5:
261 return IDX_AFE_PORT_ID_QUINARY_TDM_TX_5;
262 case AFE_PORT_ID_QUINARY_TDM_RX_6:
263 return IDX_AFE_PORT_ID_QUINARY_TDM_RX_6;
264 case AFE_PORT_ID_QUINARY_TDM_TX_6:
265 return IDX_AFE_PORT_ID_QUINARY_TDM_TX_6;
266 case AFE_PORT_ID_QUINARY_TDM_RX_7:
267 return IDX_AFE_PORT_ID_QUINARY_TDM_RX_7;
268 case AFE_PORT_ID_QUINARY_TDM_TX_7:
269 return IDX_AFE_PORT_ID_QUINARY_TDM_TX_7;
270 case AFE_PORT_ID_SENARY_MI2S_TX:
271 return IDX_AFE_PORT_ID_SENARY_MI2S_TX;
272 case AFE_PORT_ID_USB_RX:
273 return IDX_AFE_PORT_ID_USB_RX;
274 case AFE_PORT_ID_USB_TX:
275 return IDX_AFE_PORT_ID_USB_TX;
276 case AFE_PORT_ID_INT0_MI2S_RX:
277 return IDX_AFE_PORT_ID_INT0_MI2S_RX;
278 case AFE_PORT_ID_INT0_MI2S_TX:
279 return IDX_AFE_PORT_ID_INT0_MI2S_TX;
280 case AFE_PORT_ID_INT1_MI2S_RX:
281 return IDX_AFE_PORT_ID_INT1_MI2S_RX;
282 case AFE_PORT_ID_INT1_MI2S_TX:
283 return IDX_AFE_PORT_ID_INT1_MI2S_TX;
284 case AFE_PORT_ID_INT2_MI2S_RX:
285 return IDX_AFE_PORT_ID_INT2_MI2S_RX;
286 case AFE_PORT_ID_INT2_MI2S_TX:
287 return IDX_AFE_PORT_ID_INT2_MI2S_TX;
288 case AFE_PORT_ID_INT3_MI2S_RX:
289 return IDX_AFE_PORT_ID_INT3_MI2S_RX;
290 case AFE_PORT_ID_INT3_MI2S_TX:
291 return IDX_AFE_PORT_ID_INT3_MI2S_TX;
292 case AFE_PORT_ID_INT4_MI2S_RX:
293 return IDX_AFE_PORT_ID_INT4_MI2S_RX;
294 case AFE_PORT_ID_INT4_MI2S_TX:
295 return IDX_AFE_PORT_ID_INT4_MI2S_TX;
296 case AFE_PORT_ID_INT5_MI2S_RX:
297 return IDX_AFE_PORT_ID_INT5_MI2S_RX;
298 case AFE_PORT_ID_INT5_MI2S_TX:
299 return IDX_AFE_PORT_ID_INT5_MI2S_TX;
300 case AFE_PORT_ID_INT6_MI2S_RX:
301 return IDX_AFE_PORT_ID_INT6_MI2S_RX;
302 case AFE_PORT_ID_INT6_MI2S_TX:
303 return IDX_AFE_PORT_ID_INT6_MI2S_TX;
Anver sadhique276e2a42021-02-16 11:35:57 +0530304 case RT_PROXY_PORT_002_RX:
305 return IDX_RT_PROXY_PORT_002_RX;
306 case RT_PROXY_PORT_002_TX:
307 return IDX_RT_PROXY_PORT_002_TX;
Alexander Martinz28de9412021-09-09 17:05:05 +0200308 default: return -EINVAL;
309 }
310}
311
312int q6audio_get_port_id(u16 port_id)
313{
314 switch (port_id) {
315 case PRIMARY_I2S_RX: return PRIMARY_I2S_RX;
316 case PRIMARY_I2S_TX: return PRIMARY_I2S_TX;
317 case AFE_PORT_ID_PRIMARY_PCM_RX:
318 return AFE_PORT_ID_PRIMARY_PCM_RX;
319 case AFE_PORT_ID_PRIMARY_PCM_TX:
320 return AFE_PORT_ID_PRIMARY_PCM_TX;
321 case AFE_PORT_ID_SECONDARY_PCM_RX:
322 return AFE_PORT_ID_SECONDARY_PCM_RX;
323 case AFE_PORT_ID_SECONDARY_PCM_TX:
324 return AFE_PORT_ID_SECONDARY_PCM_TX;
325 case AFE_PORT_ID_TERTIARY_PCM_RX:
326 return AFE_PORT_ID_TERTIARY_PCM_RX;
327 case AFE_PORT_ID_TERTIARY_PCM_TX:
328 return AFE_PORT_ID_TERTIARY_PCM_TX;
329 case AFE_PORT_ID_QUATERNARY_PCM_RX:
330 return AFE_PORT_ID_QUATERNARY_PCM_RX;
331 case AFE_PORT_ID_QUATERNARY_PCM_TX:
332 return AFE_PORT_ID_QUATERNARY_PCM_TX;
333 case AFE_PORT_ID_QUINARY_PCM_RX:
334 return AFE_PORT_ID_QUINARY_PCM_RX;
335 case AFE_PORT_ID_QUINARY_PCM_TX:
336 return AFE_PORT_ID_QUINARY_PCM_TX;
337 case SECONDARY_I2S_RX: return AFE_PORT_ID_SECONDARY_MI2S_RX;
338 case SECONDARY_I2S_TX: return AFE_PORT_ID_SECONDARY_MI2S_TX;
339 case MI2S_RX: return AFE_PORT_ID_PRIMARY_MI2S_RX;
340 case MI2S_TX: return AFE_PORT_ID_PRIMARY_MI2S_TX;
341 case HDMI_RX: return AFE_PORT_ID_MULTICHAN_HDMI_RX;
342 case DISPLAY_PORT_RX:
343 return AFE_PORT_ID_HDMI_OVER_DP_RX;
344 case AFE_PORT_ID_SPDIF_RX: return AFE_PORT_ID_SPDIF_RX;
345 case RSVD_2: return IDX_RSVD_2;
346 case RSVD_3: return IDX_RSVD_3;
347 case DIGI_MIC_TX: return AFE_PORT_ID_DIGITAL_MIC_TX;
348 case VOICE_RECORD_RX: return AFE_PORT_ID_VOICE_RECORD_RX;
349 case VOICE_RECORD_TX: return AFE_PORT_ID_VOICE_RECORD_TX;
350 case VOICE_PLAYBACK_TX: return AFE_PORT_ID_VOICE_PLAYBACK_TX;
351 case VOICE2_PLAYBACK_TX: return AFE_PORT_ID_VOICE2_PLAYBACK_TX;
352 case SLIMBUS_0_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_RX;
353 case SLIMBUS_0_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_0_TX;
354 case SLIMBUS_1_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_RX;
355 case SLIMBUS_1_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_1_TX;
356 case SLIMBUS_2_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_RX;
357 case SLIMBUS_2_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_2_TX;
358 case SLIMBUS_3_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_RX;
359 case SLIMBUS_3_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_3_TX;
360 case SLIMBUS_4_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_RX;
361 case SLIMBUS_4_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_4_TX;
362 case SLIMBUS_5_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_RX;
363 case SLIMBUS_5_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_5_TX;
364 case SLIMBUS_6_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_RX;
365 case SLIMBUS_6_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_6_TX;
366 case SLIMBUS_7_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_7_RX;
367 case SLIMBUS_7_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_7_TX;
368 case SLIMBUS_8_RX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_8_RX;
369 case SLIMBUS_8_TX: return AFE_PORT_ID_SLIMBUS_MULTI_CHAN_8_TX;
370 case INT_BT_SCO_RX: return AFE_PORT_ID_INTERNAL_BT_SCO_RX;
371 case INT_BT_SCO_TX: return AFE_PORT_ID_INTERNAL_BT_SCO_TX;
372 case INT_BT_A2DP_RX: return AFE_PORT_ID_INTERNAL_BT_A2DP_RX;
373 case INT_FM_RX: return AFE_PORT_ID_INTERNAL_FM_RX;
374 case INT_FM_TX: return AFE_PORT_ID_INTERNAL_FM_TX;
375 case RT_PROXY_PORT_001_RX: return AFE_PORT_ID_RT_PROXY_PORT_001_RX;
376 case RT_PROXY_PORT_001_TX: return AFE_PORT_ID_RT_PROXY_PORT_001_TX;
377 case AFE_PORT_ID_PRIMARY_MI2S_RX:
378 return AFE_PORT_ID_PRIMARY_MI2S_RX;
379 case AFE_PORT_ID_PRIMARY_MI2S_TX:
380 return AFE_PORT_ID_PRIMARY_MI2S_TX;
381 case AFE_PORT_ID_QUATERNARY_MI2S_RX:
382 return AFE_PORT_ID_QUATERNARY_MI2S_RX;
383 case AFE_PORT_ID_QUATERNARY_MI2S_TX:
384 return AFE_PORT_ID_QUATERNARY_MI2S_TX;
385 case AFE_PORT_ID_SECONDARY_MI2S_RX:
386 return AFE_PORT_ID_SECONDARY_MI2S_RX;
387 case AFE_PORT_ID_SECONDARY_MI2S_TX:
388 return AFE_PORT_ID_SECONDARY_MI2S_TX;
389 case AFE_PORT_ID_TERTIARY_MI2S_RX:
390 return AFE_PORT_ID_TERTIARY_MI2S_RX;
391 case AFE_PORT_ID_TERTIARY_MI2S_TX:
392 return AFE_PORT_ID_TERTIARY_MI2S_TX;
393 case AFE_PORT_ID_QUINARY_MI2S_RX:
394 return AFE_PORT_ID_QUINARY_MI2S_RX;
395 case AFE_PORT_ID_QUINARY_MI2S_TX:
396 return AFE_PORT_ID_QUINARY_MI2S_TX;
397 case AUDIO_PORT_ID_I2S_RX:
398 return AUDIO_PORT_ID_I2S_RX;
399 case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
400 return AFE_PORT_ID_SECONDARY_MI2S_RX_SD1;
401 case AFE_PORT_ID_PRIMARY_TDM_RX:
402 return AFE_PORT_ID_PRIMARY_TDM_RX;
403 case AFE_PORT_ID_PRIMARY_TDM_TX:
404 return AFE_PORT_ID_PRIMARY_TDM_TX;
405 case AFE_PORT_ID_PRIMARY_TDM_RX_1:
406 return AFE_PORT_ID_PRIMARY_TDM_RX_1;
407 case AFE_PORT_ID_PRIMARY_TDM_TX_1:
408 return AFE_PORT_ID_PRIMARY_TDM_TX_1;
409 case AFE_PORT_ID_PRIMARY_TDM_RX_2:
410 return AFE_PORT_ID_PRIMARY_TDM_RX_2;
411 case AFE_PORT_ID_PRIMARY_TDM_TX_2:
412 return AFE_PORT_ID_PRIMARY_TDM_TX_2;
413 case AFE_PORT_ID_PRIMARY_TDM_RX_3:
414 return AFE_PORT_ID_PRIMARY_TDM_RX_3;
415 case AFE_PORT_ID_PRIMARY_TDM_TX_3:
416 return AFE_PORT_ID_PRIMARY_TDM_TX_3;
417 case AFE_PORT_ID_PRIMARY_TDM_RX_4:
418 return AFE_PORT_ID_PRIMARY_TDM_RX_4;
419 case AFE_PORT_ID_PRIMARY_TDM_TX_4:
420 return AFE_PORT_ID_PRIMARY_TDM_TX_4;
421 case AFE_PORT_ID_PRIMARY_TDM_RX_5:
422 return AFE_PORT_ID_PRIMARY_TDM_RX_5;
423 case AFE_PORT_ID_PRIMARY_TDM_TX_5:
424 return AFE_PORT_ID_PRIMARY_TDM_TX_5;
425 case AFE_PORT_ID_PRIMARY_TDM_RX_6:
426 return AFE_PORT_ID_PRIMARY_TDM_RX_6;
427 case AFE_PORT_ID_PRIMARY_TDM_TX_6:
428 return AFE_PORT_ID_PRIMARY_TDM_TX_6;
429 case AFE_PORT_ID_PRIMARY_TDM_RX_7:
430 return AFE_PORT_ID_PRIMARY_TDM_RX_7;
431 case AFE_PORT_ID_PRIMARY_TDM_TX_7:
432 return AFE_PORT_ID_PRIMARY_TDM_TX_7;
433 case AFE_PORT_ID_SECONDARY_TDM_RX:
434 return AFE_PORT_ID_SECONDARY_TDM_RX;
435 case AFE_PORT_ID_SECONDARY_TDM_TX:
436 return AFE_PORT_ID_SECONDARY_TDM_TX;
437 case AFE_PORT_ID_SECONDARY_TDM_RX_1:
438 return AFE_PORT_ID_SECONDARY_TDM_RX_1;
439 case AFE_PORT_ID_SECONDARY_TDM_TX_1:
440 return AFE_PORT_ID_SECONDARY_TDM_TX_1;
441 case AFE_PORT_ID_SECONDARY_TDM_RX_2:
442 return AFE_PORT_ID_SECONDARY_TDM_RX_2;
443 case AFE_PORT_ID_SECONDARY_TDM_TX_2:
444 return AFE_PORT_ID_SECONDARY_TDM_TX_2;
445 case AFE_PORT_ID_SECONDARY_TDM_RX_3:
446 return AFE_PORT_ID_SECONDARY_TDM_RX_3;
447 case AFE_PORT_ID_SECONDARY_TDM_TX_3:
448 return AFE_PORT_ID_SECONDARY_TDM_TX_3;
449 case AFE_PORT_ID_SECONDARY_TDM_RX_4:
450 return AFE_PORT_ID_SECONDARY_TDM_RX_4;
451 case AFE_PORT_ID_SECONDARY_TDM_TX_4:
452 return AFE_PORT_ID_SECONDARY_TDM_TX_4;
453 case AFE_PORT_ID_SECONDARY_TDM_RX_5:
454 return AFE_PORT_ID_SECONDARY_TDM_RX_5;
455 case AFE_PORT_ID_SECONDARY_TDM_TX_5:
456 return AFE_PORT_ID_SECONDARY_TDM_TX_5;
457 case AFE_PORT_ID_SECONDARY_TDM_RX_6:
458 return AFE_PORT_ID_SECONDARY_TDM_RX_6;
459 case AFE_PORT_ID_SECONDARY_TDM_TX_6:
460 return AFE_PORT_ID_SECONDARY_TDM_TX_6;
461 case AFE_PORT_ID_SECONDARY_TDM_RX_7:
462 return AFE_PORT_ID_SECONDARY_TDM_RX_7;
463 case AFE_PORT_ID_SECONDARY_TDM_TX_7:
464 return AFE_PORT_ID_SECONDARY_TDM_TX_7;
465 case AFE_PORT_ID_TERTIARY_TDM_RX:
466 return AFE_PORT_ID_TERTIARY_TDM_RX;
467 case AFE_PORT_ID_TERTIARY_TDM_TX:
468 return AFE_PORT_ID_TERTIARY_TDM_TX;
469 case AFE_PORT_ID_TERTIARY_TDM_RX_1:
470 return AFE_PORT_ID_TERTIARY_TDM_RX_1;
471 case AFE_PORT_ID_TERTIARY_TDM_TX_1:
472 return AFE_PORT_ID_TERTIARY_TDM_TX_1;
473 case AFE_PORT_ID_TERTIARY_TDM_RX_2:
474 return AFE_PORT_ID_TERTIARY_TDM_RX_2;
475 case AFE_PORT_ID_TERTIARY_TDM_TX_2:
476 return AFE_PORT_ID_TERTIARY_TDM_TX_2;
477 case AFE_PORT_ID_TERTIARY_TDM_RX_3:
478 return AFE_PORT_ID_TERTIARY_TDM_RX_3;
479 case AFE_PORT_ID_TERTIARY_TDM_TX_3:
480 return AFE_PORT_ID_TERTIARY_TDM_TX_3;
481 case AFE_PORT_ID_TERTIARY_TDM_RX_4:
482 return AFE_PORT_ID_TERTIARY_TDM_RX_4;
483 case AFE_PORT_ID_TERTIARY_TDM_TX_4:
484 return AFE_PORT_ID_TERTIARY_TDM_TX_4;
485 case AFE_PORT_ID_TERTIARY_TDM_RX_5:
486 return AFE_PORT_ID_TERTIARY_TDM_RX_5;
487 case AFE_PORT_ID_TERTIARY_TDM_TX_5:
488 return AFE_PORT_ID_TERTIARY_TDM_TX_5;
489 case AFE_PORT_ID_TERTIARY_TDM_RX_6:
490 return AFE_PORT_ID_TERTIARY_TDM_RX_6;
491 case AFE_PORT_ID_TERTIARY_TDM_TX_6:
492 return AFE_PORT_ID_TERTIARY_TDM_TX_6;
493 case AFE_PORT_ID_TERTIARY_TDM_RX_7:
494 return AFE_PORT_ID_TERTIARY_TDM_RX_7;
495 case AFE_PORT_ID_TERTIARY_TDM_TX_7:
496 return AFE_PORT_ID_TERTIARY_TDM_TX_7;
497 case AFE_PORT_ID_QUATERNARY_TDM_RX:
498 return AFE_PORT_ID_QUATERNARY_TDM_RX;
499 case AFE_PORT_ID_QUATERNARY_TDM_TX:
500 return AFE_PORT_ID_QUATERNARY_TDM_TX;
501 case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
502 return AFE_PORT_ID_QUATERNARY_TDM_RX_1;
503 case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
504 return AFE_PORT_ID_QUATERNARY_TDM_TX_1;
505 case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
506 return AFE_PORT_ID_QUATERNARY_TDM_RX_2;
507 case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
508 return AFE_PORT_ID_QUATERNARY_TDM_TX_2;
509 case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
510 return AFE_PORT_ID_QUATERNARY_TDM_RX_3;
511 case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
512 return AFE_PORT_ID_QUATERNARY_TDM_TX_3;
513 case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
514 return AFE_PORT_ID_QUATERNARY_TDM_RX_4;
515 case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
516 return AFE_PORT_ID_QUATERNARY_TDM_TX_4;
517 case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
518 return AFE_PORT_ID_QUATERNARY_TDM_RX_5;
519 case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
520 return AFE_PORT_ID_QUATERNARY_TDM_TX_5;
521 case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
522 return AFE_PORT_ID_QUATERNARY_TDM_RX_6;
523 case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
524 return AFE_PORT_ID_QUATERNARY_TDM_TX_6;
525 case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
526 return AFE_PORT_ID_QUATERNARY_TDM_RX_7;
527 case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
528 return AFE_PORT_ID_QUATERNARY_TDM_TX_7;
529 case AFE_PORT_ID_QUINARY_TDM_RX:
530 return AFE_PORT_ID_QUINARY_TDM_RX;
531 case AFE_PORT_ID_QUINARY_TDM_TX:
532 return AFE_PORT_ID_QUINARY_TDM_TX;
533 case AFE_PORT_ID_QUINARY_TDM_RX_1:
534 return AFE_PORT_ID_QUINARY_TDM_RX_1;
535 case AFE_PORT_ID_QUINARY_TDM_TX_1:
536 return AFE_PORT_ID_QUINARY_TDM_TX_1;
537 case AFE_PORT_ID_QUINARY_TDM_RX_2:
538 return AFE_PORT_ID_QUINARY_TDM_RX_2;
539 case AFE_PORT_ID_QUINARY_TDM_TX_2:
540 return AFE_PORT_ID_QUINARY_TDM_TX_2;
541 case AFE_PORT_ID_QUINARY_TDM_RX_3:
542 return AFE_PORT_ID_QUINARY_TDM_RX_3;
543 case AFE_PORT_ID_QUINARY_TDM_TX_3:
544 return AFE_PORT_ID_QUINARY_TDM_TX_3;
545 case AFE_PORT_ID_QUINARY_TDM_RX_4:
546 return AFE_PORT_ID_QUINARY_TDM_RX_4;
547 case AFE_PORT_ID_QUINARY_TDM_TX_4:
548 return AFE_PORT_ID_QUINARY_TDM_TX_4;
549 case AFE_PORT_ID_QUINARY_TDM_RX_5:
550 return AFE_PORT_ID_QUINARY_TDM_RX_5;
551 case AFE_PORT_ID_QUINARY_TDM_TX_5:
552 return AFE_PORT_ID_QUINARY_TDM_TX_5;
553 case AFE_PORT_ID_QUINARY_TDM_RX_6:
554 return AFE_PORT_ID_QUINARY_TDM_RX_6;
555 case AFE_PORT_ID_QUINARY_TDM_TX_6:
556 return AFE_PORT_ID_QUINARY_TDM_TX_6;
557 case AFE_PORT_ID_QUINARY_TDM_RX_7:
558 return AFE_PORT_ID_QUINARY_TDM_RX_7;
559 case AFE_PORT_ID_QUINARY_TDM_TX_7:
560 return AFE_PORT_ID_QUINARY_TDM_TX_7;
561 case AFE_PORT_ID_SENARY_MI2S_TX:
562 return AFE_PORT_ID_SENARY_MI2S_TX;
563 case AFE_PORT_ID_USB_RX:
564 return AFE_PORT_ID_USB_RX;
565 case AFE_PORT_ID_USB_TX:
566 return AFE_PORT_ID_USB_TX;
567 case AFE_PORT_ID_INT0_MI2S_RX:
568 return AFE_PORT_ID_INT0_MI2S_RX;
569 case AFE_PORT_ID_INT0_MI2S_TX:
570 return AFE_PORT_ID_INT0_MI2S_TX;
571 case AFE_PORT_ID_INT1_MI2S_RX:
572 return AFE_PORT_ID_INT1_MI2S_RX;
573 case AFE_PORT_ID_INT1_MI2S_TX:
574 return AFE_PORT_ID_INT1_MI2S_TX;
575 case AFE_PORT_ID_INT2_MI2S_RX:
576 return AFE_PORT_ID_INT2_MI2S_RX;
577 case AFE_PORT_ID_INT2_MI2S_TX:
578 return AFE_PORT_ID_INT2_MI2S_TX;
579 case AFE_PORT_ID_INT3_MI2S_RX:
580 return AFE_PORT_ID_INT3_MI2S_RX;
581 case AFE_PORT_ID_INT3_MI2S_TX:
582 return AFE_PORT_ID_INT3_MI2S_TX;
583 case AFE_PORT_ID_INT4_MI2S_RX:
584 return AFE_PORT_ID_INT4_MI2S_RX;
585 case AFE_PORT_ID_INT4_MI2S_TX:
586 return AFE_PORT_ID_INT4_MI2S_TX;
587 case AFE_PORT_ID_INT5_MI2S_RX:
588 return AFE_PORT_ID_INT5_MI2S_RX;
589 case AFE_PORT_ID_INT5_MI2S_TX:
590 return AFE_PORT_ID_INT5_MI2S_TX;
591 case AFE_PORT_ID_INT6_MI2S_RX:
592 return AFE_PORT_ID_INT6_MI2S_RX;
593 case AFE_PORT_ID_INT6_MI2S_TX:
594 return AFE_PORT_ID_INT6_MI2S_TX;
Anver sadhique276e2a42021-02-16 11:35:57 +0530595 case RT_PROXY_PORT_002_RX:
596 return RT_PROXY_PORT_002_RX;
597 case RT_PROXY_PORT_002_TX:
598 return RT_PROXY_PORT_002_TX;
599
Alexander Martinz28de9412021-09-09 17:05:05 +0200600 default:
601 pr_warn("%s: Invalid port_id %d\n", __func__, port_id);
602 return -EINVAL;
603 }
604}
605int q6audio_convert_virtual_to_portid(u16 port_id)
606{
607 int ret;
608
609 /* if port_id is virtual, convert to physical..
610 * if port_id is already physical, return physical
611 */
612 if (q6audio_validate_port(port_id) < 0) {
613 if (port_id == RT_PROXY_DAI_001_RX ||
614 port_id == RT_PROXY_DAI_001_TX ||
615 port_id == RT_PROXY_DAI_002_RX ||
616 port_id == RT_PROXY_DAI_002_TX)
617 ret = VIRTUAL_ID_TO_PORTID(port_id);
618 else
619 ret = -EINVAL;
620 } else
621 ret = port_id;
622
623 return ret;
624}
625
626int q6audio_is_digital_pcm_interface(u16 port_id)
627{
628 int ret = 0;
629
630 switch (port_id) {
631 case PRIMARY_I2S_RX:
632 case PRIMARY_I2S_TX:
633 case AFE_PORT_ID_PRIMARY_PCM_RX:
634 case AFE_PORT_ID_PRIMARY_PCM_TX:
635 case AFE_PORT_ID_SECONDARY_PCM_RX:
636 case AFE_PORT_ID_SECONDARY_PCM_TX:
637 case AFE_PORT_ID_TERTIARY_PCM_RX:
638 case AFE_PORT_ID_TERTIARY_PCM_TX:
639 case AFE_PORT_ID_QUATERNARY_PCM_RX:
640 case AFE_PORT_ID_QUATERNARY_PCM_TX:
641 case AFE_PORT_ID_QUINARY_PCM_RX:
642 case AFE_PORT_ID_QUINARY_PCM_TX:
643 case SECONDARY_I2S_RX:
644 case SECONDARY_I2S_TX:
645 case MI2S_RX:
646 case MI2S_TX:
647 case AFE_PORT_ID_TERTIARY_MI2S_TX:
648 case AFE_PORT_ID_TERTIARY_MI2S_RX:
649 case AFE_PORT_ID_QUINARY_MI2S_TX:
650 case AFE_PORT_ID_QUINARY_MI2S_RX:
651 case AFE_PORT_ID_QUATERNARY_MI2S_RX:
652 case AFE_PORT_ID_QUATERNARY_MI2S_TX:
653 case AFE_PORT_ID_PRIMARY_MI2S_RX:
654 case AFE_PORT_ID_PRIMARY_MI2S_TX:
655 case AFE_PORT_ID_SECONDARY_MI2S_RX:
656 case AFE_PORT_ID_SECONDARY_MI2S_TX:
657 case AUDIO_PORT_ID_I2S_RX:
658 case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
659 case AFE_PORT_ID_PRIMARY_TDM_RX:
660 case AFE_PORT_ID_PRIMARY_TDM_TX:
661 case AFE_PORT_ID_PRIMARY_TDM_RX_1:
662 case AFE_PORT_ID_PRIMARY_TDM_TX_1:
663 case AFE_PORT_ID_PRIMARY_TDM_RX_2:
664 case AFE_PORT_ID_PRIMARY_TDM_TX_2:
665 case AFE_PORT_ID_PRIMARY_TDM_RX_3:
666 case AFE_PORT_ID_PRIMARY_TDM_TX_3:
667 case AFE_PORT_ID_PRIMARY_TDM_RX_4:
668 case AFE_PORT_ID_PRIMARY_TDM_TX_4:
669 case AFE_PORT_ID_PRIMARY_TDM_RX_5:
670 case AFE_PORT_ID_PRIMARY_TDM_TX_5:
671 case AFE_PORT_ID_PRIMARY_TDM_RX_6:
672 case AFE_PORT_ID_PRIMARY_TDM_TX_6:
673 case AFE_PORT_ID_PRIMARY_TDM_RX_7:
674 case AFE_PORT_ID_PRIMARY_TDM_TX_7:
675 case AFE_PORT_ID_SECONDARY_TDM_RX:
676 case AFE_PORT_ID_SECONDARY_TDM_TX:
677 case AFE_PORT_ID_SECONDARY_TDM_RX_1:
678 case AFE_PORT_ID_SECONDARY_TDM_TX_1:
679 case AFE_PORT_ID_SECONDARY_TDM_RX_2:
680 case AFE_PORT_ID_SECONDARY_TDM_TX_2:
681 case AFE_PORT_ID_SECONDARY_TDM_RX_3:
682 case AFE_PORT_ID_SECONDARY_TDM_TX_3:
683 case AFE_PORT_ID_SECONDARY_TDM_RX_4:
684 case AFE_PORT_ID_SECONDARY_TDM_TX_4:
685 case AFE_PORT_ID_SECONDARY_TDM_RX_5:
686 case AFE_PORT_ID_SECONDARY_TDM_TX_5:
687 case AFE_PORT_ID_SECONDARY_TDM_RX_6:
688 case AFE_PORT_ID_SECONDARY_TDM_TX_6:
689 case AFE_PORT_ID_SECONDARY_TDM_RX_7:
690 case AFE_PORT_ID_SECONDARY_TDM_TX_7:
691 case AFE_PORT_ID_TERTIARY_TDM_RX:
692 case AFE_PORT_ID_TERTIARY_TDM_TX:
693 case AFE_PORT_ID_TERTIARY_TDM_RX_1:
694 case AFE_PORT_ID_TERTIARY_TDM_TX_1:
695 case AFE_PORT_ID_TERTIARY_TDM_RX_2:
696 case AFE_PORT_ID_TERTIARY_TDM_TX_2:
697 case AFE_PORT_ID_TERTIARY_TDM_RX_3:
698 case AFE_PORT_ID_TERTIARY_TDM_TX_3:
699 case AFE_PORT_ID_TERTIARY_TDM_RX_4:
700 case AFE_PORT_ID_TERTIARY_TDM_TX_4:
701 case AFE_PORT_ID_TERTIARY_TDM_RX_5:
702 case AFE_PORT_ID_TERTIARY_TDM_TX_5:
703 case AFE_PORT_ID_TERTIARY_TDM_RX_6:
704 case AFE_PORT_ID_TERTIARY_TDM_TX_6:
705 case AFE_PORT_ID_TERTIARY_TDM_RX_7:
706 case AFE_PORT_ID_TERTIARY_TDM_TX_7:
707 case AFE_PORT_ID_QUATERNARY_TDM_RX:
708 case AFE_PORT_ID_QUATERNARY_TDM_TX:
709 case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
710 case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
711 case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
712 case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
713 case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
714 case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
715 case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
716 case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
717 case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
718 case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
719 case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
720 case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
721 case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
722 case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
723 case AFE_PORT_ID_QUINARY_TDM_RX:
724 case AFE_PORT_ID_QUINARY_TDM_TX:
725 case AFE_PORT_ID_QUINARY_TDM_RX_1:
726 case AFE_PORT_ID_QUINARY_TDM_TX_1:
727 case AFE_PORT_ID_QUINARY_TDM_RX_2:
728 case AFE_PORT_ID_QUINARY_TDM_TX_2:
729 case AFE_PORT_ID_QUINARY_TDM_RX_3:
730 case AFE_PORT_ID_QUINARY_TDM_TX_3:
731 case AFE_PORT_ID_QUINARY_TDM_RX_4:
732 case AFE_PORT_ID_QUINARY_TDM_TX_4:
733 case AFE_PORT_ID_QUINARY_TDM_RX_5:
734 case AFE_PORT_ID_QUINARY_TDM_TX_5:
735 case AFE_PORT_ID_QUINARY_TDM_RX_6:
736 case AFE_PORT_ID_QUINARY_TDM_TX_6:
737 case AFE_PORT_ID_QUINARY_TDM_RX_7:
738 case AFE_PORT_ID_QUINARY_TDM_TX_7:
739 case AFE_PORT_ID_SENARY_MI2S_TX:
740 case AFE_PORT_ID_INT0_MI2S_RX:
741 case AFE_PORT_ID_INT0_MI2S_TX:
742 case AFE_PORT_ID_INT1_MI2S_RX:
743 case AFE_PORT_ID_INT1_MI2S_TX:
744 case AFE_PORT_ID_INT2_MI2S_RX:
745 case AFE_PORT_ID_INT2_MI2S_TX:
746 case AFE_PORT_ID_INT3_MI2S_RX:
747 case AFE_PORT_ID_INT3_MI2S_TX:
748 case AFE_PORT_ID_INT4_MI2S_RX:
749 case AFE_PORT_ID_INT4_MI2S_TX:
750 case AFE_PORT_ID_INT5_MI2S_RX:
751 case AFE_PORT_ID_INT5_MI2S_TX:
752 case AFE_PORT_ID_INT6_MI2S_RX:
753 case AFE_PORT_ID_INT6_MI2S_TX:
754 break;
755 default:
756 ret = -EINVAL;
757 }
758
759 return ret;
760}
761
762int q6audio_validate_port(u16 port_id)
763{
764 int ret;
765
766 switch (port_id) {
767 case PRIMARY_I2S_RX:
768 case PRIMARY_I2S_TX:
769 case AFE_PORT_ID_PRIMARY_PCM_RX:
770 case AFE_PORT_ID_PRIMARY_PCM_TX:
771 case AFE_PORT_ID_SECONDARY_PCM_RX:
772 case AFE_PORT_ID_SECONDARY_PCM_TX:
773 case AFE_PORT_ID_TERTIARY_PCM_RX:
774 case AFE_PORT_ID_TERTIARY_PCM_TX:
775 case AFE_PORT_ID_QUATERNARY_PCM_RX:
776 case AFE_PORT_ID_QUATERNARY_PCM_TX:
777 case AFE_PORT_ID_QUINARY_PCM_RX:
778 case AFE_PORT_ID_QUINARY_PCM_TX:
779 case SECONDARY_I2S_RX:
780 case SECONDARY_I2S_TX:
781 case MI2S_RX:
782 case MI2S_TX:
783 case HDMI_RX:
784 case DISPLAY_PORT_RX:
785 case RSVD_2:
786 case RSVD_3:
787 case DIGI_MIC_TX:
788 case VOICE_RECORD_RX:
789 case VOICE_RECORD_TX:
790 case VOICE_PLAYBACK_TX:
791 case VOICE2_PLAYBACK_TX:
792 case SLIMBUS_0_RX:
793 case SLIMBUS_0_TX:
794 case SLIMBUS_1_RX:
795 case SLIMBUS_1_TX:
796 case SLIMBUS_2_RX:
797 case SLIMBUS_2_TX:
798 case SLIMBUS_3_RX:
799 case SLIMBUS_3_TX:
800 case SLIMBUS_4_RX:
801 case SLIMBUS_4_TX:
802 case SLIMBUS_5_RX:
803 case SLIMBUS_5_TX:
804 case SLIMBUS_6_RX:
805 case SLIMBUS_6_TX:
806 case SLIMBUS_7_RX:
807 case SLIMBUS_7_TX:
808 case SLIMBUS_8_RX:
809 case SLIMBUS_8_TX:
810 case INT_BT_SCO_RX:
811 case INT_BT_SCO_TX:
812 case INT_BT_A2DP_RX:
813 case INT_FM_RX:
814 case INT_FM_TX:
815 case RT_PROXY_PORT_001_RX:
816 case RT_PROXY_PORT_001_TX:
817 case AFE_PORT_ID_PRIMARY_MI2S_RX:
818 case AFE_PORT_ID_PRIMARY_MI2S_TX:
819 case AFE_PORT_ID_QUATERNARY_MI2S_RX:
820 case AFE_PORT_ID_QUATERNARY_MI2S_TX:
821 case AFE_PORT_ID_SECONDARY_MI2S_RX:
822 case AFE_PORT_ID_SECONDARY_MI2S_TX:
823 case AFE_PORT_ID_SPDIF_RX:
824 case AFE_PORT_ID_TERTIARY_MI2S_RX:
825 case AFE_PORT_ID_TERTIARY_MI2S_TX:
826 case AFE_PORT_ID_QUINARY_MI2S_RX:
827 case AFE_PORT_ID_QUINARY_MI2S_TX:
828 case AFE_PORT_ID_SECONDARY_MI2S_RX_SD1:
829 case AFE_PORT_ID_PRIMARY_TDM_RX:
830 case AFE_PORT_ID_PRIMARY_TDM_TX:
831 case AFE_PORT_ID_PRIMARY_TDM_RX_1:
832 case AFE_PORT_ID_PRIMARY_TDM_TX_1:
833 case AFE_PORT_ID_PRIMARY_TDM_RX_2:
834 case AFE_PORT_ID_PRIMARY_TDM_TX_2:
835 case AFE_PORT_ID_PRIMARY_TDM_RX_3:
836 case AFE_PORT_ID_PRIMARY_TDM_TX_3:
837 case AFE_PORT_ID_PRIMARY_TDM_RX_4:
838 case AFE_PORT_ID_PRIMARY_TDM_TX_4:
839 case AFE_PORT_ID_PRIMARY_TDM_RX_5:
840 case AFE_PORT_ID_PRIMARY_TDM_TX_5:
841 case AFE_PORT_ID_PRIMARY_TDM_RX_6:
842 case AFE_PORT_ID_PRIMARY_TDM_TX_6:
843 case AFE_PORT_ID_PRIMARY_TDM_RX_7:
844 case AFE_PORT_ID_PRIMARY_TDM_TX_7:
845 case AFE_PORT_ID_SECONDARY_TDM_RX:
846 case AFE_PORT_ID_SECONDARY_TDM_TX:
847 case AFE_PORT_ID_SECONDARY_TDM_RX_1:
848 case AFE_PORT_ID_SECONDARY_TDM_TX_1:
849 case AFE_PORT_ID_SECONDARY_TDM_RX_2:
850 case AFE_PORT_ID_SECONDARY_TDM_TX_2:
851 case AFE_PORT_ID_SECONDARY_TDM_RX_3:
852 case AFE_PORT_ID_SECONDARY_TDM_TX_3:
853 case AFE_PORT_ID_SECONDARY_TDM_RX_4:
854 case AFE_PORT_ID_SECONDARY_TDM_TX_4:
855 case AFE_PORT_ID_SECONDARY_TDM_RX_5:
856 case AFE_PORT_ID_SECONDARY_TDM_TX_5:
857 case AFE_PORT_ID_SECONDARY_TDM_RX_6:
858 case AFE_PORT_ID_SECONDARY_TDM_TX_6:
859 case AFE_PORT_ID_SECONDARY_TDM_RX_7:
860 case AFE_PORT_ID_SECONDARY_TDM_TX_7:
861 case AFE_PORT_ID_TERTIARY_TDM_RX:
862 case AFE_PORT_ID_TERTIARY_TDM_TX:
863 case AFE_PORT_ID_TERTIARY_TDM_RX_1:
864 case AFE_PORT_ID_TERTIARY_TDM_TX_1:
865 case AFE_PORT_ID_TERTIARY_TDM_RX_2:
866 case AFE_PORT_ID_TERTIARY_TDM_TX_2:
867 case AFE_PORT_ID_TERTIARY_TDM_RX_3:
868 case AFE_PORT_ID_TERTIARY_TDM_TX_3:
869 case AFE_PORT_ID_TERTIARY_TDM_RX_4:
870 case AFE_PORT_ID_TERTIARY_TDM_TX_4:
871 case AFE_PORT_ID_TERTIARY_TDM_RX_5:
872 case AFE_PORT_ID_TERTIARY_TDM_TX_5:
873 case AFE_PORT_ID_TERTIARY_TDM_RX_6:
874 case AFE_PORT_ID_TERTIARY_TDM_TX_6:
875 case AFE_PORT_ID_TERTIARY_TDM_RX_7:
876 case AFE_PORT_ID_TERTIARY_TDM_TX_7:
877 case AFE_PORT_ID_QUATERNARY_TDM_RX:
878 case AFE_PORT_ID_QUATERNARY_TDM_TX:
879 case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
880 case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
881 case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
882 case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
883 case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
884 case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
885 case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
886 case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
887 case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
888 case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
889 case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
890 case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
891 case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
892 case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
893 case AFE_PORT_ID_QUINARY_TDM_RX:
894 case AFE_PORT_ID_QUINARY_TDM_TX:
895 case AFE_PORT_ID_QUINARY_TDM_RX_1:
896 case AFE_PORT_ID_QUINARY_TDM_TX_1:
897 case AFE_PORT_ID_QUINARY_TDM_RX_2:
898 case AFE_PORT_ID_QUINARY_TDM_TX_2:
899 case AFE_PORT_ID_QUINARY_TDM_RX_3:
900 case AFE_PORT_ID_QUINARY_TDM_TX_3:
901 case AFE_PORT_ID_QUINARY_TDM_RX_4:
902 case AFE_PORT_ID_QUINARY_TDM_TX_4:
903 case AFE_PORT_ID_QUINARY_TDM_RX_5:
904 case AFE_PORT_ID_QUINARY_TDM_TX_5:
905 case AFE_PORT_ID_QUINARY_TDM_RX_6:
906 case AFE_PORT_ID_QUINARY_TDM_TX_6:
907 case AFE_PORT_ID_QUINARY_TDM_RX_7:
908 case AFE_PORT_ID_QUINARY_TDM_TX_7:
909 case AFE_PORT_ID_SENARY_MI2S_TX:
910 case AFE_PORT_ID_USB_RX:
911 case AFE_PORT_ID_USB_TX:
912 case AFE_PORT_ID_INT0_MI2S_RX:
913 case AFE_PORT_ID_INT0_MI2S_TX:
914 case AFE_PORT_ID_INT1_MI2S_RX:
915 case AFE_PORT_ID_INT1_MI2S_TX:
916 case AFE_PORT_ID_INT2_MI2S_RX:
917 case AFE_PORT_ID_INT2_MI2S_TX:
918 case AFE_PORT_ID_INT3_MI2S_RX:
919 case AFE_PORT_ID_INT3_MI2S_TX:
920 case AFE_PORT_ID_INT4_MI2S_RX:
921 case AFE_PORT_ID_INT4_MI2S_TX:
922 case AFE_PORT_ID_INT5_MI2S_RX:
923 case AFE_PORT_ID_INT5_MI2S_TX:
924 case AFE_PORT_ID_INT6_MI2S_RX:
925 case AFE_PORT_ID_INT6_MI2S_TX:
Anver sadhique276e2a42021-02-16 11:35:57 +0530926 case RT_PROXY_PORT_002_RX:
927 case RT_PROXY_PORT_002_TX:
928
Alexander Martinz28de9412021-09-09 17:05:05 +0200929 {
930 ret = 0;
931 break;
932 }
933
934 default:
935 ret = -EINVAL;
936 }
937
938 return ret;
939}