Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/of_gpio.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/module.h> |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 16 | #include <linux/mfd/msm-cdc-pinctrl.h> |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 17 | #include <sound/pcm_params.h> |
| 18 | #include "qdsp6v2/msm-pcm-routing-v2.h" |
Neeraj Upadhyay | 4993442 | 2016-12-27 19:03:35 +0530 | [diff] [blame] | 19 | #include "sdm660-common.h" |
| 20 | #include "../codecs/sdm660_cdc/msm-digital-cdc.h" |
| 21 | #include "../codecs/sdm660_cdc/msm-analog-cdc.h" |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 22 | #include "../codecs/msm_sdw/msm_sdw.h" |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 23 | |
Neeraj Upadhyay | 4993442 | 2016-12-27 19:03:35 +0530 | [diff] [blame] | 24 | #define __CHIPSET__ "SDM660 " |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 25 | #define MSM_DAILINK_NAME(name) (__CHIPSET__#name) |
| 26 | |
| 27 | #define DEFAULT_MCLK_RATE 9600000 |
| 28 | #define NATIVE_MCLK_RATE 11289600 |
| 29 | |
| 30 | #define WCD_MBHC_DEF_RLOADS 5 |
| 31 | |
| 32 | #define WCN_CDC_SLIM_RX_CH_MAX 2 |
| 33 | #define WCN_CDC_SLIM_TX_CH_MAX 3 |
| 34 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 35 | #define WSA8810_NAME_1 "wsa881x.20170211" |
| 36 | #define WSA8810_NAME_2 "wsa881x.20170212" |
| 37 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 38 | enum { |
| 39 | INT0_MI2S = 0, |
| 40 | INT1_MI2S, |
| 41 | INT2_MI2S, |
| 42 | INT3_MI2S, |
| 43 | INT4_MI2S, |
| 44 | INT5_MI2S, |
| 45 | INT6_MI2S, |
| 46 | INT_MI2S_MAX, |
| 47 | }; |
| 48 | |
| 49 | enum { |
| 50 | BT_SLIM7, |
| 51 | FM_SLIM8, |
| 52 | SLIM_MAX, |
| 53 | }; |
| 54 | |
| 55 | /*TDM default offset currently only supporting TDM_RX_0 and TDM_TX_0 */ |
| 56 | static unsigned int tdm_slot_offset[TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = { |
| 57 | {0, 4, 8, 12, 16, 20, 24, 28},/* TX_0 | RX_0 */ |
| 58 | {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_1 | RX_1 */ |
| 59 | {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_2 | RX_2 */ |
| 60 | {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_3 | RX_3 */ |
| 61 | {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_4 | RX_4 */ |
| 62 | {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_5 | RX_5 */ |
| 63 | {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_6 | RX_6 */ |
| 64 | {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_7 | RX_7 */ |
| 65 | }; |
| 66 | |
| 67 | static struct afe_clk_set int_mi2s_clk[INT_MI2S_MAX] = { |
| 68 | { |
| 69 | AFE_API_VERSION_I2S_CONFIG, |
| 70 | Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT, |
| 71 | Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ, |
| 72 | Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, |
| 73 | Q6AFE_LPASS_CLK_ROOT_DEFAULT, |
| 74 | 0, |
| 75 | }, |
| 76 | { |
| 77 | AFE_API_VERSION_I2S_CONFIG, |
| 78 | Q6AFE_LPASS_CLK_ID_INT1_MI2S_IBIT, |
| 79 | Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ, |
| 80 | Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, |
| 81 | Q6AFE_LPASS_CLK_ROOT_DEFAULT, |
| 82 | 0, |
| 83 | }, |
| 84 | { |
| 85 | AFE_API_VERSION_I2S_CONFIG, |
| 86 | Q6AFE_LPASS_CLK_ID_INT2_MI2S_IBIT, |
| 87 | Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ, |
| 88 | Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, |
| 89 | Q6AFE_LPASS_CLK_ROOT_DEFAULT, |
| 90 | 0, |
| 91 | }, |
| 92 | { |
| 93 | AFE_API_VERSION_I2S_CONFIG, |
| 94 | Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT, |
| 95 | Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ, |
| 96 | Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, |
| 97 | Q6AFE_LPASS_CLK_ROOT_DEFAULT, |
| 98 | 0, |
| 99 | }, |
| 100 | { |
| 101 | AFE_API_VERSION_I2S_CONFIG, |
| 102 | Q6AFE_LPASS_CLK_ID_INT4_MI2S_IBIT, |
| 103 | Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ, |
| 104 | Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, |
| 105 | Q6AFE_LPASS_CLK_ROOT_DEFAULT, |
| 106 | 0, |
| 107 | }, |
| 108 | { |
| 109 | AFE_API_VERSION_I2S_CONFIG, |
| 110 | Q6AFE_LPASS_CLK_ID_INT5_MI2S_IBIT, |
| 111 | Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ, |
| 112 | Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, |
| 113 | Q6AFE_LPASS_CLK_ROOT_DEFAULT, |
| 114 | 0, |
| 115 | }, |
| 116 | { |
| 117 | AFE_API_VERSION_I2S_CONFIG, |
| 118 | Q6AFE_LPASS_CLK_ID_INT6_MI2S_IBIT, |
| 119 | Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ, |
| 120 | Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO, |
| 121 | Q6AFE_LPASS_CLK_ROOT_DEFAULT, |
| 122 | 0, |
| 123 | }, |
| 124 | }; |
| 125 | |
| 126 | struct dev_config { |
| 127 | u32 sample_rate; |
| 128 | u32 bit_format; |
| 129 | u32 channels; |
| 130 | }; |
| 131 | |
| 132 | /* Default configuration of MI2S channels */ |
| 133 | static struct dev_config int_mi2s_cfg[] = { |
| 134 | [INT0_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, |
| 135 | [INT1_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, |
| 136 | [INT2_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, |
| 137 | [INT3_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, |
| 138 | [INT4_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, |
| 139 | [INT5_MI2S] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, |
| 140 | [INT6_MI2S] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, |
| 141 | }; |
| 142 | |
| 143 | static struct dev_config bt_fm_cfg[] = { |
| 144 | [BT_SLIM7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, |
| 145 | [FM_SLIM8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2}, |
| 146 | }; |
| 147 | |
| 148 | static char const *int_mi2s_rate_text[] = {"KHZ_8", "KHZ_16", |
| 149 | "KHZ_32", "KHZ_44P1", "KHZ_48", |
| 150 | "KHZ_96", "KHZ_192"}; |
| 151 | static const char *const int_mi2s_ch_text[] = {"One", "Two"}; |
| 152 | static const char *const int_mi2s_tx_ch_text[] = {"One", "Two", |
| 153 | "Three", "Four"}; |
| 154 | static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"}; |
| 155 | static const char *const loopback_mclk_text[] = {"DISABLE", "ENABLE"}; |
| 156 | static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_48"}; |
| 157 | |
| 158 | static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_sample_rate, int_mi2s_rate_text); |
| 159 | static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_chs, int_mi2s_ch_text); |
| 160 | static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_format, bit_format_text); |
| 161 | static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_sample_rate, int_mi2s_rate_text); |
| 162 | static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_chs, int_mi2s_tx_ch_text); |
| 163 | static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_format, bit_format_text); |
| 164 | static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_sample_rate, int_mi2s_rate_text); |
| 165 | static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_chs, int_mi2s_tx_ch_text); |
| 166 | static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_format, bit_format_text); |
| 167 | static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_sample_rate, int_mi2s_rate_text); |
| 168 | static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_chs, int_mi2s_ch_text); |
| 169 | static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_format, bit_format_text); |
| 170 | static SOC_ENUM_SINGLE_EXT_DECL(int5_mi2s_tx_chs, int_mi2s_ch_text); |
| 171 | static SOC_ENUM_SINGLE_EXT_DECL(loopback_mclk_en, loopback_mclk_text); |
| 172 | static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text); |
| 173 | |
| 174 | static int msm_dmic_event(struct snd_soc_dapm_widget *w, |
| 175 | struct snd_kcontrol *kcontrol, int event); |
| 176 | static int msm_int_enable_dig_cdc_clk(struct snd_soc_codec *codec, int enable, |
| 177 | bool dapm); |
| 178 | static int msm_int_mclk0_event(struct snd_soc_dapm_widget *w, |
| 179 | struct snd_kcontrol *kcontrol, int event); |
| 180 | static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream); |
| 181 | static void msm_int_mi2s_snd_shutdown(struct snd_pcm_substream *substream); |
| 182 | |
| 183 | static struct wcd_mbhc_config *mbhc_cfg_ptr; |
Laxminath Kasam | 4e44457 | 2017-01-15 20:00:11 +0530 | [diff] [blame] | 184 | static struct snd_info_entry *codec_root; |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 185 | |
| 186 | static int int_mi2s_get_bit_format_val(int bit_format) |
| 187 | { |
| 188 | int val = 0; |
| 189 | |
| 190 | switch (bit_format) { |
| 191 | case SNDRV_PCM_FORMAT_S24_3LE: |
| 192 | val = 2; |
| 193 | break; |
| 194 | case SNDRV_PCM_FORMAT_S24_LE: |
| 195 | val = 1; |
| 196 | break; |
| 197 | case SNDRV_PCM_FORMAT_S16_LE: |
| 198 | default: |
| 199 | val = 0; |
| 200 | break; |
| 201 | } |
| 202 | return val; |
| 203 | } |
| 204 | |
| 205 | static int int_mi2s_get_bit_format(int val) |
| 206 | { |
| 207 | int bit_fmt = SNDRV_PCM_FORMAT_S16_LE; |
| 208 | |
| 209 | switch (val) { |
| 210 | case 0: |
| 211 | bit_fmt = SNDRV_PCM_FORMAT_S16_LE; |
| 212 | break; |
| 213 | case 1: |
| 214 | bit_fmt = SNDRV_PCM_FORMAT_S24_LE; |
| 215 | break; |
| 216 | case 2: |
| 217 | bit_fmt = SNDRV_PCM_FORMAT_S24_3LE; |
| 218 | break; |
| 219 | default: |
| 220 | bit_fmt = SNDRV_PCM_FORMAT_S16_LE; |
| 221 | break; |
| 222 | } |
| 223 | return bit_fmt; |
| 224 | } |
| 225 | |
| 226 | static int int_mi2s_get_port_idx(struct snd_kcontrol *kcontrol) |
| 227 | { |
| 228 | int port_id = 0; |
| 229 | |
| 230 | if (strnstr(kcontrol->id.name, "INT0_MI2S", sizeof("INT0_MI2S"))) |
| 231 | port_id = INT0_MI2S; |
| 232 | else if (strnstr(kcontrol->id.name, "INT2_MI2S", sizeof("INT2_MI2S"))) |
| 233 | port_id = INT2_MI2S; |
| 234 | else if (strnstr(kcontrol->id.name, "INT3_MI2S", sizeof("INT3_MI2S"))) |
| 235 | port_id = INT3_MI2S; |
| 236 | else if (strnstr(kcontrol->id.name, "INT4_MI2S", sizeof("INT4_MI2S"))) |
| 237 | port_id = INT4_MI2S; |
| 238 | else { |
| 239 | pr_err("%s: unsupported channel: %s", |
| 240 | __func__, kcontrol->id.name); |
| 241 | return -EINVAL; |
| 242 | } |
| 243 | |
| 244 | return port_id; |
| 245 | } |
| 246 | |
| 247 | static int int_mi2s_bit_format_get(struct snd_kcontrol *kcontrol, |
| 248 | struct snd_ctl_elem_value *ucontrol) |
| 249 | { |
| 250 | int ch_num = int_mi2s_get_port_idx(kcontrol); |
| 251 | |
| 252 | if (ch_num < 0) |
| 253 | return ch_num; |
| 254 | |
| 255 | ucontrol->value.enumerated.item[0] = |
| 256 | int_mi2s_get_bit_format_val(int_mi2s_cfg[ch_num].bit_format); |
| 257 | |
| 258 | pr_debug("%s: int_mi2s[%d]_bit_format = %d, ucontrol value = %d\n", |
| 259 | __func__, ch_num, int_mi2s_cfg[ch_num].bit_format, |
| 260 | ucontrol->value.enumerated.item[0]); |
| 261 | |
| 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | static int int_mi2s_bit_format_put(struct snd_kcontrol *kcontrol, |
| 266 | struct snd_ctl_elem_value *ucontrol) |
| 267 | { |
| 268 | int ch_num = int_mi2s_get_port_idx(kcontrol); |
| 269 | |
| 270 | if (ch_num < 0) |
| 271 | return ch_num; |
| 272 | |
| 273 | int_mi2s_cfg[ch_num].bit_format = |
| 274 | int_mi2s_get_bit_format(ucontrol->value.enumerated.item[0]); |
| 275 | |
| 276 | pr_debug("%s: int_mi2s[%d]_rx_bit_format = %d, ucontrol value = %d\n", |
| 277 | __func__, ch_num, int_mi2s_cfg[ch_num].bit_format, |
| 278 | ucontrol->value.enumerated.item[0]); |
| 279 | |
| 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | static inline int param_is_mask(int p) |
| 284 | { |
| 285 | return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) && |
| 286 | (p <= SNDRV_PCM_HW_PARAM_LAST_MASK); |
| 287 | } |
| 288 | |
| 289 | static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, |
| 290 | int n) |
| 291 | { |
| 292 | return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]); |
| 293 | } |
| 294 | |
| 295 | static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit) |
| 296 | { |
| 297 | if (bit >= SNDRV_MASK_MAX) |
| 298 | return; |
| 299 | if (param_is_mask(n)) { |
| 300 | struct snd_mask *m = param_to_mask(p, n); |
| 301 | |
| 302 | m->bits[0] = 0; |
| 303 | m->bits[1] = 0; |
| 304 | m->bits[bit >> 5] |= (1 << (bit & 31)); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | static int int_mi2s_get_sample_rate_val(int sample_rate) |
| 309 | { |
| 310 | int sample_rate_val; |
| 311 | |
| 312 | switch (sample_rate) { |
| 313 | case SAMPLING_RATE_8KHZ: |
| 314 | sample_rate_val = 0; |
| 315 | break; |
| 316 | case SAMPLING_RATE_16KHZ: |
| 317 | sample_rate_val = 1; |
| 318 | break; |
| 319 | case SAMPLING_RATE_32KHZ: |
| 320 | sample_rate_val = 2; |
| 321 | break; |
| 322 | case SAMPLING_RATE_44P1KHZ: |
| 323 | sample_rate_val = 3; |
| 324 | break; |
| 325 | case SAMPLING_RATE_48KHZ: |
| 326 | sample_rate_val = 4; |
| 327 | break; |
| 328 | case SAMPLING_RATE_96KHZ: |
| 329 | sample_rate_val = 5; |
| 330 | break; |
| 331 | case SAMPLING_RATE_192KHZ: |
| 332 | sample_rate_val = 6; |
| 333 | break; |
| 334 | default: |
| 335 | sample_rate_val = 4; |
| 336 | break; |
| 337 | } |
| 338 | return sample_rate_val; |
| 339 | } |
| 340 | |
| 341 | static int int_mi2s_get_sample_rate(int value) |
| 342 | { |
| 343 | int sample_rate; |
| 344 | |
| 345 | switch (value) { |
| 346 | case 0: |
| 347 | sample_rate = SAMPLING_RATE_8KHZ; |
| 348 | break; |
| 349 | case 1: |
| 350 | sample_rate = SAMPLING_RATE_16KHZ; |
| 351 | break; |
| 352 | case 2: |
| 353 | sample_rate = SAMPLING_RATE_32KHZ; |
| 354 | break; |
| 355 | case 3: |
| 356 | sample_rate = SAMPLING_RATE_44P1KHZ; |
| 357 | break; |
| 358 | case 4: |
| 359 | sample_rate = SAMPLING_RATE_48KHZ; |
| 360 | break; |
| 361 | case 5: |
| 362 | sample_rate = SAMPLING_RATE_96KHZ; |
| 363 | break; |
| 364 | case 6: |
| 365 | sample_rate = SAMPLING_RATE_192KHZ; |
| 366 | break; |
| 367 | default: |
| 368 | sample_rate = SAMPLING_RATE_48KHZ; |
| 369 | break; |
| 370 | } |
| 371 | return sample_rate; |
| 372 | } |
| 373 | |
| 374 | static int int_mi2s_sample_rate_put(struct snd_kcontrol *kcontrol, |
| 375 | struct snd_ctl_elem_value *ucontrol) |
| 376 | { |
| 377 | int idx = int_mi2s_get_port_idx(kcontrol); |
| 378 | |
| 379 | if (idx < 0) |
| 380 | return idx; |
| 381 | |
| 382 | int_mi2s_cfg[idx].sample_rate = |
| 383 | int_mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]); |
| 384 | |
| 385 | pr_debug("%s: idx[%d]_sample_rate = %d, item = %d\n", __func__, |
| 386 | idx, int_mi2s_cfg[idx].sample_rate, |
| 387 | ucontrol->value.enumerated.item[0]); |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static int int_mi2s_sample_rate_get(struct snd_kcontrol *kcontrol, |
| 393 | struct snd_ctl_elem_value *ucontrol) |
| 394 | { |
| 395 | int idx = int_mi2s_get_port_idx(kcontrol); |
| 396 | |
| 397 | if (idx < 0) |
| 398 | return idx; |
| 399 | |
| 400 | ucontrol->value.enumerated.item[0] = |
| 401 | int_mi2s_get_sample_rate_val(int_mi2s_cfg[idx].sample_rate); |
| 402 | |
| 403 | pr_debug("%s: idx[%d]_sample_rate = %d, item = %d\n", __func__, |
| 404 | idx, int_mi2s_cfg[idx].sample_rate, |
| 405 | ucontrol->value.enumerated.item[0]); |
| 406 | |
| 407 | return 0; |
| 408 | } |
| 409 | |
| 410 | static int int_mi2s_ch_get(struct snd_kcontrol *kcontrol, |
| 411 | struct snd_ctl_elem_value *ucontrol) |
| 412 | { |
| 413 | int idx = int_mi2s_get_port_idx(kcontrol); |
| 414 | |
| 415 | if (idx < 0) |
| 416 | return idx; |
| 417 | |
| 418 | pr_debug("%s: int_mi2s_[%d]_rx_ch = %d\n", __func__, |
| 419 | idx, int_mi2s_cfg[idx].channels); |
| 420 | ucontrol->value.enumerated.item[0] = int_mi2s_cfg[idx].channels - 1; |
| 421 | |
| 422 | return 0; |
| 423 | } |
| 424 | |
| 425 | static int int_mi2s_ch_put(struct snd_kcontrol *kcontrol, |
| 426 | struct snd_ctl_elem_value *ucontrol) |
| 427 | { |
| 428 | int idx = int_mi2s_get_port_idx(kcontrol); |
| 429 | |
| 430 | if (idx < 0) |
| 431 | return idx; |
| 432 | |
| 433 | int_mi2s_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1; |
| 434 | pr_debug("%s: int_mi2s_[%d]_ch = %d\n", __func__, |
| 435 | idx, int_mi2s_cfg[idx].channels); |
| 436 | |
| 437 | return 1; |
| 438 | } |
| 439 | |
| 440 | static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = { |
| 441 | SND_SOC_DAPM_SUPPLY_S("INT_MCLK0", -1, SND_SOC_NOPM, 0, 0, |
| 442 | msm_int_mclk0_event, SND_SOC_DAPM_POST_PMD), |
| 443 | SND_SOC_DAPM_MIC("Handset Mic", NULL), |
| 444 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 445 | SND_SOC_DAPM_MIC("Secondary Mic", NULL), |
| 446 | SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event), |
| 447 | SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event), |
| 448 | SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event), |
| 449 | SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event), |
| 450 | }; |
| 451 | |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 452 | static int msm_config_hph_compander_gpio(bool enable, |
| 453 | struct snd_soc_codec *codec) |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 454 | { |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 455 | struct snd_soc_card *card = codec->component.card; |
| 456 | struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 457 | int ret = 0; |
| 458 | |
| 459 | pr_debug("%s: %s HPH Compander\n", __func__, |
| 460 | enable ? "Enable" : "Disable"); |
| 461 | |
| 462 | if (enable) { |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 463 | ret = msm_cdc_pinctrl_select_active_state(pdata->comp_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 464 | if (ret) { |
| 465 | pr_err("%s: gpio set cannot be activated %s\n", |
| 466 | __func__, "comp_gpio"); |
| 467 | goto done; |
| 468 | } |
| 469 | } else { |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 470 | ret = msm_cdc_pinctrl_select_sleep_state(pdata->comp_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 471 | if (ret) { |
| 472 | pr_err("%s: gpio set cannot be de-activated %s\n", |
| 473 | __func__, "comp_gpio"); |
| 474 | goto done; |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | done: |
| 479 | return ret; |
| 480 | } |
| 481 | |
| 482 | static int is_ext_spk_gpio_support(struct platform_device *pdev, |
| 483 | struct msm_asoc_mach_data *pdata) |
| 484 | { |
| 485 | const char *spk_ext_pa = "qcom,msm-spk-ext-pa"; |
| 486 | |
| 487 | pr_debug("%s:Enter\n", __func__); |
| 488 | |
| 489 | pdata->spk_ext_pa_gpio = of_get_named_gpio(pdev->dev.of_node, |
| 490 | spk_ext_pa, 0); |
| 491 | |
| 492 | if (pdata->spk_ext_pa_gpio < 0) { |
| 493 | dev_dbg(&pdev->dev, |
| 494 | "%s: missing %s in dt node\n", __func__, spk_ext_pa); |
| 495 | } else { |
| 496 | if (!gpio_is_valid(pdata->spk_ext_pa_gpio)) { |
| 497 | pr_err("%s: Invalid external speaker gpio: %d", |
| 498 | __func__, pdata->spk_ext_pa_gpio); |
| 499 | return -EINVAL; |
| 500 | } |
| 501 | } |
| 502 | return 0; |
| 503 | } |
| 504 | |
| 505 | static int enable_spk_ext_pa(struct snd_soc_codec *codec, int enable) |
| 506 | { |
| 507 | struct snd_soc_card *card = codec->component.card; |
| 508 | struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); |
| 509 | int ret; |
| 510 | |
| 511 | if (!gpio_is_valid(pdata->spk_ext_pa_gpio)) { |
| 512 | pr_err("%s: Invalid gpio: %d\n", __func__, |
| 513 | pdata->spk_ext_pa_gpio); |
| 514 | return false; |
| 515 | } |
| 516 | |
| 517 | pr_debug("%s: %s external speaker PA\n", __func__, |
| 518 | enable ? "Enable" : "Disable"); |
| 519 | |
| 520 | if (enable) { |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 521 | ret = msm_cdc_pinctrl_select_active_state( |
| 522 | pdata->ext_spk_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 523 | if (ret) { |
| 524 | pr_err("%s: gpio set cannot be de-activated %s\n", |
| 525 | __func__, "ext_spk_gpio"); |
| 526 | return ret; |
| 527 | } |
| 528 | gpio_set_value_cansleep(pdata->spk_ext_pa_gpio, enable); |
| 529 | } else { |
| 530 | gpio_set_value_cansleep(pdata->spk_ext_pa_gpio, enable); |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 531 | ret = msm_cdc_pinctrl_select_sleep_state( |
| 532 | pdata->ext_spk_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 533 | if (ret) { |
| 534 | pr_err("%s: gpio set cannot be de-activated %s\n", |
| 535 | __func__, "ext_spk_gpio"); |
| 536 | return ret; |
| 537 | } |
| 538 | } |
| 539 | return 0; |
| 540 | } |
| 541 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 542 | static int msm_config_sdw_gpio(bool enable, struct snd_soc_codec *codec) |
| 543 | { |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 544 | struct snd_soc_card *card = codec->component.card; |
| 545 | struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 546 | int ret = 0; |
| 547 | |
| 548 | pr_debug("%s: %s SDW Clk/Data Gpios\n", __func__, |
| 549 | enable ? "Enable" : "Disable"); |
| 550 | |
| 551 | if (enable) { |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 552 | ret = msm_cdc_pinctrl_select_active_state(pdata->sdw_gpio_p); |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 553 | if (ret) { |
| 554 | pr_err("%s: gpio set cannot be activated %s\n", |
| 555 | __func__, "sdw_pin"); |
| 556 | goto done; |
| 557 | } |
| 558 | } else { |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 559 | ret = msm_cdc_pinctrl_select_sleep_state(pdata->sdw_gpio_p); |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 560 | if (ret) { |
| 561 | pr_err("%s: gpio set cannot be de-activated %s\n", |
| 562 | __func__, "sdw_pin"); |
| 563 | goto done; |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | done: |
| 568 | return ret; |
| 569 | } |
| 570 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 571 | static int int_mi2s_get_idx_from_beid(int32_t be_id) |
| 572 | { |
| 573 | int idx = 0; |
| 574 | |
| 575 | switch (be_id) { |
| 576 | case MSM_BACKEND_DAI_INT0_MI2S_RX: |
| 577 | idx = INT0_MI2S; |
| 578 | break; |
| 579 | case MSM_BACKEND_DAI_INT2_MI2S_TX: |
| 580 | idx = INT2_MI2S; |
| 581 | break; |
| 582 | case MSM_BACKEND_DAI_INT3_MI2S_TX: |
| 583 | idx = INT3_MI2S; |
| 584 | break; |
| 585 | case MSM_BACKEND_DAI_INT4_MI2S_RX: |
| 586 | idx = INT4_MI2S; |
| 587 | break; |
| 588 | case MSM_BACKEND_DAI_INT5_MI2S_TX: |
| 589 | idx = INT5_MI2S; |
| 590 | break; |
| 591 | default: |
| 592 | idx = INT0_MI2S; |
| 593 | break; |
| 594 | } |
| 595 | |
| 596 | return idx; |
| 597 | } |
| 598 | |
| 599 | static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 600 | struct snd_pcm_hw_params *params) |
| 601 | { |
| 602 | struct snd_interval *rate = hw_param_interval(params, |
| 603 | SNDRV_PCM_HW_PARAM_RATE); |
| 604 | |
| 605 | struct snd_interval *channels = hw_param_interval(params, |
| 606 | SNDRV_PCM_HW_PARAM_CHANNELS); |
| 607 | |
| 608 | pr_debug("%s()\n", __func__); |
| 609 | rate->min = rate->max = 48000; |
| 610 | channels->min = channels->max = 2; |
| 611 | |
| 612 | return 0; |
| 613 | } |
| 614 | |
| 615 | static int int_mi2s_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 616 | struct snd_pcm_hw_params *params) |
| 617 | { |
| 618 | struct snd_soc_dai_link *dai_link = rtd->dai_link; |
| 619 | struct snd_interval *rate = hw_param_interval(params, |
| 620 | SNDRV_PCM_HW_PARAM_RATE); |
| 621 | struct snd_interval *channels = hw_param_interval(params, |
| 622 | SNDRV_PCM_HW_PARAM_CHANNELS); |
| 623 | int idx; |
| 624 | |
| 625 | pr_debug("%s: format = %d, rate = %d\n", |
| 626 | __func__, params_format(params), params_rate(params)); |
| 627 | |
| 628 | switch (dai_link->be_id) { |
| 629 | case MSM_BACKEND_DAI_INT0_MI2S_RX: |
| 630 | case MSM_BACKEND_DAI_INT2_MI2S_TX: |
| 631 | case MSM_BACKEND_DAI_INT3_MI2S_TX: |
| 632 | case MSM_BACKEND_DAI_INT4_MI2S_RX: |
| 633 | case MSM_BACKEND_DAI_INT5_MI2S_TX: |
| 634 | idx = int_mi2s_get_idx_from_beid(dai_link->be_id); |
| 635 | rate->min = rate->max = int_mi2s_cfg[idx].sample_rate; |
| 636 | channels->min = channels->max = |
| 637 | int_mi2s_cfg[idx].channels; |
| 638 | param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT, |
| 639 | int_mi2s_cfg[idx].bit_format); |
| 640 | break; |
| 641 | default: |
| 642 | rate->min = rate->max = SAMPLING_RATE_48KHZ; |
| 643 | break; |
| 644 | } |
| 645 | return 0; |
| 646 | } |
| 647 | |
| 648 | static int msm_btfm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 649 | struct snd_pcm_hw_params *params) |
| 650 | { |
| 651 | struct snd_soc_dai_link *dai_link = rtd->dai_link; |
| 652 | struct snd_interval *rate = hw_param_interval(params, |
| 653 | SNDRV_PCM_HW_PARAM_RATE); |
| 654 | struct snd_interval *channels = hw_param_interval(params, |
| 655 | SNDRV_PCM_HW_PARAM_CHANNELS); |
| 656 | |
| 657 | switch (dai_link->be_id) { |
| 658 | case MSM_BACKEND_DAI_SLIMBUS_7_RX: |
| 659 | case MSM_BACKEND_DAI_SLIMBUS_7_TX: |
| 660 | param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT, |
| 661 | bt_fm_cfg[BT_SLIM7].bit_format); |
| 662 | rate->min = rate->max = bt_fm_cfg[BT_SLIM7].sample_rate; |
| 663 | channels->min = channels->max = |
| 664 | bt_fm_cfg[BT_SLIM7].channels; |
| 665 | break; |
| 666 | |
| 667 | case MSM_BACKEND_DAI_SLIMBUS_8_TX: |
| 668 | rate->min = rate->max = bt_fm_cfg[FM_SLIM8].sample_rate; |
| 669 | channels->min = channels->max = |
| 670 | bt_fm_cfg[FM_SLIM8].channels; |
| 671 | break; |
| 672 | |
| 673 | default: |
| 674 | rate->min = rate->max = SAMPLING_RATE_48KHZ; |
| 675 | break; |
| 676 | } |
| 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol, |
| 681 | struct snd_ctl_elem_value *ucontrol) |
| 682 | { |
| 683 | ucontrol->value.integer.value[0] = |
| 684 | (int_mi2s_cfg[INT5_MI2S].channels/2 - 1); |
| 685 | pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__, |
| 686 | ucontrol->value.integer.value[0]); |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 690 | static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol, |
| 691 | struct snd_ctl_elem_value *ucontrol) |
| 692 | { |
| 693 | int_mi2s_cfg[INT5_MI2S].channels = |
| 694 | roundup_pow_of_two(ucontrol->value.integer.value[0] + 2); |
| 695 | |
| 696 | pr_debug("%s: msm_vi_feed_tx_ch = %d\n", |
| 697 | __func__, int_mi2s_cfg[INT5_MI2S].channels); |
| 698 | return 1; |
| 699 | } |
| 700 | |
| 701 | static int msm_int_enable_dig_cdc_clk(struct snd_soc_codec *codec, |
| 702 | int enable, bool dapm) |
| 703 | { |
| 704 | int ret = 0; |
| 705 | struct msm_asoc_mach_data *pdata = NULL; |
| 706 | int clk_freq_in_hz; |
| 707 | bool int_mclk0_freq_chg = false; |
| 708 | |
| 709 | pdata = snd_soc_card_get_drvdata(codec->component.card); |
| 710 | pr_debug("%s: enable %d mclk ref counter %d\n", |
| 711 | __func__, enable, |
| 712 | atomic_read(&pdata->int_mclk0_rsc_ref)); |
| 713 | if (enable) { |
| 714 | if (int_mi2s_cfg[INT0_MI2S].sample_rate == |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 715 | SAMPLING_RATE_44P1KHZ) { |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 716 | clk_freq_in_hz = NATIVE_MCLK_RATE; |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 717 | pdata->native_clk_set = true; |
| 718 | } else { |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 719 | clk_freq_in_hz = pdata->mclk_freq; |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 720 | pdata->native_clk_set = false; |
| 721 | } |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 722 | |
| 723 | if (pdata->digital_cdc_core_clk.clk_freq_in_hz |
| 724 | != clk_freq_in_hz) |
| 725 | int_mclk0_freq_chg = true; |
| 726 | if (!atomic_read(&pdata->int_mclk0_rsc_ref) || |
| 727 | int_mclk0_freq_chg) { |
| 728 | cancel_delayed_work_sync( |
| 729 | &pdata->disable_int_mclk0_work); |
| 730 | mutex_lock(&pdata->cdc_int_mclk0_mutex); |
| 731 | if (atomic_read(&pdata->int_mclk0_enabled) == false || |
| 732 | int_mclk0_freq_chg) { |
Laxminath Kasam | 24f049a | 2017-01-24 18:05:32 +0530 | [diff] [blame^] | 733 | if (atomic_read(&pdata->int_mclk0_enabled)) { |
| 734 | pdata->digital_cdc_core_clk.enable = 0; |
| 735 | afe_set_lpass_clock_v2( |
| 736 | AFE_PORT_ID_INT0_MI2S_RX, |
| 737 | &pdata->digital_cdc_core_clk); |
| 738 | } |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 739 | pdata->digital_cdc_core_clk.clk_freq_in_hz = |
| 740 | clk_freq_in_hz; |
| 741 | pdata->digital_cdc_core_clk.enable = 1; |
| 742 | ret = afe_set_lpass_clock_v2( |
| 743 | AFE_PORT_ID_INT0_MI2S_RX, |
| 744 | &pdata->digital_cdc_core_clk); |
| 745 | if (ret < 0) { |
| 746 | pr_err("%s: failed to enable CCLK\n", |
| 747 | __func__); |
| 748 | mutex_unlock( |
| 749 | &pdata->cdc_int_mclk0_mutex); |
| 750 | return ret; |
| 751 | } |
| 752 | pr_debug("enabled digital codec core clk\n"); |
| 753 | atomic_set(&pdata->int_mclk0_enabled, true); |
| 754 | } |
| 755 | mutex_unlock(&pdata->cdc_int_mclk0_mutex); |
| 756 | } |
| 757 | atomic_inc(&pdata->int_mclk0_rsc_ref); |
| 758 | } else { |
| 759 | cancel_delayed_work_sync(&pdata->disable_int_mclk0_work); |
| 760 | mutex_lock(&pdata->cdc_int_mclk0_mutex); |
| 761 | if (atomic_read(&pdata->int_mclk0_enabled) == true) { |
| 762 | pdata->digital_cdc_core_clk.enable = 0; |
| 763 | ret = afe_set_lpass_clock_v2( |
| 764 | AFE_PORT_ID_INT0_MI2S_RX, |
| 765 | &pdata->digital_cdc_core_clk); |
| 766 | if (ret < 0) |
| 767 | pr_err("%s: failed to disable CCLK\n", |
| 768 | __func__); |
| 769 | atomic_set(&pdata->int_mclk0_enabled, false); |
| 770 | } |
| 771 | mutex_unlock(&pdata->cdc_int_mclk0_mutex); |
| 772 | } |
| 773 | return ret; |
| 774 | } |
| 775 | |
| 776 | static int loopback_mclk_get(struct snd_kcontrol *kcontrol, |
| 777 | struct snd_ctl_elem_value *ucontrol) |
| 778 | { |
| 779 | pr_debug("%s\n", __func__); |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | static int loopback_mclk_put(struct snd_kcontrol *kcontrol, |
| 784 | struct snd_ctl_elem_value *ucontrol) |
| 785 | { |
| 786 | int ret = -EINVAL; |
| 787 | struct msm_asoc_mach_data *pdata = NULL; |
| 788 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
| 789 | |
| 790 | pdata = snd_soc_card_get_drvdata(codec->component.card); |
| 791 | pr_debug("%s: mclk_rsc_ref %d enable %ld\n", |
| 792 | __func__, atomic_read(&pdata->int_mclk0_rsc_ref), |
| 793 | ucontrol->value.integer.value[0]); |
| 794 | switch (ucontrol->value.integer.value[0]) { |
| 795 | case 1: |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 796 | ret = msm_cdc_pinctrl_select_active_state(pdata->pdm_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 797 | if (ret) { |
| 798 | pr_err("%s: failed to enable the pri gpios: %d\n", |
| 799 | __func__, ret); |
| 800 | break; |
| 801 | } |
| 802 | mutex_lock(&pdata->cdc_int_mclk0_mutex); |
| 803 | if ((!atomic_read(&pdata->int_mclk0_rsc_ref)) && |
| 804 | (!atomic_read(&pdata->int_mclk0_enabled))) { |
| 805 | pdata->digital_cdc_core_clk.enable = 1; |
| 806 | ret = afe_set_lpass_clock_v2( |
| 807 | AFE_PORT_ID_INT0_MI2S_RX, |
| 808 | &pdata->digital_cdc_core_clk); |
| 809 | if (ret < 0) { |
| 810 | pr_err("%s: failed to enable the MCLK: %d\n", |
| 811 | __func__, ret); |
| 812 | mutex_unlock(&pdata->cdc_int_mclk0_mutex); |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 813 | ret = msm_cdc_pinctrl_select_sleep_state( |
| 814 | pdata->pdm_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 815 | if (ret) |
| 816 | pr_err("%s: failed to disable the pri gpios: %d\n", |
| 817 | __func__, ret); |
| 818 | break; |
| 819 | } |
| 820 | atomic_set(&pdata->int_mclk0_enabled, true); |
| 821 | } |
| 822 | mutex_unlock(&pdata->cdc_int_mclk0_mutex); |
| 823 | atomic_inc(&pdata->int_mclk0_rsc_ref); |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 824 | msm_anlg_cdc_mclk_enable(codec, 1, true); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 825 | break; |
| 826 | case 0: |
| 827 | if (atomic_read(&pdata->int_mclk0_rsc_ref) <= 0) |
| 828 | break; |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 829 | msm_anlg_cdc_mclk_enable(codec, 0, true); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 830 | mutex_lock(&pdata->cdc_int_mclk0_mutex); |
| 831 | if ((!atomic_dec_return(&pdata->int_mclk0_rsc_ref)) && |
| 832 | (atomic_read(&pdata->int_mclk0_enabled))) { |
| 833 | pdata->digital_cdc_core_clk.enable = 0; |
| 834 | ret = afe_set_lpass_clock_v2( |
| 835 | AFE_PORT_ID_INT0_MI2S_RX, |
| 836 | &pdata->digital_cdc_core_clk); |
| 837 | if (ret < 0) { |
| 838 | pr_err("%s: failed to disable the CCLK: %d\n", |
| 839 | __func__, ret); |
| 840 | mutex_unlock(&pdata->cdc_int_mclk0_mutex); |
| 841 | break; |
| 842 | } |
| 843 | atomic_set(&pdata->int_mclk0_enabled, false); |
| 844 | } |
| 845 | mutex_unlock(&pdata->cdc_int_mclk0_mutex); |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 846 | ret = msm_cdc_pinctrl_select_sleep_state(pdata->pdm_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 847 | if (ret) |
| 848 | pr_err("%s: failed to disable the pri gpios: %d\n", |
| 849 | __func__, ret); |
| 850 | break; |
| 851 | default: |
| 852 | pr_err("%s: Unexpected input value\n", __func__); |
| 853 | break; |
| 854 | } |
| 855 | return ret; |
| 856 | } |
| 857 | |
| 858 | static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol, |
| 859 | struct snd_ctl_elem_value *ucontrol) |
| 860 | { |
| 861 | /* |
| 862 | * Slimbus_7_Rx/Tx sample rate values should always be in sync (same) |
| 863 | * when used for BT_SCO use case. Return either Rx or Tx sample rate |
| 864 | * value. |
| 865 | */ |
| 866 | switch (bt_fm_cfg[BT_SLIM7].sample_rate) { |
| 867 | case SAMPLING_RATE_48KHZ: |
| 868 | ucontrol->value.integer.value[0] = 2; |
| 869 | break; |
| 870 | case SAMPLING_RATE_16KHZ: |
| 871 | ucontrol->value.integer.value[0] = 1; |
| 872 | break; |
| 873 | case SAMPLING_RATE_8KHZ: |
| 874 | default: |
| 875 | ucontrol->value.integer.value[0] = 0; |
| 876 | break; |
| 877 | } |
| 878 | pr_debug("%s: sample rate = %d", __func__, |
| 879 | bt_fm_cfg[BT_SLIM7].sample_rate); |
| 880 | |
| 881 | return 0; |
| 882 | } |
| 883 | |
| 884 | static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol, |
| 885 | struct snd_ctl_elem_value *ucontrol) |
| 886 | { |
| 887 | switch (ucontrol->value.integer.value[0]) { |
| 888 | case 1: |
| 889 | bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_16KHZ; |
| 890 | break; |
| 891 | case 2: |
| 892 | bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_48KHZ; |
| 893 | break; |
| 894 | case 0: |
| 895 | default: |
| 896 | bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_8KHZ; |
| 897 | break; |
| 898 | } |
| 899 | pr_debug("%s: sample rates: slim7_rx = %d, value = %d\n", |
| 900 | __func__, |
| 901 | bt_fm_cfg[BT_SLIM7].sample_rate, |
| 902 | ucontrol->value.enumerated.item[0]); |
| 903 | |
| 904 | return 0; |
| 905 | } |
| 906 | |
| 907 | static const struct snd_kcontrol_new msm_snd_controls[] = { |
| 908 | SOC_ENUM_EXT("INT0_MI2S_RX Format", int0_mi2s_rx_format, |
| 909 | int_mi2s_bit_format_get, int_mi2s_bit_format_put), |
| 910 | SOC_ENUM_EXT("INT2_MI2S_TX Format", int2_mi2s_tx_format, |
| 911 | int_mi2s_bit_format_get, int_mi2s_bit_format_put), |
| 912 | SOC_ENUM_EXT("INT3_MI2S_TX Format", int3_mi2s_tx_format, |
| 913 | int_mi2s_bit_format_get, int_mi2s_bit_format_put), |
| 914 | SOC_ENUM_EXT("INT0_MI2S_RX SampleRate", int0_mi2s_rx_sample_rate, |
| 915 | int_mi2s_sample_rate_get, |
| 916 | int_mi2s_sample_rate_put), |
| 917 | SOC_ENUM_EXT("INT2_MI2S_TX SampleRate", int2_mi2s_tx_sample_rate, |
| 918 | int_mi2s_sample_rate_get, |
| 919 | int_mi2s_sample_rate_put), |
| 920 | SOC_ENUM_EXT("INT3_MI2S_TX SampleRate", int3_mi2s_tx_sample_rate, |
| 921 | int_mi2s_sample_rate_get, |
| 922 | int_mi2s_sample_rate_put), |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 923 | SOC_ENUM_EXT("INT0_MI2S_RX Channels", int0_mi2s_rx_chs, |
| 924 | int_mi2s_ch_get, int_mi2s_ch_put), |
| 925 | SOC_ENUM_EXT("INT2_MI2S_TX Channels", int2_mi2s_tx_chs, |
| 926 | int_mi2s_ch_get, int_mi2s_ch_put), |
| 927 | SOC_ENUM_EXT("INT3_MI2S_TX Channels", int3_mi2s_tx_chs, |
| 928 | int_mi2s_ch_get, int_mi2s_ch_put), |
| 929 | SOC_ENUM_EXT("Loopback MCLK", loopback_mclk_en, |
| 930 | loopback_mclk_get, loopback_mclk_put), |
| 931 | SOC_ENUM_EXT("BT SampleRate", bt_sample_rate, |
| 932 | msm_bt_sample_rate_get, |
| 933 | msm_bt_sample_rate_put), |
| 934 | }; |
| 935 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 936 | static const struct snd_kcontrol_new msm_sdw_controls[] = { |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 937 | SOC_ENUM_EXT("INT4_MI2S_RX Format", int4_mi2s_rx_format, |
| 938 | int_mi2s_bit_format_get, int_mi2s_bit_format_put), |
| 939 | SOC_ENUM_EXT("INT4_MI2S_RX SampleRate", int4_mi2s_rx_sample_rate, |
| 940 | int_mi2s_sample_rate_get, |
| 941 | int_mi2s_sample_rate_put), |
| 942 | SOC_ENUM_EXT("INT4_MI2S_RX SampleRate", int4_mi2s_rx_sample_rate, |
| 943 | int_mi2s_sample_rate_get, |
| 944 | int_mi2s_sample_rate_put), |
| 945 | SOC_ENUM_EXT("INT4_MI2S_RX Channels", int4_mi2s_rx_chs, |
| 946 | int_mi2s_ch_get, int_mi2s_ch_put), |
| 947 | SOC_ENUM_EXT("VI_FEED_TX Channels", int5_mi2s_tx_chs, |
| 948 | msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put), |
| 949 | }; |
| 950 | |
| 951 | static int msm_dmic_event(struct snd_soc_dapm_widget *w, |
| 952 | struct snd_kcontrol *kcontrol, int event) |
| 953 | { |
| 954 | struct msm_asoc_mach_data *pdata = NULL; |
| 955 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); |
| 956 | int ret = 0; |
| 957 | |
| 958 | pdata = snd_soc_card_get_drvdata(codec->component.card); |
| 959 | pr_debug("%s: event = %d\n", __func__, event); |
| 960 | switch (event) { |
| 961 | case SND_SOC_DAPM_PRE_PMU: |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 962 | ret = msm_cdc_pinctrl_select_active_state(pdata->dmic_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 963 | if (ret < 0) { |
| 964 | pr_err("%s: gpio set cannot be activated %sd", |
| 965 | __func__, "dmic_gpio"); |
| 966 | return ret; |
| 967 | } |
| 968 | break; |
| 969 | case SND_SOC_DAPM_POST_PMD: |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 970 | ret = msm_cdc_pinctrl_select_sleep_state(pdata->dmic_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 971 | if (ret < 0) { |
| 972 | pr_err("%s: gpio set cannot be de-activated %sd", |
| 973 | __func__, "dmic_gpio"); |
| 974 | return ret; |
| 975 | } |
| 976 | break; |
| 977 | default: |
| 978 | pr_err("%s: invalid DAPM event %d\n", __func__, event); |
| 979 | return -EINVAL; |
| 980 | } |
| 981 | return 0; |
| 982 | } |
| 983 | |
| 984 | static int msm_int_mclk0_event(struct snd_soc_dapm_widget *w, |
| 985 | struct snd_kcontrol *kcontrol, int event) |
| 986 | { |
| 987 | struct msm_asoc_mach_data *pdata = NULL; |
| 988 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); |
| 989 | int ret = 0; |
| 990 | |
| 991 | pdata = snd_soc_card_get_drvdata(codec->component.card); |
| 992 | pr_debug("%s: event = %d\n", __func__, event); |
| 993 | switch (event) { |
| 994 | case SND_SOC_DAPM_POST_PMD: |
| 995 | pr_debug("%s: mclk_res_ref = %d\n", |
| 996 | __func__, atomic_read(&pdata->int_mclk0_rsc_ref)); |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 997 | ret = msm_cdc_pinctrl_select_sleep_state(pdata->pdm_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 998 | if (ret < 0) { |
| 999 | pr_err("%s: gpio set cannot be de-activated %sd", |
| 1000 | __func__, "int_pdm"); |
| 1001 | return ret; |
| 1002 | } |
| 1003 | if (atomic_read(&pdata->int_mclk0_rsc_ref) == 0) { |
| 1004 | pr_debug("%s: disabling MCLK\n", __func__); |
| 1005 | /* disable the codec mclk config*/ |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1006 | msm_anlg_cdc_mclk_enable(codec, 0, true); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1007 | msm_int_enable_dig_cdc_clk(codec, 0, true); |
| 1008 | } |
| 1009 | break; |
| 1010 | default: |
| 1011 | pr_err("%s: invalid DAPM event %d\n", __func__, event); |
| 1012 | return -EINVAL; |
| 1013 | } |
| 1014 | return 0; |
| 1015 | } |
| 1016 | |
| 1017 | static int int_mi2s_get_port_id(int be_id) |
| 1018 | { |
| 1019 | int afe_port_id; |
| 1020 | |
| 1021 | switch (be_id) { |
| 1022 | case MSM_BACKEND_DAI_INT0_MI2S_RX: |
| 1023 | afe_port_id = AFE_PORT_ID_INT0_MI2S_RX; |
| 1024 | break; |
| 1025 | case MSM_BACKEND_DAI_INT2_MI2S_TX: |
| 1026 | afe_port_id = AFE_PORT_ID_INT2_MI2S_TX; |
| 1027 | break; |
| 1028 | case MSM_BACKEND_DAI_INT3_MI2S_TX: |
| 1029 | afe_port_id = AFE_PORT_ID_INT3_MI2S_TX; |
| 1030 | break; |
| 1031 | case MSM_BACKEND_DAI_INT4_MI2S_RX: |
| 1032 | afe_port_id = AFE_PORT_ID_INT4_MI2S_RX; |
| 1033 | break; |
| 1034 | case MSM_BACKEND_DAI_INT5_MI2S_TX: |
| 1035 | afe_port_id = AFE_PORT_ID_INT5_MI2S_TX; |
| 1036 | break; |
| 1037 | default: |
| 1038 | pr_err("%s: Invalid be_id: %d\n", __func__, be_id); |
| 1039 | afe_port_id = -EINVAL; |
| 1040 | } |
| 1041 | |
| 1042 | return afe_port_id; |
| 1043 | } |
| 1044 | |
| 1045 | static int int_mi2s_get_index(int port_id) |
| 1046 | { |
| 1047 | int index; |
| 1048 | |
| 1049 | switch (port_id) { |
| 1050 | case AFE_PORT_ID_INT0_MI2S_RX: |
| 1051 | index = INT0_MI2S; |
| 1052 | break; |
| 1053 | case AFE_PORT_ID_INT2_MI2S_TX: |
| 1054 | index = INT2_MI2S; |
| 1055 | break; |
| 1056 | case AFE_PORT_ID_INT3_MI2S_TX: |
| 1057 | index = INT3_MI2S; |
| 1058 | break; |
| 1059 | case AFE_PORT_ID_INT4_MI2S_RX: |
| 1060 | index = INT4_MI2S; |
| 1061 | break; |
| 1062 | case AFE_PORT_ID_INT5_MI2S_TX: |
| 1063 | index = INT5_MI2S; |
| 1064 | break; |
| 1065 | default: |
| 1066 | pr_err("%s: Invalid port_id: %d\n", __func__, port_id); |
| 1067 | index = -EINVAL; |
| 1068 | } |
| 1069 | |
| 1070 | return index; |
| 1071 | } |
| 1072 | |
| 1073 | static u32 get_int_mi2s_bits_per_sample(u32 bit_format) |
| 1074 | { |
| 1075 | u32 bit_per_sample; |
| 1076 | |
| 1077 | switch (bit_format) { |
| 1078 | case SNDRV_PCM_FORMAT_S24_3LE: |
| 1079 | case SNDRV_PCM_FORMAT_S24_LE: |
| 1080 | bit_per_sample = 32; |
| 1081 | break; |
| 1082 | case SNDRV_PCM_FORMAT_S16_LE: |
| 1083 | default: |
| 1084 | bit_per_sample = 16; |
| 1085 | break; |
| 1086 | } |
| 1087 | |
| 1088 | return bit_per_sample; |
| 1089 | } |
| 1090 | |
| 1091 | static void update_int_mi2s_clk_val(int idx, int stream) |
| 1092 | { |
| 1093 | u32 bit_per_sample; |
| 1094 | |
| 1095 | bit_per_sample = |
| 1096 | get_int_mi2s_bits_per_sample(int_mi2s_cfg[idx].bit_format); |
| 1097 | int_mi2s_clk[idx].clk_freq_in_hz = |
Laxminath Kasam | 24f049a | 2017-01-24 18:05:32 +0530 | [diff] [blame^] | 1098 | (int_mi2s_cfg[idx].sample_rate * 2 * bit_per_sample); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | static int int_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable) |
| 1102 | { |
| 1103 | int ret = 0; |
| 1104 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 1105 | int port_id = 0; |
| 1106 | int index; |
| 1107 | |
| 1108 | port_id = int_mi2s_get_port_id(rtd->dai_link->be_id); |
Xiaoyu Ye | 1a2d8bd9 | 2017-01-31 18:54:15 -0800 | [diff] [blame] | 1109 | if (port_id < 0) { |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1110 | dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__); |
| 1111 | ret = port_id; |
| 1112 | goto done; |
| 1113 | } |
| 1114 | index = int_mi2s_get_index(port_id); |
| 1115 | if (index < 0) { |
| 1116 | dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__); |
| 1117 | ret = port_id; |
| 1118 | goto done; |
| 1119 | } |
| 1120 | if (enable) { |
| 1121 | update_int_mi2s_clk_val(index, substream->stream); |
| 1122 | dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__, |
| 1123 | int_mi2s_clk[index].clk_freq_in_hz); |
| 1124 | } |
| 1125 | |
| 1126 | int_mi2s_clk[index].enable = enable; |
| 1127 | ret = afe_set_lpass_clock_v2(port_id, |
| 1128 | &int_mi2s_clk[index]); |
| 1129 | if (ret < 0) { |
| 1130 | dev_err(rtd->card->dev, |
| 1131 | "%s: afe lpass clock failed for port 0x%x , err:%d\n", |
| 1132 | __func__, port_id, ret); |
| 1133 | goto done; |
| 1134 | } |
| 1135 | |
| 1136 | done: |
| 1137 | return ret; |
| 1138 | } |
| 1139 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1140 | static int msm_sdw_mi2s_snd_startup(struct snd_pcm_substream *substream) |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1141 | { |
| 1142 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 1143 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 1144 | int ret = 0; |
| 1145 | |
| 1146 | pr_debug("%s(): substream = %s stream = %d\n", __func__, |
| 1147 | substream->name, substream->stream); |
| 1148 | |
| 1149 | ret = int_mi2s_set_sclk(substream, true); |
| 1150 | if (ret < 0) { |
| 1151 | pr_err("%s: failed to enable sclk %d\n", |
| 1152 | __func__, ret); |
| 1153 | return ret; |
| 1154 | } |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1155 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS); |
| 1156 | if (ret < 0) |
| 1157 | pr_err("%s: set fmt cpu dai failed; ret=%d\n", __func__, ret); |
| 1158 | |
| 1159 | return ret; |
| 1160 | } |
| 1161 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1162 | static void msm_sdw_mi2s_snd_shutdown(struct snd_pcm_substream *substream) |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1163 | { |
| 1164 | int ret; |
| 1165 | |
| 1166 | pr_debug("%s(): substream = %s stream = %d\n", __func__, |
| 1167 | substream->name, substream->stream); |
| 1168 | |
| 1169 | ret = int_mi2s_set_sclk(substream, false); |
| 1170 | if (ret < 0) |
| 1171 | pr_err("%s:clock disable failed; ret=%d\n", __func__, |
| 1172 | ret); |
| 1173 | } |
| 1174 | |
| 1175 | static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream) |
| 1176 | { |
| 1177 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 1178 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1179 | struct snd_soc_codec *codec = rtd->codec_dais[ANA_CDC]->codec; |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1180 | int ret = 0; |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 1181 | struct msm_asoc_mach_data *pdata = NULL; |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1182 | |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 1183 | pdata = snd_soc_card_get_drvdata(codec->component.card); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1184 | pr_debug("%s(): substream = %s stream = %d\n", __func__, |
| 1185 | substream->name, substream->stream); |
| 1186 | |
| 1187 | ret = int_mi2s_set_sclk(substream, true); |
| 1188 | if (ret < 0) { |
| 1189 | pr_err("%s: failed to enable sclk %d\n", |
| 1190 | __func__, ret); |
| 1191 | return ret; |
| 1192 | } |
| 1193 | ret = msm_int_enable_dig_cdc_clk(codec, 1, true); |
| 1194 | if (ret < 0) { |
| 1195 | pr_err("failed to enable mclk\n"); |
| 1196 | return ret; |
| 1197 | } |
| 1198 | /* Enable the codec mclk config */ |
Laxminath Kasam | ad0f696 | 2016-12-14 20:00:35 +0530 | [diff] [blame] | 1199 | ret = msm_cdc_pinctrl_select_active_state(pdata->pdm_gpio_p); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1200 | if (ret < 0) { |
| 1201 | pr_err("%s: gpio set cannot be activated %s\n", |
| 1202 | __func__, "int_pdm"); |
| 1203 | return ret; |
| 1204 | } |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1205 | msm_anlg_cdc_mclk_enable(codec, 1, true); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1206 | ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS); |
| 1207 | if (ret < 0) |
| 1208 | pr_err("%s: set fmt cpu dai failed; ret=%d\n", __func__, ret); |
| 1209 | |
| 1210 | return ret; |
| 1211 | } |
| 1212 | |
| 1213 | static void msm_int_mi2s_snd_shutdown(struct snd_pcm_substream *substream) |
| 1214 | { |
| 1215 | int ret; |
| 1216 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 1217 | struct snd_soc_card *card = rtd->card; |
| 1218 | struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); |
| 1219 | |
| 1220 | pr_debug("%s(): substream = %s stream = %d\n", __func__, |
| 1221 | substream->name, substream->stream); |
| 1222 | |
| 1223 | ret = int_mi2s_set_sclk(substream, false); |
| 1224 | if (ret < 0) |
| 1225 | pr_err("%s:clock disable failed; ret=%d\n", __func__, |
| 1226 | ret); |
| 1227 | if (atomic_read(&pdata->int_mclk0_rsc_ref) > 0) { |
| 1228 | atomic_dec(&pdata->int_mclk0_rsc_ref); |
| 1229 | pr_debug("%s: decrementing mclk_res_ref %d\n", |
| 1230 | __func__, |
| 1231 | atomic_read(&pdata->int_mclk0_rsc_ref)); |
| 1232 | } |
| 1233 | } |
| 1234 | |
| 1235 | static void *def_msm_int_wcd_mbhc_cal(void) |
| 1236 | { |
| 1237 | void *msm_int_wcd_cal; |
| 1238 | struct wcd_mbhc_btn_detect_cfg *btn_cfg; |
| 1239 | u16 *btn_low, *btn_high; |
| 1240 | |
| 1241 | msm_int_wcd_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS, |
| 1242 | WCD_MBHC_DEF_RLOADS), GFP_KERNEL); |
| 1243 | if (!msm_int_wcd_cal) |
| 1244 | return NULL; |
| 1245 | |
| 1246 | #define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(msm_int_wcd_cal)->X) = (Y)) |
| 1247 | S(v_hs_max, 1500); |
| 1248 | #undef S |
| 1249 | #define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(msm_int_wcd_cal)->X) = (Y)) |
| 1250 | S(num_btn, WCD_MBHC_DEF_BUTTONS); |
| 1251 | #undef S |
| 1252 | |
| 1253 | |
| 1254 | btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(msm_int_wcd_cal); |
| 1255 | btn_low = btn_cfg->_v_btn_low; |
| 1256 | btn_high = ((void *)&btn_cfg->_v_btn_low) + |
| 1257 | (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn); |
| 1258 | |
| 1259 | /* |
| 1260 | * In SW we are maintaining two sets of threshold register |
| 1261 | * one for current source and another for Micbias. |
| 1262 | * all btn_low corresponds to threshold for current source |
| 1263 | * all bt_high corresponds to threshold for Micbias |
| 1264 | * Below thresholds are based on following resistances |
| 1265 | * 0-70 == Button 0 |
| 1266 | * 110-180 == Button 1 |
| 1267 | * 210-290 == Button 2 |
| 1268 | * 360-680 == Button 3 |
| 1269 | */ |
| 1270 | btn_low[0] = 75; |
| 1271 | btn_high[0] = 75; |
| 1272 | btn_low[1] = 150; |
| 1273 | btn_high[1] = 150; |
| 1274 | btn_low[2] = 225; |
| 1275 | btn_high[2] = 225; |
| 1276 | btn_low[3] = 450; |
| 1277 | btn_high[3] = 450; |
| 1278 | btn_low[4] = 500; |
| 1279 | btn_high[4] = 500; |
| 1280 | |
| 1281 | return msm_int_wcd_cal; |
| 1282 | } |
| 1283 | |
| 1284 | static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd) |
| 1285 | { |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1286 | struct snd_soc_codec *dig_cdc = rtd->codec_dais[DIG_CDC]->codec; |
| 1287 | struct snd_soc_codec *ana_cdc = rtd->codec_dais[ANA_CDC]->codec; |
| 1288 | struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(ana_cdc); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1289 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1290 | struct snd_soc_pcm_runtime *rtd_aux = rtd->card->rtd_aux; |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1291 | struct snd_card *card; |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1292 | int ret = -ENOMEM; |
| 1293 | |
| 1294 | pr_debug("%s(),dev_name%s\n", __func__, dev_name(cpu_dai->dev)); |
| 1295 | |
Laxminath Kasam | 35a610e | 2016-12-30 15:02:33 +0530 | [diff] [blame] | 1296 | ret = snd_soc_add_codec_controls(ana_cdc, msm_snd_controls, |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1297 | ARRAY_SIZE(msm_snd_controls)); |
Laxminath Kasam | 35a610e | 2016-12-30 15:02:33 +0530 | [diff] [blame] | 1298 | if (ret < 0) { |
| 1299 | pr_err("%s: add_codec_controls failed: %d\n", |
| 1300 | __func__, ret); |
| 1301 | return ret; |
| 1302 | } |
| 1303 | ret = snd_soc_add_codec_controls(ana_cdc, msm_common_snd_controls, |
| 1304 | msm_common_snd_controls_size()); |
| 1305 | if (ret < 0) { |
| 1306 | pr_err("%s: add common snd controls failed: %d\n", |
| 1307 | __func__, ret); |
| 1308 | return ret; |
| 1309 | } |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1310 | |
| 1311 | snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets, |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1312 | ARRAY_SIZE(msm_int_dapm_widgets)); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1313 | |
| 1314 | snd_soc_dapm_ignore_suspend(dapm, "Handset Mic"); |
| 1315 | snd_soc_dapm_ignore_suspend(dapm, "Headset Mic"); |
| 1316 | snd_soc_dapm_ignore_suspend(dapm, "Secondary Mic"); |
| 1317 | snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1"); |
| 1318 | snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2"); |
| 1319 | |
| 1320 | snd_soc_dapm_ignore_suspend(dapm, "EAR"); |
| 1321 | snd_soc_dapm_ignore_suspend(dapm, "HEADPHONE"); |
| 1322 | snd_soc_dapm_ignore_suspend(dapm, "SPK_OUT"); |
| 1323 | snd_soc_dapm_ignore_suspend(dapm, "AMIC1"); |
| 1324 | snd_soc_dapm_ignore_suspend(dapm, "AMIC2"); |
| 1325 | snd_soc_dapm_ignore_suspend(dapm, "AMIC3"); |
| 1326 | snd_soc_dapm_ignore_suspend(dapm, "DMIC1"); |
| 1327 | snd_soc_dapm_ignore_suspend(dapm, "DMIC2"); |
| 1328 | snd_soc_dapm_ignore_suspend(dapm, "DMIC3"); |
| 1329 | snd_soc_dapm_ignore_suspend(dapm, "DMIC4"); |
| 1330 | |
| 1331 | snd_soc_dapm_sync(dapm); |
| 1332 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1333 | /* |
| 1334 | * Send speaker configuration only for WSA8810. |
| 1335 | * Defalut configuration is for WSA8815. |
| 1336 | */ |
| 1337 | if (rtd_aux && rtd_aux->component) |
| 1338 | if (!strcmp(rtd_aux->component->name, WSA8810_NAME_1) || |
| 1339 | !strcmp(rtd_aux->component->name, WSA8810_NAME_2)) { |
| 1340 | msm_sdw_set_spkr_mode(rtd->codec, SPKR_MODE_1); |
| 1341 | msm_sdw_set_spkr_gain_offset(rtd->codec, |
| 1342 | RX_GAIN_OFFSET_M1P5_DB); |
| 1343 | } |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1344 | msm_anlg_cdc_spk_ext_pa_cb(enable_spk_ext_pa, ana_cdc); |
| 1345 | msm_dig_cdc_hph_comp_cb(msm_config_hph_compander_gpio, dig_cdc); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1346 | |
| 1347 | mbhc_cfg_ptr->calibration = def_msm_int_wcd_mbhc_cal(); |
| 1348 | if (mbhc_cfg_ptr->calibration) { |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1349 | ret = msm_anlg_cdc_hs_detect(ana_cdc, mbhc_cfg_ptr); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1350 | if (ret) { |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1351 | pr_err("%s: msm_anlg_cdc_hs_detect failed\n", __func__); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1352 | kfree(mbhc_cfg_ptr->calibration); |
| 1353 | return ret; |
| 1354 | } |
| 1355 | } |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1356 | card = rtd->card->snd_card; |
Laxminath Kasam | 4e44457 | 2017-01-15 20:00:11 +0530 | [diff] [blame] | 1357 | if (!codec_root) |
| 1358 | codec_root = snd_register_module_info(card->module, "codecs", |
| 1359 | card->proc_root); |
| 1360 | if (!codec_root) { |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1361 | pr_debug("%s: Cannot create codecs module entry\n", |
| 1362 | __func__); |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1363 | goto done; |
| 1364 | } |
Laxminath Kasam | 4e44457 | 2017-01-15 20:00:11 +0530 | [diff] [blame] | 1365 | msm_dig_codec_info_create_codec_entry(codec_root, dig_cdc); |
| 1366 | msm_anlg_codec_info_create_codec_entry(codec_root, ana_cdc); |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1367 | done: |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1368 | return 0; |
| 1369 | } |
| 1370 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1371 | static int msm_sdw_audrx_init(struct snd_soc_pcm_runtime *rtd) |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1372 | { |
| 1373 | struct snd_soc_codec *codec = rtd->codec; |
| 1374 | struct snd_soc_dapm_context *dapm = |
| 1375 | snd_soc_codec_get_dapm(codec); |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1376 | struct snd_card *card; |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1377 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1378 | snd_soc_add_codec_controls(codec, msm_sdw_controls, |
| 1379 | ARRAY_SIZE(msm_sdw_controls)); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1380 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1381 | snd_soc_dapm_ignore_suspend(dapm, "AIF1_SDW Playback"); |
| 1382 | snd_soc_dapm_ignore_suspend(dapm, "VIfeed_SDW"); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1383 | snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT"); |
| 1384 | snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT"); |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1385 | snd_soc_dapm_ignore_suspend(dapm, "AIF1_SDW VI"); |
| 1386 | snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_SDW"); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1387 | |
| 1388 | snd_soc_dapm_sync(dapm); |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1389 | msm_sdw_gpio_cb(msm_config_sdw_gpio, codec); |
| 1390 | card = rtd->card->snd_card; |
Laxminath Kasam | 4e44457 | 2017-01-15 20:00:11 +0530 | [diff] [blame] | 1391 | if (!codec_root) |
| 1392 | codec_root = snd_register_module_info(card->module, "codecs", |
| 1393 | card->proc_root); |
| 1394 | if (!codec_root) { |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1395 | pr_debug("%s: Cannot create codecs module entry\n", |
| 1396 | __func__); |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1397 | goto done; |
| 1398 | } |
Laxminath Kasam | 4e44457 | 2017-01-15 20:00:11 +0530 | [diff] [blame] | 1399 | msm_sdw_codec_info_create_codec_entry(codec_root, codec); |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1400 | done: |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1401 | return 0; |
| 1402 | } |
| 1403 | |
| 1404 | static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd) |
| 1405 | { |
| 1406 | unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158}; |
| 1407 | unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160, 161}; |
| 1408 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 1409 | |
| 1410 | return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch), |
| 1411 | tx_ch, ARRAY_SIZE(rx_ch), rx_ch); |
| 1412 | } |
| 1413 | |
| 1414 | static int msm_wcn_hw_params(struct snd_pcm_substream *substream, |
| 1415 | struct snd_pcm_hw_params *params) |
| 1416 | { |
| 1417 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 1418 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 1419 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 1420 | struct snd_soc_dai_link *dai_link = rtd->dai_link; |
| 1421 | u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX]; |
| 1422 | u32 rx_ch_cnt = 0, tx_ch_cnt = 0; |
| 1423 | int ret; |
| 1424 | |
| 1425 | dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__, |
| 1426 | codec_dai->name, codec_dai->id); |
| 1427 | ret = snd_soc_dai_get_channel_map(codec_dai, |
| 1428 | &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch); |
| 1429 | if (ret) { |
| 1430 | dev_err(rtd->dev, |
| 1431 | "%s: failed to get BTFM codec chan map\n, err:%d\n", |
| 1432 | __func__, ret); |
| 1433 | goto exit; |
| 1434 | } |
| 1435 | |
| 1436 | dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) be_id %d\n", |
| 1437 | __func__, tx_ch_cnt, dai_link->be_id); |
| 1438 | |
| 1439 | ret = snd_soc_dai_set_channel_map(cpu_dai, |
| 1440 | tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch); |
| 1441 | if (ret) |
| 1442 | dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n", |
| 1443 | __func__, ret); |
| 1444 | |
| 1445 | exit: |
| 1446 | return ret; |
| 1447 | } |
| 1448 | |
| 1449 | static unsigned int tdm_param_set_slot_mask(u16 port_id, int slot_width, |
| 1450 | int slots) |
| 1451 | { |
| 1452 | unsigned int slot_mask = 0; |
| 1453 | int i, j; |
| 1454 | unsigned int *slot_offset; |
| 1455 | |
| 1456 | for (i = TDM_0; i < TDM_PORT_MAX; i++) { |
| 1457 | slot_offset = tdm_slot_offset[i]; |
| 1458 | |
| 1459 | for (j = 0; j < TDM_SLOT_OFFSET_MAX; j++) { |
| 1460 | if (slot_offset[j] != AFE_SLOT_MAPPING_OFFSET_INVALID) |
| 1461 | slot_mask |= |
| 1462 | (1 << ((slot_offset[j] * 8) / slot_width)); |
| 1463 | else |
| 1464 | break; |
| 1465 | } |
| 1466 | } |
| 1467 | |
| 1468 | return slot_mask; |
| 1469 | } |
| 1470 | |
| 1471 | static int msm_tdm_snd_hw_params(struct snd_pcm_substream *substream, |
| 1472 | struct snd_pcm_hw_params *params) |
| 1473 | { |
| 1474 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 1475 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 1476 | int ret = 0; |
| 1477 | int channels, slot_width, slots; |
| 1478 | unsigned int slot_mask; |
| 1479 | unsigned int *slot_offset; |
| 1480 | int offset_channels = 0; |
| 1481 | int i; |
| 1482 | |
| 1483 | pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id); |
| 1484 | |
| 1485 | channels = params_channels(params); |
| 1486 | switch (channels) { |
| 1487 | case 1: |
| 1488 | case 2: |
| 1489 | case 3: |
| 1490 | case 4: |
| 1491 | case 5: |
| 1492 | case 6: |
| 1493 | case 7: |
| 1494 | case 8: |
| 1495 | switch (params_format(params)) { |
| 1496 | case SNDRV_PCM_FORMAT_S32_LE: |
| 1497 | case SNDRV_PCM_FORMAT_S24_LE: |
| 1498 | case SNDRV_PCM_FORMAT_S16_LE: |
| 1499 | /* |
| 1500 | * up to 8 channels HW config should |
| 1501 | * use 32 bit slot width for max support of |
| 1502 | * stream bit width. (slot_width > bit_width) |
| 1503 | */ |
| 1504 | slot_width = 32; |
| 1505 | break; |
| 1506 | default: |
| 1507 | pr_err("%s: invalid param format 0x%x\n", |
| 1508 | __func__, params_format(params)); |
| 1509 | return -EINVAL; |
| 1510 | } |
| 1511 | slots = 8; |
| 1512 | slot_mask = tdm_param_set_slot_mask(cpu_dai->id, |
| 1513 | slot_width, |
| 1514 | slots); |
| 1515 | if (!slot_mask) { |
| 1516 | pr_err("%s: invalid slot_mask 0x%x\n", |
| 1517 | __func__, slot_mask); |
| 1518 | return -EINVAL; |
| 1519 | } |
| 1520 | break; |
| 1521 | default: |
| 1522 | pr_err("%s: invalid param channels %d\n", |
| 1523 | __func__, channels); |
| 1524 | return -EINVAL; |
| 1525 | } |
| 1526 | /* currently only supporting TDM_RX_0 and TDM_TX_0 */ |
| 1527 | switch (cpu_dai->id) { |
| 1528 | case AFE_PORT_ID_PRIMARY_TDM_RX: |
| 1529 | case AFE_PORT_ID_SECONDARY_TDM_RX: |
| 1530 | case AFE_PORT_ID_TERTIARY_TDM_RX: |
| 1531 | case AFE_PORT_ID_QUATERNARY_TDM_RX: |
| 1532 | case AFE_PORT_ID_PRIMARY_TDM_TX: |
| 1533 | case AFE_PORT_ID_SECONDARY_TDM_TX: |
| 1534 | case AFE_PORT_ID_TERTIARY_TDM_TX: |
| 1535 | case AFE_PORT_ID_QUATERNARY_TDM_TX: |
| 1536 | slot_offset = tdm_slot_offset[TDM_0]; |
| 1537 | break; |
| 1538 | default: |
| 1539 | pr_err("%s: dai id 0x%x not supported\n", |
| 1540 | __func__, cpu_dai->id); |
| 1541 | return -EINVAL; |
| 1542 | } |
| 1543 | |
| 1544 | for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) { |
| 1545 | if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID) |
| 1546 | offset_channels++; |
| 1547 | else |
| 1548 | break; |
| 1549 | } |
| 1550 | |
| 1551 | if (offset_channels == 0) { |
| 1552 | pr_err("%s: slot offset not supported, offset_channels %d\n", |
| 1553 | __func__, offset_channels); |
| 1554 | return -EINVAL; |
| 1555 | } |
| 1556 | |
| 1557 | if (channels > offset_channels) { |
| 1558 | pr_err("%s: channels %d exceed offset_channels %d\n", |
| 1559 | __func__, channels, offset_channels); |
| 1560 | return -EINVAL; |
| 1561 | } |
| 1562 | |
| 1563 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 1564 | ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask, |
| 1565 | slots, slot_width); |
| 1566 | if (ret < 0) { |
| 1567 | pr_err("%s: failed to set tdm slot, err:%d\n", |
| 1568 | __func__, ret); |
| 1569 | goto end; |
| 1570 | } |
| 1571 | |
| 1572 | ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, |
| 1573 | channels, slot_offset); |
| 1574 | if (ret < 0) { |
| 1575 | pr_err("%s: failed to set channel map, err:%d\n", |
| 1576 | __func__, ret); |
| 1577 | goto end; |
| 1578 | } |
| 1579 | } else { |
| 1580 | ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0, |
| 1581 | slots, slot_width); |
| 1582 | if (ret < 0) { |
| 1583 | pr_err("%s: failed to set tdm slot, err:%d\n", |
| 1584 | __func__, ret); |
| 1585 | goto end; |
| 1586 | } |
| 1587 | |
| 1588 | ret = snd_soc_dai_set_channel_map(cpu_dai, channels, |
| 1589 | slot_offset, 0, NULL); |
| 1590 | if (ret < 0) { |
| 1591 | pr_err("%s: failed to set channel map, err:%d\n", |
| 1592 | __func__, ret); |
| 1593 | goto end; |
| 1594 | } |
| 1595 | } |
| 1596 | end: |
| 1597 | return ret; |
| 1598 | } |
| 1599 | |
| 1600 | static struct snd_soc_ops msm_tdm_be_ops = { |
| 1601 | .hw_params = msm_tdm_snd_hw_params |
| 1602 | }; |
| 1603 | |
| 1604 | static struct snd_soc_ops msm_wcn_ops = { |
| 1605 | .hw_params = msm_wcn_hw_params, |
| 1606 | }; |
| 1607 | |
| 1608 | static struct snd_soc_ops msm_mi2s_be_ops = { |
| 1609 | .startup = msm_mi2s_snd_startup, |
| 1610 | .shutdown = msm_mi2s_snd_shutdown, |
| 1611 | }; |
| 1612 | |
| 1613 | static struct snd_soc_ops msm_aux_pcm_be_ops = { |
| 1614 | .startup = msm_aux_pcm_snd_startup, |
| 1615 | .shutdown = msm_aux_pcm_snd_shutdown, |
| 1616 | }; |
| 1617 | |
| 1618 | static struct snd_soc_ops msm_int_mi2s_be_ops = { |
| 1619 | .startup = msm_int_mi2s_snd_startup, |
| 1620 | .shutdown = msm_int_mi2s_snd_shutdown, |
| 1621 | }; |
| 1622 | |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 1623 | static struct snd_soc_ops msm_sdw_mi2s_be_ops = { |
| 1624 | .startup = msm_sdw_mi2s_snd_startup, |
| 1625 | .shutdown = msm_sdw_mi2s_snd_shutdown, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1626 | }; |
| 1627 | |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1628 | struct snd_soc_dai_link_component dlc_rx1[] = { |
| 1629 | { |
| 1630 | .of_node = NULL, |
| 1631 | .dai_name = "msm_dig_cdc_dai_rx1", |
| 1632 | }, |
| 1633 | { |
| 1634 | .of_node = NULL, |
| 1635 | .dai_name = "msm_anlg_cdc_i2s_rx1", |
| 1636 | }, |
| 1637 | }; |
| 1638 | |
| 1639 | struct snd_soc_dai_link_component dlc_tx1[] = { |
| 1640 | { |
| 1641 | .of_node = NULL, |
| 1642 | .dai_name = "msm_dig_cdc_dai_tx1", |
| 1643 | }, |
| 1644 | { |
| 1645 | .of_node = NULL, |
| 1646 | .dai_name = "msm_anlg_cdc_i2s_tx1", |
| 1647 | }, |
| 1648 | }; |
| 1649 | |
| 1650 | struct snd_soc_dai_link_component dlc_tx2[] = { |
| 1651 | { |
| 1652 | .of_node = NULL, |
| 1653 | .dai_name = "msm_dig_cdc_dai_tx2", |
| 1654 | }, |
| 1655 | { |
| 1656 | .of_node = NULL, |
| 1657 | .dai_name = "msm_anlg_cdc_i2s_tx2", |
| 1658 | }, |
| 1659 | }; |
| 1660 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1661 | /* Digital audio interface glue - connects codec <---> CPU */ |
| 1662 | static struct snd_soc_dai_link msm_int_dai[] = { |
| 1663 | /* FrontEnd DAI Links */ |
| 1664 | {/* hw:x,0 */ |
| 1665 | .name = MSM_DAILINK_NAME(Media1), |
| 1666 | .stream_name = "MultiMedia1", |
| 1667 | .cpu_dai_name = "MultiMedia1", |
| 1668 | .platform_name = "msm-pcm-dsp.0", |
| 1669 | .dynamic = 1, |
| 1670 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1671 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1672 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1673 | .codec_name = "snd-soc-dummy", |
| 1674 | .ignore_suspend = 1, |
| 1675 | .dpcm_playback = 1, |
| 1676 | .dpcm_capture = 1, |
| 1677 | /* this dai link has playback support */ |
| 1678 | .ignore_pmdown_time = 1, |
| 1679 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA1 |
| 1680 | }, |
| 1681 | {/* hw:x,1 */ |
| 1682 | .name = MSM_DAILINK_NAME(Media2), |
| 1683 | .stream_name = "MultiMedia2", |
| 1684 | .cpu_dai_name = "MultiMedia2", |
| 1685 | .platform_name = "msm-pcm-dsp.0", |
| 1686 | .dynamic = 1, |
| 1687 | .dpcm_playback = 1, |
| 1688 | .dpcm_capture = 1, |
| 1689 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1690 | .codec_name = "snd-soc-dummy", |
| 1691 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1692 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1693 | .ignore_suspend = 1, |
| 1694 | /* this dai link has playback support */ |
| 1695 | .ignore_pmdown_time = 1, |
| 1696 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA2, |
| 1697 | }, |
| 1698 | {/* hw:x,2 */ |
| 1699 | .name = "VoiceMMode1", |
| 1700 | .stream_name = "VoiceMMode1", |
| 1701 | .cpu_dai_name = "VoiceMMode1", |
| 1702 | .platform_name = "msm-pcm-voice", |
| 1703 | .dynamic = 1, |
| 1704 | .dpcm_capture = 1, |
| 1705 | .dpcm_playback = 1, |
| 1706 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1707 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1708 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1709 | .ignore_suspend = 1, |
| 1710 | .ignore_pmdown_time = 1, |
| 1711 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1712 | .codec_name = "snd-soc-dummy", |
| 1713 | .be_id = MSM_FRONTEND_DAI_VOICEMMODE1, |
| 1714 | }, |
| 1715 | {/* hw:x,3 */ |
| 1716 | .name = "MSM VoIP", |
| 1717 | .stream_name = "VoIP", |
| 1718 | .cpu_dai_name = "VoIP", |
| 1719 | .platform_name = "msm-voip-dsp", |
| 1720 | .dynamic = 1, |
| 1721 | .dpcm_playback = 1, |
| 1722 | .dpcm_capture = 1, |
| 1723 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1724 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1725 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1726 | .codec_name = "snd-soc-dummy", |
| 1727 | .ignore_suspend = 1, |
| 1728 | /* this dai link has playback support */ |
| 1729 | .ignore_pmdown_time = 1, |
| 1730 | .be_id = MSM_FRONTEND_DAI_VOIP, |
| 1731 | }, |
| 1732 | {/* hw:x,4 */ |
| 1733 | .name = MSM_DAILINK_NAME(ULL), |
| 1734 | .stream_name = "ULL", |
| 1735 | .cpu_dai_name = "MultiMedia3", |
| 1736 | .platform_name = "msm-pcm-dsp.2", |
| 1737 | .dynamic = 1, |
| 1738 | .dpcm_playback = 1, |
| 1739 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1740 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1741 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1742 | .codec_name = "snd-soc-dummy", |
| 1743 | .ignore_suspend = 1, |
| 1744 | /* this dai link has playback support */ |
| 1745 | .ignore_pmdown_time = 1, |
| 1746 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA3, |
| 1747 | }, |
| 1748 | /* Hostless PCM purpose */ |
| 1749 | {/* hw:x,5 */ |
| 1750 | .name = "INT4 MI2S_RX Hostless", |
| 1751 | .stream_name = "INT4 MI2S_RX Hostless", |
| 1752 | .cpu_dai_name = "INT4_MI2S_RX_HOSTLESS", |
| 1753 | .platform_name = "msm-pcm-hostless", |
| 1754 | .dynamic = 1, |
| 1755 | .dpcm_playback = 1, |
| 1756 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1757 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1758 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1759 | .ignore_suspend = 1, |
| 1760 | /* this dailink has playback support */ |
| 1761 | .ignore_pmdown_time = 1, |
| 1762 | /* This dainlink has MI2S support */ |
| 1763 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1764 | .codec_name = "snd-soc-dummy", |
| 1765 | }, |
| 1766 | {/* hw:x,6 */ |
| 1767 | .name = "MSM AFE-PCM RX", |
| 1768 | .stream_name = "AFE-PROXY RX", |
| 1769 | .cpu_dai_name = "msm-dai-q6-dev.241", |
| 1770 | .codec_name = "msm-stub-codec.1", |
| 1771 | .codec_dai_name = "msm-stub-rx", |
| 1772 | .platform_name = "msm-pcm-afe", |
| 1773 | .ignore_suspend = 1, |
| 1774 | /* this dai link has playback support */ |
| 1775 | .ignore_pmdown_time = 1, |
| 1776 | }, |
| 1777 | {/* hw:x,7 */ |
| 1778 | .name = "MSM AFE-PCM TX", |
| 1779 | .stream_name = "AFE-PROXY TX", |
| 1780 | .cpu_dai_name = "msm-dai-q6-dev.240", |
| 1781 | .codec_name = "msm-stub-codec.1", |
| 1782 | .codec_dai_name = "msm-stub-tx", |
| 1783 | .platform_name = "msm-pcm-afe", |
| 1784 | .ignore_suspend = 1, |
| 1785 | }, |
| 1786 | {/* hw:x,8 */ |
| 1787 | .name = MSM_DAILINK_NAME(Compress1), |
| 1788 | .stream_name = "Compress1", |
| 1789 | .cpu_dai_name = "MultiMedia4", |
| 1790 | .platform_name = "msm-compress-dsp", |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 1791 | .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1792 | .dynamic = 1, |
| 1793 | .dpcm_capture = 1, |
| 1794 | .dpcm_playback = 1, |
| 1795 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1796 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1797 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1798 | .codec_name = "snd-soc-dummy", |
| 1799 | .ignore_suspend = 1, |
| 1800 | .ignore_pmdown_time = 1, |
| 1801 | /* this dai link has playback support */ |
| 1802 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA4, |
| 1803 | }, |
| 1804 | {/* hw:x,9*/ |
| 1805 | .name = "AUXPCM Hostless", |
| 1806 | .stream_name = "AUXPCM Hostless", |
| 1807 | .cpu_dai_name = "AUXPCM_HOSTLESS", |
| 1808 | .platform_name = "msm-pcm-hostless", |
| 1809 | .dynamic = 1, |
| 1810 | .dpcm_capture = 1, |
| 1811 | .dpcm_playback = 1, |
| 1812 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1813 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1814 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1815 | .ignore_suspend = 1, |
| 1816 | /* this dai link has playback support */ |
| 1817 | .ignore_pmdown_time = 1, |
| 1818 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1819 | .codec_name = "snd-soc-dummy", |
| 1820 | }, |
| 1821 | {/* hw:x,10 */ |
| 1822 | .name = "SLIMBUS_1 Hostless", |
| 1823 | .stream_name = "SLIMBUS_1 Hostless", |
| 1824 | .cpu_dai_name = "SLIMBUS1_HOSTLESS", |
| 1825 | .platform_name = "msm-pcm-hostless", |
| 1826 | .dynamic = 1, |
| 1827 | .dpcm_capture = 1, |
| 1828 | .dpcm_playback = 1, |
| 1829 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1830 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1831 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1832 | .ignore_suspend = 1, |
| 1833 | .ignore_pmdown_time = 1, /* dai link has playback support */ |
| 1834 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1835 | .codec_name = "snd-soc-dummy", |
| 1836 | }, |
| 1837 | {/* hw:x,11 */ |
Laxminath Kasam | fc19e02 | 2016-12-14 22:20:11 +0530 | [diff] [blame] | 1838 | .name = "INT3 MI2S_TX Hostless", |
| 1839 | .stream_name = "INT3 MI2S_TX Hostless", |
| 1840 | .cpu_dai_name = "INT3_MI2S_TX_HOSTLESS", |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1841 | .platform_name = "msm-pcm-hostless", |
| 1842 | .dynamic = 1, |
| 1843 | .dpcm_capture = 1, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1844 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1845 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1846 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1847 | .ignore_suspend = 1, |
Laxminath Kasam | fc19e02 | 2016-12-14 22:20:11 +0530 | [diff] [blame] | 1848 | .ignore_pmdown_time = 1, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1849 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1850 | .codec_name = "snd-soc-dummy", |
| 1851 | }, |
| 1852 | {/* hw:x,12 */ |
Laxminath Kasam | fc19e02 | 2016-12-14 22:20:11 +0530 | [diff] [blame] | 1853 | .name = "SLIMBUS_7 Hostless", |
| 1854 | .stream_name = "SLIMBUS_7 Hostless", |
| 1855 | .cpu_dai_name = "SLIMBUS7_HOSTLESS", |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1856 | .platform_name = "msm-pcm-hostless", |
| 1857 | .dynamic = 1, |
| 1858 | .dpcm_capture = 1, |
| 1859 | .dpcm_playback = 1, |
| 1860 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1861 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1862 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1863 | .ignore_suspend = 1, |
| 1864 | .ignore_pmdown_time = 1, /* dai link has playback support */ |
| 1865 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1866 | .codec_name = "snd-soc-dummy", |
| 1867 | }, |
| 1868 | {/* hw:x,13 */ |
| 1869 | .name = MSM_DAILINK_NAME(LowLatency), |
| 1870 | .stream_name = "MultiMedia5", |
| 1871 | .cpu_dai_name = "MultiMedia5", |
| 1872 | .platform_name = "msm-pcm-dsp.1", |
| 1873 | .dynamic = 1, |
| 1874 | .dpcm_capture = 1, |
| 1875 | .dpcm_playback = 1, |
| 1876 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1877 | .codec_name = "snd-soc-dummy", |
| 1878 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1879 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1880 | .ignore_suspend = 1, |
| 1881 | /* this dai link has playback support */ |
| 1882 | .ignore_pmdown_time = 1, |
| 1883 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA5, |
| 1884 | }, |
| 1885 | /* LSM FE */ |
| 1886 | {/* hw:x,14 */ |
| 1887 | .name = "Listen 1 Audio Service", |
| 1888 | .stream_name = "Listen 1 Audio Service", |
| 1889 | .cpu_dai_name = "LSM1", |
| 1890 | .platform_name = "msm-lsm-client", |
| 1891 | .dynamic = 1, |
| 1892 | .dpcm_capture = 1, |
| 1893 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1894 | SND_SOC_DPCM_TRIGGER_POST }, |
| 1895 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1896 | .ignore_suspend = 1, |
| 1897 | .ignore_pmdown_time = 1, |
| 1898 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1899 | .codec_name = "snd-soc-dummy", |
| 1900 | .be_id = MSM_FRONTEND_DAI_LSM1, |
| 1901 | }, |
| 1902 | {/* hw:x,15 */ |
| 1903 | .name = MSM_DAILINK_NAME(Compress2), |
| 1904 | .stream_name = "Compress2", |
| 1905 | .cpu_dai_name = "MultiMedia7", |
| 1906 | .platform_name = "msm-compress-dsp", |
| 1907 | .dynamic = 1, |
| 1908 | .dpcm_capture = 1, |
| 1909 | .dpcm_playback = 1, |
| 1910 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1911 | .codec_name = "snd-soc-dummy", |
| 1912 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1913 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1914 | .ignore_suspend = 1, |
| 1915 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA7, |
| 1916 | }, |
| 1917 | {/* hw:x,16 */ |
| 1918 | .name = MSM_DAILINK_NAME(Compress3), |
| 1919 | .stream_name = "Compress3", |
| 1920 | .cpu_dai_name = "MultiMedia10", |
| 1921 | .platform_name = "msm-compress-dsp", |
| 1922 | .dynamic = 1, |
| 1923 | .dpcm_capture = 1, |
| 1924 | .dpcm_playback = 1, |
| 1925 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1926 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1927 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1928 | .codec_name = "snd-soc-dummy", |
| 1929 | .ignore_suspend = 1, |
| 1930 | .ignore_pmdown_time = 1, |
| 1931 | /* this dai link has playback support */ |
| 1932 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA10, |
| 1933 | }, |
| 1934 | {/* hw:x,17 */ |
| 1935 | .name = MSM_DAILINK_NAME(ULL_NOIRQ), |
| 1936 | .stream_name = "MM_NOIRQ", |
| 1937 | .cpu_dai_name = "MultiMedia8", |
| 1938 | .platform_name = "msm-pcm-dsp-noirq", |
| 1939 | .dynamic = 1, |
| 1940 | .dpcm_capture = 1, |
| 1941 | .dpcm_playback = 1, |
| 1942 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1943 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1944 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1945 | .codec_name = "snd-soc-dummy", |
| 1946 | .ignore_suspend = 1, |
| 1947 | .ignore_pmdown_time = 1, |
| 1948 | /* this dai link has playback support */ |
| 1949 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA8, |
| 1950 | }, |
| 1951 | {/* hw:x,18 */ |
| 1952 | .name = "HDMI_RX_HOSTLESS", |
| 1953 | .stream_name = "HDMI_RX_HOSTLESS", |
| 1954 | .cpu_dai_name = "HDMI_HOSTLESS", |
| 1955 | .platform_name = "msm-pcm-hostless", |
| 1956 | .dynamic = 1, |
| 1957 | .dpcm_playback = 1, |
| 1958 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1959 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1960 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1961 | .ignore_suspend = 1, |
| 1962 | .ignore_pmdown_time = 1, |
| 1963 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1964 | .codec_name = "snd-soc-dummy", |
| 1965 | }, |
| 1966 | {/* hw:x,19 */ |
| 1967 | .name = "VoiceMMode2", |
| 1968 | .stream_name = "VoiceMMode2", |
| 1969 | .cpu_dai_name = "VoiceMMode2", |
| 1970 | .platform_name = "msm-pcm-voice", |
| 1971 | .dynamic = 1, |
| 1972 | .dpcm_capture = 1, |
| 1973 | .dpcm_playback = 1, |
| 1974 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1975 | SND_SOC_DPCM_TRIGGER_POST}, |
| 1976 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1977 | .ignore_suspend = 1, |
| 1978 | .ignore_pmdown_time = 1, |
| 1979 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1980 | .codec_name = "snd-soc-dummy", |
| 1981 | .be_id = MSM_FRONTEND_DAI_VOICEMMODE2, |
| 1982 | }, |
| 1983 | {/* hw:x,20 */ |
| 1984 | .name = "Listen 2 Audio Service", |
| 1985 | .stream_name = "Listen 2 Audio Service", |
| 1986 | .cpu_dai_name = "LSM2", |
| 1987 | .platform_name = "msm-lsm-client", |
| 1988 | .dynamic = 1, |
| 1989 | .dpcm_capture = 1, |
| 1990 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 1991 | SND_SOC_DPCM_TRIGGER_POST }, |
| 1992 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 1993 | .ignore_suspend = 1, |
| 1994 | .ignore_pmdown_time = 1, |
| 1995 | .codec_dai_name = "snd-soc-dummy-dai", |
| 1996 | .codec_name = "snd-soc-dummy", |
| 1997 | .be_id = MSM_FRONTEND_DAI_LSM2, |
| 1998 | }, |
| 1999 | {/* hw:x,21 */ |
| 2000 | .name = "Listen 3 Audio Service", |
| 2001 | .stream_name = "Listen 3 Audio Service", |
| 2002 | .cpu_dai_name = "LSM3", |
| 2003 | .platform_name = "msm-lsm-client", |
| 2004 | .dynamic = 1, |
| 2005 | .dpcm_capture = 1, |
| 2006 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2007 | SND_SOC_DPCM_TRIGGER_POST }, |
| 2008 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2009 | .ignore_suspend = 1, |
| 2010 | .ignore_pmdown_time = 1, |
| 2011 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2012 | .codec_name = "snd-soc-dummy", |
| 2013 | .be_id = MSM_FRONTEND_DAI_LSM3, |
| 2014 | }, |
| 2015 | {/* hw:x,22 */ |
| 2016 | .name = "Listen 4 Audio Service", |
| 2017 | .stream_name = "Listen 4 Audio Service", |
| 2018 | .cpu_dai_name = "LSM4", |
| 2019 | .platform_name = "msm-lsm-client", |
| 2020 | .dynamic = 1, |
| 2021 | .dpcm_capture = 1, |
| 2022 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2023 | SND_SOC_DPCM_TRIGGER_POST }, |
| 2024 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2025 | .ignore_suspend = 1, |
| 2026 | .ignore_pmdown_time = 1, |
| 2027 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2028 | .codec_name = "snd-soc-dummy", |
| 2029 | .be_id = MSM_FRONTEND_DAI_LSM4, |
| 2030 | }, |
| 2031 | {/* hw:x,23 */ |
| 2032 | .name = "Listen 5 Audio Service", |
| 2033 | .stream_name = "Listen 5 Audio Service", |
| 2034 | .cpu_dai_name = "LSM5", |
| 2035 | .platform_name = "msm-lsm-client", |
| 2036 | .dynamic = 1, |
| 2037 | .dpcm_capture = 1, |
| 2038 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2039 | SND_SOC_DPCM_TRIGGER_POST }, |
| 2040 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2041 | .ignore_suspend = 1, |
| 2042 | .ignore_pmdown_time = 1, |
| 2043 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2044 | .codec_name = "snd-soc-dummy", |
| 2045 | .be_id = MSM_FRONTEND_DAI_LSM5, |
| 2046 | }, |
| 2047 | {/* hw:x,24 */ |
| 2048 | .name = "Listen 6 Audio Service", |
| 2049 | .stream_name = "Listen 6 Audio Service", |
| 2050 | .cpu_dai_name = "LSM6", |
| 2051 | .platform_name = "msm-lsm-client", |
| 2052 | .dynamic = 1, |
| 2053 | .dpcm_capture = 1, |
| 2054 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2055 | SND_SOC_DPCM_TRIGGER_POST }, |
| 2056 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2057 | .ignore_suspend = 1, |
| 2058 | .ignore_pmdown_time = 1, |
| 2059 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2060 | .codec_name = "snd-soc-dummy", |
| 2061 | .be_id = MSM_FRONTEND_DAI_LSM6 |
| 2062 | }, |
| 2063 | {/* hw:x,25 */ |
| 2064 | .name = "Listen 7 Audio Service", |
| 2065 | .stream_name = "Listen 7 Audio Service", |
| 2066 | .cpu_dai_name = "LSM7", |
| 2067 | .platform_name = "msm-lsm-client", |
| 2068 | .dynamic = 1, |
| 2069 | .dpcm_capture = 1, |
| 2070 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2071 | SND_SOC_DPCM_TRIGGER_POST }, |
| 2072 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2073 | .ignore_suspend = 1, |
| 2074 | .ignore_pmdown_time = 1, |
| 2075 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2076 | .codec_name = "snd-soc-dummy", |
| 2077 | .be_id = MSM_FRONTEND_DAI_LSM7, |
| 2078 | }, |
| 2079 | {/* hw:x,26 */ |
| 2080 | .name = "Listen 8 Audio Service", |
| 2081 | .stream_name = "Listen 8 Audio Service", |
| 2082 | .cpu_dai_name = "LSM8", |
| 2083 | .platform_name = "msm-lsm-client", |
| 2084 | .dynamic = 1, |
| 2085 | .dpcm_capture = 1, |
| 2086 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2087 | SND_SOC_DPCM_TRIGGER_POST }, |
| 2088 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2089 | .ignore_suspend = 1, |
| 2090 | .ignore_pmdown_time = 1, |
| 2091 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2092 | .codec_name = "snd-soc-dummy", |
| 2093 | .be_id = MSM_FRONTEND_DAI_LSM8, |
| 2094 | }, |
| 2095 | {/* hw:x,27 */ |
| 2096 | .name = MSM_DAILINK_NAME(Media9), |
| 2097 | .stream_name = "MultiMedia9", |
| 2098 | .cpu_dai_name = "MultiMedia9", |
| 2099 | .platform_name = "msm-pcm-dsp.0", |
| 2100 | .dynamic = 1, |
| 2101 | .dpcm_capture = 1, |
| 2102 | .dpcm_playback = 1, |
| 2103 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2104 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2105 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2106 | .codec_name = "snd-soc-dummy", |
| 2107 | .ignore_suspend = 1, |
| 2108 | .ignore_pmdown_time = 1, |
| 2109 | /* this dai link has playback support */ |
| 2110 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA9, |
| 2111 | }, |
| 2112 | {/* hw:x,28 */ |
| 2113 | .name = MSM_DAILINK_NAME(Compress4), |
| 2114 | .stream_name = "Compress4", |
| 2115 | .cpu_dai_name = "MultiMedia11", |
| 2116 | .platform_name = "msm-compress-dsp", |
| 2117 | .dynamic = 1, |
| 2118 | .dpcm_capture = 1, |
| 2119 | .dpcm_playback = 1, |
| 2120 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2121 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2122 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2123 | .codec_name = "snd-soc-dummy", |
| 2124 | .ignore_suspend = 1, |
| 2125 | .ignore_pmdown_time = 1, |
| 2126 | /* this dai link has playback support */ |
| 2127 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA11, |
| 2128 | }, |
| 2129 | {/* hw:x,29 */ |
| 2130 | .name = MSM_DAILINK_NAME(Compress5), |
| 2131 | .stream_name = "Compress5", |
| 2132 | .cpu_dai_name = "MultiMedia12", |
| 2133 | .platform_name = "msm-compress-dsp", |
| 2134 | .dynamic = 1, |
| 2135 | .dpcm_capture = 1, |
| 2136 | .dpcm_playback = 1, |
| 2137 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2138 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2139 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2140 | .codec_name = "snd-soc-dummy", |
| 2141 | .ignore_suspend = 1, |
| 2142 | .ignore_pmdown_time = 1, |
| 2143 | /* this dai link has playback support */ |
| 2144 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA12, |
| 2145 | }, |
| 2146 | {/* hw:x,30 */ |
| 2147 | .name = MSM_DAILINK_NAME(Compress6), |
| 2148 | .stream_name = "Compress6", |
| 2149 | .cpu_dai_name = "MultiMedia13", |
| 2150 | .platform_name = "msm-compress-dsp", |
| 2151 | .dynamic = 1, |
| 2152 | .dpcm_capture = 1, |
| 2153 | .dpcm_playback = 1, |
| 2154 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2155 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2156 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2157 | .codec_name = "snd-soc-dummy", |
| 2158 | .ignore_suspend = 1, |
| 2159 | .ignore_pmdown_time = 1, |
| 2160 | /* this dai link has playback support */ |
| 2161 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA13, |
| 2162 | }, |
| 2163 | {/* hw:x,31 */ |
| 2164 | .name = MSM_DAILINK_NAME(Compress7), |
| 2165 | .stream_name = "Compress7", |
| 2166 | .cpu_dai_name = "MultiMedia14", |
| 2167 | .platform_name = "msm-compress-dsp", |
| 2168 | .dynamic = 1, |
| 2169 | .dpcm_capture = 1, |
| 2170 | .dpcm_playback = 1, |
| 2171 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2172 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2173 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2174 | .codec_name = "snd-soc-dummy", |
| 2175 | .ignore_suspend = 1, |
| 2176 | .ignore_pmdown_time = 1, |
| 2177 | /* this dai link has playback support */ |
| 2178 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA14, |
| 2179 | }, |
| 2180 | {/* hw:x,32 */ |
| 2181 | .name = MSM_DAILINK_NAME(Compress8), |
| 2182 | .stream_name = "Compress8", |
| 2183 | .cpu_dai_name = "MultiMedia15", |
| 2184 | .platform_name = "msm-compress-dsp", |
| 2185 | .dynamic = 1, |
| 2186 | .dpcm_capture = 1, |
| 2187 | .dpcm_playback = 1, |
| 2188 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2189 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2190 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2191 | .codec_name = "snd-soc-dummy", |
| 2192 | .ignore_suspend = 1, |
| 2193 | .ignore_pmdown_time = 1, |
| 2194 | /* this dai link has playback support */ |
| 2195 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA15, |
| 2196 | }, |
| 2197 | {/* hw:x,33 */ |
| 2198 | .name = MSM_DAILINK_NAME(Compress9), |
| 2199 | .stream_name = "Compress9", |
| 2200 | .cpu_dai_name = "MultiMedia16", |
| 2201 | .platform_name = "msm-compress-dsp", |
| 2202 | .dynamic = 1, |
| 2203 | .dpcm_capture = 1, |
| 2204 | .dpcm_playback = 1, |
| 2205 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2206 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2207 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2208 | .codec_name = "snd-soc-dummy", |
| 2209 | .ignore_suspend = 1, |
| 2210 | .ignore_pmdown_time = 1, |
| 2211 | /* this dai link has playback support */ |
| 2212 | .be_id = MSM_FRONTEND_DAI_MULTIMEDIA16, |
| 2213 | }, |
| 2214 | {/* hw:x,34 */ |
| 2215 | .name = "SLIMBUS_8 Hostless", |
| 2216 | .stream_name = "SLIMBUS8_HOSTLESS Capture", |
| 2217 | .cpu_dai_name = "SLIMBUS8_HOSTLESS", |
| 2218 | .platform_name = "msm-pcm-hostless", |
| 2219 | .dynamic = 1, |
| 2220 | .dpcm_capture = 1, |
| 2221 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2222 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2223 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2224 | .ignore_suspend = 1, |
| 2225 | .ignore_pmdown_time = 1, |
| 2226 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2227 | .codec_name = "snd-soc-dummy", |
| 2228 | }, |
| 2229 | {/* hw:x,35 */ |
| 2230 | .name = LPASS_BE_INT5_MI2S_TX, |
Rohit Kumar | 7731112 | 2016-12-08 12:22:08 +0530 | [diff] [blame] | 2231 | .stream_name = "INT5 MI2S Capture", |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2232 | .cpu_dai_name = "msm-dai-q6-mi2s.12", |
| 2233 | .platform_name = "msm-pcm-hostless", |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 2234 | .codec_name = "msm_sdw_codec", |
| 2235 | .codec_dai_name = "msm_sdw_vifeedback", |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2236 | .be_id = MSM_BACKEND_DAI_INT5_MI2S_TX, |
| 2237 | .be_hw_params_fixup = int_mi2s_be_hw_params_fixup, |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 2238 | .ops = &msm_sdw_mi2s_be_ops, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2239 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2240 | .ignore_suspend = 1, |
| 2241 | .dpcm_capture = 1, |
| 2242 | .ignore_pmdown_time = 1, |
| 2243 | }, |
| 2244 | {/* hw:x,36 */ |
| 2245 | .name = "Primary MI2S_RX Hostless", |
| 2246 | .stream_name = "Primary MI2S_RX Hostless", |
| 2247 | .cpu_dai_name = "PRI_MI2S_RX_HOSTLESS", |
| 2248 | .platform_name = "msm-pcm-hostless", |
| 2249 | .dynamic = 1, |
| 2250 | .dpcm_playback = 1, |
| 2251 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2252 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2253 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2254 | .ignore_suspend = 1, |
| 2255 | /* this dailink has playback support */ |
| 2256 | .ignore_pmdown_time = 1, |
| 2257 | /* This dainlink has MI2S support */ |
| 2258 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2259 | .codec_name = "snd-soc-dummy", |
| 2260 | }, |
| 2261 | {/* hw:x,37 */ |
| 2262 | .name = "Secondary MI2S_RX Hostless", |
| 2263 | .stream_name = "Secondary MI2S_RX Hostless", |
| 2264 | .cpu_dai_name = "SEC_MI2S_RX_HOSTLESS", |
| 2265 | .platform_name = "msm-pcm-hostless", |
| 2266 | .dynamic = 1, |
| 2267 | .dpcm_playback = 1, |
| 2268 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2269 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2270 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2271 | .ignore_suspend = 1, |
| 2272 | /* this dailink has playback support */ |
| 2273 | .ignore_pmdown_time = 1, |
| 2274 | /* This dainlink has MI2S support */ |
| 2275 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2276 | .codec_name = "snd-soc-dummy", |
| 2277 | }, |
| 2278 | {/* hw:x,38 */ |
| 2279 | .name = "Tertiary MI2S_RX Hostless", |
| 2280 | .stream_name = "Tertiary MI2S_RX Hostless", |
| 2281 | .cpu_dai_name = "TERT_MI2S_RX_HOSTLESS", |
| 2282 | .platform_name = "msm-pcm-hostless", |
| 2283 | .dynamic = 1, |
| 2284 | .dpcm_playback = 1, |
| 2285 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2286 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2287 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2288 | .ignore_suspend = 1, |
| 2289 | /* this dailink has playback support */ |
| 2290 | .ignore_pmdown_time = 1, |
| 2291 | /* This dainlink has MI2S support */ |
| 2292 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2293 | .codec_name = "snd-soc-dummy", |
| 2294 | }, |
| 2295 | {/* hw:x,39 */ |
| 2296 | .name = "INT0 MI2S_RX Hostless", |
| 2297 | .stream_name = "INT0 MI2S_RX Hostless", |
| 2298 | .cpu_dai_name = "INT0_MI2S_RX_HOSTLESS", |
| 2299 | .platform_name = "msm-pcm-hostless", |
| 2300 | .dynamic = 1, |
| 2301 | .dpcm_playback = 1, |
| 2302 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, |
| 2303 | SND_SOC_DPCM_TRIGGER_POST}, |
| 2304 | .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, |
| 2305 | .ignore_suspend = 1, |
| 2306 | /* this dailink has playback support */ |
| 2307 | .ignore_pmdown_time = 1, |
| 2308 | /* This dainlink has MI2S support */ |
| 2309 | .codec_dai_name = "snd-soc-dummy-dai", |
| 2310 | .codec_name = "snd-soc-dummy", |
| 2311 | }, |
| 2312 | /* Backend I2S DAI Links */ |
| 2313 | { |
| 2314 | .name = LPASS_BE_INT0_MI2S_RX, |
| 2315 | .stream_name = "INT0 MI2S Playback", |
| 2316 | .cpu_dai_name = "msm-dai-q6-mi2s.7", |
| 2317 | .platform_name = "msm-pcm-routing", |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 2318 | .codecs = dlc_rx1, |
| 2319 | .num_codecs = CODECS_MAX, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2320 | .no_pcm = 1, |
| 2321 | .dpcm_playback = 1, |
| 2322 | .async_ops = ASYNC_DPCM_SND_SOC_PREPARE | |
| 2323 | ASYNC_DPCM_SND_SOC_HW_PARAMS, |
| 2324 | .be_id = MSM_BACKEND_DAI_INT0_MI2S_RX, |
| 2325 | .init = &msm_audrx_init, |
| 2326 | .be_hw_params_fixup = int_mi2s_be_hw_params_fixup, |
| 2327 | .ops = &msm_int_mi2s_be_ops, |
| 2328 | .ignore_suspend = 1, |
| 2329 | }, |
| 2330 | { |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 2331 | .name = LPASS_BE_INT3_MI2S_TX, |
| 2332 | .stream_name = "INT3 MI2S Capture", |
| 2333 | .cpu_dai_name = "msm-dai-q6-mi2s.10", |
| 2334 | .platform_name = "msm-pcm-routing", |
| 2335 | .codecs = dlc_tx1, |
| 2336 | .num_codecs = CODECS_MAX, |
| 2337 | .no_pcm = 1, |
| 2338 | .dpcm_capture = 1, |
| 2339 | .async_ops = ASYNC_DPCM_SND_SOC_PREPARE | |
| 2340 | ASYNC_DPCM_SND_SOC_HW_PARAMS, |
| 2341 | .be_id = MSM_BACKEND_DAI_INT3_MI2S_TX, |
| 2342 | .be_hw_params_fixup = msm_be_hw_params_fixup, |
| 2343 | .ops = &msm_int_mi2s_be_ops, |
| 2344 | .ignore_suspend = 1, |
| 2345 | }, |
| 2346 | { |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2347 | .name = LPASS_BE_INT4_MI2S_RX, |
| 2348 | .stream_name = "INT4 MI2S Playback", |
| 2349 | .cpu_dai_name = "msm-dai-q6-mi2s.11", |
| 2350 | .platform_name = "msm-pcm-routing", |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 2351 | .codec_name = "msm_sdw_codec", |
| 2352 | .codec_dai_name = "msm_sdw_i2s_rx1", |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2353 | .no_pcm = 1, |
| 2354 | .dpcm_playback = 1, |
| 2355 | .be_id = MSM_BACKEND_DAI_INT4_MI2S_RX, |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 2356 | .init = &msm_sdw_audrx_init, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2357 | .be_hw_params_fixup = int_mi2s_be_hw_params_fixup, |
Laxminath Kasam | 2d20bc9 | 2016-11-24 17:31:45 +0530 | [diff] [blame] | 2358 | .ops = &msm_sdw_mi2s_be_ops, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2359 | .ignore_suspend = 1, |
| 2360 | }, |
| 2361 | { |
| 2362 | .name = LPASS_BE_INT2_MI2S_TX, |
| 2363 | .stream_name = "INT2 MI2S Capture", |
| 2364 | .cpu_dai_name = "msm-dai-q6-mi2s.9", |
| 2365 | .platform_name = "msm-pcm-routing", |
Laxminath Kasam | e68e94f | 2016-12-09 12:08:00 +0530 | [diff] [blame] | 2366 | .codecs = dlc_tx2, |
| 2367 | .num_codecs = CODECS_MAX, |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2368 | .no_pcm = 1, |
| 2369 | .dpcm_capture = 1, |
| 2370 | .async_ops = ASYNC_DPCM_SND_SOC_PREPARE | |
| 2371 | ASYNC_DPCM_SND_SOC_HW_PARAMS, |
| 2372 | .be_id = MSM_BACKEND_DAI_INT2_MI2S_TX, |
| 2373 | .be_hw_params_fixup = int_mi2s_be_hw_params_fixup, |
| 2374 | .ops = &msm_int_mi2s_be_ops, |
| 2375 | .ignore_suspend = 1, |
| 2376 | }, |
| 2377 | { |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2378 | .name = LPASS_BE_AFE_PCM_RX, |
| 2379 | .stream_name = "AFE Playback", |
| 2380 | .cpu_dai_name = "msm-dai-q6-dev.224", |
| 2381 | .platform_name = "msm-pcm-routing", |
| 2382 | .codec_name = "msm-stub-codec.1", |
| 2383 | .codec_dai_name = "msm-stub-rx", |
| 2384 | .no_pcm = 1, |
| 2385 | .dpcm_playback = 1, |
| 2386 | .be_id = MSM_BACKEND_DAI_AFE_PCM_RX, |
| 2387 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2388 | /* this dainlink has playback support */ |
| 2389 | .ignore_pmdown_time = 1, |
| 2390 | .ignore_suspend = 1, |
| 2391 | }, |
| 2392 | { |
| 2393 | .name = LPASS_BE_AFE_PCM_TX, |
| 2394 | .stream_name = "AFE Capture", |
| 2395 | .cpu_dai_name = "msm-dai-q6-dev.225", |
| 2396 | .platform_name = "msm-pcm-routing", |
| 2397 | .codec_name = "msm-stub-codec.1", |
| 2398 | .codec_dai_name = "msm-stub-tx", |
| 2399 | .no_pcm = 1, |
| 2400 | .dpcm_capture = 1, |
| 2401 | .be_id = MSM_BACKEND_DAI_AFE_PCM_TX, |
| 2402 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2403 | .ignore_suspend = 1, |
| 2404 | }, |
| 2405 | /* Incall Record Uplink BACK END DAI Link */ |
| 2406 | { |
| 2407 | .name = LPASS_BE_INCALL_RECORD_TX, |
| 2408 | .stream_name = "Voice Uplink Capture", |
| 2409 | .cpu_dai_name = "msm-dai-q6-dev.32772", |
| 2410 | .platform_name = "msm-pcm-routing", |
| 2411 | .codec_name = "msm-stub-codec.1", |
| 2412 | .codec_dai_name = "msm-stub-tx", |
| 2413 | .no_pcm = 1, |
| 2414 | .dpcm_capture = 1, |
| 2415 | .be_id = MSM_BACKEND_DAI_INCALL_RECORD_TX, |
| 2416 | .be_hw_params_fixup = msm_be_hw_params_fixup, |
| 2417 | .ignore_suspend = 1, |
| 2418 | }, |
| 2419 | /* Incall Record Downlink BACK END DAI Link */ |
| 2420 | { |
| 2421 | .name = LPASS_BE_INCALL_RECORD_RX, |
| 2422 | .stream_name = "Voice Downlink Capture", |
| 2423 | .cpu_dai_name = "msm-dai-q6-dev.32771", |
| 2424 | .platform_name = "msm-pcm-routing", |
| 2425 | .codec_name = "msm-stub-codec.1", |
| 2426 | .codec_dai_name = "msm-stub-tx", |
| 2427 | .no_pcm = 1, |
| 2428 | .dpcm_capture = 1, |
| 2429 | .be_id = MSM_BACKEND_DAI_INCALL_RECORD_RX, |
| 2430 | .be_hw_params_fixup = msm_be_hw_params_fixup, |
| 2431 | .ignore_suspend = 1, |
| 2432 | }, |
| 2433 | /* Incall Music BACK END DAI Link */ |
| 2434 | { |
| 2435 | .name = LPASS_BE_VOICE_PLAYBACK_TX, |
| 2436 | .stream_name = "Voice Farend Playback", |
| 2437 | .cpu_dai_name = "msm-dai-q6-dev.32773", |
| 2438 | .platform_name = "msm-pcm-routing", |
| 2439 | .codec_name = "msm-stub-codec.1", |
| 2440 | .codec_dai_name = "msm-stub-rx", |
| 2441 | .no_pcm = 1, |
| 2442 | .dpcm_playback = 1, |
| 2443 | .be_id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX, |
| 2444 | .be_hw_params_fixup = msm_be_hw_params_fixup, |
| 2445 | .ignore_suspend = 1, |
| 2446 | }, |
| 2447 | /* Incall Music 2 BACK END DAI Link */ |
| 2448 | { |
| 2449 | .name = LPASS_BE_VOICE2_PLAYBACK_TX, |
| 2450 | .stream_name = "Voice2 Farend Playback", |
| 2451 | .cpu_dai_name = "msm-dai-q6-dev.32770", |
| 2452 | .platform_name = "msm-pcm-routing", |
| 2453 | .codec_name = "msm-stub-codec.1", |
| 2454 | .codec_dai_name = "msm-stub-rx", |
| 2455 | .no_pcm = 1, |
| 2456 | .dpcm_playback = 1, |
| 2457 | .be_id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX, |
| 2458 | .be_hw_params_fixup = msm_be_hw_params_fixup, |
| 2459 | .ignore_suspend = 1, |
| 2460 | }, |
| 2461 | { |
| 2462 | .name = LPASS_BE_USB_AUDIO_RX, |
| 2463 | .stream_name = "USB Audio Playback", |
| 2464 | .cpu_dai_name = "msm-dai-q6-dev.28672", |
| 2465 | .platform_name = "msm-pcm-routing", |
| 2466 | .codec_name = "msm-stub-codec.1", |
| 2467 | .codec_dai_name = "msm-stub-rx", |
| 2468 | .no_pcm = 1, |
| 2469 | .dpcm_playback = 1, |
| 2470 | .be_id = MSM_BACKEND_DAI_USB_RX, |
| 2471 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2472 | .ignore_pmdown_time = 1, |
| 2473 | .ignore_suspend = 1, |
| 2474 | }, |
| 2475 | { |
| 2476 | .name = LPASS_BE_USB_AUDIO_TX, |
| 2477 | .stream_name = "USB Audio Capture", |
| 2478 | .cpu_dai_name = "msm-dai-q6-dev.28673", |
| 2479 | .platform_name = "msm-pcm-routing", |
| 2480 | .codec_name = "msm-stub-codec.1", |
| 2481 | .codec_dai_name = "msm-stub-tx", |
| 2482 | .no_pcm = 1, |
| 2483 | .dpcm_capture = 1, |
| 2484 | .be_id = MSM_BACKEND_DAI_USB_TX, |
| 2485 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2486 | .ignore_suspend = 1, |
| 2487 | }, |
| 2488 | { |
| 2489 | .name = LPASS_BE_PRI_TDM_RX_0, |
| 2490 | .stream_name = "Primary TDM0 Playback", |
| 2491 | .cpu_dai_name = "msm-dai-q6-tdm.36864", |
| 2492 | .platform_name = "msm-pcm-routing", |
| 2493 | .codec_name = "msm-stub-codec.1", |
| 2494 | .codec_dai_name = "msm-stub-rx", |
| 2495 | .no_pcm = 1, |
| 2496 | .dpcm_playback = 1, |
| 2497 | .be_id = MSM_BACKEND_DAI_PRI_TDM_RX_0, |
| 2498 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2499 | .ops = &msm_tdm_be_ops, |
| 2500 | .ignore_suspend = 1, |
| 2501 | }, |
| 2502 | { |
| 2503 | .name = LPASS_BE_PRI_TDM_TX_0, |
| 2504 | .stream_name = "Primary TDM0 Capture", |
| 2505 | .cpu_dai_name = "msm-dai-q6-tdm.36865", |
| 2506 | .platform_name = "msm-pcm-routing", |
| 2507 | .codec_name = "msm-stub-codec.1", |
| 2508 | .codec_dai_name = "msm-stub-tx", |
| 2509 | .no_pcm = 1, |
| 2510 | .dpcm_capture = 1, |
| 2511 | .be_id = MSM_BACKEND_DAI_PRI_TDM_TX_0, |
| 2512 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2513 | .ops = &msm_tdm_be_ops, |
| 2514 | .ignore_suspend = 1, |
| 2515 | }, |
| 2516 | { |
| 2517 | .name = LPASS_BE_SEC_TDM_RX_0, |
| 2518 | .stream_name = "Secondary TDM0 Playback", |
| 2519 | .cpu_dai_name = "msm-dai-q6-tdm.36880", |
| 2520 | .platform_name = "msm-pcm-routing", |
| 2521 | .codec_name = "msm-stub-codec.1", |
| 2522 | .codec_dai_name = "msm-stub-rx", |
| 2523 | .no_pcm = 1, |
| 2524 | .dpcm_playback = 1, |
| 2525 | .be_id = MSM_BACKEND_DAI_SEC_TDM_RX_0, |
| 2526 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2527 | .ops = &msm_tdm_be_ops, |
| 2528 | .ignore_suspend = 1, |
| 2529 | }, |
| 2530 | { |
| 2531 | .name = LPASS_BE_SEC_TDM_TX_0, |
| 2532 | .stream_name = "Secondary TDM0 Capture", |
| 2533 | .cpu_dai_name = "msm-dai-q6-tdm.36881", |
| 2534 | .platform_name = "msm-pcm-routing", |
| 2535 | .codec_name = "msm-stub-codec.1", |
| 2536 | .codec_dai_name = "msm-stub-tx", |
| 2537 | .no_pcm = 1, |
| 2538 | .dpcm_capture = 1, |
| 2539 | .be_id = MSM_BACKEND_DAI_SEC_TDM_TX_0, |
| 2540 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2541 | .ops = &msm_tdm_be_ops, |
| 2542 | .ignore_suspend = 1, |
| 2543 | }, |
| 2544 | { |
| 2545 | .name = LPASS_BE_TERT_TDM_RX_0, |
| 2546 | .stream_name = "Tertiary TDM0 Playback", |
| 2547 | .cpu_dai_name = "msm-dai-q6-tdm.36896", |
| 2548 | .platform_name = "msm-pcm-routing", |
| 2549 | .codec_name = "msm-stub-codec.1", |
| 2550 | .codec_dai_name = "msm-stub-rx", |
| 2551 | .no_pcm = 1, |
| 2552 | .dpcm_playback = 1, |
| 2553 | .be_id = MSM_BACKEND_DAI_TERT_TDM_RX_0, |
| 2554 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2555 | .ops = &msm_tdm_be_ops, |
| 2556 | .ignore_suspend = 1, |
| 2557 | }, |
| 2558 | { |
| 2559 | .name = LPASS_BE_TERT_TDM_TX_0, |
| 2560 | .stream_name = "Tertiary TDM0 Capture", |
| 2561 | .cpu_dai_name = "msm-dai-q6-tdm.36897", |
| 2562 | .platform_name = "msm-pcm-routing", |
| 2563 | .codec_name = "msm-stub-codec.1", |
| 2564 | .codec_dai_name = "msm-stub-tx", |
| 2565 | .no_pcm = 1, |
| 2566 | .dpcm_capture = 1, |
| 2567 | .be_id = MSM_BACKEND_DAI_TERT_TDM_TX_0, |
| 2568 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2569 | .ops = &msm_tdm_be_ops, |
| 2570 | .ignore_suspend = 1, |
| 2571 | }, |
| 2572 | { |
| 2573 | .name = LPASS_BE_QUAT_TDM_RX_0, |
| 2574 | .stream_name = "Quaternary TDM0 Playback", |
| 2575 | .cpu_dai_name = "msm-dai-q6-tdm.36912", |
| 2576 | .platform_name = "msm-pcm-routing", |
| 2577 | .codec_name = "msm-stub-codec.1", |
| 2578 | .codec_dai_name = "msm-stub-rx", |
| 2579 | .no_pcm = 1, |
| 2580 | .dpcm_playback = 1, |
| 2581 | .be_id = MSM_BACKEND_DAI_QUAT_TDM_RX_0, |
| 2582 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2583 | .ops = &msm_tdm_be_ops, |
| 2584 | .ignore_suspend = 1, |
| 2585 | }, |
| 2586 | { |
| 2587 | .name = LPASS_BE_QUAT_TDM_TX_0, |
| 2588 | .stream_name = "Quaternary TDM0 Capture", |
| 2589 | .cpu_dai_name = "msm-dai-q6-tdm.36913", |
| 2590 | .platform_name = "msm-pcm-routing", |
| 2591 | .codec_name = "msm-stub-codec.1", |
| 2592 | .codec_dai_name = "msm-stub-tx", |
| 2593 | .no_pcm = 1, |
| 2594 | .dpcm_capture = 1, |
| 2595 | .be_id = MSM_BACKEND_DAI_QUAT_TDM_TX_0, |
| 2596 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2597 | .ops = &msm_tdm_be_ops, |
| 2598 | .ignore_suspend = 1, |
| 2599 | }, |
| 2600 | }; |
| 2601 | |
| 2602 | static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = { |
| 2603 | { |
| 2604 | .name = LPASS_BE_PRI_MI2S_RX, |
| 2605 | .stream_name = "Primary MI2S Playback", |
| 2606 | .cpu_dai_name = "msm-dai-q6-mi2s.0", |
| 2607 | .platform_name = "msm-pcm-routing", |
| 2608 | .codec_name = "msm-stub-codec.1", |
| 2609 | .codec_dai_name = "msm-stub-rx", |
| 2610 | .no_pcm = 1, |
| 2611 | .dpcm_playback = 1, |
| 2612 | .be_id = MSM_BACKEND_DAI_PRI_MI2S_RX, |
| 2613 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2614 | .ops = &msm_mi2s_be_ops, |
| 2615 | .ignore_suspend = 1, |
| 2616 | .ignore_pmdown_time = 1, |
| 2617 | }, |
| 2618 | { |
| 2619 | .name = LPASS_BE_PRI_MI2S_TX, |
| 2620 | .stream_name = "Primary MI2S Capture", |
| 2621 | .cpu_dai_name = "msm-dai-q6-mi2s.0", |
| 2622 | .platform_name = "msm-pcm-routing", |
| 2623 | .codec_name = "msm-stub-codec.1", |
| 2624 | .codec_dai_name = "msm-stub-tx", |
| 2625 | .no_pcm = 1, |
| 2626 | .dpcm_capture = 1, |
| 2627 | .be_id = MSM_BACKEND_DAI_PRI_MI2S_TX, |
| 2628 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2629 | .ops = &msm_mi2s_be_ops, |
| 2630 | .ignore_suspend = 1, |
| 2631 | }, |
| 2632 | { |
| 2633 | .name = LPASS_BE_SEC_MI2S_RX, |
| 2634 | .stream_name = "Secondary MI2S Playback", |
| 2635 | .cpu_dai_name = "msm-dai-q6-mi2s.1", |
| 2636 | .platform_name = "msm-pcm-routing", |
| 2637 | .codec_name = "msm-stub-codec.1", |
| 2638 | .codec_dai_name = "msm-stub-rx", |
| 2639 | .no_pcm = 1, |
| 2640 | .dpcm_playback = 1, |
| 2641 | .be_id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX, |
| 2642 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2643 | .ops = &msm_mi2s_be_ops, |
| 2644 | .ignore_suspend = 1, |
| 2645 | .ignore_pmdown_time = 1, |
| 2646 | }, |
| 2647 | { |
| 2648 | .name = LPASS_BE_SEC_MI2S_TX, |
| 2649 | .stream_name = "Secondary MI2S Capture", |
| 2650 | .cpu_dai_name = "msm-dai-q6-mi2s.1", |
| 2651 | .platform_name = "msm-pcm-routing", |
| 2652 | .codec_name = "msm-stub-codec.1", |
| 2653 | .codec_dai_name = "msm-stub-tx", |
| 2654 | .no_pcm = 1, |
| 2655 | .dpcm_capture = 1, |
| 2656 | .be_id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX, |
| 2657 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2658 | .ops = &msm_mi2s_be_ops, |
| 2659 | .ignore_suspend = 1, |
| 2660 | }, |
| 2661 | { |
| 2662 | .name = LPASS_BE_TERT_MI2S_RX, |
| 2663 | .stream_name = "Tertiary MI2S Playback", |
| 2664 | .cpu_dai_name = "msm-dai-q6-mi2s.2", |
| 2665 | .platform_name = "msm-pcm-routing", |
| 2666 | .codec_name = "msm-stub-codec.1", |
| 2667 | .codec_dai_name = "msm-stub-rx", |
| 2668 | .no_pcm = 1, |
| 2669 | .dpcm_playback = 1, |
| 2670 | .be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX, |
| 2671 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2672 | .ops = &msm_mi2s_be_ops, |
| 2673 | .ignore_suspend = 1, |
| 2674 | .ignore_pmdown_time = 1, |
| 2675 | }, |
| 2676 | { |
| 2677 | .name = LPASS_BE_TERT_MI2S_TX, |
| 2678 | .stream_name = "Tertiary MI2S Capture", |
| 2679 | .cpu_dai_name = "msm-dai-q6-mi2s.2", |
| 2680 | .platform_name = "msm-pcm-routing", |
| 2681 | .codec_name = "msm-stub-codec.1", |
| 2682 | .codec_dai_name = "msm-stub-tx", |
| 2683 | .no_pcm = 1, |
| 2684 | .dpcm_capture = 1, |
| 2685 | .be_id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX, |
| 2686 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2687 | .ops = &msm_mi2s_be_ops, |
| 2688 | .ignore_suspend = 1, |
| 2689 | }, |
| 2690 | { |
| 2691 | .name = LPASS_BE_QUAT_MI2S_RX, |
| 2692 | .stream_name = "Quaternary MI2S Playback", |
| 2693 | .cpu_dai_name = "msm-dai-q6-mi2s.3", |
| 2694 | .platform_name = "msm-pcm-routing", |
| 2695 | .codec_name = "msm-stub-codec.1", |
| 2696 | .codec_dai_name = "msm-stub-rx", |
| 2697 | .no_pcm = 1, |
| 2698 | .dpcm_playback = 1, |
| 2699 | .be_id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX, |
| 2700 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2701 | .ops = &msm_mi2s_be_ops, |
| 2702 | .ignore_suspend = 1, |
| 2703 | .ignore_pmdown_time = 1, |
| 2704 | }, |
| 2705 | { |
| 2706 | .name = LPASS_BE_QUAT_MI2S_TX, |
| 2707 | .stream_name = "Quaternary MI2S Capture", |
| 2708 | .cpu_dai_name = "msm-dai-q6-mi2s.3", |
| 2709 | .platform_name = "msm-pcm-routing", |
| 2710 | .codec_name = "msm-stub-codec.1", |
| 2711 | .codec_dai_name = "msm-stub-tx", |
| 2712 | .no_pcm = 1, |
| 2713 | .dpcm_capture = 1, |
| 2714 | .be_id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX, |
| 2715 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2716 | .ops = &msm_mi2s_be_ops, |
| 2717 | .ignore_suspend = 1, |
| 2718 | }, |
| 2719 | }; |
| 2720 | |
| 2721 | static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = { |
| 2722 | /* Primary AUX PCM Backend DAI Links */ |
| 2723 | { |
| 2724 | .name = LPASS_BE_AUXPCM_RX, |
| 2725 | .stream_name = "AUX PCM Playback", |
| 2726 | .cpu_dai_name = "msm-dai-q6-auxpcm.1", |
| 2727 | .platform_name = "msm-pcm-routing", |
| 2728 | .codec_name = "msm-stub-codec.1", |
| 2729 | .codec_dai_name = "msm-stub-rx", |
| 2730 | .no_pcm = 1, |
| 2731 | .dpcm_playback = 1, |
| 2732 | .be_id = MSM_BACKEND_DAI_AUXPCM_RX, |
| 2733 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2734 | .ignore_pmdown_time = 1, |
| 2735 | .ignore_suspend = 1, |
| 2736 | .ops = &msm_aux_pcm_be_ops, |
| 2737 | }, |
| 2738 | { |
| 2739 | .name = LPASS_BE_AUXPCM_TX, |
| 2740 | .stream_name = "AUX PCM Capture", |
| 2741 | .cpu_dai_name = "msm-dai-q6-auxpcm.1", |
| 2742 | .platform_name = "msm-pcm-routing", |
| 2743 | .codec_name = "msm-stub-codec.1", |
| 2744 | .codec_dai_name = "msm-stub-tx", |
| 2745 | .no_pcm = 1, |
| 2746 | .dpcm_capture = 1, |
| 2747 | .be_id = MSM_BACKEND_DAI_AUXPCM_TX, |
| 2748 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2749 | .ignore_pmdown_time = 1, |
| 2750 | .ignore_suspend = 1, |
| 2751 | .ops = &msm_aux_pcm_be_ops, |
| 2752 | }, |
| 2753 | /* Secondary AUX PCM Backend DAI Links */ |
| 2754 | { |
| 2755 | .name = LPASS_BE_SEC_AUXPCM_RX, |
| 2756 | .stream_name = "Sec AUX PCM Playback", |
| 2757 | .cpu_dai_name = "msm-dai-q6-auxpcm.2", |
| 2758 | .platform_name = "msm-pcm-routing", |
| 2759 | .codec_name = "msm-stub-codec.1", |
| 2760 | .codec_dai_name = "msm-stub-rx", |
| 2761 | .no_pcm = 1, |
| 2762 | .dpcm_playback = 1, |
| 2763 | .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_RX, |
| 2764 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2765 | .ignore_pmdown_time = 1, |
| 2766 | .ignore_suspend = 1, |
| 2767 | .ops = &msm_aux_pcm_be_ops, |
| 2768 | }, |
| 2769 | { |
| 2770 | .name = LPASS_BE_SEC_AUXPCM_TX, |
| 2771 | .stream_name = "Sec AUX PCM Capture", |
| 2772 | .cpu_dai_name = "msm-dai-q6-auxpcm.2", |
| 2773 | .platform_name = "msm-pcm-routing", |
| 2774 | .codec_name = "msm-stub-codec.1", |
| 2775 | .codec_dai_name = "msm-stub-tx", |
| 2776 | .no_pcm = 1, |
| 2777 | .dpcm_capture = 1, |
| 2778 | .be_id = MSM_BACKEND_DAI_SEC_AUXPCM_TX, |
| 2779 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2780 | .ignore_suspend = 1, |
| 2781 | .ignore_pmdown_time = 1, |
| 2782 | .ops = &msm_aux_pcm_be_ops, |
| 2783 | }, |
| 2784 | /* Tertiary AUX PCM Backend DAI Links */ |
| 2785 | { |
| 2786 | .name = LPASS_BE_TERT_AUXPCM_RX, |
| 2787 | .stream_name = "Tert AUX PCM Playback", |
| 2788 | .cpu_dai_name = "msm-dai-q6-auxpcm.3", |
| 2789 | .platform_name = "msm-pcm-routing", |
| 2790 | .codec_name = "msm-stub-codec.1", |
| 2791 | .codec_dai_name = "msm-stub-rx", |
| 2792 | .no_pcm = 1, |
| 2793 | .dpcm_playback = 1, |
| 2794 | .be_id = MSM_BACKEND_DAI_TERT_AUXPCM_RX, |
| 2795 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2796 | .ignore_pmdown_time = 1, |
| 2797 | .ignore_suspend = 1, |
| 2798 | .ops = &msm_aux_pcm_be_ops, |
| 2799 | }, |
| 2800 | { |
| 2801 | .name = LPASS_BE_TERT_AUXPCM_TX, |
| 2802 | .stream_name = "Tert AUX PCM Capture", |
| 2803 | .cpu_dai_name = "msm-dai-q6-auxpcm.3", |
| 2804 | .platform_name = "msm-pcm-routing", |
| 2805 | .codec_name = "msm-stub-codec.1", |
| 2806 | .codec_dai_name = "msm-stub-tx", |
| 2807 | .no_pcm = 1, |
| 2808 | .dpcm_capture = 1, |
| 2809 | .be_id = MSM_BACKEND_DAI_TERT_AUXPCM_TX, |
| 2810 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2811 | .ignore_suspend = 1, |
| 2812 | .ignore_pmdown_time = 1, |
| 2813 | .ops = &msm_aux_pcm_be_ops, |
| 2814 | }, |
| 2815 | /* Quaternary AUX PCM Backend DAI Links */ |
| 2816 | { |
| 2817 | .name = LPASS_BE_QUAT_AUXPCM_RX, |
| 2818 | .stream_name = "Quat AUX PCM Playback", |
| 2819 | .cpu_dai_name = "msm-dai-q6-auxpcm.4", |
| 2820 | .platform_name = "msm-pcm-routing", |
| 2821 | .codec_name = "msm-stub-codec.1", |
| 2822 | .codec_dai_name = "msm-stub-rx", |
| 2823 | .no_pcm = 1, |
| 2824 | .dpcm_playback = 1, |
| 2825 | .be_id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX, |
| 2826 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2827 | .ignore_pmdown_time = 1, |
| 2828 | .ignore_suspend = 1, |
| 2829 | .ops = &msm_aux_pcm_be_ops, |
| 2830 | }, |
| 2831 | { |
| 2832 | .name = LPASS_BE_QUAT_AUXPCM_TX, |
| 2833 | .stream_name = "Quat AUX PCM Capture", |
| 2834 | .cpu_dai_name = "msm-dai-q6-auxpcm.4", |
| 2835 | .platform_name = "msm-pcm-routing", |
| 2836 | .codec_name = "msm-stub-codec.1", |
| 2837 | .codec_dai_name = "msm-stub-tx", |
| 2838 | .no_pcm = 1, |
| 2839 | .dpcm_capture = 1, |
| 2840 | .be_id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX, |
| 2841 | .be_hw_params_fixup = msm_common_be_hw_params_fixup, |
| 2842 | .ignore_suspend = 1, |
| 2843 | .ignore_pmdown_time = 1, |
| 2844 | .ops = &msm_aux_pcm_be_ops, |
| 2845 | }, |
| 2846 | }; |
| 2847 | |
| 2848 | |
| 2849 | static struct snd_soc_dai_link msm_wcn_be_dai_links[] = { |
| 2850 | { |
| 2851 | .name = LPASS_BE_SLIMBUS_7_RX, |
| 2852 | .stream_name = "Slimbus7 Playback", |
| 2853 | .cpu_dai_name = "msm-dai-q6-dev.16398", |
| 2854 | .platform_name = "msm-pcm-routing", |
| 2855 | .codec_name = "btfmslim_slave", |
| 2856 | /* BT codec driver determines capabilities based on |
| 2857 | * dai name, bt codecdai name should always contains |
| 2858 | * supported usecase information |
| 2859 | */ |
| 2860 | .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx", |
| 2861 | .no_pcm = 1, |
| 2862 | .dpcm_playback = 1, |
| 2863 | .be_id = MSM_BACKEND_DAI_SLIMBUS_7_RX, |
| 2864 | .be_hw_params_fixup = msm_btfm_be_hw_params_fixup, |
| 2865 | .ops = &msm_wcn_ops, |
| 2866 | /* dai link has playback support */ |
| 2867 | .ignore_pmdown_time = 1, |
| 2868 | .ignore_suspend = 1, |
| 2869 | }, |
| 2870 | { |
| 2871 | .name = LPASS_BE_SLIMBUS_7_TX, |
| 2872 | .stream_name = "Slimbus7 Capture", |
| 2873 | .cpu_dai_name = "msm-dai-q6-dev.16399", |
| 2874 | .platform_name = "msm-pcm-routing", |
| 2875 | .codec_name = "btfmslim_slave", |
| 2876 | .codec_dai_name = "btfm_bt_sco_slim_tx", |
| 2877 | .no_pcm = 1, |
| 2878 | .dpcm_capture = 1, |
| 2879 | .be_id = MSM_BACKEND_DAI_SLIMBUS_7_TX, |
| 2880 | .be_hw_params_fixup = msm_btfm_be_hw_params_fixup, |
| 2881 | .ops = &msm_wcn_ops, |
| 2882 | .ignore_suspend = 1, |
| 2883 | }, |
| 2884 | { |
| 2885 | .name = LPASS_BE_SLIMBUS_8_TX, |
| 2886 | .stream_name = "Slimbus8 Capture", |
| 2887 | .cpu_dai_name = "msm-dai-q6-dev.16401", |
| 2888 | .platform_name = "msm-pcm-routing", |
| 2889 | .codec_name = "btfmslim_slave", |
| 2890 | .codec_dai_name = "btfm_fm_slim_tx", |
| 2891 | .no_pcm = 1, |
| 2892 | .dpcm_capture = 1, |
| 2893 | .be_id = MSM_BACKEND_DAI_SLIMBUS_8_TX, |
| 2894 | .be_hw_params_fixup = msm_btfm_be_hw_params_fixup, |
| 2895 | .init = &msm_wcn_init, |
| 2896 | .ops = &msm_wcn_ops, |
| 2897 | .ignore_suspend = 1, |
| 2898 | }, |
| 2899 | }; |
| 2900 | |
| 2901 | static struct snd_soc_dai_link msm_int_dai_links[ |
| 2902 | ARRAY_SIZE(msm_int_dai) + |
| 2903 | ARRAY_SIZE(msm_mi2s_be_dai_links) + |
| 2904 | ARRAY_SIZE(msm_auxpcm_be_dai_links)+ |
| 2905 | ARRAY_SIZE(msm_wcn_be_dai_links)]; |
| 2906 | |
Neeraj Upadhyay | 4993442 | 2016-12-27 19:03:35 +0530 | [diff] [blame] | 2907 | static struct snd_soc_card sdm660_card = { |
| 2908 | /* snd_soc_card_sdm660 */ |
| 2909 | .name = "sdm660-snd-card", |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2910 | .dai_link = msm_int_dai, |
| 2911 | .num_links = ARRAY_SIZE(msm_int_dai), |
| 2912 | }; |
| 2913 | |
| 2914 | static void msm_disable_int_mclk0(struct work_struct *work) |
| 2915 | { |
| 2916 | struct msm_asoc_mach_data *pdata = NULL; |
| 2917 | struct delayed_work *dwork; |
| 2918 | int ret = 0; |
| 2919 | |
| 2920 | dwork = to_delayed_work(work); |
| 2921 | pdata = container_of(dwork, struct msm_asoc_mach_data, |
| 2922 | disable_int_mclk0_work); |
| 2923 | mutex_lock(&pdata->cdc_int_mclk0_mutex); |
| 2924 | pr_debug("%s: mclk_enabled %d mclk_rsc_ref %d\n", __func__, |
| 2925 | atomic_read(&pdata->int_mclk0_enabled), |
| 2926 | atomic_read(&pdata->int_mclk0_rsc_ref)); |
| 2927 | |
| 2928 | if (atomic_read(&pdata->int_mclk0_enabled) == true |
| 2929 | && atomic_read(&pdata->int_mclk0_rsc_ref) == 0) { |
| 2930 | pr_debug("Disable the mclk\n"); |
| 2931 | pdata->digital_cdc_core_clk.enable = 0; |
| 2932 | ret = afe_set_lpass_clock_v2( |
| 2933 | AFE_PORT_ID_INT0_MI2S_RX, |
| 2934 | &pdata->digital_cdc_core_clk); |
| 2935 | if (ret < 0) |
| 2936 | pr_err("%s failed to disable the CCLK\n", __func__); |
| 2937 | atomic_set(&pdata->int_mclk0_enabled, false); |
| 2938 | } |
| 2939 | mutex_unlock(&pdata->cdc_int_mclk0_mutex); |
| 2940 | } |
| 2941 | |
| 2942 | static void msm_int_dt_parse_cap_info(struct platform_device *pdev, |
| 2943 | struct msm_asoc_mach_data *pdata) |
| 2944 | { |
| 2945 | const char *ext1_cap = "qcom,msm-micbias1-ext-cap"; |
| 2946 | const char *ext2_cap = "qcom,msm-micbias2-ext-cap"; |
| 2947 | |
| 2948 | pdata->micbias1_cap_mode = |
| 2949 | (of_property_read_bool(pdev->dev.of_node, ext1_cap) ? |
| 2950 | MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP); |
| 2951 | |
| 2952 | pdata->micbias2_cap_mode = |
| 2953 | (of_property_read_bool(pdev->dev.of_node, ext2_cap) ? |
| 2954 | MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP); |
| 2955 | } |
| 2956 | |
| 2957 | static struct snd_soc_card *msm_int_populate_sndcard_dailinks( |
| 2958 | struct device *dev) |
| 2959 | { |
Neeraj Upadhyay | 4993442 | 2016-12-27 19:03:35 +0530 | [diff] [blame] | 2960 | struct snd_soc_card *card = &sdm660_card; |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 2961 | struct snd_soc_dai_link *dailink; |
| 2962 | int len1; |
| 2963 | |
| 2964 | card->name = dev_name(dev); |
| 2965 | len1 = ARRAY_SIZE(msm_int_dai); |
| 2966 | memcpy(msm_int_dai_links, msm_int_dai, sizeof(msm_int_dai)); |
| 2967 | dailink = msm_int_dai_links; |
| 2968 | if (of_property_read_bool(dev->of_node, |
| 2969 | "qcom,mi2s-audio-intf")) { |
| 2970 | memcpy(dailink + len1, |
| 2971 | msm_mi2s_be_dai_links, |
| 2972 | sizeof(msm_mi2s_be_dai_links)); |
| 2973 | len1 += ARRAY_SIZE(msm_mi2s_be_dai_links); |
| 2974 | } |
| 2975 | if (of_property_read_bool(dev->of_node, |
| 2976 | "qcom,auxpcm-audio-intf")) { |
| 2977 | memcpy(dailink + len1, |
| 2978 | msm_auxpcm_be_dai_links, |
| 2979 | sizeof(msm_auxpcm_be_dai_links)); |
| 2980 | len1 += ARRAY_SIZE(msm_auxpcm_be_dai_links); |
| 2981 | } |
| 2982 | if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) { |
| 2983 | dev_dbg(dev, "%s(): WCN BTFM support present\n", |
| 2984 | __func__); |
| 2985 | memcpy(dailink + len1, |
| 2986 | msm_wcn_be_dai_links, |
| 2987 | sizeof(msm_wcn_be_dai_links)); |
| 2988 | len1 += ARRAY_SIZE(msm_wcn_be_dai_links); |
| 2989 | } |
| 2990 | card->dai_link = dailink; |
| 2991 | card->num_links = len1; |
| 2992 | return card; |
| 2993 | } |
| 2994 | |
| 2995 | static int msm_internal_init(struct platform_device *pdev, |
| 2996 | struct msm_asoc_mach_data *pdata, |
| 2997 | struct snd_soc_card *card) |
| 2998 | { |
| 2999 | const char *type = NULL; |
| 3000 | const char *hs_micbias_type = "qcom,msm-hs-micbias-type"; |
| 3001 | int ret; |
| 3002 | |
| 3003 | ret = is_ext_spk_gpio_support(pdev, pdata); |
| 3004 | if (ret < 0) |
| 3005 | dev_dbg(&pdev->dev, |
| 3006 | "%s: doesn't support external speaker pa\n", |
| 3007 | __func__); |
| 3008 | |
| 3009 | ret = of_property_read_string(pdev->dev.of_node, |
| 3010 | hs_micbias_type, &type); |
| 3011 | if (ret) { |
| 3012 | dev_err(&pdev->dev, "%s: missing %s in dt node\n", |
| 3013 | __func__, hs_micbias_type); |
| 3014 | goto err; |
| 3015 | } |
| 3016 | if (!strcmp(type, "external")) { |
| 3017 | dev_dbg(&pdev->dev, "Headset is using external micbias\n"); |
| 3018 | mbhc_cfg_ptr->hs_ext_micbias = true; |
| 3019 | } else { |
| 3020 | dev_dbg(&pdev->dev, "Headset is using internal micbias\n"); |
| 3021 | mbhc_cfg_ptr->hs_ext_micbias = false; |
| 3022 | } |
| 3023 | |
| 3024 | /* initialize the int_mclk0 */ |
| 3025 | pdata->digital_cdc_core_clk.clk_set_minor_version = |
| 3026 | AFE_API_VERSION_I2S_CONFIG; |
| 3027 | pdata->digital_cdc_core_clk.clk_id = |
| 3028 | Q6AFE_LPASS_CLK_ID_INT_MCLK_0; |
Tanya Dixit | 73a3a26 | 2016-12-08 22:25:56 +0530 | [diff] [blame] | 3029 | pdata->digital_cdc_core_clk.clk_freq_in_hz = pdata->mclk_freq; |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 3030 | pdata->digital_cdc_core_clk.clk_attri = |
| 3031 | Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO; |
| 3032 | pdata->digital_cdc_core_clk.clk_root = |
| 3033 | Q6AFE_LPASS_CLK_ROOT_DEFAULT; |
| 3034 | pdata->digital_cdc_core_clk.enable = 1; |
| 3035 | |
| 3036 | /* Initialize loopback mode to false */ |
| 3037 | pdata->lb_mode = false; |
| 3038 | |
| 3039 | msm_int_dt_parse_cap_info(pdev, pdata); |
| 3040 | |
| 3041 | card->dev = &pdev->dev; |
| 3042 | platform_set_drvdata(pdev, card); |
| 3043 | snd_soc_card_set_drvdata(card, pdata); |
| 3044 | ret = snd_soc_of_parse_card_name(card, "qcom,model"); |
| 3045 | if (ret) |
| 3046 | goto err; |
| 3047 | /* initialize timer */ |
| 3048 | INIT_DELAYED_WORK(&pdata->disable_int_mclk0_work, |
| 3049 | msm_disable_int_mclk0); |
| 3050 | mutex_init(&pdata->cdc_int_mclk0_mutex); |
| 3051 | atomic_set(&pdata->int_mclk0_rsc_ref, 0); |
| 3052 | atomic_set(&pdata->int_mclk0_enabled, false); |
| 3053 | |
| 3054 | dev_info(&pdev->dev, "%s: default codec configured\n", __func__); |
| 3055 | |
| 3056 | return 0; |
| 3057 | err: |
| 3058 | return ret; |
| 3059 | } |
| 3060 | |
| 3061 | /** |
| 3062 | * msm_int_cdc_init - internal codec machine specific init. |
| 3063 | * |
| 3064 | * @pdev: platform device handle |
| 3065 | * @pdata: private data of machine driver |
| 3066 | * @card: sound card pointer reference |
| 3067 | * @mbhc_cfg: MBHC config reference |
| 3068 | * |
| 3069 | * Returns 0. |
| 3070 | */ |
| 3071 | int msm_int_cdc_init(struct platform_device *pdev, |
| 3072 | struct msm_asoc_mach_data *pdata, |
| 3073 | struct snd_soc_card **card, |
| 3074 | struct wcd_mbhc_config *mbhc_cfg) |
| 3075 | { |
| 3076 | mbhc_cfg_ptr = mbhc_cfg; |
| 3077 | |
| 3078 | *card = msm_int_populate_sndcard_dailinks(&pdev->dev); |
| 3079 | msm_internal_init(pdev, pdata, *card); |
| 3080 | return 0; |
| 3081 | } |
| 3082 | EXPORT_SYMBOL(msm_int_cdc_init); |