blob: 574c652464cd0124d477dfc99c78e284f1264ba0 [file] [log] [blame]
Meng Wang688a8672019-01-29 13:43:33 +08001// SPDX-License-Identifier: GPL-2.0-only
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07002/*
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08003 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07004 */
5
6#include <linux/clk.h>
7#include <linux/delay.h>
8#include <linux/gpio.h>
9#include <linux/of_gpio.h>
10#include <linux/platform_device.h>
11#include <linux/slab.h>
12#include <linux/io.h>
13#include <linux/module.h>
14#include <linux/input.h>
15#include <linux/of_device.h>
Karthikeyan Mani5eb13422018-11-05 13:49:17 -080016#include <linux/soc/qcom/fsa4480-i2c.h>
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -070017#include <sound/core.h>
18#include <sound/soc.h>
19#include <sound/soc-dapm.h>
20#include <sound/pcm.h>
21#include <sound/pcm_params.h>
22#include <sound/info.h>
Vignesh Kulothungan483a5592018-10-19 15:00:08 -070023#include <soc/snd_event.h>
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -070024#include <dsp/audio_notifier.h>
Karthikeyan Mani7eef68e2018-12-13 17:45:02 -080025#include <soc/swr-common.h>
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -070026#include <dsp/q6afe-v2.h>
27#include <dsp/q6core.h>
28#include "device_event.h"
29#include "msm-pcm-routing-v2.h"
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -070030#include "asoc/msm-cdc-pinctrl.h"
31#include "asoc/wcd-mbhc-v2.h"
Karthikeyan Mani5eb13422018-11-05 13:49:17 -080032#include "codecs/wcd938x/wcd938x-mbhc.h"
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -070033#include "codecs/wsa881x.h"
Karthikeyan Mani5eb13422018-11-05 13:49:17 -080034#include "codecs/wcd938x/wcd938x.h"
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -070035#include "codecs/bolero/bolero-cdc.h"
36#include <dt-bindings/sound/audio-codec-port-types.h>
37#include "codecs/bolero/wsa-macro.h"
Karthikeyan Mani7eef68e2018-12-13 17:45:02 -080038#include "sm8250-port-config.h"
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -070039
40#define DRV_NAME "kona-asoc-snd"
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -070041#define __CHIPSET__ "KONA "
42#define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
43
44#define SAMPLING_RATE_8KHZ 8000
Vignesh Kulothungan483a5592018-10-19 15:00:08 -070045#define SAMPLING_RATE_11P025KHZ 11025
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -070046#define SAMPLING_RATE_16KHZ 16000
Vignesh Kulothungan483a5592018-10-19 15:00:08 -070047#define SAMPLING_RATE_22P05KHZ 22050
48#define SAMPLING_RATE_32KHZ 32000
49#define SAMPLING_RATE_44P1KHZ 44100
50#define SAMPLING_RATE_48KHZ 48000
51#define SAMPLING_RATE_88P2KHZ 88200
52#define SAMPLING_RATE_96KHZ 96000
53#define SAMPLING_RATE_176P4KHZ 176400
54#define SAMPLING_RATE_192KHZ 192000
55#define SAMPLING_RATE_352P8KHZ 352800
56#define SAMPLING_RATE_384KHZ 384000
57
Karthikeyan Mani5eb13422018-11-05 13:49:17 -080058#define WCD9XXX_MBHC_DEF_RLOADS 5
59#define WCD9XXX_MBHC_DEF_BUTTONS 8
60#define CODEC_EXT_CLK_RATE 9600000
61#define ADSP_STATE_READY_TIMEOUT_MS 3000
62#define DEV_NAME_STR_LEN 32
63#define WCD_MBHC_HS_V_MAX 1600
64
Vignesh Kulothungan483a5592018-10-19 15:00:08 -070065#define TDM_CHANNEL_MAX 8
66#define DEV_NAME_STR_LEN 32
67
68#define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
69
70#define ADSP_STATE_READY_TIMEOUT_MS 3000
71
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -070072#define WSA8810_NAME_1 "wsa881x.20170211"
73#define WSA8810_NAME_2 "wsa881x.20170212"
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -080074#define WCN_CDC_SLIM_RX_CH_MAX 2
75#define WCN_CDC_SLIM_TX_CH_MAX 2
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -070076
Vignesh Kulothungan483a5592018-10-19 15:00:08 -070077enum {
78 TDM_0 = 0,
79 TDM_1,
80 TDM_2,
81 TDM_3,
82 TDM_4,
83 TDM_5,
84 TDM_6,
85 TDM_7,
86 TDM_PORT_MAX,
87};
88
89enum {
90 TDM_PRI = 0,
91 TDM_SEC,
92 TDM_TERT,
93 TDM_INTERFACE_MAX,
94};
95
96enum {
97 PRIM_AUX_PCM = 0,
98 SEC_AUX_PCM,
99 TERT_AUX_PCM,
100 AUX_PCM_MAX,
101};
102
103enum {
104 PRIM_MI2S = 0,
105 SEC_MI2S,
106 TERT_MI2S,
107 MI2S_MAX,
108};
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700109
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700110enum {
111 WSA_CDC_DMA_RX_0 = 0,
112 WSA_CDC_DMA_RX_1,
113 RX_CDC_DMA_RX_0,
114 RX_CDC_DMA_RX_1,
115 RX_CDC_DMA_RX_2,
116 RX_CDC_DMA_RX_3,
117 RX_CDC_DMA_RX_5,
118 CDC_DMA_RX_MAX,
119};
120
121enum {
122 WSA_CDC_DMA_TX_0 = 0,
123 WSA_CDC_DMA_TX_1,
124 WSA_CDC_DMA_TX_2,
125 TX_CDC_DMA_TX_0,
126 TX_CDC_DMA_TX_3,
127 TX_CDC_DMA_TX_4,
Xiaoyu Ye2228bf02018-12-12 15:47:20 -0800128 VA_CDC_DMA_TX_0,
129 VA_CDC_DMA_TX_1,
130 VA_CDC_DMA_TX_2,
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700131 CDC_DMA_TX_MAX,
132};
133
Banajit Goswami83a370d2019-03-05 16:15:21 -0800134enum {
135 SLIM_RX_7 = 0,
136 SLIM_RX_MAX,
137};
138enum {
139 SLIM_TX_7 = 0,
140 SLIM_TX_MAX,
141};
142
Meng Wange8e53822019-03-18 10:49:50 +0800143enum {
144 AFE_LOOPBACK_TX_IDX = 0,
145 AFE_LOOPBACK_TX_IDX_MAX,
146};
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700147struct msm_asoc_mach_data {
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700148 struct snd_info_entry *codec_root;
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700149 int usbc_en2_gpio; /* used by gpio driver API */
150 struct device_node *dmic01_gpio_p; /* used by pinctrl API */
151 struct device_node *dmic23_gpio_p; /* used by pinctrl API */
152 struct device_node *dmic45_gpio_p; /* used by pinctrl API */
153 struct device_node *us_euro_gpio_p; /* used by pinctrl API */
154 struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
155 struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
156 struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
157 bool is_afe_config_done;
Karthikeyan Mani5eb13422018-11-05 13:49:17 -0800158 struct device_node *fsa_handle;
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700159};
160
161struct tdm_port {
162 u32 mode;
163 u32 channel;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700164};
165
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -0800166enum {
167 EXT_DISP_RX_IDX_DP = 0,
168 EXT_DISP_RX_IDX_MAX,
169};
170
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700171struct msm_wsa881x_dev_info {
172 struct device_node *of_node;
173 u32 index;
174};
175
176struct aux_codec_dev_info {
177 struct device_node *of_node;
178 u32 index;
179};
180
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700181struct dev_config {
182 u32 sample_rate;
183 u32 bit_format;
184 u32 channels;
185};
186
Banajit Goswami83a370d2019-03-05 16:15:21 -0800187/* Default configuration of slimbus channels */
188static struct dev_config slim_rx_cfg[] = {
189 [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
190};
191
192static struct dev_config slim_tx_cfg[] = {
193 [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
194};
195
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -0800196/* Default configuration of external display BE */
197static struct dev_config ext_disp_rx_cfg[] = {
198 [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
199};
200
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700201static struct dev_config usb_rx_cfg = {
202 .sample_rate = SAMPLING_RATE_48KHZ,
203 .bit_format = SNDRV_PCM_FORMAT_S16_LE,
204 .channels = 2,
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700205};
206
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700207static struct dev_config usb_tx_cfg = {
208 .sample_rate = SAMPLING_RATE_48KHZ,
209 .bit_format = SNDRV_PCM_FORMAT_S16_LE,
210 .channels = 1,
211};
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700212
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700213static struct dev_config proxy_rx_cfg = {
214 .sample_rate = SAMPLING_RATE_48KHZ,
215 .bit_format = SNDRV_PCM_FORMAT_S16_LE,
216 .channels = 2,
217};
218
219static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
220 {
221 AFE_API_VERSION_I2S_CONFIG,
222 Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
223 Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
224 Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
225 Q6AFE_LPASS_CLK_ROOT_DEFAULT,
226 0,
227 },
228 {
229 AFE_API_VERSION_I2S_CONFIG,
230 Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
231 Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
232 Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
233 Q6AFE_LPASS_CLK_ROOT_DEFAULT,
234 0,
235 },
236 {
237 AFE_API_VERSION_I2S_CONFIG,
238 Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
239 Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
240 Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
241 Q6AFE_LPASS_CLK_ROOT_DEFAULT,
242 0,
243 },
244};
245
246struct mi2s_conf {
247 struct mutex lock;
248 u32 ref_cnt;
249 u32 msm_is_mi2s_master;
250};
251
252static u32 mi2s_ebit_clk[MI2S_MAX] = {
253 Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
254 Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
255 Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
256};
257
258static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
259
260/* Default configuration of TDM channels */
261static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
262 { /* PRI TDM */
263 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
264 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
265 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
266 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
267 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
268 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
269 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
270 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
271 },
272 { /* SEC TDM */
273 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
274 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
275 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
276 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
277 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
278 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
279 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
280 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
281 },
282 { /* TERT TDM */
283 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
284 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
285 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
286 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
287 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
288 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
289 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
290 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
291 },
292};
293
294static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
295 { /* PRI TDM */
296 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
297 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
298 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
299 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
300 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
301 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
302 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
303 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
304 },
305 { /* SEC TDM */
306 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
307 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
308 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
309 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
310 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
311 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
312 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
313 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
314 },
315 { /* TERT TDM */
316 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
317 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
318 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
319 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
320 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
321 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
322 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
323 {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
324 },
325};
326
327/* Default configuration of AUX PCM channels */
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700328static struct dev_config aux_pcm_rx_cfg[] = {
329 [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700330 [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
331 [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700332};
333
334static struct dev_config aux_pcm_tx_cfg[] = {
335 [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700336 [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
337 [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700338};
339
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700340/* Default configuration of MI2S channels */
341static struct dev_config mi2s_rx_cfg[] = {
342 [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
343 [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
344 [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
345};
346
347static struct dev_config mi2s_tx_cfg[] = {
348 [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
349 [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
350 [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
351};
352
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700353/* Default configuration of Codec DMA Interface RX */
354static struct dev_config cdc_dma_rx_cfg[] = {
355 [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
356 [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
357 [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
358 [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
359 [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
360 [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
361 [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
362};
363
364/* Default configuration of Codec DMA Interface TX */
365static struct dev_config cdc_dma_tx_cfg[] = {
366 [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
367 [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
368 [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
369 [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
370 [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
371 [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
Xiaoyu Ye2228bf02018-12-12 15:47:20 -0800372 [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
373 [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
374 [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700375};
376
Meng Wange8e53822019-03-18 10:49:50 +0800377static struct dev_config afe_loopback_tx_cfg[] = {
378 [AFE_LOOPBACK_TX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
379};
380
Meng Wangd1db67c2019-04-17 12:41:34 +0800381static int msm_vi_feed_tx_ch = 2;
382static const char *const vi_feed_ch_text[] = {"One", "Two"};
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700383static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
384 "S32_LE"};
385static char const *ch_text[] = {"Two", "Three", "Four", "Five",
386 "Six", "Seven", "Eight"};
387static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
388 "KHZ_16", "KHZ_22P05",
389 "KHZ_32", "KHZ_44P1", "KHZ_48",
390 "KHZ_88P2", "KHZ_96", "KHZ_176P4",
391 "KHZ_192", "KHZ_352P8", "KHZ_384"};
392static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
393 "Five", "Six", "Seven",
394 "Eight"};
395static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
396 "KHZ_48", "KHZ_176P4",
397 "KHZ_352P8"};
398static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
399static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
400 "Five", "Six", "Seven", "Eight"};
401static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
402static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
403 "KHZ_22P05", "KHZ_32", "KHZ_44P1",
404 "KHZ_48", "KHZ_96", "KHZ_192"};
405static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
406 "Five", "Six", "Seven",
407 "Eight"};
408
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700409static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
410static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
411 "Five", "Six", "Seven",
412 "Eight"};
413static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
414 "KHZ_16", "KHZ_22P05",
415 "KHZ_32", "KHZ_44P1", "KHZ_48",
416 "KHZ_88P2", "KHZ_96",
417 "KHZ_176P4", "KHZ_192",
418 "KHZ_352P8", "KHZ_384"};
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -0800419static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
420 "S24_3LE"};
421static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
422 "KHZ_192", "KHZ_32", "KHZ_44P1",
423 "KHZ_88P2", "KHZ_176P4"};
Banajit Goswami83a370d2019-03-05 16:15:21 -0800424static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
425 "KHZ_44P1", "KHZ_48",
426 "KHZ_88P2", "KHZ_96"};
427static char const *bt_sample_rate_rx_text[] = {"KHZ_8", "KHZ_16",
428 "KHZ_44P1", "KHZ_48",
429 "KHZ_88P2", "KHZ_96"};
430static char const *bt_sample_rate_tx_text[] = {"KHZ_8", "KHZ_16",
431 "KHZ_44P1", "KHZ_48",
432 "KHZ_88P2", "KHZ_96"};
Meng Wange8e53822019-03-18 10:49:50 +0800433static const char *const afe_loopback_tx_ch_text[] = {"One", "Two"};
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700434
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700435static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
436static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
437static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
438static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
439static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
440static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
Meng Wangd1db67c2019-04-17 12:41:34 +0800441static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700442static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
443static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
444static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
445static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
446static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
447static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
448static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700449static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700450static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
451static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700452static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700453static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
454static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700455static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
456static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700457static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
458static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
459static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
460static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
461static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
462static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
463static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
464static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
465static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
466static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
467static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
468static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
469static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
470static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700471static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
472static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
473static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
474static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
475static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
476static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
477static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
478static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
479static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
480static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
481static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
482static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
483static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
Xiaoyu Ye2228bf02018-12-12 15:47:20 -0800484static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
485static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
486static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700487static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
488static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
489static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_format, bit_format_text);
490static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_format, bit_format_text);
491static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_format, bit_format_text);
492static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_format, bit_format_text);
493static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_format, bit_format_text);
494static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
495static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
496static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
497static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
498static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
Xiaoyu Ye2228bf02018-12-12 15:47:20 -0800499static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
500static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
501static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700502static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
503 cdc_dma_sample_rate_text);
504static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
505 cdc_dma_sample_rate_text);
506static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_sample_rate,
507 cdc_dma_sample_rate_text);
508static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_sample_rate,
509 cdc_dma_sample_rate_text);
510static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_sample_rate,
511 cdc_dma_sample_rate_text);
512static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_sample_rate,
513 cdc_dma_sample_rate_text);
514static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_sample_rate,
515 cdc_dma_sample_rate_text);
516static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
517 cdc_dma_sample_rate_text);
518static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
519 cdc_dma_sample_rate_text);
520static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
521 cdc_dma_sample_rate_text);
522static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
523 cdc_dma_sample_rate_text);
524static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
525 cdc_dma_sample_rate_text);
526static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
527 cdc_dma_sample_rate_text);
Xiaoyu Ye2228bf02018-12-12 15:47:20 -0800528static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
529 cdc_dma_sample_rate_text);
530static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
531 cdc_dma_sample_rate_text);
532static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
533 cdc_dma_sample_rate_text);
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -0800534static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
535static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
536static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
537 ext_disp_sample_rate_text);
Banajit Goswami83a370d2019-03-05 16:15:21 -0800538static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
539static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_rx, bt_sample_rate_rx_text);
540static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text);
Meng Wange8e53822019-03-18 10:49:50 +0800541static SOC_ENUM_SINGLE_EXT_DECL(afe_loopback_tx_chs, afe_loopback_tx_ch_text);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700542
543static bool is_initial_boot;
544static bool codec_reg_done;
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700545static struct snd_soc_aux_dev *msm_aux_dev;
546static struct snd_soc_codec_conf *msm_codec_conf;
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700547static struct snd_soc_card snd_soc_card_kona_msm;
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -0700548static int dmic_0_1_gpio_cnt;
549static int dmic_2_3_gpio_cnt;
550static int dmic_4_5_gpio_cnt;
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700551
Karthikeyan Mani5eb13422018-11-05 13:49:17 -0800552static void *def_wcd_mbhc_cal(void);
553
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700554/*
555 * Need to report LINEIN
556 * if R/L channel impedance is larger than 5K ohm
557 */
558static struct wcd_mbhc_config wcd_mbhc_cfg = {
559 .read_fw_bin = false,
560 .calibration = NULL,
561 .detect_extn_cable = true,
562 .mono_stero_detection = false,
563 .swap_gnd_mic = NULL,
564 .hs_ext_micbias = true,
565 .key_code[0] = KEY_MEDIA,
566 .key_code[1] = KEY_VOICECOMMAND,
567 .key_code[2] = KEY_VOLUMEUP,
568 .key_code[3] = KEY_VOLUMEDOWN,
569 .key_code[4] = 0,
570 .key_code[5] = 0,
571 .key_code[6] = 0,
572 .key_code[7] = 0,
573 .linein_th = 5000,
574 .moisture_en = true,
575 .mbhc_micbias = MIC_BIAS_2,
576 .anc_micbias = MIC_BIAS_2,
577 .enable_anc_mic_detect = false,
578};
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700579
580static inline int param_is_mask(int p)
581{
582 return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
583 (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
584}
585
586static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
587 int n)
588{
589 return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
590}
591
592static void param_set_mask(struct snd_pcm_hw_params *p, int n,
593 unsigned int bit)
594{
595 if (bit >= SNDRV_MASK_MAX)
596 return;
597 if (param_is_mask(n)) {
598 struct snd_mask *m = param_to_mask(p, n);
599
600 m->bits[0] = 0;
601 m->bits[1] = 0;
602 m->bits[bit >> 5] |= (1 << (bit & 31));
603 }
604}
605
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700606static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_value *ucontrol)
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700608{
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700609 int sample_rate_val = 0;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700610
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700611 switch (usb_rx_cfg.sample_rate) {
612 case SAMPLING_RATE_384KHZ:
613 sample_rate_val = 12;
614 break;
615 case SAMPLING_RATE_352P8KHZ:
616 sample_rate_val = 11;
617 break;
618 case SAMPLING_RATE_192KHZ:
619 sample_rate_val = 10;
620 break;
621 case SAMPLING_RATE_176P4KHZ:
622 sample_rate_val = 9;
623 break;
624 case SAMPLING_RATE_96KHZ:
625 sample_rate_val = 8;
626 break;
627 case SAMPLING_RATE_88P2KHZ:
628 sample_rate_val = 7;
629 break;
630 case SAMPLING_RATE_48KHZ:
631 sample_rate_val = 6;
632 break;
633 case SAMPLING_RATE_44P1KHZ:
634 sample_rate_val = 5;
635 break;
636 case SAMPLING_RATE_32KHZ:
637 sample_rate_val = 4;
638 break;
639 case SAMPLING_RATE_22P05KHZ:
640 sample_rate_val = 3;
641 break;
642 case SAMPLING_RATE_16KHZ:
643 sample_rate_val = 2;
644 break;
645 case SAMPLING_RATE_11P025KHZ:
646 sample_rate_val = 1;
647 break;
648 case SAMPLING_RATE_8KHZ:
649 default:
650 sample_rate_val = 0;
651 break;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700652 }
653
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700654 ucontrol->value.integer.value[0] = sample_rate_val;
655 pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
656 usb_rx_cfg.sample_rate);
657 return 0;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -0700658}
659
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700660static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_value *ucontrol)
662{
663 switch (ucontrol->value.integer.value[0]) {
664 case 12:
665 usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
666 break;
667 case 11:
668 usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
669 break;
670 case 10:
671 usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
672 break;
673 case 9:
674 usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
675 break;
676 case 8:
677 usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
678 break;
679 case 7:
680 usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
681 break;
682 case 6:
683 usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
684 break;
685 case 5:
686 usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
687 break;
688 case 4:
689 usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
690 break;
691 case 3:
692 usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
693 break;
694 case 2:
695 usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
696 break;
697 case 1:
698 usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
699 break;
700 case 0:
701 usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
702 break;
703 default:
704 usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
705 break;
706 }
707
708 pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
709 __func__, ucontrol->value.integer.value[0],
710 usb_rx_cfg.sample_rate);
711 return 0;
712}
713
714static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
715 struct snd_ctl_elem_value *ucontrol)
716{
717 int sample_rate_val = 0;
718
719 switch (usb_tx_cfg.sample_rate) {
720 case SAMPLING_RATE_384KHZ:
721 sample_rate_val = 12;
722 break;
723 case SAMPLING_RATE_352P8KHZ:
724 sample_rate_val = 11;
725 break;
726 case SAMPLING_RATE_192KHZ:
727 sample_rate_val = 10;
728 break;
729 case SAMPLING_RATE_176P4KHZ:
730 sample_rate_val = 9;
731 break;
732 case SAMPLING_RATE_96KHZ:
733 sample_rate_val = 8;
734 break;
735 case SAMPLING_RATE_88P2KHZ:
736 sample_rate_val = 7;
737 break;
738 case SAMPLING_RATE_48KHZ:
739 sample_rate_val = 6;
740 break;
741 case SAMPLING_RATE_44P1KHZ:
742 sample_rate_val = 5;
743 break;
744 case SAMPLING_RATE_32KHZ:
745 sample_rate_val = 4;
746 break;
747 case SAMPLING_RATE_22P05KHZ:
748 sample_rate_val = 3;
749 break;
750 case SAMPLING_RATE_16KHZ:
751 sample_rate_val = 2;
752 break;
753 case SAMPLING_RATE_11P025KHZ:
754 sample_rate_val = 1;
755 break;
756 case SAMPLING_RATE_8KHZ:
757 sample_rate_val = 0;
758 break;
759 default:
760 sample_rate_val = 6;
761 break;
762 }
763
764 ucontrol->value.integer.value[0] = sample_rate_val;
765 pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
766 usb_tx_cfg.sample_rate);
767 return 0;
768}
769
770static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
771 struct snd_ctl_elem_value *ucontrol)
772{
773 switch (ucontrol->value.integer.value[0]) {
774 case 12:
775 usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
776 break;
777 case 11:
778 usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
779 break;
780 case 10:
781 usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
782 break;
783 case 9:
784 usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
785 break;
786 case 8:
787 usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
788 break;
789 case 7:
790 usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
791 break;
792 case 6:
793 usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
794 break;
795 case 5:
796 usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
797 break;
798 case 4:
799 usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
800 break;
801 case 3:
802 usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
803 break;
804 case 2:
805 usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
806 break;
807 case 1:
808 usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
809 break;
810 case 0:
811 usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
812 break;
813 default:
814 usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
815 break;
816 }
817
818 pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
819 __func__, ucontrol->value.integer.value[0],
820 usb_tx_cfg.sample_rate);
821 return 0;
822}
Meng Wange8e53822019-03-18 10:49:50 +0800823static int afe_loopback_tx_ch_get(struct snd_kcontrol *kcontrol,
824 struct snd_ctl_elem_value *ucontrol)
825{
826 pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
827 afe_loopback_tx_cfg[0].channels);
828 ucontrol->value.enumerated.item[0] =
829 afe_loopback_tx_cfg[0].channels - 1;
830
831 return 0;
832}
833
834static int afe_loopback_tx_ch_put(struct snd_kcontrol *kcontrol,
835 struct snd_ctl_elem_value *ucontrol)
836{
837 afe_loopback_tx_cfg[0].channels =
838 ucontrol->value.enumerated.item[0] + 1;
839 pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
840 afe_loopback_tx_cfg[0].channels);
841
842 return 1;
843}
Vignesh Kulothungan483a5592018-10-19 15:00:08 -0700844
845static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
846 struct snd_ctl_elem_value *ucontrol)
847{
848 switch (usb_rx_cfg.bit_format) {
849 case SNDRV_PCM_FORMAT_S32_LE:
850 ucontrol->value.integer.value[0] = 3;
851 break;
852 case SNDRV_PCM_FORMAT_S24_3LE:
853 ucontrol->value.integer.value[0] = 2;
854 break;
855 case SNDRV_PCM_FORMAT_S24_LE:
856 ucontrol->value.integer.value[0] = 1;
857 break;
858 case SNDRV_PCM_FORMAT_S16_LE:
859 default:
860 ucontrol->value.integer.value[0] = 0;
861 break;
862 }
863
864 pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
865 __func__, usb_rx_cfg.bit_format,
866 ucontrol->value.integer.value[0]);
867 return 0;
868}
869
870static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
871 struct snd_ctl_elem_value *ucontrol)
872{
873 int rc = 0;
874
875 switch (ucontrol->value.integer.value[0]) {
876 case 3:
877 usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
878 break;
879 case 2:
880 usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
881 break;
882 case 1:
883 usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
884 break;
885 case 0:
886 default:
887 usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
888 break;
889 }
890 pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
891 __func__, usb_rx_cfg.bit_format,
892 ucontrol->value.integer.value[0]);
893
894 return rc;
895}
896
897static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
898 struct snd_ctl_elem_value *ucontrol)
899{
900 switch (usb_tx_cfg.bit_format) {
901 case SNDRV_PCM_FORMAT_S32_LE:
902 ucontrol->value.integer.value[0] = 3;
903 break;
904 case SNDRV_PCM_FORMAT_S24_3LE:
905 ucontrol->value.integer.value[0] = 2;
906 break;
907 case SNDRV_PCM_FORMAT_S24_LE:
908 ucontrol->value.integer.value[0] = 1;
909 break;
910 case SNDRV_PCM_FORMAT_S16_LE:
911 default:
912 ucontrol->value.integer.value[0] = 0;
913 break;
914 }
915
916 pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
917 __func__, usb_tx_cfg.bit_format,
918 ucontrol->value.integer.value[0]);
919 return 0;
920}
921
922static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
923 struct snd_ctl_elem_value *ucontrol)
924{
925 int rc = 0;
926
927 switch (ucontrol->value.integer.value[0]) {
928 case 3:
929 usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
930 break;
931 case 2:
932 usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
933 break;
934 case 1:
935 usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
936 break;
937 case 0:
938 default:
939 usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
940 break;
941 }
942 pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
943 __func__, usb_tx_cfg.bit_format,
944 ucontrol->value.integer.value[0]);
945
946 return rc;
947}
948
949static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
950 struct snd_ctl_elem_value *ucontrol)
951{
952 pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
953 usb_rx_cfg.channels);
954 ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
955 return 0;
956}
957
958static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
959 struct snd_ctl_elem_value *ucontrol)
960{
961 usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
962
963 pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
964 return 1;
965}
966
967static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
968 struct snd_ctl_elem_value *ucontrol)
969{
970 pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
971 usb_tx_cfg.channels);
972 ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
973 return 0;
974}
975
976static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
977 struct snd_ctl_elem_value *ucontrol)
978{
979 usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
980
981 pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
982 return 1;
983}
984
Meng Wangd1db67c2019-04-17 12:41:34 +0800985static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
986 struct snd_ctl_elem_value *ucontrol)
987{
988 ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
989 pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
990 ucontrol->value.integer.value[0]);
991 return 0;
992}
993
994static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
995 struct snd_ctl_elem_value *ucontrol)
996{
997 msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
998 pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
999 return 1;
1000}
1001
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08001002static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
1003{
1004 int idx = 0;
1005
1006 if (strnstr(kcontrol->id.name, "Display Port RX",
1007 sizeof("Display Port RX"))) {
1008 idx = EXT_DISP_RX_IDX_DP;
1009 } else {
1010 pr_err("%s: unsupported BE: %s\n",
1011 __func__, kcontrol->id.name);
1012 idx = -EINVAL;
1013 }
1014
1015 return idx;
1016}
1017
1018static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
1019 struct snd_ctl_elem_value *ucontrol)
1020{
1021 int idx = ext_disp_get_port_idx(kcontrol);
1022
1023 if (idx < 0)
1024 return idx;
1025
1026 switch (ext_disp_rx_cfg[idx].bit_format) {
1027 case SNDRV_PCM_FORMAT_S24_3LE:
1028 ucontrol->value.integer.value[0] = 2;
1029 break;
1030 case SNDRV_PCM_FORMAT_S24_LE:
1031 ucontrol->value.integer.value[0] = 1;
1032 break;
1033 case SNDRV_PCM_FORMAT_S16_LE:
1034 default:
1035 ucontrol->value.integer.value[0] = 0;
1036 break;
1037 }
1038
1039 pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
1040 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
1041 ucontrol->value.integer.value[0]);
1042 return 0;
1043}
1044
1045static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
1046 struct snd_ctl_elem_value *ucontrol)
1047{
1048 int idx = ext_disp_get_port_idx(kcontrol);
1049
1050 if (idx < 0)
1051 return idx;
1052
1053 switch (ucontrol->value.integer.value[0]) {
1054 case 2:
1055 ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
1056 break;
1057 case 1:
1058 ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
1059 break;
1060 case 0:
1061 default:
1062 ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
1063 break;
1064 }
1065 pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
1066 __func__, idx, ext_disp_rx_cfg[idx].bit_format,
1067 ucontrol->value.integer.value[0]);
1068
1069 return 0;
1070}
1071
1072static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
1073 struct snd_ctl_elem_value *ucontrol)
1074{
1075 int idx = ext_disp_get_port_idx(kcontrol);
1076
1077 if (idx < 0)
1078 return idx;
1079
1080 ucontrol->value.integer.value[0] =
1081 ext_disp_rx_cfg[idx].channels - 2;
1082
1083 pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
1084 idx, ext_disp_rx_cfg[idx].channels);
1085
1086 return 0;
1087}
1088
1089static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
1090 struct snd_ctl_elem_value *ucontrol)
1091{
1092 int idx = ext_disp_get_port_idx(kcontrol);
1093
1094 if (idx < 0)
1095 return idx;
1096
1097 ext_disp_rx_cfg[idx].channels =
1098 ucontrol->value.integer.value[0] + 2;
1099
1100 pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
1101 idx, ext_disp_rx_cfg[idx].channels);
1102 return 1;
1103}
1104
1105static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
1106 struct snd_ctl_elem_value *ucontrol)
1107{
1108 int sample_rate_val;
1109 int idx = ext_disp_get_port_idx(kcontrol);
1110
1111 if (idx < 0)
1112 return idx;
1113
1114 switch (ext_disp_rx_cfg[idx].sample_rate) {
1115 case SAMPLING_RATE_176P4KHZ:
1116 sample_rate_val = 6;
1117 break;
1118
1119 case SAMPLING_RATE_88P2KHZ:
1120 sample_rate_val = 5;
1121 break;
1122
1123 case SAMPLING_RATE_44P1KHZ:
1124 sample_rate_val = 4;
1125 break;
1126
1127 case SAMPLING_RATE_32KHZ:
1128 sample_rate_val = 3;
1129 break;
1130
1131 case SAMPLING_RATE_192KHZ:
1132 sample_rate_val = 2;
1133 break;
1134
1135 case SAMPLING_RATE_96KHZ:
1136 sample_rate_val = 1;
1137 break;
1138
1139 case SAMPLING_RATE_48KHZ:
1140 default:
1141 sample_rate_val = 0;
1142 break;
1143 }
1144
1145 ucontrol->value.integer.value[0] = sample_rate_val;
1146 pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
1147 idx, ext_disp_rx_cfg[idx].sample_rate);
1148
1149 return 0;
1150}
1151
1152static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
1153 struct snd_ctl_elem_value *ucontrol)
1154{
1155 int idx = ext_disp_get_port_idx(kcontrol);
1156
1157 if (idx < 0)
1158 return idx;
1159
1160 switch (ucontrol->value.integer.value[0]) {
1161 case 6:
1162 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
1163 break;
1164 case 5:
1165 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
1166 break;
1167 case 4:
1168 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
1169 break;
1170 case 3:
1171 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
1172 break;
1173 case 2:
1174 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
1175 break;
1176 case 1:
1177 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
1178 break;
1179 case 0:
1180 default:
1181 ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
1182 break;
1183 }
1184
1185 pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
1186 __func__, ucontrol->value.integer.value[0], idx,
1187 ext_disp_rx_cfg[idx].sample_rate);
1188 return 0;
1189}
1190
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001191static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
1192 struct snd_ctl_elem_value *ucontrol)
1193{
1194 pr_debug("%s: proxy_rx channels = %d\n",
1195 __func__, proxy_rx_cfg.channels);
1196 ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
1197
1198 return 0;
1199}
1200
1201static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
1202 struct snd_ctl_elem_value *ucontrol)
1203{
1204 proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
1205 pr_debug("%s: proxy_rx channels = %d\n",
1206 __func__, proxy_rx_cfg.channels);
1207
1208 return 1;
1209}
1210
1211static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
1212 struct tdm_port *port)
1213{
1214 if (port) {
1215 if (strnstr(kcontrol->id.name, "PRI",
1216 sizeof(kcontrol->id.name))) {
1217 port->mode = TDM_PRI;
1218 } else if (strnstr(kcontrol->id.name, "SEC",
1219 sizeof(kcontrol->id.name))) {
1220 port->mode = TDM_SEC;
1221 } else if (strnstr(kcontrol->id.name, "TERT",
1222 sizeof(kcontrol->id.name))) {
1223 port->mode = TDM_TERT;
1224 } else {
1225 pr_err("%s: unsupported mode in: %s\n",
1226 __func__, kcontrol->id.name);
1227 return -EINVAL;
1228 }
1229
1230 if (strnstr(kcontrol->id.name, "RX_0",
1231 sizeof(kcontrol->id.name)) ||
1232 strnstr(kcontrol->id.name, "TX_0",
1233 sizeof(kcontrol->id.name))) {
1234 port->channel = TDM_0;
1235 } else if (strnstr(kcontrol->id.name, "RX_1",
1236 sizeof(kcontrol->id.name)) ||
1237 strnstr(kcontrol->id.name, "TX_1",
1238 sizeof(kcontrol->id.name))) {
1239 port->channel = TDM_1;
1240 } else if (strnstr(kcontrol->id.name, "RX_2",
1241 sizeof(kcontrol->id.name)) ||
1242 strnstr(kcontrol->id.name, "TX_2",
1243 sizeof(kcontrol->id.name))) {
1244 port->channel = TDM_2;
1245 } else if (strnstr(kcontrol->id.name, "RX_3",
1246 sizeof(kcontrol->id.name)) ||
1247 strnstr(kcontrol->id.name, "TX_3",
1248 sizeof(kcontrol->id.name))) {
1249 port->channel = TDM_3;
1250 } else if (strnstr(kcontrol->id.name, "RX_4",
1251 sizeof(kcontrol->id.name)) ||
1252 strnstr(kcontrol->id.name, "TX_4",
1253 sizeof(kcontrol->id.name))) {
1254 port->channel = TDM_4;
1255 } else if (strnstr(kcontrol->id.name, "RX_5",
1256 sizeof(kcontrol->id.name)) ||
1257 strnstr(kcontrol->id.name, "TX_5",
1258 sizeof(kcontrol->id.name))) {
1259 port->channel = TDM_5;
1260 } else if (strnstr(kcontrol->id.name, "RX_6",
1261 sizeof(kcontrol->id.name)) ||
1262 strnstr(kcontrol->id.name, "TX_6",
1263 sizeof(kcontrol->id.name))) {
1264 port->channel = TDM_6;
1265 } else if (strnstr(kcontrol->id.name, "RX_7",
1266 sizeof(kcontrol->id.name)) ||
1267 strnstr(kcontrol->id.name, "TX_7",
1268 sizeof(kcontrol->id.name))) {
1269 port->channel = TDM_7;
1270 } else {
1271 pr_err("%s: unsupported channel in: %s\n",
1272 __func__, kcontrol->id.name);
1273 return -EINVAL;
1274 }
1275 } else {
1276 return -EINVAL;
1277 }
1278 return 0;
1279}
1280
1281static int tdm_get_sample_rate(int value)
1282{
1283 int sample_rate = 0;
1284
1285 switch (value) {
1286 case 0:
1287 sample_rate = SAMPLING_RATE_8KHZ;
1288 break;
1289 case 1:
1290 sample_rate = SAMPLING_RATE_16KHZ;
1291 break;
1292 case 2:
1293 sample_rate = SAMPLING_RATE_32KHZ;
1294 break;
1295 case 3:
1296 sample_rate = SAMPLING_RATE_48KHZ;
1297 break;
1298 case 4:
1299 sample_rate = SAMPLING_RATE_176P4KHZ;
1300 break;
1301 case 5:
1302 sample_rate = SAMPLING_RATE_352P8KHZ;
1303 break;
1304 default:
1305 sample_rate = SAMPLING_RATE_48KHZ;
1306 break;
1307 }
1308 return sample_rate;
1309}
1310
1311static int tdm_get_sample_rate_val(int sample_rate)
1312{
1313 int sample_rate_val = 0;
1314
1315 switch (sample_rate) {
1316 case SAMPLING_RATE_8KHZ:
1317 sample_rate_val = 0;
1318 break;
1319 case SAMPLING_RATE_16KHZ:
1320 sample_rate_val = 1;
1321 break;
1322 case SAMPLING_RATE_32KHZ:
1323 sample_rate_val = 2;
1324 break;
1325 case SAMPLING_RATE_48KHZ:
1326 sample_rate_val = 3;
1327 break;
1328 case SAMPLING_RATE_176P4KHZ:
1329 sample_rate_val = 4;
1330 break;
1331 case SAMPLING_RATE_352P8KHZ:
1332 sample_rate_val = 5;
1333 break;
1334 default:
1335 sample_rate_val = 3;
1336 break;
1337 }
1338 return sample_rate_val;
1339}
1340
1341static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
1342 struct snd_ctl_elem_value *ucontrol)
1343{
1344 struct tdm_port port;
1345 int ret = tdm_get_port_idx(kcontrol, &port);
1346
1347 if (ret) {
1348 pr_err("%s: unsupported control: %s\n",
1349 __func__, kcontrol->id.name);
1350 } else {
1351 ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
1352 tdm_rx_cfg[port.mode][port.channel].sample_rate);
1353
1354 pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
1355 tdm_rx_cfg[port.mode][port.channel].sample_rate,
1356 ucontrol->value.enumerated.item[0]);
1357 }
1358 return ret;
1359}
1360
1361static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
1362 struct snd_ctl_elem_value *ucontrol)
1363{
1364 struct tdm_port port;
1365 int ret = tdm_get_port_idx(kcontrol, &port);
1366
1367 if (ret) {
1368 pr_err("%s: unsupported control: %s\n",
1369 __func__, kcontrol->id.name);
1370 } else {
1371 tdm_rx_cfg[port.mode][port.channel].sample_rate =
1372 tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
1373
1374 pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
1375 tdm_rx_cfg[port.mode][port.channel].sample_rate,
1376 ucontrol->value.enumerated.item[0]);
1377 }
1378 return ret;
1379}
1380
1381static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
1382 struct snd_ctl_elem_value *ucontrol)
1383{
1384 struct tdm_port port;
1385 int ret = tdm_get_port_idx(kcontrol, &port);
1386
1387 if (ret) {
1388 pr_err("%s: unsupported control: %s\n",
1389 __func__, kcontrol->id.name);
1390 } else {
1391 ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
1392 tdm_tx_cfg[port.mode][port.channel].sample_rate);
1393
1394 pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
1395 tdm_tx_cfg[port.mode][port.channel].sample_rate,
1396 ucontrol->value.enumerated.item[0]);
1397 }
1398 return ret;
1399}
1400
1401static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
1402 struct snd_ctl_elem_value *ucontrol)
1403{
1404 struct tdm_port port;
1405 int ret = tdm_get_port_idx(kcontrol, &port);
1406
1407 if (ret) {
1408 pr_err("%s: unsupported control: %s\n",
1409 __func__, kcontrol->id.name);
1410 } else {
1411 tdm_tx_cfg[port.mode][port.channel].sample_rate =
1412 tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
1413
1414 pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
1415 tdm_tx_cfg[port.mode][port.channel].sample_rate,
1416 ucontrol->value.enumerated.item[0]);
1417 }
1418 return ret;
1419}
1420
1421static int tdm_get_format(int value)
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001422{
1423 int format = 0;
1424
1425 switch (value) {
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001426 case 0:
1427 format = SNDRV_PCM_FORMAT_S16_LE;
1428 break;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001429 case 1:
1430 format = SNDRV_PCM_FORMAT_S24_LE;
1431 break;
1432 case 2:
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001433 format = SNDRV_PCM_FORMAT_S32_LE;
1434 break;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001435 default:
1436 format = SNDRV_PCM_FORMAT_S16_LE;
1437 break;
1438 }
1439 return format;
1440}
1441
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001442static int tdm_get_format_val(int format)
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001443{
1444 int value = 0;
1445
1446 switch (format) {
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001447 case SNDRV_PCM_FORMAT_S16_LE:
1448 value = 0;
1449 break;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001450 case SNDRV_PCM_FORMAT_S24_LE:
1451 value = 1;
1452 break;
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001453 case SNDRV_PCM_FORMAT_S32_LE:
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001454 value = 2;
1455 break;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001456 default:
1457 value = 0;
1458 break;
1459 }
1460 return value;
1461}
1462
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001463static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
1464 struct snd_ctl_elem_value *ucontrol)
1465{
1466 struct tdm_port port;
1467 int ret = tdm_get_port_idx(kcontrol, &port);
1468
1469 if (ret) {
1470 pr_err("%s: unsupported control: %s\n",
1471 __func__, kcontrol->id.name);
1472 } else {
1473 ucontrol->value.enumerated.item[0] = tdm_get_format_val(
1474 tdm_rx_cfg[port.mode][port.channel].bit_format);
1475
1476 pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
1477 tdm_rx_cfg[port.mode][port.channel].bit_format,
1478 ucontrol->value.enumerated.item[0]);
1479 }
1480 return ret;
1481}
1482
1483static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
1484 struct snd_ctl_elem_value *ucontrol)
1485{
1486 struct tdm_port port;
1487 int ret = tdm_get_port_idx(kcontrol, &port);
1488
1489 if (ret) {
1490 pr_err("%s: unsupported control: %s\n",
1491 __func__, kcontrol->id.name);
1492 } else {
1493 tdm_rx_cfg[port.mode][port.channel].bit_format =
1494 tdm_get_format(ucontrol->value.enumerated.item[0]);
1495
1496 pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
1497 tdm_rx_cfg[port.mode][port.channel].bit_format,
1498 ucontrol->value.enumerated.item[0]);
1499 }
1500 return ret;
1501}
1502
1503static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
1504 struct snd_ctl_elem_value *ucontrol)
1505{
1506 struct tdm_port port;
1507 int ret = tdm_get_port_idx(kcontrol, &port);
1508
1509 if (ret) {
1510 pr_err("%s: unsupported control: %s\n",
1511 __func__, kcontrol->id.name);
1512 } else {
1513 ucontrol->value.enumerated.item[0] = tdm_get_format_val(
1514 tdm_tx_cfg[port.mode][port.channel].bit_format);
1515
1516 pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
1517 tdm_tx_cfg[port.mode][port.channel].bit_format,
1518 ucontrol->value.enumerated.item[0]);
1519 }
1520 return ret;
1521}
1522
1523static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
1524 struct snd_ctl_elem_value *ucontrol)
1525{
1526 struct tdm_port port;
1527 int ret = tdm_get_port_idx(kcontrol, &port);
1528
1529 if (ret) {
1530 pr_err("%s: unsupported control: %s\n",
1531 __func__, kcontrol->id.name);
1532 } else {
1533 tdm_tx_cfg[port.mode][port.channel].bit_format =
1534 tdm_get_format(ucontrol->value.enumerated.item[0]);
1535
1536 pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
1537 tdm_tx_cfg[port.mode][port.channel].bit_format,
1538 ucontrol->value.enumerated.item[0]);
1539 }
1540 return ret;
1541}
1542
1543static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
1544 struct snd_ctl_elem_value *ucontrol)
1545{
1546 struct tdm_port port;
1547 int ret = tdm_get_port_idx(kcontrol, &port);
1548
1549 if (ret) {
1550 pr_err("%s: unsupported control: %s\n",
1551 __func__, kcontrol->id.name);
1552 } else {
1553
1554 ucontrol->value.enumerated.item[0] =
1555 tdm_rx_cfg[port.mode][port.channel].channels - 1;
1556
1557 pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
1558 tdm_rx_cfg[port.mode][port.channel].channels - 1,
1559 ucontrol->value.enumerated.item[0]);
1560 }
1561 return ret;
1562}
1563
1564static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
1565 struct snd_ctl_elem_value *ucontrol)
1566{
1567 struct tdm_port port;
1568 int ret = tdm_get_port_idx(kcontrol, &port);
1569
1570 if (ret) {
1571 pr_err("%s: unsupported control: %s\n",
1572 __func__, kcontrol->id.name);
1573 } else {
1574 tdm_rx_cfg[port.mode][port.channel].channels =
1575 ucontrol->value.enumerated.item[0] + 1;
1576
1577 pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
1578 tdm_rx_cfg[port.mode][port.channel].channels,
1579 ucontrol->value.enumerated.item[0] + 1);
1580 }
1581 return ret;
1582}
1583
1584static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
1585 struct snd_ctl_elem_value *ucontrol)
1586{
1587 struct tdm_port port;
1588 int ret = tdm_get_port_idx(kcontrol, &port);
1589
1590 if (ret) {
1591 pr_err("%s: unsupported control: %s\n",
1592 __func__, kcontrol->id.name);
1593 } else {
1594 ucontrol->value.enumerated.item[0] =
1595 tdm_tx_cfg[port.mode][port.channel].channels - 1;
1596
1597 pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
1598 tdm_tx_cfg[port.mode][port.channel].channels - 1,
1599 ucontrol->value.enumerated.item[0]);
1600 }
1601 return ret;
1602}
1603
1604static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
1605 struct snd_ctl_elem_value *ucontrol)
1606{
1607 struct tdm_port port;
1608 int ret = tdm_get_port_idx(kcontrol, &port);
1609
1610 if (ret) {
1611 pr_err("%s: unsupported control: %s\n",
1612 __func__, kcontrol->id.name);
1613 } else {
1614 tdm_tx_cfg[port.mode][port.channel].channels =
1615 ucontrol->value.enumerated.item[0] + 1;
1616
1617 pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
1618 tdm_tx_cfg[port.mode][port.channel].channels,
1619 ucontrol->value.enumerated.item[0] + 1);
1620 }
1621 return ret;
1622}
1623
1624static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
1625{
1626 int idx = 0;
1627
1628 if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
1629 sizeof("PRIM_AUX_PCM"))) {
1630 idx = PRIM_AUX_PCM;
1631 } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
1632 sizeof("SEC_AUX_PCM"))) {
1633 idx = SEC_AUX_PCM;
1634 } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
1635 sizeof("TERT_AUX_PCM"))) {
1636 idx = TERT_AUX_PCM;
1637 } else {
1638 pr_err("%s: unsupported port: %s\n",
1639 __func__, kcontrol->id.name);
1640 idx = -EINVAL;
1641 }
1642
1643 return idx;
1644}
1645
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001646static int aux_pcm_get_sample_rate(int value)
1647{
1648 int sample_rate = 0;
1649
1650 switch (value) {
1651 case 1:
1652 sample_rate = SAMPLING_RATE_16KHZ;
1653 break;
1654 case 0:
1655 default:
1656 sample_rate = SAMPLING_RATE_8KHZ;
1657 break;
1658 }
1659 return sample_rate;
1660}
1661
1662static int aux_pcm_get_sample_rate_val(int sample_rate)
1663{
1664 int sample_rate_val = 0;
1665
1666 switch (sample_rate) {
1667 case SAMPLING_RATE_16KHZ:
1668 sample_rate_val = 1;
1669 break;
1670 case SAMPLING_RATE_8KHZ:
1671 default:
1672 sample_rate_val = 0;
1673 break;
1674 }
1675 return sample_rate_val;
1676}
1677
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001678static int mi2s_auxpcm_get_format(int value)
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001679{
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001680 int format = 0;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001681
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001682 switch (value) {
1683 case 0:
1684 format = SNDRV_PCM_FORMAT_S16_LE;
1685 break;
1686 case 1:
1687 format = SNDRV_PCM_FORMAT_S24_LE;
1688 break;
1689 case 2:
1690 format = SNDRV_PCM_FORMAT_S24_3LE;
1691 break;
1692 case 3:
1693 format = SNDRV_PCM_FORMAT_S32_LE;
1694 break;
1695 default:
1696 format = SNDRV_PCM_FORMAT_S16_LE;
1697 break;
1698 }
1699 return format;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001700}
1701
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001702static int mi2s_auxpcm_get_format_value(int format)
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001703{
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001704 int value = 0;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001705
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001706 switch (format) {
1707 case SNDRV_PCM_FORMAT_S16_LE:
1708 value = 0;
1709 break;
1710 case SNDRV_PCM_FORMAT_S24_LE:
1711 value = 1;
1712 break;
1713 case SNDRV_PCM_FORMAT_S24_3LE:
1714 value = 2;
1715 break;
1716 case SNDRV_PCM_FORMAT_S32_LE:
1717 value = 3;
1718 break;
1719 default:
1720 value = 0;
1721 break;
1722 }
1723 return value;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001724}
1725
1726static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
1727 struct snd_ctl_elem_value *ucontrol)
1728{
1729 int idx = aux_pcm_get_port_idx(kcontrol);
1730
1731 if (idx < 0)
1732 return idx;
1733
1734 ucontrol->value.enumerated.item[0] =
1735 aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
1736
1737 pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
1738 idx, aux_pcm_rx_cfg[idx].sample_rate,
1739 ucontrol->value.enumerated.item[0]);
1740
1741 return 0;
1742}
1743
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001744static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001745 struct snd_ctl_elem_value *ucontrol)
1746{
1747 int idx = aux_pcm_get_port_idx(kcontrol);
1748
1749 if (idx < 0)
1750 return idx;
1751
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001752 aux_pcm_rx_cfg[idx].sample_rate =
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001753 aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
1754
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001755 pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
1756 idx, aux_pcm_rx_cfg[idx].sample_rate,
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07001757 ucontrol->value.enumerated.item[0]);
1758
1759 return 0;
1760}
1761
1762static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
1763 struct snd_ctl_elem_value *ucontrol)
1764{
1765 int idx = aux_pcm_get_port_idx(kcontrol);
1766
1767 if (idx < 0)
1768 return idx;
1769
1770 ucontrol->value.enumerated.item[0] =
1771 aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
1772
1773 pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
1774 idx, aux_pcm_tx_cfg[idx].sample_rate,
1775 ucontrol->value.enumerated.item[0]);
1776
1777 return 0;
1778}
1779
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07001780static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
1781 struct snd_ctl_elem_value *ucontrol)
1782{
1783 int idx = aux_pcm_get_port_idx(kcontrol);
1784
1785 if (idx < 0)
1786 return idx;
1787
1788 aux_pcm_tx_cfg[idx].sample_rate =
1789 aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
1790
1791 pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
1792 idx, aux_pcm_tx_cfg[idx].sample_rate,
1793 ucontrol->value.enumerated.item[0]);
1794
1795 return 0;
1796}
1797
1798static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
1799 struct snd_ctl_elem_value *ucontrol)
1800{
1801 int idx = aux_pcm_get_port_idx(kcontrol);
1802
1803 if (idx < 0)
1804 return idx;
1805
1806 ucontrol->value.enumerated.item[0] =
1807 mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
1808
1809 pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
1810 idx, aux_pcm_rx_cfg[idx].bit_format,
1811 ucontrol->value.enumerated.item[0]);
1812
1813 return 0;
1814}
1815
1816static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
1817 struct snd_ctl_elem_value *ucontrol)
1818{
1819 int idx = aux_pcm_get_port_idx(kcontrol);
1820
1821 if (idx < 0)
1822 return idx;
1823
1824 aux_pcm_rx_cfg[idx].bit_format =
1825 mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
1826
1827 pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
1828 idx, aux_pcm_rx_cfg[idx].bit_format,
1829 ucontrol->value.enumerated.item[0]);
1830
1831 return 0;
1832}
1833
1834static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
1835 struct snd_ctl_elem_value *ucontrol)
1836{
1837 int idx = aux_pcm_get_port_idx(kcontrol);
1838
1839 if (idx < 0)
1840 return idx;
1841
1842 ucontrol->value.enumerated.item[0] =
1843 mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
1844
1845 pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
1846 idx, aux_pcm_tx_cfg[idx].bit_format,
1847 ucontrol->value.enumerated.item[0]);
1848
1849 return 0;
1850}
1851
1852static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
1853 struct snd_ctl_elem_value *ucontrol)
1854{
1855 int idx = aux_pcm_get_port_idx(kcontrol);
1856
1857 if (idx < 0)
1858 return idx;
1859
1860 aux_pcm_tx_cfg[idx].bit_format =
1861 mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
1862
1863 pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
1864 idx, aux_pcm_tx_cfg[idx].bit_format,
1865 ucontrol->value.enumerated.item[0]);
1866
1867 return 0;
1868}
1869
1870static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
1871{
1872 int idx = 0;
1873
1874 if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
1875 sizeof("PRIM_MI2S_RX"))) {
1876 idx = PRIM_MI2S;
1877 } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
1878 sizeof("SEC_MI2S_RX"))) {
1879 idx = SEC_MI2S;
1880 } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
1881 sizeof("TERT_MI2S_RX"))) {
1882 idx = TERT_MI2S;
1883 } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
1884 sizeof("PRIM_MI2S_TX"))) {
1885 idx = PRIM_MI2S;
1886 } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
1887 sizeof("SEC_MI2S_TX"))) {
1888 idx = SEC_MI2S;
1889 } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
1890 sizeof("TERT_MI2S_TX"))) {
1891 idx = TERT_MI2S;
1892 } else {
1893 pr_err("%s: unsupported channel: %s\n",
1894 __func__, kcontrol->id.name);
1895 idx = -EINVAL;
1896 }
1897
1898 return idx;
1899}
1900
1901static int mi2s_get_sample_rate(int value)
1902{
1903 int sample_rate = 0;
1904
1905 switch (value) {
1906 case 0:
1907 sample_rate = SAMPLING_RATE_8KHZ;
1908 break;
1909 case 1:
1910 sample_rate = SAMPLING_RATE_11P025KHZ;
1911 break;
1912 case 2:
1913 sample_rate = SAMPLING_RATE_16KHZ;
1914 break;
1915 case 3:
1916 sample_rate = SAMPLING_RATE_22P05KHZ;
1917 break;
1918 case 4:
1919 sample_rate = SAMPLING_RATE_32KHZ;
1920 break;
1921 case 5:
1922 sample_rate = SAMPLING_RATE_44P1KHZ;
1923 break;
1924 case 6:
1925 sample_rate = SAMPLING_RATE_48KHZ;
1926 break;
1927 case 7:
1928 sample_rate = SAMPLING_RATE_96KHZ;
1929 break;
1930 case 8:
1931 sample_rate = SAMPLING_RATE_192KHZ;
1932 break;
1933 default:
1934 sample_rate = SAMPLING_RATE_48KHZ;
1935 break;
1936 }
1937 return sample_rate;
1938}
1939
1940static int mi2s_get_sample_rate_val(int sample_rate)
1941{
1942 int sample_rate_val = 0;
1943
1944 switch (sample_rate) {
1945 case SAMPLING_RATE_8KHZ:
1946 sample_rate_val = 0;
1947 break;
1948 case SAMPLING_RATE_11P025KHZ:
1949 sample_rate_val = 1;
1950 break;
1951 case SAMPLING_RATE_16KHZ:
1952 sample_rate_val = 2;
1953 break;
1954 case SAMPLING_RATE_22P05KHZ:
1955 sample_rate_val = 3;
1956 break;
1957 case SAMPLING_RATE_32KHZ:
1958 sample_rate_val = 4;
1959 break;
1960 case SAMPLING_RATE_44P1KHZ:
1961 sample_rate_val = 5;
1962 break;
1963 case SAMPLING_RATE_48KHZ:
1964 sample_rate_val = 6;
1965 break;
1966 case SAMPLING_RATE_96KHZ:
1967 sample_rate_val = 7;
1968 break;
1969 case SAMPLING_RATE_192KHZ:
1970 sample_rate_val = 8;
1971 break;
1972 default:
1973 sample_rate_val = 6;
1974 break;
1975 }
1976 return sample_rate_val;
1977}
1978
1979static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
1980 struct snd_ctl_elem_value *ucontrol)
1981{
1982 int idx = mi2s_get_port_idx(kcontrol);
1983
1984 if (idx < 0)
1985 return idx;
1986
1987 ucontrol->value.enumerated.item[0] =
1988 mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
1989
1990 pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
1991 idx, mi2s_rx_cfg[idx].sample_rate,
1992 ucontrol->value.enumerated.item[0]);
1993
1994 return 0;
1995}
1996
1997static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
1998 struct snd_ctl_elem_value *ucontrol)
1999{
2000 int idx = mi2s_get_port_idx(kcontrol);
2001
2002 if (idx < 0)
2003 return idx;
2004
2005 mi2s_rx_cfg[idx].sample_rate =
2006 mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
2007
2008 pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
2009 idx, mi2s_rx_cfg[idx].sample_rate,
2010 ucontrol->value.enumerated.item[0]);
2011
2012 return 0;
2013}
2014
2015static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
2016 struct snd_ctl_elem_value *ucontrol)
2017{
2018 int idx = mi2s_get_port_idx(kcontrol);
2019
2020 if (idx < 0)
2021 return idx;
2022
2023 ucontrol->value.enumerated.item[0] =
2024 mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
2025
2026 pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
2027 idx, mi2s_tx_cfg[idx].sample_rate,
2028 ucontrol->value.enumerated.item[0]);
2029
2030 return 0;
2031}
2032
2033static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
2034 struct snd_ctl_elem_value *ucontrol)
2035{
2036 int idx = mi2s_get_port_idx(kcontrol);
2037
2038 if (idx < 0)
2039 return idx;
2040
2041 mi2s_tx_cfg[idx].sample_rate =
2042 mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
2043
2044 pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
2045 idx, mi2s_tx_cfg[idx].sample_rate,
2046 ucontrol->value.enumerated.item[0]);
2047
2048 return 0;
2049}
2050
2051static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
2052 struct snd_ctl_elem_value *ucontrol)
2053{
2054 int idx = mi2s_get_port_idx(kcontrol);
2055
2056 if (idx < 0)
2057 return idx;
2058
2059 ucontrol->value.enumerated.item[0] =
2060 mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
2061
2062 pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
2063 idx, mi2s_rx_cfg[idx].bit_format,
2064 ucontrol->value.enumerated.item[0]);
2065
2066 return 0;
2067}
2068
2069static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
2070 struct snd_ctl_elem_value *ucontrol)
2071{
2072 int idx = mi2s_get_port_idx(kcontrol);
2073
2074 if (idx < 0)
2075 return idx;
2076
2077 mi2s_rx_cfg[idx].bit_format =
2078 mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
2079
2080 pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
2081 idx, mi2s_rx_cfg[idx].bit_format,
2082 ucontrol->value.enumerated.item[0]);
2083
2084 return 0;
2085}
2086
2087static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
2088 struct snd_ctl_elem_value *ucontrol)
2089{
2090 int idx = mi2s_get_port_idx(kcontrol);
2091
2092 if (idx < 0)
2093 return idx;
2094
2095 ucontrol->value.enumerated.item[0] =
2096 mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
2097
2098 pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
2099 idx, mi2s_tx_cfg[idx].bit_format,
2100 ucontrol->value.enumerated.item[0]);
2101
2102 return 0;
2103}
2104
2105static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
2106 struct snd_ctl_elem_value *ucontrol)
2107{
2108 int idx = mi2s_get_port_idx(kcontrol);
2109
2110 if (idx < 0)
2111 return idx;
2112
2113 mi2s_tx_cfg[idx].bit_format =
2114 mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
2115
2116 pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
2117 idx, mi2s_tx_cfg[idx].bit_format,
2118 ucontrol->value.enumerated.item[0]);
2119
2120 return 0;
2121}
2122static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
2123 struct snd_ctl_elem_value *ucontrol)
2124{
2125 int idx = mi2s_get_port_idx(kcontrol);
2126
2127 if (idx < 0)
2128 return idx;
2129
2130 pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
2131 idx, mi2s_rx_cfg[idx].channels);
2132 ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
2133
2134 return 0;
2135}
2136
2137static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
2138 struct snd_ctl_elem_value *ucontrol)
2139{
2140 int idx = mi2s_get_port_idx(kcontrol);
2141
2142 if (idx < 0)
2143 return idx;
2144
2145 mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
2146 pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
2147 idx, mi2s_rx_cfg[idx].channels);
2148
2149 return 1;
2150}
2151
2152static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
2153 struct snd_ctl_elem_value *ucontrol)
2154{
2155 int idx = mi2s_get_port_idx(kcontrol);
2156
2157 if (idx < 0)
2158 return idx;
2159
2160 pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
2161 idx, mi2s_tx_cfg[idx].channels);
2162 ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
2163
2164 return 0;
2165}
2166
2167static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
2168 struct snd_ctl_elem_value *ucontrol)
2169{
2170 int idx = mi2s_get_port_idx(kcontrol);
2171
2172 if (idx < 0)
2173 return idx;
2174
2175 mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
2176 pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
2177 idx, mi2s_tx_cfg[idx].channels);
2178
2179 return 1;
2180}
2181
2182static int msm_get_port_id(int be_id)
2183{
2184 int afe_port_id = 0;
2185
2186 switch (be_id) {
2187 case MSM_BACKEND_DAI_PRI_MI2S_RX:
2188 afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
2189 break;
2190 case MSM_BACKEND_DAI_PRI_MI2S_TX:
2191 afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
2192 break;
2193 case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
2194 afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
2195 break;
2196 case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
2197 afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
2198 break;
2199 case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
2200 afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
2201 break;
2202 case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
2203 afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
2204 break;
2205 default:
2206 pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
2207 afe_port_id = -EINVAL;
2208 }
2209
2210 return afe_port_id;
2211}
2212
2213static u32 get_mi2s_bits_per_sample(u32 bit_format)
2214{
2215 u32 bit_per_sample = 0;
2216
2217 switch (bit_format) {
2218 case SNDRV_PCM_FORMAT_S32_LE:
2219 case SNDRV_PCM_FORMAT_S24_3LE:
2220 case SNDRV_PCM_FORMAT_S24_LE:
2221 bit_per_sample = 32;
2222 break;
2223 case SNDRV_PCM_FORMAT_S16_LE:
2224 default:
2225 bit_per_sample = 16;
2226 break;
2227 }
2228
2229 return bit_per_sample;
2230}
2231
2232static void update_mi2s_clk_val(int dai_id, int stream)
2233{
2234 u32 bit_per_sample = 0;
2235
2236 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
2237 bit_per_sample =
2238 get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
2239 mi2s_clk[dai_id].clk_freq_in_hz =
2240 mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
2241 } else {
2242 bit_per_sample =
2243 get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
2244 mi2s_clk[dai_id].clk_freq_in_hz =
2245 mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
2246 }
2247}
2248
2249static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
2250{
2251 int ret = 0;
2252 struct snd_soc_pcm_runtime *rtd = substream->private_data;
2253 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
2254 int port_id = 0;
2255 int index = cpu_dai->id;
2256
2257 port_id = msm_get_port_id(rtd->dai_link->id);
2258 if (port_id < 0) {
2259 dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
2260 ret = port_id;
2261 goto err;
2262 }
2263
2264 if (enable) {
2265 update_mi2s_clk_val(index, substream->stream);
2266 dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
2267 mi2s_clk[index].clk_freq_in_hz);
2268 }
2269
2270 mi2s_clk[index].enable = enable;
2271 ret = afe_set_lpass_clock_v2(port_id,
2272 &mi2s_clk[index]);
2273 if (ret < 0) {
2274 dev_err(rtd->card->dev,
2275 "%s: afe lpass clock failed for port 0x%x , err:%d\n",
2276 __func__, port_id, ret);
2277 goto err;
2278 }
2279
2280err:
2281 return ret;
2282}
2283
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002284static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
2285{
2286 int idx = 0;
2287
2288 if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
2289 sizeof("WSA_CDC_DMA_RX_0")))
2290 idx = WSA_CDC_DMA_RX_0;
2291 else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
2292 sizeof("WSA_CDC_DMA_RX_0")))
2293 idx = WSA_CDC_DMA_RX_1;
2294 else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
2295 sizeof("RX_CDC_DMA_RX_0")))
2296 idx = RX_CDC_DMA_RX_0;
2297 else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
2298 sizeof("RX_CDC_DMA_RX_1")))
2299 idx = RX_CDC_DMA_RX_1;
2300 else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
2301 sizeof("RX_CDC_DMA_RX_2")))
2302 idx = RX_CDC_DMA_RX_2;
2303 else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
2304 sizeof("RX_CDC_DMA_RX_3")))
2305 idx = RX_CDC_DMA_RX_3;
2306 else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
2307 sizeof("RX_CDC_DMA_RX_5")))
2308 idx = RX_CDC_DMA_RX_5;
2309 else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
2310 sizeof("WSA_CDC_DMA_TX_0")))
2311 idx = WSA_CDC_DMA_TX_0;
2312 else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
2313 sizeof("WSA_CDC_DMA_TX_1")))
2314 idx = WSA_CDC_DMA_TX_1;
2315 else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
2316 sizeof("WSA_CDC_DMA_TX_2")))
2317 idx = WSA_CDC_DMA_TX_2;
2318 else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
2319 sizeof("TX_CDC_DMA_TX_0")))
2320 idx = TX_CDC_DMA_TX_0;
2321 else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
2322 sizeof("TX_CDC_DMA_TX_3")))
2323 idx = TX_CDC_DMA_TX_3;
2324 else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
2325 sizeof("TX_CDC_DMA_TX_4")))
2326 idx = TX_CDC_DMA_TX_4;
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08002327 else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
2328 sizeof("VA_CDC_DMA_TX_0")))
2329 idx = VA_CDC_DMA_TX_0;
2330 else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
2331 sizeof("VA_CDC_DMA_TX_1")))
2332 idx = VA_CDC_DMA_TX_1;
2333 else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
2334 sizeof("VA_CDC_DMA_TX_2")))
2335 idx = VA_CDC_DMA_TX_2;
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002336 else {
2337 pr_err("%s: unsupported channel: %s\n",
2338 __func__, kcontrol->id.name);
2339 return -EINVAL;
2340 }
2341
2342 return idx;
2343}
2344
2345static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
2346 struct snd_ctl_elem_value *ucontrol)
2347{
2348 int ch_num = cdc_dma_get_port_idx(kcontrol);
2349
Vignesh Kulothungan9e17da02019-03-21 12:15:59 -07002350 if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002351 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2352 return ch_num;
2353 }
2354
2355 pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
2356 cdc_dma_rx_cfg[ch_num].channels - 1);
2357 ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
2358 return 0;
2359}
2360
2361static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
2362 struct snd_ctl_elem_value *ucontrol)
2363{
2364 int ch_num = cdc_dma_get_port_idx(kcontrol);
2365
Vignesh Kulothungan9e17da02019-03-21 12:15:59 -07002366 if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002367 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2368 return ch_num;
2369 }
2370
2371 cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
2372
2373 pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
2374 cdc_dma_rx_cfg[ch_num].channels);
2375 return 1;
2376}
2377
2378static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
2379 struct snd_ctl_elem_value *ucontrol)
2380{
2381 int ch_num = cdc_dma_get_port_idx(kcontrol);
2382
Vignesh Kulothungan9e17da02019-03-21 12:15:59 -07002383 if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002384 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2385 return ch_num;
2386 }
2387
2388 switch (cdc_dma_rx_cfg[ch_num].bit_format) {
2389 case SNDRV_PCM_FORMAT_S32_LE:
2390 ucontrol->value.integer.value[0] = 3;
2391 break;
2392 case SNDRV_PCM_FORMAT_S24_3LE:
2393 ucontrol->value.integer.value[0] = 2;
2394 break;
2395 case SNDRV_PCM_FORMAT_S24_LE:
2396 ucontrol->value.integer.value[0] = 1;
2397 break;
2398 case SNDRV_PCM_FORMAT_S16_LE:
2399 default:
2400 ucontrol->value.integer.value[0] = 0;
2401 break;
2402 }
2403
2404 pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
2405 __func__, cdc_dma_rx_cfg[ch_num].bit_format,
2406 ucontrol->value.integer.value[0]);
2407 return 0;
2408}
2409
2410static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
2411 struct snd_ctl_elem_value *ucontrol)
2412{
2413 int rc = 0;
2414 int ch_num = cdc_dma_get_port_idx(kcontrol);
2415
Vignesh Kulothungan9e17da02019-03-21 12:15:59 -07002416 if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002417 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2418 return ch_num;
2419 }
2420
2421 switch (ucontrol->value.integer.value[0]) {
2422 case 3:
2423 cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
2424 break;
2425 case 2:
2426 cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
2427 break;
2428 case 1:
2429 cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
2430 break;
2431 case 0:
2432 default:
2433 cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
2434 break;
2435 }
2436 pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
2437 __func__, cdc_dma_rx_cfg[ch_num].bit_format,
2438 ucontrol->value.integer.value[0]);
2439
2440 return rc;
2441}
2442
2443
2444static int cdc_dma_get_sample_rate_val(int sample_rate)
2445{
2446 int sample_rate_val = 0;
2447
2448 switch (sample_rate) {
2449 case SAMPLING_RATE_8KHZ:
2450 sample_rate_val = 0;
2451 break;
2452 case SAMPLING_RATE_11P025KHZ:
2453 sample_rate_val = 1;
2454 break;
2455 case SAMPLING_RATE_16KHZ:
2456 sample_rate_val = 2;
2457 break;
2458 case SAMPLING_RATE_22P05KHZ:
2459 sample_rate_val = 3;
2460 break;
2461 case SAMPLING_RATE_32KHZ:
2462 sample_rate_val = 4;
2463 break;
2464 case SAMPLING_RATE_44P1KHZ:
2465 sample_rate_val = 5;
2466 break;
2467 case SAMPLING_RATE_48KHZ:
2468 sample_rate_val = 6;
2469 break;
2470 case SAMPLING_RATE_88P2KHZ:
2471 sample_rate_val = 7;
2472 break;
2473 case SAMPLING_RATE_96KHZ:
2474 sample_rate_val = 8;
2475 break;
2476 case SAMPLING_RATE_176P4KHZ:
2477 sample_rate_val = 9;
2478 break;
2479 case SAMPLING_RATE_192KHZ:
2480 sample_rate_val = 10;
2481 break;
2482 case SAMPLING_RATE_352P8KHZ:
2483 sample_rate_val = 11;
2484 break;
2485 case SAMPLING_RATE_384KHZ:
2486 sample_rate_val = 12;
2487 break;
2488 default:
2489 sample_rate_val = 6;
2490 break;
2491 }
2492 return sample_rate_val;
2493}
2494
2495static int cdc_dma_get_sample_rate(int value)
2496{
2497 int sample_rate = 0;
2498
2499 switch (value) {
2500 case 0:
2501 sample_rate = SAMPLING_RATE_8KHZ;
2502 break;
2503 case 1:
2504 sample_rate = SAMPLING_RATE_11P025KHZ;
2505 break;
2506 case 2:
2507 sample_rate = SAMPLING_RATE_16KHZ;
2508 break;
2509 case 3:
2510 sample_rate = SAMPLING_RATE_22P05KHZ;
2511 break;
2512 case 4:
2513 sample_rate = SAMPLING_RATE_32KHZ;
2514 break;
2515 case 5:
2516 sample_rate = SAMPLING_RATE_44P1KHZ;
2517 break;
2518 case 6:
2519 sample_rate = SAMPLING_RATE_48KHZ;
2520 break;
2521 case 7:
2522 sample_rate = SAMPLING_RATE_88P2KHZ;
2523 break;
2524 case 8:
2525 sample_rate = SAMPLING_RATE_96KHZ;
2526 break;
2527 case 9:
2528 sample_rate = SAMPLING_RATE_176P4KHZ;
2529 break;
2530 case 10:
2531 sample_rate = SAMPLING_RATE_192KHZ;
2532 break;
2533 case 11:
2534 sample_rate = SAMPLING_RATE_352P8KHZ;
2535 break;
2536 case 12:
2537 sample_rate = SAMPLING_RATE_384KHZ;
2538 break;
2539 default:
2540 sample_rate = SAMPLING_RATE_48KHZ;
2541 break;
2542 }
2543 return sample_rate;
2544}
2545
2546static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
2547 struct snd_ctl_elem_value *ucontrol)
2548{
2549 int ch_num = cdc_dma_get_port_idx(kcontrol);
2550
Vignesh Kulothungan9e17da02019-03-21 12:15:59 -07002551 if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002552 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2553 return ch_num;
2554 }
2555
2556 ucontrol->value.enumerated.item[0] =
2557 cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
2558
2559 pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
2560 cdc_dma_rx_cfg[ch_num].sample_rate);
2561 return 0;
2562}
2563
2564static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
2565 struct snd_ctl_elem_value *ucontrol)
2566{
2567 int ch_num = cdc_dma_get_port_idx(kcontrol);
2568
Vignesh Kulothungan9e17da02019-03-21 12:15:59 -07002569 if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002570 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2571 return ch_num;
2572 }
2573
2574 cdc_dma_rx_cfg[ch_num].sample_rate =
2575 cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
2576
2577
2578 pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
2579 __func__, ucontrol->value.enumerated.item[0],
2580 cdc_dma_rx_cfg[ch_num].sample_rate);
2581 return 0;
2582}
2583
2584static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
2585 struct snd_ctl_elem_value *ucontrol)
2586{
2587 int ch_num = cdc_dma_get_port_idx(kcontrol);
2588
2589 if (ch_num < 0) {
2590 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2591 return ch_num;
2592 }
2593
2594 pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
2595 cdc_dma_tx_cfg[ch_num].channels);
2596 ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
2597 return 0;
2598}
2599
2600static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
2601 struct snd_ctl_elem_value *ucontrol)
2602{
2603 int ch_num = cdc_dma_get_port_idx(kcontrol);
2604
2605 if (ch_num < 0) {
2606 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2607 return ch_num;
2608 }
2609
2610 cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
2611
2612 pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
2613 cdc_dma_tx_cfg[ch_num].channels);
2614 return 1;
2615}
2616
2617static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
2618 struct snd_ctl_elem_value *ucontrol)
2619{
2620 int sample_rate_val;
2621 int ch_num = cdc_dma_get_port_idx(kcontrol);
2622
2623 if (ch_num < 0) {
2624 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2625 return ch_num;
2626 }
2627
2628 switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
2629 case SAMPLING_RATE_384KHZ:
2630 sample_rate_val = 12;
2631 break;
2632 case SAMPLING_RATE_352P8KHZ:
2633 sample_rate_val = 11;
2634 break;
2635 case SAMPLING_RATE_192KHZ:
2636 sample_rate_val = 10;
2637 break;
2638 case SAMPLING_RATE_176P4KHZ:
2639 sample_rate_val = 9;
2640 break;
2641 case SAMPLING_RATE_96KHZ:
2642 sample_rate_val = 8;
2643 break;
2644 case SAMPLING_RATE_88P2KHZ:
2645 sample_rate_val = 7;
2646 break;
2647 case SAMPLING_RATE_48KHZ:
2648 sample_rate_val = 6;
2649 break;
2650 case SAMPLING_RATE_44P1KHZ:
2651 sample_rate_val = 5;
2652 break;
2653 case SAMPLING_RATE_32KHZ:
2654 sample_rate_val = 4;
2655 break;
2656 case SAMPLING_RATE_22P05KHZ:
2657 sample_rate_val = 3;
2658 break;
2659 case SAMPLING_RATE_16KHZ:
2660 sample_rate_val = 2;
2661 break;
2662 case SAMPLING_RATE_11P025KHZ:
2663 sample_rate_val = 1;
2664 break;
2665 case SAMPLING_RATE_8KHZ:
2666 sample_rate_val = 0;
2667 break;
2668 default:
2669 sample_rate_val = 6;
2670 break;
2671 }
2672
2673 ucontrol->value.integer.value[0] = sample_rate_val;
2674 pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
2675 cdc_dma_tx_cfg[ch_num].sample_rate);
2676 return 0;
2677}
2678
2679static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
2680 struct snd_ctl_elem_value *ucontrol)
2681{
2682 int ch_num = cdc_dma_get_port_idx(kcontrol);
2683
2684 if (ch_num < 0) {
2685 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2686 return ch_num;
2687 }
2688
2689 switch (ucontrol->value.integer.value[0]) {
2690 case 12:
2691 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
2692 break;
2693 case 11:
2694 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
2695 break;
2696 case 10:
2697 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
2698 break;
2699 case 9:
2700 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
2701 break;
2702 case 8:
2703 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
2704 break;
2705 case 7:
2706 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
2707 break;
2708 case 6:
2709 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
2710 break;
2711 case 5:
2712 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
2713 break;
2714 case 4:
2715 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
2716 break;
2717 case 3:
2718 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
2719 break;
2720 case 2:
2721 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
2722 break;
2723 case 1:
2724 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
2725 break;
2726 case 0:
2727 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
2728 break;
2729 default:
2730 cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
2731 break;
2732 }
2733
2734 pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
2735 __func__, ucontrol->value.integer.value[0],
2736 cdc_dma_tx_cfg[ch_num].sample_rate);
2737 return 0;
2738}
2739
2740static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
2741 struct snd_ctl_elem_value *ucontrol)
2742{
2743 int ch_num = cdc_dma_get_port_idx(kcontrol);
2744
2745 if (ch_num < 0) {
2746 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2747 return ch_num;
2748 }
2749
2750 switch (cdc_dma_tx_cfg[ch_num].bit_format) {
2751 case SNDRV_PCM_FORMAT_S32_LE:
2752 ucontrol->value.integer.value[0] = 3;
2753 break;
2754 case SNDRV_PCM_FORMAT_S24_3LE:
2755 ucontrol->value.integer.value[0] = 2;
2756 break;
2757 case SNDRV_PCM_FORMAT_S24_LE:
2758 ucontrol->value.integer.value[0] = 1;
2759 break;
2760 case SNDRV_PCM_FORMAT_S16_LE:
2761 default:
2762 ucontrol->value.integer.value[0] = 0;
2763 break;
2764 }
2765
2766 pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
2767 __func__, cdc_dma_tx_cfg[ch_num].bit_format,
2768 ucontrol->value.integer.value[0]);
2769 return 0;
2770}
2771
2772static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
2773 struct snd_ctl_elem_value *ucontrol)
2774{
2775 int rc = 0;
2776 int ch_num = cdc_dma_get_port_idx(kcontrol);
2777
2778 if (ch_num < 0) {
2779 pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
2780 return ch_num;
2781 }
2782
2783 switch (ucontrol->value.integer.value[0]) {
2784 case 3:
2785 cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
2786 break;
2787 case 2:
2788 cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
2789 break;
2790 case 1:
2791 cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
2792 break;
2793 case 0:
2794 default:
2795 cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
2796 break;
2797 }
2798 pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
2799 __func__, cdc_dma_tx_cfg[ch_num].bit_format,
2800 ucontrol->value.integer.value[0]);
2801
2802 return rc;
2803}
2804
2805static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
2806{
2807 int idx = 0;
2808
2809 switch (be_id) {
2810 case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
2811 idx = WSA_CDC_DMA_RX_0;
2812 break;
2813 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
2814 idx = WSA_CDC_DMA_TX_0;
2815 break;
2816 case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
2817 idx = WSA_CDC_DMA_RX_1;
2818 break;
2819 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
2820 idx = WSA_CDC_DMA_TX_1;
2821 break;
2822 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
2823 idx = WSA_CDC_DMA_TX_2;
2824 break;
2825 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
2826 idx = RX_CDC_DMA_RX_0;
2827 break;
2828 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
2829 idx = RX_CDC_DMA_RX_1;
2830 break;
2831 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
2832 idx = RX_CDC_DMA_RX_2;
2833 break;
2834 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
2835 idx = RX_CDC_DMA_RX_3;
2836 break;
2837 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
2838 idx = RX_CDC_DMA_RX_5;
2839 break;
2840 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
2841 idx = TX_CDC_DMA_TX_0;
2842 break;
2843 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
2844 idx = TX_CDC_DMA_TX_3;
2845 break;
2846 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
2847 idx = TX_CDC_DMA_TX_4;
2848 break;
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08002849 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
2850 idx = VA_CDC_DMA_TX_0;
2851 break;
2852 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
2853 idx = VA_CDC_DMA_TX_1;
2854 break;
2855 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
2856 idx = VA_CDC_DMA_TX_2;
2857 break;
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07002858 default:
2859 idx = RX_CDC_DMA_RX_0;
2860 break;
2861 }
2862
2863 return idx;
2864}
2865
Banajit Goswami83a370d2019-03-05 16:15:21 -08002866static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
2867 struct snd_ctl_elem_value *ucontrol)
2868{
2869 /*
2870 * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
2871 * when used for BT_SCO use case. Return either Rx or Tx sample rate
2872 * value.
2873 */
2874 switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
2875 case SAMPLING_RATE_96KHZ:
2876 ucontrol->value.integer.value[0] = 5;
2877 break;
2878 case SAMPLING_RATE_88P2KHZ:
2879 ucontrol->value.integer.value[0] = 4;
2880 break;
2881 case SAMPLING_RATE_48KHZ:
2882 ucontrol->value.integer.value[0] = 3;
2883 break;
2884 case SAMPLING_RATE_44P1KHZ:
2885 ucontrol->value.integer.value[0] = 2;
2886 break;
2887 case SAMPLING_RATE_16KHZ:
2888 ucontrol->value.integer.value[0] = 1;
2889 break;
2890 case SAMPLING_RATE_8KHZ:
2891 default:
2892 ucontrol->value.integer.value[0] = 0;
2893 break;
2894 }
2895 pr_debug("%s: sample rate = %d\n", __func__,
2896 slim_rx_cfg[SLIM_RX_7].sample_rate);
2897
2898 return 0;
2899}
2900
2901static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
2902 struct snd_ctl_elem_value *ucontrol)
2903{
2904 switch (ucontrol->value.integer.value[0]) {
2905 case 1:
2906 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
2907 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
2908 break;
2909 case 2:
2910 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
2911 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
2912 break;
2913 case 3:
2914 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
2915 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
2916 break;
2917 case 4:
2918 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
2919 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
2920 break;
2921 case 5:
2922 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
2923 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
2924 break;
2925 case 0:
2926 default:
2927 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
2928 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
2929 break;
2930 }
2931 pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
2932 __func__,
2933 slim_rx_cfg[SLIM_RX_7].sample_rate,
2934 slim_tx_cfg[SLIM_TX_7].sample_rate,
2935 ucontrol->value.enumerated.item[0]);
2936
2937 return 0;
2938}
2939
2940static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
2941 struct snd_ctl_elem_value *ucontrol)
2942{
2943 switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
2944 case SAMPLING_RATE_96KHZ:
2945 ucontrol->value.integer.value[0] = 5;
2946 break;
2947 case SAMPLING_RATE_88P2KHZ:
2948 ucontrol->value.integer.value[0] = 4;
2949 break;
2950 case SAMPLING_RATE_48KHZ:
2951 ucontrol->value.integer.value[0] = 3;
2952 break;
2953 case SAMPLING_RATE_44P1KHZ:
2954 ucontrol->value.integer.value[0] = 2;
2955 break;
2956 case SAMPLING_RATE_16KHZ:
2957 ucontrol->value.integer.value[0] = 1;
2958 break;
2959 case SAMPLING_RATE_8KHZ:
2960 default:
2961 ucontrol->value.integer.value[0] = 0;
2962 break;
2963 }
2964 pr_debug("%s: sample rate rx = %d\n", __func__,
2965 slim_rx_cfg[SLIM_RX_7].sample_rate);
2966
2967 return 0;
2968}
2969
2970static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
2971 struct snd_ctl_elem_value *ucontrol)
2972{
2973 switch (ucontrol->value.integer.value[0]) {
2974 case 1:
2975 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
2976 break;
2977 case 2:
2978 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
2979 break;
2980 case 3:
2981 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
2982 break;
2983 case 4:
2984 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
2985 break;
2986 case 5:
2987 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
2988 break;
2989 case 0:
2990 default:
2991 slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
2992 break;
2993 }
2994 pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
2995 __func__,
2996 slim_rx_cfg[SLIM_RX_7].sample_rate,
2997 ucontrol->value.enumerated.item[0]);
2998
2999 return 0;
3000}
3001
3002static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
3003 struct snd_ctl_elem_value *ucontrol)
3004{
3005 switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
3006 case SAMPLING_RATE_96KHZ:
3007 ucontrol->value.integer.value[0] = 5;
3008 break;
3009 case SAMPLING_RATE_88P2KHZ:
3010 ucontrol->value.integer.value[0] = 4;
3011 break;
3012 case SAMPLING_RATE_48KHZ:
3013 ucontrol->value.integer.value[0] = 3;
3014 break;
3015 case SAMPLING_RATE_44P1KHZ:
3016 ucontrol->value.integer.value[0] = 2;
3017 break;
3018 case SAMPLING_RATE_16KHZ:
3019 ucontrol->value.integer.value[0] = 1;
3020 break;
3021 case SAMPLING_RATE_8KHZ:
3022 default:
3023 ucontrol->value.integer.value[0] = 0;
3024 break;
3025 }
3026 pr_debug("%s: sample rate tx = %d\n", __func__,
3027 slim_tx_cfg[SLIM_TX_7].sample_rate);
3028
3029 return 0;
3030}
3031
3032static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
3033 struct snd_ctl_elem_value *ucontrol)
3034{
3035 switch (ucontrol->value.integer.value[0]) {
3036 case 1:
3037 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
3038 break;
3039 case 2:
3040 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
3041 break;
3042 case 3:
3043 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
3044 break;
3045 case 4:
3046 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
3047 break;
3048 case 5:
3049 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
3050 break;
3051 case 0:
3052 default:
3053 slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
3054 break;
3055 }
3056 pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
3057 __func__,
3058 slim_tx_cfg[SLIM_TX_7].sample_rate,
3059 ucontrol->value.enumerated.item[0]);
3060
3061 return 0;
3062}
3063
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07003064static const struct snd_kcontrol_new msm_int_snd_controls[] = {
3065 SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
3066 cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
3067 SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
3068 cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
3069 SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
3070 cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
3071 SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
3072 cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
3073 SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
3074 cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
3075 SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
3076 cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
3077 SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
3078 cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
3079 SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
3080 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
3081 SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
3082 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
3083 SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
3084 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
3085 SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
3086 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
3087 SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
3088 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
3089 SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
3090 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08003091 SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
3092 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
3093 SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
3094 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
3095 SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
3096 cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07003097 SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
3098 cdc_dma_rx_format_get, cdc_dma_rx_format_put),
3099 SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
3100 cdc_dma_rx_format_get, cdc_dma_rx_format_put),
3101 SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc_dma_rx_0_format,
3102 cdc_dma_rx_format_get, cdc_dma_rx_format_put),
3103 SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc_dma_rx_1_format,
3104 cdc_dma_rx_format_get, cdc_dma_rx_format_put),
3105 SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc_dma_rx_2_format,
3106 cdc_dma_rx_format_get, cdc_dma_rx_format_put),
3107 SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc_dma_rx_3_format,
3108 cdc_dma_rx_format_get, cdc_dma_rx_format_put),
3109 SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc_dma_rx_5_format,
3110 cdc_dma_rx_format_get, cdc_dma_rx_format_put),
3111 SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
3112 cdc_dma_tx_format_get, cdc_dma_tx_format_put),
3113 SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
3114 cdc_dma_tx_format_get, cdc_dma_tx_format_put),
3115 SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
3116 cdc_dma_tx_format_get, cdc_dma_tx_format_put),
3117 SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
3118 cdc_dma_tx_format_get, cdc_dma_tx_format_put),
3119 SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
3120 cdc_dma_tx_format_get, cdc_dma_tx_format_put),
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08003121 SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
3122 cdc_dma_tx_format_get, cdc_dma_tx_format_put),
3123 SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
3124 cdc_dma_tx_format_get, cdc_dma_tx_format_put),
3125 SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
3126 cdc_dma_tx_format_get, cdc_dma_tx_format_put),
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07003127 SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
3128 wsa_cdc_dma_rx_0_sample_rate,
3129 cdc_dma_rx_sample_rate_get,
3130 cdc_dma_rx_sample_rate_put),
3131 SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
3132 wsa_cdc_dma_rx_1_sample_rate,
3133 cdc_dma_rx_sample_rate_get,
3134 cdc_dma_rx_sample_rate_put),
3135 SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
3136 rx_cdc_dma_rx_0_sample_rate,
3137 cdc_dma_rx_sample_rate_get,
3138 cdc_dma_rx_sample_rate_put),
3139 SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
3140 rx_cdc_dma_rx_1_sample_rate,
3141 cdc_dma_rx_sample_rate_get,
3142 cdc_dma_rx_sample_rate_put),
3143 SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
3144 rx_cdc_dma_rx_2_sample_rate,
3145 cdc_dma_rx_sample_rate_get,
3146 cdc_dma_rx_sample_rate_put),
3147 SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
3148 rx_cdc_dma_rx_3_sample_rate,
3149 cdc_dma_rx_sample_rate_get,
3150 cdc_dma_rx_sample_rate_put),
3151 SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
3152 rx_cdc_dma_rx_5_sample_rate,
3153 cdc_dma_rx_sample_rate_get,
3154 cdc_dma_rx_sample_rate_put),
3155 SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
3156 wsa_cdc_dma_tx_0_sample_rate,
3157 cdc_dma_tx_sample_rate_get,
3158 cdc_dma_tx_sample_rate_put),
3159 SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
3160 wsa_cdc_dma_tx_1_sample_rate,
3161 cdc_dma_tx_sample_rate_get,
3162 cdc_dma_tx_sample_rate_put),
3163 SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
3164 wsa_cdc_dma_tx_2_sample_rate,
3165 cdc_dma_tx_sample_rate_get,
3166 cdc_dma_tx_sample_rate_put),
3167 SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
3168 tx_cdc_dma_tx_0_sample_rate,
3169 cdc_dma_tx_sample_rate_get,
3170 cdc_dma_tx_sample_rate_put),
3171 SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
3172 tx_cdc_dma_tx_3_sample_rate,
3173 cdc_dma_tx_sample_rate_get,
3174 cdc_dma_tx_sample_rate_put),
3175 SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
3176 tx_cdc_dma_tx_4_sample_rate,
3177 cdc_dma_tx_sample_rate_get,
3178 cdc_dma_tx_sample_rate_put),
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08003179 SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
3180 va_cdc_dma_tx_0_sample_rate,
3181 cdc_dma_tx_sample_rate_get,
3182 cdc_dma_tx_sample_rate_put),
3183 SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
3184 va_cdc_dma_tx_1_sample_rate,
3185 cdc_dma_tx_sample_rate_get,
3186 cdc_dma_tx_sample_rate_put),
3187 SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
3188 va_cdc_dma_tx_2_sample_rate,
3189 cdc_dma_tx_sample_rate_get,
3190 cdc_dma_tx_sample_rate_put),
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07003191};
3192
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003193static const struct snd_kcontrol_new msm_common_snd_controls[] = {
3194 SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
3195 usb_audio_rx_sample_rate_get,
3196 usb_audio_rx_sample_rate_put),
3197 SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
3198 usb_audio_tx_sample_rate_get,
3199 usb_audio_tx_sample_rate_put),
3200 SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
3201 tdm_rx_sample_rate_get,
3202 tdm_rx_sample_rate_put),
3203 SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
3204 tdm_rx_sample_rate_get,
3205 tdm_rx_sample_rate_put),
3206 SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
3207 tdm_rx_sample_rate_get,
3208 tdm_rx_sample_rate_put),
3209 SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
3210 tdm_tx_sample_rate_get,
3211 tdm_tx_sample_rate_put),
3212 SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
3213 tdm_tx_sample_rate_get,
3214 tdm_tx_sample_rate_put),
3215 SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
3216 tdm_tx_sample_rate_get,
3217 tdm_tx_sample_rate_put),
3218 SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
3219 aux_pcm_rx_sample_rate_get,
3220 aux_pcm_rx_sample_rate_put),
3221 SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
3222 aux_pcm_rx_sample_rate_get,
3223 aux_pcm_rx_sample_rate_put),
3224 SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
3225 aux_pcm_rx_sample_rate_get,
3226 aux_pcm_rx_sample_rate_put),
3227 SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
3228 aux_pcm_tx_sample_rate_get,
3229 aux_pcm_tx_sample_rate_put),
3230 SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
3231 aux_pcm_tx_sample_rate_get,
3232 aux_pcm_tx_sample_rate_put),
3233 SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
3234 aux_pcm_tx_sample_rate_get,
3235 aux_pcm_tx_sample_rate_put),
3236 SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
3237 mi2s_rx_sample_rate_get,
3238 mi2s_rx_sample_rate_put),
3239 SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
3240 mi2s_rx_sample_rate_get,
3241 mi2s_rx_sample_rate_put),
3242 SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
3243 mi2s_rx_sample_rate_get,
3244 mi2s_rx_sample_rate_put),
3245 SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
3246 mi2s_tx_sample_rate_get,
3247 mi2s_tx_sample_rate_put),
3248 SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
3249 mi2s_tx_sample_rate_get,
3250 mi2s_tx_sample_rate_put),
3251 SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
3252 mi2s_tx_sample_rate_get,
3253 mi2s_tx_sample_rate_put),
3254 SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
3255 usb_audio_rx_format_get, usb_audio_rx_format_put),
3256 SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
3257 usb_audio_tx_format_get, usb_audio_tx_format_put),
3258 SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
3259 tdm_rx_format_get,
3260 tdm_rx_format_put),
3261 SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
3262 tdm_rx_format_get,
3263 tdm_rx_format_put),
3264 SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
3265 tdm_rx_format_get,
3266 tdm_rx_format_put),
3267 SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
3268 tdm_tx_format_get,
3269 tdm_tx_format_put),
3270 SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
3271 tdm_tx_format_get,
3272 tdm_tx_format_put),
3273 SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
3274 tdm_tx_format_get,
3275 tdm_tx_format_put),
3276 SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
3277 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3278 SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
3279 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3280 SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
3281 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3282 SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
3283 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3284 SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
3285 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3286 SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
3287 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3288 SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
3289 msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
3290 SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
3291 msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
3292 SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
3293 msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
3294 SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
3295 msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
3296 SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
3297 msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
3298 SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
3299 msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
3300 SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
3301 usb_audio_rx_ch_get, usb_audio_rx_ch_put),
3302 SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
3303 usb_audio_tx_ch_get, usb_audio_tx_ch_put),
3304 SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
3305 proxy_rx_ch_get, proxy_rx_ch_put),
3306 SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
3307 tdm_rx_ch_get,
3308 tdm_rx_ch_put),
3309 SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
3310 tdm_rx_ch_get,
3311 tdm_rx_ch_put),
3312 SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
3313 tdm_rx_ch_get,
3314 tdm_rx_ch_put),
3315 SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
3316 tdm_tx_ch_get,
3317 tdm_tx_ch_put),
3318 SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
3319 tdm_tx_ch_get,
3320 tdm_tx_ch_put),
3321 SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
3322 tdm_tx_ch_get,
3323 tdm_tx_ch_put),
3324 SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
3325 msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
3326 SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
3327 msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
3328 SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
3329 msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
3330 SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
3331 msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
3332 SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
3333 msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
3334 SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
3335 msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
Banajit Goswamib4347d52019-02-28 20:11:49 -08003336 SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
3337 ext_disp_rx_ch_get, ext_disp_rx_ch_put),
3338 SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
3339 ext_disp_rx_format_get, ext_disp_rx_format_put),
3340 SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
3341 ext_disp_rx_sample_rate_get,
3342 ext_disp_rx_sample_rate_put),
Banajit Goswami83a370d2019-03-05 16:15:21 -08003343 SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
3344 msm_bt_sample_rate_get,
3345 msm_bt_sample_rate_put),
3346 SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
3347 msm_bt_sample_rate_rx_get,
3348 msm_bt_sample_rate_rx_put),
3349 SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
3350 msm_bt_sample_rate_tx_get,
3351 msm_bt_sample_rate_tx_put),
Meng Wange8e53822019-03-18 10:49:50 +08003352 SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_loopback_tx_chs,
3353 afe_loopback_tx_ch_get, afe_loopback_tx_ch_put),
Meng Wangd1db67c2019-04-17 12:41:34 +08003354 SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
3355 msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003356};
3357
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07003358static const struct snd_kcontrol_new msm_snd_controls[] = {
3359 SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
3360 msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
3361 SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
3362 msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
3363 SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
3364 aux_pcm_rx_sample_rate_get,
3365 aux_pcm_rx_sample_rate_put),
3366 SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
3367 aux_pcm_tx_sample_rate_get,
3368 aux_pcm_tx_sample_rate_put),
3369};
3370
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08003371static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
3372{
3373 int idx;
3374
3375 switch (be_id) {
3376 case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
3377 idx = EXT_DISP_RX_IDX_DP;
3378 break;
3379 default:
3380 pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
3381 idx = -EINVAL;
3382 break;
3383 }
3384
3385 return idx;
3386}
3387
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003388static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
3389 struct snd_pcm_hw_params *params)
3390{
3391 struct snd_soc_dai_link *dai_link = rtd->dai_link;
3392 struct snd_interval *rate = hw_param_interval(params,
3393 SNDRV_PCM_HW_PARAM_RATE);
3394 struct snd_interval *channels = hw_param_interval(params,
3395 SNDRV_PCM_HW_PARAM_CHANNELS);
Meng Wange8e53822019-03-18 10:49:50 +08003396 int idx = 0, rc = 0;
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003397
3398 pr_debug("%s: format = %d, rate = %d\n",
3399 __func__, params_format(params), params_rate(params));
3400
3401 switch (dai_link->id) {
3402 case MSM_BACKEND_DAI_USB_RX:
3403 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3404 usb_rx_cfg.bit_format);
3405 rate->min = rate->max = usb_rx_cfg.sample_rate;
3406 channels->min = channels->max = usb_rx_cfg.channels;
3407 break;
3408
3409 case MSM_BACKEND_DAI_USB_TX:
3410 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3411 usb_tx_cfg.bit_format);
3412 rate->min = rate->max = usb_tx_cfg.sample_rate;
3413 channels->min = channels->max = usb_tx_cfg.channels;
3414 break;
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08003415
3416 case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
3417 idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
3418 if (idx < 0) {
3419 pr_err("%s: Incorrect ext disp idx %d\n",
3420 __func__, idx);
3421 rc = idx;
3422 goto done;
3423 }
3424
3425 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3426 ext_disp_rx_cfg[idx].bit_format);
3427 rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
3428 channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
3429 break;
3430
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003431 case MSM_BACKEND_DAI_AFE_PCM_RX:
3432 channels->min = channels->max = proxy_rx_cfg.channels;
3433 rate->min = rate->max = SAMPLING_RATE_48KHZ;
3434 break;
3435
3436 case MSM_BACKEND_DAI_PRI_TDM_RX_0:
3437 channels->min = channels->max =
3438 tdm_rx_cfg[TDM_PRI][TDM_0].channels;
3439 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3440 tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
3441 rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
3442 break;
3443
3444 case MSM_BACKEND_DAI_PRI_TDM_TX_0:
3445 channels->min = channels->max =
3446 tdm_tx_cfg[TDM_PRI][TDM_0].channels;
3447 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3448 tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
3449 rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
3450 break;
3451
3452 case MSM_BACKEND_DAI_SEC_TDM_RX_0:
3453 channels->min = channels->max =
3454 tdm_rx_cfg[TDM_SEC][TDM_0].channels;
3455 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3456 tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
3457 rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
3458 break;
3459
3460 case MSM_BACKEND_DAI_SEC_TDM_TX_0:
3461 channels->min = channels->max =
3462 tdm_tx_cfg[TDM_SEC][TDM_0].channels;
3463 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3464 tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
3465 rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
3466 break;
3467
3468 case MSM_BACKEND_DAI_TERT_TDM_RX_0:
3469 channels->min = channels->max =
3470 tdm_rx_cfg[TDM_TERT][TDM_0].channels;
3471 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3472 tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
3473 rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
3474 break;
3475
3476 case MSM_BACKEND_DAI_TERT_TDM_TX_0:
3477 channels->min = channels->max =
3478 tdm_tx_cfg[TDM_TERT][TDM_0].channels;
3479 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3480 tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
3481 rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
3482 break;
3483
3484 case MSM_BACKEND_DAI_AUXPCM_RX:
3485 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3486 aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
3487 rate->min = rate->max =
3488 aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
3489 channels->min = channels->max =
3490 aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
3491 break;
3492
3493 case MSM_BACKEND_DAI_AUXPCM_TX:
3494 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3495 aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
3496 rate->min = rate->max =
3497 aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
3498 channels->min = channels->max =
3499 aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
3500 break;
3501
3502 case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
3503 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3504 aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
3505 rate->min = rate->max =
3506 aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
3507 channels->min = channels->max =
3508 aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
3509 break;
3510
3511 case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
3512 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3513 aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
3514 rate->min = rate->max =
3515 aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
3516 channels->min = channels->max =
3517 aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
3518 break;
3519
3520 case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
3521 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3522 aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
3523 rate->min = rate->max =
3524 aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
3525 channels->min = channels->max =
3526 aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
3527 break;
3528
3529 case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
3530 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3531 aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
3532 rate->min = rate->max =
3533 aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
3534 channels->min = channels->max =
3535 aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
3536 break;
3537
3538 case MSM_BACKEND_DAI_PRI_MI2S_RX:
3539 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3540 mi2s_rx_cfg[PRIM_MI2S].bit_format);
3541 rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
3542 channels->min = channels->max =
3543 mi2s_rx_cfg[PRIM_MI2S].channels;
3544 break;
3545
3546 case MSM_BACKEND_DAI_PRI_MI2S_TX:
3547 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3548 mi2s_tx_cfg[PRIM_MI2S].bit_format);
3549 rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
3550 channels->min = channels->max =
3551 mi2s_tx_cfg[PRIM_MI2S].channels;
3552 break;
3553
3554 case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
3555 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3556 mi2s_rx_cfg[SEC_MI2S].bit_format);
3557 rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
3558 channels->min = channels->max =
3559 mi2s_rx_cfg[SEC_MI2S].channels;
3560 break;
3561
3562 case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
3563 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3564 mi2s_tx_cfg[SEC_MI2S].bit_format);
3565 rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
3566 channels->min = channels->max =
3567 mi2s_tx_cfg[SEC_MI2S].channels;
3568 break;
3569
3570 case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
3571 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3572 mi2s_rx_cfg[TERT_MI2S].bit_format);
3573 rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
3574 channels->min = channels->max =
3575 mi2s_rx_cfg[TERT_MI2S].channels;
3576 break;
3577
3578 case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
3579 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3580 mi2s_tx_cfg[TERT_MI2S].bit_format);
3581 rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
3582 channels->min = channels->max =
3583 mi2s_tx_cfg[TERT_MI2S].channels;
3584 break;
3585
Meng Wang574f4942019-02-18 12:59:41 +08003586 case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
3587 case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
3588 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
3589 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
3590 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
3591 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
3592 idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
3593 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3594 cdc_dma_rx_cfg[idx].bit_format);
3595 rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
3596 channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
3597 break;
3598
3599 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
3600 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
3601 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
3602 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
3603 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08003604 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
3605 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
3606 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
3607 idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
3608 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
Meng Wang574f4942019-02-18 12:59:41 +08003609 cdc_dma_tx_cfg[idx].bit_format);
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08003610 rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
3611 channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
3612 break;
3613
Meng Wang574f4942019-02-18 12:59:41 +08003614 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
3615 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3616 SNDRV_PCM_FORMAT_S32_LE);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003617 rate->min = rate->max = SAMPLING_RATE_8KHZ;
Meng Wang574f4942019-02-18 12:59:41 +08003618 channels->min = channels->max = msm_vi_feed_tx_ch;
3619 break;
3620
Banajit Goswami83a370d2019-03-05 16:15:21 -08003621 case MSM_BACKEND_DAI_SLIMBUS_7_RX:
3622 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3623 slim_rx_cfg[SLIM_RX_7].bit_format);
3624 rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
3625 channels->min = channels->max =
3626 slim_rx_cfg[SLIM_RX_7].channels;
3627 break;
3628
3629 case MSM_BACKEND_DAI_SLIMBUS_7_TX:
3630 rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
3631 channels->min = channels->max =
3632 slim_tx_cfg[SLIM_TX_7].channels;
3633 break;
3634
Meng Wange8e53822019-03-18 10:49:50 +08003635 case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
3636 param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
3637 afe_loopback_tx_cfg[idx].bit_format);
3638 rate->min = rate->max = afe_loopback_tx_cfg[idx].sample_rate;
3639 channels->min = channels->max =
3640 afe_loopback_tx_cfg[idx].channels;
3641 break;
3642
Meng Wang574f4942019-02-18 12:59:41 +08003643 default:
3644 rate->min = rate->max = SAMPLING_RATE_48KHZ;
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003645 break;
3646 }
3647
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08003648done:
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003649 return rc;
3650}
3651
Karthikeyan Mani5eb13422018-11-05 13:49:17 -08003652static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
3653{
3654 struct snd_soc_card *card = component->card;
3655 struct msm_asoc_mach_data *pdata =
3656 snd_soc_card_get_drvdata(card);
3657
3658 if (!pdata->fsa_handle)
3659 return false;
3660
3661 return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
3662}
3663
3664static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
3665{
3666 int value = 0;
3667 bool ret = false;
3668 struct snd_soc_card *card;
3669 struct msm_asoc_mach_data *pdata;
3670
3671 if (!component) {
3672 pr_err("%s component is NULL\n", __func__);
3673 return false;
3674 }
3675 card = component->card;
3676 pdata = snd_soc_card_get_drvdata(card);
3677
3678 if (!pdata)
3679 return false;
3680
3681 if (wcd_mbhc_cfg.enable_usbc_analog)
3682 return msm_usbc_swap_gnd_mic(component, active);
3683
3684 /* if usbc is not defined, swap using us_euro_gpio_p */
3685 if (pdata->us_euro_gpio_p) {
3686 value = msm_cdc_pinctrl_get_state(
3687 pdata->us_euro_gpio_p);
3688 if (value)
3689 msm_cdc_pinctrl_select_sleep_state(
3690 pdata->us_euro_gpio_p);
3691 else
3692 msm_cdc_pinctrl_select_active_state(
3693 pdata->us_euro_gpio_p);
3694 dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
3695 __func__, value, !value);
3696 ret = true;
3697 }
3698
3699 return ret;
3700}
3701
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003702static int kona_tdm_snd_hw_params(struct snd_pcm_substream *substream,
3703 struct snd_pcm_hw_params *params)
3704{
3705 struct snd_soc_pcm_runtime *rtd = substream->private_data;
3706 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
3707 int ret = 0;
3708 int slot_width = 32;
3709 int channels, slots;
3710 unsigned int slot_mask, rate, clk_freq;
3711 unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
3712
3713 pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
3714
3715 /* currently only supporting TDM_RX_0 and TDM_TX_0 */
3716 switch (cpu_dai->id) {
3717 case AFE_PORT_ID_PRIMARY_TDM_RX:
3718 slots = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
3719 break;
3720 case AFE_PORT_ID_SECONDARY_TDM_RX:
3721 slots = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
3722 break;
3723 case AFE_PORT_ID_TERTIARY_TDM_RX:
3724 slots = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
3725 break;
3726 case AFE_PORT_ID_PRIMARY_TDM_TX:
3727 slots = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
3728 break;
3729 case AFE_PORT_ID_SECONDARY_TDM_TX:
3730 slots = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
3731 break;
3732 case AFE_PORT_ID_TERTIARY_TDM_TX:
3733 slots = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
3734 break;
3735
3736 default:
3737 pr_err("%s: dai id 0x%x not supported\n",
3738 __func__, cpu_dai->id);
3739 return -EINVAL;
3740 }
3741
3742 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
3743 /*2 slot config - bits 0 and 1 set for the first two slots */
3744 slot_mask = 0x0000FFFF >> (16 - slots);
3745 channels = slots;
3746
3747 pr_debug("%s: tdm rx slot_width %d slots %d\n",
3748 __func__, slot_width, slots);
3749
3750 ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
3751 slots, slot_width);
3752 if (ret < 0) {
3753 pr_err("%s: failed to set tdm rx slot, err:%d\n",
3754 __func__, ret);
3755 goto end;
3756 }
3757
3758 ret = snd_soc_dai_set_channel_map(cpu_dai,
3759 0, NULL, channels, slot_offset);
3760 if (ret < 0) {
3761 pr_err("%s: failed to set tdm rx channel map, err:%d\n",
3762 __func__, ret);
3763 goto end;
3764 }
3765 } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
3766 /*2 slot config - bits 0 and 1 set for the first two slots */
3767 slot_mask = 0x0000FFFF >> (16 - slots);
3768 channels = slots;
3769
3770 pr_debug("%s: tdm tx slot_width %d slots %d\n",
3771 __func__, slot_width, slots);
3772
3773 ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
3774 slots, slot_width);
3775 if (ret < 0) {
3776 pr_err("%s: failed to set tdm tx slot, err:%d\n",
3777 __func__, ret);
3778 goto end;
3779 }
3780
3781 ret = snd_soc_dai_set_channel_map(cpu_dai,
3782 channels, slot_offset, 0, NULL);
3783 if (ret < 0) {
3784 pr_err("%s: failed to set tdm tx channel map, err:%d\n",
3785 __func__, ret);
3786 goto end;
3787 }
3788 } else {
3789 ret = -EINVAL;
3790 pr_err("%s: invalid use case, err:%d\n",
3791 __func__, ret);
3792 goto end;
3793 }
3794
3795 rate = params_rate(params);
3796 clk_freq = rate * slot_width * slots;
3797 ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
3798 if (ret < 0)
3799 pr_err("%s: failed to set tdm clk, err:%d\n",
3800 __func__, ret);
3801
3802end:
3803 return ret;
3804}
3805
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07003806static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
3807 struct snd_pcm_hw_params *params)
3808{
3809 struct snd_soc_pcm_runtime *rtd = substream->private_data;
3810 struct snd_soc_dai *codec_dai = rtd->codec_dai;
3811 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
3812 struct snd_soc_dai_link *dai_link = rtd->dai_link;
3813
3814 int ret = 0;
3815 u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
3816 u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
3817 u32 user_set_tx_ch = 0;
3818 u32 user_set_rx_ch = 0;
3819 u32 ch_id;
3820
3821 ret = snd_soc_dai_get_channel_map(codec_dai,
3822 &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
3823 &rx_ch_cdc_dma);
3824 if (ret < 0) {
3825 pr_err("%s: failed to get codec chan map, err:%d\n",
3826 __func__, ret);
3827 goto err;
3828 }
3829
3830 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
3831 switch (dai_link->id) {
3832 case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
3833 case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
3834 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
3835 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
3836 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
3837 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
3838 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
3839 case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
3840 {
3841 ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
3842 pr_debug("%s: id %d rx_ch=%d\n", __func__,
3843 ch_id, cdc_dma_rx_cfg[ch_id].channels);
3844 user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
3845 ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
3846 user_set_rx_ch, &rx_ch_cdc_dma);
3847 if (ret < 0) {
3848 pr_err("%s: failed to set cpu chan map, err:%d\n",
3849 __func__, ret);
3850 goto err;
3851 }
3852
3853 }
3854 break;
3855 }
3856 } else {
3857 switch (dai_link->id) {
3858 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
3859 {
3860 user_set_tx_ch = msm_vi_feed_tx_ch;
3861 }
3862 break;
3863 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
3864 case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
3865 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
3866 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
3867 case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08003868 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
3869 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
3870 case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07003871 {
3872 ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
3873 pr_debug("%s: id %d tx_ch=%d\n", __func__,
3874 ch_id, cdc_dma_tx_cfg[ch_id].channels);
3875 user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
3876 }
3877 break;
3878 }
3879
3880 ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
3881 &tx_ch_cdc_dma, 0, 0);
3882 if (ret < 0) {
3883 pr_err("%s: failed to set cpu chan map, err:%d\n",
3884 __func__, ret);
3885 goto err;
3886 }
3887 }
3888
3889err:
3890 return ret;
3891}
3892
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07003893static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
3894{
3895 cpumask_t mask;
3896
3897 if (pm_qos_request_active(&substream->latency_pm_qos_req))
3898 pm_qos_remove_request(&substream->latency_pm_qos_req);
3899
3900 cpumask_clear(&mask);
3901 cpumask_set_cpu(1, &mask); /* affine to core 1 */
3902 cpumask_set_cpu(2, &mask); /* affine to core 2 */
3903 cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
3904
3905 substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
3906
3907 pm_qos_add_request(&substream->latency_pm_qos_req,
3908 PM_QOS_CPU_DMA_LATENCY,
3909 MSM_LL_QOS_VALUE);
3910 return 0;
3911}
3912
3913static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
3914{
3915 int ret = 0;
3916 struct snd_soc_pcm_runtime *rtd = substream->private_data;
3917 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
3918 int index = cpu_dai->id;
3919 unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
3920
3921 dev_dbg(rtd->card->dev,
3922 "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
3923 __func__, substream->name, substream->stream,
3924 cpu_dai->name, cpu_dai->id);
3925
3926 if (index < PRIM_MI2S || index >= MI2S_MAX) {
3927 ret = -EINVAL;
3928 dev_err(rtd->card->dev,
3929 "%s: CPU DAI id (%d) out of range\n",
3930 __func__, cpu_dai->id);
3931 goto err;
3932 }
3933 /*
3934 * Mutex protection in case the same MI2S
3935 * interface using for both TX and RX so
3936 * that the same clock won't be enable twice.
3937 */
3938 mutex_lock(&mi2s_intf_conf[index].lock);
3939 if (++mi2s_intf_conf[index].ref_cnt == 1) {
3940 /* Check if msm needs to provide the clock to the interface */
3941 if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
3942 mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
3943 fmt = SND_SOC_DAIFMT_CBM_CFM;
3944 }
3945 ret = msm_mi2s_set_sclk(substream, true);
3946 if (ret < 0) {
3947 dev_err(rtd->card->dev,
3948 "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
3949 __func__, ret);
3950 goto clean_up;
3951 }
3952
3953 ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
3954 if (ret < 0) {
3955 pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
3956 __func__, index, ret);
3957 goto clk_off;
3958 }
3959 }
3960clk_off:
3961 if (ret < 0)
3962 msm_mi2s_set_sclk(substream, false);
3963clean_up:
3964 if (ret < 0)
3965 mi2s_intf_conf[index].ref_cnt--;
3966 mutex_unlock(&mi2s_intf_conf[index].lock);
3967err:
3968 return ret;
3969}
3970
3971static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
3972{
3973 int ret = 0;
3974 struct snd_soc_pcm_runtime *rtd = substream->private_data;
3975 int index = rtd->cpu_dai->id;
3976
3977 pr_debug("%s(): substream = %s stream = %d\n", __func__,
3978 substream->name, substream->stream);
3979 if (index < PRIM_MI2S || index >= MI2S_MAX) {
3980 pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
3981 return;
3982 }
3983
3984 mutex_lock(&mi2s_intf_conf[index].lock);
3985 if (--mi2s_intf_conf[index].ref_cnt == 0) {
3986 ret = msm_mi2s_set_sclk(substream, false);
3987 if (ret < 0)
3988 pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
3989 __func__, index, ret);
3990 }
3991 mutex_unlock(&mi2s_intf_conf[index].lock);
3992}
3993
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08003994static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
3995 struct snd_pcm_hw_params *params)
3996{
3997 struct snd_soc_pcm_runtime *rtd = substream->private_data;
3998 struct snd_soc_dai *codec_dai = rtd->codec_dai;
3999 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
4000 struct snd_soc_dai_link *dai_link = rtd->dai_link;
4001 u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
4002 u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
4003 int ret = 0;
4004
4005 dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
4006 codec_dai->name, codec_dai->id);
4007 ret = snd_soc_dai_get_channel_map(codec_dai,
4008 &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
4009 if (ret) {
4010 dev_err(rtd->dev,
4011 "%s: failed to get BTFM codec chan map\n, err:%d\n",
4012 __func__, ret);
4013 goto err;
4014 }
4015
4016 dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
4017 __func__, tx_ch_cnt, dai_link->id);
4018
4019 ret = snd_soc_dai_set_channel_map(cpu_dai,
4020 tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
4021 if (ret)
4022 dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
4023 __func__, ret);
4024
4025err:
4026 return ret;
4027}
4028
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004029static struct snd_soc_ops kona_tdm_be_ops = {
4030 .hw_params = kona_tdm_snd_hw_params,
4031};
4032
4033static struct snd_soc_ops msm_mi2s_be_ops = {
4034 .startup = msm_mi2s_snd_startup,
4035 .shutdown = msm_mi2s_snd_shutdown,
4036};
4037
4038static struct snd_soc_ops msm_fe_qos_ops = {
4039 .prepare = msm_fe_qos_prepare,
4040};
4041
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004042static struct snd_soc_ops msm_cdc_dma_be_ops = {
4043 .hw_params = msm_snd_cdc_dma_hw_params,
4044};
4045
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08004046static struct snd_soc_ops msm_wcn_ops = {
4047 .hw_params = msm_wcn_hw_params,
4048};
4049
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004050static int msm_dmic_event(struct snd_soc_dapm_widget *w,
4051 struct snd_kcontrol *kcontrol, int event)
4052{
4053 struct msm_asoc_mach_data *pdata = NULL;
4054 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
4055 int ret = 0;
4056 u32 dmic_idx;
4057 int *dmic_gpio_cnt;
4058 struct device_node *dmic_gpio;
4059 char *wname;
4060
4061 wname = strpbrk(w->name, "012345");
4062 if (!wname) {
4063 dev_err(component->dev, "%s: widget not found\n", __func__);
4064 return -EINVAL;
4065 }
4066
4067 ret = kstrtouint(wname, 10, &dmic_idx);
4068 if (ret < 0) {
4069 dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
4070 __func__);
4071 return -EINVAL;
4072 }
4073
4074 pdata = snd_soc_card_get_drvdata(component->card);
4075
4076 switch (dmic_idx) {
4077 case 0:
4078 case 1:
4079 dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
4080 dmic_gpio = pdata->dmic01_gpio_p;
4081 break;
4082 case 2:
4083 case 3:
4084 dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
4085 dmic_gpio = pdata->dmic23_gpio_p;
4086 break;
4087 case 4:
4088 case 5:
4089 dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
4090 dmic_gpio = pdata->dmic45_gpio_p;
4091 break;
4092 default:
4093 dev_err(component->dev, "%s: Invalid DMIC Selection\n",
4094 __func__);
4095 return -EINVAL;
4096 }
4097
4098 dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
4099 __func__, event, dmic_idx, *dmic_gpio_cnt);
4100
4101 switch (event) {
4102 case SND_SOC_DAPM_PRE_PMU:
4103 (*dmic_gpio_cnt)++;
4104 if (*dmic_gpio_cnt == 1) {
4105 ret = msm_cdc_pinctrl_select_active_state(
4106 dmic_gpio);
4107 if (ret < 0) {
4108 pr_err("%s: gpio set cannot be activated %sd",
4109 __func__, "dmic_gpio");
4110 return ret;
4111 }
4112 }
4113
4114 break;
4115 case SND_SOC_DAPM_POST_PMD:
4116 (*dmic_gpio_cnt)--;
4117 if (*dmic_gpio_cnt == 0) {
4118 ret = msm_cdc_pinctrl_select_sleep_state(
4119 dmic_gpio);
4120 if (ret < 0) {
4121 pr_err("%s: gpio set cannot be de-activated %sd",
4122 __func__, "dmic_gpio");
4123 return ret;
4124 }
4125 }
4126 break;
4127 default:
4128 pr_err("%s: invalid DAPM event %d\n", __func__, event);
4129 return -EINVAL;
4130 }
4131 return 0;
4132}
4133
4134static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
4135 SND_SOC_DAPM_MIC("Analog Mic1", NULL),
4136 SND_SOC_DAPM_MIC("Analog Mic2", NULL),
4137 SND_SOC_DAPM_MIC("Analog Mic3", NULL),
4138 SND_SOC_DAPM_MIC("Analog Mic4", NULL),
Karthikeyan Mani1a111b92019-02-12 21:35:31 -08004139 SND_SOC_DAPM_MIC("Analog Mic5", NULL),
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004140 SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
4141 SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
4142 SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
4143 SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
4144 SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
4145 SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
4146};
4147
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08004148static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
4149{
4150 unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
4151 unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
4152 struct snd_soc_dai *codec_dai = rtd->codec_dai;
4153
4154 return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
4155 tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
4156}
4157
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004158static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
4159{
4160 int ret = -EINVAL;
4161 struct snd_soc_component *component;
4162 struct snd_soc_dapm_context *dapm;
4163 struct snd_card *card;
4164 struct snd_info_entry *entry;
4165 struct snd_soc_component *aux_comp;
4166 struct msm_asoc_mach_data *pdata =
4167 snd_soc_card_get_drvdata(rtd->card);
4168
4169 component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
4170 if (!component) {
4171 pr_err("%s: could not find component for bolero_codec\n",
4172 __func__);
4173 return ret;
4174 }
4175
4176 dapm = snd_soc_component_get_dapm(component);
4177
4178 ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
4179 ARRAY_SIZE(msm_int_snd_controls));
4180 if (ret < 0) {
4181 pr_err("%s: add_component_controls failed: %d\n",
4182 __func__, ret);
4183 return ret;
4184 }
4185 ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
4186 ARRAY_SIZE(msm_common_snd_controls));
4187 if (ret < 0) {
4188 pr_err("%s: add common snd controls failed: %d\n",
4189 __func__, ret);
4190 return ret;
4191 }
4192
4193 snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
4194 ARRAY_SIZE(msm_int_dapm_widgets));
4195
4196 snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
4197 snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
4198 snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
4199 snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
4200
4201 snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
4202 snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
4203 snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
4204 snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
Karthikeyan Mani1a111b92019-02-12 21:35:31 -08004205 snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004206
4207 snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
4208 snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
4209 snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
4210 snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
4211
4212 snd_soc_dapm_sync(dapm);
4213
4214 /*
4215 * Send speaker configuration only for WSA8810.
4216 * Default configuration is for WSA8815.
4217 */
4218 dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
4219 __func__, rtd->card->num_aux_devs);
4220 if (rtd->card->num_aux_devs &&
4221 !list_empty(&rtd->card->component_dev_list)) {
4222 aux_comp = list_first_entry(
4223 &rtd->card->component_dev_list,
4224 struct snd_soc_component,
4225 card_aux_list);
4226 if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
4227 !strcmp(aux_comp->name, WSA8810_NAME_2)) {
4228 wsa_macro_set_spkr_mode(component,
4229 WSA_MACRO_SPKR_MODE_1);
4230 wsa_macro_set_spkr_gain_offset(component,
4231 WSA_MACRO_GAIN_OFFSET_M1P5_DB);
4232 }
Karthikeyan Mani7eef68e2018-12-13 17:45:02 -08004233 bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
4234 sm_port_map);
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004235 }
4236 card = rtd->card->snd_card;
4237 if (!pdata->codec_root) {
4238 entry = snd_info_create_subdir(card->module, "codecs",
4239 card->proc_root);
4240 if (!entry) {
4241 pr_debug("%s: Cannot create codecs module entry\n",
4242 __func__);
4243 ret = 0;
4244 goto err;
4245 }
4246 pdata->codec_root = entry;
4247 }
4248 bolero_info_create_codec_entry(pdata->codec_root, component);
Karthikeyan Mani664bd4a2019-02-21 13:30:34 -08004249 bolero_register_wake_irq(component, false);
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004250 codec_reg_done = true;
4251 return 0;
4252err:
4253 return ret;
4254}
4255
Karthikeyan Mani5eb13422018-11-05 13:49:17 -08004256static void *def_wcd_mbhc_cal(void)
4257{
4258 void *wcd_mbhc_cal;
4259 struct wcd_mbhc_btn_detect_cfg *btn_cfg;
4260 u16 *btn_high;
4261
4262 wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
4263 WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
4264 if (!wcd_mbhc_cal)
4265 return NULL;
4266
4267 WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
4268 WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
4269 btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
4270 btn_high = ((void *)&btn_cfg->_v_btn_low) +
4271 (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
4272
4273 btn_high[0] = 75;
4274 btn_high[1] = 150;
4275 btn_high[2] = 237;
4276 btn_high[3] = 500;
4277 btn_high[4] = 500;
4278 btn_high[5] = 500;
4279 btn_high[6] = 500;
4280 btn_high[7] = 500;
4281
4282 return wcd_mbhc_cal;
4283}
4284
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004285/* Digital audio interface glue - connects codec <---> CPU */
4286static struct snd_soc_dai_link msm_common_dai_links[] = {
4287 /* FrontEnd DAI Links */
4288 {/* hw:x,0 */
4289 .name = MSM_DAILINK_NAME(Media1),
4290 .stream_name = "MultiMedia1",
4291 .cpu_dai_name = "MultiMedia1",
4292 .platform_name = "msm-pcm-dsp.0",
4293 .dynamic = 1,
4294 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
4295 .dpcm_playback = 1,
4296 .dpcm_capture = 1,
4297 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4298 SND_SOC_DPCM_TRIGGER_POST},
4299 .codec_dai_name = "snd-soc-dummy-dai",
4300 .codec_name = "snd-soc-dummy",
4301 .ignore_suspend = 1,
4302 /* this dainlink has playback support */
4303 .ignore_pmdown_time = 1,
4304 .id = MSM_FRONTEND_DAI_MULTIMEDIA1
4305 },
4306 {/* hw:x,1 */
4307 .name = MSM_DAILINK_NAME(Media2),
4308 .stream_name = "MultiMedia2",
4309 .cpu_dai_name = "MultiMedia2",
4310 .platform_name = "msm-pcm-dsp.0",
4311 .dynamic = 1,
4312 .dpcm_playback = 1,
4313 .dpcm_capture = 1,
4314 .codec_dai_name = "snd-soc-dummy-dai",
4315 .codec_name = "snd-soc-dummy",
4316 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4317 SND_SOC_DPCM_TRIGGER_POST},
4318 .ignore_suspend = 1,
4319 /* this dainlink has playback support */
4320 .ignore_pmdown_time = 1,
4321 .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
4322 },
4323 {/* hw:x,2 */
4324 .name = "VoiceMMode1",
4325 .stream_name = "VoiceMMode1",
4326 .cpu_dai_name = "VoiceMMode1",
4327 .platform_name = "msm-pcm-voice",
4328 .dynamic = 1,
4329 .dpcm_playback = 1,
4330 .dpcm_capture = 1,
4331 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4332 SND_SOC_DPCM_TRIGGER_POST},
4333 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4334 .ignore_suspend = 1,
4335 .ignore_pmdown_time = 1,
4336 .codec_dai_name = "snd-soc-dummy-dai",
4337 .codec_name = "snd-soc-dummy",
4338 .id = MSM_FRONTEND_DAI_VOICEMMODE1,
4339 },
4340 {/* hw:x,3 */
4341 .name = "MSM VoIP",
4342 .stream_name = "VoIP",
4343 .cpu_dai_name = "VoIP",
4344 .platform_name = "msm-voip-dsp",
4345 .dynamic = 1,
4346 .dpcm_playback = 1,
4347 .dpcm_capture = 1,
4348 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4349 SND_SOC_DPCM_TRIGGER_POST},
4350 .codec_dai_name = "snd-soc-dummy-dai",
4351 .codec_name = "snd-soc-dummy",
4352 .ignore_suspend = 1,
4353 /* this dainlink has playback support */
4354 .ignore_pmdown_time = 1,
4355 .id = MSM_FRONTEND_DAI_VOIP,
4356 },
4357 {/* hw:x,4 */
4358 .name = MSM_DAILINK_NAME(ULL),
4359 .stream_name = "MultiMedia3",
4360 .cpu_dai_name = "MultiMedia3",
4361 .platform_name = "msm-pcm-dsp.2",
4362 .dynamic = 1,
4363 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
4364 .dpcm_playback = 1,
4365 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4366 SND_SOC_DPCM_TRIGGER_POST},
4367 .codec_dai_name = "snd-soc-dummy-dai",
4368 .codec_name = "snd-soc-dummy",
4369 .ignore_suspend = 1,
4370 /* this dainlink has playback support */
4371 .ignore_pmdown_time = 1,
4372 .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
4373 },
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004374 {/* hw:x,5 */
4375 .name = "MSM AFE-PCM RX",
4376 .stream_name = "AFE-PROXY RX",
4377 .cpu_dai_name = "msm-dai-q6-dev.241",
4378 .codec_name = "msm-stub-codec.1",
4379 .codec_dai_name = "msm-stub-rx",
4380 .platform_name = "msm-pcm-afe",
4381 .dpcm_playback = 1,
4382 .ignore_suspend = 1,
4383 /* this dainlink has playback support */
4384 .ignore_pmdown_time = 1,
4385 },
4386 {/* hw:x,6 */
4387 .name = "MSM AFE-PCM TX",
4388 .stream_name = "AFE-PROXY TX",
4389 .cpu_dai_name = "msm-dai-q6-dev.240",
4390 .codec_name = "msm-stub-codec.1",
4391 .codec_dai_name = "msm-stub-tx",
4392 .platform_name = "msm-pcm-afe",
4393 .dpcm_capture = 1,
4394 .ignore_suspend = 1,
4395 },
4396 {/* hw:x,7 */
4397 .name = MSM_DAILINK_NAME(Compress1),
4398 .stream_name = "Compress1",
4399 .cpu_dai_name = "MultiMedia4",
4400 .platform_name = "msm-compress-dsp",
4401 .dynamic = 1,
4402 .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
4403 .dpcm_playback = 1,
4404 .dpcm_capture = 1,
4405 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4406 SND_SOC_DPCM_TRIGGER_POST},
4407 .codec_dai_name = "snd-soc-dummy-dai",
4408 .codec_name = "snd-soc-dummy",
4409 .ignore_suspend = 1,
4410 .ignore_pmdown_time = 1,
4411 /* this dainlink has playback support */
4412 .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
4413 },
Meng Wang197cb302019-03-01 13:54:38 +08004414 /* Hostless PCM purpose */
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004415 {/* hw:x,8 */
4416 .name = "AUXPCM Hostless",
4417 .stream_name = "AUXPCM Hostless",
4418 .cpu_dai_name = "AUXPCM_HOSTLESS",
4419 .platform_name = "msm-pcm-hostless",
4420 .dynamic = 1,
4421 .dpcm_playback = 1,
4422 .dpcm_capture = 1,
4423 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4424 SND_SOC_DPCM_TRIGGER_POST},
4425 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4426 .ignore_suspend = 1,
4427 /* this dainlink has playback support */
4428 .ignore_pmdown_time = 1,
4429 .codec_dai_name = "snd-soc-dummy-dai",
4430 .codec_name = "snd-soc-dummy",
4431 },
4432 {/* hw:x,9 */
4433 .name = MSM_DAILINK_NAME(LowLatency),
4434 .stream_name = "MultiMedia5",
4435 .cpu_dai_name = "MultiMedia5",
4436 .platform_name = "msm-pcm-dsp.1",
4437 .dynamic = 1,
4438 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
4439 .dpcm_playback = 1,
4440 .dpcm_capture = 1,
4441 .codec_dai_name = "snd-soc-dummy-dai",
4442 .codec_name = "snd-soc-dummy",
4443 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4444 SND_SOC_DPCM_TRIGGER_POST},
4445 .ignore_suspend = 1,
4446 /* this dainlink has playback support */
4447 .ignore_pmdown_time = 1,
4448 .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
4449 .ops = &msm_fe_qos_ops,
4450 },
4451 {/* hw:x,10 */
4452 .name = "Listen 1 Audio Service",
4453 .stream_name = "Listen 1 Audio Service",
4454 .cpu_dai_name = "LSM1",
4455 .platform_name = "msm-lsm-client",
4456 .dynamic = 1,
4457 .dpcm_capture = 1,
4458 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
4459 SND_SOC_DPCM_TRIGGER_POST },
4460 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4461 .ignore_suspend = 1,
4462 .codec_dai_name = "snd-soc-dummy-dai",
4463 .codec_name = "snd-soc-dummy",
4464 .id = MSM_FRONTEND_DAI_LSM1,
4465 },
4466 /* Multiple Tunnel instances */
4467 {/* hw:x,11 */
4468 .name = MSM_DAILINK_NAME(Compress2),
4469 .stream_name = "Compress2",
4470 .cpu_dai_name = "MultiMedia7",
4471 .platform_name = "msm-compress-dsp",
4472 .dynamic = 1,
4473 .dpcm_playback = 1,
4474 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4475 SND_SOC_DPCM_TRIGGER_POST},
4476 .codec_dai_name = "snd-soc-dummy-dai",
4477 .codec_name = "snd-soc-dummy",
4478 .ignore_suspend = 1,
4479 .ignore_pmdown_time = 1,
4480 /* this dainlink has playback support */
4481 .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
4482 },
4483 {/* hw:x,12 */
4484 .name = MSM_DAILINK_NAME(MultiMedia10),
4485 .stream_name = "MultiMedia10",
4486 .cpu_dai_name = "MultiMedia10",
4487 .platform_name = "msm-pcm-dsp.1",
4488 .dynamic = 1,
4489 .dpcm_playback = 1,
4490 .dpcm_capture = 1,
4491 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4492 SND_SOC_DPCM_TRIGGER_POST},
4493 .codec_dai_name = "snd-soc-dummy-dai",
4494 .codec_name = "snd-soc-dummy",
4495 .ignore_suspend = 1,
4496 .ignore_pmdown_time = 1,
4497 /* this dainlink has playback support */
4498 .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
4499 },
4500 {/* hw:x,13 */
4501 .name = MSM_DAILINK_NAME(ULL_NOIRQ),
4502 .stream_name = "MM_NOIRQ",
4503 .cpu_dai_name = "MultiMedia8",
4504 .platform_name = "msm-pcm-dsp-noirq",
4505 .dynamic = 1,
4506 .dpcm_playback = 1,
4507 .dpcm_capture = 1,
4508 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4509 SND_SOC_DPCM_TRIGGER_POST},
4510 .codec_dai_name = "snd-soc-dummy-dai",
4511 .codec_name = "snd-soc-dummy",
4512 .ignore_suspend = 1,
4513 .ignore_pmdown_time = 1,
4514 /* this dainlink has playback support */
4515 .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
4516 .ops = &msm_fe_qos_ops,
4517 },
4518 /* HDMI Hostless */
4519 {/* hw:x,14 */
4520 .name = "HDMI_RX_HOSTLESS",
4521 .stream_name = "HDMI_RX_HOSTLESS",
4522 .cpu_dai_name = "HDMI_HOSTLESS",
4523 .platform_name = "msm-pcm-hostless",
4524 .dynamic = 1,
4525 .dpcm_playback = 1,
4526 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4527 SND_SOC_DPCM_TRIGGER_POST},
4528 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4529 .ignore_suspend = 1,
4530 .ignore_pmdown_time = 1,
4531 .codec_dai_name = "snd-soc-dummy-dai",
4532 .codec_name = "snd-soc-dummy",
4533 },
4534 {/* hw:x,15 */
4535 .name = "VoiceMMode2",
4536 .stream_name = "VoiceMMode2",
4537 .cpu_dai_name = "VoiceMMode2",
4538 .platform_name = "msm-pcm-voice",
4539 .dynamic = 1,
4540 .dpcm_playback = 1,
4541 .dpcm_capture = 1,
4542 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4543 SND_SOC_DPCM_TRIGGER_POST},
4544 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4545 .ignore_suspend = 1,
4546 .ignore_pmdown_time = 1,
4547 .codec_dai_name = "snd-soc-dummy-dai",
4548 .codec_name = "snd-soc-dummy",
4549 .id = MSM_FRONTEND_DAI_VOICEMMODE2,
4550 },
4551 /* LSM FE */
4552 {/* hw:x,16 */
4553 .name = "Listen 2 Audio Service",
4554 .stream_name = "Listen 2 Audio Service",
4555 .cpu_dai_name = "LSM2",
4556 .platform_name = "msm-lsm-client",
4557 .dynamic = 1,
4558 .dpcm_capture = 1,
4559 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
4560 SND_SOC_DPCM_TRIGGER_POST },
4561 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4562 .ignore_suspend = 1,
4563 .codec_dai_name = "snd-soc-dummy-dai",
4564 .codec_name = "snd-soc-dummy",
4565 .id = MSM_FRONTEND_DAI_LSM2,
4566 },
4567 {/* hw:x,17 */
4568 .name = "Listen 3 Audio Service",
4569 .stream_name = "Listen 3 Audio Service",
4570 .cpu_dai_name = "LSM3",
4571 .platform_name = "msm-lsm-client",
4572 .dynamic = 1,
4573 .dpcm_capture = 1,
4574 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
4575 SND_SOC_DPCM_TRIGGER_POST },
4576 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4577 .ignore_suspend = 1,
4578 .codec_dai_name = "snd-soc-dummy-dai",
4579 .codec_name = "snd-soc-dummy",
4580 .id = MSM_FRONTEND_DAI_LSM3,
4581 },
4582 {/* hw:x,18 */
4583 .name = "Listen 4 Audio Service",
4584 .stream_name = "Listen 4 Audio Service",
4585 .cpu_dai_name = "LSM4",
4586 .platform_name = "msm-lsm-client",
4587 .dynamic = 1,
4588 .dpcm_capture = 1,
4589 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
4590 SND_SOC_DPCM_TRIGGER_POST },
4591 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4592 .ignore_suspend = 1,
4593 .codec_dai_name = "snd-soc-dummy-dai",
4594 .codec_name = "snd-soc-dummy",
4595 .id = MSM_FRONTEND_DAI_LSM4,
4596 },
4597 {/* hw:x,19 */
4598 .name = "Listen 5 Audio Service",
4599 .stream_name = "Listen 5 Audio Service",
4600 .cpu_dai_name = "LSM5",
4601 .platform_name = "msm-lsm-client",
4602 .dynamic = 1,
4603 .dpcm_capture = 1,
4604 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
4605 SND_SOC_DPCM_TRIGGER_POST },
4606 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4607 .ignore_suspend = 1,
4608 .codec_dai_name = "snd-soc-dummy-dai",
4609 .codec_name = "snd-soc-dummy",
4610 .id = MSM_FRONTEND_DAI_LSM5,
4611 },
4612 {/* hw:x,20 */
4613 .name = "Listen 6 Audio Service",
4614 .stream_name = "Listen 6 Audio Service",
4615 .cpu_dai_name = "LSM6",
4616 .platform_name = "msm-lsm-client",
4617 .dynamic = 1,
4618 .dpcm_capture = 1,
4619 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
4620 SND_SOC_DPCM_TRIGGER_POST },
4621 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4622 .ignore_suspend = 1,
4623 .codec_dai_name = "snd-soc-dummy-dai",
4624 .codec_name = "snd-soc-dummy",
4625 .id = MSM_FRONTEND_DAI_LSM6,
4626 },
4627 {/* hw:x,21 */
4628 .name = "Listen 7 Audio Service",
4629 .stream_name = "Listen 7 Audio Service",
4630 .cpu_dai_name = "LSM7",
4631 .platform_name = "msm-lsm-client",
4632 .dynamic = 1,
4633 .dpcm_capture = 1,
4634 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
4635 SND_SOC_DPCM_TRIGGER_POST },
4636 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4637 .ignore_suspend = 1,
4638 .codec_dai_name = "snd-soc-dummy-dai",
4639 .codec_name = "snd-soc-dummy",
4640 .id = MSM_FRONTEND_DAI_LSM7,
4641 },
4642 {/* hw:x,22 */
4643 .name = "Listen 8 Audio Service",
4644 .stream_name = "Listen 8 Audio Service",
4645 .cpu_dai_name = "LSM8",
4646 .platform_name = "msm-lsm-client",
4647 .dynamic = 1,
4648 .dpcm_capture = 1,
4649 .trigger = { SND_SOC_DPCM_TRIGGER_POST,
4650 SND_SOC_DPCM_TRIGGER_POST },
4651 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4652 .ignore_suspend = 1,
4653 .codec_dai_name = "snd-soc-dummy-dai",
4654 .codec_name = "snd-soc-dummy",
4655 .id = MSM_FRONTEND_DAI_LSM8,
4656 },
4657 {/* hw:x,23 */
4658 .name = MSM_DAILINK_NAME(Media9),
4659 .stream_name = "MultiMedia9",
4660 .cpu_dai_name = "MultiMedia9",
4661 .platform_name = "msm-pcm-dsp.0",
4662 .dynamic = 1,
4663 .dpcm_playback = 1,
4664 .dpcm_capture = 1,
4665 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4666 SND_SOC_DPCM_TRIGGER_POST},
4667 .codec_dai_name = "snd-soc-dummy-dai",
4668 .codec_name = "snd-soc-dummy",
4669 .ignore_suspend = 1,
4670 /* this dainlink has playback support */
4671 .ignore_pmdown_time = 1,
4672 .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
4673 },
4674 {/* hw:x,24 */
4675 .name = MSM_DAILINK_NAME(Compress4),
4676 .stream_name = "Compress4",
4677 .cpu_dai_name = "MultiMedia11",
4678 .platform_name = "msm-compress-dsp",
4679 .dynamic = 1,
4680 .dpcm_playback = 1,
4681 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4682 SND_SOC_DPCM_TRIGGER_POST},
4683 .codec_dai_name = "snd-soc-dummy-dai",
4684 .codec_name = "snd-soc-dummy",
4685 .ignore_suspend = 1,
4686 .ignore_pmdown_time = 1,
4687 /* this dainlink has playback support */
4688 .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
4689 },
4690 {/* hw:x,25 */
4691 .name = MSM_DAILINK_NAME(Compress5),
4692 .stream_name = "Compress5",
4693 .cpu_dai_name = "MultiMedia12",
4694 .platform_name = "msm-compress-dsp",
4695 .dynamic = 1,
4696 .dpcm_playback = 1,
4697 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4698 SND_SOC_DPCM_TRIGGER_POST},
4699 .codec_dai_name = "snd-soc-dummy-dai",
4700 .codec_name = "snd-soc-dummy",
4701 .ignore_suspend = 1,
4702 .ignore_pmdown_time = 1,
4703 /* this dainlink has playback support */
4704 .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
4705 },
4706 {/* hw:x,26 */
4707 .name = MSM_DAILINK_NAME(Compress6),
4708 .stream_name = "Compress6",
4709 .cpu_dai_name = "MultiMedia13",
4710 .platform_name = "msm-compress-dsp",
4711 .dynamic = 1,
4712 .dpcm_playback = 1,
4713 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4714 SND_SOC_DPCM_TRIGGER_POST},
4715 .codec_dai_name = "snd-soc-dummy-dai",
4716 .codec_name = "snd-soc-dummy",
4717 .ignore_suspend = 1,
4718 .ignore_pmdown_time = 1,
4719 /* this dainlink has playback support */
4720 .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
4721 },
4722 {/* hw:x,27 */
4723 .name = MSM_DAILINK_NAME(Compress7),
4724 .stream_name = "Compress7",
4725 .cpu_dai_name = "MultiMedia14",
4726 .platform_name = "msm-compress-dsp",
4727 .dynamic = 1,
4728 .dpcm_playback = 1,
4729 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4730 SND_SOC_DPCM_TRIGGER_POST},
4731 .codec_dai_name = "snd-soc-dummy-dai",
4732 .codec_name = "snd-soc-dummy",
4733 .ignore_suspend = 1,
4734 .ignore_pmdown_time = 1,
4735 /* this dainlink has playback support */
4736 .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
4737 },
4738 {/* hw:x,28 */
4739 .name = MSM_DAILINK_NAME(Compress8),
4740 .stream_name = "Compress8",
4741 .cpu_dai_name = "MultiMedia15",
4742 .platform_name = "msm-compress-dsp",
4743 .dynamic = 1,
4744 .dpcm_playback = 1,
4745 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4746 SND_SOC_DPCM_TRIGGER_POST},
4747 .codec_dai_name = "snd-soc-dummy-dai",
4748 .codec_name = "snd-soc-dummy",
4749 .ignore_suspend = 1,
4750 .ignore_pmdown_time = 1,
4751 /* this dainlink has playback support */
4752 .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
4753 },
4754 {/* hw:x,29 */
4755 .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
4756 .stream_name = "MM_NOIRQ_2",
4757 .cpu_dai_name = "MultiMedia16",
4758 .platform_name = "msm-pcm-dsp-noirq",
4759 .dynamic = 1,
4760 .dpcm_playback = 1,
4761 .dpcm_capture = 1,
4762 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4763 SND_SOC_DPCM_TRIGGER_POST},
4764 .codec_dai_name = "snd-soc-dummy-dai",
4765 .codec_name = "snd-soc-dummy",
4766 .ignore_suspend = 1,
4767 .ignore_pmdown_time = 1,
4768 /* this dainlink has playback support */
4769 .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
4770 },
4771 {/* hw:x,30 */
4772 .name = "CDC_DMA Hostless",
4773 .stream_name = "CDC_DMA Hostless",
4774 .cpu_dai_name = "CDC_DMA_HOSTLESS",
4775 .platform_name = "msm-pcm-hostless",
4776 .dynamic = 1,
4777 .dpcm_playback = 1,
4778 .dpcm_capture = 1,
4779 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4780 SND_SOC_DPCM_TRIGGER_POST},
4781 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4782 .ignore_suspend = 1,
4783 /* this dailink has playback support */
4784 .ignore_pmdown_time = 1,
4785 .codec_dai_name = "snd-soc-dummy-dai",
4786 .codec_name = "snd-soc-dummy",
4787 },
4788 {/* hw:x,31 */
4789 .name = "TX3_CDC_DMA Hostless",
4790 .stream_name = "TX3_CDC_DMA Hostless",
4791 .cpu_dai_name = "TX3_CDC_DMA_HOSTLESS",
4792 .platform_name = "msm-pcm-hostless",
4793 .dynamic = 1,
4794 .dpcm_capture = 1,
4795 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4796 SND_SOC_DPCM_TRIGGER_POST},
4797 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4798 .ignore_suspend = 1,
4799 .codec_dai_name = "snd-soc-dummy-dai",
4800 .codec_name = "snd-soc-dummy",
4801 },
Karthikeyan Manif0de7562019-03-04 16:39:41 -08004802 {/* hw:x,32 */
4803 .name = "Tertiary MI2S TX_Hostless",
4804 .stream_name = "Tertiary MI2S_TX Hostless Capture",
4805 .cpu_dai_name = "TERT_MI2S_TX_HOSTLESS",
4806 .platform_name = "msm-pcm-hostless",
4807 .dynamic = 1,
4808 .dpcm_capture = 1,
4809 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4810 SND_SOC_DPCM_TRIGGER_POST},
4811 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4812 .ignore_suspend = 1,
4813 .ignore_pmdown_time = 1,
4814 .codec_dai_name = "snd-soc-dummy-dai",
4815 .codec_name = "snd-soc-dummy",
4816 },
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004817};
4818
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004819static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
Karthikeyan Manif0de7562019-03-04 16:39:41 -08004820 {/* hw:x,33 */
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07004821 .name = LPASS_BE_WSA_CDC_DMA_TX_0,
4822 .stream_name = "WSA CDC DMA0 Capture",
4823 .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
4824 .platform_name = "msm-pcm-hostless",
4825 .codec_name = "bolero_codec",
4826 .codec_dai_name = "wsa_macro_vifeedback",
4827 .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
4828 .be_hw_params_fixup = msm_be_hw_params_fixup,
4829 .ignore_suspend = 1,
4830 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4831 .ops = &msm_cdc_dma_be_ops,
4832 },
4833};
4834
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004835static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
Karthikeyan Manif0de7562019-03-04 16:39:41 -08004836 {/* hw:x,34 */
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004837 .name = MSM_DAILINK_NAME(ASM Loopback),
4838 .stream_name = "MultiMedia6",
4839 .cpu_dai_name = "MultiMedia6",
4840 .platform_name = "msm-pcm-loopback",
4841 .dynamic = 1,
4842 .dpcm_playback = 1,
4843 .dpcm_capture = 1,
4844 .codec_dai_name = "snd-soc-dummy-dai",
4845 .codec_name = "snd-soc-dummy",
4846 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4847 SND_SOC_DPCM_TRIGGER_POST},
4848 .ignore_suspend = 1,
4849 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4850 .ignore_pmdown_time = 1,
4851 .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
4852 },
Karthikeyan Manif0de7562019-03-04 16:39:41 -08004853 {/* hw:x,35 */
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004854 .name = "USB Audio Hostless",
4855 .stream_name = "USB Audio Hostless",
4856 .cpu_dai_name = "USBAUDIO_HOSTLESS",
4857 .platform_name = "msm-pcm-hostless",
4858 .dynamic = 1,
4859 .dpcm_playback = 1,
4860 .dpcm_capture = 1,
4861 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4862 SND_SOC_DPCM_TRIGGER_POST},
4863 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4864 .ignore_suspend = 1,
4865 .ignore_pmdown_time = 1,
4866 .codec_dai_name = "snd-soc-dummy-dai",
4867 .codec_name = "snd-soc-dummy",
4868 },
Karthikeyan Manif0de7562019-03-04 16:39:41 -08004869 {/* hw:x,36 */
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004870 .name = "SLIMBUS_7 Hostless",
4871 .stream_name = "SLIMBUS_7 Hostless",
4872 .cpu_dai_name = "SLIMBUS7_HOSTLESS",
4873 .platform_name = "msm-pcm-hostless",
4874 .dynamic = 1,
4875 .dpcm_capture = 1,
4876 .dpcm_playback = 1,
4877 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4878 SND_SOC_DPCM_TRIGGER_POST},
4879 .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
4880 .ignore_suspend = 1,
4881 .ignore_pmdown_time = 1,
4882 .codec_dai_name = "snd-soc-dummy-dai",
4883 .codec_name = "snd-soc-dummy",
4884 },
Karthikeyan Manif0de7562019-03-04 16:39:41 -08004885 {/* hw:x,37 */
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08004886 .name = "Compress Capture",
4887 .stream_name = "Compress9",
4888 .cpu_dai_name = "MultiMedia17",
4889 .platform_name = "msm-compress-dsp",
4890 .dynamic = 1,
4891 .dpcm_capture = 1,
4892 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
4893 SND_SOC_DPCM_TRIGGER_POST},
4894 .codec_dai_name = "snd-soc-dummy-dai",
4895 .codec_name = "snd-soc-dummy",
4896 .ignore_suspend = 1,
4897 .ignore_pmdown_time = 1,
4898 .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
4899 },
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07004900};
4901
4902static struct snd_soc_dai_link msm_common_be_dai_links[] = {
4903 /* Backend AFE DAI Links */
4904 {
4905 .name = LPASS_BE_AFE_PCM_RX,
4906 .stream_name = "AFE Playback",
4907 .cpu_dai_name = "msm-dai-q6-dev.224",
4908 .platform_name = "msm-pcm-routing",
4909 .codec_name = "msm-stub-codec.1",
4910 .codec_dai_name = "msm-stub-rx",
4911 .no_pcm = 1,
4912 .dpcm_playback = 1,
4913 .id = MSM_BACKEND_DAI_AFE_PCM_RX,
4914 .be_hw_params_fixup = msm_be_hw_params_fixup,
4915 /* this dainlink has playback support */
4916 .ignore_pmdown_time = 1,
4917 .ignore_suspend = 1,
4918 },
4919 {
4920 .name = LPASS_BE_AFE_PCM_TX,
4921 .stream_name = "AFE Capture",
4922 .cpu_dai_name = "msm-dai-q6-dev.225",
4923 .platform_name = "msm-pcm-routing",
4924 .codec_name = "msm-stub-codec.1",
4925 .codec_dai_name = "msm-stub-tx",
4926 .no_pcm = 1,
4927 .dpcm_capture = 1,
4928 .id = MSM_BACKEND_DAI_AFE_PCM_TX,
4929 .be_hw_params_fixup = msm_be_hw_params_fixup,
4930 .ignore_suspend = 1,
4931 },
4932 /* Incall Record Uplink BACK END DAI Link */
4933 {
4934 .name = LPASS_BE_INCALL_RECORD_TX,
4935 .stream_name = "Voice Uplink Capture",
4936 .cpu_dai_name = "msm-dai-q6-dev.32772",
4937 .platform_name = "msm-pcm-routing",
4938 .codec_name = "msm-stub-codec.1",
4939 .codec_dai_name = "msm-stub-tx",
4940 .no_pcm = 1,
4941 .dpcm_capture = 1,
4942 .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
4943 .be_hw_params_fixup = msm_be_hw_params_fixup,
4944 .ignore_suspend = 1,
4945 },
4946 /* Incall Record Downlink BACK END DAI Link */
4947 {
4948 .name = LPASS_BE_INCALL_RECORD_RX,
4949 .stream_name = "Voice Downlink Capture",
4950 .cpu_dai_name = "msm-dai-q6-dev.32771",
4951 .platform_name = "msm-pcm-routing",
4952 .codec_name = "msm-stub-codec.1",
4953 .codec_dai_name = "msm-stub-tx",
4954 .no_pcm = 1,
4955 .dpcm_capture = 1,
4956 .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
4957 .be_hw_params_fixup = msm_be_hw_params_fixup,
4958 .ignore_suspend = 1,
4959 },
4960 /* Incall Music BACK END DAI Link */
4961 {
4962 .name = LPASS_BE_VOICE_PLAYBACK_TX,
4963 .stream_name = "Voice Farend Playback",
4964 .cpu_dai_name = "msm-dai-q6-dev.32773",
4965 .platform_name = "msm-pcm-routing",
4966 .codec_name = "msm-stub-codec.1",
4967 .codec_dai_name = "msm-stub-rx",
4968 .no_pcm = 1,
4969 .dpcm_playback = 1,
4970 .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
4971 .be_hw_params_fixup = msm_be_hw_params_fixup,
4972 .ignore_suspend = 1,
4973 .ignore_pmdown_time = 1,
4974 },
4975 /* Incall Music 2 BACK END DAI Link */
4976 {
4977 .name = LPASS_BE_VOICE2_PLAYBACK_TX,
4978 .stream_name = "Voice2 Farend Playback",
4979 .cpu_dai_name = "msm-dai-q6-dev.32770",
4980 .platform_name = "msm-pcm-routing",
4981 .codec_name = "msm-stub-codec.1",
4982 .codec_dai_name = "msm-stub-rx",
4983 .no_pcm = 1,
4984 .dpcm_playback = 1,
4985 .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
4986 .be_hw_params_fixup = msm_be_hw_params_fixup,
4987 .ignore_suspend = 1,
4988 .ignore_pmdown_time = 1,
4989 },
4990 {
4991 .name = LPASS_BE_USB_AUDIO_RX,
4992 .stream_name = "USB Audio Playback",
4993 .cpu_dai_name = "msm-dai-q6-dev.28672",
4994 .platform_name = "msm-pcm-routing",
4995 .codec_name = "msm-stub-codec.1",
4996 .codec_dai_name = "msm-stub-rx",
4997 .no_pcm = 1,
4998 .dpcm_playback = 1,
4999 .id = MSM_BACKEND_DAI_USB_RX,
5000 .be_hw_params_fixup = msm_be_hw_params_fixup,
5001 .ignore_pmdown_time = 1,
5002 .ignore_suspend = 1,
5003 },
5004 {
5005 .name = LPASS_BE_USB_AUDIO_TX,
5006 .stream_name = "USB Audio Capture",
5007 .cpu_dai_name = "msm-dai-q6-dev.28673",
5008 .platform_name = "msm-pcm-routing",
5009 .codec_name = "msm-stub-codec.1",
5010 .codec_dai_name = "msm-stub-tx",
5011 .no_pcm = 1,
5012 .dpcm_capture = 1,
5013 .id = MSM_BACKEND_DAI_USB_TX,
5014 .be_hw_params_fixup = msm_be_hw_params_fixup,
5015 .ignore_suspend = 1,
5016 },
5017 {
5018 .name = LPASS_BE_PRI_TDM_RX_0,
5019 .stream_name = "Primary TDM0 Playback",
5020 .cpu_dai_name = "msm-dai-q6-tdm.36864",
5021 .platform_name = "msm-pcm-routing",
5022 .codec_name = "msm-stub-codec.1",
5023 .codec_dai_name = "msm-stub-rx",
5024 .no_pcm = 1,
5025 .dpcm_playback = 1,
5026 .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
5027 .be_hw_params_fixup = msm_be_hw_params_fixup,
5028 .ops = &kona_tdm_be_ops,
5029 .ignore_suspend = 1,
5030 .ignore_pmdown_time = 1,
5031 },
5032 {
5033 .name = LPASS_BE_PRI_TDM_TX_0,
5034 .stream_name = "Primary TDM0 Capture",
5035 .cpu_dai_name = "msm-dai-q6-tdm.36865",
5036 .platform_name = "msm-pcm-routing",
5037 .codec_name = "msm-stub-codec.1",
5038 .codec_dai_name = "msm-stub-tx",
5039 .no_pcm = 1,
5040 .dpcm_capture = 1,
5041 .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
5042 .be_hw_params_fixup = msm_be_hw_params_fixup,
5043 .ops = &kona_tdm_be_ops,
5044 .ignore_suspend = 1,
5045 },
5046 {
5047 .name = LPASS_BE_SEC_TDM_RX_0,
5048 .stream_name = "Secondary TDM0 Playback",
5049 .cpu_dai_name = "msm-dai-q6-tdm.36880",
5050 .platform_name = "msm-pcm-routing",
5051 .codec_name = "msm-stub-codec.1",
5052 .codec_dai_name = "msm-stub-rx",
5053 .no_pcm = 1,
5054 .dpcm_playback = 1,
5055 .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
5056 .be_hw_params_fixup = msm_be_hw_params_fixup,
5057 .ops = &kona_tdm_be_ops,
5058 .ignore_suspend = 1,
5059 .ignore_pmdown_time = 1,
5060 },
5061 {
5062 .name = LPASS_BE_SEC_TDM_TX_0,
5063 .stream_name = "Secondary TDM0 Capture",
5064 .cpu_dai_name = "msm-dai-q6-tdm.36881",
5065 .platform_name = "msm-pcm-routing",
5066 .codec_name = "msm-stub-codec.1",
5067 .codec_dai_name = "msm-stub-tx",
5068 .no_pcm = 1,
5069 .dpcm_capture = 1,
5070 .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
5071 .be_hw_params_fixup = msm_be_hw_params_fixup,
5072 .ops = &kona_tdm_be_ops,
5073 .ignore_suspend = 1,
5074 },
5075 {
5076 .name = LPASS_BE_TERT_TDM_RX_0,
5077 .stream_name = "Tertiary TDM0 Playback",
5078 .cpu_dai_name = "msm-dai-q6-tdm.36896",
5079 .platform_name = "msm-pcm-routing",
5080 .codec_name = "msm-stub-codec.1",
5081 .codec_dai_name = "msm-stub-rx",
5082 .no_pcm = 1,
5083 .dpcm_playback = 1,
5084 .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
5085 .be_hw_params_fixup = msm_be_hw_params_fixup,
5086 .ops = &kona_tdm_be_ops,
5087 .ignore_suspend = 1,
5088 .ignore_pmdown_time = 1,
5089 },
5090 {
5091 .name = LPASS_BE_TERT_TDM_TX_0,
5092 .stream_name = "Tertiary TDM0 Capture",
5093 .cpu_dai_name = "msm-dai-q6-tdm.36897",
5094 .platform_name = "msm-pcm-routing",
5095 .codec_name = "msm-stub-codec.1",
5096 .codec_dai_name = "msm-stub-tx",
5097 .no_pcm = 1,
5098 .dpcm_capture = 1,
5099 .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
5100 .be_hw_params_fixup = msm_be_hw_params_fixup,
5101 .ops = &kona_tdm_be_ops,
5102 .ignore_suspend = 1,
5103 },
5104};
5105
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08005106static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
5107 {
5108 .name = LPASS_BE_SLIMBUS_7_RX,
5109 .stream_name = "Slimbus7 Playback",
5110 .cpu_dai_name = "msm-dai-q6-dev.16398",
5111 .platform_name = "msm-pcm-routing",
5112 .codec_name = "btfmslim_slave",
5113 /* BT codec driver determines capabilities based on
5114 * dai name, bt codecdai name should always contains
5115 * supported usecase information
5116 */
5117 .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
5118 .no_pcm = 1,
5119 .dpcm_playback = 1,
5120 .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
5121 .be_hw_params_fixup = msm_be_hw_params_fixup,
5122 .init = &msm_wcn_init,
5123 .ops = &msm_wcn_ops,
5124 /* dai link has playback support */
5125 .ignore_pmdown_time = 1,
5126 .ignore_suspend = 1,
5127 },
5128 {
5129 .name = LPASS_BE_SLIMBUS_7_TX,
5130 .stream_name = "Slimbus7 Capture",
5131 .cpu_dai_name = "msm-dai-q6-dev.16399",
5132 .platform_name = "msm-pcm-routing",
5133 .codec_name = "btfmslim_slave",
5134 .codec_dai_name = "btfm_bt_sco_slim_tx",
5135 .no_pcm = 1,
5136 .dpcm_capture = 1,
5137 .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
5138 .be_hw_params_fixup = msm_be_hw_params_fixup,
5139 .ops = &msm_wcn_ops,
5140 .ignore_suspend = 1,
5141 },
5142};
5143
5144static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
5145 /* DISP PORT BACK END DAI Link */
5146 {
5147 .name = LPASS_BE_DISPLAY_PORT,
5148 .stream_name = "Display Port Playback",
5149 .cpu_dai_name = "msm-dai-q6-dp.24608",
5150 .platform_name = "msm-pcm-routing",
5151 .codec_name = "msm-ext-disp-audio-codec-rx",
5152 .codec_dai_name = "msm_dp_audio_codec_rx_dai",
5153 .no_pcm = 1,
5154 .dpcm_playback = 1,
5155 .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
5156 .be_hw_params_fixup = msm_be_hw_params_fixup,
5157 .ignore_pmdown_time = 1,
5158 .ignore_suspend = 1,
5159 },
5160 /* DISP PORT 1 BACK END DAI Link */
5161 {
5162 .name = LPASS_BE_DISPLAY_PORT1,
5163 .stream_name = "Display Port1 Playback",
5164 .cpu_dai_name = "msm-dai-q6-dp.24608",
5165 .platform_name = "msm-pcm-routing",
5166 .codec_name = "msm-ext-disp-audio-codec-rx",
5167 .codec_dai_name = "msm_dp_audio_codec_rx1_dai",
5168 .no_pcm = 1,
5169 .dpcm_playback = 1,
5170 .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
5171 .be_hw_params_fixup = msm_be_hw_params_fixup,
5172 .ignore_pmdown_time = 1,
5173 .ignore_suspend = 1,
5174 },
5175};
5176
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07005177static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
5178 {
5179 .name = LPASS_BE_PRI_MI2S_RX,
5180 .stream_name = "Primary MI2S Playback",
5181 .cpu_dai_name = "msm-dai-q6-mi2s.0",
5182 .platform_name = "msm-pcm-routing",
5183 .codec_name = "msm-stub-codec.1",
5184 .codec_dai_name = "msm-stub-rx",
5185 .no_pcm = 1,
5186 .dpcm_playback = 1,
5187 .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
5188 .be_hw_params_fixup = msm_be_hw_params_fixup,
5189 .ops = &msm_mi2s_be_ops,
5190 .ignore_suspend = 1,
5191 .ignore_pmdown_time = 1,
5192 },
5193 {
5194 .name = LPASS_BE_PRI_MI2S_TX,
5195 .stream_name = "Primary MI2S Capture",
5196 .cpu_dai_name = "msm-dai-q6-mi2s.0",
5197 .platform_name = "msm-pcm-routing",
5198 .codec_name = "msm-stub-codec.1",
5199 .codec_dai_name = "msm-stub-tx",
5200 .no_pcm = 1,
5201 .dpcm_capture = 1,
5202 .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
5203 .be_hw_params_fixup = msm_be_hw_params_fixup,
5204 .ops = &msm_mi2s_be_ops,
5205 .ignore_suspend = 1,
5206 },
5207 {
5208 .name = LPASS_BE_SEC_MI2S_RX,
5209 .stream_name = "Secondary MI2S Playback",
5210 .cpu_dai_name = "msm-dai-q6-mi2s.1",
5211 .platform_name = "msm-pcm-routing",
5212 .codec_name = "msm-stub-codec.1",
5213 .codec_dai_name = "msm-stub-rx",
5214 .no_pcm = 1,
5215 .dpcm_playback = 1,
5216 .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
5217 .be_hw_params_fixup = msm_be_hw_params_fixup,
5218 .ops = &msm_mi2s_be_ops,
5219 .ignore_suspend = 1,
5220 .ignore_pmdown_time = 1,
5221 },
5222 {
5223 .name = LPASS_BE_SEC_MI2S_TX,
5224 .stream_name = "Secondary MI2S Capture",
5225 .cpu_dai_name = "msm-dai-q6-mi2s.1",
5226 .platform_name = "msm-pcm-routing",
5227 .codec_name = "msm-stub-codec.1",
5228 .codec_dai_name = "msm-stub-tx",
5229 .no_pcm = 1,
5230 .dpcm_capture = 1,
5231 .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
5232 .be_hw_params_fixup = msm_be_hw_params_fixup,
5233 .ops = &msm_mi2s_be_ops,
5234 .ignore_suspend = 1,
5235 },
5236 {
5237 .name = LPASS_BE_TERT_MI2S_RX,
5238 .stream_name = "Tertiary MI2S Playback",
5239 .cpu_dai_name = "msm-dai-q6-mi2s.2",
5240 .platform_name = "msm-pcm-routing",
5241 .codec_name = "msm-stub-codec.1",
5242 .codec_dai_name = "msm-stub-rx",
5243 .no_pcm = 1,
5244 .dpcm_playback = 1,
5245 .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
5246 .be_hw_params_fixup = msm_be_hw_params_fixup,
5247 .ops = &msm_mi2s_be_ops,
5248 .ignore_suspend = 1,
5249 .ignore_pmdown_time = 1,
5250 },
5251 {
5252 .name = LPASS_BE_TERT_MI2S_TX,
5253 .stream_name = "Tertiary MI2S Capture",
5254 .cpu_dai_name = "msm-dai-q6-mi2s.2",
5255 .platform_name = "msm-pcm-routing",
5256 .codec_name = "msm-stub-codec.1",
5257 .codec_dai_name = "msm-stub-tx",
5258 .no_pcm = 1,
5259 .dpcm_capture = 1,
5260 .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
5261 .be_hw_params_fixup = msm_be_hw_params_fixup,
5262 .ops = &msm_mi2s_be_ops,
5263 .ignore_suspend = 1,
5264 },
5265};
5266
5267static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
5268 /* Primary AUX PCM Backend DAI Links */
5269 {
5270 .name = LPASS_BE_AUXPCM_RX,
5271 .stream_name = "AUX PCM Playback",
5272 .cpu_dai_name = "msm-dai-q6-auxpcm.1",
5273 .platform_name = "msm-pcm-routing",
5274 .codec_name = "msm-stub-codec.1",
5275 .codec_dai_name = "msm-stub-rx",
5276 .no_pcm = 1,
5277 .dpcm_playback = 1,
5278 .id = MSM_BACKEND_DAI_AUXPCM_RX,
5279 .be_hw_params_fixup = msm_be_hw_params_fixup,
5280 .ignore_pmdown_time = 1,
5281 .ignore_suspend = 1,
5282 },
5283 {
5284 .name = LPASS_BE_AUXPCM_TX,
5285 .stream_name = "AUX PCM Capture",
5286 .cpu_dai_name = "msm-dai-q6-auxpcm.1",
5287 .platform_name = "msm-pcm-routing",
5288 .codec_name = "msm-stub-codec.1",
5289 .codec_dai_name = "msm-stub-tx",
5290 .no_pcm = 1,
5291 .dpcm_capture = 1,
5292 .id = MSM_BACKEND_DAI_AUXPCM_TX,
5293 .be_hw_params_fixup = msm_be_hw_params_fixup,
5294 .ignore_suspend = 1,
5295 },
5296 /* Secondary AUX PCM Backend DAI Links */
5297 {
5298 .name = LPASS_BE_SEC_AUXPCM_RX,
5299 .stream_name = "Sec AUX PCM Playback",
5300 .cpu_dai_name = "msm-dai-q6-auxpcm.2",
5301 .platform_name = "msm-pcm-routing",
5302 .codec_name = "msm-stub-codec.1",
5303 .codec_dai_name = "msm-stub-rx",
5304 .no_pcm = 1,
5305 .dpcm_playback = 1,
5306 .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
5307 .be_hw_params_fixup = msm_be_hw_params_fixup,
5308 .ignore_pmdown_time = 1,
5309 .ignore_suspend = 1,
5310 },
5311 {
5312 .name = LPASS_BE_SEC_AUXPCM_TX,
5313 .stream_name = "Sec AUX PCM Capture",
5314 .cpu_dai_name = "msm-dai-q6-auxpcm.2",
5315 .platform_name = "msm-pcm-routing",
5316 .codec_name = "msm-stub-codec.1",
5317 .codec_dai_name = "msm-stub-tx",
5318 .no_pcm = 1,
5319 .dpcm_capture = 1,
5320 .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
5321 .be_hw_params_fixup = msm_be_hw_params_fixup,
5322 .ignore_suspend = 1,
5323 },
5324 /* Tertiary AUX PCM Backend DAI Links */
5325 {
5326 .name = LPASS_BE_TERT_AUXPCM_RX,
5327 .stream_name = "Tert AUX PCM Playback",
5328 .cpu_dai_name = "msm-dai-q6-auxpcm.3",
5329 .platform_name = "msm-pcm-routing",
5330 .codec_name = "msm-stub-codec.1",
5331 .codec_dai_name = "msm-stub-rx",
5332 .no_pcm = 1,
5333 .dpcm_playback = 1,
5334 .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
5335 .be_hw_params_fixup = msm_be_hw_params_fixup,
5336 .ignore_suspend = 1,
5337 },
5338 {
5339 .name = LPASS_BE_TERT_AUXPCM_TX,
5340 .stream_name = "Tert AUX PCM Capture",
5341 .cpu_dai_name = "msm-dai-q6-auxpcm.3",
5342 .platform_name = "msm-pcm-routing",
5343 .codec_name = "msm-stub-codec.1",
5344 .codec_dai_name = "msm-stub-tx",
5345 .no_pcm = 1,
5346 .dpcm_capture = 1,
5347 .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
5348 .be_hw_params_fixup = msm_be_hw_params_fixup,
5349 .ignore_suspend = 1,
5350 },
5351};
5352
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07005353static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
5354 /* WSA CDC DMA Backend DAI Links */
5355 {
5356 .name = LPASS_BE_WSA_CDC_DMA_RX_0,
5357 .stream_name = "WSA CDC DMA0 Playback",
5358 .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
5359 .platform_name = "msm-pcm-routing",
5360 .codec_name = "bolero_codec",
5361 .codec_dai_name = "wsa_macro_rx1",
5362 .no_pcm = 1,
5363 .dpcm_playback = 1,
5364 .init = &msm_int_audrx_init,
5365 .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
5366 .be_hw_params_fixup = msm_be_hw_params_fixup,
5367 .ignore_pmdown_time = 1,
5368 .ignore_suspend = 1,
5369 .ops = &msm_cdc_dma_be_ops,
5370 },
5371 {
5372 .name = LPASS_BE_WSA_CDC_DMA_RX_1,
5373 .stream_name = "WSA CDC DMA1 Playback",
5374 .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
5375 .platform_name = "msm-pcm-routing",
5376 .codec_name = "bolero_codec",
5377 .codec_dai_name = "wsa_macro_rx_mix",
5378 .no_pcm = 1,
5379 .dpcm_playback = 1,
5380 .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
5381 .be_hw_params_fixup = msm_be_hw_params_fixup,
5382 .ignore_pmdown_time = 1,
5383 .ignore_suspend = 1,
5384 .ops = &msm_cdc_dma_be_ops,
5385 },
5386 {
5387 .name = LPASS_BE_WSA_CDC_DMA_TX_1,
5388 .stream_name = "WSA CDC DMA1 Capture",
5389 .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
5390 .platform_name = "msm-pcm-routing",
5391 .codec_name = "bolero_codec",
5392 .codec_dai_name = "wsa_macro_echo",
5393 .no_pcm = 1,
5394 .dpcm_capture = 1,
5395 .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
5396 .be_hw_params_fixup = msm_be_hw_params_fixup,
5397 .ignore_suspend = 1,
5398 .ops = &msm_cdc_dma_be_ops,
5399 },
5400};
5401
5402static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
5403 /* RX CDC DMA Backend DAI Links */
5404 {
5405 .name = LPASS_BE_RX_CDC_DMA_RX_0,
5406 .stream_name = "RX CDC DMA0 Playback",
5407 .cpu_dai_name = "msm-dai-cdc-dma-dev.45104",
5408 .platform_name = "msm-pcm-routing",
5409 .codec_name = "bolero_codec",
5410 .codec_dai_name = "rx_macro_rx1",
5411 .no_pcm = 1,
5412 .dpcm_playback = 1,
5413 .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
5414 .be_hw_params_fixup = msm_be_hw_params_fixup,
5415 .ignore_pmdown_time = 1,
5416 .ignore_suspend = 1,
5417 .ops = &msm_cdc_dma_be_ops,
5418 },
5419 {
5420 .name = LPASS_BE_RX_CDC_DMA_RX_1,
5421 .stream_name = "RX CDC DMA1 Playback",
5422 .cpu_dai_name = "msm-dai-cdc-dma-dev.45106",
5423 .platform_name = "msm-pcm-routing",
5424 .codec_name = "bolero_codec",
5425 .codec_dai_name = "rx_macro_rx2",
5426 .no_pcm = 1,
5427 .dpcm_playback = 1,
5428 .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
5429 .be_hw_params_fixup = msm_be_hw_params_fixup,
5430 .ignore_pmdown_time = 1,
5431 .ignore_suspend = 1,
5432 .ops = &msm_cdc_dma_be_ops,
5433 },
5434 {
5435 .name = LPASS_BE_RX_CDC_DMA_RX_2,
5436 .stream_name = "RX CDC DMA2 Playback",
5437 .cpu_dai_name = "msm-dai-cdc-dma-dev.45108",
5438 .platform_name = "msm-pcm-routing",
5439 .codec_name = "bolero_codec",
5440 .codec_dai_name = "rx_macro_rx3",
5441 .no_pcm = 1,
5442 .dpcm_playback = 1,
5443 .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
5444 .be_hw_params_fixup = msm_be_hw_params_fixup,
5445 .ignore_pmdown_time = 1,
5446 .ignore_suspend = 1,
5447 .ops = &msm_cdc_dma_be_ops,
5448 },
5449 {
5450 .name = LPASS_BE_RX_CDC_DMA_RX_3,
5451 .stream_name = "RX CDC DMA3 Playback",
5452 .cpu_dai_name = "msm-dai-cdc-dma-dev.45110",
5453 .platform_name = "msm-pcm-routing",
5454 .codec_name = "bolero_codec",
5455 .codec_dai_name = "rx_macro_rx4",
5456 .no_pcm = 1,
5457 .dpcm_playback = 1,
5458 .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
5459 .be_hw_params_fixup = msm_be_hw_params_fixup,
5460 .ignore_pmdown_time = 1,
5461 .ignore_suspend = 1,
5462 .ops = &msm_cdc_dma_be_ops,
5463 },
5464 /* TX CDC DMA Backend DAI Links */
5465 {
5466 .name = LPASS_BE_TX_CDC_DMA_TX_3,
5467 .stream_name = "TX CDC DMA3 Capture",
5468 .cpu_dai_name = "msm-dai-cdc-dma-dev.45111",
5469 .platform_name = "msm-pcm-routing",
5470 .codec_name = "bolero_codec",
5471 .codec_dai_name = "tx_macro_tx1",
5472 .no_pcm = 1,
5473 .dpcm_capture = 1,
5474 .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
5475 .be_hw_params_fixup = msm_be_hw_params_fixup,
5476 .ignore_suspend = 1,
5477 .ops = &msm_cdc_dma_be_ops,
5478 },
5479 {
5480 .name = LPASS_BE_TX_CDC_DMA_TX_4,
5481 .stream_name = "TX CDC DMA4 Capture",
5482 .cpu_dai_name = "msm-dai-cdc-dma-dev.45113",
5483 .platform_name = "msm-pcm-routing",
5484 .codec_name = "bolero_codec",
5485 .codec_dai_name = "tx_macro_tx2",
5486 .no_pcm = 1,
5487 .dpcm_capture = 1,
5488 .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
5489 .be_hw_params_fixup = msm_be_hw_params_fixup,
5490 .ignore_suspend = 1,
5491 .ops = &msm_cdc_dma_be_ops,
5492 },
5493};
5494
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08005495static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
5496 {
5497 .name = LPASS_BE_VA_CDC_DMA_TX_0,
5498 .stream_name = "VA CDC DMA0 Capture",
5499 .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
5500 .platform_name = "msm-pcm-routing",
5501 .codec_name = "bolero_codec",
5502 .codec_dai_name = "va_macro_tx1",
5503 .no_pcm = 1,
5504 .dpcm_capture = 1,
5505 .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
5506 .be_hw_params_fixup = msm_be_hw_params_fixup,
5507 .ignore_suspend = 1,
5508 .ops = &msm_cdc_dma_be_ops,
5509 },
5510 {
5511 .name = LPASS_BE_VA_CDC_DMA_TX_1,
5512 .stream_name = "VA CDC DMA1 Capture",
5513 .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
5514 .platform_name = "msm-pcm-routing",
5515 .codec_name = "bolero_codec",
5516 .codec_dai_name = "va_macro_tx2",
5517 .no_pcm = 1,
5518 .dpcm_capture = 1,
5519 .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
5520 .be_hw_params_fixup = msm_be_hw_params_fixup,
5521 .ignore_suspend = 1,
5522 .ops = &msm_cdc_dma_be_ops,
5523 },
5524 {
5525 .name = LPASS_BE_VA_CDC_DMA_TX_2,
5526 .stream_name = "VA CDC DMA2 Capture",
5527 .cpu_dai_name = "msm-dai-cdc-dma-dev.45093",
5528 .platform_name = "msm-pcm-routing",
5529 .codec_name = "bolero_codec",
5530 .codec_dai_name = "va_macro_tx3",
5531 .no_pcm = 1,
5532 .dpcm_capture = 1,
5533 .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
5534 .be_hw_params_fixup = msm_be_hw_params_fixup,
5535 .ignore_suspend = 1,
5536 .ops = &msm_cdc_dma_be_ops,
5537 },
5538};
5539
Meng Wange8e53822019-03-18 10:49:50 +08005540static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
5541 {
5542 .name = LPASS_BE_AFE_LOOPBACK_TX,
5543 .stream_name = "AFE Loopback Capture",
5544 .cpu_dai_name = "msm-dai-q6-dev.24577",
5545 .platform_name = "msm-pcm-routing",
5546 .codec_name = "msm-stub-codec.1",
5547 .codec_dai_name = "msm-stub-tx",
5548 .no_pcm = 1,
5549 .dpcm_capture = 1,
5550 .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
5551 .be_hw_params_fixup = msm_be_hw_params_fixup,
5552 .ignore_pmdown_time = 1,
5553 .ignore_suspend = 1,
5554 },
5555};
5556
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07005557static struct snd_soc_dai_link msm_kona_dai_links[
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07005558 ARRAY_SIZE(msm_common_dai_links) +
5559 ARRAY_SIZE(msm_bolero_fe_dai_links) +
5560 ARRAY_SIZE(msm_common_misc_fe_dai_links) +
5561 ARRAY_SIZE(msm_common_be_dai_links) +
5562 ARRAY_SIZE(msm_mi2s_be_dai_links) +
5563 ARRAY_SIZE(msm_auxpcm_be_dai_links) +
5564 ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08005565 ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08005566 ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
5567 ARRAY_SIZE(ext_disp_be_dai_link) +
Meng Wange8e53822019-03-18 10:49:50 +08005568 ARRAY_SIZE(msm_wcn_be_dai_links) +
5569 ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link)];
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07005570
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07005571static int msm_populate_dai_link_component_of_node(
5572 struct snd_soc_card *card)
5573{
5574 int i, index, ret = 0;
5575 struct device *cdev = card->dev;
5576 struct snd_soc_dai_link *dai_link = card->dai_link;
5577 struct device_node *np;
5578
5579 if (!cdev) {
5580 dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
5581 return -ENODEV;
5582 }
5583
5584 for (i = 0; i < card->num_links; i++) {
5585 if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
5586 continue;
5587
5588 /* populate platform_of_node for snd card dai links */
5589 if (dai_link[i].platform_name &&
5590 !dai_link[i].platform_of_node) {
5591 index = of_property_match_string(cdev->of_node,
5592 "asoc-platform-names",
5593 dai_link[i].platform_name);
5594 if (index < 0) {
5595 dev_err(cdev, "%s: No match found for platform name: %s\n",
5596 __func__, dai_link[i].platform_name);
5597 ret = index;
5598 goto err;
5599 }
5600 np = of_parse_phandle(cdev->of_node, "asoc-platform",
5601 index);
5602 if (!np) {
5603 dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
5604 __func__, dai_link[i].platform_name,
5605 index);
5606 ret = -ENODEV;
5607 goto err;
5608 }
5609 dai_link[i].platform_of_node = np;
5610 dai_link[i].platform_name = NULL;
5611 }
5612
5613 /* populate cpu_of_node for snd card dai links */
5614 if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
5615 index = of_property_match_string(cdev->of_node,
5616 "asoc-cpu-names",
5617 dai_link[i].cpu_dai_name);
5618 if (index >= 0) {
5619 np = of_parse_phandle(cdev->of_node, "asoc-cpu",
5620 index);
5621 if (!np) {
5622 dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
5623 __func__,
5624 dai_link[i].cpu_dai_name);
5625 ret = -ENODEV;
5626 goto err;
5627 }
5628 dai_link[i].cpu_of_node = np;
5629 dai_link[i].cpu_dai_name = NULL;
5630 }
5631 }
5632
5633 /* populate codec_of_node for snd card dai links */
5634 if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
5635 index = of_property_match_string(cdev->of_node,
5636 "asoc-codec-names",
5637 dai_link[i].codec_name);
5638 if (index < 0)
5639 continue;
5640 np = of_parse_phandle(cdev->of_node, "asoc-codec",
5641 index);
5642 if (!np) {
5643 dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
5644 __func__, dai_link[i].codec_name);
5645 ret = -ENODEV;
5646 goto err;
5647 }
5648 dai_link[i].codec_of_node = np;
5649 dai_link[i].codec_name = NULL;
5650 }
5651 }
5652
5653err:
5654 return ret;
5655}
5656
5657static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
5658{
5659 int ret = -EINVAL;
5660 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
5661
5662 if (!component) {
5663 pr_err("* %s: No match for msm-stub-codec component\n", __func__);
5664 return ret;
5665 }
5666
5667 ret = snd_soc_add_component_controls(component, msm_snd_controls,
5668 ARRAY_SIZE(msm_snd_controls));
5669 if (ret < 0) {
5670 dev_err(component->dev,
5671 "%s: add_codec_controls failed, err = %d\n",
5672 __func__, ret);
5673 return ret;
5674 }
5675
5676 return ret;
5677}
5678
5679static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
5680 struct snd_pcm_hw_params *params)
5681{
5682 return 0;
5683}
5684
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07005685static struct snd_soc_ops msm_stub_be_ops = {
5686 .hw_params = msm_snd_stub_hw_params,
5687};
5688
5689struct snd_soc_card snd_soc_card_stub_msm = {
5690 .name = "kona-stub-snd-card",
5691};
5692
5693static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
5694 /* FrontEnd DAI Links */
5695 {
5696 .name = "MSMSTUB Media1",
5697 .stream_name = "MultiMedia1",
5698 .cpu_dai_name = "MultiMedia1",
5699 .platform_name = "msm-pcm-dsp.0",
5700 .dynamic = 1,
5701 .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
5702 .dpcm_playback = 1,
5703 .dpcm_capture = 1,
5704 .trigger = {SND_SOC_DPCM_TRIGGER_POST,
5705 SND_SOC_DPCM_TRIGGER_POST},
5706 .codec_dai_name = "snd-soc-dummy-dai",
5707 .codec_name = "snd-soc-dummy",
5708 .ignore_suspend = 1,
5709 /* this dainlink has playback support */
5710 .ignore_pmdown_time = 1,
5711 .id = MSM_FRONTEND_DAI_MULTIMEDIA1
5712 },
5713};
5714
5715static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
5716 /* Backend DAI Links */
5717 {
5718 .name = LPASS_BE_AUXPCM_RX,
5719 .stream_name = "AUX PCM Playback",
5720 .cpu_dai_name = "msm-dai-q6-auxpcm.1",
5721 .platform_name = "msm-pcm-routing",
5722 .codec_name = "msm-stub-codec.1",
5723 .codec_dai_name = "msm-stub-rx",
5724 .no_pcm = 1,
5725 .dpcm_playback = 1,
5726 .id = MSM_BACKEND_DAI_AUXPCM_RX,
5727 .init = &msm_audrx_stub_init,
5728 .be_hw_params_fixup = msm_be_hw_params_fixup,
5729 .ignore_pmdown_time = 1,
5730 .ignore_suspend = 1,
5731 .ops = &msm_stub_be_ops,
5732 },
5733 {
5734 .name = LPASS_BE_AUXPCM_TX,
5735 .stream_name = "AUX PCM Capture",
5736 .cpu_dai_name = "msm-dai-q6-auxpcm.1",
5737 .platform_name = "msm-pcm-routing",
5738 .codec_name = "msm-stub-codec.1",
5739 .codec_dai_name = "msm-stub-tx",
5740 .no_pcm = 1,
5741 .dpcm_capture = 1,
5742 .id = MSM_BACKEND_DAI_AUXPCM_TX,
5743 .be_hw_params_fixup = msm_be_hw_params_fixup,
5744 .ignore_suspend = 1,
5745 .ops = &msm_stub_be_ops,
5746 },
5747};
5748
5749static struct snd_soc_dai_link msm_stub_dai_links[
5750 ARRAY_SIZE(msm_stub_fe_dai_links) +
5751 ARRAY_SIZE(msm_stub_be_dai_links)];
5752
5753static const struct of_device_id kona_asoc_machine_of_match[] = {
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07005754 { .compatible = "qcom,kona-asoc-snd",
5755 .data = "codec"},
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07005756 { .compatible = "qcom,kona-asoc-snd-stub",
5757 .data = "stub_codec"},
5758 {},
5759};
5760
5761static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
5762{
5763 struct snd_soc_card *card = NULL;
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07005764 struct snd_soc_dai_link *dailink = NULL;
5765 int len_1 = 0;
5766 int len_2 = 0;
5767 int total_links = 0;
5768 int rc = 0;
5769 u32 mi2s_audio_intf = 0;
5770 u32 auxpcm_audio_intf = 0;
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08005771 u32 val = 0;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07005772 const struct of_device_id *match;
5773
5774 match = of_match_node(kona_asoc_machine_of_match, dev->of_node);
5775 if (!match) {
5776 dev_err(dev, "%s: No DT match found for sound card\n",
5777 __func__);
5778 return NULL;
5779 }
5780
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07005781 if (!strcmp(match->data, "codec")) {
5782 card = &snd_soc_card_kona_msm;
5783
5784 memcpy(msm_kona_dai_links + total_links,
5785 msm_common_dai_links,
5786 sizeof(msm_common_dai_links));
5787 total_links += ARRAY_SIZE(msm_common_dai_links);
5788
5789 memcpy(msm_kona_dai_links + total_links,
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07005790 msm_bolero_fe_dai_links,
5791 sizeof(msm_bolero_fe_dai_links));
5792 total_links +=
5793 ARRAY_SIZE(msm_bolero_fe_dai_links);
5794
5795 memcpy(msm_kona_dai_links + total_links,
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07005796 msm_common_misc_fe_dai_links,
5797 sizeof(msm_common_misc_fe_dai_links));
5798 total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
5799
5800 memcpy(msm_kona_dai_links + total_links,
5801 msm_common_be_dai_links,
5802 sizeof(msm_common_be_dai_links));
5803 total_links += ARRAY_SIZE(msm_common_be_dai_links);
5804
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07005805 memcpy(msm_kona_dai_links + total_links,
5806 msm_wsa_cdc_dma_be_dai_links,
5807 sizeof(msm_wsa_cdc_dma_be_dai_links));
5808 total_links +=
5809 ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
5810
5811 memcpy(msm_kona_dai_links + total_links,
5812 msm_rx_tx_cdc_dma_be_dai_links,
5813 sizeof(msm_rx_tx_cdc_dma_be_dai_links));
5814 total_links +=
5815 ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
5816
Xiaoyu Ye2228bf02018-12-12 15:47:20 -08005817 memcpy(msm_kona_dai_links + total_links,
5818 msm_va_cdc_dma_be_dai_links,
5819 sizeof(msm_va_cdc_dma_be_dai_links));
5820 total_links +=
5821 ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
5822
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07005823 rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
5824 &mi2s_audio_intf);
5825 if (rc) {
5826 dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
5827 __func__);
5828 } else {
5829 if (mi2s_audio_intf) {
5830 memcpy(msm_kona_dai_links + total_links,
5831 msm_mi2s_be_dai_links,
5832 sizeof(msm_mi2s_be_dai_links));
5833 total_links +=
5834 ARRAY_SIZE(msm_mi2s_be_dai_links);
5835 }
5836 }
5837
5838 rc = of_property_read_u32(dev->of_node,
5839 "qcom,auxpcm-audio-intf",
5840 &auxpcm_audio_intf);
5841 if (rc) {
5842 dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
5843 __func__);
5844 } else {
5845 if (auxpcm_audio_intf) {
5846 memcpy(msm_kona_dai_links + total_links,
5847 msm_auxpcm_be_dai_links,
5848 sizeof(msm_auxpcm_be_dai_links));
5849 total_links +=
5850 ARRAY_SIZE(msm_auxpcm_be_dai_links);
5851 }
5852 }
5853
Karthikeyan Manieaad2ed2018-12-26 11:47:26 -08005854 rc = of_property_read_u32(dev->of_node,
5855 "qcom,ext-disp-audio-rx", &val);
5856 if (!rc && val) {
5857 dev_dbg(dev, "%s(): ext disp audio support present\n",
5858 __func__);
5859 memcpy(msm_kona_dai_links + total_links,
5860 ext_disp_be_dai_link,
5861 sizeof(ext_disp_be_dai_link));
5862 total_links += ARRAY_SIZE(ext_disp_be_dai_link);
5863 }
5864
5865 rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
5866 if (!rc && val) {
5867 dev_dbg(dev, "%s(): WCN BT support present\n",
5868 __func__);
5869 memcpy(msm_kona_dai_links + total_links,
5870 msm_wcn_be_dai_links,
5871 sizeof(msm_wcn_be_dai_links));
5872 total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
5873 }
5874
Meng Wange8e53822019-03-18 10:49:50 +08005875 rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
5876 &val);
5877 if (!rc && val) {
5878 memcpy(msm_kona_dai_links + total_links,
5879 msm_afe_rxtx_lb_be_dai_link,
5880 sizeof(msm_afe_rxtx_lb_be_dai_link));
5881 total_links +=
5882 ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
5883 }
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07005884 dailink = msm_kona_dai_links;
5885 } else if(!strcmp(match->data, "stub_codec")) {
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07005886 card = &snd_soc_card_stub_msm;
5887 len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
5888 len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
5889
5890 memcpy(msm_stub_dai_links,
5891 msm_stub_fe_dai_links,
5892 sizeof(msm_stub_fe_dai_links));
5893 memcpy(msm_stub_dai_links + len_1,
5894 msm_stub_be_dai_links,
5895 sizeof(msm_stub_be_dai_links));
5896
5897 dailink = msm_stub_dai_links;
5898 total_links = len_2;
5899 }
5900
5901 if (card) {
5902 card->dai_link = dailink;
5903 card->num_links = total_links;
5904 }
5905
5906 return card;
5907}
5908
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07005909static int msm_wsa881x_init(struct snd_soc_component *component)
5910{
5911 u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
5912 u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
5913 u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
5914 SPKR_L_BOOST, SPKR_L_VI};
5915 u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
5916 SPKR_R_BOOST, SPKR_R_VI};
5917 unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
5918 unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
5919 struct msm_asoc_mach_data *pdata;
5920 struct snd_soc_dapm_context *dapm;
5921 struct snd_card *card;
5922 struct snd_info_entry *entry;
5923 int ret = 0;
5924
5925 if (!component) {
5926 pr_err("%s component is NULL\n", __func__);
5927 return -EINVAL;
5928 }
5929
5930 card = component->card->snd_card;
5931 dapm = snd_soc_component_get_dapm(component);
5932
5933 if (!strcmp(component->name_prefix, "SpkrLeft")) {
5934 dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
5935 __func__, component->name);
5936 wsa881x_set_channel_map(component, &spkleft_ports[0],
5937 WSA881X_MAX_SWR_PORTS, &ch_mask[0],
5938 &ch_rate[0], &spkleft_port_types[0]);
5939 if (dapm->component) {
5940 snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
5941 snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
5942 }
5943 } else if (!strcmp(component->name_prefix, "SpkrRight")) {
5944 dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
5945 __func__, component->name);
5946 wsa881x_set_channel_map(component, &spkright_ports[0],
5947 WSA881X_MAX_SWR_PORTS, &ch_mask[0],
5948 &ch_rate[0], &spkright_port_types[0]);
5949 if (dapm->component) {
5950 snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
5951 snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
5952 }
5953 } else {
5954 dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
5955 component->name);
5956 ret = -EINVAL;
5957 goto err;
5958 }
5959 pdata = snd_soc_card_get_drvdata(component->card);
5960 if (!pdata->codec_root) {
5961 entry = snd_info_create_subdir(card->module, "codecs",
5962 card->proc_root);
5963 if (!entry) {
5964 pr_err("%s: Cannot create codecs module entry\n",
5965 __func__);
5966 ret = 0;
5967 goto err;
5968 }
5969 pdata->codec_root = entry;
5970 }
5971 wsa881x_codec_info_create_codec_entry(pdata->codec_root,
5972 component);
5973err:
5974 return ret;
5975}
5976
5977static int msm_aux_codec_init(struct snd_soc_component *component)
5978{
5979 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
5980 int ret = 0;
Karthikeyan Mani5eb13422018-11-05 13:49:17 -08005981 void *mbhc_calibration;
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07005982 struct snd_info_entry *entry;
5983 struct snd_card *card = component->card->snd_card;
5984 struct msm_asoc_mach_data *pdata;
5985
5986 snd_soc_dapm_ignore_suspend(dapm, "EAR");
5987 snd_soc_dapm_ignore_suspend(dapm, "AUX");
5988 snd_soc_dapm_ignore_suspend(dapm, "HPHL");
5989 snd_soc_dapm_ignore_suspend(dapm, "HPHR");
5990 snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
5991 snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
5992 snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
5993 snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
5994 snd_soc_dapm_sync(dapm);
5995
5996 pdata = snd_soc_card_get_drvdata(component->card);
5997 if (!pdata->codec_root) {
5998 entry = snd_info_create_subdir(card->module, "codecs",
5999 card->proc_root);
6000 if (!entry) {
Karthikeyan Mani5eb13422018-11-05 13:49:17 -08006001 dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006002 __func__);
6003 ret = 0;
Karthikeyan Mani5eb13422018-11-05 13:49:17 -08006004 goto mbhc_cfg_cal;
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006005 }
6006 pdata->codec_root = entry;
6007 }
Karthikeyan Mani5eb13422018-11-05 13:49:17 -08006008 wcd938x_info_create_codec_entry(pdata->codec_root, component);
6009
6010mbhc_cfg_cal:
6011 mbhc_calibration = def_wcd_mbhc_cal();
6012 if (!mbhc_calibration)
6013 return -ENOMEM;
6014 wcd_mbhc_cfg.calibration = mbhc_calibration;
6015 ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
6016 if (ret) {
6017 dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
6018 __func__, ret);
6019 goto err_hs_detect;
6020 }
6021 return 0;
6022
6023err_hs_detect:
6024 kfree(mbhc_calibration);
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006025 return ret;
6026}
6027
6028static int msm_init_aux_dev(struct platform_device *pdev,
6029 struct snd_soc_card *card)
6030{
6031 struct device_node *wsa_of_node;
6032 struct device_node *aux_codec_of_node;
6033 u32 wsa_max_devs;
6034 u32 wsa_dev_cnt;
6035 u32 codec_aux_dev_cnt = 0;
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006036 int i;
6037 struct msm_wsa881x_dev_info *wsa881x_dev_info;
6038 struct aux_codec_dev_info *aux_cdc_dev_info;
6039 const char *auxdev_name_prefix[1];
6040 char *dev_name_str = NULL;
6041 int found = 0;
6042 int codecs_found = 0;
6043 int ret = 0;
6044
6045 /* Get maximum WSA device count for this platform */
6046 ret = of_property_read_u32(pdev->dev.of_node,
6047 "qcom,wsa-max-devs", &wsa_max_devs);
6048 if (ret) {
6049 dev_info(&pdev->dev,
6050 "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
6051 __func__, pdev->dev.of_node->full_name, ret);
6052 wsa_max_devs = 0;
6053 goto codec_aux_dev;
6054 }
6055 if (wsa_max_devs == 0) {
6056 dev_warn(&pdev->dev,
6057 "%s: Max WSA devices is 0 for this target?\n",
6058 __func__);
6059 goto codec_aux_dev;
6060 }
6061
6062 /* Get count of WSA device phandles for this platform */
6063 wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
6064 "qcom,wsa-devs", NULL);
6065 if (wsa_dev_cnt == -ENOENT) {
6066 dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
6067 __func__);
6068 goto err;
6069 } else if (wsa_dev_cnt <= 0) {
6070 dev_err(&pdev->dev,
6071 "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
6072 __func__, wsa_dev_cnt);
6073 ret = -EINVAL;
6074 goto err;
6075 }
6076
6077 /*
6078 * Expect total phandles count to be NOT less than maximum possible
6079 * WSA count. However, if it is less, then assign same value to
6080 * max count as well.
6081 */
6082 if (wsa_dev_cnt < wsa_max_devs) {
6083 dev_dbg(&pdev->dev,
6084 "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
6085 __func__, wsa_max_devs, wsa_dev_cnt);
6086 wsa_max_devs = wsa_dev_cnt;
6087 }
6088
6089 /* Make sure prefix string passed for each WSA device */
6090 ret = of_property_count_strings(pdev->dev.of_node,
6091 "qcom,wsa-aux-dev-prefix");
6092 if (ret != wsa_dev_cnt) {
6093 dev_err(&pdev->dev,
6094 "%s: expecting %d wsa prefix. Defined only %d in DT\n",
6095 __func__, wsa_dev_cnt, ret);
6096 ret = -EINVAL;
6097 goto err;
6098 }
6099
6100 /*
6101 * Alloc mem to store phandle and index info of WSA device, if already
6102 * registered with ALSA core
6103 */
6104 wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
6105 sizeof(struct msm_wsa881x_dev_info),
6106 GFP_KERNEL);
6107 if (!wsa881x_dev_info) {
6108 ret = -ENOMEM;
6109 goto err;
6110 }
6111
6112 /*
6113 * search and check whether all WSA devices are already
6114 * registered with ALSA core or not. If found a node, store
6115 * the node and the index in a local array of struct for later
6116 * use.
6117 */
6118 for (i = 0; i < wsa_dev_cnt; i++) {
6119 wsa_of_node = of_parse_phandle(pdev->dev.of_node,
6120 "qcom,wsa-devs", i);
6121 if (unlikely(!wsa_of_node)) {
6122 /* we should not be here */
6123 dev_err(&pdev->dev,
6124 "%s: wsa dev node is not present\n",
6125 __func__);
6126 ret = -EINVAL;
6127 goto err;
6128 }
6129 if (soc_find_component(wsa_of_node, NULL)) {
6130 /* WSA device registered with ALSA core */
6131 wsa881x_dev_info[found].of_node = wsa_of_node;
6132 wsa881x_dev_info[found].index = i;
6133 found++;
6134 if (found == wsa_max_devs)
6135 break;
6136 }
6137 }
6138
6139 if (found < wsa_max_devs) {
6140 dev_dbg(&pdev->dev,
6141 "%s: failed to find %d components. Found only %d\n",
6142 __func__, wsa_max_devs, found);
6143 return -EPROBE_DEFER;
6144 }
6145 dev_info(&pdev->dev,
6146 "%s: found %d wsa881x devices registered with ALSA core\n",
6147 __func__, found);
6148
6149codec_aux_dev:
Karthikeyan Mani1a111b92019-02-12 21:35:31 -08006150 /* Get count of aux codec device phandles for this platform */
6151 codec_aux_dev_cnt = of_count_phandle_with_args(
6152 pdev->dev.of_node,
6153 "qcom,codec-aux-devs", NULL);
6154 if (codec_aux_dev_cnt == -ENOENT) {
6155 dev_warn(&pdev->dev, "%s: No aux codec defined in DT.\n",
6156 __func__);
6157 goto err;
6158 } else if (codec_aux_dev_cnt <= 0) {
6159 dev_err(&pdev->dev,
6160 "%s: Error reading aux codec device from DT, dev_cnt=%d\n",
6161 __func__, codec_aux_dev_cnt);
6162 ret = -EINVAL;
6163 goto err;
6164 }
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006165
Karthikeyan Mani1a111b92019-02-12 21:35:31 -08006166 /*
6167 * Alloc mem to store phandle and index info of aux codec
6168 * if already registered with ALSA core
6169 */
6170 aux_cdc_dev_info = devm_kcalloc(&pdev->dev, codec_aux_dev_cnt,
6171 sizeof(struct aux_codec_dev_info),
6172 GFP_KERNEL);
6173 if (!aux_cdc_dev_info) {
6174 ret = -ENOMEM;
6175 goto err;
6176 }
6177
6178 /*
6179 * search and check whether all aux codecs are already
6180 * registered with ALSA core or not. If found a node, store
6181 * the node and the index in a local array of struct for later
6182 * use.
6183 */
6184 for (i = 0; i < codec_aux_dev_cnt; i++) {
6185 aux_codec_of_node = of_parse_phandle(pdev->dev.of_node,
6186 "qcom,codec-aux-devs", i);
6187 if (unlikely(!aux_codec_of_node)) {
6188 /* we should not be here */
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006189 dev_err(&pdev->dev,
Karthikeyan Mani1a111b92019-02-12 21:35:31 -08006190 "%s: aux codec dev node is not present\n",
6191 __func__);
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006192 ret = -EINVAL;
6193 goto err;
6194 }
Karthikeyan Mani1a111b92019-02-12 21:35:31 -08006195 if (soc_find_component(aux_codec_of_node, NULL)) {
6196 /* AUX codec registered with ALSA core */
6197 aux_cdc_dev_info[codecs_found].of_node =
6198 aux_codec_of_node;
6199 aux_cdc_dev_info[codecs_found].index = i;
6200 codecs_found++;
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006201 }
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006202 }
6203
Karthikeyan Mani1a111b92019-02-12 21:35:31 -08006204 if (codecs_found < codec_aux_dev_cnt) {
6205 dev_dbg(&pdev->dev,
6206 "%s: failed to find %d components. Found only %d\n",
6207 __func__, codec_aux_dev_cnt, codecs_found);
6208 return -EPROBE_DEFER;
6209 }
6210 dev_info(&pdev->dev,
6211 "%s: found %d AUX codecs registered with ALSA core\n",
6212 __func__, codecs_found);
6213
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006214 card->num_aux_devs = wsa_max_devs + codec_aux_dev_cnt;
6215 card->num_configs = wsa_max_devs + codec_aux_dev_cnt;
6216
6217 /* Alloc array of AUX devs struct */
6218 msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
6219 sizeof(struct snd_soc_aux_dev),
6220 GFP_KERNEL);
6221 if (!msm_aux_dev) {
6222 ret = -ENOMEM;
6223 goto err;
6224 }
6225
6226 /* Alloc array of codec conf struct */
6227 msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_configs,
6228 sizeof(struct snd_soc_codec_conf),
6229 GFP_KERNEL);
6230 if (!msm_codec_conf) {
6231 ret = -ENOMEM;
6232 goto err;
6233 }
6234
6235 for (i = 0; i < wsa_max_devs; i++) {
6236 dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
6237 GFP_KERNEL);
6238 if (!dev_name_str) {
6239 ret = -ENOMEM;
6240 goto err;
6241 }
6242
6243 ret = of_property_read_string_index(pdev->dev.of_node,
6244 "qcom,wsa-aux-dev-prefix",
6245 wsa881x_dev_info[i].index,
6246 auxdev_name_prefix);
6247 if (ret) {
6248 dev_err(&pdev->dev,
6249 "%s: failed to read wsa aux dev prefix, ret = %d\n",
6250 __func__, ret);
6251 ret = -EINVAL;
6252 goto err;
6253 }
6254
6255 snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
6256 msm_aux_dev[i].name = dev_name_str;
6257 msm_aux_dev[i].codec_name = NULL;
6258 msm_aux_dev[i].codec_of_node =
6259 wsa881x_dev_info[i].of_node;
6260 msm_aux_dev[i].init = msm_wsa881x_init;
6261 msm_codec_conf[i].dev_name = NULL;
6262 msm_codec_conf[i].name_prefix = auxdev_name_prefix[0];
6263 msm_codec_conf[i].of_node =
6264 wsa881x_dev_info[i].of_node;
6265 }
6266
6267 for (i = 0; i < codec_aux_dev_cnt; i++) {
6268 msm_aux_dev[wsa_max_devs + i].name = NULL;
6269 msm_aux_dev[wsa_max_devs + i].codec_name = NULL;
6270 msm_aux_dev[wsa_max_devs + i].codec_of_node =
6271 aux_cdc_dev_info[i].of_node;
6272 msm_aux_dev[wsa_max_devs + i].init = msm_aux_codec_init;
6273 msm_codec_conf[wsa_max_devs + i].dev_name = NULL;
6274 msm_codec_conf[wsa_max_devs + i].name_prefix =
6275 NULL;
6276 msm_codec_conf[wsa_max_devs + i].of_node =
6277 aux_cdc_dev_info[i].of_node;
6278 }
6279
6280 card->codec_conf = msm_codec_conf;
6281 card->aux_dev = msm_aux_dev;
6282err:
6283 return ret;
6284}
6285
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006286static void msm_i2s_auxpcm_init(struct platform_device *pdev)
6287{
6288 int count = 0;
6289 u32 mi2s_master_slave[MI2S_MAX];
6290 int ret = 0;
6291
6292 for (count = 0; count < MI2S_MAX; count++) {
6293 mutex_init(&mi2s_intf_conf[count].lock);
6294 mi2s_intf_conf[count].ref_cnt = 0;
6295 }
6296
6297 ret = of_property_read_u32_array(pdev->dev.of_node,
6298 "qcom,msm-mi2s-master",
6299 mi2s_master_slave, MI2S_MAX);
6300 if (ret) {
6301 dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
6302 __func__);
6303 } else {
6304 for (count = 0; count < MI2S_MAX; count++) {
6305 mi2s_intf_conf[count].msm_is_mi2s_master =
6306 mi2s_master_slave[count];
6307 }
6308 }
6309}
6310
6311static void msm_i2s_auxpcm_deinit(void)
6312{
6313 int count = 0;
6314
6315 for (count = 0; count < MI2S_MAX; count++) {
6316 mutex_destroy(&mi2s_intf_conf[count].lock);
6317 mi2s_intf_conf[count].ref_cnt = 0;
6318 mi2s_intf_conf[count].msm_is_mi2s_master = 0;
6319 }
6320}
6321
6322static int kona_ssr_enable(struct device *dev, void *data)
6323{
6324 struct platform_device *pdev = to_platform_device(dev);
6325 struct snd_soc_card *card = platform_get_drvdata(pdev);
6326 int ret = 0;
6327
6328 if (!card) {
6329 dev_err(dev, "%s: card is NULL\n", __func__);
6330 ret = -EINVAL;
6331 goto err;
6332 }
6333
6334 if (!strcmp(card->name, "kona-stub-snd-card")) {
6335 /* TODO */
6336 dev_dbg(dev, "%s: TODO \n", __func__);
6337 }
6338
6339 snd_soc_card_change_online_state(card, 1);
6340 dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
6341
6342err:
6343 return ret;
6344}
6345
6346static void kona_ssr_disable(struct device *dev, void *data)
6347{
6348 struct platform_device *pdev = to_platform_device(dev);
6349 struct snd_soc_card *card = platform_get_drvdata(pdev);
6350
6351 if (!card) {
6352 dev_err(dev, "%s: card is NULL\n", __func__);
6353 return;
6354 }
6355
6356 dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
6357 snd_soc_card_change_online_state(card, 0);
6358
6359 if (!strcmp(card->name, "kona-stub-snd-card")) {
6360 /* TODO */
6361 dev_dbg(dev, "%s: TODO \n", __func__);
6362 }
6363}
6364
6365static const struct snd_event_ops kona_ssr_ops = {
6366 .enable = kona_ssr_enable,
6367 .disable = kona_ssr_disable,
6368};
6369
6370static int msm_audio_ssr_compare(struct device *dev, void *data)
6371{
6372 struct device_node *node = data;
6373
6374 dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
6375 __func__, dev->of_node, node);
6376 return (dev->of_node && dev->of_node == node);
6377}
6378
6379static int msm_audio_ssr_register(struct device *dev)
6380{
6381 struct device_node *np = dev->of_node;
6382 struct snd_event_clients *ssr_clients = NULL;
6383 struct device_node *node = NULL;
6384 int ret = 0;
6385 int i = 0;
6386
6387 for (i = 0; ; i++) {
6388 node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
6389 if (!node)
6390 break;
6391 snd_event_mstr_add_client(&ssr_clients,
6392 msm_audio_ssr_compare, node);
6393 }
6394
6395 ret = snd_event_master_register(dev, &kona_ssr_ops,
6396 ssr_clients, NULL);
6397 if (!ret)
6398 snd_event_notify(dev, SND_EVENT_UP);
6399
6400 return ret;
6401}
6402
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006403static int msm_asoc_machine_probe(struct platform_device *pdev)
6404{
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006405 struct snd_soc_card *card = NULL;
6406 struct msm_asoc_mach_data *pdata = NULL;
6407 const char *mbhc_audio_jack_type = NULL;
6408 int ret = 0;
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006409
6410 if (!pdev->dev.of_node) {
6411 dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
6412 return -EINVAL;
6413 }
6414
6415 pdata = devm_kzalloc(&pdev->dev,
6416 sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
6417 if (!pdata)
6418 return -ENOMEM;
6419
6420 card = populate_snd_card_dailinks(&pdev->dev);
6421 if (!card) {
6422 dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
6423 ret = -EINVAL;
6424 goto err;
6425 }
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006426
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006427 card->dev = &pdev->dev;
6428 platform_set_drvdata(pdev, card);
6429 snd_soc_card_set_drvdata(card, pdata);
6430
6431 ret = snd_soc_of_parse_card_name(card, "qcom,model");
6432 if (ret) {
6433 dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
6434 __func__, ret);
6435 goto err;
6436 }
6437
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006438 ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
6439 if (ret) {
6440 dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
6441 __func__, ret);
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006442 goto err;
6443 }
6444
6445 ret = msm_populate_dai_link_component_of_node(card);
6446 if (ret) {
6447 ret = -EPROBE_DEFER;
6448 goto err;
6449 }
6450
Vignesh Kulothungan3e5ebbf2018-10-23 12:19:13 -07006451 ret = msm_init_aux_dev(pdev, card);
6452 if (ret)
6453 goto err;
6454
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006455 ret = devm_snd_soc_register_card(&pdev->dev, card);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006456 if (ret == -EPROBE_DEFER) {
6457 if (codec_reg_done)
6458 ret = -EINVAL;
6459 goto err;
6460 } else if (ret) {
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006461 dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
6462 __func__, ret);
6463 goto err;
6464 }
6465 dev_info(&pdev->dev, "%s: Sound card %s registered\n",
6466 __func__, card->name);
6467
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006468 pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
6469 "qcom,hph-en1-gpio", 0);
6470 if (!pdata->hph_en1_gpio_p) {
6471 dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
6472 __func__, "qcom,hph-en1-gpio",
6473 pdev->dev.of_node->full_name);
6474 }
6475
6476 pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
6477 "qcom,hph-en0-gpio", 0);
6478 if (!pdata->hph_en0_gpio_p) {
6479 dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
6480 __func__, "qcom,hph-en0-gpio",
6481 pdev->dev.of_node->full_name);
6482 }
6483
6484 ret = of_property_read_string(pdev->dev.of_node,
6485 "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
6486 if (ret) {
6487 dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
6488 __func__, "qcom,mbhc-audio-jack-type",
6489 pdev->dev.of_node->full_name);
6490 dev_dbg(&pdev->dev, "Jack type properties set to default\n");
6491 } else {
6492 if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
6493 wcd_mbhc_cfg.enable_anc_mic_detect = false;
6494 dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
6495 } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
6496 wcd_mbhc_cfg.enable_anc_mic_detect = true;
6497 dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
6498 } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
6499 wcd_mbhc_cfg.enable_anc_mic_detect = true;
6500 dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
6501 } else {
6502 wcd_mbhc_cfg.enable_anc_mic_detect = false;
6503 dev_dbg(&pdev->dev, "Unknown value, set to default\n");
6504 }
6505 }
Karthikeyan Mani5eb13422018-11-05 13:49:17 -08006506 /*
6507 * Parse US-Euro gpio info from DT. Report no error if us-euro
6508 * entry is not found in DT file as some targets do not support
6509 * US-Euro detection
6510 */
6511 pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
6512 "qcom,us-euro-gpios", 0);
6513 if (!pdata->us_euro_gpio_p) {
6514 dev_dbg(&pdev->dev, "property %s not detected in node %s",
6515 "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
6516 } else {
6517 dev_dbg(&pdev->dev, "%s detected\n",
6518 "qcom,us-euro-gpios");
6519 wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
6520 }
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006521
Meng Wanga60b4082019-02-25 17:02:23 +08006522 if (wcd_mbhc_cfg.enable_usbc_analog)
6523 wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
6524
6525 pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
6526 "fsa4480-i2c-handle", 0);
6527 if (!pdata->fsa_handle)
6528 dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
6529 "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
6530
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006531 msm_i2s_auxpcm_init(pdev);
Karthikeyan Mani1a111b92019-02-12 21:35:31 -08006532 pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
6533 "qcom,cdc-dmic01-gpios",
6534 0);
6535 pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
6536 "qcom,cdc-dmic23-gpios",
6537 0);
6538 pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
6539 "qcom,cdc-dmic45-gpios",
6540 0);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006541
6542 ret = msm_audio_ssr_register(&pdev->dev);
6543 if (ret)
6544 pr_err("%s: Registration with SND event FWK failed ret = %d\n",
6545 __func__, ret);
6546
6547 is_initial_boot = true;
6548
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006549 return 0;
6550err:
6551 devm_kfree(&pdev->dev, pdata);
6552 return ret;
6553}
6554
6555static int msm_asoc_machine_remove(struct platform_device *pdev)
6556{
6557 struct snd_soc_card *card = platform_get_drvdata(pdev);
6558
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006559 snd_event_master_deregister(&pdev->dev);
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006560 snd_soc_unregister_card(card);
Vignesh Kulothungan483a5592018-10-19 15:00:08 -07006561 msm_i2s_auxpcm_deinit();
6562
Vignesh Kulothungane9abcd02018-10-01 15:55:25 -07006563 return 0;
6564}
6565
6566static struct platform_driver kona_asoc_machine_driver = {
6567 .driver = {
6568 .name = DRV_NAME,
6569 .owner = THIS_MODULE,
6570 .pm = &snd_soc_pm_ops,
6571 .of_match_table = kona_asoc_machine_of_match,
6572 },
6573 .probe = msm_asoc_machine_probe,
6574 .remove = msm_asoc_machine_remove,
6575};
6576module_platform_driver(kona_asoc_machine_driver);
6577
6578MODULE_DESCRIPTION("ALSA SoC msm");
6579MODULE_LICENSE("GPL v2");
6580MODULE_ALIAS("platform:" DRV_NAME);
6581MODULE_DEVICE_TABLE(of, kona_asoc_machine_of_match);