blob: ab4e8428451c38cce9013e854c18ec4b85c3160f [file] [log] [blame]
Rahul Sharma02bee732018-12-20 18:48:34 +05301/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12/*
13 * Copyright 2011, The Android Open Source Project
14
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are met:
17 * Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
19 * Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22 * Neither the name of The Android Open Source Project nor the names of
23 its contributors may be used to endorse or promote products derived
24 from this software without specific prior written permission.
25
26 * THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
36 * DAMAGE.
37 */
38
39#include <linux/clk.h>
40#include <linux/delay.h>
41#include <linux/gpio.h>
42#include <linux/of_gpio.h>
43#include <linux/platform_device.h>
44#include <linux/slab.h>
45#include <linux/io.h>
46#include <linux/module.h>
47#include <linux/input.h>
48#include <linux/of_device.h>
49#include <linux/pm_qos.h>
50#include <sound/core.h>
51#include <sound/soc.h>
52#include <sound/soc-dapm.h>
53#include <sound/pcm.h>
54#include <sound/pcm_params.h>
55#include <sound/info.h>
Erin Yan300664f2019-05-14 10:42:31 +080056#include <soc/snd_event.h>
Rahul Sharma02bee732018-12-20 18:48:34 +053057#include <dsp/audio_notifier.h>
58#include <dsp/q6afe-v2.h>
59#include <dsp/q6core.h>
60#include "device_event.h"
61#include "msm-pcm-routing-v2.h"
62
63#define DRV_NAME "sa6155-asoc-snd"
64
65#define __CHIPSET__ "SA6155 "
66#define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
67
68#define DEV_NAME_STR_LEN 32
69
70#define SAMPLING_RATE_8KHZ 8000
71#define SAMPLING_RATE_11P025KHZ 11025
72#define SAMPLING_RATE_16KHZ 16000
73#define SAMPLING_RATE_22P05KHZ 22050
74#define SAMPLING_RATE_32KHZ 32000
75#define SAMPLING_RATE_44P1KHZ 44100
76#define SAMPLING_RATE_48KHZ 48000
77#define SAMPLING_RATE_88P2KHZ 88200
78#define SAMPLING_RATE_96KHZ 96000
79#define SAMPLING_RATE_176P4KHZ 176400
80#define SAMPLING_RATE_192KHZ 192000
81#define SAMPLING_RATE_352P8KHZ 352800
82#define SAMPLING_RATE_384KHZ 384000
83
84#define ADSP_STATE_READY_TIMEOUT_MS 3000
85#define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
86
87enum {
88 PRIM_MI2S = 0,
89 SEC_MI2S,
90 TERT_MI2S,
91 QUAT_MI2S,
92 QUIN_MI2S,
93 MI2S_MAX,
94};
95
96enum {
97 PRIM_AUX_PCM = 0,
98 SEC_AUX_PCM,
99 TERT_AUX_PCM,
100 QUAT_AUX_PCM,
101 QUIN_AUX_PCM,
102 AUX_PCM_MAX,
103};
104
105struct mi2s_conf {
106 struct mutex lock;
107 u32 ref_cnt;
108 u32 msm_is_mi2s_master;
109};
110
111static u32 mi2s_ebit_clk[MI2S_MAX] = {
112 Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
113 Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
114 Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
115 Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT,
116 Q6AFE_LPASS_CLK_ID_QUI_MI2S_EBIT
117};
118
119struct dev_config {
120 u32 sample_rate;
121 u32 bit_format;
122 u32 channels;
123};
124
125enum {
126 DP_RX_IDX = 0,
127 EXT_DISP_RX_IDX_MAX,
128};
129
130enum pinctrl_pin_state {
Derek Chen7bb78312019-06-18 00:36:55 -0700131 STATE_SLEEP = 0, /* All pins are in sleep state */
132 STATE_ACTIVE, /* TDM = active */
Rahul Sharma02bee732018-12-20 18:48:34 +0530133};
134
135struct msm_pinctrl_info {
136 struct pinctrl *pinctrl;
Derek Chen7bb78312019-06-18 00:36:55 -0700137 struct pinctrl_state *sleep;
138 struct pinctrl_state *active;
Rahul Sharma02bee732018-12-20 18:48:34 +0530139 enum pinctrl_pin_state curr_state;
140};
141
Derek Chen7bb78312019-06-18 00:36:55 -0700142static const char *const pin_states[] = {"sleep", "active"};
Rahul Sharma02bee732018-12-20 18:48:34 +0530143
Derek Chen7bb78312019-06-18 00:36:55 -0700144static const char *const tdm_gpio_phandle[] = {"qcom,pri-tdm-gpios",
145 "qcom,sec-tdm-gpios",
146 "qcom,tert-tdm-gpios",
147 "qcom,quat-tdm-gpios",
148 "qcom,quin-tdm-gpios"};
Rahul Sharma02bee732018-12-20 18:48:34 +0530149
150enum {
151 TDM_0 = 0,
152 TDM_1,
153 TDM_2,
154 TDM_3,
155 TDM_4,
156 TDM_5,
157 TDM_6,
158 TDM_7,
159 TDM_PORT_MAX,
160};
161
162enum {
163 TDM_PRI = 0,
164 TDM_SEC,
165 TDM_TERT,
166 TDM_QUAT,
167 TDM_QUIN,
168 TDM_INTERFACE_MAX,
169};
170
171struct tdm_port {
172 u32 mode;
173 u32 channel;
174};
175
Derek Chen7bb78312019-06-18 00:36:55 -0700176struct tdm_conf {
177 struct mutex lock;
178 u32 ref_cnt;
179};
180
Rahul Sharma02bee732018-12-20 18:48:34 +0530181/* TDM default config */
182static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
183 { /* PRI TDM */
184 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* RX_0 */
185 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* RX_1 */
186 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* RX_2 */
187 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* RX_3 */
188 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
189 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
190 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
191 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
192 },
193 { /* SEC TDM */
194 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* RX_0 */
195 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* RX_1 */
196 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* RX_2 */
197 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* RX_3 */
198 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
199 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
200 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
201 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
202 },
203 { /* TERT TDM */
204 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 6}, /* RX_0 */
205 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
206 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
207 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
208 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
209 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
210 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
211 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
212 },
213 { /* QUAT TDM */
Derek Chen0150b832019-06-05 18:46:29 +0530214 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8}, /* RX_0 */
Rahul Sharma02bee732018-12-20 18:48:34 +0530215 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
216 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
217 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
218 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
219 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
220 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
221 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
222 },
223 { /* QUIN TDM */
224 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
225 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
226 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
227 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
228 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
229 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
230 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
231 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
232 }
233};
234
235/* TDM default config */
236static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
237 { /* PRI TDM */
238 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* TX_0 */
239 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* TX_1 */
240 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* TX_2 */
241 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* TX_3 */
242 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
243 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
244 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
245 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
246 },
247 { /* SEC TDM */
248 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 6}, /* TX_0 */
249 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
250 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
251 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
252 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
253 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
254 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
255 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
256 },
257 { /* TERT TDM */
258 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 4}, /* TX_0 */
259 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* TX_1 */
260 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, /* TX_2 */
261 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
262 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
263 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
264 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
265 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
266 },
267 { /* QUAT TDM */
Derek Chen0150b832019-06-05 18:46:29 +0530268 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 16}, /* TX_0 */
Rahul Sharma02bee732018-12-20 18:48:34 +0530269 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
270 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
271 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
272 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
273 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
274 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
275 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
276 },
277 { /* QUIN TDM */
278 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
279 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
280 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
281 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
282 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
283 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
284 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
285 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
286 }
287};
288
289/* Default configuration of external display BE */
290static struct dev_config ext_disp_rx_cfg[] = {
291 [DP_RX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
292};
293
294static struct dev_config usb_rx_cfg = {
295 .sample_rate = SAMPLING_RATE_48KHZ,
296 .bit_format = SNDRV_PCM_FORMAT_S16_LE,
297 .channels = 2,
298};
299
300static struct dev_config usb_tx_cfg = {
301 .sample_rate = SAMPLING_RATE_48KHZ,
302 .bit_format = SNDRV_PCM_FORMAT_S16_LE,
303 .channels = 1,
304};
305
306static struct dev_config proxy_rx_cfg = {
307 .sample_rate = SAMPLING_RATE_48KHZ,
308 .bit_format = SNDRV_PCM_FORMAT_S16_LE,
309 .channels = 2,
310};
311
312/* Default configuration of MI2S channels */
313static struct dev_config mi2s_rx_cfg[] = {
314 [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
315 [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
316 [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
317 [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
318 [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
319};
320
321static struct dev_config mi2s_tx_cfg[] = {
322 [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
323 [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
324 [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
325 [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
326 [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
327};
328
329static struct dev_config aux_pcm_rx_cfg[] = {
330 [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
331 [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
332 [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
333 [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
334 [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
335};
336
337static struct dev_config aux_pcm_tx_cfg[] = {
338 [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
339 [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
340 [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
341 [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
342 [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
343};
344
345/* TDM default slot config */
346struct tdm_slot_cfg {
347 u32 width;
348 u32 num;
349};
350
351static struct tdm_slot_cfg tdm_slot[TDM_INTERFACE_MAX] = {
352 /* PRI TDM */
353 {32, 8},
354 /* SEC TDM */
355 {32, 8},
356 /* TERT TDM */
357 {32, 8},
358 /* QUAT TDM */
Derek Chen0150b832019-06-05 18:46:29 +0530359 {32, 16},
Rahul Sharma02bee732018-12-20 18:48:34 +0530360 /* QUIN TDM */
361 {32, 8}
362};
363
364/*****************************************************************************
365* TO BE UPDATED: Codec/Platform specific tdm slot table
366*****************************************************************************/
367static struct tdm_slot_cfg tdm_slot_custom[TDM_INTERFACE_MAX] = {
368 /* PRI TDM */
369 {16, 16},
370 /* SEC TDM */
371 {16, 16},
372 /* TERT TDM */
373 {16, 16},
374 /* QUAT TDM */
375 {16, 16},
376 /* QUIN TDM */
377 {16, 16}
378};
379
380
381/* TDM default slot offset config */
382#define TDM_SLOT_OFFSET_MAX 32
383
384static unsigned int tdm_rx_slot_offset
385 [TDM_INTERFACE_MAX][TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
386 {/* PRI TDM */
387 {0, 4, 0xFFFF},
388 {8, 12, 0xFFFF},
389 {16, 20, 0xFFFF},
390 {24, 28, 0xFFFF},
391 {0xFFFF}, /* not used */
392 {0xFFFF}, /* not used */
393 {0xFFFF}, /* not used */
394 {0xFFFF}, /* not used */
395 },
396 {/* SEC TDM */
397 {0, 4, 0xFFFF},
398 {8, 12, 0xFFFF},
399 {16, 20, 0xFFFF},
400 {24, 28, 0xFFFF},
401 {0xFFFF}, /* not used */
402 {0xFFFF}, /* not used */
403 {0xFFFF}, /* not used */
Derek Chen0150b832019-06-05 18:46:29 +0530404 {28, 0xFFFF},
Rahul Sharma02bee732018-12-20 18:48:34 +0530405 },
406 {/* TERT TDM */
407 {0, 4, 8, 12, 16, 20, 0xFFFF},
408 {24, 0xFFFF},
409 {28, 0xFFFF},
410 {0xFFFF}, /* not used */
411 {0xFFFF}, /* not used */
412 {0xFFFF}, /* not used */
413 {0xFFFF}, /* not used */
414 {0xFFFF}, /* not used */
415 },
416 {/* QUAT TDM */
Rahul Sharma51181d02019-04-12 17:03:01 +0530417 {0, 4, 8, 12, 16, 20, 24, 28, 0xFFFF},/*AMP OUT*/
Rahul Sharma02bee732018-12-20 18:48:34 +0530418 {0xFFFF}, /* not used */
419 {0xFFFF}, /* not used */
420 {0xFFFF}, /* not used */
421 {0xFFFF}, /* not used */
422 {0xFFFF}, /* not used */
423 {0xFFFF}, /* not used */
Derek Chen0150b832019-06-05 18:46:29 +0530424 {28,0xFFFF},
Rahul Sharma02bee732018-12-20 18:48:34 +0530425 },
426 {/* QUIN TDM */
Derek Chen0150b832019-06-05 18:46:29 +0530427 {0, 4, 0xFFFF},/*STEREO SPKR1*/
428 {8, 12, 0xFFFF},/*STEREO SPKR2*/
429 {16, 20, 0xFFFF},/*STEREO SPKR3*/
430 {24, 28, 0xFFFF},/*STEREO SPKR4*/
Rahul Sharma02bee732018-12-20 18:48:34 +0530431 {0xFFFF}, /* not used */
432 {0xFFFF}, /* not used */
433 {0xFFFF}, /* not used */
434 {0xFFFF}, /* not used */
435 }
436};
437
438static unsigned int tdm_tx_slot_offset
439 [TDM_INTERFACE_MAX][TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
440 {/* PRI TDM */
441 {0, 4, 0xFFFF},
442 {8, 12, 0xFFFF},
443 {16, 20, 0xFFFF},
444 {24, 28, 0xFFFF},
445 {0xFFFF}, /* not used */
446 {0xFFFF}, /* not used */
447 {0xFFFF}, /* not used */
448 {0xFFFF}, /* not used */
449 },
450 {/* SEC TDM */
451 {0, 4, 8, 12, 16, 20, 0xFFFF},
452 {24, 0xFFFF},
453 {28, 0xFFFF},
454 {0xFFFF}, /* not used */
455 {0xFFFF}, /* not used */
456 {0xFFFF}, /* not used */
457 {0xFFFF}, /* not used */
458 {0xFFFF}, /* not used */
459 },
460 {/* TERT TDM */
461 {0, 4, 8, 12, 0xFFFF},
462 {16, 20, 0xFFFF},
463 {24, 28, 0xFFFF},
464 {0xFFFF}, /* not used */
465 {0xFFFF}, /* not used */
466 {0xFFFF}, /* not used */
467 {0xFFFF}, /* not used */
Derek Chen0150b832019-06-05 18:46:29 +0530468 {28, 0xFFFF},
Rahul Sharma02bee732018-12-20 18:48:34 +0530469 },
470 {/* QUAT TDM */
Rahul Sharma51181d02019-04-12 17:03:01 +0530471 {0, 4, 8, 12, 16, 20, 24, 28,
Derek Chen0150b832019-06-05 18:46:29 +0530472 32, 36, 40, 44, 48, 52, 56, 60, 0xFFFF},/*MIC ARR*/
Rahul Sharma02bee732018-12-20 18:48:34 +0530473 {0xFFFF}, /* not used */
474 {0xFFFF}, /* not used */
475 {0xFFFF}, /* not used */
476 {0xFFFF}, /* not used */
477 {0xFFFF}, /* not used */
478 {0xFFFF}, /* not used */
Derek Chen0150b832019-06-05 18:46:29 +0530479 {60,0xFFFF},
Rahul Sharma02bee732018-12-20 18:48:34 +0530480 },
481 {/* QUIN TDM */
Derek Chen0150b832019-06-05 18:46:29 +0530482 {0, 4, 8, 12, 16, 20, 0xFFFF},/*EC/ANC REF*/
Rahul Sharma02bee732018-12-20 18:48:34 +0530483 {0xFFFF}, /* not used */
484 {0xFFFF}, /* not used */
485 {0xFFFF}, /* not used */
486 {0xFFFF}, /* not used */
487 {0xFFFF}, /* not used */
488 {0xFFFF}, /* not used */
489 {0xFFFF}, /* not used */
490 }
491};
492
493/*****************************************************************************
Derek Chen0150b832019-06-05 18:46:29 +0530494* TO BE UPDATED: Codec/Platform specific tdm slot offset table
Rahul Sharma02bee732018-12-20 18:48:34 +0530495* NOTE:
496* Each entry represents the slot offset array of one backend tdm device
497* valid offset represents the starting offset in byte for the channel
498* use 0xFFFF for end or unused slot offset entry.
499*****************************************************************************/
500static unsigned int tdm_rx_slot_offset_custom
501 [TDM_INTERFACE_MAX][TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
502 {/* PRI TDM */
503 {0xFFFF}, /* not used */
504 {0xFFFF}, /* not used */
505 {0xFFFF}, /* not used */
506 {0xFFFF}, /* not used */
507 {0xFFFF}, /* not used */
508 {0xFFFF}, /* not used */
509 {0xFFFF}, /* not used */
510 {0xFFFF}, /* not used */
511 },
512 {/* SEC TDM */
513 {0, 2, 0xFFFF},
514 {4, 0xFFFF},
515 {6, 0xFFFF},
516 {8, 0xFFFF},
517 {10, 0xFFFF},
518 {12, 14, 16, 18, 20, 22, 24, 26, 0xFFFF},
519 {28, 30, 0xFFFF},
Derek Chen0150b832019-06-05 18:46:29 +0530520 {30, 0xFFFF},
Rahul Sharma02bee732018-12-20 18:48:34 +0530521 },
522 {/* TERT TDM */
523 {0, 2, 0xFFFF},
524 {4, 6, 8, 10, 12, 14, 16, 18, 0xFFFF},
525 {20, 22, 24, 26, 28, 30, 0xFFFF},
526 {0xFFFF}, /* not used */
527 {0xFFFF}, /* not used */
528 {0xFFFF}, /* not used */
529 {0xFFFF}, /* not used */
530 {0xFFFF}, /* not used */
531 },
532 {/* QUAT TDM */
533 {0xFFFF}, /* not used */
534 {0xFFFF}, /* not used */
535 {0xFFFF}, /* not used */
536 {0xFFFF}, /* not used */
537 {0xFFFF}, /* not used */
538 {0xFFFF}, /* not used */
539 {0xFFFF}, /* not used */
Derek Chen0150b832019-06-05 18:46:29 +0530540 {0, 0xFFFF},
Rahul Sharma02bee732018-12-20 18:48:34 +0530541 },
542 {/* QUIN TDM */
543 {0xFFFF}, /* not used */
544 {0xFFFF}, /* not used */
545 {0xFFFF}, /* not used */
546 {0xFFFF}, /* not used */
547 {0xFFFF}, /* not used */
548 {0xFFFF}, /* not used */
549 {0xFFFF}, /* not used */
550 {0xFFFF}, /* not used */
551 }
552};
553
554static unsigned int tdm_tx_slot_offset_custom
555 [TDM_INTERFACE_MAX][TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
556 {/* PRI TDM */
557 {0xFFFF}, /* not used */
558 {0xFFFF}, /* not used */
559 {0xFFFF}, /* not used */
560 {0xFFFF}, /* not used */
561 {0xFFFF}, /* not used */
562 {0xFFFF}, /* not used */
563 {0xFFFF}, /* not used */
564 {0xFFFF}, /* not used */
565 },
566 {/* SEC TDM */
567 {0, 2, 0xFFFF},
568 {4, 6, 8, 10, 12, 14, 16, 18, 0xFFFF},
569 {20, 22, 24, 26, 28, 30, 0xFFFF},
570 {0xFFFF}, /* not used */
571 {0xFFFF}, /* not used */
572 {0xFFFF}, /* not used */
573 {0xFFFF}, /* not used */
574 {0xFFFF}, /* not used */
575 },
576 {/* TERT TDM */
577 {0, 2, 4, 6, 8, 10, 12, 0xFFFF},
578 {14, 16, 0xFFFF},
579 {18, 20, 22, 24, 26, 28, 30, 0xFFFF},
580 {0xFFFF}, /* not used */
581 {0xFFFF}, /* not used */
582 {0xFFFF}, /* not used */
583 {0xFFFF}, /* not used */
Derek Chen0150b832019-06-05 18:46:29 +0530584 {30, 0xFFFF},
Rahul Sharma02bee732018-12-20 18:48:34 +0530585 },
586 {/* QUAT TDM */
587 {0xFFFF}, /* not used */
588 {0xFFFF}, /* not used */
589 {0xFFFF}, /* not used */
590 {0xFFFF}, /* not used */
591 {0xFFFF}, /* not used */
592 {0xFFFF}, /* not used */
593 {0xFFFF}, /* not used */
Derek Chen0150b832019-06-05 18:46:29 +0530594 {0, 0xFFFF},
Rahul Sharma02bee732018-12-20 18:48:34 +0530595 },
596 {/* QUIN TDM */
597 {0xFFFF}, /* not used */
598 {0xFFFF}, /* not used */
599 {0xFFFF}, /* not used */
600 {0xFFFF}, /* not used */
601 {0xFFFF}, /* not used */
602 {0xFFFF}, /* not used */
603 {0xFFFF}, /* not used */
604 {0xFFFF}, /* not used */
605 }
606};
607
608
609static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
610 "S32_LE"};
611static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
612 "S24_3LE"};
613static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
614 "Five", "Six", "Seven",
615 "Eight"};
616static char const *ch_text[] = {"Two", "Three", "Four", "Five",
617 "Six", "Seven", "Eight"};
618static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
619 "KHZ_16", "KHZ_22P05",
620 "KHZ_32", "KHZ_44P1", "KHZ_48",
621 "KHZ_88P2", "KHZ_96", "KHZ_176P4",
622 "KHZ_192", "KHZ_352P8", "KHZ_384"};
623static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
624 "KHZ_192", "KHZ_32", "KHZ_44P1",
625 "KHZ_88P2", "KHZ_176P4"};
626static char const *tdm_ch_text[] = {
627 "One", "Two", "Three", "Four",
628 "Five", "Six", "Seven", "Eight",
629 "Nine", "Ten", "Eleven", "Twelve",
630 "Thirteen", "Fourteen", "Fifteen", "Sixteen",
631 "Seventeen", "Eighteen", "Nineteen", "Twenty",
632 "TwentyOne", "TwentyTwo", "TwentyThree", "TwentyFour",
633 "TwentyFive", "TwentySix", "TwentySeven", "TwentyEight",
634 "TwentyNine", "Thirty", "ThirtyOne", "ThirtyTwo"};
635static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
636static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
637 "KHZ_48", "KHZ_176P4",
638 "KHZ_352P8"};
639static const char *const tdm_slot_num_text[] = {"One", "Two", "Four",
640 "Eight", "Sixteen", "ThirtyTwo"};
641static const char *const tdm_slot_width_text[] = {"16", "24", "32"};
642static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
643static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
644 "KHZ_22P05", "KHZ_32", "KHZ_44P1",
645 "KHZ_48", "KHZ_96", "KHZ_192"};
646static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
647 "Five", "Six", "Seven",
648 "Eight"};
649static const char *const qos_text[] = {"Disable", "Enable"};
650
651static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
652static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
653static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
654static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
655static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
656static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
657static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
658static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
659static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
660static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
661 ext_disp_sample_rate_text);
662static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
663static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
664static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
665static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
666static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
667static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
668static SOC_ENUM_SINGLE_EXT_DECL(tdm_slot_num, tdm_slot_num_text);
669static SOC_ENUM_SINGLE_EXT_DECL(tdm_slot_width, tdm_slot_width_text);
670static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
671static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
672static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
673static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
674static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
675static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
676static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
677static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
678static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
679static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
680static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
681static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
682static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
683static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
684static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
685static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
686static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
687static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
688static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
689static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
690static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
691static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
692static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
693static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
694static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
695static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
696static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
697static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
698static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
699static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
700static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
701static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
702static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
703static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
704
Rahul Sharma02bee732018-12-20 18:48:34 +0530705static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
706 {
707 AFE_API_VERSION_I2S_CONFIG,
708 Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
709 Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
710 Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
711 Q6AFE_LPASS_CLK_ROOT_DEFAULT,
712 0,
713 },
714 {
715 AFE_API_VERSION_I2S_CONFIG,
716 Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
717 Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
718 Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
719 Q6AFE_LPASS_CLK_ROOT_DEFAULT,
720 0,
721 },
722 {
723 AFE_API_VERSION_I2S_CONFIG,
724 Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
725 Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
726 Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
727 Q6AFE_LPASS_CLK_ROOT_DEFAULT,
728 0,
729 },
730 {
731 AFE_API_VERSION_I2S_CONFIG,
732 Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
733 Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
734 Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
735 Q6AFE_LPASS_CLK_ROOT_DEFAULT,
736 0,
737 },
738 {
739 AFE_API_VERSION_I2S_CONFIG,
740 Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
741 Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
742 Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
743 Q6AFE_LPASS_CLK_ROOT_DEFAULT,
744 0,
745 }
746
747};
748
Derek Chen7bb78312019-06-18 00:36:55 -0700749struct msm_asoc_mach_data {
750 struct msm_pinctrl_info pinctrl_info[TDM_INTERFACE_MAX];
751 struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
752 struct tdm_conf tdm_intf_conf[TDM_INTERFACE_MAX];
753};
Rahul Sharma02bee732018-12-20 18:48:34 +0530754
755static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
756 struct snd_ctl_elem_value *ucontrol)
757{
758 pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
759 usb_rx_cfg.channels);
760 ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
761 return 0;
762}
763
764static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
765 struct snd_ctl_elem_value *ucontrol)
766{
767 usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
768
769 pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
770 return 1;
771}
772
773static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
774 struct snd_ctl_elem_value *ucontrol)
775{
776 int sample_rate_val;
777
778 switch (usb_rx_cfg.sample_rate) {
779 case SAMPLING_RATE_384KHZ:
780 sample_rate_val = 12;
781 break;
782 case SAMPLING_RATE_352P8KHZ:
783 sample_rate_val = 11;
784 break;
785 case SAMPLING_RATE_192KHZ:
786 sample_rate_val = 10;
787 break;
788 case SAMPLING_RATE_176P4KHZ:
789 sample_rate_val = 9;
790 break;
791 case SAMPLING_RATE_96KHZ:
792 sample_rate_val = 8;
793 break;
794 case SAMPLING_RATE_88P2KHZ:
795 sample_rate_val = 7;
796 break;
797 case SAMPLING_RATE_48KHZ:
798 sample_rate_val = 6;
799 break;
800 case SAMPLING_RATE_44P1KHZ:
801 sample_rate_val = 5;
802 break;
803 case SAMPLING_RATE_32KHZ:
804 sample_rate_val = 4;
805 break;
806 case SAMPLING_RATE_22P05KHZ:
807 sample_rate_val = 3;
808 break;
809 case SAMPLING_RATE_16KHZ:
810 sample_rate_val = 2;
811 break;
812 case SAMPLING_RATE_11P025KHZ:
813 sample_rate_val = 1;
814 break;
815 case SAMPLING_RATE_8KHZ:
816 default:
817 sample_rate_val = 0;
818 break;
819 }
820
821 ucontrol->value.integer.value[0] = sample_rate_val;
822 pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
823 usb_rx_cfg.sample_rate);
824 return 0;
825}
826
827static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
828 struct snd_ctl_elem_value *ucontrol)
829{
830 switch (ucontrol->value.integer.value[0]) {
831 case 12:
832 usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
833 break;
834 case 11:
835 usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
836 break;
837 case 10:
838 usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
839 break;
840 case 9:
841 usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
842 break;
843 case 8:
844 usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
845 break;
846 case 7:
847 usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
848 break;
849 case 6:
850 usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
851 break;
852 case 5:
853 usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
854 break;
855 case 4:
856 usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
857 break;
858 case 3:
859 usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
860 break;
861 case 2:
862 usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
863 break;
864 case 1:
865 usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
866 break;
867 case 0:
868 usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
869 break;
870 default:
871 usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
872 break;
873 }
874
875 pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
876 __func__, ucontrol->value.integer.value[0],
877 usb_rx_cfg.sample_rate);
878 return 0;
879}
880
881static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
882 struct snd_ctl_elem_value *ucontrol)
883{
884 switch (usb_rx_cfg.bit_format) {
885 case SNDRV_PCM_FORMAT_S32_LE:
886 ucontrol->value.integer.value[0] = 3;
887 break;
888 case SNDRV_PCM_FORMAT_S24_3LE:
889 ucontrol->value.integer.value[0] = 2;
890 break;
891 case SNDRV_PCM_FORMAT_S24_LE:
892 ucontrol->value.integer.value[0] = 1;
893 break;
894 case SNDRV_PCM_FORMAT_S16_LE:
895 default:
896 ucontrol->value.integer.value[0] = 0;
897 break;
898 }
899
900 pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
901 __func__, usb_rx_cfg.bit_format,
902 ucontrol->value.integer.value[0]);
903 return 0;
904}
905
906static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
907 struct snd_ctl_elem_value *ucontrol)
908{
909 int rc = 0;
910
911 switch (ucontrol->value.integer.value[0]) {
912 case 3:
913 usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
914 break;
915 case 2:
916 usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
917 break;
918 case 1:
919 usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
920 break;
921 case 0:
922 default:
923 usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
924 break;
925 }
926 pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
927 __func__, usb_rx_cfg.bit_format,
928 ucontrol->value.integer.value[0]);
929
930 return rc;
931}
932
933static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
934 struct snd_ctl_elem_value *ucontrol)
935{
936 pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
937 usb_tx_cfg.channels);
938 ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
939 return 0;
940}
941
942static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
943 struct snd_ctl_elem_value *ucontrol)
944{
945 usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
946
947 pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
948 return 1;
949}
950
951static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
952 struct snd_ctl_elem_value *ucontrol)
953{
954 int sample_rate_val;
955
956 switch (usb_tx_cfg.sample_rate) {
957 case SAMPLING_RATE_384KHZ:
958 sample_rate_val = 12;
959 break;
960 case SAMPLING_RATE_352P8KHZ:
961 sample_rate_val = 11;
962 break;
963 case SAMPLING_RATE_192KHZ:
964 sample_rate_val = 10;
965 break;
966 case SAMPLING_RATE_176P4KHZ:
967 sample_rate_val = 9;
968 break;
969 case SAMPLING_RATE_96KHZ:
970 sample_rate_val = 8;
971 break;
972 case SAMPLING_RATE_88P2KHZ:
973 sample_rate_val = 7;
974 break;
975 case SAMPLING_RATE_48KHZ:
976 sample_rate_val = 6;
977 break;
978 case SAMPLING_RATE_44P1KHZ:
979 sample_rate_val = 5;
980 break;
981 case SAMPLING_RATE_32KHZ:
982 sample_rate_val = 4;
983 break;
984 case SAMPLING_RATE_22P05KHZ:
985 sample_rate_val = 3;
986 break;
987 case SAMPLING_RATE_16KHZ:
988 sample_rate_val = 2;
989 break;
990 case SAMPLING_RATE_11P025KHZ:
991 sample_rate_val = 1;
992 break;
993 case SAMPLING_RATE_8KHZ:
994 sample_rate_val = 0;
995 break;
996 default:
997 sample_rate_val = 6;
998 break;
999 }
1000
1001 ucontrol->value.integer.value[0] = sample_rate_val;
1002 pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
1003 usb_tx_cfg.sample_rate);
1004 return 0;
1005}
1006
1007static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
1008 struct snd_ctl_elem_value *ucontrol)
1009{
1010 switch (ucontrol->value.integer.value[0]) {
1011 case 12:
1012 usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
1013 break;
1014 case 11:
1015 usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
1016 break;
1017 case 10:
1018 usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
1019 break;
1020 case 9:
1021 usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
1022 break;
1023 case 8:
1024 usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
1025 break;
1026 case 7:
1027 usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
1028 break;
1029 case 6:
1030 usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
1031 break;
1032 case 5:
1033 usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
1034 break;
1035 case 4:
1036 usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
1037 break;
1038 case 3:
1039 usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
1040 break;
1041 case 2:
1042 usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
1043 break;
1044 case 1:
1045 usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
1046 break;
1047 case 0:
1048 usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
1049 break;
1050 default:
1051 usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
1052 break;
1053 }
1054
1055 pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
1056 __func__, ucontrol->value.integer.value[0],
1057 usb_tx_cfg.sample_rate);
1058 return 0;
1059}
1060
1061static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
1062 struct snd_ctl_elem_value *ucontrol)
1063{
1064 switch (usb_tx_cfg.bit_format) {
1065 case SNDRV_PCM_FORMAT_S32_LE:
1066 ucontrol->value.integer.value[0] = 3;
1067 break;
1068 case SNDRV_PCM_FORMAT_S24_3LE:
1069 ucontrol->value.integer.value[0] = 2;
1070 break;
1071 case SNDRV_PCM_FORMAT_S24_LE:
1072 ucontrol->value.integer.value[0] = 1;
1073 break;
1074 case SNDRV_PCM_FORMAT_S16_LE:
1075 default:
1076 ucontrol->value.integer.value[0] = 0;
1077 break;
1078 }
1079
1080 pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
1081 __func__, usb_tx_cfg.bit_format,
1082 ucontrol->value.integer.value[0]);
1083 return 0;
1084}
1085
1086static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
1087 struct snd_ctl_elem_value *ucontrol)
1088{
1089 int rc = 0;
1090
1091 switch (ucontrol->value.integer.value[0]) {
1092 case 3:
1093 usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
1094 break;
1095 case 2:
1096 usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
1097 break;
1098 case 1:
1099 usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
1100 break;
1101 case 0:
1102 default:
1103 usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
1104 break;
1105 }
1106 pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
1107 __func__, usb_tx_cfg.bit_format,
1108 ucontrol->value.integer.value[0]);
1109
1110 return rc;
1111}
1112
1113static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
1114{
1115 int idx = 0;
1116
1117 if (strnstr(kcontrol->id.name, "Display Port RX",
1118 sizeof("Display Port RX"))) {
1119 idx = DP_RX_IDX;
1120 } else {
1121 pr_err("%s: unsupported BE: %s\n",
1122 __func__, kcontrol->id.name);
1123 idx = -EINVAL;
1124 }
1125
1126 return idx;
1127}
1128
1129static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
1130 struct snd_ctl_elem_value *ucontrol)
1131{
1132 int idx = ext_disp_get_port_idx(kcontrol);
1133
1134 if (idx < 0)
1135 return idx;
1136
1137 switch (ext_disp_rx_cfg[idx].bit_format) {
1138 case SNDRV_PCM_FORMAT_S24_3LE:
1139 ucontrol->value.integer.value[0] = 2;
1140 break;
1141 case SNDRV_PCM_FORMAT_S24_LE:
1142 ucontrol->value.integer.value[0] = 1;
1143 break;
1144 case SNDRV_PCM_FORMAT_S16_LE:
1145 default:
1146 ucontrol->value.integer.value[0] = 0;
1147 break;
1148 }
1149
1150 pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
1151 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
1152 ucontrol->value.integer.value[0]);
1153 return 0;
1154}
1155
1156static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
1157 struct snd_ctl_elem_value *ucontrol)
1158{
1159 int idx = ext_disp_get_port_idx(kcontrol);
1160
1161 if (idx < 0)
1162 return idx;
1163
1164 switch (ucontrol->value.integer.value[0]) {
1165 case 2:
1166 ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
1167 break;
1168 case 1:
1169 ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
1170 break;
1171 case 0:
1172 default:
1173 ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
1174 break;
1175 }
1176 pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
1177 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
1178 ucontrol->value.integer.value[0]);
1179
1180 return 0;
1181}
1182
1183static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
1184 struct snd_ctl_elem_value *ucontrol)
1185{
1186 int idx = ext_disp_get_port_idx(kcontrol);
1187
1188 if (idx < 0)
1189 return idx;
1190
1191 ucontrol->value.integer.value[0] =
1192 ext_disp_rx_cfg[idx].channels - 2;
1193
1194 pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
1195 idx, ext_disp_rx_cfg[idx].channels);
1196
1197 return 0;
1198}
1199
1200static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
1201 struct snd_ctl_elem_value *ucontrol)
1202{
1203 int idx = ext_disp_get_port_idx(kcontrol);
1204
1205 if (idx < 0)
1206 return idx;
1207
1208 ext_disp_rx_cfg[idx].channels =
1209 ucontrol->value.integer.value[0] + 2;
1210
1211 pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
1212 idx, ext_disp_rx_cfg[idx].channels);
1213 return 1;
1214}
1215
1216static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
1217 struct snd_ctl_elem_value *ucontrol)
1218{
1219 int sample_rate_val;
1220 int idx = ext_disp_get_port_idx(kcontrol);
1221
1222 if (idx < 0)
1223 return idx;
1224
1225 switch (ext_disp_rx_cfg[idx].sample_rate) {
1226 case SAMPLING_RATE_176P4KHZ:
1227 sample_rate_val = 6;
1228 break;
1229
1230 case SAMPLING_RATE_88P2KHZ:
1231 sample_rate_val = 5;
1232 break;
1233
1234 case SAMPLING_RATE_44P1KHZ:
1235 sample_rate_val = 4;
1236 break;
1237
1238 case SAMPLING_RATE_32KHZ:
1239 sample_rate_val = 3;
1240 break;
1241
1242 case SAMPLING_RATE_192KHZ:
1243 sample_rate_val = 2;
1244 break;
1245
1246 case SAMPLING_RATE_96KHZ:
1247 sample_rate_val = 1;
1248 break;
1249
1250 case SAMPLING_RATE_48KHZ:
1251 default:
1252 sample_rate_val = 0;
1253 break;
1254 }
1255
1256 ucontrol->value.integer.value[0] = sample_rate_val;
1257 pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
1258 idx, ext_disp_rx_cfg[idx].sample_rate);
1259
1260 return 0;
1261}
1262
1263static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
1264 struct snd_ctl_elem_value *ucontrol)
1265{
1266 int idx = ext_disp_get_port_idx(kcontrol);
1267
1268 if (idx < 0)
1269 return idx;
1270
1271 switch (ucontrol->value.integer.value[0]) {
1272 case 6:
1273 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
1274 break;
1275 case 5:
1276 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
1277 break;
1278 case 4:
1279 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
1280 break;
1281 case 3:
1282 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
1283 break;
1284 case 2:
1285 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
1286 break;
1287 case 1:
1288 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
1289 break;
1290 case 0:
1291 default:
1292 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
1293 break;
1294 }
1295
1296 pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
1297 __func__, ucontrol->value.integer.value[0], idx,
1298 ext_disp_rx_cfg[idx].sample_rate);
1299 return 0;
1300}
1301
1302static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
1303 struct snd_ctl_elem_value *ucontrol)
1304{
1305 pr_debug("%s: proxy_rx channels = %d\n",
1306 __func__, proxy_rx_cfg.channels);
1307 ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
1308
1309 return 0;
1310}
1311
1312static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
1313 struct snd_ctl_elem_value *ucontrol)
1314{
1315 proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
1316 pr_debug("%s: proxy_rx channels = %d\n",
1317 __func__, proxy_rx_cfg.channels);
1318
1319 return 1;
1320}
1321
1322static int tdm_get_sample_rate(int value)
1323{
1324 int sample_rate = 0;
1325
1326 switch (value) {
1327 case 0:
1328 sample_rate = SAMPLING_RATE_8KHZ;
1329 break;
1330 case 1:
1331 sample_rate = SAMPLING_RATE_16KHZ;
1332 break;
1333 case 2:
1334 sample_rate = SAMPLING_RATE_32KHZ;
1335 break;
1336 case 3:
1337 sample_rate = SAMPLING_RATE_48KHZ;
1338 break;
1339 case 4:
1340 sample_rate = SAMPLING_RATE_176P4KHZ;
1341 break;
1342 case 5:
1343 sample_rate = SAMPLING_RATE_352P8KHZ;
1344 break;
1345 default:
1346 sample_rate = SAMPLING_RATE_48KHZ;
1347 break;
1348 }
1349 return sample_rate;
1350}
1351
1352static int aux_pcm_get_sample_rate(int value)
1353{
1354 int sample_rate;
1355
1356 switch (value) {
1357 case 1:
1358 sample_rate = SAMPLING_RATE_16KHZ;
1359 break;
1360 case 0:
1361 default:
1362 sample_rate = SAMPLING_RATE_8KHZ;
1363 break;
1364 }
1365 return sample_rate;
1366}
1367
1368static int tdm_get_sample_rate_val(int sample_rate)
1369{
1370 int sample_rate_val = 0;
1371
1372 switch (sample_rate) {
1373 case SAMPLING_RATE_8KHZ:
1374 sample_rate_val = 0;
1375 break;
1376 case SAMPLING_RATE_16KHZ:
1377 sample_rate_val = 1;
1378 break;
1379 case SAMPLING_RATE_32KHZ:
1380 sample_rate_val = 2;
1381 break;
1382 case SAMPLING_RATE_48KHZ:
1383 sample_rate_val = 3;
1384 break;
1385 case SAMPLING_RATE_176P4KHZ:
1386 sample_rate_val = 4;
1387 break;
1388 case SAMPLING_RATE_352P8KHZ:
1389 sample_rate_val = 5;
1390 break;
1391 default:
1392 sample_rate_val = 3;
1393 break;
1394 }
1395 return sample_rate_val;
1396}
1397
1398static int aux_pcm_get_sample_rate_val(int sample_rate)
1399{
1400 int sample_rate_val = 0;
1401
1402 switch (sample_rate) {
1403 case SAMPLING_RATE_16KHZ:
1404 sample_rate_val = 1;
1405 break;
1406 case SAMPLING_RATE_8KHZ:
1407 default:
1408 sample_rate_val = 0;
1409 break;
1410 }
1411 return sample_rate_val;
1412}
1413
1414static int tdm_get_mode(struct snd_kcontrol *kcontrol)
1415{
Derek Chen0150b832019-06-05 18:46:29 +05301416 int mode = -EINVAL;
Rahul Sharma02bee732018-12-20 18:48:34 +05301417
1418 if (strnstr(kcontrol->id.name, "PRI",
1419 sizeof(kcontrol->id.name))) {
1420 mode = TDM_PRI;
1421 } else if (strnstr(kcontrol->id.name, "SEC",
1422 sizeof(kcontrol->id.name))) {
1423 mode = TDM_SEC;
1424 } else if (strnstr(kcontrol->id.name, "TERT",
1425 sizeof(kcontrol->id.name))) {
1426 mode = TDM_TERT;
1427 } else if (strnstr(kcontrol->id.name, "QUAT",
1428 sizeof(kcontrol->id.name))) {
1429 mode = TDM_QUAT;
1430 } else if (strnstr(kcontrol->id.name, "QUIN",
1431 sizeof(kcontrol->id.name))) {
1432 mode = TDM_QUIN;
1433 } else {
1434 pr_err("%s: unsupported mode in: %s",
1435 __func__, kcontrol->id.name);
1436 mode = -EINVAL;
1437 }
1438
1439 return mode;
1440}
1441
1442static int tdm_get_channel(struct snd_kcontrol *kcontrol)
1443{
Derek Chen0150b832019-06-05 18:46:29 +05301444 int channel = -EINVAL;
Rahul Sharma02bee732018-12-20 18:48:34 +05301445
1446 if (strnstr(kcontrol->id.name, "RX_0",
1447 sizeof(kcontrol->id.name)) ||
1448 strnstr(kcontrol->id.name, "TX_0",
1449 sizeof(kcontrol->id.name))) {
1450 channel = TDM_0;
1451 } else if (strnstr(kcontrol->id.name, "RX_1",
1452 sizeof(kcontrol->id.name)) ||
1453 strnstr(kcontrol->id.name, "TX_1",
1454 sizeof(kcontrol->id.name))) {
1455 channel = TDM_1;
1456 } else if (strnstr(kcontrol->id.name, "RX_2",
1457 sizeof(kcontrol->id.name)) ||
1458 strnstr(kcontrol->id.name, "TX_2",
1459 sizeof(kcontrol->id.name))) {
1460 channel = TDM_2;
1461 } else if (strnstr(kcontrol->id.name, "RX_3",
1462 sizeof(kcontrol->id.name)) ||
1463 strnstr(kcontrol->id.name, "TX_3",
1464 sizeof(kcontrol->id.name))) {
1465 channel = TDM_3;
1466 } else if (strnstr(kcontrol->id.name, "RX_4",
1467 sizeof(kcontrol->id.name)) ||
1468 strnstr(kcontrol->id.name, "TX_4",
1469 sizeof(kcontrol->id.name))) {
1470 channel = TDM_4;
1471 } else if (strnstr(kcontrol->id.name, "RX_5",
1472 sizeof(kcontrol->id.name)) ||
1473 strnstr(kcontrol->id.name, "TX_5",
1474 sizeof(kcontrol->id.name))) {
1475 channel = TDM_5;
1476 } else if (strnstr(kcontrol->id.name, "RX_6",
1477 sizeof(kcontrol->id.name)) ||
1478 strnstr(kcontrol->id.name, "TX_6",
1479 sizeof(kcontrol->id.name))) {
1480 channel = TDM_6;
1481 } else if (strnstr(kcontrol->id.name, "RX_7",
1482 sizeof(kcontrol->id.name)) ||
1483 strnstr(kcontrol->id.name, "TX_7",
1484 sizeof(kcontrol->id.name))) {
1485 channel = TDM_7;
1486 } else {
1487 pr_err("%s: unsupported channel in: %s",
1488 __func__, kcontrol->id.name);
1489 channel = -EINVAL;
1490 }
1491
1492 return channel;
1493}
1494
1495static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
1496 struct tdm_port *port)
1497{
1498 if (port) {
1499 port->mode = tdm_get_mode(kcontrol);
1500 if (port->mode < 0)
1501 return port->mode;
1502
1503 port->channel = tdm_get_channel(kcontrol);
1504 if (port->channel < 0)
1505 return port->channel;
Derek Chen0150b832019-06-05 18:46:29 +05301506 } else
Rahul Sharma02bee732018-12-20 18:48:34 +05301507 return -EINVAL;
Rahul Sharma02bee732018-12-20 18:48:34 +05301508 return 0;
1509}
1510
1511static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
1512 struct snd_ctl_elem_value *ucontrol)
1513{
1514 struct tdm_port port;
1515 int ret = tdm_get_port_idx(kcontrol, &port);
1516
1517 if (ret) {
1518 pr_err("%s: unsupported control: %s\n",
1519 __func__, kcontrol->id.name);
1520 } else {
1521 ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
1522 tdm_rx_cfg[port.mode][port.channel].sample_rate);
1523
1524 pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
1525 tdm_rx_cfg[port.mode][port.channel].sample_rate,
1526 ucontrol->value.enumerated.item[0]);
1527 }
1528 return ret;
1529}
1530
1531static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
1532 struct snd_ctl_elem_value *ucontrol)
1533{
1534 struct tdm_port port;
1535 int ret = tdm_get_port_idx(kcontrol, &port);
1536
1537 if (ret) {
1538 pr_err("%s: unsupported control: %s\n",
1539 __func__, kcontrol->id.name);
1540 } else {
1541 tdm_rx_cfg[port.mode][port.channel].sample_rate =
1542 tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
1543
1544 pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
1545 tdm_rx_cfg[port.mode][port.channel].sample_rate,
1546 ucontrol->value.enumerated.item[0]);
1547 }
1548 return ret;
1549}
1550
1551static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
1552 struct snd_ctl_elem_value *ucontrol)
1553{
1554 struct tdm_port port;
1555 int ret = tdm_get_port_idx(kcontrol, &port);
1556
1557 if (ret) {
1558 pr_err("%s: unsupported control: %s",
1559 __func__, kcontrol->id.name);
1560 } else {
1561 ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
1562 tdm_tx_cfg[port.mode][port.channel].sample_rate);
1563
1564 pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
1565 tdm_tx_cfg[port.mode][port.channel].sample_rate,
1566 ucontrol->value.enumerated.item[0]);
1567 }
1568 return ret;
1569}
1570
1571static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
1572 struct snd_ctl_elem_value *ucontrol)
1573{
1574 struct tdm_port port;
1575 int ret = tdm_get_port_idx(kcontrol, &port);
1576
1577 if (ret) {
1578 pr_err("%s: unsupported control: %s\n",
1579 __func__, kcontrol->id.name);
1580 } else {
1581 tdm_tx_cfg[port.mode][port.channel].sample_rate =
1582 tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
1583
1584 pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
1585 tdm_tx_cfg[port.mode][port.channel].sample_rate,
1586 ucontrol->value.enumerated.item[0]);
1587 }
1588 return ret;
1589}
1590
1591static int tdm_get_format(int value)
1592{
1593 int format = 0;
1594
1595 switch (value) {
1596 case 0:
1597 format = SNDRV_PCM_FORMAT_S16_LE;
1598 break;
1599 case 1:
1600 format = SNDRV_PCM_FORMAT_S24_LE;
1601 break;
1602 case 2:
1603 format = SNDRV_PCM_FORMAT_S32_LE;
1604 break;
1605 default:
1606 format = SNDRV_PCM_FORMAT_S16_LE;
1607 break;
1608 }
1609 return format;
1610}
1611
1612static int tdm_get_format_val(int format)
1613{
1614 int value = 0;
1615
1616 switch (format) {
1617 case SNDRV_PCM_FORMAT_S16_LE:
1618 value = 0;
1619 break;
1620 case SNDRV_PCM_FORMAT_S24_LE:
1621 value = 1;
1622 break;
1623 case SNDRV_PCM_FORMAT_S32_LE:
1624 value = 2;
1625 break;
1626 default:
1627 value = 0;
1628 break;
1629 }
1630 return value;
1631}
1632
1633static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
1634 struct snd_ctl_elem_value *ucontrol)
1635{
1636 struct tdm_port port;
1637 int ret = tdm_get_port_idx(kcontrol, &port);
1638
1639 if (ret) {
1640 pr_err("%s: unsupported control: %s\n",
1641 __func__, kcontrol->id.name);
1642 } else {
1643 ucontrol->value.enumerated.item[0] = tdm_get_format_val(
1644 tdm_rx_cfg[port.mode][port.channel].bit_format);
1645
1646 pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
1647 tdm_rx_cfg[port.mode][port.channel].bit_format,
1648 ucontrol->value.enumerated.item[0]);
1649 }
1650 return ret;
1651}
1652
1653static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
1654 struct snd_ctl_elem_value *ucontrol)
1655{
1656 struct tdm_port port;
1657 int ret = tdm_get_port_idx(kcontrol, &port);
1658
1659 if (ret) {
1660 pr_err("%s: unsupported control: %s\n",
1661 __func__, kcontrol->id.name);
1662 } else {
1663 tdm_rx_cfg[port.mode][port.channel].bit_format =
1664 tdm_get_format(ucontrol->value.enumerated.item[0]);
1665
1666 pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
1667 tdm_rx_cfg[port.mode][port.channel].bit_format,
1668 ucontrol->value.enumerated.item[0]);
1669 }
1670 return ret;
1671}
1672
1673static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
1674 struct snd_ctl_elem_value *ucontrol)
1675{
1676 struct tdm_port port;
1677 int ret = tdm_get_port_idx(kcontrol, &port);
1678
1679 if (ret) {
1680 pr_err("%s: unsupported control: %s\n",
1681 __func__, kcontrol->id.name);
1682 } else {
1683 ucontrol->value.enumerated.item[0] = tdm_get_format_val(
1684 tdm_tx_cfg[port.mode][port.channel].bit_format);
1685
1686 pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
1687 tdm_tx_cfg[port.mode][port.channel].bit_format,
1688 ucontrol->value.enumerated.item[0]);
1689 }
1690 return ret;
1691}
1692
1693static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
1694 struct snd_ctl_elem_value *ucontrol)
1695{
1696 struct tdm_port port;
1697 int ret = tdm_get_port_idx(kcontrol, &port);
1698
1699 if (ret) {
1700 pr_err("%s: unsupported control: %s\n",
1701 __func__, kcontrol->id.name);
1702 } else {
1703 tdm_tx_cfg[port.mode][port.channel].bit_format =
1704 tdm_get_format(ucontrol->value.enumerated.item[0]);
1705
1706 pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
1707 tdm_tx_cfg[port.mode][port.channel].bit_format,
1708 ucontrol->value.enumerated.item[0]);
1709 }
1710 return ret;
1711}
1712
1713static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
1714 struct snd_ctl_elem_value *ucontrol)
1715{
1716 struct tdm_port port;
1717 int ret = tdm_get_port_idx(kcontrol, &port);
1718
1719 if (ret) {
1720 pr_err("%s: unsupported control: %s\n",
1721 __func__, kcontrol->id.name);
1722 } else {
1723
1724 ucontrol->value.enumerated.item[0] =
1725 tdm_rx_cfg[port.mode][port.channel].channels - 1;
1726
1727 pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
1728 tdm_rx_cfg[port.mode][port.channel].channels - 1,
1729 ucontrol->value.enumerated.item[0]);
1730 }
1731 return ret;
1732}
1733
1734static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
1735 struct snd_ctl_elem_value *ucontrol)
1736{
1737 struct tdm_port port;
1738 int ret = tdm_get_port_idx(kcontrol, &port);
1739
1740 if (ret) {
1741 pr_err("%s: unsupported control: %s\n",
1742 __func__, kcontrol->id.name);
1743 } else {
1744 tdm_rx_cfg[port.mode][port.channel].channels =
1745 ucontrol->value.enumerated.item[0] + 1;
1746
1747 pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
1748 tdm_rx_cfg[port.mode][port.channel].channels,
1749 ucontrol->value.enumerated.item[0] + 1);
1750 }
1751 return ret;
1752}
1753
1754static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
1755 struct snd_ctl_elem_value *ucontrol)
1756{
1757 struct tdm_port port;
1758 int ret = tdm_get_port_idx(kcontrol, &port);
1759
1760 if (ret) {
1761 pr_err("%s: unsupported control: %s\n",
1762 __func__, kcontrol->id.name);
1763 } else {
1764 ucontrol->value.enumerated.item[0] =
1765 tdm_tx_cfg[port.mode][port.channel].channels - 1;
1766
1767 pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
1768 tdm_tx_cfg[port.mode][port.channel].channels - 1,
1769 ucontrol->value.enumerated.item[0]);
1770 }
1771 return ret;
1772}
1773
1774static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
1775 struct snd_ctl_elem_value *ucontrol)
1776{
1777 struct tdm_port port;
1778 int ret = tdm_get_port_idx(kcontrol, &port);
1779
1780 if (ret) {
1781 pr_err("%s: unsupported control: %s\n",
1782 __func__, kcontrol->id.name);
1783 } else {
1784 tdm_tx_cfg[port.mode][port.channel].channels =
1785 ucontrol->value.enumerated.item[0] + 1;
1786
1787 pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
1788 tdm_tx_cfg[port.mode][port.channel].channels,
1789 ucontrol->value.enumerated.item[0] + 1);
1790 }
1791 return ret;
1792}
1793
1794static int tdm_get_slot_num_val(int slot_num)
1795{
1796 int slot_num_val = 0;
1797
1798 switch (slot_num) {
1799 case 1:
1800 slot_num_val = 0;
1801 break;
1802 case 2:
1803 slot_num_val = 1;
1804 break;
1805 case 4:
1806 slot_num_val = 2;
1807 break;
1808 case 8:
1809 slot_num_val = 3;
1810 break;
1811 case 16:
1812 slot_num_val = 4;
1813 break;
1814 case 32:
1815 slot_num_val = 5;
1816 break;
1817 default:
1818 slot_num_val = 5;
1819 break;
1820 }
1821 return slot_num_val;
1822}
1823
1824static int tdm_slot_num_get(struct snd_kcontrol *kcontrol,
1825 struct snd_ctl_elem_value *ucontrol)
1826{
1827 int mode = tdm_get_mode(kcontrol);
1828
1829 if (mode < 0) {
1830 pr_err("%s: unsupported control: %s\n",
1831 __func__, kcontrol->id.name);
1832 return mode;
1833 }
1834
1835 ucontrol->value.enumerated.item[0] =
1836 tdm_get_slot_num_val(tdm_slot[mode].num);
1837
1838 pr_debug("%s: mode = %d, tdm_slot_num = %d, item = %d\n", __func__,
1839 mode, tdm_slot[mode].num,
1840 ucontrol->value.enumerated.item[0]);
1841
1842 return 0;
1843}
1844
1845static int tdm_get_slot_num(int value)
1846{
1847 int slot_num = 0;
1848
1849 switch (value) {
1850 case 0:
1851 slot_num = 1;
1852 break;
1853 case 1:
1854 slot_num = 2;
1855 break;
1856 case 2:
1857 slot_num = 4;
1858 break;
1859 case 3:
1860 slot_num = 8;
1861 break;
1862 case 4:
1863 slot_num = 16;
1864 break;
1865 case 5:
1866 slot_num = 32;
1867 break;
1868 default:
1869 slot_num = 8;
1870 break;
1871 }
1872 return slot_num;
1873}
1874
1875static int tdm_slot_num_put(struct snd_kcontrol *kcontrol,
1876 struct snd_ctl_elem_value *ucontrol)
1877{
1878 int mode = tdm_get_mode(kcontrol);
1879
1880 if (mode < 0) {
1881 pr_err("%s: unsupported control: %s\n",
1882 __func__, kcontrol->id.name);
1883 return mode;
1884 }
1885
1886 tdm_slot[mode].num =
1887 tdm_get_slot_num(ucontrol->value.enumerated.item[0]);
1888
1889 pr_debug("%s: mode = %d, tdm_slot_num = %d, item = %d\n", __func__,
1890 mode, tdm_slot[mode].num,
1891 ucontrol->value.enumerated.item[0]);
1892
1893 return 0;
1894}
1895
1896static int tdm_get_slot_width_val(int slot_width)
1897{
1898 int slot_width_val = 2;
1899
1900 switch (slot_width) {
1901 case 16:
1902 slot_width_val = 0;
1903 break;
1904 case 24:
1905 slot_width_val = 1;
1906 break;
1907 case 32:
1908 slot_width_val = 2;
1909 break;
1910 default:
1911 slot_width_val = 2;
1912 break;
1913 }
1914 return slot_width_val;
1915}
1916
1917static int tdm_slot_width_get(struct snd_kcontrol *kcontrol,
1918 struct snd_ctl_elem_value *ucontrol)
1919{
1920 int mode = tdm_get_mode(kcontrol);
1921
1922 if (mode < 0) {
1923 pr_err("%s: unsupported control: %s\n",
1924 __func__, kcontrol->id.name);
1925 return mode;
1926 }
1927
1928 ucontrol->value.enumerated.item[0] =
1929 tdm_get_slot_width_val(tdm_slot[mode].width);
1930
1931 pr_debug("%s: mode = %d, tdm_slot_width = %d, item = %d\n", __func__,
1932 mode, tdm_slot[mode].width,
1933 ucontrol->value.enumerated.item[0]);
1934
1935 return 0;
1936}
1937
1938static int tdm_get_slot_width(int value)
1939{
1940 int slot_width = 32;
1941
1942 switch (value) {
1943 case 0:
1944 slot_width = 16;
1945 break;
1946 case 1:
1947 slot_width = 24;
1948 break;
1949 case 2:
1950 slot_width = 32;
1951 break;
1952 default:
1953 slot_width = 32;
1954 break;
1955 }
1956 return slot_width;
1957}
1958
1959static int tdm_slot_width_put(struct snd_kcontrol *kcontrol,
1960 struct snd_ctl_elem_value *ucontrol)
1961{
1962 int mode = tdm_get_mode(kcontrol);
1963
1964 if (mode < 0) {
1965 pr_err("%s: unsupported control: %s\n",
1966 __func__, kcontrol->id.name);
1967 return mode;
1968 }
1969
1970 tdm_slot[mode].width =
1971 tdm_get_slot_width(ucontrol->value.enumerated.item[0]);
1972
1973 pr_debug("%s: mode = %d, tdm_slot_width = %d, item = %d\n", __func__,
1974 mode, tdm_slot[mode].width,
1975 ucontrol->value.enumerated.item[0]);
1976
1977 return 0;
1978}
1979
1980static int tdm_rx_slot_mapping_get(struct snd_kcontrol *kcontrol,
1981 struct snd_ctl_elem_value *ucontrol)
1982{
1983 unsigned int *slot_offset;
1984 int i;
1985 struct tdm_port port;
1986 int ret = tdm_get_port_idx(kcontrol, &port);
1987
1988 if (ret) {
1989 pr_err("%s: unsupported control: %s\n",
1990 __func__, kcontrol->id.name);
1991 } else {
1992 slot_offset = tdm_rx_slot_offset[port.mode][port.channel];
1993 pr_debug("%s: mode = %d, channel = %d\n",
1994 __func__, port.mode, port.channel);
1995 for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
1996 ucontrol->value.integer.value[i] = slot_offset[i];
1997 pr_debug("%s: offset %d, value %d\n",
1998 __func__, i, slot_offset[i]);
1999 }
2000 }
2001 return ret;
2002}
2003
2004static int tdm_rx_slot_mapping_put(struct snd_kcontrol *kcontrol,
2005 struct snd_ctl_elem_value *ucontrol)
2006{
2007 unsigned int *slot_offset;
2008 int i;
2009 struct tdm_port port;
2010 int ret = tdm_get_port_idx(kcontrol, &port);
2011
2012 if (ret) {
2013 pr_err("%s: unsupported control: %s\n",
2014 __func__, kcontrol->id.name);
2015 } else {
2016 slot_offset = tdm_rx_slot_offset[port.mode][port.channel];
2017 pr_debug("%s: mode = %d, channel = %d\n",
2018 __func__, port.mode, port.channel);
2019 for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
2020 slot_offset[i] = ucontrol->value.integer.value[i];
2021 pr_debug("%s: offset %d, value %d\n",
2022 __func__, i, slot_offset[i]);
2023 }
2024 }
2025 return ret;
2026}
2027
2028static int tdm_tx_slot_mapping_get(struct snd_kcontrol *kcontrol,
2029 struct snd_ctl_elem_value *ucontrol)
2030{
2031 unsigned int *slot_offset;
2032 int i;
2033 struct tdm_port port;
2034 int ret = tdm_get_port_idx(kcontrol, &port);
2035
2036 if (ret) {
2037 pr_err("%s: unsupported control: %s\n",
2038 __func__, kcontrol->id.name);
2039 } else {
2040 slot_offset = tdm_tx_slot_offset[port.mode][port.channel];
2041 pr_debug("%s: mode = %d, channel = %d\n",
2042 __func__, port.mode, port.channel);
2043 for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
2044 ucontrol->value.integer.value[i] = slot_offset[i];
2045 pr_debug("%s: offset %d, value %d\n",
2046 __func__, i, slot_offset[i]);
2047 }
2048 }
2049 return ret;
2050}
2051
2052static int tdm_tx_slot_mapping_put(struct snd_kcontrol *kcontrol,
2053 struct snd_ctl_elem_value *ucontrol)
2054{
2055 unsigned int *slot_offset;
2056 int i;
2057 struct tdm_port port;
2058 int ret = tdm_get_port_idx(kcontrol, &port);
2059
2060 if (ret) {
2061 pr_err("%s: unsupported control: %s\n",
2062 __func__, kcontrol->id.name);
2063 } else {
2064 slot_offset = tdm_tx_slot_offset[port.mode][port.channel];
2065 pr_debug("%s: mode = %d, channel = %d\n",
2066 __func__, port.mode, port.channel);
2067 for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
2068 slot_offset[i] = ucontrol->value.integer.value[i];
2069 pr_debug("%s: offset %d, value %d\n",
2070 __func__, i, slot_offset[i]);
2071 }
2072 }
2073 return ret;
2074}
2075
2076static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
2077{
2078 int idx;
2079
2080 if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
2081 sizeof("PRIM_AUX_PCM")))
2082 idx = PRIM_AUX_PCM;
2083 else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
2084 sizeof("SEC_AUX_PCM")))
2085 idx = SEC_AUX_PCM;
2086 else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
2087 sizeof("TERT_AUX_PCM")))
2088 idx = TERT_AUX_PCM;
2089 else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
2090 sizeof("QUAT_AUX_PCM")))
2091 idx = QUAT_AUX_PCM;
2092 else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
2093 sizeof("QUIN_AUX_PCM")))
2094 idx = QUIN_AUX_PCM;
2095 else {
2096 pr_err("%s: unsupported port: %s\n",
2097 __func__, kcontrol->id.name);
2098 idx = -EINVAL;
2099 }
2100
2101 return idx;
2102}
2103
2104static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
2105 struct snd_ctl_elem_value *ucontrol)
2106{
2107 int idx = aux_pcm_get_port_idx(kcontrol);
2108
2109 if (idx < 0)
2110 return idx;
2111
2112 aux_pcm_rx_cfg[idx].sample_rate =
2113 aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
2114
2115 pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
2116 idx, aux_pcm_rx_cfg[idx].sample_rate,
2117 ucontrol->value.enumerated.item[0]);
2118
2119 return 0;
2120}
2121
2122static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
2123 struct snd_ctl_elem_value *ucontrol)
2124{
2125 int idx = aux_pcm_get_port_idx(kcontrol);
2126
2127 if (idx < 0)
2128 return idx;
2129
2130 ucontrol->value.enumerated.item[0] =
2131 aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
2132
2133 pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
2134 idx, aux_pcm_rx_cfg[idx].sample_rate,
2135 ucontrol->value.enumerated.item[0]);
2136
2137 return 0;
2138}
2139
2140static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
2141 struct snd_ctl_elem_value *ucontrol)
2142{
2143 int idx = aux_pcm_get_port_idx(kcontrol);
2144
2145 if (idx < 0)
2146 return idx;
2147
2148 aux_pcm_tx_cfg[idx].sample_rate =
2149 aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
2150
2151 pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
2152 idx, aux_pcm_tx_cfg[idx].sample_rate,
2153 ucontrol->value.enumerated.item[0]);
2154
2155 return 0;
2156}
2157
2158static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
2159 struct snd_ctl_elem_value *ucontrol)
2160{
2161 int idx = aux_pcm_get_port_idx(kcontrol);
2162
2163 if (idx < 0)
2164 return idx;
2165
2166 ucontrol->value.enumerated.item[0] =
2167 aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
2168
2169 pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
2170 idx, aux_pcm_tx_cfg[idx].sample_rate,
2171 ucontrol->value.enumerated.item[0]);
2172
2173 return 0;
2174}
2175
2176static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
2177{
2178 int idx;
2179
2180 if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
2181 sizeof("PRIM_MI2S_RX")))
2182 idx = PRIM_MI2S;
2183 else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
2184 sizeof("SEC_MI2S_RX")))
2185 idx = SEC_MI2S;
2186 else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
2187 sizeof("TERT_MI2S_RX")))
2188 idx = TERT_MI2S;
2189 else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
2190 sizeof("QUAT_MI2S_RX")))
2191 idx = QUAT_MI2S;
2192 else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
2193 sizeof("QUIN_MI2S_RX")))
2194 idx = QUIN_MI2S;
2195 else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
2196 sizeof("PRIM_MI2S_TX")))
2197 idx = PRIM_MI2S;
2198 else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
2199 sizeof("SEC_MI2S_TX")))
2200 idx = SEC_MI2S;
2201 else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
2202 sizeof("TERT_MI2S_TX")))
2203 idx = TERT_MI2S;
2204 else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
2205 sizeof("QUAT_MI2S_TX")))
2206 idx = QUAT_MI2S;
2207 else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
2208 sizeof("QUIN_MI2S_TX")))
2209 idx = QUIN_MI2S;
2210 else {
2211 pr_err("%s: unsupported channel: %s\n",
2212 __func__, kcontrol->id.name);
2213 idx = -EINVAL;
2214 }
2215
2216 return idx;
2217}
2218
2219static int mi2s_get_sample_rate_val(int sample_rate)
2220{
2221 int sample_rate_val;
2222
2223 switch (sample_rate) {
2224 case SAMPLING_RATE_8KHZ:
2225 sample_rate_val = 0;
2226 break;
2227 case SAMPLING_RATE_11P025KHZ:
2228 sample_rate_val = 1;
2229 break;
2230 case SAMPLING_RATE_16KHZ:
2231 sample_rate_val = 2;
2232 break;
2233 case SAMPLING_RATE_22P05KHZ:
2234 sample_rate_val = 3;
2235 break;
2236 case SAMPLING_RATE_32KHZ:
2237 sample_rate_val = 4;
2238 break;
2239 case SAMPLING_RATE_44P1KHZ:
2240 sample_rate_val = 5;
2241 break;
2242 case SAMPLING_RATE_48KHZ:
2243 sample_rate_val = 6;
2244 break;
2245 case SAMPLING_RATE_96KHZ:
2246 sample_rate_val = 7;
2247 break;
2248 case SAMPLING_RATE_192KHZ:
2249 sample_rate_val = 8;
2250 break;
2251 default:
2252 sample_rate_val = 6;
2253 break;
2254 }
2255 return sample_rate_val;
2256}
2257
2258static int mi2s_get_sample_rate(int value)
2259{
2260 int sample_rate;
2261
2262 switch (value) {
2263 case 0:
2264 sample_rate = SAMPLING_RATE_8KHZ;
2265 break;
2266 case 1:
2267 sample_rate = SAMPLING_RATE_11P025KHZ;
2268 break;
2269 case 2:
2270 sample_rate = SAMPLING_RATE_16KHZ;
2271 break;
2272 case 3:
2273 sample_rate = SAMPLING_RATE_22P05KHZ;
2274 break;
2275 case 4:
2276 sample_rate = SAMPLING_RATE_32KHZ;
2277 break;
2278 case 5:
2279 sample_rate = SAMPLING_RATE_44P1KHZ;
2280 break;
2281 case 6:
2282 sample_rate = SAMPLING_RATE_48KHZ;
2283 break;
2284 case 7:
2285 sample_rate = SAMPLING_RATE_96KHZ;
2286 break;
2287 case 8:
2288 sample_rate = SAMPLING_RATE_192KHZ;
2289 break;
2290 default:
2291 sample_rate = SAMPLING_RATE_48KHZ;
2292 break;
2293 }
2294 return sample_rate;
2295}
2296
2297static int mi2s_auxpcm_get_format(int value)
2298{
2299 int format;
2300
2301 switch (value) {
2302 case 0:
2303 format = SNDRV_PCM_FORMAT_S16_LE;
2304 break;
2305 case 1:
2306 format = SNDRV_PCM_FORMAT_S24_LE;
2307 break;
2308 case 2:
2309 format = SNDRV_PCM_FORMAT_S24_3LE;
2310 break;
2311 case 3:
2312 format = SNDRV_PCM_FORMAT_S32_LE;
2313 break;
2314 default:
2315 format = SNDRV_PCM_FORMAT_S16_LE;
2316 break;
2317 }
2318 return format;
2319}
2320
2321static int mi2s_auxpcm_get_format_value(int format)
2322{
2323 int value;
2324
2325 switch (format) {
2326 case SNDRV_PCM_FORMAT_S16_LE:
2327 value = 0;
2328 break;
2329 case SNDRV_PCM_FORMAT_S24_LE:
2330 value = 1;
2331 break;
2332 case SNDRV_PCM_FORMAT_S24_3LE:
2333 value = 2;
2334 break;
2335 case SNDRV_PCM_FORMAT_S32_LE:
2336 value = 3;
2337 break;
2338 default:
2339 value = 0;
2340 break;
2341 }
2342 return value;
2343}
2344
2345static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
2346 struct snd_ctl_elem_value *ucontrol)
2347{
2348 int idx = mi2s_get_port_idx(kcontrol);
2349
2350 if (idx < 0)
2351 return idx;
2352
2353 mi2s_rx_cfg[idx].sample_rate =
2354 mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
2355
2356 pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
2357 idx, mi2s_rx_cfg[idx].sample_rate,
2358 ucontrol->value.enumerated.item[0]);
2359
2360 return 0;
2361}
2362
2363static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
2364 struct snd_ctl_elem_value *ucontrol)
2365{
2366 int idx = mi2s_get_port_idx(kcontrol);
2367
2368 if (idx < 0)
2369 return idx;
2370
2371 ucontrol->value.enumerated.item[0] =
2372 mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
2373
2374 pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
2375 idx, mi2s_rx_cfg[idx].sample_rate,
2376 ucontrol->value.enumerated.item[0]);
2377
2378 return 0;
2379}
2380
2381static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
2382 struct snd_ctl_elem_value *ucontrol)
2383{
2384 int idx = mi2s_get_port_idx(kcontrol);
2385
2386 if (idx < 0)
2387 return idx;
2388
2389 mi2s_tx_cfg[idx].sample_rate =
2390 mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
2391
2392 pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
2393 idx, mi2s_tx_cfg[idx].sample_rate,
2394 ucontrol->value.enumerated.item[0]);
2395
2396 return 0;
2397}
2398
2399static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
2400 struct snd_ctl_elem_value *ucontrol)
2401{
2402 int idx = mi2s_get_port_idx(kcontrol);
2403
2404 if (idx < 0)
2405 return idx;
2406
2407 ucontrol->value.enumerated.item[0] =
2408 mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
2409
2410 pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
2411 idx, mi2s_tx_cfg[idx].sample_rate,
2412 ucontrol->value.enumerated.item[0]);
2413
2414 return 0;
2415}
2416
2417static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
2418 struct snd_ctl_elem_value *ucontrol)
2419{
2420 int idx = mi2s_get_port_idx(kcontrol);
2421
2422 if (idx < 0)
2423 return idx;
2424
2425 pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
2426 idx, mi2s_rx_cfg[idx].channels);
2427 ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
2428
2429 return 0;
2430}
2431
2432static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
2433 struct snd_ctl_elem_value *ucontrol)
2434{
2435 int idx = mi2s_get_port_idx(kcontrol);
2436
2437 if (idx < 0)
2438 return idx;
2439
2440 mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
2441 pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
2442 idx, mi2s_rx_cfg[idx].channels);
2443
2444 return 1;
2445}
2446
2447static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
2448 struct snd_ctl_elem_value *ucontrol)
2449{
2450 int idx = mi2s_get_port_idx(kcontrol);
2451
2452 if (idx < 0)
2453 return idx;
2454
2455 pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
2456 idx, mi2s_tx_cfg[idx].channels);
2457 ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
2458
2459 return 0;
2460}
2461
2462static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
2463 struct snd_ctl_elem_value *ucontrol)
2464{
2465 int idx = mi2s_get_port_idx(kcontrol);
2466
2467 if (idx < 0)
2468 return idx;
2469
2470 mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
2471 pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
2472 idx, mi2s_tx_cfg[idx].channels);
2473
2474 return 1;
2475}
2476
2477static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
2478 struct snd_ctl_elem_value *ucontrol)
2479{
2480 int idx = mi2s_get_port_idx(kcontrol);
2481
2482 if (idx < 0)
2483 return idx;
2484
2485 ucontrol->value.enumerated.item[0] =
2486 mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
2487
2488 pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
2489 idx, mi2s_rx_cfg[idx].bit_format,
2490 ucontrol->value.enumerated.item[0]);
2491
2492 return 0;
2493}
2494
2495static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
2496 struct snd_ctl_elem_value *ucontrol)
2497{
2498 int idx = mi2s_get_port_idx(kcontrol);
2499
2500 if (idx < 0)
2501 return idx;
2502
2503 mi2s_rx_cfg[idx].bit_format =
2504 mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
2505
2506 pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
2507 idx, mi2s_rx_cfg[idx].bit_format,
2508 ucontrol->value.enumerated.item[0]);
2509
2510 return 0;
2511}
2512
2513static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
2514 struct snd_ctl_elem_value *ucontrol)
2515{
2516 int idx = mi2s_get_port_idx(kcontrol);
2517
2518 if (idx < 0)
2519 return idx;
2520
2521 ucontrol->value.enumerated.item[0] =
2522 mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
2523
2524 pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
2525 idx, mi2s_tx_cfg[idx].bit_format,
2526 ucontrol->value.enumerated.item[0]);
2527
2528 return 0;
2529}
2530
2531static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
2532 struct snd_ctl_elem_value *ucontrol)
2533{
2534 int idx = mi2s_get_port_idx(kcontrol);
2535
2536 if (idx < 0)
2537 return idx;
2538
2539 mi2s_tx_cfg[idx].bit_format =
2540 mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
2541
2542 pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
2543 idx, mi2s_tx_cfg[idx].bit_format,
2544 ucontrol->value.enumerated.item[0]);
2545
2546 return 0;
2547}
2548
2549static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
2550 struct snd_ctl_elem_value *ucontrol)
2551{
2552 int idx = aux_pcm_get_port_idx(kcontrol);
2553
2554 if (idx < 0)
2555 return idx;
2556
2557 ucontrol->value.enumerated.item[0] =
2558 mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
2559
2560 pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
2561 idx, aux_pcm_rx_cfg[idx].bit_format,
2562 ucontrol->value.enumerated.item[0]);
2563
2564 return 0;
2565}
2566
2567static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
2568 struct snd_ctl_elem_value *ucontrol)
2569{
2570 int idx = aux_pcm_get_port_idx(kcontrol);
2571
2572 if (idx < 0)
2573 return idx;
2574
2575 aux_pcm_rx_cfg[idx].bit_format =
2576 mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
2577
2578 pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
2579 idx, aux_pcm_rx_cfg[idx].bit_format,
2580 ucontrol->value.enumerated.item[0]);
2581
2582 return 0;
2583}
2584
2585static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
2586 struct snd_ctl_elem_value *ucontrol)
2587{
2588 int idx = aux_pcm_get_port_idx(kcontrol);
2589
2590 if (idx < 0)
2591 return idx;
2592
2593 ucontrol->value.enumerated.item[0] =
2594 mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
2595
2596 pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
2597 idx, aux_pcm_tx_cfg[idx].bit_format,
2598 ucontrol->value.enumerated.item[0]);
2599
2600 return 0;
2601}
2602
2603static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
2604 struct snd_ctl_elem_value *ucontrol)
2605{
2606 int idx = aux_pcm_get_port_idx(kcontrol);
2607
2608 if (idx < 0)
2609 return idx;
2610
2611 aux_pcm_tx_cfg[idx].bit_format =
2612 mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
2613
2614 pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
2615 idx, aux_pcm_tx_cfg[idx].bit_format,
2616 ucontrol->value.enumerated.item[0]);
2617
2618 return 0;
2619}
2620
2621static const struct snd_kcontrol_new msm_snd_controls[] = {
2622 SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
2623 usb_audio_rx_ch_get, usb_audio_rx_ch_put),
2624 SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
2625 usb_audio_tx_ch_get, usb_audio_tx_ch_put),
2626 SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
2627 ext_disp_rx_ch_get, ext_disp_rx_ch_put),
2628 SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
2629 proxy_rx_ch_get, proxy_rx_ch_put),
2630 SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
2631 usb_audio_rx_format_get, usb_audio_rx_format_put),
2632 SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
2633 usb_audio_tx_format_get, usb_audio_tx_format_put),
2634 SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
2635 ext_disp_rx_format_get, ext_disp_rx_format_put),
2636 SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
2637 usb_audio_rx_sample_rate_get,
2638 usb_audio_rx_sample_rate_put),
2639 SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
2640 usb_audio_tx_sample_rate_get,
2641 usb_audio_tx_sample_rate_put),
2642 SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
2643 ext_disp_rx_sample_rate_get,
2644 ext_disp_rx_sample_rate_put),
2645 SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
2646 tdm_rx_sample_rate_get,
2647 tdm_rx_sample_rate_put),
2648 SOC_ENUM_EXT("PRI_TDM_RX_1 SampleRate", tdm_rx_sample_rate,
2649 tdm_rx_sample_rate_get,
2650 tdm_rx_sample_rate_put),
2651 SOC_ENUM_EXT("PRI_TDM_RX_2 SampleRate", tdm_rx_sample_rate,
2652 tdm_rx_sample_rate_get,
2653 tdm_rx_sample_rate_put),
2654 SOC_ENUM_EXT("PRI_TDM_RX_3 SampleRate", tdm_rx_sample_rate,
2655 tdm_rx_sample_rate_get,
2656 tdm_rx_sample_rate_put),
2657 SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
2658 tdm_tx_sample_rate_get,
2659 tdm_tx_sample_rate_put),
2660 SOC_ENUM_EXT("PRI_TDM_TX_1 SampleRate", tdm_tx_sample_rate,
2661 tdm_tx_sample_rate_get,
2662 tdm_tx_sample_rate_put),
2663 SOC_ENUM_EXT("PRI_TDM_TX_2 SampleRate", tdm_tx_sample_rate,
2664 tdm_tx_sample_rate_get,
2665 tdm_tx_sample_rate_put),
2666 SOC_ENUM_EXT("PRI_TDM_TX_3 SampleRate", tdm_tx_sample_rate,
2667 tdm_tx_sample_rate_get,
2668 tdm_tx_sample_rate_put),
2669 SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
2670 tdm_rx_format_get,
2671 tdm_rx_format_put),
2672 SOC_ENUM_EXT("PRI_TDM_RX_1 Format", tdm_rx_format,
2673 tdm_rx_format_get,
2674 tdm_rx_format_put),
2675 SOC_ENUM_EXT("PRI_TDM_RX_2 Format", tdm_rx_format,
2676 tdm_rx_format_get,
2677 tdm_rx_format_put),
2678 SOC_ENUM_EXT("PRI_TDM_RX_3 Format", tdm_rx_format,
2679 tdm_rx_format_get,
2680 tdm_rx_format_put),
2681 SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
2682 tdm_tx_format_get,
2683 tdm_tx_format_put),
2684 SOC_ENUM_EXT("PRI_TDM_TX_1 Format", tdm_tx_format,
2685 tdm_tx_format_get,
2686 tdm_tx_format_put),
2687 SOC_ENUM_EXT("PRI_TDM_TX_2 Format", tdm_tx_format,
2688 tdm_tx_format_get,
2689 tdm_tx_format_put),
2690 SOC_ENUM_EXT("PRI_TDM_TX_3 Format", tdm_tx_format,
2691 tdm_tx_format_get,
2692 tdm_tx_format_put),
2693 SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
2694 tdm_rx_ch_get,
2695 tdm_rx_ch_put),
2696 SOC_ENUM_EXT("PRI_TDM_RX_1 Channels", tdm_rx_chs,
2697 tdm_rx_ch_get,
2698 tdm_rx_ch_put),
2699 SOC_ENUM_EXT("PRI_TDM_RX_2 Channels", tdm_rx_chs,
2700 tdm_rx_ch_get,
2701 tdm_rx_ch_put),
2702 SOC_ENUM_EXT("PRI_TDM_RX_3 Channels", tdm_rx_chs,
2703 tdm_rx_ch_get,
2704 tdm_rx_ch_put),
2705 SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
2706 tdm_tx_ch_get,
2707 tdm_tx_ch_put),
2708 SOC_ENUM_EXT("PRI_TDM_TX_1 Channels", tdm_tx_chs,
2709 tdm_tx_ch_get,
2710 tdm_tx_ch_put),
2711 SOC_ENUM_EXT("PRI_TDM_TX_2 Channels", tdm_tx_chs,
2712 tdm_tx_ch_get,
2713 tdm_tx_ch_put),
2714 SOC_ENUM_EXT("PRI_TDM_TX_3 Channels", tdm_tx_chs,
2715 tdm_tx_ch_get,
2716 tdm_tx_ch_put),
2717 SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
2718 tdm_rx_sample_rate_get,
2719 tdm_rx_sample_rate_put),
2720 SOC_ENUM_EXT("SEC_TDM_RX_1 SampleRate", tdm_rx_sample_rate,
2721 tdm_rx_sample_rate_get,
2722 tdm_rx_sample_rate_put),
2723 SOC_ENUM_EXT("SEC_TDM_RX_2 SampleRate", tdm_rx_sample_rate,
2724 tdm_rx_sample_rate_get,
2725 tdm_rx_sample_rate_put),
2726 SOC_ENUM_EXT("SEC_TDM_RX_3 SampleRate", tdm_rx_sample_rate,
2727 tdm_rx_sample_rate_get,
2728 tdm_rx_sample_rate_put),
2729 SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
2730 tdm_tx_sample_rate_get,
2731 tdm_tx_sample_rate_put),
2732 SOC_ENUM_EXT("SEC_TDM_TX_1 SampleRate", tdm_tx_sample_rate,
2733 tdm_tx_sample_rate_get,
2734 tdm_tx_sample_rate_put),
2735 SOC_ENUM_EXT("SEC_TDM_TX_2 SampleRate", tdm_tx_sample_rate,
2736 tdm_tx_sample_rate_get,
2737 tdm_tx_sample_rate_put),
2738 SOC_ENUM_EXT("SEC_TDM_TX_3 SampleRate", tdm_tx_sample_rate,
2739 tdm_tx_sample_rate_get,
2740 tdm_tx_sample_rate_put),
2741 SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
2742 tdm_rx_format_get,
2743 tdm_rx_format_put),
2744 SOC_ENUM_EXT("SEC_TDM_RX_1 Format", tdm_rx_format,
2745 tdm_rx_format_get,
2746 tdm_rx_format_put),
2747 SOC_ENUM_EXT("SEC_TDM_RX_2 Format", tdm_rx_format,
2748 tdm_rx_format_get,
2749 tdm_rx_format_put),
2750 SOC_ENUM_EXT("SEC_TDM_RX_3 Format", tdm_rx_format,
2751 tdm_rx_format_get,
2752 tdm_rx_format_put),
2753 SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
2754 tdm_tx_format_get,
2755 tdm_tx_format_put),
2756 SOC_ENUM_EXT("SEC_TDM_TX_1 Format", tdm_tx_format,
2757 tdm_tx_format_get,
2758 tdm_tx_format_put),
2759 SOC_ENUM_EXT("SEC_TDM_TX_2 Format", tdm_tx_format,
2760 tdm_tx_format_get,
2761 tdm_tx_format_put),
2762 SOC_ENUM_EXT("SEC_TDM_TX_3 Format", tdm_tx_format,
2763 tdm_tx_format_get,
2764 tdm_tx_format_put),
2765 SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
2766 tdm_rx_ch_get,
2767 tdm_rx_ch_put),
2768 SOC_ENUM_EXT("SEC_TDM_RX_1 Channels", tdm_rx_chs,
2769 tdm_rx_ch_get,
2770 tdm_rx_ch_put),
2771 SOC_ENUM_EXT("SEC_TDM_RX_2 Channels", tdm_rx_chs,
2772 tdm_rx_ch_get,
2773 tdm_rx_ch_put),
2774 SOC_ENUM_EXT("SEC_TDM_RX_3 Channels", tdm_rx_chs,
2775 tdm_rx_ch_get,
2776 tdm_rx_ch_put),
2777 SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
2778 tdm_tx_ch_get,
2779 tdm_tx_ch_put),
2780 SOC_ENUM_EXT("SEC_TDM_TX_1 Channels", tdm_tx_chs,
2781 tdm_tx_ch_get,
2782 tdm_tx_ch_put),
2783 SOC_ENUM_EXT("SEC_TDM_TX_2 Channels", tdm_tx_chs,
2784 tdm_tx_ch_get,
2785 tdm_tx_ch_put),
2786 SOC_ENUM_EXT("SEC_TDM_TX_3 Channels", tdm_tx_chs,
2787 tdm_tx_ch_get,
2788 tdm_tx_ch_put),
2789 SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
2790 tdm_rx_sample_rate_get,
2791 tdm_rx_sample_rate_put),
2792 SOC_ENUM_EXT("TERT_TDM_RX_1 SampleRate", tdm_rx_sample_rate,
2793 tdm_rx_sample_rate_get,
2794 tdm_rx_sample_rate_put),
2795 SOC_ENUM_EXT("TERT_TDM_RX_2 SampleRate", tdm_rx_sample_rate,
2796 tdm_rx_sample_rate_get,
2797 tdm_rx_sample_rate_put),
2798 SOC_ENUM_EXT("TERT_TDM_RX_3 SampleRate", tdm_rx_sample_rate,
2799 tdm_rx_sample_rate_get,
2800 tdm_rx_sample_rate_put),
2801 SOC_ENUM_EXT("TERT_TDM_RX_4 SampleRate", tdm_rx_sample_rate,
2802 tdm_rx_sample_rate_get,
2803 tdm_rx_sample_rate_put),
2804 SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
2805 tdm_tx_sample_rate_get,
2806 tdm_tx_sample_rate_put),
2807 SOC_ENUM_EXT("TERT_TDM_TX_1 SampleRate", tdm_tx_sample_rate,
2808 tdm_tx_sample_rate_get,
2809 tdm_tx_sample_rate_put),
2810 SOC_ENUM_EXT("TERT_TDM_TX_2 SampleRate", tdm_tx_sample_rate,
2811 tdm_tx_sample_rate_get,
2812 tdm_tx_sample_rate_put),
2813 SOC_ENUM_EXT("TERT_TDM_TX_3 SampleRate", tdm_tx_sample_rate,
2814 tdm_tx_sample_rate_get,
2815 tdm_tx_sample_rate_put),
2816 SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
2817 tdm_rx_format_get,
2818 tdm_rx_format_put),
2819 SOC_ENUM_EXT("TERT_TDM_RX_1 Format", tdm_rx_format,
2820 tdm_rx_format_get,
2821 tdm_rx_format_put),
2822 SOC_ENUM_EXT("TERT_TDM_RX_2 Format", tdm_rx_format,
2823 tdm_rx_format_get,
2824 tdm_rx_format_put),
2825 SOC_ENUM_EXT("TERT_TDM_RX_3 Format", tdm_rx_format,
2826 tdm_rx_format_get,
2827 tdm_rx_format_put),
2828 SOC_ENUM_EXT("TERT_TDM_RX_4 Format", tdm_rx_format,
2829 tdm_rx_format_get,
2830 tdm_rx_format_put),
2831 SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
2832 tdm_tx_format_get,
2833 tdm_tx_format_put),
2834 SOC_ENUM_EXT("TERT_TDM_TX_1 Format", tdm_tx_format,
2835 tdm_tx_format_get,
2836 tdm_tx_format_put),
2837 SOC_ENUM_EXT("TERT_TDM_TX_2 Format", tdm_tx_format,
2838 tdm_tx_format_get,
2839 tdm_tx_format_put),
2840 SOC_ENUM_EXT("TERT_TDM_TX_3 Format", tdm_tx_format,
2841 tdm_tx_format_get,
2842 tdm_tx_format_put),
2843 SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
2844 tdm_rx_ch_get,
2845 tdm_rx_ch_put),
2846 SOC_ENUM_EXT("TERT_TDM_RX_1 Channels", tdm_rx_chs,
2847 tdm_rx_ch_get,
2848 tdm_rx_ch_put),
2849 SOC_ENUM_EXT("TERT_TDM_RX_2 Channels", tdm_rx_chs,
2850 tdm_rx_ch_get,
2851 tdm_rx_ch_put),
2852 SOC_ENUM_EXT("TERT_TDM_RX_3 Channels", tdm_rx_chs,
2853 tdm_rx_ch_get,
2854 tdm_rx_ch_put),
2855 SOC_ENUM_EXT("TERT_TDM_RX_4 Channels", tdm_rx_chs,
2856 tdm_rx_ch_get,
2857 tdm_rx_ch_put),
2858 SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
2859 tdm_tx_ch_get,
2860 tdm_tx_ch_put),
2861 SOC_ENUM_EXT("TERT_TDM_TX_1 Channels", tdm_tx_chs,
2862 tdm_tx_ch_get,
2863 tdm_tx_ch_put),
2864 SOC_ENUM_EXT("TERT_TDM_TX_2 Channels", tdm_tx_chs,
2865 tdm_tx_ch_get,
2866 tdm_tx_ch_put),
2867 SOC_ENUM_EXT("TERT_TDM_TX_3 Channels", tdm_tx_chs,
2868 tdm_tx_ch_get,
2869 tdm_tx_ch_put),
2870 SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
2871 tdm_rx_sample_rate_get,
2872 tdm_rx_sample_rate_put),
2873 SOC_ENUM_EXT("QUAT_TDM_RX_1 SampleRate", tdm_rx_sample_rate,
2874 tdm_rx_sample_rate_get,
2875 tdm_rx_sample_rate_put),
2876 SOC_ENUM_EXT("QUAT_TDM_RX_2 SampleRate", tdm_rx_sample_rate,
2877 tdm_rx_sample_rate_get,
2878 tdm_rx_sample_rate_put),
2879 SOC_ENUM_EXT("QUAT_TDM_RX_3 SampleRate", tdm_rx_sample_rate,
2880 tdm_rx_sample_rate_get,
2881 tdm_rx_sample_rate_put),
2882 SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
2883 tdm_tx_sample_rate_get,
2884 tdm_tx_sample_rate_put),
2885 SOC_ENUM_EXT("QUAT_TDM_TX_1 SampleRate", tdm_tx_sample_rate,
2886 tdm_tx_sample_rate_get,
2887 tdm_tx_sample_rate_put),
2888 SOC_ENUM_EXT("QUAT_TDM_TX_2 SampleRate", tdm_tx_sample_rate,
2889 tdm_tx_sample_rate_get,
2890 tdm_tx_sample_rate_put),
2891 SOC_ENUM_EXT("QUAT_TDM_TX_3 SampleRate", tdm_tx_sample_rate,
2892 tdm_tx_sample_rate_get,
2893 tdm_tx_sample_rate_put),
2894 SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
2895 tdm_rx_format_get,
2896 tdm_rx_format_put),
2897 SOC_ENUM_EXT("QUAT_TDM_RX_1 Format", tdm_rx_format,
2898 tdm_rx_format_get,
2899 tdm_rx_format_put),
2900 SOC_ENUM_EXT("QUAT_TDM_RX_2 Format", tdm_rx_format,
2901 tdm_rx_format_get,
2902 tdm_rx_format_put),
2903 SOC_ENUM_EXT("QUAT_TDM_RX_3 Format", tdm_rx_format,
2904 tdm_rx_format_get,
2905 tdm_rx_format_put),
2906 SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
2907 tdm_tx_format_get,
2908 tdm_tx_format_put),
2909 SOC_ENUM_EXT("QUAT_TDM_TX_1 Format", tdm_tx_format,
2910 tdm_tx_format_get,
2911 tdm_tx_format_put),
2912 SOC_ENUM_EXT("QUAT_TDM_TX_2 Format", tdm_tx_format,
2913 tdm_tx_format_get,
2914 tdm_tx_format_put),
2915 SOC_ENUM_EXT("QUAT_TDM_TX_3 Format", tdm_tx_format,
2916 tdm_tx_format_get,
2917 tdm_tx_format_put),
2918 SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
2919 tdm_rx_ch_get,
2920 tdm_rx_ch_put),
2921 SOC_ENUM_EXT("QUAT_TDM_RX_1 Channels", tdm_rx_chs,
2922 tdm_rx_ch_get,
2923 tdm_rx_ch_put),
2924 SOC_ENUM_EXT("QUAT_TDM_RX_2 Channels", tdm_rx_chs,
2925 tdm_rx_ch_get,
2926 tdm_rx_ch_put),
2927 SOC_ENUM_EXT("QUAT_TDM_RX_3 Channels", tdm_rx_chs,
2928 tdm_rx_ch_get,
2929 tdm_rx_ch_put),
2930 SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
2931 tdm_tx_ch_get,
2932 tdm_tx_ch_put),
2933 SOC_ENUM_EXT("QUAT_TDM_TX_1 Channels", tdm_tx_chs,
2934 tdm_tx_ch_get,
2935 tdm_tx_ch_put),
2936 SOC_ENUM_EXT("QUAT_TDM_TX_2 Channels", tdm_tx_chs,
2937 tdm_tx_ch_get,
2938 tdm_tx_ch_put),
2939 SOC_ENUM_EXT("QUAT_TDM_TX_3 Channels", tdm_tx_chs,
2940 tdm_tx_ch_get,
2941 tdm_tx_ch_put),
2942 SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
2943 tdm_rx_sample_rate_get,
2944 tdm_rx_sample_rate_put),
2945 SOC_ENUM_EXT("QUIN_TDM_RX_1 SampleRate", tdm_rx_sample_rate,
2946 tdm_rx_sample_rate_get,
2947 tdm_rx_sample_rate_put),
2948 SOC_ENUM_EXT("QUIN_TDM_RX_2 SampleRate", tdm_rx_sample_rate,
2949 tdm_rx_sample_rate_get,
2950 tdm_rx_sample_rate_put),
2951 SOC_ENUM_EXT("QUIN_TDM_RX_3 SampleRate", tdm_rx_sample_rate,
2952 tdm_rx_sample_rate_get,
2953 tdm_rx_sample_rate_put),
2954 SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
2955 tdm_tx_sample_rate_get,
2956 tdm_tx_sample_rate_put),
2957 SOC_ENUM_EXT("QUIN_TDM_TX_1 SampleRate", tdm_tx_sample_rate,
2958 tdm_tx_sample_rate_get,
2959 tdm_tx_sample_rate_put),
2960 SOC_ENUM_EXT("QUIN_TDM_TX_2 SampleRate", tdm_tx_sample_rate,
2961 tdm_tx_sample_rate_get,
2962 tdm_tx_sample_rate_put),
2963 SOC_ENUM_EXT("QUIN_TDM_TX_3 SampleRate", tdm_tx_sample_rate,
2964 tdm_tx_sample_rate_get,
2965 tdm_tx_sample_rate_put),
2966 SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
2967 tdm_rx_format_get,
2968 tdm_rx_format_put),
2969 SOC_ENUM_EXT("QUIN_TDM_RX_1 Format", tdm_rx_format,
2970 tdm_rx_format_get,
2971 tdm_rx_format_put),
2972 SOC_ENUM_EXT("QUIN_TDM_RX_2 Format", tdm_rx_format,
2973 tdm_rx_format_get,
2974 tdm_rx_format_put),
2975 SOC_ENUM_EXT("QUIN_TDM_RX_3 Format", tdm_rx_format,
2976 tdm_rx_format_get,
2977 tdm_rx_format_put),
2978 SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
2979 tdm_tx_format_get,
2980 tdm_tx_format_put),
2981 SOC_ENUM_EXT("QUIN_TDM_TX_1 Format", tdm_tx_format,
2982 tdm_tx_format_get,
2983 tdm_tx_format_put),
2984 SOC_ENUM_EXT("QUIN_TDM_TX_2 Format", tdm_tx_format,
2985 tdm_tx_format_get,
2986 tdm_tx_format_put),
2987 SOC_ENUM_EXT("QUIN_TDM_TX_3 Format", tdm_tx_format,
2988 tdm_tx_format_get,
2989 tdm_tx_format_put),
2990 SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
2991 tdm_rx_ch_get,
2992 tdm_rx_ch_put),
2993 SOC_ENUM_EXT("QUIN_TDM_RX_1 Channels", tdm_rx_chs,
2994 tdm_rx_ch_get,
2995 tdm_rx_ch_put),
2996 SOC_ENUM_EXT("QUIN_TDM_RX_2 Channels", tdm_rx_chs,
2997 tdm_rx_ch_get,
2998 tdm_rx_ch_put),
2999 SOC_ENUM_EXT("QUIN_TDM_RX_3 Channels", tdm_rx_chs,
3000 tdm_rx_ch_get,
3001 tdm_rx_ch_put),
3002 SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
3003 tdm_tx_ch_get,
3004 tdm_tx_ch_put),
3005 SOC_ENUM_EXT("QUIN_TDM_TX_1 Channels", tdm_tx_chs,
3006 tdm_tx_ch_get,
3007 tdm_tx_ch_put),
3008 SOC_ENUM_EXT("QUIN_TDM_TX_2 Channels", tdm_tx_chs,
3009 tdm_tx_ch_get,
3010 tdm_tx_ch_put),
3011 SOC_ENUM_EXT("QUIN_TDM_TX_3 Channels", tdm_tx_chs,
3012 tdm_tx_ch_get,
3013 tdm_tx_ch_put),
3014 SOC_ENUM_EXT("PRI_TDM SlotNumber", tdm_slot_num,
3015 tdm_slot_num_get, tdm_slot_num_put),
3016 SOC_ENUM_EXT("PRI_TDM SlotWidth", tdm_slot_width,
3017 tdm_slot_width_get, tdm_slot_width_put),
3018 SOC_ENUM_EXT("SEC_TDM SlotNumber", tdm_slot_num,
3019 tdm_slot_num_get, tdm_slot_num_put),
3020 SOC_ENUM_EXT("SEC_TDM SlotWidth", tdm_slot_width,
3021 tdm_slot_width_get, tdm_slot_width_put),
3022 SOC_ENUM_EXT("TERT_TDM SlotNumber", tdm_slot_num,
3023 tdm_slot_num_get, tdm_slot_num_put),
3024 SOC_ENUM_EXT("TERT_TDM SlotWidth", tdm_slot_width,
3025 tdm_slot_width_get, tdm_slot_width_put),
3026 SOC_ENUM_EXT("QUAT_TDM SlotNumber", tdm_slot_num,
3027 tdm_slot_num_get, tdm_slot_num_put),
3028 SOC_ENUM_EXT("QUAT_TDM SlotWidth", tdm_slot_width,
3029 tdm_slot_width_get, tdm_slot_width_put),
3030 SOC_ENUM_EXT("QUIN_TDM SlotNumber", tdm_slot_num,
3031 tdm_slot_num_get, tdm_slot_num_put),
3032 SOC_ENUM_EXT("QUIN_TDM SlotWidth", tdm_slot_width,
3033 tdm_slot_width_get, tdm_slot_width_put),
3034 SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_0 SlotMapping",
3035 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3036 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3037 SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_1 SlotMapping",
3038 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3039 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3040 SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_2 SlotMapping",
3041 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3042 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3043 SOC_SINGLE_MULTI_EXT("PRI_TDM_RX_3 SlotMapping",
3044 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3045 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3046 SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_0 SlotMapping",
3047 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3048 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3049 SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_1 SlotMapping",
3050 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3051 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3052 SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_2 SlotMapping",
3053 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3054 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3055 SOC_SINGLE_MULTI_EXT("PRI_TDM_TX_3 SlotMapping",
3056 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3057 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3058 SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_0 SlotMapping",
3059 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3060 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3061 SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_1 SlotMapping",
3062 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3063 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3064 SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_2 SlotMapping",
3065 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3066 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3067 SOC_SINGLE_MULTI_EXT("SEC_TDM_RX_3 SlotMapping",
3068 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3069 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3070 SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_0 SlotMapping",
3071 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3072 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3073 SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_1 SlotMapping",
3074 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3075 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3076 SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_2 SlotMapping",
3077 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3078 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3079 SOC_SINGLE_MULTI_EXT("SEC_TDM_TX_3 SlotMapping",
3080 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3081 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3082 SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_0 SlotMapping",
3083 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3084 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3085 SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_1 SlotMapping",
3086 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3087 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3088 SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_2 SlotMapping",
3089 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3090 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3091 SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_3 SlotMapping",
3092 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3093 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3094 SOC_SINGLE_MULTI_EXT("TERT_TDM_RX_4 SlotMapping",
3095 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3096 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3097 SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_0 SlotMapping",
3098 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3099 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3100 SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_1 SlotMapping",
3101 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3102 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3103 SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_2 SlotMapping",
3104 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3105 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3106 SOC_SINGLE_MULTI_EXT("TERT_TDM_TX_3 SlotMapping",
3107 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3108 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3109 SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_0 SlotMapping",
3110 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3111 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3112 SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_1 SlotMapping",
3113 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3114 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3115 SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_2 SlotMapping",
3116 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3117 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3118 SOC_SINGLE_MULTI_EXT("QUAT_TDM_RX_3 SlotMapping",
3119 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3120 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3121 SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_0 SlotMapping",
3122 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3123 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3124 SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_1 SlotMapping",
3125 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3126 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3127 SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_2 SlotMapping",
3128 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3129 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3130 SOC_SINGLE_MULTI_EXT("QUAT_TDM_TX_3 SlotMapping",
3131 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3132 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3133 SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_0 SlotMapping",
3134 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3135 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3136 SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_1 SlotMapping",
3137 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3138 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3139 SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_2 SlotMapping",
3140 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3141 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3142 SOC_SINGLE_MULTI_EXT("QUIN_TDM_RX_3 SlotMapping",
3143 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3144 tdm_rx_slot_mapping_get, tdm_rx_slot_mapping_put),
3145 SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_0 SlotMapping",
3146 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3147 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3148 SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_1 SlotMapping",
3149 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3150 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3151 SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_2 SlotMapping",
3152 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3153 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3154 SOC_SINGLE_MULTI_EXT("QUIN_TDM_TX_3 SlotMapping",
3155 SND_SOC_NOPM, 0, 0xFFFF, 0, TDM_SLOT_OFFSET_MAX,
3156 tdm_tx_slot_mapping_get, tdm_tx_slot_mapping_put),
3157 SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
3158 aux_pcm_rx_sample_rate_get,
3159 aux_pcm_rx_sample_rate_put),
3160 SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
3161 aux_pcm_rx_sample_rate_get,
3162 aux_pcm_rx_sample_rate_put),
3163 SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
3164 aux_pcm_rx_sample_rate_get,
3165 aux_pcm_rx_sample_rate_put),
3166 SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
3167 aux_pcm_rx_sample_rate_get,
3168 aux_pcm_rx_sample_rate_put),
3169 SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
3170 aux_pcm_rx_sample_rate_get,
3171 aux_pcm_rx_sample_rate_put),
3172 SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
3173 aux_pcm_tx_sample_rate_get,
3174 aux_pcm_tx_sample_rate_put),
3175 SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
3176 aux_pcm_tx_sample_rate_get,
3177 aux_pcm_tx_sample_rate_put),
3178 SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
3179 aux_pcm_tx_sample_rate_get,
3180 aux_pcm_tx_sample_rate_put),
3181 SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
3182 aux_pcm_tx_sample_rate_get,
3183 aux_pcm_tx_sample_rate_put),
3184 SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
3185 aux_pcm_tx_sample_rate_get,
3186 aux_pcm_tx_sample_rate_put),
3187 SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
3188 mi2s_rx_sample_rate_get,
3189 mi2s_rx_sample_rate_put),
3190 SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
3191 mi2s_rx_sample_rate_get,
3192 mi2s_rx_sample_rate_put),
3193 SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
3194 mi2s_rx_sample_rate_get,
3195 mi2s_rx_sample_rate_put),
3196 SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
3197 mi2s_rx_sample_rate_get,
3198 mi2s_rx_sample_rate_put),
3199 SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
3200 mi2s_rx_sample_rate_get,
3201 mi2s_rx_sample_rate_put),
3202 SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
3203 mi2s_tx_sample_rate_get,
3204 mi2s_tx_sample_rate_put),
3205 SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
3206 mi2s_tx_sample_rate_get,
3207 mi2s_tx_sample_rate_put),
3208 SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
3209 mi2s_tx_sample_rate_get,
3210 mi2s_tx_sample_rate_put),
3211 SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
3212 mi2s_tx_sample_rate_get,
3213 mi2s_tx_sample_rate_put),
3214 SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
3215 mi2s_tx_sample_rate_get,
3216 mi2s_tx_sample_rate_put),
3217 SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
3218 msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
3219 SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
3220 msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
3221 SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
3222 msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
3223 SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
3224 msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
3225 SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
3226 msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
3227 SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
3228 msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
3229 SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
3230 msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
3231 SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
3232 msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
3233 SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
3234 msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
3235 SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
3236 msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
3237 SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
3238 msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
3239 SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
3240 msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
3241 SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
3242 msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
3243 SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
3244 msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
3245 SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
3246 msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
3247 SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
3248 msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
3249 SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
3250 msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
3251 SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
3252 msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
3253 SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
3254 msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
3255 SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
3256 msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
3257 SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
3258 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3259 SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
3260 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3261 SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
3262 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3263 SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
3264 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3265 SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
3266 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3267 SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
3268 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3269 SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
3270 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3271 SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
3272 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3273 SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
3274 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3275 SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
3276 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3277};
3278
3279static inline int param_is_mask(int p)
3280{
3281 return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
3282 (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
3283}
3284
3285static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
3286 int n)
3287{
3288 return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
3289}
3290
3291static void param_set_mask(struct snd_pcm_hw_params *p, int n,
3292 unsigned int bit)
3293{
3294 if (bit >= SNDRV_MASK_MAX)
3295 return;
3296 if (param_is_mask(n)) {
3297 struct snd_mask *m = param_to_mask(p, n);
3298
3299 m->bits[0] = 0;
3300 m->bits[1] = 0;
3301 m->bits[bit >> 5] |= (1 << (bit & 31));
3302 }
3303}
3304
3305static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
3306{
3307 int idx;
3308
3309 switch (be_id) {
3310 case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
3311 idx = DP_RX_IDX;
3312 break;
3313 default:
3314 pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
3315 idx = -EINVAL;
3316 break;
3317 }
3318
3319 return idx;
3320}
3321
3322static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
3323 struct snd_pcm_hw_params *params)
3324{
3325 struct snd_soc_dai_link *dai_link = rtd->dai_link;
3326 struct snd_interval *rate = hw_param_interval(params,
3327 SNDRV_PCM_HW_PARAM_RATE);
3328 struct snd_interval *channels = hw_param_interval(params,
3329 SNDRV_PCM_HW_PARAM_CHANNELS);
3330 int rc = 0;
3331 int idx;
3332
3333 pr_debug("%s: format = %d, rate = %d\n",
3334 __func__, params_format(params), params_rate(params));
3335
3336 switch (dai_link->id) {
3337 case MSM_BACKEND_DAI_USB_RX:
3338 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3339 usb_rx_cfg.bit_format);
3340 rate->min = rate->max = usb_rx_cfg.sample_rate;
3341 channels->min = channels->max = usb_rx_cfg.channels;
3342 break;
3343
3344 case MSM_BACKEND_DAI_USB_TX:
3345 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3346 usb_tx_cfg.bit_format);
3347 rate->min = rate->max = usb_tx_cfg.sample_rate;
3348 channels->min = channels->max = usb_tx_cfg.channels;
3349 break;
3350
3351 case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
3352 idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
3353 if (idx < 0) {
3354 pr_err("%s: Incorrect ext disp idx %d\n",
3355 __func__, idx);
3356 rc = idx;
3357 goto done;
3358 }
3359
3360 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3361 ext_disp_rx_cfg[idx].bit_format);
3362 rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
3363 channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
3364 break;
3365
3366 case MSM_BACKEND_DAI_AFE_PCM_RX:
3367 channels->min = channels->max = proxy_rx_cfg.channels;
3368 rate->min = rate->max = SAMPLING_RATE_48KHZ;
3369 break;
3370
3371 case MSM_BACKEND_DAI_PRI_TDM_RX_0:
3372 channels->min = channels->max =
3373 tdm_rx_cfg[TDM_PRI][TDM_0].channels;
3374 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3375 tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
3376 rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
3377 break;
3378
3379 case MSM_BACKEND_DAI_PRI_TDM_TX_0:
3380 channels->min = channels->max =
3381 tdm_tx_cfg[TDM_PRI][TDM_0].channels;
3382 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3383 tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
3384 rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
3385 break;
3386
3387 case MSM_BACKEND_DAI_SEC_TDM_RX_0:
3388 channels->min = channels->max =
3389 tdm_rx_cfg[TDM_SEC][TDM_0].channels;
3390 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3391 tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
3392 rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
3393 break;
3394
3395 case MSM_BACKEND_DAI_SEC_TDM_TX_0:
3396 channels->min = channels->max =
3397 tdm_tx_cfg[TDM_SEC][TDM_0].channels;
3398 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3399 tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
3400 rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
3401 break;
3402
3403 case MSM_BACKEND_DAI_TERT_TDM_RX_0:
3404 channels->min = channels->max =
3405 tdm_rx_cfg[TDM_TERT][TDM_0].channels;
3406 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3407 tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
3408 rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
3409 break;
3410
3411 case MSM_BACKEND_DAI_TERT_TDM_TX_0:
3412 channels->min = channels->max =
3413 tdm_tx_cfg[TDM_TERT][TDM_0].channels;
3414 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3415 tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
3416 rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
3417 break;
3418
3419 case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
3420 channels->min = channels->max =
3421 tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
3422 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3423 tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
3424 rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
3425 break;
3426
3427 case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
3428 channels->min = channels->max =
3429 tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
3430 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3431 tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
3432 rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
3433 break;
3434
3435 case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
3436 channels->min = channels->max =
3437 tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
3438 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3439 tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
3440 rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
3441 break;
3442
3443 case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
3444 channels->min = channels->max =
3445 tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
3446 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3447 tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
3448 rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
3449 break;
3450
3451
3452 case MSM_BACKEND_DAI_AUXPCM_RX:
3453 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3454 aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
3455 rate->min = rate->max =
3456 aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
3457 channels->min = channels->max =
3458 aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
3459 break;
3460
3461 case MSM_BACKEND_DAI_AUXPCM_TX:
3462 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3463 aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
3464 rate->min = rate->max =
3465 aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
3466 channels->min = channels->max =
3467 aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
3468 break;
3469
3470 case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
3471 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3472 aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
3473 rate->min = rate->max =
3474 aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
3475 channels->min = channels->max =
3476 aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
3477 break;
3478
3479 case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
3480 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3481 aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
3482 rate->min = rate->max =
3483 aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
3484 channels->min = channels->max =
3485 aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
3486 break;
3487
3488 case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
3489 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3490 aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
3491 rate->min = rate->max =
3492 aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
3493 channels->min = channels->max =
3494 aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
3495 break;
3496
3497 case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
3498 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3499 aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
3500 rate->min = rate->max =
3501 aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
3502 channels->min = channels->max =
3503 aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
3504 break;
3505
3506 case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
3507 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3508 aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
3509 rate->min = rate->max =
3510 aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
3511 channels->min = channels->max =
3512 aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
3513 break;
3514
3515 case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
3516 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3517 aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
3518 rate->min = rate->max =
3519 aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
3520 channels->min = channels->max =
3521 aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
3522 break;
3523
3524 case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
3525 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3526 aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
3527 rate->min = rate->max =
3528 aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
3529 channels->min = channels->max =
3530 aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
3531 break;
3532
3533 case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
3534 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3535 aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
3536 rate->min = rate->max =
3537 aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
3538 channels->min = channels->max =
3539 aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
3540 break;
3541
3542 case MSM_BACKEND_DAI_PRI_MI2S_RX:
3543 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3544 mi2s_rx_cfg[PRIM_MI2S].bit_format);
3545 rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
3546 channels->min = channels->max =
3547 mi2s_rx_cfg[PRIM_MI2S].channels;
3548 break;
3549
3550 case MSM_BACKEND_DAI_PRI_MI2S_TX:
3551 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3552 mi2s_tx_cfg[PRIM_MI2S].bit_format);
3553 rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
3554 channels->min = channels->max =
3555 mi2s_tx_cfg[PRIM_MI2S].channels;
3556 break;
3557
3558 case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
3559 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3560 mi2s_rx_cfg[SEC_MI2S].bit_format);
3561 rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
3562 channels->min = channels->max =
3563 mi2s_rx_cfg[SEC_MI2S].channels;
3564 break;
3565
3566 case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
3567 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3568 mi2s_tx_cfg[SEC_MI2S].bit_format);
3569 rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
3570 channels->min = channels->max =
3571 mi2s_tx_cfg[SEC_MI2S].channels;
3572 break;
3573
3574 case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
3575 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3576 mi2s_rx_cfg[TERT_MI2S].bit_format);
3577 rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
3578 channels->min = channels->max =
3579 mi2s_rx_cfg[TERT_MI2S].channels;
3580 break;
3581
3582 case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
3583 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3584 mi2s_tx_cfg[TERT_MI2S].bit_format);
3585 rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
3586 channels->min = channels->max =
3587 mi2s_tx_cfg[TERT_MI2S].channels;
3588 break;
3589
3590 case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
3591 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3592 mi2s_rx_cfg[QUAT_MI2S].bit_format);
3593 rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
3594 channels->min = channels->max =
3595 mi2s_rx_cfg[QUAT_MI2S].channels;
3596 break;
3597
3598 case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
3599 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3600 mi2s_tx_cfg[QUAT_MI2S].bit_format);
3601 rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
3602 channels->min = channels->max =
3603 mi2s_tx_cfg[QUAT_MI2S].channels;
3604 break;
3605
3606 case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
3607 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3608 mi2s_rx_cfg[QUIN_MI2S].bit_format);
3609 rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
3610 channels->min = channels->max =
3611 mi2s_rx_cfg[QUIN_MI2S].channels;
3612 break;
3613
3614 case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
3615 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3616 mi2s_tx_cfg[QUIN_MI2S].bit_format);
3617 rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
3618 channels->min = channels->max =
3619 mi2s_tx_cfg[QUIN_MI2S].channels;
3620 break;
3621
3622 default:
3623 rate->min = rate->max = SAMPLING_RATE_48KHZ;
3624 break;
3625 }
3626
3627done:
3628 return rc;
3629}
3630
3631static int msm_get_port_id(int be_id)
3632{
3633 int afe_port_id;
3634
3635 switch (be_id) {
3636 case MSM_BACKEND_DAI_PRI_MI2S_RX:
3637 afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
3638 break;
3639 case MSM_BACKEND_DAI_PRI_MI2S_TX:
3640 afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
3641 break;
3642 case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
3643 afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
3644 break;
3645 case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
3646 afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
3647 break;
3648 case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
3649 afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
3650 break;
3651 case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
3652 afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
3653 break;
3654 case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
3655 afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
3656 break;
3657 case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
3658 afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
3659 break;
3660 case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
3661 afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
3662 break;
3663 case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
3664 afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
3665 break;
3666 default:
3667 pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
3668 afe_port_id = -EINVAL;
3669 }
3670
3671 return afe_port_id;
3672}
3673
3674static u32 get_mi2s_bits_per_sample(u32 bit_format)
3675{
3676 u32 bit_per_sample;
3677
3678 switch (bit_format) {
3679 case SNDRV_PCM_FORMAT_S32_LE:
3680 case SNDRV_PCM_FORMAT_S24_3LE:
3681 case SNDRV_PCM_FORMAT_S24_LE:
3682 bit_per_sample = 32;
3683 break;
3684 case SNDRV_PCM_FORMAT_S16_LE:
3685 default:
3686 bit_per_sample = 16;
3687 break;
3688 }
3689
3690 return bit_per_sample;
3691}
3692
3693static void update_mi2s_clk_val(int dai_id, int stream)
3694{
3695 u32 bit_per_sample;
3696
3697 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
3698 bit_per_sample =
3699 get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
3700 mi2s_clk[dai_id].clk_freq_in_hz =
3701 mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
3702 } else {
3703 bit_per_sample =
3704 get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
3705 mi2s_clk[dai_id].clk_freq_in_hz =
3706 mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
3707 }
3708}
3709
3710static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
3711{
3712 int ret = 0;
3713 struct snd_soc_pcm_runtime *rtd = substream->private_data;
3714 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
3715 int port_id = 0;
3716 int index = cpu_dai->id;
3717
3718 port_id = msm_get_port_id(rtd->dai_link->id);
3719 if (port_id < 0) {
3720 dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
3721 ret = port_id;
3722 goto err;
3723 }
3724
3725 if (enable) {
3726 update_mi2s_clk_val(index, substream->stream);
3727 dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
3728 mi2s_clk[index].clk_freq_in_hz);
3729 }
3730
3731 mi2s_clk[index].enable = enable;
3732 ret = afe_set_lpass_clock_v2(port_id,
3733 &mi2s_clk[index]);
3734 if (ret < 0) {
3735 dev_err(rtd->card->dev,
3736 "%s: afe lpass clock failed for port 0x%x , err:%d\n",
3737 __func__, port_id, ret);
3738 goto err;
3739 }
3740
3741err:
3742 return ret;
3743}
3744
Rahul Sharma02bee732018-12-20 18:48:34 +05303745static int msm_set_pinctrl(struct msm_pinctrl_info *pinctrl_info,
3746 enum pinctrl_pin_state new_state)
3747{
3748 int ret = 0;
3749 int curr_state = 0;
3750
3751 if (pinctrl_info == NULL) {
Derek Chen7bb78312019-06-18 00:36:55 -07003752 pr_err("%s: pinctrl info is NULL\n", __func__);
Rahul Sharma02bee732018-12-20 18:48:34 +05303753 ret = -EINVAL;
3754 goto err;
3755 }
3756
3757 if (pinctrl_info->pinctrl == NULL) {
Derek Chen7bb78312019-06-18 00:36:55 -07003758 pr_err("%s: pinctrl handle is NULL\n", __func__);
Rahul Sharma02bee732018-12-20 18:48:34 +05303759 ret = -EINVAL;
3760 goto err;
3761 }
3762
3763 curr_state = pinctrl_info->curr_state;
3764 pinctrl_info->curr_state = new_state;
3765 pr_debug("%s: curr_state = %s new_state = %s\n", __func__,
3766 pin_states[curr_state], pin_states[pinctrl_info->curr_state]);
3767
3768 if (curr_state == pinctrl_info->curr_state) {
Derek Chen7bb78312019-06-18 00:36:55 -07003769 pr_debug("%s: pin already in same state\n", __func__);
Rahul Sharma02bee732018-12-20 18:48:34 +05303770 goto err;
3771 }
3772
Derek Chen7bb78312019-06-18 00:36:55 -07003773 if (curr_state != STATE_SLEEP &&
3774 pinctrl_info->curr_state != STATE_SLEEP) {
3775 pr_debug("%s: pin state is already active, cannot switch\n", __func__);
Rahul Sharma02bee732018-12-20 18:48:34 +05303776 ret = -EIO;
3777 goto err;
3778 }
3779
3780 switch (pinctrl_info->curr_state) {
Derek Chen7bb78312019-06-18 00:36:55 -07003781 case STATE_ACTIVE:
Rahul Sharma02bee732018-12-20 18:48:34 +05303782 ret = pinctrl_select_state(pinctrl_info->pinctrl,
Derek Chen7bb78312019-06-18 00:36:55 -07003783 pinctrl_info->active);
Rahul Sharma02bee732018-12-20 18:48:34 +05303784 if (ret) {
Derek Chen7bb78312019-06-18 00:36:55 -07003785 pr_err("%s: state select to active failed with %d\n",
Rahul Sharma02bee732018-12-20 18:48:34 +05303786 __func__, ret);
3787 ret = -EIO;
3788 goto err;
3789 }
3790 break;
Derek Chen7bb78312019-06-18 00:36:55 -07003791 case STATE_SLEEP:
Rahul Sharma02bee732018-12-20 18:48:34 +05303792 ret = pinctrl_select_state(pinctrl_info->pinctrl,
Derek Chen7bb78312019-06-18 00:36:55 -07003793 pinctrl_info->sleep);
Rahul Sharma02bee732018-12-20 18:48:34 +05303794 if (ret) {
Derek Chen7bb78312019-06-18 00:36:55 -07003795 pr_err("%s: state select to sleep failed with %d\n",
Rahul Sharma02bee732018-12-20 18:48:34 +05303796 __func__, ret);
3797 ret = -EIO;
3798 goto err;
3799 }
3800 break;
3801 default:
Derek Chen7bb78312019-06-18 00:36:55 -07003802 pr_err("%s: pin state is invalid\n", __func__);
Rahul Sharma02bee732018-12-20 18:48:34 +05303803 return -EINVAL;
3804 }
3805
3806err:
3807 return ret;
3808}
3809
3810static void msm_release_pinctrl(struct platform_device *pdev)
3811{
3812 struct snd_soc_card *card = platform_get_drvdata(pdev);
3813 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
Derek Chen7bb78312019-06-18 00:36:55 -07003814 struct msm_pinctrl_info *pinctrl_info = NULL;
3815 int i;
Rahul Sharma02bee732018-12-20 18:48:34 +05303816
Derek Chen7bb78312019-06-18 00:36:55 -07003817 for (i = TDM_PRI; i < TDM_INTERFACE_MAX; i++) {
3818 pinctrl_info = &pdata->pinctrl_info[i];
3819 if (pinctrl_info == NULL)
3820 continue;
3821 if (pinctrl_info->pinctrl) {
3822 devm_pinctrl_put(pinctrl_info->pinctrl);
3823 pinctrl_info->pinctrl = NULL;
3824 }
Rahul Sharma02bee732018-12-20 18:48:34 +05303825 }
3826}
3827
3828static int msm_get_pinctrl(struct platform_device *pdev)
3829{
3830 struct snd_soc_card *card = platform_get_drvdata(pdev);
3831 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
3832 struct msm_pinctrl_info *pinctrl_info = NULL;
Derek Chen7bb78312019-06-18 00:36:55 -07003833 struct pinctrl *pinctrl = NULL;
3834 int i, j;
3835 struct device_node *np = NULL;
3836 struct platform_device *pdev_np = NULL;
Rahul Sharma02bee732018-12-20 18:48:34 +05303837 int ret = 0;
3838
Derek Chen7bb78312019-06-18 00:36:55 -07003839 for (i = TDM_PRI; i < TDM_INTERFACE_MAX; i++) {
3840 np = of_parse_phandle(pdev->dev.of_node,
3841 tdm_gpio_phandle[i], 0);
3842 if (!np) {
3843 pr_debug("%s: device node %s is null\n",
3844 __func__, tdm_gpio_phandle[i]);
3845 continue;
3846 }
Rahul Sharma02bee732018-12-20 18:48:34 +05303847
Derek Chen7bb78312019-06-18 00:36:55 -07003848 pdev_np = of_find_device_by_node(np);
3849 if (!pdev_np) {
3850 pr_err("%s: platform device not found\n", __func__);
3851 continue;
3852 }
Rahul Sharma02bee732018-12-20 18:48:34 +05303853
Derek Chen7bb78312019-06-18 00:36:55 -07003854 pinctrl_info = &pdata->pinctrl_info[i];
3855 if (pinctrl_info == NULL) {
3856 pr_err("%s: pinctrl info is null\n", __func__);
3857 continue;
3858 }
Rahul Sharma02bee732018-12-20 18:48:34 +05303859
Derek Chen7bb78312019-06-18 00:36:55 -07003860 pinctrl = devm_pinctrl_get(&pdev_np->dev);
3861 if (IS_ERR_OR_NULL(pinctrl)) {
3862 pr_err("%s: fail to get pinctrl handle\n", __func__);
3863 goto err;
3864 }
3865 pinctrl_info->pinctrl = pinctrl;
Rahul Sharma02bee732018-12-20 18:48:34 +05303866
Derek Chen7bb78312019-06-18 00:36:55 -07003867 /* get all the states handles from Device Tree */
3868 pinctrl_info->sleep = pinctrl_lookup_state(pinctrl,
3869 "sleep");
3870 if (IS_ERR(pinctrl_info->sleep)) {
3871 pr_err("%s: could not get sleep pin state\n", __func__);
3872 goto err;
3873 }
3874 pinctrl_info->active = pinctrl_lookup_state(pinctrl,
3875 "default");
3876 if (IS_ERR(pinctrl_info->active)) {
3877 pr_err("%s: could not get active pin state\n",
3878 __func__);
3879 goto err;
3880 }
3881
3882 /* Reset the TLMM pins to a sleep state */
3883 ret = pinctrl_select_state(pinctrl_info->pinctrl,
3884 pinctrl_info->sleep);
3885 if (ret != 0) {
3886 pr_err("%s: set pin state to sleep failed with %d\n",
3887 __func__, ret);
3888 ret = -EIO;
3889 goto err;
3890 }
3891 pinctrl_info->curr_state = STATE_SLEEP;
3892 }
Rahul Sharma02bee732018-12-20 18:48:34 +05303893 return 0;
3894
3895err:
Derek Chen7bb78312019-06-18 00:36:55 -07003896 for (j = i; j >= 0; j--) {
3897 pinctrl_info = &pdata->pinctrl_info[j];
3898 if (pinctrl_info == NULL)
3899 continue;
3900 if (pinctrl_info->pinctrl) {
3901 devm_pinctrl_put(pinctrl_info->pinctrl);
3902 pinctrl_info->pinctrl = NULL;
3903 }
3904 }
Rahul Sharma02bee732018-12-20 18:48:34 +05303905 return -EINVAL;
3906}
Rahul Sharma02bee732018-12-20 18:48:34 +05303907
Derek Chen7bb78312019-06-18 00:36:55 -07003908static int msm_tdm_get_intf_idx(u16 id)
Rahul Sharma02bee732018-12-20 18:48:34 +05303909{
Derek Chen7bb78312019-06-18 00:36:55 -07003910 switch (id) {
3911 case AFE_PORT_ID_PRIMARY_TDM_RX:
3912 case AFE_PORT_ID_PRIMARY_TDM_RX_1:
3913 case AFE_PORT_ID_PRIMARY_TDM_RX_2:
3914 case AFE_PORT_ID_PRIMARY_TDM_RX_3:
3915 case AFE_PORT_ID_PRIMARY_TDM_RX_4:
3916 case AFE_PORT_ID_PRIMARY_TDM_RX_5:
3917 case AFE_PORT_ID_PRIMARY_TDM_RX_6:
3918 case AFE_PORT_ID_PRIMARY_TDM_RX_7:
3919 case AFE_PORT_ID_PRIMARY_TDM_TX:
3920 case AFE_PORT_ID_PRIMARY_TDM_TX_1:
3921 case AFE_PORT_ID_PRIMARY_TDM_TX_2:
3922 case AFE_PORT_ID_PRIMARY_TDM_TX_3:
3923 case AFE_PORT_ID_PRIMARY_TDM_TX_4:
3924 case AFE_PORT_ID_PRIMARY_TDM_TX_5:
3925 case AFE_PORT_ID_PRIMARY_TDM_TX_6:
3926 case AFE_PORT_ID_PRIMARY_TDM_TX_7:
3927 return TDM_PRI;
3928 case AFE_PORT_ID_SECONDARY_TDM_RX:
3929 case AFE_PORT_ID_SECONDARY_TDM_RX_1:
3930 case AFE_PORT_ID_SECONDARY_TDM_RX_2:
3931 case AFE_PORT_ID_SECONDARY_TDM_RX_3:
3932 case AFE_PORT_ID_SECONDARY_TDM_RX_4:
3933 case AFE_PORT_ID_SECONDARY_TDM_RX_5:
3934 case AFE_PORT_ID_SECONDARY_TDM_RX_6:
3935 case AFE_PORT_ID_SECONDARY_TDM_RX_7:
3936 case AFE_PORT_ID_SECONDARY_TDM_TX:
3937 case AFE_PORT_ID_SECONDARY_TDM_TX_1:
3938 case AFE_PORT_ID_SECONDARY_TDM_TX_2:
3939 case AFE_PORT_ID_SECONDARY_TDM_TX_3:
3940 case AFE_PORT_ID_SECONDARY_TDM_TX_4:
3941 case AFE_PORT_ID_SECONDARY_TDM_TX_5:
3942 case AFE_PORT_ID_SECONDARY_TDM_TX_6:
3943 case AFE_PORT_ID_SECONDARY_TDM_TX_7:
3944 return TDM_SEC;
3945 case AFE_PORT_ID_TERTIARY_TDM_RX:
3946 case AFE_PORT_ID_TERTIARY_TDM_RX_1:
3947 case AFE_PORT_ID_TERTIARY_TDM_RX_2:
3948 case AFE_PORT_ID_TERTIARY_TDM_RX_3:
3949 case AFE_PORT_ID_TERTIARY_TDM_RX_4:
3950 case AFE_PORT_ID_TERTIARY_TDM_RX_5:
3951 case AFE_PORT_ID_TERTIARY_TDM_RX_6:
3952 case AFE_PORT_ID_TERTIARY_TDM_RX_7:
3953 case AFE_PORT_ID_TERTIARY_TDM_TX:
3954 case AFE_PORT_ID_TERTIARY_TDM_TX_1:
3955 case AFE_PORT_ID_TERTIARY_TDM_TX_2:
3956 case AFE_PORT_ID_TERTIARY_TDM_TX_3:
3957 case AFE_PORT_ID_TERTIARY_TDM_TX_4:
3958 case AFE_PORT_ID_TERTIARY_TDM_TX_5:
3959 case AFE_PORT_ID_TERTIARY_TDM_TX_6:
3960 case AFE_PORT_ID_TERTIARY_TDM_TX_7:
3961 return TDM_TERT;
3962 case AFE_PORT_ID_QUATERNARY_TDM_RX:
3963 case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
3964 case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
3965 case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
3966 case AFE_PORT_ID_QUATERNARY_TDM_RX_4:
3967 case AFE_PORT_ID_QUATERNARY_TDM_RX_5:
3968 case AFE_PORT_ID_QUATERNARY_TDM_RX_6:
3969 case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
3970 case AFE_PORT_ID_QUATERNARY_TDM_TX:
3971 case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
3972 case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
3973 case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
3974 case AFE_PORT_ID_QUATERNARY_TDM_TX_4:
3975 case AFE_PORT_ID_QUATERNARY_TDM_TX_5:
3976 case AFE_PORT_ID_QUATERNARY_TDM_TX_6:
3977 case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
3978 return TDM_QUAT;
3979 case AFE_PORT_ID_QUINARY_TDM_RX:
3980 case AFE_PORT_ID_QUINARY_TDM_RX_1:
3981 case AFE_PORT_ID_QUINARY_TDM_RX_2:
3982 case AFE_PORT_ID_QUINARY_TDM_RX_3:
3983 case AFE_PORT_ID_QUINARY_TDM_RX_4:
3984 case AFE_PORT_ID_QUINARY_TDM_RX_5:
3985 case AFE_PORT_ID_QUINARY_TDM_RX_6:
3986 case AFE_PORT_ID_QUINARY_TDM_RX_7:
3987 case AFE_PORT_ID_QUINARY_TDM_TX:
3988 case AFE_PORT_ID_QUINARY_TDM_TX_1:
3989 case AFE_PORT_ID_QUINARY_TDM_TX_2:
3990 case AFE_PORT_ID_QUINARY_TDM_TX_3:
3991 case AFE_PORT_ID_QUINARY_TDM_TX_4:
3992 case AFE_PORT_ID_QUINARY_TDM_TX_5:
3993 case AFE_PORT_ID_QUINARY_TDM_TX_6:
3994 case AFE_PORT_ID_QUINARY_TDM_TX_7:
3995 return TDM_QUIN;
3996 default: return -EINVAL;
3997 }
Rahul Sharma02bee732018-12-20 18:48:34 +05303998}
3999
Rahul Sharma02bee732018-12-20 18:48:34 +05304000static int msm_tdm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
4001 struct snd_pcm_hw_params *params)
4002{
4003 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
4004 struct snd_interval *rate = hw_param_interval(params,
4005 SNDRV_PCM_HW_PARAM_RATE);
4006 struct snd_interval *channels = hw_param_interval(params,
4007 SNDRV_PCM_HW_PARAM_CHANNELS);
4008
4009 switch (cpu_dai->id) {
4010 case AFE_PORT_ID_PRIMARY_TDM_RX:
4011 channels->min = channels->max =
4012 tdm_rx_cfg[TDM_PRI][TDM_0].channels;
4013 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4014 tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
4015 rate->min = rate->max =
4016 tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
4017 break;
4018 case AFE_PORT_ID_PRIMARY_TDM_RX_1:
4019 channels->min = channels->max =
4020 tdm_rx_cfg[TDM_PRI][TDM_1].channels;
4021 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4022 tdm_rx_cfg[TDM_PRI][TDM_1].bit_format);
4023 rate->min = rate->max =
4024 tdm_rx_cfg[TDM_PRI][TDM_1].sample_rate;
4025 break;
4026 case AFE_PORT_ID_PRIMARY_TDM_RX_2:
4027 channels->min = channels->max =
4028 tdm_rx_cfg[TDM_PRI][TDM_2].channels;
4029 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4030 tdm_rx_cfg[TDM_PRI][TDM_2].bit_format);
4031 rate->min = rate->max =
4032 tdm_rx_cfg[TDM_PRI][TDM_2].sample_rate;
4033 break;
4034 case AFE_PORT_ID_PRIMARY_TDM_RX_3:
4035 channels->min = channels->max =
4036 tdm_rx_cfg[TDM_PRI][TDM_3].channels;
4037 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4038 tdm_rx_cfg[TDM_PRI][TDM_3].bit_format);
4039 rate->min = rate->max =
4040 tdm_rx_cfg[TDM_PRI][TDM_3].sample_rate;
4041 break;
4042 case AFE_PORT_ID_PRIMARY_TDM_TX:
4043 channels->min = channels->max =
4044 tdm_tx_cfg[TDM_PRI][TDM_0].channels;
4045 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4046 tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
4047 rate->min = rate->max =
4048 tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
4049 break;
4050 case AFE_PORT_ID_PRIMARY_TDM_TX_1:
4051 channels->min = channels->max =
4052 tdm_tx_cfg[TDM_PRI][TDM_1].channels;
4053 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4054 tdm_tx_cfg[TDM_PRI][TDM_1].bit_format);
4055 rate->min = rate->max =
4056 tdm_tx_cfg[TDM_PRI][TDM_1].sample_rate;
4057 break;
4058 case AFE_PORT_ID_PRIMARY_TDM_TX_2:
4059 channels->min = channels->max =
4060 tdm_tx_cfg[TDM_PRI][TDM_2].channels;
4061 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4062 tdm_tx_cfg[TDM_PRI][TDM_2].bit_format);
4063 rate->min = rate->max =
4064 tdm_tx_cfg[TDM_PRI][TDM_2].sample_rate;
4065 break;
4066 case AFE_PORT_ID_PRIMARY_TDM_TX_3:
4067 channels->min = channels->max =
4068 tdm_tx_cfg[TDM_PRI][TDM_3].channels;
4069 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4070 tdm_tx_cfg[TDM_PRI][TDM_3].bit_format);
4071 rate->min = rate->max =
4072 tdm_tx_cfg[TDM_PRI][TDM_3].sample_rate;
4073 break;
4074 case AFE_PORT_ID_SECONDARY_TDM_RX:
4075 channels->min = channels->max =
4076 tdm_rx_cfg[TDM_SEC][TDM_0].channels;
4077 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4078 tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
4079 rate->min = rate->max =
4080 tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
4081 break;
4082 case AFE_PORT_ID_SECONDARY_TDM_RX_1:
4083 channels->min = channels->max =
4084 tdm_rx_cfg[TDM_SEC][TDM_1].channels;
4085 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4086 tdm_rx_cfg[TDM_SEC][TDM_1].bit_format);
4087 rate->min = rate->max =
4088 tdm_rx_cfg[TDM_SEC][TDM_1].sample_rate;
4089 break;
4090 case AFE_PORT_ID_SECONDARY_TDM_RX_2:
4091 channels->min = channels->max =
4092 tdm_rx_cfg[TDM_SEC][TDM_2].channels;
4093 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4094 tdm_rx_cfg[TDM_SEC][TDM_2].bit_format);
4095 rate->min = rate->max =
4096 tdm_rx_cfg[TDM_SEC][TDM_2].sample_rate;
4097 break;
4098 case AFE_PORT_ID_SECONDARY_TDM_RX_3:
4099 channels->min = channels->max =
4100 tdm_rx_cfg[TDM_SEC][TDM_3].channels;
4101 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4102 tdm_rx_cfg[TDM_SEC][TDM_3].bit_format);
4103 rate->min = rate->max =
4104 tdm_rx_cfg[TDM_SEC][TDM_3].sample_rate;
4105 break;
Derek Chen0150b832019-06-05 18:46:29 +05304106 case AFE_PORT_ID_SECONDARY_TDM_RX_7:
4107 channels->min = channels->max =
4108 tdm_rx_cfg[TDM_SEC][TDM_7].channels;
4109 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4110 tdm_rx_cfg[TDM_SEC][TDM_7].bit_format);
4111 rate->min = rate->max =
4112 tdm_rx_cfg[TDM_SEC][TDM_7].sample_rate;
4113 break;
Rahul Sharma02bee732018-12-20 18:48:34 +05304114 case AFE_PORT_ID_SECONDARY_TDM_TX:
4115 channels->min = channels->max =
4116 tdm_tx_cfg[TDM_SEC][TDM_0].channels;
4117 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4118 tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
4119 rate->min = rate->max =
4120 tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
4121 break;
4122 case AFE_PORT_ID_SECONDARY_TDM_TX_1:
4123 channels->min = channels->max =
4124 tdm_tx_cfg[TDM_SEC][TDM_1].channels;
4125 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4126 tdm_tx_cfg[TDM_SEC][TDM_1].bit_format);
4127 rate->min = rate->max =
4128 tdm_tx_cfg[TDM_SEC][TDM_1].sample_rate;
4129 break;
4130 case AFE_PORT_ID_SECONDARY_TDM_TX_2:
4131 channels->min = channels->max =
4132 tdm_tx_cfg[TDM_SEC][TDM_2].channels;
4133 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4134 tdm_tx_cfg[TDM_SEC][TDM_2].bit_format);
4135 rate->min = rate->max =
4136 tdm_tx_cfg[TDM_SEC][TDM_2].sample_rate;
4137 break;
4138 case AFE_PORT_ID_SECONDARY_TDM_TX_3:
4139 channels->min = channels->max =
4140 tdm_tx_cfg[TDM_SEC][TDM_3].channels;
4141 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4142 tdm_tx_cfg[TDM_SEC][TDM_3].bit_format);
4143 rate->min = rate->max =
4144 tdm_tx_cfg[TDM_SEC][TDM_3].sample_rate;
4145 break;
4146 case AFE_PORT_ID_TERTIARY_TDM_RX:
4147 channels->min = channels->max =
4148 tdm_rx_cfg[TDM_TERT][TDM_0].channels;
4149 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4150 tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
4151 rate->min = rate->max =
4152 tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
4153 break;
4154 case AFE_PORT_ID_TERTIARY_TDM_RX_1:
4155 channels->min = channels->max =
4156 tdm_rx_cfg[TDM_TERT][TDM_1].channels;
4157 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4158 tdm_rx_cfg[TDM_TERT][TDM_1].bit_format);
4159 rate->min = rate->max =
4160 tdm_rx_cfg[TDM_TERT][TDM_1].sample_rate;
4161 break;
4162 case AFE_PORT_ID_TERTIARY_TDM_RX_2:
4163 channels->min = channels->max =
4164 tdm_rx_cfg[TDM_TERT][TDM_2].channels;
4165 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4166 tdm_rx_cfg[TDM_TERT][TDM_2].bit_format);
4167 rate->min = rate->max =
4168 tdm_rx_cfg[TDM_TERT][TDM_2].sample_rate;
4169 break;
4170 case AFE_PORT_ID_TERTIARY_TDM_RX_3:
4171 channels->min = channels->max =
4172 tdm_rx_cfg[TDM_TERT][TDM_3].channels;
4173 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4174 tdm_rx_cfg[TDM_TERT][TDM_3].bit_format);
4175 rate->min = rate->max =
4176 tdm_rx_cfg[TDM_TERT][TDM_3].sample_rate;
4177 break;
4178 case AFE_PORT_ID_TERTIARY_TDM_RX_4:
4179 channels->min = channels->max =
4180 tdm_rx_cfg[TDM_TERT][TDM_4].channels;
4181 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4182 tdm_rx_cfg[TDM_TERT][TDM_4].bit_format);
4183 rate->min = rate->max =
4184 tdm_rx_cfg[TDM_TERT][TDM_4].sample_rate;
4185 break;
4186 case AFE_PORT_ID_TERTIARY_TDM_TX:
4187 channels->min = channels->max =
4188 tdm_tx_cfg[TDM_TERT][TDM_0].channels;
4189 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4190 tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
4191 rate->min = rate->max =
4192 tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
4193 break;
4194 case AFE_PORT_ID_TERTIARY_TDM_TX_1:
4195 channels->min = channels->max =
4196 tdm_tx_cfg[TDM_TERT][TDM_1].channels;
4197 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4198 tdm_tx_cfg[TDM_TERT][TDM_1].bit_format);
4199 rate->min = rate->max =
4200 tdm_tx_cfg[TDM_TERT][TDM_1].sample_rate;
4201 break;
4202 case AFE_PORT_ID_TERTIARY_TDM_TX_2:
4203 channels->min = channels->max =
4204 tdm_tx_cfg[TDM_TERT][TDM_2].channels;
4205 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4206 tdm_tx_cfg[TDM_TERT][TDM_2].bit_format);
4207 rate->min = rate->max =
4208 tdm_tx_cfg[TDM_TERT][TDM_2].sample_rate;
4209 break;
4210 case AFE_PORT_ID_TERTIARY_TDM_TX_3:
4211 channels->min = channels->max =
4212 tdm_tx_cfg[TDM_TERT][TDM_3].channels;
4213 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4214 tdm_tx_cfg[TDM_TERT][TDM_3].bit_format);
4215 rate->min = rate->max =
4216 tdm_tx_cfg[TDM_TERT][TDM_3].sample_rate;
4217 break;
Derek Chen0150b832019-06-05 18:46:29 +05304218 case AFE_PORT_ID_TERTIARY_TDM_TX_7:
4219 channels->min = channels->max =
4220 tdm_tx_cfg[TDM_TERT][TDM_7].channels;
4221 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4222 tdm_tx_cfg[TDM_TERT][TDM_7].bit_format);
4223 rate->min = rate->max =
4224 tdm_tx_cfg[TDM_TERT][TDM_7].sample_rate;
4225 break;
Rahul Sharma02bee732018-12-20 18:48:34 +05304226 case AFE_PORT_ID_QUATERNARY_TDM_RX:
4227 channels->min = channels->max =
4228 tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
4229 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4230 tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
4231 rate->min = rate->max =
4232 tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
4233 break;
4234 case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
4235 channels->min = channels->max =
4236 tdm_rx_cfg[TDM_QUAT][TDM_1].channels;
4237 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4238 tdm_rx_cfg[TDM_QUAT][TDM_1].bit_format);
4239 rate->min = rate->max =
4240 tdm_rx_cfg[TDM_QUAT][TDM_1].sample_rate;
4241 break;
4242 case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
4243 channels->min = channels->max =
4244 tdm_rx_cfg[TDM_QUAT][TDM_2].channels;
4245 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4246 tdm_rx_cfg[TDM_QUAT][TDM_2].bit_format);
4247 rate->min = rate->max =
4248 tdm_rx_cfg[TDM_QUAT][TDM_2].sample_rate;
4249 break;
4250 case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
4251 channels->min = channels->max =
4252 tdm_rx_cfg[TDM_QUAT][TDM_3].channels;
4253 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4254 tdm_rx_cfg[TDM_QUAT][TDM_3].bit_format);
4255 rate->min = rate->max =
4256 tdm_rx_cfg[TDM_QUAT][TDM_3].sample_rate;
4257 break;
Derek Chen0150b832019-06-05 18:46:29 +05304258 case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
4259 channels->min = channels->max =
4260 tdm_rx_cfg[TDM_QUAT][TDM_7].channels;
4261 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4262 tdm_rx_cfg[TDM_QUAT][TDM_7].bit_format);
4263 rate->min = rate->max =
4264 tdm_rx_cfg[TDM_QUAT][TDM_7].sample_rate;
4265 break;
Rahul Sharma02bee732018-12-20 18:48:34 +05304266 case AFE_PORT_ID_QUATERNARY_TDM_TX:
4267 channels->min = channels->max =
4268 tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
4269 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4270 tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
4271 rate->min = rate->max =
4272 tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
4273 break;
4274 case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
4275 channels->min = channels->max =
4276 tdm_tx_cfg[TDM_QUAT][TDM_1].channels;
4277 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4278 tdm_tx_cfg[TDM_QUAT][TDM_1].bit_format);
4279 rate->min = rate->max =
4280 tdm_tx_cfg[TDM_QUAT][TDM_1].sample_rate;
4281 break;
4282 case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
4283 channels->min = channels->max =
4284 tdm_tx_cfg[TDM_QUAT][TDM_2].channels;
4285 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4286 tdm_tx_cfg[TDM_QUAT][TDM_2].bit_format);
4287 rate->min = rate->max =
4288 tdm_tx_cfg[TDM_QUAT][TDM_2].sample_rate;
4289 break;
4290 case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
4291 channels->min = channels->max =
4292 tdm_tx_cfg[TDM_QUAT][TDM_3].channels;
4293 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4294 tdm_tx_cfg[TDM_QUAT][TDM_3].bit_format);
4295 rate->min = rate->max =
4296 tdm_tx_cfg[TDM_QUAT][TDM_3].sample_rate;
4297 break;
Derek Chen0150b832019-06-05 18:46:29 +05304298 case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
4299 channels->min = channels->max =
4300 tdm_tx_cfg[TDM_QUAT][TDM_7].channels;
4301 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4302 tdm_tx_cfg[TDM_QUAT][TDM_7].bit_format);
4303 rate->min = rate->max =
4304 tdm_tx_cfg[TDM_QUAT][TDM_7].sample_rate;
4305 break;
Rahul Sharma02bee732018-12-20 18:48:34 +05304306 case AFE_PORT_ID_QUINARY_TDM_RX:
4307 channels->min = channels->max =
4308 tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
4309 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4310 tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
4311 rate->min = rate->max =
4312 tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
4313 break;
4314 case AFE_PORT_ID_QUINARY_TDM_RX_1:
4315 channels->min = channels->max =
4316 tdm_rx_cfg[TDM_QUIN][TDM_1].channels;
4317 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4318 tdm_rx_cfg[TDM_QUIN][TDM_1].bit_format);
4319 rate->min = rate->max =
4320 tdm_rx_cfg[TDM_QUIN][TDM_1].sample_rate;
4321 break;
4322 case AFE_PORT_ID_QUINARY_TDM_RX_2:
4323 channels->min = channels->max =
4324 tdm_rx_cfg[TDM_QUIN][TDM_2].channels;
4325 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4326 tdm_rx_cfg[TDM_QUIN][TDM_2].bit_format);
4327 rate->min = rate->max =
4328 tdm_rx_cfg[TDM_QUIN][TDM_2].sample_rate;
4329 break;
4330 case AFE_PORT_ID_QUINARY_TDM_RX_3:
4331 channels->min = channels->max =
4332 tdm_rx_cfg[TDM_QUIN][TDM_3].channels;
4333 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4334 tdm_rx_cfg[TDM_QUIN][TDM_3].bit_format);
4335 rate->min = rate->max =
4336 tdm_rx_cfg[TDM_QUIN][TDM_3].sample_rate;
4337 break;
4338 case AFE_PORT_ID_QUINARY_TDM_TX:
4339 channels->min = channels->max =
4340 tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
4341 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4342 tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
4343 rate->min = rate->max =
4344 tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
4345 break;
4346 case AFE_PORT_ID_QUINARY_TDM_TX_1:
4347 channels->min = channels->max =
4348 tdm_tx_cfg[TDM_QUIN][TDM_1].channels;
4349 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4350 tdm_tx_cfg[TDM_QUIN][TDM_1].bit_format);
4351 rate->min = rate->max =
4352 tdm_tx_cfg[TDM_QUIN][TDM_1].sample_rate;
4353 break;
4354 case AFE_PORT_ID_QUINARY_TDM_TX_2:
4355 channels->min = channels->max =
4356 tdm_tx_cfg[TDM_QUIN][TDM_2].channels;
4357 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4358 tdm_tx_cfg[TDM_QUIN][TDM_2].bit_format);
4359 rate->min = rate->max =
4360 tdm_tx_cfg[TDM_QUIN][TDM_2].sample_rate;
4361 break;
4362 case AFE_PORT_ID_QUINARY_TDM_TX_3:
4363 channels->min = channels->max =
4364 tdm_tx_cfg[TDM_QUIN][TDM_3].channels;
4365 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
4366 tdm_tx_cfg[TDM_QUIN][TDM_3].bit_format);
4367 rate->min = rate->max =
4368 tdm_tx_cfg[TDM_QUIN][TDM_3].sample_rate;
4369 break;
4370 default:
4371 pr_err("%s: dai id 0x%x not supported\n",
4372 __func__, cpu_dai->id);
4373 return -EINVAL;
4374 }
4375
4376 pr_debug("%s: dai id = 0x%x channels = %d rate = %d format = 0x%x\n",
4377 __func__, cpu_dai->id, channels->max, rate->max,
4378 params_format(params));
4379
4380 return 0;
4381}
4382
4383static unsigned int tdm_param_set_slot_mask(int slots)
4384{
4385 unsigned int slot_mask = 0;
4386 int i = 0;
4387
4388 if ((slots <= 0) || (slots > 32)) {
4389 pr_err("%s: invalid slot number %d\n", __func__, slots);
4390 return -EINVAL;
4391 }
4392
4393 for (i = 0; i < slots ; i++)
4394 slot_mask |= 1 << i;
4395 return slot_mask;
4396}
4397
4398static int sa6155_tdm_snd_hw_params(struct snd_pcm_substream *substream,
4399 struct snd_pcm_hw_params *params)
4400{
4401 struct snd_soc_pcm_runtime *rtd = substream->private_data;
4402 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
4403 int ret = 0;
4404 int channels, slot_width, slots, rate, format;
4405 unsigned int slot_mask;
4406 unsigned int *slot_offset;
4407 int offset_channels = 0;
4408 int i;
4409 int clk_freq;
4410
4411 pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
4412
4413 channels = params_channels(params);
4414 if (channels < 1 || channels > 32) {
4415 pr_err("%s: invalid param channels %d\n",
4416 __func__, channels);
4417 return -EINVAL;
4418 }
4419
4420 format = params_format(params);
4421 if (format != SNDRV_PCM_FORMAT_S32_LE &&
4422 format != SNDRV_PCM_FORMAT_S24_LE &&
4423 format != SNDRV_PCM_FORMAT_S16_LE) {
4424 /*
4425 * Up to 8 channel HW configuration should
4426 * use 32 bit slot width for max support of
4427 * stream bit width. (slot_width > bit_width)
4428 */
4429 pr_err("%s: invalid param format 0x%x\n",
4430 __func__, format);
4431 return -EINVAL;
4432 }
4433
4434 switch (cpu_dai->id) {
4435 case AFE_PORT_ID_PRIMARY_TDM_RX:
4436 slots = tdm_slot[TDM_PRI].num;
4437 slot_width = tdm_slot[TDM_PRI].width;
4438 slot_offset = tdm_rx_slot_offset[TDM_PRI][TDM_0];
4439 break;
4440 case AFE_PORT_ID_PRIMARY_TDM_RX_1:
4441 slots = tdm_slot[TDM_PRI].num;
4442 slot_width = tdm_slot[TDM_PRI].width;
4443 slot_offset = tdm_rx_slot_offset[TDM_PRI][TDM_1];
4444 break;
4445 case AFE_PORT_ID_PRIMARY_TDM_RX_2:
4446 slots = tdm_slot[TDM_PRI].num;
4447 slot_width = tdm_slot[TDM_PRI].width;
4448 slot_offset = tdm_rx_slot_offset[TDM_PRI][TDM_2];
4449 break;
4450 case AFE_PORT_ID_PRIMARY_TDM_RX_3:
4451 slots = tdm_slot[TDM_PRI].num;
4452 slot_width = tdm_slot[TDM_PRI].width;
4453 slot_offset = tdm_rx_slot_offset[TDM_PRI][TDM_3];
4454 break;
4455 case AFE_PORT_ID_PRIMARY_TDM_TX:
4456 slots = tdm_slot[TDM_PRI].num;
4457 slot_width = tdm_slot[TDM_PRI].width;
4458 slot_offset = tdm_tx_slot_offset[TDM_PRI][TDM_0];
4459 break;
4460 case AFE_PORT_ID_PRIMARY_TDM_TX_1:
4461 slots = tdm_slot[TDM_PRI].num;
4462 slot_width = tdm_slot[TDM_PRI].width;
4463 slot_offset = tdm_tx_slot_offset[TDM_PRI][TDM_1];
4464 break;
4465 case AFE_PORT_ID_PRIMARY_TDM_TX_2:
4466 slots = tdm_slot[TDM_PRI].num;
4467 slot_width = tdm_slot[TDM_PRI].width;
4468 slot_offset = tdm_tx_slot_offset[TDM_PRI][TDM_2];
4469 break;
4470 case AFE_PORT_ID_PRIMARY_TDM_TX_3:
4471 slots = tdm_slot[TDM_PRI].num;
4472 slot_width = tdm_slot[TDM_PRI].width;
4473 slot_offset = tdm_tx_slot_offset[TDM_PRI][TDM_3];
4474 break;
4475 case AFE_PORT_ID_SECONDARY_TDM_RX:
4476 slots = tdm_slot[TDM_SEC].num;
4477 slot_width = tdm_slot[TDM_SEC].width;
4478 slot_offset = tdm_rx_slot_offset[TDM_SEC][TDM_0];
4479 break;
4480 case AFE_PORT_ID_SECONDARY_TDM_RX_1:
4481 slots = tdm_slot[TDM_SEC].num;
4482 slot_width = tdm_slot[TDM_SEC].width;
4483 slot_offset = tdm_rx_slot_offset[TDM_SEC][TDM_1];
4484 break;
4485 case AFE_PORT_ID_SECONDARY_TDM_RX_2:
4486 slots = tdm_slot[TDM_SEC].num;
4487 slot_width = tdm_slot[TDM_SEC].width;
4488 slot_offset = tdm_rx_slot_offset[TDM_SEC][TDM_2];
4489 break;
4490 case AFE_PORT_ID_SECONDARY_TDM_RX_3:
4491 slots = tdm_slot[TDM_SEC].num;
4492 slot_width = tdm_slot[TDM_SEC].width;
4493 slot_offset = tdm_rx_slot_offset[TDM_SEC][TDM_3];
4494 break;
Derek Chen0150b832019-06-05 18:46:29 +05304495 case AFE_PORT_ID_SECONDARY_TDM_RX_7:
4496 slots = tdm_slot[TDM_SEC].num;
4497 slot_width = tdm_slot[TDM_SEC].width;
4498 slot_offset = tdm_rx_slot_offset[TDM_SEC][TDM_7];
4499 break;
Rahul Sharma02bee732018-12-20 18:48:34 +05304500 case AFE_PORT_ID_SECONDARY_TDM_TX:
4501 slots = tdm_slot[TDM_SEC].num;
4502 slot_width = tdm_slot[TDM_SEC].width;
4503 slot_offset = tdm_tx_slot_offset[TDM_SEC][TDM_0];
4504 break;
4505 case AFE_PORT_ID_SECONDARY_TDM_TX_1:
4506 slots = tdm_slot[TDM_SEC].num;
4507 slot_width = tdm_slot[TDM_SEC].width;
4508 slot_offset = tdm_tx_slot_offset[TDM_SEC][TDM_1];
4509 break;
4510 case AFE_PORT_ID_SECONDARY_TDM_TX_2:
4511 slots = tdm_slot[TDM_SEC].num;
4512 slot_width = tdm_slot[TDM_SEC].width;
4513 slot_offset = tdm_tx_slot_offset[TDM_SEC][TDM_2];
4514 break;
4515 case AFE_PORT_ID_SECONDARY_TDM_TX_3:
4516 slots = tdm_slot[TDM_SEC].num;
4517 slot_width = tdm_slot[TDM_SEC].width;
4518 slot_offset = tdm_tx_slot_offset[TDM_SEC][TDM_3];
4519 break;
4520 case AFE_PORT_ID_TERTIARY_TDM_RX:
4521 slots = tdm_slot[TDM_TERT].num;
4522 slot_width = tdm_slot[TDM_TERT].width;
4523 slot_offset = tdm_rx_slot_offset[TDM_TERT][TDM_0];
4524 break;
4525 case AFE_PORT_ID_TERTIARY_TDM_RX_1:
4526 slots = tdm_slot[TDM_TERT].num;
4527 slot_width = tdm_slot[TDM_TERT].width;
4528 slot_offset = tdm_rx_slot_offset[TDM_TERT][TDM_1];
4529 break;
4530 case AFE_PORT_ID_TERTIARY_TDM_RX_2:
4531 slots = tdm_slot[TDM_TERT].num;
4532 slot_width = tdm_slot[TDM_TERT].width;
4533 slot_offset = tdm_rx_slot_offset[TDM_TERT][TDM_2];
4534 break;
4535 case AFE_PORT_ID_TERTIARY_TDM_RX_3:
4536 slots = tdm_slot[TDM_TERT].num;
4537 slot_width = tdm_slot[TDM_TERT].width;
4538 slot_offset = tdm_rx_slot_offset[TDM_TERT][TDM_3];
4539 break;
4540 case AFE_PORT_ID_TERTIARY_TDM_RX_4:
4541 slots = tdm_slot[TDM_TERT].num;
4542 slot_width = tdm_slot[TDM_TERT].width;
4543 slot_offset = tdm_rx_slot_offset[TDM_TERT][TDM_4];
4544 break;
4545 case AFE_PORT_ID_TERTIARY_TDM_TX:
4546 slots = tdm_slot[TDM_TERT].num;
4547 slot_width = tdm_slot[TDM_TERT].width;
4548 slot_offset = tdm_tx_slot_offset[TDM_TERT][TDM_0];
4549 break;
4550 case AFE_PORT_ID_TERTIARY_TDM_TX_1:
4551 slots = tdm_slot[TDM_TERT].num;
4552 slot_width = tdm_slot[TDM_TERT].width;
4553 slot_offset = tdm_tx_slot_offset[TDM_TERT][TDM_1];
4554 break;
4555 case AFE_PORT_ID_TERTIARY_TDM_TX_2:
4556 slots = tdm_slot[TDM_TERT].num;
4557 slot_width = tdm_slot[TDM_TERT].width;
4558 slot_offset = tdm_tx_slot_offset[TDM_TERT][TDM_2];
4559 break;
4560 case AFE_PORT_ID_TERTIARY_TDM_TX_3:
4561 slots = tdm_slot[TDM_TERT].num;
4562 slot_width = tdm_slot[TDM_TERT].width;
4563 slot_offset = tdm_tx_slot_offset[TDM_TERT][TDM_3];
4564 break;
Derek Chen0150b832019-06-05 18:46:29 +05304565 case AFE_PORT_ID_TERTIARY_TDM_TX_7:
4566 slots = tdm_slot[TDM_TERT].num;
4567 slot_width = tdm_slot[TDM_TERT].width;
4568 slot_offset = tdm_tx_slot_offset[TDM_TERT][TDM_7];
4569 break;
Rahul Sharma02bee732018-12-20 18:48:34 +05304570 case AFE_PORT_ID_QUATERNARY_TDM_RX:
4571 slots = tdm_slot[TDM_QUAT].num;
4572 slot_width = tdm_slot[TDM_QUAT].width;
4573 slot_offset = tdm_rx_slot_offset[TDM_QUAT][TDM_0];
4574 break;
4575 case AFE_PORT_ID_QUATERNARY_TDM_RX_1:
4576 slots = tdm_slot[TDM_QUAT].num;
4577 slot_width = tdm_slot[TDM_QUAT].width;
4578 slot_offset = tdm_rx_slot_offset[TDM_QUAT][TDM_1];
4579 break;
4580 case AFE_PORT_ID_QUATERNARY_TDM_RX_2:
4581 slots = tdm_slot[TDM_QUAT].num;
4582 slot_width = tdm_slot[TDM_QUAT].width;
4583 slot_offset = tdm_rx_slot_offset[TDM_QUAT][TDM_2];
4584 break;
4585 case AFE_PORT_ID_QUATERNARY_TDM_RX_3:
4586 slots = tdm_slot[TDM_QUAT].num;
4587 slot_width = tdm_slot[TDM_QUAT].width;
4588 slot_offset = tdm_rx_slot_offset[TDM_QUAT][TDM_3];
4589 break;
Derek Chen0150b832019-06-05 18:46:29 +05304590 case AFE_PORT_ID_QUATERNARY_TDM_RX_7:
4591 slots = tdm_slot[TDM_QUAT].num;
4592 slot_width = tdm_slot[TDM_QUAT].width;
4593 slot_offset = tdm_rx_slot_offset[TDM_QUAT][TDM_7];
4594 break;
Rahul Sharma02bee732018-12-20 18:48:34 +05304595 case AFE_PORT_ID_QUATERNARY_TDM_TX:
4596 slots = tdm_slot[TDM_QUAT].num;
4597 slot_width = tdm_slot[TDM_QUAT].width;
4598 slot_offset = tdm_tx_slot_offset[TDM_QUAT][TDM_0];
4599 break;
4600 case AFE_PORT_ID_QUATERNARY_TDM_TX_1:
4601 slots = tdm_slot[TDM_QUAT].num;
4602 slot_width = tdm_slot[TDM_QUAT].width;
4603 slot_offset = tdm_tx_slot_offset[TDM_QUAT][TDM_1];
4604 break;
4605 case AFE_PORT_ID_QUATERNARY_TDM_TX_2:
4606 slots = tdm_slot[TDM_QUAT].num;
4607 slot_width = tdm_slot[TDM_QUAT].width;
4608 slot_offset = tdm_tx_slot_offset[TDM_QUAT][TDM_2];
4609 break;
4610 case AFE_PORT_ID_QUATERNARY_TDM_TX_3:
4611 slots = tdm_slot[TDM_QUAT].num;
4612 slot_width = tdm_slot[TDM_QUAT].width;
4613 slot_offset = tdm_tx_slot_offset[TDM_QUAT][TDM_3];
4614 break;
Derek Chen0150b832019-06-05 18:46:29 +05304615 case AFE_PORT_ID_QUATERNARY_TDM_TX_7:
4616 slots = tdm_slot[TDM_QUAT].num;
4617 slot_width = tdm_slot[TDM_QUAT].width;
4618 slot_offset = tdm_tx_slot_offset[TDM_QUAT][TDM_7];
4619 break;
Rahul Sharma02bee732018-12-20 18:48:34 +05304620 case AFE_PORT_ID_QUINARY_TDM_RX:
4621 slots = tdm_slot[TDM_QUIN].num;
4622 slot_width = tdm_slot[TDM_QUIN].width;
4623 slot_offset = tdm_rx_slot_offset[TDM_QUIN][TDM_0];
4624 break;
4625 case AFE_PORT_ID_QUINARY_TDM_RX_1:
4626 slots = tdm_slot[TDM_QUIN].num;
4627 slot_width = tdm_slot[TDM_QUIN].width;
4628 slot_offset = tdm_rx_slot_offset[TDM_QUIN][TDM_1];
4629 break;
4630 case AFE_PORT_ID_QUINARY_TDM_RX_2:
4631 slots = tdm_slot[TDM_QUIN].num;
4632 slot_width = tdm_slot[TDM_QUIN].width;
4633 slot_offset = tdm_rx_slot_offset[TDM_QUIN][TDM_2];
4634 break;
4635 case AFE_PORT_ID_QUINARY_TDM_RX_3:
4636 slots = tdm_slot[TDM_QUIN].num;
4637 slot_width = tdm_slot[TDM_QUIN].width;
4638 slot_offset = tdm_rx_slot_offset[TDM_QUIN][TDM_3];
4639 break;
4640 case AFE_PORT_ID_QUINARY_TDM_TX:
4641 slots = tdm_slot[TDM_QUIN].num;
4642 slot_width = tdm_slot[TDM_QUIN].width;
4643 slot_offset = tdm_tx_slot_offset[TDM_QUIN][TDM_0];
4644 break;
4645 case AFE_PORT_ID_QUINARY_TDM_TX_1:
4646 slots = tdm_slot[TDM_QUIN].num;
4647 slot_width = tdm_slot[TDM_QUIN].width;
4648 slot_offset = tdm_tx_slot_offset[TDM_QUIN][TDM_1];
4649 break;
4650 case AFE_PORT_ID_QUINARY_TDM_TX_2:
4651 slots = tdm_slot[TDM_QUIN].num;
4652 slot_width = tdm_slot[TDM_QUIN].width;
4653 slot_offset = tdm_tx_slot_offset[TDM_QUIN][TDM_2];
4654 break;
4655 case AFE_PORT_ID_QUINARY_TDM_TX_3:
4656 slots = tdm_slot[TDM_QUIN].num;
4657 slot_width = tdm_slot[TDM_QUIN].width;
4658 slot_offset = tdm_tx_slot_offset[TDM_QUIN][TDM_3];
4659 break;
4660 default:
4661 pr_err("%s: dai id 0x%x not supported\n",
4662 __func__, cpu_dai->id);
4663 return -EINVAL;
4664 }
4665
4666 for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
4667 if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID)
4668 offset_channels++;
4669 else
4670 break;
4671 }
4672
4673 if (offset_channels == 0) {
4674 pr_err("%s: invalid offset_channels %d\n",
4675 __func__, offset_channels);
4676 return -EINVAL;
4677 }
4678
4679 if (channels > offset_channels) {
4680 pr_err("%s: channels %d exceed offset_channels %d\n",
4681 __func__, channels, offset_channels);
4682 return -EINVAL;
4683 }
4684
4685 slot_mask = tdm_param_set_slot_mask(slots);
4686 if (!slot_mask) {
4687 pr_err("%s: invalid slot_mask 0x%x\n",
4688 __func__, slot_mask);
4689 return -EINVAL;
4690 }
4691
4692 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
4693 ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
4694 slots, slot_width);
4695 if (ret < 0) {
4696 pr_err("%s: failed to set tdm slot, err:%d\n",
4697 __func__, ret);
4698 goto end;
4699 }
4700
4701 ret = snd_soc_dai_set_channel_map(cpu_dai,
4702 0, NULL, channels, slot_offset);
4703 if (ret < 0) {
4704 pr_err("%s: failed to set channel map, err:%d\n",
4705 __func__, ret);
4706 goto end;
4707 }
4708 } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
4709 ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
4710 slots, slot_width);
4711 if (ret < 0) {
4712 pr_err("%s: failed to set tdm slot, err:%d\n",
4713 __func__, ret);
4714 goto end;
4715 }
4716
4717 ret = snd_soc_dai_set_channel_map(cpu_dai,
4718 channels, slot_offset, 0, NULL);
4719 if (ret < 0) {
4720 pr_err("%s: failed to set channel map, err:%d\n",
4721 __func__, ret);
4722 goto end;
4723 }
4724 } else {
4725 ret = -EINVAL;
4726 pr_err("%s: invalid use case, err:%d\n",
4727 __func__, ret);
4728 goto end;
4729 }
4730
4731 rate = params_rate(params);
4732 clk_freq = rate * slot_width * slots;
4733 ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
4734 if (ret < 0)
4735 pr_err("%s: failed to set tdm clk, err:%d\n",
4736 __func__, ret);
4737
4738end:
4739 return ret;
4740}
4741
4742static int sa6155_tdm_snd_startup(struct snd_pcm_substream *substream)
4743{
4744 int ret = 0;
4745 struct snd_soc_pcm_runtime *rtd = substream->private_data;
4746 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
4747 struct snd_soc_card *card = rtd->card;
4748 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
Derek Chen7bb78312019-06-18 00:36:55 -07004749 struct msm_pinctrl_info *pinctrl_info = NULL;
4750 struct tdm_conf *intf_conf = NULL;
4751 int ret_pinctrl = 0;
4752 int index;
Rahul Sharma02bee732018-12-20 18:48:34 +05304753
Derek Chen7bb78312019-06-18 00:36:55 -07004754 pr_debug("%s: substream = %s, stream = %d, dai name = %s, dai id = %d\n",
4755 __func__, substream->name, substream->stream,
4756 cpu_dai->name, cpu_dai->id);
4757
4758 index = msm_tdm_get_intf_idx(cpu_dai->id);
4759 if (index < 0) {
4760 ret = -EINVAL;
4761 pr_err("%s: CPU DAI id (%d) out of range\n",
4762 __func__, cpu_dai->id);
4763 goto err;
Rahul Sharma02bee732018-12-20 18:48:34 +05304764 }
4765
Derek Chen7bb78312019-06-18 00:36:55 -07004766 /*
4767 * Mutex protection in case the same TDM
4768 * interface using for both TX and RX so
4769 * that the same clock won't be enable twice.
4770 */
4771 intf_conf = &pdata->tdm_intf_conf[index];
4772 mutex_lock(&intf_conf->lock);
4773 if (++intf_conf->ref_cnt == 1) {
4774 pinctrl_info = &pdata->pinctrl_info[index];
4775 ret_pinctrl = msm_set_pinctrl(pinctrl_info,
4776 STATE_ACTIVE);
4777 if (ret_pinctrl)
4778 pr_err("%s: TDM TLMM pinctrl set failed with %d\n",
4779 __func__, ret_pinctrl);
4780 }
4781 mutex_unlock(&intf_conf->lock);
4782
4783err:
Rahul Sharma02bee732018-12-20 18:48:34 +05304784 return ret;
4785}
4786
4787static void sa6155_tdm_snd_shutdown(struct snd_pcm_substream *substream)
4788{
Rahul Sharma02bee732018-12-20 18:48:34 +05304789 struct snd_soc_pcm_runtime *rtd = substream->private_data;
4790 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
4791 struct snd_soc_card *card = rtd->card;
4792 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
Derek Chen7bb78312019-06-18 00:36:55 -07004793 struct msm_pinctrl_info *pinctrl_info = NULL;
4794 struct tdm_conf *intf_conf = NULL;
4795 int ret_pinctrl = 0;
4796 int index;
Rahul Sharma02bee732018-12-20 18:48:34 +05304797
Derek Chen7bb78312019-06-18 00:36:55 -07004798 pr_debug("%s: substream = %s, stream = %d\n", __func__,
4799 substream->name, substream->stream);
4800
4801 index = msm_tdm_get_intf_idx(cpu_dai->id);
4802 if (index < 0) {
4803 pr_err("%s: CPU DAI id (%d) out of range\n",
4804 __func__, cpu_dai->id);
4805 return;
Rahul Sharma02bee732018-12-20 18:48:34 +05304806 }
Derek Chen7bb78312019-06-18 00:36:55 -07004807
4808 intf_conf = &pdata->tdm_intf_conf[index];
4809 mutex_lock(&intf_conf->lock);
4810 if (--intf_conf->ref_cnt == 0) {
4811 pinctrl_info = &pdata->pinctrl_info[index];
4812 ret_pinctrl = msm_set_pinctrl(pinctrl_info,
4813 STATE_SLEEP);
4814 if (ret_pinctrl)
4815 pr_err("%s: TDM TLMM pinctrl set failed with %d\n",
4816 __func__, ret_pinctrl);
4817 }
4818 mutex_unlock(&intf_conf->lock);
Rahul Sharma02bee732018-12-20 18:48:34 +05304819}
4820
4821static struct snd_soc_ops sa6155_tdm_be_ops = {
4822 .hw_params = sa6155_tdm_snd_hw_params,
4823 .startup = sa6155_tdm_snd_startup,
4824 .shutdown = sa6155_tdm_snd_shutdown
4825};
4826
4827static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
4828{
4829 cpumask_t mask;
4830
4831 if (pm_qos_request_active(&substream->latency_pm_qos_req))
4832 pm_qos_remove_request(&substream->latency_pm_qos_req);
4833
4834 cpumask_clear(&mask);
4835 cpumask_set_cpu(1, &mask); /* affine to core 1 */
4836 cpumask_set_cpu(2, &mask); /* affine to core 2 */
4837 cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
4838
4839 substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
4840
4841 pm_qos_add_request(&substream->latency_pm_qos_req,
4842 PM_QOS_CPU_DMA_LATENCY,
4843 MSM_LL_QOS_VALUE);
4844 return 0;
4845}
4846
4847static struct snd_soc_ops msm_fe_qos_ops = {
4848 .prepare = msm_fe_qos_prepare,
4849};
4850
4851static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
4852{
4853 int ret = 0;
4854 struct snd_soc_pcm_runtime *rtd = substream->private_data;
4855 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
4856 int index = cpu_dai->id;
4857 unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
4858 struct snd_soc_card *card = rtd->card;
4859 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
Derek Chen7bb78312019-06-18 00:36:55 -07004860 struct msm_pinctrl_info *pinctrl_info = NULL;
4861 struct mi2s_conf *intf_conf = NULL;
Rahul Sharma02bee732018-12-20 18:48:34 +05304862 int ret_pinctrl = 0;
4863
4864 dev_dbg(rtd->card->dev,
4865 "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
4866 __func__, substream->name, substream->stream,
4867 cpu_dai->name, cpu_dai->id);
4868
4869 if (index < PRIM_MI2S || index >= MI2S_MAX) {
4870 ret = -EINVAL;
4871 dev_err(rtd->card->dev,
4872 "%s: CPU DAI id (%d) out of range\n",
4873 __func__, cpu_dai->id);
4874 goto err;
4875 }
4876 /*
4877 * Mutex protection in case the same MI2S
4878 * interface using for both TX and RX so
4879 * that the same clock won't be enable twice.
4880 */
Derek Chen7bb78312019-06-18 00:36:55 -07004881 intf_conf = &pdata->mi2s_intf_conf[index];
4882 mutex_lock(&intf_conf->lock);
4883 if (++intf_conf->ref_cnt == 1) {
Rahul Sharma02bee732018-12-20 18:48:34 +05304884 /* Check if msm needs to provide the clock to the interface */
Derek Chen7bb78312019-06-18 00:36:55 -07004885 if (!intf_conf->msm_is_mi2s_master) {
Rahul Sharma02bee732018-12-20 18:48:34 +05304886 mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
4887 fmt = SND_SOC_DAIFMT_CBM_CFM;
4888 }
4889 ret = msm_mi2s_set_sclk(substream, true);
4890 if (ret < 0) {
4891 dev_err(rtd->card->dev,
4892 "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
4893 __func__, ret);
4894 goto clean_up;
4895 }
4896
4897 ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
4898 if (ret < 0) {
4899 pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
4900 __func__, index, ret);
4901 goto clk_off;
4902 }
Derek Chen7bb78312019-06-18 00:36:55 -07004903
4904 pinctrl_info = &pdata->pinctrl_info[index];
4905 ret_pinctrl = msm_set_pinctrl(pinctrl_info,
4906 STATE_ACTIVE);
4907 if (ret_pinctrl)
4908 pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
4909 __func__, ret_pinctrl);
Rahul Sharma02bee732018-12-20 18:48:34 +05304910 }
4911clk_off:
4912 if (ret < 0)
4913 msm_mi2s_set_sclk(substream, false);
4914clean_up:
4915 if (ret < 0)
Derek Chen7bb78312019-06-18 00:36:55 -07004916 intf_conf->ref_cnt--;
4917 mutex_unlock(&intf_conf->lock);
Rahul Sharma02bee732018-12-20 18:48:34 +05304918err:
4919 return ret;
4920}
4921
4922static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
4923{
4924 int ret;
4925 struct snd_soc_pcm_runtime *rtd = substream->private_data;
4926 int index = rtd->cpu_dai->id;
4927 struct snd_soc_card *card = rtd->card;
4928 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
Derek Chen7bb78312019-06-18 00:36:55 -07004929 struct msm_pinctrl_info *pinctrl_info = NULL;
4930 struct mi2s_conf *intf_conf = NULL;
Rahul Sharma02bee732018-12-20 18:48:34 +05304931 int ret_pinctrl = 0;
4932
4933 pr_debug("%s(): substream = %s stream = %d\n", __func__,
4934 substream->name, substream->stream);
4935 if (index < PRIM_MI2S || index >= MI2S_MAX) {
4936 pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
4937 return;
4938 }
4939
Derek Chen7bb78312019-06-18 00:36:55 -07004940 intf_conf = &pdata->mi2s_intf_conf[index];
4941 mutex_lock(&intf_conf->lock);
4942 if (--intf_conf->ref_cnt == 0) {
Rahul Sharma02bee732018-12-20 18:48:34 +05304943 ret = msm_mi2s_set_sclk(substream, false);
4944 if (ret < 0)
4945 pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
4946 __func__, index, ret);
Derek Chen7bb78312019-06-18 00:36:55 -07004947
4948 pinctrl_info = &pdata->pinctrl_info[index];
4949 ret_pinctrl = msm_set_pinctrl(pinctrl_info,
4950 STATE_SLEEP);
4951 if (ret_pinctrl)
4952 pr_err("%s: MI2S TLMM pinctrl set failed with %d\n",
4953 __func__, ret_pinctrl);
Rahul Sharma02bee732018-12-20 18:48:34 +05304954 }
Derek Chen7bb78312019-06-18 00:36:55 -07004955 mutex_unlock(&intf_conf->lock);
Rahul Sharma02bee732018-12-20 18:48:34 +05304956}
4957
4958static struct snd_soc_ops msm_mi2s_be_ops = {
4959 .startup = msm_mi2s_snd_startup,
4960 .shutdown = msm_mi2s_snd_shutdown,
4961};
4962
4963
4964/* Digital audio interface glue - connects codec <---> CPU */
4965static struct snd_soc_dai_link msm_common_dai_links[] = {
4966 /* FrontEnd DAI Links */
4967 {
4968 .name = MSM_DAILINK_NAME(Media1),
4969 .stream_name = "MultiMedia1",
4970 .cpu_dai_name = "MultiMedia1",
4971 .platform_name = "msm-pcm-dsp.0",
4972 .dynamic = 1,
4973 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
4974 .dpcm_playback = 1,
4975 .dpcm_capture = 1,
4976 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4977 SND_SOC_DPCM_TRIGGER_POST},
4978 .codec_dai_name = "snd-soc-dummy-dai",
4979 .codec_name = "snd-soc-dummy",
4980 .ignore_suspend = 1,
4981 /* this dainlink has playback support */
4982 .ignore_pmdown_time = 1,
4983 .id = MSM_FRONTEND_DAI_MULTIMEDIA1
4984 },
4985 {
4986 .name = MSM_DAILINK_NAME(Media2),
4987 .stream_name = "MultiMedia2",
4988 .cpu_dai_name = "MultiMedia2",
4989 .platform_name = "msm-pcm-dsp.0",
4990 .dynamic = 1,
4991 .dpcm_playback = 1,
4992 .dpcm_capture = 1,
4993 .codec_dai_name = "snd-soc-dummy-dai",
4994 .codec_name = "snd-soc-dummy",
4995 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4996 SND_SOC_DPCM_TRIGGER_POST},
4997 .ignore_suspend = 1,
4998 /* this dainlink has playback support */
4999 .ignore_pmdown_time = 1,
5000 .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
5001 },
5002 {
5003 .name = "VoiceMMode1",
5004 .stream_name = "VoiceMMode1",
5005 .cpu_dai_name = "VoiceMMode1",
5006 .platform_name = "msm-pcm-voice",
5007 .dynamic = 1,
5008 .dpcm_playback = 1,
5009 .dpcm_capture = 1,
5010 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5011 SND_SOC_DPCM_TRIGGER_POST},
5012 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5013 .ignore_suspend = 1,
5014 .ignore_pmdown_time = 1,
5015 .codec_dai_name = "snd-soc-dummy-dai",
5016 .codec_name = "snd-soc-dummy",
5017 .id = MSM_FRONTEND_DAI_VOICEMMODE1,
5018 },
5019 {
5020 .name = "MSM VoIP",
5021 .stream_name = "VoIP",
5022 .cpu_dai_name = "VoIP",
5023 .platform_name = "msm-voip-dsp",
5024 .dynamic = 1,
5025 .dpcm_playback = 1,
5026 .dpcm_capture = 1,
5027 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5028 SND_SOC_DPCM_TRIGGER_POST},
5029 .codec_dai_name = "snd-soc-dummy-dai",
5030 .codec_name = "snd-soc-dummy",
5031 .ignore_suspend = 1,
5032 /* this dainlink has playback support */
5033 .ignore_pmdown_time = 1,
5034 .id = MSM_FRONTEND_DAI_VOIP,
5035 },
5036 {
5037 .name = MSM_DAILINK_NAME(ULL),
5038 .stream_name = "MultiMedia3",
5039 .cpu_dai_name = "MultiMedia3",
5040 .platform_name = "msm-pcm-dsp.2",
5041 .dynamic = 1,
5042 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5043 .dpcm_playback = 1,
5044 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5045 SND_SOC_DPCM_TRIGGER_POST},
5046 .codec_dai_name = "snd-soc-dummy-dai",
5047 .codec_name = "snd-soc-dummy",
5048 .ignore_suspend = 1,
5049 /* this dainlink has playback support */
5050 .ignore_pmdown_time = 1,
5051 .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
5052 },
5053 /* - SLIMBUS_0 Hostless */
5054 {
5055 .name = "MSM AFE-PCM RX",
5056 .stream_name = "AFE-PROXY RX",
5057 .cpu_dai_name = "msm-dai-q6-dev.241",
5058 .codec_name = "msm-stub-codec.1",
5059 .codec_dai_name = "msm-stub-rx",
5060 .platform_name = "msm-pcm-afe",
5061 .dpcm_playback = 1,
5062 .ignore_suspend = 1,
5063 /* this dainlink has playback support */
5064 .ignore_pmdown_time = 1,
5065 },
5066 {
5067 .name = "MSM AFE-PCM TX",
5068 .stream_name = "AFE-PROXY TX",
5069 .cpu_dai_name = "msm-dai-q6-dev.240",
5070 .codec_name = "msm-stub-codec.1",
5071 .codec_dai_name = "msm-stub-tx",
5072 .platform_name = "msm-pcm-afe",
5073 .dpcm_capture = 1,
5074 .ignore_suspend = 1,
5075 },
5076 {
5077 .name = MSM_DAILINK_NAME(Compress1),
5078 .stream_name = "Compress1",
5079 .cpu_dai_name = "MultiMedia4",
5080 .platform_name = "msm-compress-dsp",
5081 .dynamic = 1,
5082 .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
5083 .dpcm_playback = 1,
5084 .dpcm_capture = 1,
5085 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5086 SND_SOC_DPCM_TRIGGER_POST},
5087 .codec_dai_name = "snd-soc-dummy-dai",
5088 .codec_name = "snd-soc-dummy",
5089 .ignore_suspend = 1,
5090 .ignore_pmdown_time = 1,
5091 /* this dainlink has playback support */
5092 .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
5093 },
5094 /* Hostless PCM purpose */
5095 {
5096 .name = "AUXPCM Hostless",
5097 .stream_name = "AUXPCM Hostless",
5098 .cpu_dai_name = "AUXPCM_HOSTLESS",
5099 .platform_name = "msm-pcm-hostless",
5100 .dynamic = 1,
5101 .dpcm_playback = 1,
5102 .dpcm_capture = 1,
5103 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5104 SND_SOC_DPCM_TRIGGER_POST},
5105 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5106 .ignore_suspend = 1,
5107 /* this dainlink has playback support */
5108 .ignore_pmdown_time = 1,
5109 .codec_dai_name = "snd-soc-dummy-dai",
5110 .codec_name = "snd-soc-dummy",
5111 },
5112 /* - SLIMBUS_1 Hostless */
5113 /* - SLIMBUS_3 Hostless */
5114 /* - SLIMBUS_4 Hostless */
5115 {
5116 .name = MSM_DAILINK_NAME(LowLatency),
5117 .stream_name = "MultiMedia5",
5118 .cpu_dai_name = "MultiMedia5",
5119 .platform_name = "msm-pcm-dsp.1",
5120 .dynamic = 1,
5121 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5122 .dpcm_playback = 1,
5123 .dpcm_capture = 1,
5124 .codec_dai_name = "snd-soc-dummy-dai",
5125 .codec_name = "snd-soc-dummy",
5126 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5127 SND_SOC_DPCM_TRIGGER_POST},
5128 .ignore_suspend = 1,
5129 /* this dainlink has playback support */
5130 .ignore_pmdown_time = 1,
5131 .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
5132 .ops = &msm_fe_qos_ops,
5133 },
5134 {
5135 .name = "Listen 1 Audio Service",
5136 .stream_name = "Listen 1 Audio Service",
5137 .cpu_dai_name = "LSM1",
5138 .platform_name = "msm-lsm-client",
5139 .dynamic = 1,
5140 .dpcm_capture = 1,
5141 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
5142 SND_SOC_DPCM_TRIGGER_POST },
5143 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5144 .ignore_suspend = 1,
5145 .codec_dai_name = "snd-soc-dummy-dai",
5146 .codec_name = "snd-soc-dummy",
5147 .id = MSM_FRONTEND_DAI_LSM1,
5148 },
5149 /* Multiple Tunnel instances */
5150 {
5151 .name = MSM_DAILINK_NAME(Compress2),
5152 .stream_name = "Compress2",
5153 .cpu_dai_name = "MultiMedia7",
5154 .platform_name = "msm-compress-dsp",
5155 .dynamic = 1,
5156 .dpcm_playback = 1,
5157 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5158 SND_SOC_DPCM_TRIGGER_POST},
5159 .codec_dai_name = "snd-soc-dummy-dai",
5160 .codec_name = "snd-soc-dummy",
5161 .ignore_suspend = 1,
5162 .ignore_pmdown_time = 1,
5163 /* this dainlink has playback support */
5164 .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
5165 },
5166 {
5167 .name = MSM_DAILINK_NAME(MultiMedia10),
5168 .stream_name = "MultiMedia10",
5169 .cpu_dai_name = "MultiMedia10",
5170 .platform_name = "msm-pcm-dsp.1",
5171 .dynamic = 1,
5172 .dpcm_playback = 1,
5173 .dpcm_capture = 1,
5174 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5175 SND_SOC_DPCM_TRIGGER_POST},
5176 .codec_dai_name = "snd-soc-dummy-dai",
5177 .codec_name = "snd-soc-dummy",
5178 .ignore_suspend = 1,
5179 .ignore_pmdown_time = 1,
5180 /* this dainlink has playback support */
5181 .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
5182 },
5183 {
5184 .name = MSM_DAILINK_NAME(ULL_NOIRQ),
5185 .stream_name = "MM_NOIRQ",
5186 .cpu_dai_name = "MultiMedia8",
5187 .platform_name = "msm-pcm-dsp-noirq",
5188 .dynamic = 1,
5189 .dpcm_playback = 1,
5190 .dpcm_capture = 1,
5191 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5192 SND_SOC_DPCM_TRIGGER_POST},
5193 .codec_dai_name = "snd-soc-dummy-dai",
5194 .codec_name = "snd-soc-dummy",
5195 .ignore_suspend = 1,
5196 .ignore_pmdown_time = 1,
5197 /* this dainlink has playback support */
5198 .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
5199 .ops = &msm_fe_qos_ops,
5200 },
5201 /* HDMI Hostless */
5202 {
5203 .name = "HDMI_RX_HOSTLESS",
5204 .stream_name = "HDMI_RX_HOSTLESS",
5205 .cpu_dai_name = "HDMI_HOSTLESS",
5206 .platform_name = "msm-pcm-hostless",
5207 .dynamic = 1,
5208 .dpcm_playback = 1,
5209 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5210 SND_SOC_DPCM_TRIGGER_POST},
5211 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5212 .ignore_suspend = 1,
5213 .ignore_pmdown_time = 1,
5214 .codec_dai_name = "snd-soc-dummy-dai",
5215 .codec_name = "snd-soc-dummy",
5216 },
5217 {
5218 .name = "VoiceMMode2",
5219 .stream_name = "VoiceMMode2",
5220 .cpu_dai_name = "VoiceMMode2",
5221 .platform_name = "msm-pcm-voice",
5222 .dynamic = 1,
5223 .dpcm_playback = 1,
5224 .dpcm_capture = 1,
5225 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5226 SND_SOC_DPCM_TRIGGER_POST},
5227 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5228 .ignore_suspend = 1,
5229 .ignore_pmdown_time = 1,
5230 .codec_dai_name = "snd-soc-dummy-dai",
5231 .codec_name = "snd-soc-dummy",
5232 .id = MSM_FRONTEND_DAI_VOICEMMODE2,
5233 },
5234 /* LSM FE */
5235 {
5236 .name = "Listen 2 Audio Service",
5237 .stream_name = "Listen 2 Audio Service",
5238 .cpu_dai_name = "LSM2",
5239 .platform_name = "msm-lsm-client",
5240 .dynamic = 1,
5241 .dpcm_capture = 1,
5242 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
5243 SND_SOC_DPCM_TRIGGER_POST },
5244 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5245 .ignore_suspend = 1,
5246 .codec_dai_name = "snd-soc-dummy-dai",
5247 .codec_name = "snd-soc-dummy",
5248 .id = MSM_FRONTEND_DAI_LSM2,
5249 },
5250 {
5251 .name = "Listen 3 Audio Service",
5252 .stream_name = "Listen 3 Audio Service",
5253 .cpu_dai_name = "LSM3",
5254 .platform_name = "msm-lsm-client",
5255 .dynamic = 1,
5256 .dpcm_capture = 1,
5257 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
5258 SND_SOC_DPCM_TRIGGER_POST },
5259 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5260 .ignore_suspend = 1,
5261 .codec_dai_name = "snd-soc-dummy-dai",
5262 .codec_name = "snd-soc-dummy",
5263 .id = MSM_FRONTEND_DAI_LSM3,
5264 },
5265 {
5266 .name = "Listen 4 Audio Service",
5267 .stream_name = "Listen 4 Audio Service",
5268 .cpu_dai_name = "LSM4",
5269 .platform_name = "msm-lsm-client",
5270 .dynamic = 1,
5271 .dpcm_capture = 1,
5272 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
5273 SND_SOC_DPCM_TRIGGER_POST },
5274 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5275 .ignore_suspend = 1,
5276 .codec_dai_name = "snd-soc-dummy-dai",
5277 .codec_name = "snd-soc-dummy",
5278 .id = MSM_FRONTEND_DAI_LSM4,
5279 },
5280 {
5281 .name = "Listen 5 Audio Service",
5282 .stream_name = "Listen 5 Audio Service",
5283 .cpu_dai_name = "LSM5",
5284 .platform_name = "msm-lsm-client",
5285 .dynamic = 1,
5286 .dpcm_capture = 1,
5287 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
5288 SND_SOC_DPCM_TRIGGER_POST },
5289 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5290 .ignore_suspend = 1,
5291 .codec_dai_name = "snd-soc-dummy-dai",
5292 .codec_name = "snd-soc-dummy",
5293 .id = MSM_FRONTEND_DAI_LSM5,
5294 },
5295 {
5296 .name = "Listen 6 Audio Service",
5297 .stream_name = "Listen 6 Audio Service",
5298 .cpu_dai_name = "LSM6",
5299 .platform_name = "msm-lsm-client",
5300 .dynamic = 1,
5301 .dpcm_capture = 1,
5302 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
5303 SND_SOC_DPCM_TRIGGER_POST },
5304 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5305 .ignore_suspend = 1,
5306 .codec_dai_name = "snd-soc-dummy-dai",
5307 .codec_name = "snd-soc-dummy",
5308 .id = MSM_FRONTEND_DAI_LSM6,
5309 },
5310 {
5311 .name = "Listen 7 Audio Service",
5312 .stream_name = "Listen 7 Audio Service",
5313 .cpu_dai_name = "LSM7",
5314 .platform_name = "msm-lsm-client",
5315 .dynamic = 1,
5316 .dpcm_capture = 1,
5317 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
5318 SND_SOC_DPCM_TRIGGER_POST },
5319 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5320 .ignore_suspend = 1,
5321 .codec_dai_name = "snd-soc-dummy-dai",
5322 .codec_name = "snd-soc-dummy",
5323 .id = MSM_FRONTEND_DAI_LSM7,
5324 },
5325 {
5326 .name = "Listen 8 Audio Service",
5327 .stream_name = "Listen 8 Audio Service",
5328 .cpu_dai_name = "LSM8",
5329 .platform_name = "msm-lsm-client",
5330 .dynamic = 1,
5331 .dpcm_capture = 1,
5332 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
5333 SND_SOC_DPCM_TRIGGER_POST },
5334 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5335 .ignore_suspend = 1,
5336 .codec_dai_name = "snd-soc-dummy-dai",
5337 .codec_name = "snd-soc-dummy",
5338 .id = MSM_FRONTEND_DAI_LSM8,
5339 },
5340 /* - Multimedia9 */
5341 {
5342 .name = MSM_DAILINK_NAME(Compress4),
5343 .stream_name = "Compress4",
5344 .cpu_dai_name = "MultiMedia11",
5345 .platform_name = "msm-compress-dsp",
5346 .dynamic = 1,
5347 .dpcm_playback = 1,
5348 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5349 SND_SOC_DPCM_TRIGGER_POST},
5350 .codec_dai_name = "snd-soc-dummy-dai",
5351 .codec_name = "snd-soc-dummy",
5352 .ignore_suspend = 1,
5353 .ignore_pmdown_time = 1,
5354 /* this dainlink has playback support */
5355 .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
5356 },
5357 {
5358 .name = MSM_DAILINK_NAME(Compress5),
5359 .stream_name = "Compress5",
5360 .cpu_dai_name = "MultiMedia12",
5361 .platform_name = "msm-compress-dsp",
5362 .dynamic = 1,
5363 .dpcm_playback = 1,
5364 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5365 SND_SOC_DPCM_TRIGGER_POST},
5366 .codec_dai_name = "snd-soc-dummy-dai",
5367 .codec_name = "snd-soc-dummy",
5368 .ignore_suspend = 1,
5369 .ignore_pmdown_time = 1,
5370 /* this dainlink has playback support */
5371 .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
5372 },
5373 {
5374 .name = MSM_DAILINK_NAME(Compress6),
5375 .stream_name = "Compress6",
5376 .cpu_dai_name = "MultiMedia13",
5377 .platform_name = "msm-compress-dsp",
5378 .dynamic = 1,
5379 .dpcm_playback = 1,
5380 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5381 SND_SOC_DPCM_TRIGGER_POST},
5382 .codec_dai_name = "snd-soc-dummy-dai",
5383 .codec_name = "snd-soc-dummy",
5384 .ignore_suspend = 1,
5385 .ignore_pmdown_time = 1,
5386 /* this dainlink has playback support */
5387 .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
5388 },
5389 {
5390 .name = MSM_DAILINK_NAME(Compress7),
5391 .stream_name = "Compress7",
5392 .cpu_dai_name = "MultiMedia14",
5393 .platform_name = "msm-compress-dsp",
5394 .dynamic = 1,
5395 .dpcm_playback = 1,
5396 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5397 SND_SOC_DPCM_TRIGGER_POST},
5398 .codec_dai_name = "snd-soc-dummy-dai",
5399 .codec_name = "snd-soc-dummy",
5400 .ignore_suspend = 1,
5401 .ignore_pmdown_time = 1,
5402 /* this dainlink has playback support */
5403 .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
5404 },
5405 {
5406 .name = MSM_DAILINK_NAME(Compress8),
5407 .stream_name = "Compress8",
5408 .cpu_dai_name = "MultiMedia15",
5409 .platform_name = "msm-compress-dsp",
5410 .dynamic = 1,
5411 .dpcm_playback = 1,
5412 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5413 SND_SOC_DPCM_TRIGGER_POST},
5414 .codec_dai_name = "snd-soc-dummy-dai",
5415 .codec_name = "snd-soc-dummy",
5416 .ignore_suspend = 1,
5417 .ignore_pmdown_time = 1,
5418 /* this dainlink has playback support */
5419 .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
5420 },
5421 {
5422 .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
5423 .stream_name = "MM_NOIRQ_2",
5424 .cpu_dai_name = "MultiMedia16",
5425 .platform_name = "msm-pcm-dsp-noirq",
5426 .dynamic = 1,
5427 .dpcm_playback = 1,
5428 .dpcm_capture = 1,
5429 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5430 SND_SOC_DPCM_TRIGGER_POST},
5431 .codec_dai_name = "snd-soc-dummy-dai",
5432 .codec_name = "snd-soc-dummy",
5433 .ignore_suspend = 1,
5434 .ignore_pmdown_time = 1,
5435 /* this dainlink has playback support */
5436 .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
5437 },
5438 /* - SLIMBUS_8 Hostless */
5439 /* - Slimbus4 Capture */
5440 /* - SLIMBUS_2 Hostless Playback */
5441 /* - SLIMBUS_2 Hostless Capture */
5442 /* HFP TX */
5443 {
5444 .name = MSM_DAILINK_NAME(ASM Loopback),
5445 .stream_name = "MultiMedia6",
5446 .cpu_dai_name = "MultiMedia6",
5447 .platform_name = "msm-pcm-loopback",
5448 .dynamic = 1,
5449 .dpcm_playback = 1,
5450 .dpcm_capture = 1,
5451 .codec_dai_name = "snd-soc-dummy-dai",
5452 .codec_name = "snd-soc-dummy",
5453 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5454 SND_SOC_DPCM_TRIGGER_POST},
5455 .ignore_suspend = 1,
5456 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5457 .ignore_pmdown_time = 1,
5458 .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
5459 },
5460 {
5461 .name = "USB Audio Hostless",
5462 .stream_name = "USB Audio Hostless",
5463 .cpu_dai_name = "USBAUDIO_HOSTLESS",
5464 .platform_name = "msm-pcm-hostless",
5465 .dynamic = 1,
5466 .dpcm_playback = 1,
5467 .dpcm_capture = 1,
5468 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5469 SND_SOC_DPCM_TRIGGER_POST},
5470 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5471 .ignore_suspend = 1,
5472 .ignore_pmdown_time = 1,
5473 .codec_dai_name = "snd-soc-dummy-dai",
5474 .codec_name = "snd-soc-dummy",
5475 },
5476 /* - SLIMBUS_7 Hostless */
5477 {
5478 .name = "Compress Capture",
5479 .stream_name = "Compress9",
5480 .cpu_dai_name = "MultiMedia17",
5481 .platform_name = "msm-compress-dsp",
5482 .dynamic = 1,
5483 .dpcm_capture = 1,
5484 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5485 SND_SOC_DPCM_TRIGGER_POST},
5486 .codec_dai_name = "snd-soc-dummy-dai",
5487 .codec_name = "snd-soc-dummy",
5488 .ignore_suspend = 1,
5489 .ignore_pmdown_time = 1,
5490 .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
5491 },
5492};
5493
5494static struct snd_soc_dai_link msm_auto_fe_dai_links[] = {
5495 {
5496 .name = "INT_HFP_BT Hostless",
5497 .stream_name = "INT_HFP_BT Hostless",
5498 .cpu_dai_name = "INT_HFP_BT_HOSTLESS",
5499 .platform_name = "msm-pcm-hostless",
5500 .dynamic = 1,
5501 .dpcm_playback = 1,
5502 .dpcm_capture = 1,
5503 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5504 SND_SOC_DPCM_TRIGGER_POST},
5505 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5506 .ignore_suspend = 1,
5507 /* this dainlink has playback support */
5508 .ignore_pmdown_time = 1,
5509 .codec_dai_name = "snd-soc-dummy-dai",
5510 .codec_name = "snd-soc-dummy",
5511 },
5512 /* Low latency ASM loopback for ICC */
5513 {
5514 .name = MSM_DAILINK_NAME(LowLatency Loopback),
5515 .stream_name = "MultiMedia9",
5516 .cpu_dai_name = "MultiMedia9",
5517 .platform_name = "msm-pcm-loopback.1",
5518 .dynamic = 1,
5519 .dpcm_playback = 1,
5520 .dpcm_capture = 1,
5521 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5522 SND_SOC_DPCM_TRIGGER_POST},
5523 .codec_dai_name = "snd-soc-dummy-dai",
5524 .codec_name = "snd-soc-dummy",
5525 .ignore_suspend = 1,
5526 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5527 /* this dainlink has playback support */
5528 .ignore_pmdown_time = 1,
5529 .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
5530 },
5531 {
5532 .name = "Tertiary MI2S TX_Hostless",
5533 .stream_name = "Tertiary MI2S_TX Hostless Capture",
5534 .cpu_dai_name = "TERT_MI2S_TX_HOSTLESS",
5535 .platform_name = "msm-pcm-hostless",
5536 .dynamic = 1,
5537 .dpcm_capture = 1,
5538 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5539 SND_SOC_DPCM_TRIGGER_POST},
5540 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5541 .ignore_suspend = 1,
5542 .ignore_pmdown_time = 1,
5543 .codec_dai_name = "snd-soc-dummy-dai",
5544 .codec_name = "snd-soc-dummy",
5545 },
5546 {
5547 .name = MSM_DAILINK_NAME(Media20),
5548 .stream_name = "MultiMedia20",
5549 .cpu_dai_name = "MultiMedia20",
5550 .platform_name = "msm-pcm-loopback",
5551 .dynamic = 1,
5552 .dpcm_playback = 1,
5553 .dpcm_capture = 1,
5554 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5555 SND_SOC_DPCM_TRIGGER_POST},
5556 .codec_dai_name = "snd-soc-dummy-dai",
5557 .codec_name = "snd-soc-dummy",
5558 .ignore_suspend = 1,
5559 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5560 /* this dainlink has playback support */
5561 .ignore_pmdown_time = 1,
5562 .id = MSM_FRONTEND_DAI_MULTIMEDIA20,
5563 },
5564 {
5565 .name = MSM_DAILINK_NAME(HFP RX),
5566 .stream_name = "MultiMedia21",
5567 .cpu_dai_name = "MultiMedia21",
5568 .platform_name = "msm-pcm-loopback",
5569 .dynamic = 1,
5570 .dpcm_playback = 1,
5571 .dpcm_capture = 1,
5572 .codec_dai_name = "snd-soc-dummy-dai",
5573 .codec_name = "snd-soc-dummy",
5574 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5575 SND_SOC_DPCM_TRIGGER_POST},
5576 .ignore_suspend = 1,
5577 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5578 .ignore_pmdown_time = 1,
5579 .id = MSM_FRONTEND_DAI_MULTIMEDIA21,
5580 },
5581 /* TDM Hostless */
5582 {
5583 .name = "Primary TDM RX 0 Hostless",
5584 .stream_name = "Primary TDM RX 0 Hostless",
5585 .cpu_dai_name = "PRI_TDM_RX_0_HOSTLESS",
5586 .platform_name = "msm-pcm-hostless",
5587 .dynamic = 1,
5588 .dpcm_playback = 1,
5589 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5590 SND_SOC_DPCM_TRIGGER_POST},
5591 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5592 .ignore_suspend = 1,
5593 .ignore_pmdown_time = 1,
5594 .codec_dai_name = "snd-soc-dummy-dai",
5595 .codec_name = "snd-soc-dummy",
5596 },
5597 {
5598 .name = "Primary TDM TX 0 Hostless",
5599 .stream_name = "Primary TDM TX 0 Hostless",
5600 .cpu_dai_name = "PRI_TDM_TX_0_HOSTLESS",
5601 .platform_name = "msm-pcm-hostless",
5602 .dynamic = 1,
5603 .dpcm_capture = 1,
5604 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5605 SND_SOC_DPCM_TRIGGER_POST},
5606 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5607 .ignore_suspend = 1,
5608 .ignore_pmdown_time = 1,
5609 .codec_dai_name = "snd-soc-dummy-dai",
5610 .codec_name = "snd-soc-dummy",
5611 },
5612 {
5613 .name = "Secondary TDM RX 0 Hostless",
5614 .stream_name = "Secondary TDM RX 0 Hostless",
5615 .cpu_dai_name = "SEC_TDM_RX_0_HOSTLESS",
5616 .platform_name = "msm-pcm-hostless",
5617 .dynamic = 1,
5618 .dpcm_playback = 1,
5619 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5620 SND_SOC_DPCM_TRIGGER_POST},
5621 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5622 .ignore_suspend = 1,
5623 .ignore_pmdown_time = 1,
5624 .codec_dai_name = "snd-soc-dummy-dai",
5625 .codec_name = "snd-soc-dummy",
5626 },
5627 {
5628 .name = "Secondary TDM TX 0 Hostless",
5629 .stream_name = "Secondary TDM TX 0 Hostless",
5630 .cpu_dai_name = "SEC_TDM_TX_0_HOSTLESS",
5631 .platform_name = "msm-pcm-hostless",
5632 .dynamic = 1,
5633 .dpcm_capture = 1,
5634 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5635 SND_SOC_DPCM_TRIGGER_POST},
5636 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5637 .ignore_suspend = 1,
5638 .ignore_pmdown_time = 1,
5639 .codec_dai_name = "snd-soc-dummy-dai",
5640 .codec_name = "snd-soc-dummy",
5641 },
5642 {
5643 .name = "Tertiary TDM RX 0 Hostless",
5644 .stream_name = "Tertiary TDM RX 0 Hostless",
5645 .cpu_dai_name = "TERT_TDM_RX_0_HOSTLESS",
5646 .platform_name = "msm-pcm-hostless",
5647 .dynamic = 1,
5648 .dpcm_playback = 1,
5649 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5650 SND_SOC_DPCM_TRIGGER_POST},
5651 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5652 .ignore_suspend = 1,
5653 .ignore_pmdown_time = 1,
5654 .codec_dai_name = "snd-soc-dummy-dai",
5655 .codec_name = "snd-soc-dummy",
5656 },
5657 {
5658 .name = "Tertiary TDM TX 0 Hostless",
5659 .stream_name = "Tertiary TDM TX 0 Hostless",
5660 .cpu_dai_name = "TERT_TDM_TX_0_HOSTLESS",
5661 .platform_name = "msm-pcm-hostless",
5662 .dynamic = 1,
5663 .dpcm_capture = 1,
5664 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5665 SND_SOC_DPCM_TRIGGER_POST},
5666 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5667 .ignore_suspend = 1,
5668 .ignore_pmdown_time = 1,
5669 .codec_dai_name = "snd-soc-dummy-dai",
5670 .codec_name = "snd-soc-dummy",
5671 },
5672 {
5673 .name = "Quaternary TDM RX 0 Hostless",
5674 .stream_name = "Quaternary TDM RX 0 Hostless",
5675 .cpu_dai_name = "QUAT_TDM_RX_0_HOSTLESS",
5676 .platform_name = "msm-pcm-hostless",
5677 .dynamic = 1,
5678 .dpcm_playback = 1,
5679 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5680 SND_SOC_DPCM_TRIGGER_POST},
5681 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5682 .ignore_suspend = 1,
5683 .ignore_pmdown_time = 1,
5684 .codec_dai_name = "snd-soc-dummy-dai",
5685 .codec_name = "snd-soc-dummy",
5686 },
5687 {
5688 .name = "Quaternary TDM TX 0 Hostless",
5689 .stream_name = "Quaternary TDM TX 0 Hostless",
5690 .cpu_dai_name = "QUAT_TDM_TX_0_HOSTLESS",
5691 .platform_name = "msm-pcm-hostless",
5692 .dynamic = 1,
5693 .dpcm_capture = 1,
5694 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5695 SND_SOC_DPCM_TRIGGER_POST},
5696 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5697 .ignore_suspend = 1,
5698 .ignore_pmdown_time = 1,
5699 .codec_dai_name = "snd-soc-dummy-dai",
5700 .codec_name = "snd-soc-dummy",
5701 },
5702 {
5703 .name = "Quaternary MI2S_RX Hostless Playback",
5704 .stream_name = "Quaternary MI2S_RX Hostless Playback",
5705 .cpu_dai_name = "QUAT_MI2S_RX_HOSTLESS",
5706 .platform_name = "msm-pcm-hostless",
5707 .dynamic = 1,
5708 .dpcm_playback = 1,
5709 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5710 SND_SOC_DPCM_TRIGGER_POST},
5711 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5712 .ignore_suspend = 1,
5713 .ignore_pmdown_time = 1,
5714 .codec_dai_name = "snd-soc-dummy-dai",
5715 .codec_name = "snd-soc-dummy",
5716 },
5717 {
5718 .name = "Secondary MI2S_TX Hostless Capture",
5719 .stream_name = "Secondary MI2S_TX Hostless Capture",
5720 .cpu_dai_name = "SEC_MI2S_TX_HOSTLESS",
5721 .platform_name = "msm-pcm-hostless",
5722 .dynamic = 1,
5723 .dpcm_capture = 1,
5724 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5725 SND_SOC_DPCM_TRIGGER_POST},
5726 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5727 .ignore_suspend = 1,
5728 .ignore_pmdown_time = 1,
5729 .codec_dai_name = "snd-soc-dummy-dai",
5730 .codec_name = "snd-soc-dummy",
5731 },
5732 {
5733 .name = "DTMF RX Hostless",
5734 .stream_name = "DTMF RX Hostless",
5735 .cpu_dai_name = "DTMF_RX_HOSTLESS",
5736 .platform_name = "msm-pcm-dtmf",
5737 .dynamic = 1,
5738 .dpcm_playback = 1,
5739 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5740 SND_SOC_DPCM_TRIGGER_POST},
5741 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5742 .ignore_suspend = 1,
5743 .ignore_pmdown_time = 1,
5744 .codec_dai_name = "snd-soc-dummy-dai",
5745 .codec_name = "snd-soc-dummy",
5746 .id = MSM_FRONTEND_DAI_DTMF_RX,
Derek Chen0150b832019-06-05 18:46:29 +05305747 },
5748 {
5749 .name = "Secondary TDM RX 7 Hostless",
5750 .stream_name = "Secondary TDM RX 7 Hostless",
5751 .cpu_dai_name = "SEC_TDM_RX_7_HOSTLESS",
5752 .platform_name = "msm-pcm-hostless",
5753 .dynamic = 1,
5754 .dpcm_playback = 1,
5755 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5756 SND_SOC_DPCM_TRIGGER_POST},
5757 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5758 .ignore_suspend = 1,
5759 .ignore_pmdown_time = 1,
5760 .codec_dai_name = "snd-soc-dummy-dai",
5761 .codec_name = "snd-soc-dummy",
5762 },
5763 {
5764 .name = "Tertiary TDM TX 7 Hostless",
5765 .stream_name = "Tertiary TDM TX 7 Hostless",
5766 .cpu_dai_name = "TERT_TDM_TX_7_HOSTLESS",
5767 .platform_name = "msm-pcm-hostless",
5768 .dynamic = 1,
5769 .dpcm_capture = 1,
5770 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5771 SND_SOC_DPCM_TRIGGER_POST},
5772 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5773 .ignore_suspend = 1,
5774 .ignore_pmdown_time = 1,
5775 .codec_dai_name = "snd-soc-dummy-dai",
5776 .codec_name = "snd-soc-dummy",
5777 },
5778 {
5779 .name = "Quaternary TDM RX 7 Hostless",
5780 .stream_name = "Quaternary TDM RX 7 Hostless",
5781 .cpu_dai_name = "QUAT_TDM_RX_7_HOSTLESS",
5782 .platform_name = "msm-pcm-hostless",
5783 .dynamic = 1,
5784 .dpcm_playback = 1,
5785 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5786 SND_SOC_DPCM_TRIGGER_POST},
5787 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5788 .ignore_suspend = 1,
5789 .ignore_pmdown_time = 1,
5790 .codec_dai_name = "snd-soc-dummy-dai",
5791 .codec_name = "snd-soc-dummy",
5792 },
5793 {
5794 .name = "Quaternary TDM TX 7 Hostless",
5795 .stream_name = "Quaternary TDM TX 7 Hostless",
5796 .cpu_dai_name = "QUAT_TDM_TX_7_HOSTLESS",
5797 .platform_name = "msm-pcm-hostless",
5798 .dynamic = 1,
5799 .dpcm_capture = 1,
5800 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5801 SND_SOC_DPCM_TRIGGER_POST},
5802 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5803 .ignore_suspend = 1,
5804 .ignore_pmdown_time = 1,
5805 .codec_dai_name = "snd-soc-dummy-dai",
5806 .codec_name = "snd-soc-dummy",
5807 },
Rahul Sharma02bee732018-12-20 18:48:34 +05305808};
5809
5810static struct snd_soc_dai_link msm_custom_fe_dai_links[] = {
5811 /* FrontEnd DAI Links */
5812 {
5813 .name = MSM_DAILINK_NAME(Media1),
5814 .stream_name = "MultiMedia1",
5815 .cpu_dai_name = "MultiMedia1",
5816 .platform_name = "msm-pcm-dsp.1",
5817 .dynamic = 1,
5818 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5819 .dpcm_playback = 1,
5820 .dpcm_capture = 1,
5821 .codec_dai_name = "snd-soc-dummy-dai",
5822 .codec_name = "snd-soc-dummy",
5823 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5824 SND_SOC_DPCM_TRIGGER_POST},
5825 .ignore_suspend = 1,
5826 /* this dainlink has playback support */
5827 .ignore_pmdown_time = 1,
5828 .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
5829 .ops = &msm_fe_qos_ops,
5830 },
5831 {
5832 .name = MSM_DAILINK_NAME(Media2),
5833 .stream_name = "MultiMedia2",
5834 .cpu_dai_name = "MultiMedia2",
5835 .platform_name = "msm-pcm-dsp.1",
5836 .dynamic = 1,
5837 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5838 .dpcm_playback = 1,
5839 .dpcm_capture = 1,
5840 .codec_dai_name = "snd-soc-dummy-dai",
5841 .codec_name = "snd-soc-dummy",
5842 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5843 SND_SOC_DPCM_TRIGGER_POST},
5844 .ignore_suspend = 1,
5845 /* this dainlink has playback support */
5846 .ignore_pmdown_time = 1,
5847 .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
5848 .ops = &msm_fe_qos_ops,
5849 },
5850 {
5851 .name = MSM_DAILINK_NAME(Media3),
5852 .stream_name = "MultiMedia3",
5853 .cpu_dai_name = "MultiMedia3",
5854 .platform_name = "msm-pcm-dsp.1",
5855 .dynamic = 1,
5856 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5857 .dpcm_playback = 1,
5858 .dpcm_capture = 1,
5859 .codec_dai_name = "snd-soc-dummy-dai",
5860 .codec_name = "snd-soc-dummy",
5861 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5862 SND_SOC_DPCM_TRIGGER_POST},
5863 .ignore_suspend = 1,
5864 /* this dainlink has playback support */
5865 .ignore_pmdown_time = 1,
5866 .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
5867 .ops = &msm_fe_qos_ops,
5868 },
5869 {
5870 .name = MSM_DAILINK_NAME(Media5),
5871 .stream_name = "MultiMedia5",
5872 .cpu_dai_name = "MultiMedia5",
5873 .platform_name = "msm-pcm-dsp.1",
5874 .dynamic = 1,
5875 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5876 .dpcm_playback = 1,
5877 .dpcm_capture = 1,
5878 .codec_dai_name = "snd-soc-dummy-dai",
5879 .codec_name = "snd-soc-dummy",
5880 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5881 SND_SOC_DPCM_TRIGGER_POST},
5882 .ignore_suspend = 1,
5883 /* this dainlink has playback support */
5884 .ignore_pmdown_time = 1,
5885 .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
5886 .ops = &msm_fe_qos_ops,
5887 },
5888 {
5889 .name = MSM_DAILINK_NAME(Media6),
5890 .stream_name = "MultiMedia6",
5891 .cpu_dai_name = "MultiMedia6",
5892 .platform_name = "msm-pcm-dsp.1",
5893 .dynamic = 1,
5894 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5895 .dpcm_playback = 1,
5896 .dpcm_capture = 1,
5897 .codec_dai_name = "snd-soc-dummy-dai",
5898 .codec_name = "snd-soc-dummy",
5899 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5900 SND_SOC_DPCM_TRIGGER_POST},
5901 .ignore_suspend = 1,
5902 /* this dainlink has playback support */
5903 .ignore_pmdown_time = 1,
5904 .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
5905 .ops = &msm_fe_qos_ops,
5906 },
5907 {
5908 .name = MSM_DAILINK_NAME(Media8),
5909 .stream_name = "MultiMedia8",
5910 .cpu_dai_name = "MultiMedia8",
5911 .platform_name = "msm-pcm-dsp.1",
5912 .dynamic = 1,
5913 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5914 .dpcm_playback = 1,
5915 .dpcm_capture = 1,
5916 .codec_dai_name = "snd-soc-dummy-dai",
5917 .codec_name = "snd-soc-dummy",
5918 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5919 SND_SOC_DPCM_TRIGGER_POST},
5920 .ignore_suspend = 1,
5921 /* this dainlink has playback support */
5922 .ignore_pmdown_time = 1,
5923 .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
5924 .ops = &msm_fe_qos_ops,
5925 },
5926 {
5927 .name = MSM_DAILINK_NAME(Media9),
5928 .stream_name = "MultiMedia9",
5929 .cpu_dai_name = "MultiMedia9",
5930 .platform_name = "msm-pcm-dsp.1",
5931 .dynamic = 1,
5932 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5933 .dpcm_playback = 1,
5934 .dpcm_capture = 1,
5935 .codec_dai_name = "snd-soc-dummy-dai",
5936 .codec_name = "snd-soc-dummy",
5937 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5938 SND_SOC_DPCM_TRIGGER_POST},
5939 .ignore_suspend = 1,
5940 /* this dainlink has playback support */
5941 .ignore_pmdown_time = 1,
5942 .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
5943 .ops = &msm_fe_qos_ops,
5944 },
5945 {
5946 .name = "INT_HFP_BT Hostless",
5947 .stream_name = "INT_HFP_BT Hostless",
5948 .cpu_dai_name = "INT_HFP_BT_HOSTLESS",
5949 .platform_name = "msm-pcm-hostless",
5950 .dynamic = 1,
5951 .dpcm_playback = 1,
5952 .dpcm_capture = 1,
5953 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5954 SND_SOC_DPCM_TRIGGER_POST},
5955 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5956 .ignore_suspend = 1,
5957 /* this dainlink has playback support */
5958 .ignore_pmdown_time = 1,
5959 .codec_dai_name = "snd-soc-dummy-dai",
5960 .codec_name = "snd-soc-dummy",
5961 },
5962 {
5963 .name = "AUXPCM Hostless",
5964 .stream_name = "AUXPCM Hostless",
5965 .cpu_dai_name = "AUXPCM_HOSTLESS",
5966 .platform_name = "msm-pcm-hostless",
5967 .dynamic = 1,
5968 .dpcm_playback = 1,
5969 .dpcm_capture = 1,
5970 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5971 SND_SOC_DPCM_TRIGGER_POST},
5972 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5973 .ignore_suspend = 1,
5974 /* this dainlink has playback support */
5975 .ignore_pmdown_time = 1,
5976 .codec_dai_name = "snd-soc-dummy-dai",
5977 .codec_name = "snd-soc-dummy",
5978 },
5979 {
5980 .name = MSM_DAILINK_NAME(Media20),
5981 .stream_name = "MultiMedia20",
5982 .cpu_dai_name = "MultiMedia20",
5983 .platform_name = "msm-pcm-loopback",
5984 .dynamic = 1,
5985 .dpcm_playback = 1,
5986 .dpcm_capture = 1,
5987 .codec_dai_name = "snd-soc-dummy-dai",
5988 .codec_name = "snd-soc-dummy",
5989 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5990 SND_SOC_DPCM_TRIGGER_POST},
5991 .ignore_suspend = 1,
5992 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
5993 /* this dainlink has playback support */
5994 .ignore_pmdown_time = 1,
5995 .id = MSM_FRONTEND_DAI_MULTIMEDIA20,
5996 },
5997};
5998
5999static struct snd_soc_dai_link msm_common_be_dai_links[] = {
6000 /* Backend AFE DAI Links */
6001 {
6002 .name = LPASS_BE_AFE_PCM_RX,
6003 .stream_name = "AFE Playback",
6004 .cpu_dai_name = "msm-dai-q6-dev.224",
6005 .platform_name = "msm-pcm-routing",
6006 .codec_name = "msm-stub-codec.1",
6007 .codec_dai_name = "msm-stub-rx",
6008 .no_pcm = 1,
6009 .dpcm_playback = 1,
6010 .id = MSM_BACKEND_DAI_AFE_PCM_RX,
6011 .be_hw_params_fixup = msm_be_hw_params_fixup,
6012 /* this dainlink has playback support */
6013 .ignore_pmdown_time = 1,
6014 .ignore_suspend = 1,
6015 },
6016 {
6017 .name = LPASS_BE_AFE_PCM_TX,
6018 .stream_name = "AFE Capture",
6019 .cpu_dai_name = "msm-dai-q6-dev.225",
6020 .platform_name = "msm-pcm-routing",
6021 .codec_name = "msm-stub-codec.1",
6022 .codec_dai_name = "msm-stub-tx",
6023 .no_pcm = 1,
6024 .dpcm_capture = 1,
6025 .id = MSM_BACKEND_DAI_AFE_PCM_TX,
6026 .be_hw_params_fixup = msm_be_hw_params_fixup,
6027 .ignore_suspend = 1,
6028 },
6029 /* Incall Record Uplink BACK END DAI Link */
6030 {
6031 .name = LPASS_BE_INCALL_RECORD_TX,
6032 .stream_name = "Voice Uplink Capture",
6033 .cpu_dai_name = "msm-dai-q6-dev.32772",
6034 .platform_name = "msm-pcm-routing",
6035 .codec_name = "msm-stub-codec.1",
6036 .codec_dai_name = "msm-stub-tx",
6037 .no_pcm = 1,
6038 .dpcm_capture = 1,
6039 .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
6040 .be_hw_params_fixup = msm_be_hw_params_fixup,
6041 .ignore_suspend = 1,
6042 },
6043 /* Incall Record Downlink BACK END DAI Link */
6044 {
6045 .name = LPASS_BE_INCALL_RECORD_RX,
6046 .stream_name = "Voice Downlink Capture",
6047 .cpu_dai_name = "msm-dai-q6-dev.32771",
6048 .platform_name = "msm-pcm-routing",
6049 .codec_name = "msm-stub-codec.1",
6050 .codec_dai_name = "msm-stub-tx",
6051 .no_pcm = 1,
6052 .dpcm_capture = 1,
6053 .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
6054 .be_hw_params_fixup = msm_be_hw_params_fixup,
6055 .ignore_suspend = 1,
6056 },
6057 /* Incall Music BACK END DAI Link */
6058 {
6059 .name = LPASS_BE_VOICE_PLAYBACK_TX,
6060 .stream_name = "Voice Farend Playback",
6061 .cpu_dai_name = "msm-dai-q6-dev.32773",
6062 .platform_name = "msm-pcm-routing",
6063 .codec_name = "msm-stub-codec.1",
6064 .codec_dai_name = "msm-stub-rx",
6065 .no_pcm = 1,
6066 .dpcm_playback = 1,
6067 .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
6068 .be_hw_params_fixup = msm_be_hw_params_fixup,
6069 .ignore_suspend = 1,
6070 .ignore_pmdown_time = 1,
6071 },
6072 /* Incall Music 2 BACK END DAI Link */
6073 {
6074 .name = LPASS_BE_VOICE2_PLAYBACK_TX,
6075 .stream_name = "Voice2 Farend Playback",
6076 .cpu_dai_name = "msm-dai-q6-dev.32770",
6077 .platform_name = "msm-pcm-routing",
6078 .codec_name = "msm-stub-codec.1",
6079 .codec_dai_name = "msm-stub-rx",
6080 .no_pcm = 1,
6081 .dpcm_playback = 1,
6082 .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
6083 .be_hw_params_fixup = msm_be_hw_params_fixup,
6084 .ignore_suspend = 1,
6085 .ignore_pmdown_time = 1,
6086 },
6087 {
6088 .name = LPASS_BE_USB_AUDIO_RX,
6089 .stream_name = "USB Audio Playback",
6090 .cpu_dai_name = "msm-dai-q6-dev.28672",
6091 .platform_name = "msm-pcm-routing",
6092 .codec_name = "msm-stub-codec.1",
6093 .codec_dai_name = "msm-stub-rx",
6094 .no_pcm = 1,
6095 .dpcm_playback = 1,
6096 .id = MSM_BACKEND_DAI_USB_RX,
6097 .be_hw_params_fixup = msm_be_hw_params_fixup,
6098 .ignore_pmdown_time = 1,
6099 .ignore_suspend = 1,
6100 },
6101 {
6102 .name = LPASS_BE_USB_AUDIO_TX,
6103 .stream_name = "USB Audio Capture",
6104 .cpu_dai_name = "msm-dai-q6-dev.28673",
6105 .platform_name = "msm-pcm-routing",
6106 .codec_name = "msm-stub-codec.1",
6107 .codec_dai_name = "msm-stub-tx",
6108 .no_pcm = 1,
6109 .dpcm_capture = 1,
6110 .id = MSM_BACKEND_DAI_USB_TX,
6111 .be_hw_params_fixup = msm_be_hw_params_fixup,
6112 .ignore_suspend = 1,
6113 },
6114 {
6115 .name = LPASS_BE_PRI_TDM_RX_0,
6116 .stream_name = "Primary TDM0 Playback",
6117 .cpu_dai_name = "msm-dai-q6-tdm.36864",
6118 .platform_name = "msm-pcm-routing",
6119 .codec_name = "msm-stub-codec.1",
6120 .codec_dai_name = "msm-stub-rx",
6121 .no_pcm = 1,
6122 .dpcm_playback = 1,
6123 .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
6124 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6125 .ops = &sa6155_tdm_be_ops,
6126 .ignore_suspend = 1,
6127 .ignore_pmdown_time = 1,
6128 },
6129 {
6130 .name = LPASS_BE_PRI_TDM_TX_0,
6131 .stream_name = "Primary TDM0 Capture",
6132 .cpu_dai_name = "msm-dai-q6-tdm.36865",
6133 .platform_name = "msm-pcm-routing",
6134 .codec_name = "msm-stub-codec.1",
6135 .codec_dai_name = "msm-stub-tx",
6136 .no_pcm = 1,
6137 .dpcm_capture = 1,
6138 .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
6139 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6140 .ops = &sa6155_tdm_be_ops,
6141 .ignore_suspend = 1,
6142 },
6143 {
6144 .name = LPASS_BE_SEC_TDM_RX_0,
6145 .stream_name = "Secondary TDM0 Playback",
6146 .cpu_dai_name = "msm-dai-q6-tdm.36880",
6147 .platform_name = "msm-pcm-routing",
6148 .codec_name = "msm-stub-codec.1",
6149 .codec_dai_name = "msm-stub-rx",
6150 .no_pcm = 1,
6151 .dpcm_playback = 1,
6152 .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
6153 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6154 .ops = &sa6155_tdm_be_ops,
6155 .ignore_suspend = 1,
6156 .ignore_pmdown_time = 1,
6157 },
6158 {
6159 .name = LPASS_BE_SEC_TDM_TX_0,
6160 .stream_name = "Secondary TDM0 Capture",
6161 .cpu_dai_name = "msm-dai-q6-tdm.36881",
6162 .platform_name = "msm-pcm-routing",
6163 .codec_name = "msm-stub-codec.1",
6164 .codec_dai_name = "msm-stub-tx",
6165 .no_pcm = 1,
6166 .dpcm_capture = 1,
6167 .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
6168 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6169 .ops = &sa6155_tdm_be_ops,
6170 .ignore_suspend = 1,
6171 },
6172 {
6173 .name = LPASS_BE_TERT_TDM_RX_0,
6174 .stream_name = "Tertiary TDM0 Playback",
6175 .cpu_dai_name = "msm-dai-q6-tdm.36896",
6176 .platform_name = "msm-pcm-routing",
6177 .codec_name = "msm-stub-codec.1",
6178 .codec_dai_name = "msm-stub-rx",
6179 .no_pcm = 1,
6180 .dpcm_playback = 1,
6181 .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
6182 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6183 .ops = &sa6155_tdm_be_ops,
6184 .ignore_suspend = 1,
6185 .ignore_pmdown_time = 1,
6186 },
6187 {
6188 .name = LPASS_BE_TERT_TDM_TX_0,
6189 .stream_name = "Tertiary TDM0 Capture",
6190 .cpu_dai_name = "msm-dai-q6-tdm.36897",
6191 .platform_name = "msm-pcm-routing",
6192 .codec_name = "msm-stub-codec.1",
6193 .codec_dai_name = "msm-stub-tx",
6194 .no_pcm = 1,
6195 .dpcm_capture = 1,
6196 .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
6197 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6198 .ops = &sa6155_tdm_be_ops,
6199 .ignore_suspend = 1,
6200 },
6201 {
6202 .name = LPASS_BE_QUAT_TDM_RX_0,
6203 .stream_name = "Quaternary TDM0 Playback",
6204 .cpu_dai_name = "msm-dai-q6-tdm.36912",
6205 .platform_name = "msm-pcm-routing",
6206 .codec_name = "msm-stub-codec.1",
6207 .codec_dai_name = "msm-stub-rx",
6208 .no_pcm = 1,
6209 .dpcm_playback = 1,
6210 .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
6211 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6212 .ops = &sa6155_tdm_be_ops,
6213 .ignore_suspend = 1,
6214 .ignore_pmdown_time = 1,
6215 },
6216 {
6217 .name = LPASS_BE_QUAT_TDM_TX_0,
6218 .stream_name = "Quaternary TDM0 Capture",
6219 .cpu_dai_name = "msm-dai-q6-tdm.36913",
6220 .platform_name = "msm-pcm-routing",
6221 .codec_name = "msm-stub-codec.1",
6222 .codec_dai_name = "msm-stub-tx",
6223 .no_pcm = 1,
6224 .dpcm_capture = 1,
6225 .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
6226 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6227 .ops = &sa6155_tdm_be_ops,
6228 .ignore_suspend = 1,
6229 },
Rahul Sharma51181d02019-04-12 17:03:01 +05306230 {
6231 .name = LPASS_BE_QUIN_TDM_RX_0,
6232 .stream_name = "Quinary TDM0 Playback",
6233 .cpu_dai_name = "msm-dai-q6-tdm.36928",
6234 .platform_name = "msm-pcm-routing",
6235 .codec_name = "msm-stub-codec.1",
6236 .codec_dai_name = "msm-stub-rx",
6237 .no_pcm = 1,
6238 .dpcm_playback = 1,
6239 .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
6240 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6241 .ops = &sa6155_tdm_be_ops,
6242 .ignore_suspend = 1,
6243 .ignore_pmdown_time = 1,
6244 },
6245 {
6246 .name = LPASS_BE_QUIN_TDM_TX_0,
6247 .stream_name = "Quinary TDM0 Capture",
6248 .cpu_dai_name = "msm-dai-q6-tdm.36929",
6249 .platform_name = "msm-pcm-routing",
6250 .codec_name = "msm-stub-codec.1",
6251 .codec_dai_name = "msm-stub-tx",
6252 .no_pcm = 1,
6253 .dpcm_capture = 1,
6254 .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
6255 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6256 .ops = &sa6155_tdm_be_ops,
6257 .ignore_suspend = 1,
6258 },
Rahul Sharma02bee732018-12-20 18:48:34 +05306259};
6260
6261static struct snd_soc_dai_link msm_auto_be_dai_links[] = {
6262 /* Backend DAI Links */
6263 {
6264 .name = LPASS_BE_PRI_TDM_RX_1,
6265 .stream_name = "Primary TDM1 Playback",
6266 .cpu_dai_name = "msm-dai-q6-tdm.36866",
6267 .platform_name = "msm-pcm-routing",
6268 .codec_name = "msm-stub-codec.1",
6269 .codec_dai_name = "msm-stub-rx",
6270 .no_pcm = 1,
6271 .dpcm_playback = 1,
6272 .id = MSM_BACKEND_DAI_PRI_TDM_RX_1,
6273 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6274 .ops = &sa6155_tdm_be_ops,
6275 .ignore_suspend = 1,
6276 },
6277 {
6278 .name = LPASS_BE_PRI_TDM_RX_2,
6279 .stream_name = "Primary TDM2 Playback",
6280 .cpu_dai_name = "msm-dai-q6-tdm.36868",
6281 .platform_name = "msm-pcm-routing",
6282 .codec_name = "msm-stub-codec.1",
6283 .codec_dai_name = "msm-stub-rx",
6284 .no_pcm = 1,
6285 .dpcm_playback = 1,
6286 .id = MSM_BACKEND_DAI_PRI_TDM_RX_2,
6287 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6288 .ops = &sa6155_tdm_be_ops,
6289 .ignore_suspend = 1,
6290 },
6291 {
6292 .name = LPASS_BE_PRI_TDM_RX_3,
6293 .stream_name = "Primary TDM3 Playback",
6294 .cpu_dai_name = "msm-dai-q6-tdm.36870",
6295 .platform_name = "msm-pcm-routing",
6296 .codec_name = "msm-stub-codec.1",
6297 .codec_dai_name = "msm-stub-rx",
6298 .no_pcm = 1,
6299 .dpcm_playback = 1,
6300 .id = MSM_BACKEND_DAI_PRI_TDM_RX_3,
6301 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6302 .ops = &sa6155_tdm_be_ops,
6303 .ignore_suspend = 1,
6304 },
6305 {
6306 .name = LPASS_BE_PRI_TDM_TX_1,
6307 .stream_name = "Primary TDM1 Capture",
6308 .cpu_dai_name = "msm-dai-q6-tdm.36867",
6309 .platform_name = "msm-pcm-routing",
6310 .codec_name = "msm-stub-codec.1",
6311 .codec_dai_name = "msm-stub-rx",
6312 .no_pcm = 1,
6313 .dpcm_capture = 1,
6314 .id = MSM_BACKEND_DAI_PRI_TDM_TX_1,
6315 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6316 .ops = &sa6155_tdm_be_ops,
6317 .ignore_suspend = 1,
6318 },
6319 {
6320 .name = LPASS_BE_PRI_TDM_TX_2,
6321 .stream_name = "Primary TDM2 Capture",
6322 .cpu_dai_name = "msm-dai-q6-tdm.36869",
6323 .platform_name = "msm-pcm-routing",
6324 .codec_name = "msm-stub-codec.1",
6325 .codec_dai_name = "msm-stub-rx",
6326 .no_pcm = 1,
6327 .dpcm_capture = 1,
6328 .id = MSM_BACKEND_DAI_PRI_TDM_TX_2,
6329 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6330 .ops = &sa6155_tdm_be_ops,
6331 .ignore_suspend = 1,
6332 },
6333 {
6334 .name = LPASS_BE_PRI_TDM_TX_3,
6335 .stream_name = "Primary TDM3 Capture",
6336 .cpu_dai_name = "msm-dai-q6-tdm.36871",
6337 .platform_name = "msm-pcm-routing",
6338 .codec_name = "msm-stub-codec.1",
6339 .codec_dai_name = "msm-stub-rx",
6340 .no_pcm = 1,
6341 .dpcm_capture = 1,
6342 .id = MSM_BACKEND_DAI_PRI_TDM_TX_3,
6343 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6344 .ops = &sa6155_tdm_be_ops,
6345 .ignore_suspend = 1,
6346 },
6347 {
6348 .name = LPASS_BE_SEC_TDM_RX_1,
6349 .stream_name = "Secondary TDM1 Playback",
6350 .cpu_dai_name = "msm-dai-q6-tdm.36882",
6351 .platform_name = "msm-pcm-routing",
6352 .codec_name = "msm-stub-codec.1",
6353 .codec_dai_name = "msm-stub-rx",
6354 .no_pcm = 1,
6355 .dpcm_playback = 1,
6356 .id = MSM_BACKEND_DAI_SEC_TDM_RX_1,
6357 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6358 .ops = &sa6155_tdm_be_ops,
6359 .ignore_suspend = 1,
6360 },
6361 {
6362 .name = LPASS_BE_SEC_TDM_RX_2,
6363 .stream_name = "Secondary TDM2 Playback",
6364 .cpu_dai_name = "msm-dai-q6-tdm.36884",
6365 .platform_name = "msm-pcm-routing",
6366 .codec_name = "msm-stub-codec.1",
6367 .codec_dai_name = "msm-stub-rx",
6368 .no_pcm = 1,
6369 .dpcm_playback = 1,
6370 .id = MSM_BACKEND_DAI_SEC_TDM_RX_2,
6371 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6372 .ops = &sa6155_tdm_be_ops,
6373 .ignore_suspend = 1,
6374 },
6375 {
6376 .name = LPASS_BE_SEC_TDM_RX_3,
6377 .stream_name = "Secondary TDM3 Playback",
6378 .cpu_dai_name = "msm-dai-q6-tdm.36886",
6379 .platform_name = "msm-pcm-routing",
6380 .codec_name = "msm-stub-codec.1",
6381 .codec_dai_name = "msm-stub-rx",
6382 .no_pcm = 1,
6383 .dpcm_playback = 1,
6384 .id = MSM_BACKEND_DAI_SEC_TDM_RX_3,
6385 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6386 .ops = &sa6155_tdm_be_ops,
6387 .ignore_suspend = 1,
6388 },
6389 {
Derek Chen0150b832019-06-05 18:46:29 +05306390 .name = LPASS_BE_SEC_TDM_RX_7,
6391 .stream_name = "Secondary TDM7 Playback",
6392 .cpu_dai_name = "msm-dai-q6-tdm.36894",
6393 .platform_name = "msm-pcm-routing",
6394 .codec_name = "msm-stub-codec.1",
6395 .codec_dai_name = "msm-stub-rx",
6396 .no_pcm = 1,
6397 .dpcm_playback = 1,
6398 .id = MSM_BACKEND_DAI_SEC_TDM_RX_7,
6399 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6400 .ops = &sa6155_tdm_be_ops,
6401 .ignore_suspend = 1,
6402 },
6403 {
Rahul Sharma02bee732018-12-20 18:48:34 +05306404 .name = LPASS_BE_SEC_TDM_TX_1,
6405 .stream_name = "Secondary TDM1 Capture",
6406 .cpu_dai_name = "msm-dai-q6-tdm.36883",
6407 .platform_name = "msm-pcm-routing",
6408 .codec_name = "msm-stub-codec.1",
6409 .codec_dai_name = "msm-stub-rx",
6410 .no_pcm = 1,
6411 .dpcm_capture = 1,
6412 .id = MSM_BACKEND_DAI_SEC_TDM_TX_1,
6413 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6414 .ops = &sa6155_tdm_be_ops,
6415 .ignore_suspend = 1,
6416 },
6417 {
6418 .name = LPASS_BE_SEC_TDM_TX_2,
6419 .stream_name = "Secondary TDM2 Capture",
6420 .cpu_dai_name = "msm-dai-q6-tdm.36885",
6421 .platform_name = "msm-pcm-routing",
6422 .codec_name = "msm-stub-codec.1",
6423 .codec_dai_name = "msm-stub-rx",
6424 .no_pcm = 1,
6425 .dpcm_capture = 1,
6426 .id = MSM_BACKEND_DAI_SEC_TDM_TX_2,
6427 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6428 .ops = &sa6155_tdm_be_ops,
6429 .ignore_suspend = 1,
6430 },
6431 {
6432 .name = LPASS_BE_SEC_TDM_TX_3,
6433 .stream_name = "Secondary TDM3 Capture",
6434 .cpu_dai_name = "msm-dai-q6-tdm.36887",
6435 .platform_name = "msm-pcm-routing",
6436 .codec_name = "msm-stub-codec.1",
6437 .codec_dai_name = "msm-stub-rx",
6438 .no_pcm = 1,
6439 .dpcm_capture = 1,
6440 .id = MSM_BACKEND_DAI_SEC_TDM_TX_3,
6441 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6442 .ops = &sa6155_tdm_be_ops,
6443 .ignore_suspend = 1,
6444 },
6445 {
6446 .name = LPASS_BE_TERT_TDM_RX_1,
6447 .stream_name = "Tertiary TDM1 Playback",
6448 .cpu_dai_name = "msm-dai-q6-tdm.36898",
6449 .platform_name = "msm-pcm-routing",
6450 .codec_name = "msm-stub-codec.1",
6451 .codec_dai_name = "msm-stub-rx",
6452 .no_pcm = 1,
6453 .dpcm_playback = 1,
6454 .id = MSM_BACKEND_DAI_TERT_TDM_RX_1,
6455 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6456 .ops = &sa6155_tdm_be_ops,
6457 .ignore_suspend = 1,
6458 },
6459 {
6460 .name = LPASS_BE_TERT_TDM_RX_2,
6461 .stream_name = "Tertiary TDM2 Playback",
6462 .cpu_dai_name = "msm-dai-q6-tdm.36900",
6463 .platform_name = "msm-pcm-routing",
6464 .codec_name = "msm-stub-codec.1",
6465 .codec_dai_name = "msm-stub-rx",
6466 .no_pcm = 1,
6467 .dpcm_playback = 1,
6468 .id = MSM_BACKEND_DAI_TERT_TDM_RX_2,
6469 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6470 .ops = &sa6155_tdm_be_ops,
6471 .ignore_suspend = 1,
6472 },
6473 {
6474 .name = LPASS_BE_TERT_TDM_RX_3,
6475 .stream_name = "Tertiary TDM3 Playback",
6476 .cpu_dai_name = "msm-dai-q6-tdm.36902",
6477 .platform_name = "msm-pcm-routing",
6478 .codec_name = "msm-stub-codec.1",
6479 .codec_dai_name = "msm-stub-rx",
6480 .no_pcm = 1,
6481 .dpcm_playback = 1,
6482 .id = MSM_BACKEND_DAI_TERT_TDM_RX_3,
6483 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6484 .ops = &sa6155_tdm_be_ops,
6485 .ignore_suspend = 1,
6486 },
6487 {
6488 .name = LPASS_BE_TERT_TDM_RX_4,
6489 .stream_name = "Tertiary TDM4 Playback",
6490 .cpu_dai_name = "msm-dai-q6-tdm.36904",
6491 .platform_name = "msm-pcm-routing",
6492 .codec_name = "msm-stub-codec.1",
6493 .codec_dai_name = "msm-stub-rx",
6494 .no_pcm = 1,
6495 .dpcm_playback = 1,
6496 .id = MSM_BACKEND_DAI_TERT_TDM_RX_4,
6497 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6498 .ops = &sa6155_tdm_be_ops,
6499 .ignore_suspend = 1,
6500 },
6501 {
6502 .name = LPASS_BE_TERT_TDM_TX_1,
6503 .stream_name = "Tertiary TDM1 Capture",
6504 .cpu_dai_name = "msm-dai-q6-tdm.36899",
6505 .platform_name = "msm-pcm-routing",
6506 .codec_name = "msm-stub-codec.1",
6507 .codec_dai_name = "msm-stub-rx",
6508 .no_pcm = 1,
6509 .dpcm_capture = 1,
6510 .id = MSM_BACKEND_DAI_TERT_TDM_TX_1,
6511 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6512 .ops = &sa6155_tdm_be_ops,
6513 .ignore_suspend = 1,
6514 },
6515 {
6516 .name = LPASS_BE_TERT_TDM_TX_2,
6517 .stream_name = "Tertiary TDM2 Capture",
6518 .cpu_dai_name = "msm-dai-q6-tdm.36901",
6519 .platform_name = "msm-pcm-routing",
6520 .codec_name = "msm-stub-codec.1",
6521 .codec_dai_name = "msm-stub-rx",
6522 .no_pcm = 1,
6523 .dpcm_capture = 1,
6524 .id = MSM_BACKEND_DAI_TERT_TDM_TX_2,
6525 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6526 .ops = &sa6155_tdm_be_ops,
6527 .ignore_suspend = 1,
6528 },
6529 {
6530 .name = LPASS_BE_TERT_TDM_TX_3,
6531 .stream_name = "Tertiary TDM3 Capture",
6532 .cpu_dai_name = "msm-dai-q6-tdm.36903",
6533 .platform_name = "msm-pcm-routing",
6534 .codec_name = "msm-stub-codec.1",
6535 .codec_dai_name = "msm-stub-rx",
6536 .no_pcm = 1,
6537 .dpcm_capture = 1,
6538 .id = MSM_BACKEND_DAI_TERT_TDM_TX_3,
6539 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6540 .ops = &sa6155_tdm_be_ops,
6541 .ignore_suspend = 1,
6542 },
6543 {
Derek Chen0150b832019-06-05 18:46:29 +05306544 .name = LPASS_BE_TERT_TDM_TX_7,
6545 .stream_name = "Tertiary TDM7 Capture",
6546 .cpu_dai_name = "msm-dai-q6-tdm.36911",
6547 .platform_name = "msm-pcm-routing",
6548 .codec_name = "msm-stub-codec.1",
6549 .codec_dai_name = "msm-stub-rx",
6550 .no_pcm = 1,
6551 .dpcm_capture = 1,
6552 .id = MSM_BACKEND_DAI_TERT_TDM_TX_7,
6553 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6554 .ops = &sa6155_tdm_be_ops,
6555 .ignore_suspend = 1,
6556 },
6557 {
Rahul Sharma02bee732018-12-20 18:48:34 +05306558 .name = LPASS_BE_QUAT_TDM_RX_1,
6559 .stream_name = "Quaternary TDM1 Playback",
6560 .cpu_dai_name = "msm-dai-q6-tdm.36914",
6561 .platform_name = "msm-pcm-routing",
6562 .codec_name = "msm-stub-codec.1",
6563 .codec_dai_name = "msm-stub-rx",
6564 .no_pcm = 1,
6565 .dpcm_playback = 1,
6566 .id = MSM_BACKEND_DAI_QUAT_TDM_RX_1,
6567 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6568 .ops = &sa6155_tdm_be_ops,
6569 .ignore_suspend = 1,
6570 },
6571 {
6572 .name = LPASS_BE_QUAT_TDM_RX_2,
6573 .stream_name = "Quaternary TDM2 Playback",
6574 .cpu_dai_name = "msm-dai-q6-tdm.36916",
6575 .platform_name = "msm-pcm-routing",
6576 .codec_name = "msm-stub-codec.1",
6577 .codec_dai_name = "msm-stub-rx",
6578 .no_pcm = 1,
6579 .dpcm_playback = 1,
6580 .id = MSM_BACKEND_DAI_QUAT_TDM_RX_2,
6581 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6582 .ops = &sa6155_tdm_be_ops,
6583 .ignore_suspend = 1,
6584 },
6585 {
6586 .name = LPASS_BE_QUAT_TDM_RX_3,
6587 .stream_name = "Quaternary TDM3 Playback",
6588 .cpu_dai_name = "msm-dai-q6-tdm.36918",
6589 .platform_name = "msm-pcm-routing",
6590 .codec_name = "msm-stub-codec.1",
6591 .codec_dai_name = "msm-stub-rx",
6592 .no_pcm = 1,
6593 .dpcm_playback = 1,
6594 .id = MSM_BACKEND_DAI_QUAT_TDM_RX_3,
6595 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6596 .ops = &sa6155_tdm_be_ops,
6597 .ignore_suspend = 1,
6598 },
6599 {
Derek Chen0150b832019-06-05 18:46:29 +05306600 .name = LPASS_BE_QUAT_TDM_RX_7,
6601 .stream_name = "Quaternary TDM7 Playback",
6602 .cpu_dai_name = "msm-dai-q6-tdm.36926",
6603 .platform_name = "msm-pcm-routing",
6604 .codec_name = "msm-stub-codec.1",
6605 .codec_dai_name = "msm-stub-rx",
6606 .no_pcm = 1,
6607 .dpcm_playback = 1,
6608 .id = MSM_BACKEND_DAI_QUAT_TDM_RX_7,
6609 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6610 .ops = &sa6155_tdm_be_ops,
6611 .ignore_suspend = 1,
6612 },
6613 {
Rahul Sharma02bee732018-12-20 18:48:34 +05306614 .name = LPASS_BE_QUAT_TDM_TX_1,
6615 .stream_name = "Quaternary TDM1 Capture",
6616 .cpu_dai_name = "msm-dai-q6-tdm.36915",
6617 .platform_name = "msm-pcm-routing",
6618 .codec_name = "msm-stub-codec.1",
6619 .codec_dai_name = "msm-stub-rx",
6620 .no_pcm = 1,
6621 .dpcm_capture = 1,
6622 .id = MSM_BACKEND_DAI_QUAT_TDM_TX_1,
6623 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6624 .ops = &sa6155_tdm_be_ops,
6625 .ignore_suspend = 1,
6626 },
6627 {
6628 .name = LPASS_BE_QUAT_TDM_TX_2,
6629 .stream_name = "Quaternary TDM2 Capture",
6630 .cpu_dai_name = "msm-dai-q6-tdm.36917",
6631 .platform_name = "msm-pcm-routing",
6632 .codec_name = "msm-stub-codec.1",
6633 .codec_dai_name = "msm-stub-rx",
6634 .no_pcm = 1,
6635 .dpcm_capture = 1,
6636 .id = MSM_BACKEND_DAI_QUAT_TDM_TX_2,
6637 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6638 .ops = &sa6155_tdm_be_ops,
6639 .ignore_suspend = 1,
6640 },
6641 {
6642 .name = LPASS_BE_QUAT_TDM_TX_3,
6643 .stream_name = "Quaternary TDM3 Capture",
6644 .cpu_dai_name = "msm-dai-q6-tdm.36919",
6645 .platform_name = "msm-pcm-routing",
6646 .codec_name = "msm-stub-codec.1",
6647 .codec_dai_name = "msm-stub-rx",
6648 .no_pcm = 1,
6649 .dpcm_capture = 1,
6650 .id = MSM_BACKEND_DAI_QUAT_TDM_TX_3,
6651 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6652 .ops = &sa6155_tdm_be_ops,
6653 .ignore_suspend = 1,
6654 },
Derek Chen0150b832019-06-05 18:46:29 +05306655 {
6656 .name = LPASS_BE_QUAT_TDM_TX_7,
6657 .stream_name = "Quaternary TDM7 Capture",
6658 .cpu_dai_name = "msm-dai-q6-tdm.36927",
6659 .platform_name = "msm-pcm-routing",
6660 .codec_name = "msm-stub-codec.1",
6661 .codec_dai_name = "msm-stub-rx",
6662 .no_pcm = 1,
6663 .dpcm_capture = 1,
6664 .id = MSM_BACKEND_DAI_QUAT_TDM_TX_7,
6665 .be_hw_params_fixup = msm_tdm_be_hw_params_fixup,
6666 .ops = &sa6155_tdm_be_ops,
6667 .ignore_suspend = 1,
6668 },
Rahul Sharma02bee732018-12-20 18:48:34 +05306669};
6670
6671static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
6672 /* DISP PORT BACK END DAI Link */
6673 {
6674 .name = LPASS_BE_DISPLAY_PORT,
6675 .stream_name = "Display Port Playback",
6676 .cpu_dai_name = "msm-dai-q6-dp.24608",
6677 .platform_name = "msm-pcm-routing",
6678 .codec_name = "msm-ext-disp-audio-codec-rx",
6679 .codec_dai_name = "msm_dp_audio_codec_rx_dai",
6680 .no_pcm = 1,
6681 .dpcm_playback = 1,
6682 .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
6683 .be_hw_params_fixup = msm_be_hw_params_fixup,
6684 .ignore_pmdown_time = 1,
6685 .ignore_suspend = 1,
6686 },
6687};
6688
6689static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
6690 {
6691 .name = LPASS_BE_PRI_MI2S_RX,
6692 .stream_name = "Primary MI2S Playback",
6693 .cpu_dai_name = "msm-dai-q6-mi2s.0",
6694 .platform_name = "msm-pcm-routing",
6695 .codec_name = "msm-stub-codec.1",
6696 .codec_dai_name = "msm-stub-rx",
6697 .no_pcm = 1,
6698 .dpcm_playback = 1,
6699 .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
6700 .be_hw_params_fixup = msm_be_hw_params_fixup,
6701 .ops = &msm_mi2s_be_ops,
6702 .ignore_suspend = 1,
6703 .ignore_pmdown_time = 1,
6704 },
6705 {
6706 .name = LPASS_BE_PRI_MI2S_TX,
6707 .stream_name = "Primary MI2S Capture",
6708 .cpu_dai_name = "msm-dai-q6-mi2s.0",
6709 .platform_name = "msm-pcm-routing",
6710 .codec_name = "msm-stub-codec.1",
6711 .codec_dai_name = "msm-stub-tx",
6712 .no_pcm = 1,
6713 .dpcm_capture = 1,
6714 .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
6715 .be_hw_params_fixup = msm_be_hw_params_fixup,
6716 .ops = &msm_mi2s_be_ops,
6717 .ignore_suspend = 1,
6718 },
6719 {
6720 .name = LPASS_BE_SEC_MI2S_RX,
6721 .stream_name = "Secondary MI2S Playback",
6722 .cpu_dai_name = "msm-dai-q6-mi2s.1",
6723 .platform_name = "msm-pcm-routing",
6724 .codec_name = "msm-stub-codec.1",
6725 .codec_dai_name = "msm-stub-rx",
6726 .no_pcm = 1,
6727 .dpcm_playback = 1,
6728 .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
6729 .be_hw_params_fixup = msm_be_hw_params_fixup,
6730 .ops = &msm_mi2s_be_ops,
6731 .ignore_suspend = 1,
6732 .ignore_pmdown_time = 1,
6733 },
6734 {
6735 .name = LPASS_BE_SEC_MI2S_TX,
6736 .stream_name = "Secondary MI2S Capture",
6737 .cpu_dai_name = "msm-dai-q6-mi2s.1",
6738 .platform_name = "msm-pcm-routing",
6739 .codec_name = "msm-stub-codec.1",
6740 .codec_dai_name = "msm-stub-tx",
6741 .no_pcm = 1,
6742 .dpcm_capture = 1,
6743 .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
6744 .be_hw_params_fixup = msm_be_hw_params_fixup,
6745 .ops = &msm_mi2s_be_ops,
6746 .ignore_suspend = 1,
6747 },
6748 {
6749 .name = LPASS_BE_TERT_MI2S_RX,
6750 .stream_name = "Tertiary MI2S Playback",
6751 .cpu_dai_name = "msm-dai-q6-mi2s.2",
6752 .platform_name = "msm-pcm-routing",
6753 .codec_name = "msm-stub-codec.1",
6754 .codec_dai_name = "msm-stub-rx",
6755 .no_pcm = 1,
6756 .dpcm_playback = 1,
6757 .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
6758 .be_hw_params_fixup = msm_be_hw_params_fixup,
6759 .ops = &msm_mi2s_be_ops,
6760 .ignore_suspend = 1,
6761 .ignore_pmdown_time = 1,
6762 },
6763 {
6764 .name = LPASS_BE_TERT_MI2S_TX,
6765 .stream_name = "Tertiary MI2S Capture",
6766 .cpu_dai_name = "msm-dai-q6-mi2s.2",
6767 .platform_name = "msm-pcm-routing",
6768 .codec_name = "msm-stub-codec.1",
6769 .codec_dai_name = "msm-stub-tx",
6770 .no_pcm = 1,
6771 .dpcm_capture = 1,
6772 .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
6773 .be_hw_params_fixup = msm_be_hw_params_fixup,
6774 .ops = &msm_mi2s_be_ops,
6775 .ignore_suspend = 1,
6776 },
6777 {
6778 .name = LPASS_BE_QUAT_MI2S_RX,
6779 .stream_name = "Quaternary MI2S Playback",
6780 .cpu_dai_name = "msm-dai-q6-mi2s.3",
6781 .platform_name = "msm-pcm-routing",
6782 .codec_name = "msm-stub-codec.1",
6783 .codec_dai_name = "msm-stub-rx",
6784 .no_pcm = 1,
6785 .dpcm_playback = 1,
6786 .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
6787 .be_hw_params_fixup = msm_be_hw_params_fixup,
6788 .ops = &msm_mi2s_be_ops,
6789 .ignore_suspend = 1,
6790 .ignore_pmdown_time = 1,
6791 },
6792 {
6793 .name = LPASS_BE_QUAT_MI2S_TX,
6794 .stream_name = "Quaternary MI2S Capture",
6795 .cpu_dai_name = "msm-dai-q6-mi2s.3",
6796 .platform_name = "msm-pcm-routing",
6797 .codec_name = "msm-stub-codec.1",
6798 .codec_dai_name = "msm-stub-tx",
6799 .no_pcm = 1,
6800 .dpcm_capture = 1,
6801 .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
6802 .be_hw_params_fixup = msm_be_hw_params_fixup,
6803 .ops = &msm_mi2s_be_ops,
6804 .ignore_suspend = 1,
6805 },
6806 {
6807 .name = LPASS_BE_QUIN_MI2S_RX,
6808 .stream_name = "Quinary MI2S Playback",
6809 .cpu_dai_name = "msm-dai-q6-mi2s.4",
6810 .platform_name = "msm-pcm-routing",
6811 .codec_name = "msm-stub-codec.1",
6812 .codec_dai_name = "msm-stub-rx",
6813 .no_pcm = 1,
6814 .dpcm_playback = 1,
6815 .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
6816 .be_hw_params_fixup = msm_be_hw_params_fixup,
6817 .ops = &msm_mi2s_be_ops,
6818 .ignore_suspend = 1,
6819 .ignore_pmdown_time = 1,
6820 },
6821 {
6822 .name = LPASS_BE_QUIN_MI2S_TX,
6823 .stream_name = "Quinary MI2S Capture",
6824 .cpu_dai_name = "msm-dai-q6-mi2s.4",
6825 .platform_name = "msm-pcm-routing",
6826 .codec_name = "msm-stub-codec.1",
6827 .codec_dai_name = "msm-stub-tx",
6828 .no_pcm = 1,
6829 .dpcm_capture = 1,
6830 .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
6831 .be_hw_params_fixup = msm_be_hw_params_fixup,
6832 .ops = &msm_mi2s_be_ops,
6833 .ignore_suspend = 1,
6834 },
6835};
6836
6837static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
6838 /* Primary AUX PCM Backend DAI Links */
6839 {
6840 .name = LPASS_BE_AUXPCM_RX,
6841 .stream_name = "AUX PCM Playback",
6842 .cpu_dai_name = "msm-dai-q6-auxpcm.1",
6843 .platform_name = "msm-pcm-routing",
6844 .codec_name = "msm-stub-codec.1",
6845 .codec_dai_name = "msm-stub-rx",
6846 .no_pcm = 1,
6847 .dpcm_playback = 1,
6848 .id = MSM_BACKEND_DAI_AUXPCM_RX,
6849 .be_hw_params_fixup = msm_be_hw_params_fixup,
6850 .ignore_pmdown_time = 1,
6851 .ignore_suspend = 1,
6852 },
6853 {
6854 .name = LPASS_BE_AUXPCM_TX,
6855 .stream_name = "AUX PCM Capture",
6856 .cpu_dai_name = "msm-dai-q6-auxpcm.1",
6857 .platform_name = "msm-pcm-routing",
6858 .codec_name = "msm-stub-codec.1",
6859 .codec_dai_name = "msm-stub-tx",
6860 .no_pcm = 1,
6861 .dpcm_capture = 1,
6862 .id = MSM_BACKEND_DAI_AUXPCM_TX,
6863 .be_hw_params_fixup = msm_be_hw_params_fixup,
6864 .ignore_suspend = 1,
6865 },
6866 /* Secondary AUX PCM Backend DAI Links */
6867 {
6868 .name = LPASS_BE_SEC_AUXPCM_RX,
6869 .stream_name = "Sec AUX PCM Playback",
6870 .cpu_dai_name = "msm-dai-q6-auxpcm.2",
6871 .platform_name = "msm-pcm-routing",
6872 .codec_name = "msm-stub-codec.1",
6873 .codec_dai_name = "msm-stub-rx",
6874 .no_pcm = 1,
6875 .dpcm_playback = 1,
6876 .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
6877 .be_hw_params_fixup = msm_be_hw_params_fixup,
6878 .ignore_pmdown_time = 1,
6879 .ignore_suspend = 1,
6880 },
6881 {
6882 .name = LPASS_BE_SEC_AUXPCM_TX,
6883 .stream_name = "Sec AUX PCM Capture",
6884 .cpu_dai_name = "msm-dai-q6-auxpcm.2",
6885 .platform_name = "msm-pcm-routing",
6886 .codec_name = "msm-stub-codec.1",
6887 .codec_dai_name = "msm-stub-tx",
6888 .no_pcm = 1,
6889 .dpcm_capture = 1,
6890 .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
6891 .be_hw_params_fixup = msm_be_hw_params_fixup,
6892 .ignore_suspend = 1,
6893 },
6894 /* Tertiary AUX PCM Backend DAI Links */
6895 {
6896 .name = LPASS_BE_TERT_AUXPCM_RX,
6897 .stream_name = "Tert AUX PCM Playback",
6898 .cpu_dai_name = "msm-dai-q6-auxpcm.3",
6899 .platform_name = "msm-pcm-routing",
6900 .codec_name = "msm-stub-codec.1",
6901 .codec_dai_name = "msm-stub-rx",
6902 .no_pcm = 1,
6903 .dpcm_playback = 1,
6904 .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
6905 .be_hw_params_fixup = msm_be_hw_params_fixup,
6906 .ignore_suspend = 1,
6907 },
6908 {
6909 .name = LPASS_BE_TERT_AUXPCM_TX,
6910 .stream_name = "Tert AUX PCM Capture",
6911 .cpu_dai_name = "msm-dai-q6-auxpcm.3",
6912 .platform_name = "msm-pcm-routing",
6913 .codec_name = "msm-stub-codec.1",
6914 .codec_dai_name = "msm-stub-tx",
6915 .no_pcm = 1,
6916 .dpcm_capture = 1,
6917 .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
6918 .be_hw_params_fixup = msm_be_hw_params_fixup,
6919 .ignore_suspend = 1,
6920 },
6921 /* Quaternary AUX PCM Backend DAI Links */
6922 {
6923 .name = LPASS_BE_QUAT_AUXPCM_RX,
6924 .stream_name = "Quat AUX PCM Playback",
6925 .cpu_dai_name = "msm-dai-q6-auxpcm.4",
6926 .platform_name = "msm-pcm-routing",
6927 .codec_name = "msm-stub-codec.1",
6928 .codec_dai_name = "msm-stub-rx",
6929 .no_pcm = 1,
6930 .dpcm_playback = 1,
6931 .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
6932 .be_hw_params_fixup = msm_be_hw_params_fixup,
6933 .ignore_pmdown_time = 1,
6934 .ignore_suspend = 1,
6935 },
6936 {
6937 .name = LPASS_BE_QUAT_AUXPCM_TX,
6938 .stream_name = "Quat AUX PCM Capture",
6939 .cpu_dai_name = "msm-dai-q6-auxpcm.4",
6940 .platform_name = "msm-pcm-routing",
6941 .codec_name = "msm-stub-codec.1",
6942 .codec_dai_name = "msm-stub-tx",
6943 .no_pcm = 1,
6944 .dpcm_capture = 1,
6945 .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
6946 .be_hw_params_fixup = msm_be_hw_params_fixup,
6947 .ignore_suspend = 1,
6948 },
6949 /* Quinary AUX PCM Backend DAI Links */
6950 {
6951 .name = LPASS_BE_QUIN_AUXPCM_RX,
6952 .stream_name = "Quin AUX PCM Playback",
6953 .cpu_dai_name = "msm-dai-q6-auxpcm.5",
6954 .platform_name = "msm-pcm-routing",
6955 .codec_name = "msm-stub-codec.1",
6956 .codec_dai_name = "msm-stub-rx",
6957 .no_pcm = 1,
6958 .dpcm_playback = 1,
6959 .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
6960 .be_hw_params_fixup = msm_be_hw_params_fixup,
6961 .ignore_pmdown_time = 1,
6962 .ignore_suspend = 1,
6963 },
6964 {
6965 .name = LPASS_BE_QUIN_AUXPCM_TX,
6966 .stream_name = "Quin AUX PCM Capture",
6967 .cpu_dai_name = "msm-dai-q6-auxpcm.5",
6968 .platform_name = "msm-pcm-routing",
6969 .codec_name = "msm-stub-codec.1",
6970 .codec_dai_name = "msm-stub-tx",
6971 .no_pcm = 1,
6972 .dpcm_capture = 1,
6973 .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
6974 .be_hw_params_fixup = msm_be_hw_params_fixup,
6975 .ignore_suspend = 1,
6976 },
6977};
6978
6979static struct snd_soc_dai_link msm_auto_dai_links[
6980 ARRAY_SIZE(msm_common_dai_links) +
6981 ARRAY_SIZE(msm_auto_fe_dai_links) +
6982 ARRAY_SIZE(msm_common_be_dai_links) +
6983 ARRAY_SIZE(msm_auto_be_dai_links) +
6984 ARRAY_SIZE(ext_disp_be_dai_link) +
6985 ARRAY_SIZE(msm_mi2s_be_dai_links) +
6986 ARRAY_SIZE(msm_auxpcm_be_dai_links)];
6987
6988static struct snd_soc_dai_link msm_auto_custom_dai_links[
6989 ARRAY_SIZE(msm_custom_fe_dai_links) +
6990 ARRAY_SIZE(msm_auto_fe_dai_links) +
6991 ARRAY_SIZE(msm_common_be_dai_links) +
6992 ARRAY_SIZE(msm_auto_be_dai_links) +
6993 ARRAY_SIZE(ext_disp_be_dai_link) +
6994 ARRAY_SIZE(msm_mi2s_be_dai_links) +
6995 ARRAY_SIZE(msm_auxpcm_be_dai_links)];
6996
6997struct snd_soc_card snd_soc_card_auto_msm = {
6998 .name = "sa6155-adp-star-snd-card",
6999};
7000
7001struct snd_soc_card snd_soc_card_auto_custom_msm = {
7002 .name = "sa6155-custom-snd-card",
7003};
7004
7005static int msm_populate_dai_link_component_of_node(
7006 struct snd_soc_card *card)
7007{
7008 int i, index, ret = 0;
7009 struct device *cdev = card->dev;
7010 struct snd_soc_dai_link *dai_link = card->dai_link;
7011 struct device_node *np;
7012
7013 if (!cdev) {
7014 pr_err("%s: Sound card device memory NULL\n", __func__);
7015 return -ENODEV;
7016 }
7017
7018 for (i = 0; i < card->num_links; i++) {
7019 if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
7020 continue;
7021
7022 /* populate platform_of_node for snd card dai links */
7023 if (dai_link[i].platform_name &&
7024 !dai_link[i].platform_of_node) {
7025 index = of_property_match_string(cdev->of_node,
7026 "asoc-platform-names",
7027 dai_link[i].platform_name);
7028 if (index < 0) {
7029 pr_err("%s: No match found for platform name: %s\n",
7030 __func__, dai_link[i].platform_name);
7031 ret = index;
7032 goto err;
7033 }
7034 np = of_parse_phandle(cdev->of_node, "asoc-platform",
7035 index);
7036 if (!np) {
7037 pr_err("%s: retrieving phandle for platform %s, index %d failed\n",
7038 __func__, dai_link[i].platform_name,
7039 index);
7040 ret = -ENODEV;
7041 goto err;
7042 }
7043 dai_link[i].platform_of_node = np;
7044 dai_link[i].platform_name = NULL;
7045 }
7046
7047 /* populate cpu_of_node for snd card dai links */
7048 if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
7049 index = of_property_match_string(cdev->of_node,
7050 "asoc-cpu-names",
7051 dai_link[i].cpu_dai_name);
7052 if (index >= 0) {
7053 np = of_parse_phandle(cdev->of_node, "asoc-cpu",
7054 index);
7055 if (!np) {
7056 pr_err("%s: retrieving phandle for cpu dai %s failed\n",
7057 __func__,
7058 dai_link[i].cpu_dai_name);
7059 ret = -ENODEV;
7060 goto err;
7061 }
7062 dai_link[i].cpu_of_node = np;
7063 dai_link[i].cpu_dai_name = NULL;
7064 }
7065 }
7066
7067 /* populate codec_of_node for snd card dai links */
7068 if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
7069 index = of_property_match_string(cdev->of_node,
7070 "asoc-codec-names",
7071 dai_link[i].codec_name);
7072 if (index < 0)
7073 continue;
7074 np = of_parse_phandle(cdev->of_node, "asoc-codec",
7075 index);
7076 if (!np) {
7077 pr_err("%s: retrieving phandle for codec %s failed\n",
7078 __func__, dai_link[i].codec_name);
7079 ret = -ENODEV;
7080 goto err;
7081 }
7082 dai_link[i].codec_of_node = np;
7083 dai_link[i].codec_name = NULL;
7084 }
7085 }
7086
7087err:
7088 return ret;
7089}
7090
7091static const struct of_device_id sa6155_asoc_machine_of_match[] = {
7092 { .compatible = "qcom,sa6155-asoc-snd-adp-star",
7093 .data = "adp_star_codec"},
7094 { .compatible = "qcom,sa6155-asoc-snd-custom",
7095 .data = "custom_codec"},
7096 {},
7097};
7098
7099static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
7100{
7101 struct snd_soc_card *card = NULL;
7102 struct snd_soc_dai_link *dailink;
7103 int len_1, len_2, len_3;
7104 int total_links;
7105 const struct of_device_id *match;
7106
7107 match = of_match_node(sa6155_asoc_machine_of_match, dev->of_node);
7108 if (!match) {
7109 dev_err(dev, "%s: No DT match found for sound card\n",
7110 __func__);
7111 return NULL;
7112 }
7113
7114 if (!strcmp(match->data, "adp_star_codec")) {
7115 card = &snd_soc_card_auto_msm;
7116 len_1 = ARRAY_SIZE(msm_common_dai_links);
7117 len_2 = len_1 + ARRAY_SIZE(msm_auto_fe_dai_links);
7118 len_3 = len_2 + ARRAY_SIZE(msm_common_be_dai_links);
7119 total_links = len_3 + ARRAY_SIZE(msm_auto_be_dai_links);
7120 memcpy(msm_auto_dai_links,
7121 msm_common_dai_links,
7122 sizeof(msm_common_dai_links));
7123 memcpy(msm_auto_dai_links + len_1,
7124 msm_auto_fe_dai_links,
7125 sizeof(msm_auto_fe_dai_links));
7126 memcpy(msm_auto_dai_links + len_2,
7127 msm_common_be_dai_links,
7128 sizeof(msm_common_be_dai_links));
7129 memcpy(msm_auto_dai_links + len_3,
7130 msm_auto_be_dai_links,
7131 sizeof(msm_auto_be_dai_links));
7132
7133 if (of_property_read_bool(dev->of_node,
7134 "qcom,ext-disp-audio-rx")) {
7135 dev_dbg(dev, "%s(): ext disp audio support present\n",
7136 __func__);
7137 memcpy(msm_auto_dai_links + total_links,
7138 ext_disp_be_dai_link,
7139 sizeof(ext_disp_be_dai_link));
7140 total_links += ARRAY_SIZE(ext_disp_be_dai_link);
7141 }
7142 if (of_property_read_bool(dev->of_node,
7143 "qcom,mi2s-audio-intf")) {
7144 memcpy(msm_auto_dai_links + total_links,
7145 msm_mi2s_be_dai_links,
7146 sizeof(msm_mi2s_be_dai_links));
7147 total_links += ARRAY_SIZE(msm_mi2s_be_dai_links);
7148 }
7149 if (of_property_read_bool(dev->of_node,
7150 "qcom,auxpcm-audio-intf")) {
7151 memcpy(msm_auto_dai_links + total_links,
7152 msm_auxpcm_be_dai_links,
7153 sizeof(msm_auxpcm_be_dai_links));
7154 total_links += ARRAY_SIZE(msm_auxpcm_be_dai_links);
7155 }
7156
7157 dailink = msm_auto_dai_links;
7158 } else if (!strcmp(match->data, "custom_codec")) {
7159 card = &snd_soc_card_auto_custom_msm;
7160 len_1 = ARRAY_SIZE(msm_custom_fe_dai_links);
7161 len_2 = len_1 + ARRAY_SIZE(msm_auto_fe_dai_links);
7162 len_3 = len_2 + ARRAY_SIZE(msm_common_be_dai_links);
7163 total_links = len_3 + ARRAY_SIZE(msm_auto_be_dai_links);
7164 memcpy(msm_auto_custom_dai_links,
7165 msm_custom_fe_dai_links,
7166 sizeof(msm_custom_fe_dai_links));
7167 memcpy(msm_auto_custom_dai_links + len_1,
7168 msm_auto_fe_dai_links,
7169 sizeof(msm_auto_fe_dai_links));
7170 memcpy(msm_auto_custom_dai_links + len_2,
7171 msm_common_be_dai_links,
7172 sizeof(msm_common_be_dai_links));
7173 memcpy(msm_auto_custom_dai_links + len_3,
7174 msm_auto_be_dai_links,
7175 sizeof(msm_auto_be_dai_links));
7176
7177 if (of_property_read_bool(dev->of_node,
7178 "qcom,ext-disp-audio-rx")) {
7179 dev_dbg(dev, "%s(): ext disp audio support present\n",
7180 __func__);
7181 memcpy(msm_auto_custom_dai_links + total_links,
7182 ext_disp_be_dai_link,
7183 sizeof(ext_disp_be_dai_link));
7184 total_links += ARRAY_SIZE(ext_disp_be_dai_link);
7185 }
7186 if (of_property_read_bool(dev->of_node,
7187 "qcom,mi2s-audio-intf")) {
7188 memcpy(msm_auto_custom_dai_links + total_links,
7189 msm_mi2s_be_dai_links,
7190 sizeof(msm_mi2s_be_dai_links));
7191 total_links += ARRAY_SIZE(msm_mi2s_be_dai_links);
7192 }
7193 if (of_property_read_bool(dev->of_node,
7194 "qcom,auxpcm-audio-intf")) {
7195 memcpy(msm_auto_custom_dai_links + total_links,
7196 msm_auxpcm_be_dai_links,
7197 sizeof(msm_auxpcm_be_dai_links));
7198 total_links += ARRAY_SIZE(msm_auxpcm_be_dai_links);
7199 }
7200 dailink = msm_auto_custom_dai_links;
7201 } else {
7202 dev_err(dev, "%s: Codec not supported\n",
7203 __func__);
7204 return NULL;
7205 }
7206
7207 if (card) {
7208 card->dai_link = dailink;
7209 card->num_links = total_links;
7210 }
7211
7212 return card;
7213}
7214
7215/*****************************************************************************
7216* TO BE UPDATED: Codec/Platform specific tdm slot and offset table selection
7217*****************************************************************************/
Derek Chen7bb78312019-06-18 00:36:55 -07007218static int msm_tdm_init(struct platform_device *pdev)
Rahul Sharma02bee732018-12-20 18:48:34 +05307219{
Derek Chen7bb78312019-06-18 00:36:55 -07007220 struct snd_soc_card *card = platform_get_drvdata(pdev);
7221 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
Rahul Sharma02bee732018-12-20 18:48:34 +05307222 const struct of_device_id *match;
Derek Chen7bb78312019-06-18 00:36:55 -07007223 int count;
Rahul Sharma02bee732018-12-20 18:48:34 +05307224
Derek Chen7bb78312019-06-18 00:36:55 -07007225 match = of_match_node(sa6155_asoc_machine_of_match, pdev->dev.of_node);
Rahul Sharma02bee732018-12-20 18:48:34 +05307226 if (!match) {
Derek Chen7bb78312019-06-18 00:36:55 -07007227 dev_err(&pdev->dev, "%s: No DT match found for sound card\n",
Rahul Sharma02bee732018-12-20 18:48:34 +05307228 __func__);
7229 return -EINVAL;
7230 }
7231
7232 if (!strcmp(match->data, "custom_codec")) {
Derek Chen7bb78312019-06-18 00:36:55 -07007233 dev_dbg(&pdev->dev, "%s: custom tdm configuration\n", __func__);
Rahul Sharma02bee732018-12-20 18:48:34 +05307234
7235 memcpy(tdm_rx_slot_offset,
7236 tdm_rx_slot_offset_custom,
7237 sizeof(tdm_rx_slot_offset_custom));
7238 memcpy(tdm_tx_slot_offset,
7239 tdm_tx_slot_offset_custom,
7240 sizeof(tdm_tx_slot_offset_custom));
7241 memcpy(tdm_slot,
7242 tdm_slot_custom,
7243 sizeof(tdm_slot_custom));
7244 } else {
Derek Chen7bb78312019-06-18 00:36:55 -07007245 dev_dbg(&pdev->dev, "%s: default tdm configuration\n", __func__);
7246 }
7247
7248 for (count = 0; count < TDM_INTERFACE_MAX; count++) {
7249 mutex_init(&pdata->tdm_intf_conf[count].lock);
7250 pdata->tdm_intf_conf[count].ref_cnt = 0;
Rahul Sharma02bee732018-12-20 18:48:34 +05307251 }
7252
7253 return 0;
7254}
7255
Derek Chen7bb78312019-06-18 00:36:55 -07007256static void msm_tdm_deinit(struct platform_device *pdev)
7257{
7258 struct snd_soc_card *card = platform_get_drvdata(pdev);
7259 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
7260 int count;
7261
7262 for (count = 0; count < TDM_INTERFACE_MAX; count++) {
7263 mutex_destroy(&pdata->tdm_intf_conf[count].lock);
7264 pdata->tdm_intf_conf[count].ref_cnt = 0;
7265 }
7266}
7267
Rahul Sharma02bee732018-12-20 18:48:34 +05307268static void msm_i2s_auxpcm_init(struct platform_device *pdev)
7269{
Derek Chen7bb78312019-06-18 00:36:55 -07007270 struct snd_soc_card *card = platform_get_drvdata(pdev);
7271 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
Rahul Sharma02bee732018-12-20 18:48:34 +05307272 int count;
7273 u32 mi2s_master_slave[MI2S_MAX];
7274 int ret;
7275
7276 for (count = 0; count < MI2S_MAX; count++) {
Derek Chen7bb78312019-06-18 00:36:55 -07007277 mutex_init(&pdata->mi2s_intf_conf[count].lock);
7278 pdata->mi2s_intf_conf[count].ref_cnt = 0;
Rahul Sharma02bee732018-12-20 18:48:34 +05307279 }
7280
7281 ret = of_property_read_u32_array(pdev->dev.of_node,
7282 "qcom,msm-mi2s-master",
7283 mi2s_master_slave, MI2S_MAX);
7284 if (ret) {
7285 dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
7286 __func__);
7287 } else {
7288 for (count = 0; count < MI2S_MAX; count++) {
Derek Chen7bb78312019-06-18 00:36:55 -07007289 pdata->mi2s_intf_conf[count].msm_is_mi2s_master =
Rahul Sharma02bee732018-12-20 18:48:34 +05307290 mi2s_master_slave[count];
7291 }
7292 }
7293}
7294
Derek Chen7bb78312019-06-18 00:36:55 -07007295static void msm_i2s_auxpcm_deinit(struct platform_device *pdev)
Rahul Sharma02bee732018-12-20 18:48:34 +05307296{
Derek Chen7bb78312019-06-18 00:36:55 -07007297 struct snd_soc_card *card = platform_get_drvdata(pdev);
7298 struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
Rahul Sharma02bee732018-12-20 18:48:34 +05307299 int count;
7300
7301 for (count = 0; count < MI2S_MAX; count++) {
Derek Chen7bb78312019-06-18 00:36:55 -07007302 mutex_destroy(&pdata->mi2s_intf_conf[count].lock);
7303 pdata->mi2s_intf_conf[count].ref_cnt = 0;
7304 pdata->mi2s_intf_conf[count].msm_is_mi2s_master = 0;
Rahul Sharma02bee732018-12-20 18:48:34 +05307305 }
7306}
Erin Yan300664f2019-05-14 10:42:31 +08007307
7308static int sa6155_ssr_enable(struct device *dev, void *data)
7309{
7310 struct platform_device *pdev = to_platform_device(dev);
7311 struct snd_soc_card *card = platform_get_drvdata(pdev);
7312 int ret = 0;
7313
7314 if (!card) {
7315 dev_err(dev, "%s: card is NULL\n", __func__);
7316 ret = -EINVAL;
7317 goto err;
7318 }
7319
7320 dev_info(dev, "%s: setting snd_card to ONLINE\n", __func__);
7321 snd_soc_card_change_online_state(card, 1);
7322
7323err:
7324 return ret;
7325}
7326
7327static void sa6155_ssr_disable(struct device *dev, void *data)
7328{
7329 struct platform_device *pdev = to_platform_device(dev);
7330 struct snd_soc_card *card = platform_get_drvdata(pdev);
7331
7332 if (!card) {
7333 dev_err(dev, "%s: card is NULL\n", __func__);
7334 return;
7335 }
7336
7337 dev_info(dev, "%s: setting snd_card to OFFLINE\n", __func__);
7338 snd_soc_card_change_online_state(card, 0);
7339}
7340
7341static const struct snd_event_ops sa6155_ssr_ops = {
7342 .enable = sa6155_ssr_enable,
7343 .disable = sa6155_ssr_disable,
7344};
7345
7346static int msm_audio_ssr_compare(struct device *dev, void *data)
7347{
7348 struct device_node *node = data;
7349
7350 dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
7351 __func__, dev->of_node, node);
7352 return (dev->of_node && dev->of_node == node);
7353}
7354
7355static int msm_audio_ssr_register(struct device *dev)
7356{
7357 struct device_node *np = dev->of_node;
7358 struct snd_event_clients *ssr_clients = NULL;
7359 struct device_node *node;
7360 int ret;
7361 int i;
7362
7363 for (i = 0; ; i++) {
7364 node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
7365 if (!node)
7366 break;
7367 snd_event_mstr_add_client(&ssr_clients,
7368 msm_audio_ssr_compare, node);
7369 }
7370
7371 ret = snd_event_master_register(dev, &sa6155_ssr_ops,
7372 ssr_clients, NULL);
7373 if (!ret)
7374 snd_event_notify(dev, SND_EVENT_UP);
7375
7376 return ret;
7377}
7378
Rahul Sharma02bee732018-12-20 18:48:34 +05307379static int msm_asoc_machine_probe(struct platform_device *pdev)
7380{
7381 struct snd_soc_card *card;
7382 struct msm_asoc_mach_data *pdata;
7383 int ret;
7384 enum apr_subsys_state q6_state;
7385
7386 if (!pdev->dev.of_node) {
7387 dev_err(&pdev->dev, "No platform supplied from device tree\n");
7388 return -EINVAL;
7389 }
7390
7391 q6_state = apr_get_q6_state();
7392 if (q6_state == APR_SUBSYS_DOWN) {
7393 dev_dbg(&pdev->dev, "deferring %s, adsp_state %d\n",
7394 __func__, q6_state);
7395 return -EPROBE_DEFER;
7396 }
7397
7398 pdata = devm_kzalloc(&pdev->dev,
7399 sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
7400 if (!pdata)
7401 return -ENOMEM;
7402
7403 card = populate_snd_card_dailinks(&pdev->dev);
7404 if (!card) {
7405 dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
7406 ret = -EINVAL;
7407 goto err;
7408 }
7409 card->dev = &pdev->dev;
7410 platform_set_drvdata(pdev, card);
7411 snd_soc_card_set_drvdata(card, pdata);
7412
7413 ret = snd_soc_of_parse_card_name(card, "qcom,model");
7414 if (ret) {
7415 dev_err(&pdev->dev, "parse card name failed, err:%d\n",
7416 ret);
7417 goto err;
7418 }
7419
7420 ret = msm_populate_dai_link_component_of_node(card);
7421 if (ret) {
7422 ret = -EPROBE_DEFER;
7423 goto err;
7424 }
7425
7426 /* Populate controls of snd card */
7427 card->controls = msm_snd_controls;
7428 card->num_controls = ARRAY_SIZE(msm_snd_controls);
7429
Derek Chen7bb78312019-06-18 00:36:55 -07007430 ret = msm_tdm_init(pdev);
Rahul Sharma02bee732018-12-20 18:48:34 +05307431 if (ret) {
7432 ret = -EPROBE_DEFER;
7433 goto err;
7434 }
7435
7436 ret = devm_snd_soc_register_card(&pdev->dev, card);
7437 if (ret == -EPROBE_DEFER) {
7438 goto err;
7439 } else if (ret) {
7440 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n",
7441 ret);
7442 goto err;
7443 }
7444 dev_info(&pdev->dev, "Sound card %s registered\n", card->name);
7445
7446 /* Parse pinctrl info from devicetree */
7447 ret = msm_get_pinctrl(pdev);
7448 if (!ret) {
7449 pr_debug("%s: pinctrl parsing successful\n", __func__);
7450 } else {
7451 dev_dbg(&pdev->dev,
Derek Chen7bb78312019-06-18 00:36:55 -07007452 "%s: pinctrl parsing failed with %d\n",
Rahul Sharma02bee732018-12-20 18:48:34 +05307453 __func__, ret);
7454 ret = 0;
7455 }
7456
7457 msm_i2s_auxpcm_init(pdev);
7458
Erin Yan300664f2019-05-14 10:42:31 +08007459 ret = msm_audio_ssr_register(&pdev->dev);
7460 if (ret)
7461 pr_err("%s: Registration with SND event FWK failed ret = %d\n",
7462 __func__, ret);
7463
Rahul Sharma02bee732018-12-20 18:48:34 +05307464 return 0;
7465err:
7466 msm_release_pinctrl(pdev);
7467 devm_kfree(&pdev->dev, pdata);
7468 return ret;
7469}
7470
7471static int msm_asoc_machine_remove(struct platform_device *pdev)
7472{
Derek Chen7bb78312019-06-18 00:36:55 -07007473 msm_i2s_auxpcm_deinit(pdev);
7474 msm_tdm_deinit(pdev);
Rahul Sharma02bee732018-12-20 18:48:34 +05307475
7476 msm_release_pinctrl(pdev);
7477 return 0;
7478}
7479
7480static struct platform_driver sa6155_asoc_machine_driver = {
7481 .driver = {
7482 .name = DRV_NAME,
7483 .owner = THIS_MODULE,
7484 .pm = &snd_soc_pm_ops,
7485 .of_match_table = sa6155_asoc_machine_of_match,
7486 },
7487 .probe = msm_asoc_machine_probe,
7488 .remove = msm_asoc_machine_remove,
7489};
7490
Rahul Sharma02bee732018-12-20 18:48:34 +05307491int __init sa6155_init(void)
7492{
7493 pr_debug("%s\n", __func__);
Rahul Sharma02bee732018-12-20 18:48:34 +05307494 return platform_driver_register(&sa6155_asoc_machine_driver);
7495}
7496
7497void sa6155_exit(void)
7498{
7499 pr_debug("%s\n", __func__);
7500 platform_driver_unregister(&sa6155_asoc_machine_driver);
Rahul Sharma02bee732018-12-20 18:48:34 +05307501}
7502
Rahul Sharmaf53de7f2019-03-03 22:30:47 +05307503module_init(sa6155_init);
7504module_exit(sa6155_exit);
7505
Rahul Sharma02bee732018-12-20 18:48:34 +05307506MODULE_DESCRIPTION("ALSA SoC msm");
7507MODULE_LICENSE("GPL v2");
7508MODULE_ALIAS("platform:" DRV_NAME);
7509MODULE_DEVICE_TABLE(of, sa6155_asoc_machine_of_match);