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