1 // SPDX-License-Identifier: GPL-2.0 2 // Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. 3 // Copyright (c) 2018, Linaro Limited 4 5 #include <linux/init.h> 6 #include <linux/err.h> 7 #include <linux/module.h> 8 #include <linux/platform_device.h> 9 #include <linux/of_platform.h> 10 #include <linux/bitops.h> 11 #include <linux/mutex.h> 12 #include <linux/of_device.h> 13 #include <linux/slab.h> 14 #include <sound/core.h> 15 #include <sound/soc.h> 16 #include <sound/soc-dapm.h> 17 #include <sound/pcm.h> 18 #include <sound/control.h> 19 #include <sound/asound.h> 20 #include <sound/pcm_params.h> 21 #include "q6afe.h" 22 #include "q6asm.h" 23 #include "q6adm.h" 24 #include "q6routing.h" 25 26 #define DRV_NAME "q6routing-component" 27 28 #define Q6ROUTING_RX_MIXERS(id) \ 29 SOC_SINGLE_EXT("MultiMedia1", id, \ 30 MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,\ 31 msm_routing_put_audio_mixer), \ 32 SOC_SINGLE_EXT("MultiMedia2", id, \ 33 MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_routing_get_audio_mixer,\ 34 msm_routing_put_audio_mixer), \ 35 SOC_SINGLE_EXT("MultiMedia3", id, \ 36 MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_routing_get_audio_mixer,\ 37 msm_routing_put_audio_mixer), \ 38 SOC_SINGLE_EXT("MultiMedia4", id, \ 39 MSM_FRONTEND_DAI_MULTIMEDIA4, 1, 0, msm_routing_get_audio_mixer,\ 40 msm_routing_put_audio_mixer), \ 41 SOC_SINGLE_EXT("MultiMedia5", id, \ 42 MSM_FRONTEND_DAI_MULTIMEDIA5, 1, 0, msm_routing_get_audio_mixer,\ 43 msm_routing_put_audio_mixer), \ 44 SOC_SINGLE_EXT("MultiMedia6", id, \ 45 MSM_FRONTEND_DAI_MULTIMEDIA6, 1, 0, msm_routing_get_audio_mixer,\ 46 msm_routing_put_audio_mixer), \ 47 SOC_SINGLE_EXT("MultiMedia7", id, \ 48 MSM_FRONTEND_DAI_MULTIMEDIA7, 1, 0, msm_routing_get_audio_mixer,\ 49 msm_routing_put_audio_mixer), \ 50 SOC_SINGLE_EXT("MultiMedia8", id, \ 51 MSM_FRONTEND_DAI_MULTIMEDIA8, 1, 0, msm_routing_get_audio_mixer,\ 52 msm_routing_put_audio_mixer), 53 54 #define Q6ROUTING_RX_DAPM_ROUTE(mix_name, s) \ 55 { mix_name, "MultiMedia1", "MM_DL1" }, \ 56 { mix_name, "MultiMedia2", "MM_DL2" }, \ 57 { mix_name, "MultiMedia3", "MM_DL3" }, \ 58 { mix_name, "MultiMedia4", "MM_DL4" }, \ 59 { mix_name, "MultiMedia5", "MM_DL5" }, \ 60 { mix_name, "MultiMedia6", "MM_DL6" }, \ 61 { mix_name, "MultiMedia7", "MM_DL7" }, \ 62 { mix_name, "MultiMedia8", "MM_DL8" }, \ 63 { s, NULL, mix_name } 64 65 #define Q6ROUTING_TX_DAPM_ROUTE(mix_name) \ 66 { mix_name, "PRI_MI2S_TX", "PRI_MI2S_TX" }, \ 67 { mix_name, "SEC_MI2S_TX", "SEC_MI2S_TX" }, \ 68 { mix_name, "QUAT_MI2S_TX", "QUAT_MI2S_TX" }, \ 69 { mix_name, "TERT_MI2S_TX", "TERT_MI2S_TX" }, \ 70 { mix_name, "SLIMBUS_0_TX", "SLIMBUS_0_TX" }, \ 71 { mix_name, "SLIMBUS_1_TX", "SLIMBUS_1_TX" }, \ 72 { mix_name, "SLIMBUS_2_TX", "SLIMBUS_2_TX" }, \ 73 { mix_name, "SLIMBUS_3_TX", "SLIMBUS_3_TX" }, \ 74 { mix_name, "SLIMBUS_4_TX", "SLIMBUS_4_TX" }, \ 75 { mix_name, "SLIMBUS_5_TX", "SLIMBUS_5_TX" }, \ 76 { mix_name, "SLIMBUS_6_TX", "SLIMBUS_6_TX" }, \ 77 { mix_name, "PRIMARY_TDM_TX_0", "PRIMARY_TDM_TX_0"}, \ 78 { mix_name, "PRIMARY_TDM_TX_1", "PRIMARY_TDM_TX_1"}, \ 79 { mix_name, "PRIMARY_TDM_TX_2", "PRIMARY_TDM_TX_2"}, \ 80 { mix_name, "PRIMARY_TDM_TX_3", "PRIMARY_TDM_TX_3"}, \ 81 { mix_name, "PRIMARY_TDM_TX_4", "PRIMARY_TDM_TX_4"}, \ 82 { mix_name, "PRIMARY_TDM_TX_5", "PRIMARY_TDM_TX_5"}, \ 83 { mix_name, "PRIMARY_TDM_TX_6", "PRIMARY_TDM_TX_6"}, \ 84 { mix_name, "PRIMARY_TDM_TX_7", "PRIMARY_TDM_TX_7"}, \ 85 { mix_name, "SEC_TDM_TX_0", "SEC_TDM_TX_0"}, \ 86 { mix_name, "SEC_TDM_TX_1", "SEC_TDM_TX_1"}, \ 87 { mix_name, "SEC_TDM_TX_2", "SEC_TDM_TX_2"}, \ 88 { mix_name, "SEC_TDM_TX_3", "SEC_TDM_TX_3"}, \ 89 { mix_name, "SEC_TDM_TX_4", "SEC_TDM_TX_4"}, \ 90 { mix_name, "SEC_TDM_TX_5", "SEC_TDM_TX_5"}, \ 91 { mix_name, "SEC_TDM_TX_6", "SEC_TDM_TX_6"}, \ 92 { mix_name, "SEC_TDM_TX_7", "SEC_TDM_TX_7"}, \ 93 { mix_name, "TERT_TDM_TX_0", "TERT_TDM_TX_0"}, \ 94 { mix_name, "TERT_TDM_TX_1", "TERT_TDM_TX_1"}, \ 95 { mix_name, "TERT_TDM_TX_2", "TERT_TDM_TX_2"}, \ 96 { mix_name, "TERT_TDM_TX_3", "TERT_TDM_TX_3"}, \ 97 { mix_name, "TERT_TDM_TX_4", "TERT_TDM_TX_4"}, \ 98 { mix_name, "TERT_TDM_TX_5", "TERT_TDM_TX_5"}, \ 99 { mix_name, "TERT_TDM_TX_6", "TERT_TDM_TX_6"}, \ 100 { mix_name, "TERT_TDM_TX_7", "TERT_TDM_TX_7"}, \ 101 { mix_name, "QUAT_TDM_TX_0", "QUAT_TDM_TX_0"}, \ 102 { mix_name, "QUAT_TDM_TX_1", "QUAT_TDM_TX_1"}, \ 103 { mix_name, "QUAT_TDM_TX_2", "QUAT_TDM_TX_2"}, \ 104 { mix_name, "QUAT_TDM_TX_3", "QUAT_TDM_TX_3"}, \ 105 { mix_name, "QUAT_TDM_TX_4", "QUAT_TDM_TX_4"}, \ 106 { mix_name, "QUAT_TDM_TX_5", "QUAT_TDM_TX_5"}, \ 107 { mix_name, "QUAT_TDM_TX_6", "QUAT_TDM_TX_6"}, \ 108 { mix_name, "QUAT_TDM_TX_7", "QUAT_TDM_TX_7"}, \ 109 { mix_name, "QUIN_TDM_TX_0", "QUIN_TDM_TX_0"}, \ 110 { mix_name, "QUIN_TDM_TX_1", "QUIN_TDM_TX_1"}, \ 111 { mix_name, "QUIN_TDM_TX_2", "QUIN_TDM_TX_2"}, \ 112 { mix_name, "QUIN_TDM_TX_3", "QUIN_TDM_TX_3"}, \ 113 { mix_name, "QUIN_TDM_TX_4", "QUIN_TDM_TX_4"}, \ 114 { mix_name, "QUIN_TDM_TX_5", "QUIN_TDM_TX_5"}, \ 115 { mix_name, "QUIN_TDM_TX_6", "QUIN_TDM_TX_6"}, \ 116 { mix_name, "QUIN_TDM_TX_7", "QUIN_TDM_TX_7"} 117 118 #define Q6ROUTING_TX_MIXERS(id) \ 119 SOC_SINGLE_EXT("PRI_MI2S_TX", PRIMARY_MI2S_TX, \ 120 id, 1, 0, msm_routing_get_audio_mixer, \ 121 msm_routing_put_audio_mixer), \ 122 SOC_SINGLE_EXT("SEC_MI2S_TX", SECONDARY_MI2S_TX, \ 123 id, 1, 0, msm_routing_get_audio_mixer, \ 124 msm_routing_put_audio_mixer), \ 125 SOC_SINGLE_EXT("TERT_MI2S_TX", TERTIARY_MI2S_TX, \ 126 id, 1, 0, msm_routing_get_audio_mixer, \ 127 msm_routing_put_audio_mixer), \ 128 SOC_SINGLE_EXT("QUAT_MI2S_TX", QUATERNARY_MI2S_TX, \ 129 id, 1, 0, msm_routing_get_audio_mixer, \ 130 msm_routing_put_audio_mixer), \ 131 SOC_SINGLE_EXT("SLIMBUS_0_TX", SLIMBUS_0_TX, \ 132 id, 1, 0, msm_routing_get_audio_mixer, \ 133 msm_routing_put_audio_mixer), \ 134 SOC_SINGLE_EXT("SLIMBUS_1_TX", SLIMBUS_1_TX, \ 135 id, 1, 0, msm_routing_get_audio_mixer, \ 136 msm_routing_put_audio_mixer), \ 137 SOC_SINGLE_EXT("SLIMBUS_2_TX", SLIMBUS_2_TX, \ 138 id, 1, 0, msm_routing_get_audio_mixer, \ 139 msm_routing_put_audio_mixer), \ 140 SOC_SINGLE_EXT("SLIMBUS_3_TX", SLIMBUS_3_TX, \ 141 id, 1, 0, msm_routing_get_audio_mixer, \ 142 msm_routing_put_audio_mixer), \ 143 SOC_SINGLE_EXT("SLIMBUS_4_TX", SLIMBUS_4_TX, \ 144 id, 1, 0, msm_routing_get_audio_mixer, \ 145 msm_routing_put_audio_mixer), \ 146 SOC_SINGLE_EXT("SLIMBUS_5_TX", SLIMBUS_5_TX, \ 147 id, 1, 0, msm_routing_get_audio_mixer, \ 148 msm_routing_put_audio_mixer), \ 149 SOC_SINGLE_EXT("SLIMBUS_6_TX", SLIMBUS_6_TX, \ 150 id, 1, 0, msm_routing_get_audio_mixer, \ 151 msm_routing_put_audio_mixer), \ 152 SOC_SINGLE_EXT("PRIMARY_TDM_TX_0", PRIMARY_TDM_TX_0, \ 153 id, 1, 0, msm_routing_get_audio_mixer, \ 154 msm_routing_put_audio_mixer), \ 155 SOC_SINGLE_EXT("PRIMARY_TDM_TX_1", PRIMARY_TDM_TX_1, \ 156 id, 1, 0, msm_routing_get_audio_mixer, \ 157 msm_routing_put_audio_mixer), \ 158 SOC_SINGLE_EXT("PRIMARY_TDM_TX_2", PRIMARY_TDM_TX_2, \ 159 id, 1, 0, msm_routing_get_audio_mixer, \ 160 msm_routing_put_audio_mixer), \ 161 SOC_SINGLE_EXT("PRIMARY_TDM_TX_3", PRIMARY_TDM_TX_3, \ 162 id, 1, 0, msm_routing_get_audio_mixer, \ 163 msm_routing_put_audio_mixer), \ 164 SOC_SINGLE_EXT("PRIMARY_TDM_TX_4", PRIMARY_TDM_TX_4, \ 165 id, 1, 0, msm_routing_get_audio_mixer, \ 166 msm_routing_put_audio_mixer), \ 167 SOC_SINGLE_EXT("PRIMARY_TDM_TX_5", PRIMARY_TDM_TX_5, \ 168 id, 1, 0, msm_routing_get_audio_mixer, \ 169 msm_routing_put_audio_mixer), \ 170 SOC_SINGLE_EXT("PRIMARY_TDM_TX_6", PRIMARY_TDM_TX_6, \ 171 id, 1, 0, msm_routing_get_audio_mixer, \ 172 msm_routing_put_audio_mixer), \ 173 SOC_SINGLE_EXT("PRIMARY_TDM_TX_7", PRIMARY_TDM_TX_7, \ 174 id, 1, 0, msm_routing_get_audio_mixer, \ 175 msm_routing_put_audio_mixer), \ 176 SOC_SINGLE_EXT("SEC_TDM_TX_0", SECONDARY_TDM_TX_0, \ 177 id, 1, 0, msm_routing_get_audio_mixer, \ 178 msm_routing_put_audio_mixer), \ 179 SOC_SINGLE_EXT("SEC_TDM_TX_1", SECONDARY_TDM_TX_1, \ 180 id, 1, 0, msm_routing_get_audio_mixer, \ 181 msm_routing_put_audio_mixer), \ 182 SOC_SINGLE_EXT("SEC_TDM_TX_2", SECONDARY_TDM_TX_2, \ 183 id, 1, 0, msm_routing_get_audio_mixer, \ 184 msm_routing_put_audio_mixer), \ 185 SOC_SINGLE_EXT("SEC_TDM_TX_3", SECONDARY_TDM_TX_3, \ 186 id, 1, 0, msm_routing_get_audio_mixer, \ 187 msm_routing_put_audio_mixer), \ 188 SOC_SINGLE_EXT("SEC_TDM_TX_4", SECONDARY_TDM_TX_4, \ 189 id, 1, 0, msm_routing_get_audio_mixer, \ 190 msm_routing_put_audio_mixer), \ 191 SOC_SINGLE_EXT("SEC_TDM_TX_5", SECONDARY_TDM_TX_5, \ 192 id, 1, 0, msm_routing_get_audio_mixer, \ 193 msm_routing_put_audio_mixer), \ 194 SOC_SINGLE_EXT("SEC_TDM_TX_6", SECONDARY_TDM_TX_6, \ 195 id, 1, 0, msm_routing_get_audio_mixer, \ 196 msm_routing_put_audio_mixer), \ 197 SOC_SINGLE_EXT("SEC_TDM_TX_7", SECONDARY_TDM_TX_7, \ 198 id, 1, 0, msm_routing_get_audio_mixer, \ 199 msm_routing_put_audio_mixer), \ 200 SOC_SINGLE_EXT("TERT_TDM_TX_0", TERTIARY_TDM_TX_0, \ 201 id, 1, 0, msm_routing_get_audio_mixer, \ 202 msm_routing_put_audio_mixer), \ 203 SOC_SINGLE_EXT("TERT_TDM_TX_1", TERTIARY_TDM_TX_1, \ 204 id, 1, 0, msm_routing_get_audio_mixer, \ 205 msm_routing_put_audio_mixer), \ 206 SOC_SINGLE_EXT("TERT_TDM_TX_2", TERTIARY_TDM_TX_2, \ 207 id, 1, 0, msm_routing_get_audio_mixer, \ 208 msm_routing_put_audio_mixer), \ 209 SOC_SINGLE_EXT("TERT_TDM_TX_3", TERTIARY_TDM_TX_3, \ 210 id, 1, 0, msm_routing_get_audio_mixer, \ 211 msm_routing_put_audio_mixer), \ 212 SOC_SINGLE_EXT("TERT_TDM_TX_4", TERTIARY_TDM_TX_4, \ 213 id, 1, 0, msm_routing_get_audio_mixer, \ 214 msm_routing_put_audio_mixer), \ 215 SOC_SINGLE_EXT("TERT_TDM_TX_5", TERTIARY_TDM_TX_5, \ 216 id, 1, 0, msm_routing_get_audio_mixer, \ 217 msm_routing_put_audio_mixer), \ 218 SOC_SINGLE_EXT("TERT_TDM_TX_6", TERTIARY_TDM_TX_6, \ 219 id, 1, 0, msm_routing_get_audio_mixer, \ 220 msm_routing_put_audio_mixer), \ 221 SOC_SINGLE_EXT("TERT_TDM_TX_7", TERTIARY_TDM_TX_7, \ 222 id, 1, 0, msm_routing_get_audio_mixer, \ 223 msm_routing_put_audio_mixer), \ 224 SOC_SINGLE_EXT("QUAT_TDM_TX_0", QUATERNARY_TDM_TX_0, \ 225 id, 1, 0, msm_routing_get_audio_mixer, \ 226 msm_routing_put_audio_mixer), \ 227 SOC_SINGLE_EXT("QUAT_TDM_TX_1", QUATERNARY_TDM_TX_1, \ 228 id, 1, 0, msm_routing_get_audio_mixer, \ 229 msm_routing_put_audio_mixer), \ 230 SOC_SINGLE_EXT("QUAT_TDM_TX_2", QUATERNARY_TDM_TX_2, \ 231 id, 1, 0, msm_routing_get_audio_mixer, \ 232 msm_routing_put_audio_mixer), \ 233 SOC_SINGLE_EXT("QUAT_TDM_TX_3", QUATERNARY_TDM_TX_3, \ 234 id, 1, 0, msm_routing_get_audio_mixer, \ 235 msm_routing_put_audio_mixer), \ 236 SOC_SINGLE_EXT("QUAT_TDM_TX_4", QUATERNARY_TDM_TX_4, \ 237 id, 1, 0, msm_routing_get_audio_mixer, \ 238 msm_routing_put_audio_mixer), \ 239 SOC_SINGLE_EXT("QUAT_TDM_TX_5", QUATERNARY_TDM_TX_5, \ 240 id, 1, 0, msm_routing_get_audio_mixer, \ 241 msm_routing_put_audio_mixer), \ 242 SOC_SINGLE_EXT("QUAT_TDM_TX_6", QUATERNARY_TDM_TX_6, \ 243 id, 1, 0, msm_routing_get_audio_mixer, \ 244 msm_routing_put_audio_mixer), \ 245 SOC_SINGLE_EXT("QUAT_TDM_TX_7", QUATERNARY_TDM_TX_7, \ 246 id, 1, 0, msm_routing_get_audio_mixer, \ 247 msm_routing_put_audio_mixer), \ 248 SOC_SINGLE_EXT("QUIN_TDM_TX_0", QUINARY_TDM_TX_0, \ 249 id, 1, 0, msm_routing_get_audio_mixer, \ 250 msm_routing_put_audio_mixer), \ 251 SOC_SINGLE_EXT("QUIN_TDM_TX_1", QUINARY_TDM_TX_1, \ 252 id, 1, 0, msm_routing_get_audio_mixer, \ 253 msm_routing_put_audio_mixer), \ 254 SOC_SINGLE_EXT("QUIN_TDM_TX_2", QUINARY_TDM_TX_2, \ 255 id, 1, 0, msm_routing_get_audio_mixer, \ 256 msm_routing_put_audio_mixer), \ 257 SOC_SINGLE_EXT("QUIN_TDM_TX_3", QUINARY_TDM_TX_3, \ 258 id, 1, 0, msm_routing_get_audio_mixer, \ 259 msm_routing_put_audio_mixer), \ 260 SOC_SINGLE_EXT("QUIN_TDM_TX_4", QUINARY_TDM_TX_4, \ 261 id, 1, 0, msm_routing_get_audio_mixer, \ 262 msm_routing_put_audio_mixer), \ 263 SOC_SINGLE_EXT("QUIN_TDM_TX_5", QUINARY_TDM_TX_5, \ 264 id, 1, 0, msm_routing_get_audio_mixer, \ 265 msm_routing_put_audio_mixer), \ 266 SOC_SINGLE_EXT("QUIN_TDM_TX_6", QUINARY_TDM_TX_6, \ 267 id, 1, 0, msm_routing_get_audio_mixer, \ 268 msm_routing_put_audio_mixer), \ 269 SOC_SINGLE_EXT("QUIN_TDM_TX_7", QUINARY_TDM_TX_7, \ 270 id, 1, 0, msm_routing_get_audio_mixer, \ 271 msm_routing_put_audio_mixer), 272 273 struct session_data { 274 int state; 275 int port_id; 276 int path_type; 277 int app_type; 278 int acdb_id; 279 int sample_rate; 280 int bits_per_sample; 281 int channels; 282 int perf_mode; 283 int numcopps; 284 int fedai_id; 285 unsigned long copp_map; 286 struct q6copp *copps[MAX_COPPS_PER_PORT]; 287 }; 288 289 struct msm_routing_data { 290 struct session_data sessions[MAX_SESSIONS]; 291 struct session_data port_data[AFE_MAX_PORTS]; 292 struct device *dev; 293 struct mutex lock; 294 }; 295 296 static struct msm_routing_data *routing_data; 297 298 /** 299 * q6routing_stream_open() - Register a new stream for route setup 300 * 301 * @fedai_id: Frontend dai id. 302 * @perf_mode: Performance mode. 303 * @stream_id: ASM stream id to map. 304 * @stream_type: Direction of stream 305 * 306 * Return: Will be an negative on error or a zero on success. 307 */ 308 int q6routing_stream_open(int fedai_id, int perf_mode, 309 int stream_id, int stream_type) 310 { 311 int j, topology, num_copps = 0; 312 struct route_payload payload; 313 struct q6copp *copp; 314 int copp_idx; 315 struct session_data *session, *pdata; 316 317 if (!routing_data) { 318 pr_err("Routing driver not yet ready\n"); 319 return -EINVAL; 320 } 321 322 session = &routing_data->sessions[stream_id - 1]; 323 pdata = &routing_data->port_data[session->port_id]; 324 325 mutex_lock(&routing_data->lock); 326 session->fedai_id = fedai_id; 327 328 session->path_type = pdata->path_type; 329 session->sample_rate = pdata->sample_rate; 330 session->channels = pdata->channels; 331 session->bits_per_sample = pdata->bits_per_sample; 332 333 payload.num_copps = 0; /* only RX needs to use payload */ 334 topology = NULL_COPP_TOPOLOGY; 335 copp = q6adm_open(routing_data->dev, session->port_id, 336 session->path_type, session->sample_rate, 337 session->channels, topology, perf_mode, 338 session->bits_per_sample, 0, 0); 339 340 if (IS_ERR_OR_NULL(copp)) { 341 mutex_unlock(&routing_data->lock); 342 return -EINVAL; 343 } 344 345 copp_idx = q6adm_get_copp_id(copp); 346 set_bit(copp_idx, &session->copp_map); 347 session->copps[copp_idx] = copp; 348 349 for_each_set_bit(j, &session->copp_map, MAX_COPPS_PER_PORT) { 350 payload.port_id[num_copps] = session->port_id; 351 payload.copp_idx[num_copps] = j; 352 num_copps++; 353 } 354 355 if (num_copps) { 356 payload.num_copps = num_copps; 357 payload.session_id = stream_id; 358 q6adm_matrix_map(routing_data->dev, session->path_type, 359 payload, perf_mode); 360 } 361 mutex_unlock(&routing_data->lock); 362 363 return 0; 364 } 365 EXPORT_SYMBOL_GPL(q6routing_stream_open); 366 367 static struct session_data *get_session_from_id(struct msm_routing_data *data, 368 int fedai_id) 369 { 370 int i; 371 372 for (i = 0; i < MAX_SESSIONS; i++) { 373 if (fedai_id == data->sessions[i].fedai_id) 374 return &data->sessions[i]; 375 } 376 377 return NULL; 378 } 379 /** 380 * q6routing_stream_close() - Deregister a stream 381 * 382 * @fedai_id: Frontend dai id. 383 * @stream_type: Direction of stream 384 * 385 * Return: Will be an negative on error or a zero on success. 386 */ 387 void q6routing_stream_close(int fedai_id, int stream_type) 388 { 389 struct session_data *session; 390 int idx; 391 392 session = get_session_from_id(routing_data, fedai_id); 393 if (!session) 394 return; 395 396 for_each_set_bit(idx, &session->copp_map, MAX_COPPS_PER_PORT) { 397 if (session->copps[idx]) { 398 q6adm_close(routing_data->dev, session->copps[idx]); 399 session->copps[idx] = NULL; 400 } 401 } 402 403 session->fedai_id = -1; 404 session->copp_map = 0; 405 } 406 EXPORT_SYMBOL_GPL(q6routing_stream_close); 407 408 static int msm_routing_get_audio_mixer(struct snd_kcontrol *kcontrol, 409 struct snd_ctl_elem_value *ucontrol) 410 { 411 struct snd_soc_dapm_context *dapm = 412 snd_soc_dapm_kcontrol_dapm(kcontrol); 413 struct soc_mixer_control *mc = 414 (struct soc_mixer_control *)kcontrol->private_value; 415 int session_id = mc->shift; 416 struct snd_soc_component *c = snd_soc_dapm_to_component(dapm); 417 struct msm_routing_data *priv = dev_get_drvdata(c->dev); 418 struct session_data *session = &priv->sessions[session_id]; 419 420 if (session->port_id == mc->reg) 421 ucontrol->value.integer.value[0] = 1; 422 else 423 ucontrol->value.integer.value[0] = 0; 424 425 return 0; 426 } 427 428 static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol, 429 struct snd_ctl_elem_value *ucontrol) 430 { 431 struct snd_soc_dapm_context *dapm = 432 snd_soc_dapm_kcontrol_dapm(kcontrol); 433 struct snd_soc_component *c = snd_soc_dapm_to_component(dapm); 434 struct msm_routing_data *data = dev_get_drvdata(c->dev); 435 struct soc_mixer_control *mc = 436 (struct soc_mixer_control *)kcontrol->private_value; 437 struct snd_soc_dapm_update *update = NULL; 438 int be_id = mc->reg; 439 int session_id = mc->shift; 440 struct session_data *session = &data->sessions[session_id]; 441 442 if (ucontrol->value.integer.value[0]) { 443 session->port_id = be_id; 444 snd_soc_dapm_mixer_update_power(dapm, kcontrol, 1, update); 445 } else { 446 session->port_id = -1; 447 snd_soc_dapm_mixer_update_power(dapm, kcontrol, 0, update); 448 } 449 450 return 1; 451 } 452 453 static const struct snd_kcontrol_new hdmi_mixer_controls[] = { 454 Q6ROUTING_RX_MIXERS(HDMI_RX) }; 455 456 static const struct snd_kcontrol_new primary_mi2s_rx_mixer_controls[] = { 457 Q6ROUTING_RX_MIXERS(PRIMARY_MI2S_RX) }; 458 459 static const struct snd_kcontrol_new secondary_mi2s_rx_mixer_controls[] = { 460 Q6ROUTING_RX_MIXERS(SECONDARY_MI2S_RX) }; 461 462 static const struct snd_kcontrol_new quaternary_mi2s_rx_mixer_controls[] = { 463 Q6ROUTING_RX_MIXERS(QUATERNARY_MI2S_RX) }; 464 465 static const struct snd_kcontrol_new tertiary_mi2s_rx_mixer_controls[] = { 466 Q6ROUTING_RX_MIXERS(TERTIARY_MI2S_RX) }; 467 468 static const struct snd_kcontrol_new slimbus_rx_mixer_controls[] = { 469 Q6ROUTING_RX_MIXERS(SLIMBUS_0_RX) }; 470 471 static const struct snd_kcontrol_new slimbus_1_rx_mixer_controls[] = { 472 Q6ROUTING_RX_MIXERS(SLIMBUS_1_RX) }; 473 474 static const struct snd_kcontrol_new slimbus_2_rx_mixer_controls[] = { 475 Q6ROUTING_RX_MIXERS(SLIMBUS_2_RX) }; 476 477 static const struct snd_kcontrol_new slimbus_3_rx_mixer_controls[] = { 478 Q6ROUTING_RX_MIXERS(SLIMBUS_3_RX) }; 479 480 static const struct snd_kcontrol_new slimbus_4_rx_mixer_controls[] = { 481 Q6ROUTING_RX_MIXERS(SLIMBUS_4_RX) }; 482 483 static const struct snd_kcontrol_new slimbus_5_rx_mixer_controls[] = { 484 Q6ROUTING_RX_MIXERS(SLIMBUS_5_RX) }; 485 486 static const struct snd_kcontrol_new slimbus_6_rx_mixer_controls[] = { 487 Q6ROUTING_RX_MIXERS(SLIMBUS_6_RX) }; 488 489 static const struct snd_kcontrol_new pri_tdm_rx_0_mixer_controls[] = { 490 Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_0) }; 491 492 static const struct snd_kcontrol_new pri_tdm_rx_1_mixer_controls[] = { 493 Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_1) }; 494 495 static const struct snd_kcontrol_new pri_tdm_rx_2_mixer_controls[] = { 496 Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_2) }; 497 498 static const struct snd_kcontrol_new pri_tdm_rx_3_mixer_controls[] = { 499 Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_3) }; 500 501 static const struct snd_kcontrol_new pri_tdm_rx_4_mixer_controls[] = { 502 Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_4) }; 503 504 static const struct snd_kcontrol_new pri_tdm_rx_5_mixer_controls[] = { 505 Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_5) }; 506 507 static const struct snd_kcontrol_new pri_tdm_rx_6_mixer_controls[] = { 508 Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_6) }; 509 510 static const struct snd_kcontrol_new pri_tdm_rx_7_mixer_controls[] = { 511 Q6ROUTING_RX_MIXERS(PRIMARY_TDM_RX_7) }; 512 513 static const struct snd_kcontrol_new sec_tdm_rx_0_mixer_controls[] = { 514 Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_0) }; 515 516 static const struct snd_kcontrol_new sec_tdm_rx_1_mixer_controls[] = { 517 Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_1) }; 518 519 static const struct snd_kcontrol_new sec_tdm_rx_2_mixer_controls[] = { 520 Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_2) }; 521 522 static const struct snd_kcontrol_new sec_tdm_rx_3_mixer_controls[] = { 523 Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_3) }; 524 525 static const struct snd_kcontrol_new sec_tdm_rx_4_mixer_controls[] = { 526 Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_4) }; 527 528 static const struct snd_kcontrol_new sec_tdm_rx_5_mixer_controls[] = { 529 Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_5) }; 530 531 static const struct snd_kcontrol_new sec_tdm_rx_6_mixer_controls[] = { 532 Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_6) }; 533 534 static const struct snd_kcontrol_new sec_tdm_rx_7_mixer_controls[] = { 535 Q6ROUTING_RX_MIXERS(SECONDARY_TDM_RX_7) }; 536 537 static const struct snd_kcontrol_new tert_tdm_rx_0_mixer_controls[] = { 538 Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_0) }; 539 540 static const struct snd_kcontrol_new tert_tdm_rx_1_mixer_controls[] = { 541 Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_1) }; 542 543 static const struct snd_kcontrol_new tert_tdm_rx_2_mixer_controls[] = { 544 Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_2) }; 545 546 static const struct snd_kcontrol_new tert_tdm_rx_3_mixer_controls[] = { 547 Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_3) }; 548 549 static const struct snd_kcontrol_new tert_tdm_rx_4_mixer_controls[] = { 550 Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_4) }; 551 552 static const struct snd_kcontrol_new tert_tdm_rx_5_mixer_controls[] = { 553 Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_5) }; 554 555 static const struct snd_kcontrol_new tert_tdm_rx_6_mixer_controls[] = { 556 Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_6) }; 557 558 static const struct snd_kcontrol_new tert_tdm_rx_7_mixer_controls[] = { 559 Q6ROUTING_RX_MIXERS(TERTIARY_TDM_RX_7) }; 560 561 static const struct snd_kcontrol_new quat_tdm_rx_0_mixer_controls[] = { 562 Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_0) }; 563 564 static const struct snd_kcontrol_new quat_tdm_rx_1_mixer_controls[] = { 565 Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_1) }; 566 567 static const struct snd_kcontrol_new quat_tdm_rx_2_mixer_controls[] = { 568 Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_2) }; 569 570 static const struct snd_kcontrol_new quat_tdm_rx_3_mixer_controls[] = { 571 Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_3) }; 572 573 static const struct snd_kcontrol_new quat_tdm_rx_4_mixer_controls[] = { 574 Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_4) }; 575 576 static const struct snd_kcontrol_new quat_tdm_rx_5_mixer_controls[] = { 577 Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_5) }; 578 579 static const struct snd_kcontrol_new quat_tdm_rx_6_mixer_controls[] = { 580 Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_6) }; 581 582 static const struct snd_kcontrol_new quat_tdm_rx_7_mixer_controls[] = { 583 Q6ROUTING_RX_MIXERS(QUATERNARY_TDM_RX_7) }; 584 585 static const struct snd_kcontrol_new quin_tdm_rx_0_mixer_controls[] = { 586 Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_0) }; 587 588 static const struct snd_kcontrol_new quin_tdm_rx_1_mixer_controls[] = { 589 Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_1) }; 590 591 static const struct snd_kcontrol_new quin_tdm_rx_2_mixer_controls[] = { 592 Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_2) }; 593 594 static const struct snd_kcontrol_new quin_tdm_rx_3_mixer_controls[] = { 595 Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_3) }; 596 597 static const struct snd_kcontrol_new quin_tdm_rx_4_mixer_controls[] = { 598 Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_4) }; 599 600 static const struct snd_kcontrol_new quin_tdm_rx_5_mixer_controls[] = { 601 Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_5) }; 602 603 static const struct snd_kcontrol_new quin_tdm_rx_6_mixer_controls[] = { 604 Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_6) }; 605 606 static const struct snd_kcontrol_new quin_tdm_rx_7_mixer_controls[] = { 607 Q6ROUTING_RX_MIXERS(QUINARY_TDM_RX_7) }; 608 609 610 static const struct snd_kcontrol_new mmul1_mixer_controls[] = { 611 Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA1) }; 612 613 static const struct snd_kcontrol_new mmul2_mixer_controls[] = { 614 Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA2) }; 615 616 static const struct snd_kcontrol_new mmul3_mixer_controls[] = { 617 Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA3) }; 618 619 static const struct snd_kcontrol_new mmul4_mixer_controls[] = { 620 Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA4) }; 621 622 static const struct snd_kcontrol_new mmul5_mixer_controls[] = { 623 Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA5) }; 624 625 static const struct snd_kcontrol_new mmul6_mixer_controls[] = { 626 Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA6) }; 627 628 static const struct snd_kcontrol_new mmul7_mixer_controls[] = { 629 Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA7) }; 630 631 static const struct snd_kcontrol_new mmul8_mixer_controls[] = { 632 Q6ROUTING_TX_MIXERS(MSM_FRONTEND_DAI_MULTIMEDIA8) }; 633 634 static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = { 635 /* Frontend AIF */ 636 SND_SOC_DAPM_AIF_IN("MM_DL1", "MultiMedia1 Playback", 0, 0, 0, 0), 637 SND_SOC_DAPM_AIF_IN("MM_DL2", "MultiMedia2 Playback", 0, 0, 0, 0), 638 SND_SOC_DAPM_AIF_IN("MM_DL3", "MultiMedia3 Playback", 0, 0, 0, 0), 639 SND_SOC_DAPM_AIF_IN("MM_DL4", "MultiMedia4 Playback", 0, 0, 0, 0), 640 SND_SOC_DAPM_AIF_IN("MM_DL5", "MultiMedia5 Playback", 0, 0, 0, 0), 641 SND_SOC_DAPM_AIF_IN("MM_DL6", "MultiMedia6 Playback", 0, 0, 0, 0), 642 SND_SOC_DAPM_AIF_IN("MM_DL7", "MultiMedia7 Playback", 0, 0, 0, 0), 643 SND_SOC_DAPM_AIF_IN("MM_DL8", "MultiMedia8 Playback", 0, 0, 0, 0), 644 SND_SOC_DAPM_AIF_OUT("MM_UL1", "MultiMedia1 Capture", 0, 0, 0, 0), 645 SND_SOC_DAPM_AIF_OUT("MM_UL2", "MultiMedia2 Capture", 0, 0, 0, 0), 646 SND_SOC_DAPM_AIF_OUT("MM_UL3", "MultiMedia3 Capture", 0, 0, 0, 0), 647 SND_SOC_DAPM_AIF_OUT("MM_UL4", "MultiMedia4 Capture", 0, 0, 0, 0), 648 SND_SOC_DAPM_AIF_OUT("MM_UL5", "MultiMedia5 Capture", 0, 0, 0, 0), 649 SND_SOC_DAPM_AIF_OUT("MM_UL6", "MultiMedia6 Capture", 0, 0, 0, 0), 650 SND_SOC_DAPM_AIF_OUT("MM_UL7", "MultiMedia7 Capture", 0, 0, 0, 0), 651 SND_SOC_DAPM_AIF_OUT("MM_UL8", "MultiMedia8 Capture", 0, 0, 0, 0), 652 653 /* Mixer definitions */ 654 SND_SOC_DAPM_MIXER("HDMI Mixer", SND_SOC_NOPM, 0, 0, 655 hdmi_mixer_controls, 656 ARRAY_SIZE(hdmi_mixer_controls)), 657 658 SND_SOC_DAPM_MIXER("SLIMBUS_0_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 659 slimbus_rx_mixer_controls, 660 ARRAY_SIZE(slimbus_rx_mixer_controls)), 661 SND_SOC_DAPM_MIXER("SLIMBUS_1_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 662 slimbus_1_rx_mixer_controls, 663 ARRAY_SIZE(slimbus_1_rx_mixer_controls)), 664 SND_SOC_DAPM_MIXER("SLIMBUS_2_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 665 slimbus_2_rx_mixer_controls, 666 ARRAY_SIZE(slimbus_2_rx_mixer_controls)), 667 SND_SOC_DAPM_MIXER("SLIMBUS_3_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 668 slimbus_3_rx_mixer_controls, 669 ARRAY_SIZE(slimbus_3_rx_mixer_controls)), 670 SND_SOC_DAPM_MIXER("SLIMBUS_4_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 671 slimbus_4_rx_mixer_controls, 672 ARRAY_SIZE(slimbus_4_rx_mixer_controls)), 673 SND_SOC_DAPM_MIXER("SLIMBUS_5_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 674 slimbus_5_rx_mixer_controls, 675 ARRAY_SIZE(slimbus_5_rx_mixer_controls)), 676 SND_SOC_DAPM_MIXER("SLIMBUS_6_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 677 slimbus_6_rx_mixer_controls, 678 ARRAY_SIZE(slimbus_6_rx_mixer_controls)), 679 SND_SOC_DAPM_MIXER("PRI_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 680 primary_mi2s_rx_mixer_controls, 681 ARRAY_SIZE(primary_mi2s_rx_mixer_controls)), 682 SND_SOC_DAPM_MIXER("SEC_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 683 secondary_mi2s_rx_mixer_controls, 684 ARRAY_SIZE(secondary_mi2s_rx_mixer_controls)), 685 SND_SOC_DAPM_MIXER("QUAT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 686 quaternary_mi2s_rx_mixer_controls, 687 ARRAY_SIZE(quaternary_mi2s_rx_mixer_controls)), 688 SND_SOC_DAPM_MIXER("TERT_MI2S_RX Audio Mixer", SND_SOC_NOPM, 0, 0, 689 tertiary_mi2s_rx_mixer_controls, 690 ARRAY_SIZE(tertiary_mi2s_rx_mixer_controls)), 691 SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0, 692 pri_tdm_rx_0_mixer_controls, 693 ARRAY_SIZE(pri_tdm_rx_0_mixer_controls)), 694 SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0, 695 pri_tdm_rx_1_mixer_controls, 696 ARRAY_SIZE(pri_tdm_rx_1_mixer_controls)), 697 SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0, 698 pri_tdm_rx_2_mixer_controls, 699 ARRAY_SIZE(pri_tdm_rx_2_mixer_controls)), 700 SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0, 701 pri_tdm_rx_3_mixer_controls, 702 ARRAY_SIZE(pri_tdm_rx_3_mixer_controls)), 703 SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0, 704 pri_tdm_rx_4_mixer_controls, 705 ARRAY_SIZE(pri_tdm_rx_4_mixer_controls)), 706 SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0, 707 pri_tdm_rx_5_mixer_controls, 708 ARRAY_SIZE(pri_tdm_rx_5_mixer_controls)), 709 SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0, 710 pri_tdm_rx_6_mixer_controls, 711 ARRAY_SIZE(pri_tdm_rx_6_mixer_controls)), 712 SND_SOC_DAPM_MIXER("PRIMARY_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0, 713 pri_tdm_rx_7_mixer_controls, 714 ARRAY_SIZE(pri_tdm_rx_7_mixer_controls)), 715 716 SND_SOC_DAPM_MIXER("SEC_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0, 717 sec_tdm_rx_0_mixer_controls, 718 ARRAY_SIZE(sec_tdm_rx_0_mixer_controls)), 719 SND_SOC_DAPM_MIXER("SEC_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0, 720 sec_tdm_rx_1_mixer_controls, 721 ARRAY_SIZE(sec_tdm_rx_1_mixer_controls)), 722 SND_SOC_DAPM_MIXER("SEC_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0, 723 sec_tdm_rx_2_mixer_controls, 724 ARRAY_SIZE(sec_tdm_rx_2_mixer_controls)), 725 SND_SOC_DAPM_MIXER("SEC_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0, 726 sec_tdm_rx_3_mixer_controls, 727 ARRAY_SIZE(sec_tdm_rx_3_mixer_controls)), 728 SND_SOC_DAPM_MIXER("SEC_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0, 729 sec_tdm_rx_4_mixer_controls, 730 ARRAY_SIZE(sec_tdm_rx_4_mixer_controls)), 731 SND_SOC_DAPM_MIXER("SEC_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0, 732 sec_tdm_rx_5_mixer_controls, 733 ARRAY_SIZE(sec_tdm_rx_5_mixer_controls)), 734 SND_SOC_DAPM_MIXER("SEC_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0, 735 sec_tdm_rx_6_mixer_controls, 736 ARRAY_SIZE(sec_tdm_rx_6_mixer_controls)), 737 SND_SOC_DAPM_MIXER("SEC_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0, 738 sec_tdm_rx_7_mixer_controls, 739 ARRAY_SIZE(sec_tdm_rx_7_mixer_controls)), 740 741 SND_SOC_DAPM_MIXER("TERT_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0, 742 tert_tdm_rx_0_mixer_controls, 743 ARRAY_SIZE(tert_tdm_rx_0_mixer_controls)), 744 SND_SOC_DAPM_MIXER("TERT_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0, 745 tert_tdm_rx_1_mixer_controls, 746 ARRAY_SIZE(tert_tdm_rx_1_mixer_controls)), 747 SND_SOC_DAPM_MIXER("TERT_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0, 748 tert_tdm_rx_2_mixer_controls, 749 ARRAY_SIZE(tert_tdm_rx_2_mixer_controls)), 750 SND_SOC_DAPM_MIXER("TERT_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0, 751 tert_tdm_rx_3_mixer_controls, 752 ARRAY_SIZE(tert_tdm_rx_3_mixer_controls)), 753 SND_SOC_DAPM_MIXER("TERT_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0, 754 tert_tdm_rx_4_mixer_controls, 755 ARRAY_SIZE(tert_tdm_rx_4_mixer_controls)), 756 SND_SOC_DAPM_MIXER("TERT_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0, 757 tert_tdm_rx_5_mixer_controls, 758 ARRAY_SIZE(tert_tdm_rx_5_mixer_controls)), 759 SND_SOC_DAPM_MIXER("TERT_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0, 760 tert_tdm_rx_6_mixer_controls, 761 ARRAY_SIZE(tert_tdm_rx_6_mixer_controls)), 762 SND_SOC_DAPM_MIXER("TERT_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0, 763 tert_tdm_rx_7_mixer_controls, 764 ARRAY_SIZE(tert_tdm_rx_7_mixer_controls)), 765 766 SND_SOC_DAPM_MIXER("QUAT_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0, 767 quat_tdm_rx_0_mixer_controls, 768 ARRAY_SIZE(quat_tdm_rx_0_mixer_controls)), 769 SND_SOC_DAPM_MIXER("QUAT_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0, 770 quat_tdm_rx_1_mixer_controls, 771 ARRAY_SIZE(quat_tdm_rx_1_mixer_controls)), 772 SND_SOC_DAPM_MIXER("QUAT_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0, 773 quat_tdm_rx_2_mixer_controls, 774 ARRAY_SIZE(quat_tdm_rx_2_mixer_controls)), 775 SND_SOC_DAPM_MIXER("QUAT_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0, 776 quat_tdm_rx_3_mixer_controls, 777 ARRAY_SIZE(quat_tdm_rx_3_mixer_controls)), 778 SND_SOC_DAPM_MIXER("QUAT_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0, 779 quat_tdm_rx_4_mixer_controls, 780 ARRAY_SIZE(quat_tdm_rx_4_mixer_controls)), 781 SND_SOC_DAPM_MIXER("QUAT_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0, 782 quat_tdm_rx_5_mixer_controls, 783 ARRAY_SIZE(quat_tdm_rx_5_mixer_controls)), 784 SND_SOC_DAPM_MIXER("QUAT_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0, 785 quat_tdm_rx_6_mixer_controls, 786 ARRAY_SIZE(quat_tdm_rx_6_mixer_controls)), 787 SND_SOC_DAPM_MIXER("QUAT_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0, 788 quat_tdm_rx_7_mixer_controls, 789 ARRAY_SIZE(quat_tdm_rx_7_mixer_controls)), 790 791 SND_SOC_DAPM_MIXER("QUIN_TDM_RX_0 Audio Mixer", SND_SOC_NOPM, 0, 0, 792 quin_tdm_rx_0_mixer_controls, 793 ARRAY_SIZE(quin_tdm_rx_0_mixer_controls)), 794 SND_SOC_DAPM_MIXER("QUIN_TDM_RX_1 Audio Mixer", SND_SOC_NOPM, 0, 0, 795 quin_tdm_rx_1_mixer_controls, 796 ARRAY_SIZE(quin_tdm_rx_1_mixer_controls)), 797 SND_SOC_DAPM_MIXER("QUIN_TDM_RX_2 Audio Mixer", SND_SOC_NOPM, 0, 0, 798 quin_tdm_rx_2_mixer_controls, 799 ARRAY_SIZE(quin_tdm_rx_2_mixer_controls)), 800 SND_SOC_DAPM_MIXER("QUIN_TDM_RX_3 Audio Mixer", SND_SOC_NOPM, 0, 0, 801 quin_tdm_rx_3_mixer_controls, 802 ARRAY_SIZE(quin_tdm_rx_3_mixer_controls)), 803 SND_SOC_DAPM_MIXER("QUIN_TDM_RX_4 Audio Mixer", SND_SOC_NOPM, 0, 0, 804 quin_tdm_rx_4_mixer_controls, 805 ARRAY_SIZE(quin_tdm_rx_4_mixer_controls)), 806 SND_SOC_DAPM_MIXER("QUIN_TDM_RX_5 Audio Mixer", SND_SOC_NOPM, 0, 0, 807 quin_tdm_rx_5_mixer_controls, 808 ARRAY_SIZE(quin_tdm_rx_5_mixer_controls)), 809 SND_SOC_DAPM_MIXER("QUIN_TDM_RX_6 Audio Mixer", SND_SOC_NOPM, 0, 0, 810 quin_tdm_rx_6_mixer_controls, 811 ARRAY_SIZE(quin_tdm_rx_6_mixer_controls)), 812 SND_SOC_DAPM_MIXER("QUIN_TDM_RX_7 Audio Mixer", SND_SOC_NOPM, 0, 0, 813 quin_tdm_rx_7_mixer_controls, 814 ARRAY_SIZE(quin_tdm_rx_7_mixer_controls)), 815 SND_SOC_DAPM_MIXER("MultiMedia1 Mixer", SND_SOC_NOPM, 0, 0, 816 mmul1_mixer_controls, ARRAY_SIZE(mmul1_mixer_controls)), 817 SND_SOC_DAPM_MIXER("MultiMedia2 Mixer", SND_SOC_NOPM, 0, 0, 818 mmul2_mixer_controls, ARRAY_SIZE(mmul2_mixer_controls)), 819 SND_SOC_DAPM_MIXER("MultiMedia3 Mixer", SND_SOC_NOPM, 0, 0, 820 mmul3_mixer_controls, ARRAY_SIZE(mmul3_mixer_controls)), 821 SND_SOC_DAPM_MIXER("MultiMedia4 Mixer", SND_SOC_NOPM, 0, 0, 822 mmul4_mixer_controls, ARRAY_SIZE(mmul4_mixer_controls)), 823 SND_SOC_DAPM_MIXER("MultiMedia5 Mixer", SND_SOC_NOPM, 0, 0, 824 mmul5_mixer_controls, ARRAY_SIZE(mmul5_mixer_controls)), 825 SND_SOC_DAPM_MIXER("MultiMedia6 Mixer", SND_SOC_NOPM, 0, 0, 826 mmul6_mixer_controls, ARRAY_SIZE(mmul6_mixer_controls)), 827 SND_SOC_DAPM_MIXER("MultiMedia7 Mixer", SND_SOC_NOPM, 0, 0, 828 mmul7_mixer_controls, ARRAY_SIZE(mmul7_mixer_controls)), 829 SND_SOC_DAPM_MIXER("MultiMedia8 Mixer", SND_SOC_NOPM, 0, 0, 830 mmul8_mixer_controls, ARRAY_SIZE(mmul8_mixer_controls)), 831 832 }; 833 834 static const struct snd_soc_dapm_route intercon[] = { 835 Q6ROUTING_RX_DAPM_ROUTE("HDMI Mixer", "HDMI_RX"), 836 Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_0_RX Audio Mixer", "SLIMBUS_0_RX"), 837 Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_1_RX Audio Mixer", "SLIMBUS_1_RX"), 838 Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_2_RX Audio Mixer", "SLIMBUS_2_RX"), 839 Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_3_RX Audio Mixer", "SLIMBUS_3_RX"), 840 Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_4_RX Audio Mixer", "SLIMBUS_4_RX"), 841 Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_5_RX Audio Mixer", "SLIMBUS_5_RX"), 842 Q6ROUTING_RX_DAPM_ROUTE("SLIMBUS_6_RX Audio Mixer", "SLIMBUS_6_RX"), 843 Q6ROUTING_RX_DAPM_ROUTE("QUAT_MI2S_RX Audio Mixer", "QUAT_MI2S_RX"), 844 Q6ROUTING_RX_DAPM_ROUTE("TERT_MI2S_RX Audio Mixer", "TERT_MI2S_RX"), 845 Q6ROUTING_RX_DAPM_ROUTE("SEC_MI2S_RX Audio Mixer", "SEC_MI2S_RX"), 846 Q6ROUTING_RX_DAPM_ROUTE("PRI_MI2S_RX Audio Mixer", "PRI_MI2S_RX"), 847 Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_0 Audio Mixer", 848 "PRIMARY_TDM_RX_0"), 849 Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_1 Audio Mixer", 850 "PRIMARY_TDM_RX_1"), 851 Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_2 Audio Mixer", 852 "PRIMARY_TDM_RX_2"), 853 Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_3 Audio Mixer", 854 "PRIMARY_TDM_RX_3"), 855 Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_4 Audio Mixer", 856 "PRIMARY_TDM_RX_4"), 857 Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_5 Audio Mixer", 858 "PRIMARY_TDM_RX_5"), 859 Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_6 Audio Mixer", 860 "PRIMARY_TDM_RX_6"), 861 Q6ROUTING_RX_DAPM_ROUTE("PRIMARY_TDM_RX_7 Audio Mixer", 862 "PRIMARY_TDM_RX_7"), 863 Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_0 Audio Mixer", "SEC_TDM_RX_0"), 864 Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_1 Audio Mixer", "SEC_TDM_RX_1"), 865 Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_2 Audio Mixer", "SEC_TDM_RX_2"), 866 Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_3 Audio Mixer", "SEC_TDM_RX_3"), 867 Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_4 Audio Mixer", "SEC_TDM_RX_4"), 868 Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_5 Audio Mixer", "SEC_TDM_RX_5"), 869 Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_6 Audio Mixer", "SEC_TDM_RX_6"), 870 Q6ROUTING_RX_DAPM_ROUTE("SEC_TDM_RX_7 Audio Mixer", "SEC_TDM_RX_7"), 871 Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_0 Audio Mixer", "TERT_TDM_RX_0"), 872 Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_1 Audio Mixer", "TERT_TDM_RX_1"), 873 Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_2 Audio Mixer", "TERT_TDM_RX_2"), 874 Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_3 Audio Mixer", "TERT_TDM_RX_3"), 875 Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_4 Audio Mixer", "TERT_TDM_RX_4"), 876 Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_5 Audio Mixer", "TERT_TDM_RX_5"), 877 Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_6 Audio Mixer", "TERT_TDM_RX_6"), 878 Q6ROUTING_RX_DAPM_ROUTE("TERT_TDM_RX_7 Audio Mixer", "TERT_TDM_RX_7"), 879 Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_0 Audio Mixer", "QUAT_TDM_RX_0"), 880 Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_1 Audio Mixer", "QUAT_TDM_RX_1"), 881 Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_2 Audio Mixer", "QUAT_TDM_RX_2"), 882 Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_3 Audio Mixer", "QUAT_TDM_RX_3"), 883 Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_4 Audio Mixer", "QUAT_TDM_RX_4"), 884 Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_5 Audio Mixer", "QUAT_TDM_RX_5"), 885 Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_6 Audio Mixer", "QUAT_TDM_RX_6"), 886 Q6ROUTING_RX_DAPM_ROUTE("QUAT_TDM_RX_7 Audio Mixer", "QUAT_TDM_RX_7"), 887 Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_0 Audio Mixer", "QUIN_TDM_RX_0"), 888 Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_1 Audio Mixer", "QUIN_TDM_RX_1"), 889 Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_2 Audio Mixer", "QUIN_TDM_RX_2"), 890 Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_3 Audio Mixer", "QUIN_TDM_RX_3"), 891 Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_4 Audio Mixer", "QUIN_TDM_RX_4"), 892 Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_5 Audio Mixer", "QUIN_TDM_RX_5"), 893 Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_6 Audio Mixer", "QUIN_TDM_RX_6"), 894 Q6ROUTING_RX_DAPM_ROUTE("QUIN_TDM_RX_7 Audio Mixer", "QUIN_TDM_RX_7"), 895 Q6ROUTING_TX_DAPM_ROUTE("MultiMedia1 Mixer"), 896 Q6ROUTING_TX_DAPM_ROUTE("MultiMedia2 Mixer"), 897 Q6ROUTING_TX_DAPM_ROUTE("MultiMedia3 Mixer"), 898 Q6ROUTING_TX_DAPM_ROUTE("MultiMedia4 Mixer"), 899 Q6ROUTING_TX_DAPM_ROUTE("MultiMedia5 Mixer"), 900 Q6ROUTING_TX_DAPM_ROUTE("MultiMedia6 Mixer"), 901 Q6ROUTING_TX_DAPM_ROUTE("MultiMedia7 Mixer"), 902 Q6ROUTING_TX_DAPM_ROUTE("MultiMedia8 Mixer"), 903 904 {"MM_UL1", NULL, "MultiMedia1 Mixer"}, 905 {"MM_UL2", NULL, "MultiMedia2 Mixer"}, 906 {"MM_UL3", NULL, "MultiMedia3 Mixer"}, 907 {"MM_UL4", NULL, "MultiMedia4 Mixer"}, 908 {"MM_UL5", NULL, "MultiMedia5 Mixer"}, 909 {"MM_UL6", NULL, "MultiMedia6 Mixer"}, 910 {"MM_UL7", NULL, "MultiMedia7 Mixer"}, 911 {"MM_UL8", NULL, "MultiMedia8 Mixer"}, 912 }; 913 914 static int routing_hw_params(struct snd_pcm_substream *substream, 915 struct snd_pcm_hw_params *params) 916 { 917 struct snd_soc_pcm_runtime *rtd = substream->private_data; 918 struct snd_soc_component *c = snd_soc_rtdcom_lookup(rtd, DRV_NAME); 919 struct msm_routing_data *data = dev_get_drvdata(c->dev); 920 unsigned int be_id = rtd->cpu_dai->id; 921 struct session_data *session; 922 int path_type; 923 924 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 925 path_type = ADM_PATH_PLAYBACK; 926 else 927 path_type = ADM_PATH_LIVE_REC; 928 929 if (be_id >= AFE_MAX_PORTS) 930 return -EINVAL; 931 932 session = &data->port_data[be_id]; 933 934 mutex_lock(&data->lock); 935 936 session->path_type = path_type; 937 session->sample_rate = params_rate(params); 938 session->channels = params_channels(params); 939 940 switch (params_format(params)) { 941 case SNDRV_PCM_FORMAT_S16_LE: 942 session->bits_per_sample = 16; 943 break; 944 case SNDRV_PCM_FORMAT_S24_LE: 945 session->bits_per_sample = 24; 946 break; 947 default: 948 break; 949 } 950 951 mutex_unlock(&data->lock); 952 return 0; 953 } 954 955 static struct snd_pcm_ops q6pcm_routing_ops = { 956 .hw_params = routing_hw_params, 957 }; 958 959 static int msm_routing_probe(struct snd_soc_component *c) 960 { 961 int i; 962 963 for (i = 0; i < MAX_SESSIONS; i++) { 964 routing_data->sessions[i].port_id = -1; 965 routing_data->sessions[i].fedai_id = -1; 966 } 967 968 return 0; 969 } 970 971 static const struct snd_soc_component_driver msm_soc_routing_component = { 972 .ops = &q6pcm_routing_ops, 973 .probe = msm_routing_probe, 974 .name = DRV_NAME, 975 .dapm_widgets = msm_qdsp6_widgets, 976 .num_dapm_widgets = ARRAY_SIZE(msm_qdsp6_widgets), 977 .dapm_routes = intercon, 978 .num_dapm_routes = ARRAY_SIZE(intercon), 979 }; 980 981 static int q6pcm_routing_probe(struct platform_device *pdev) 982 { 983 struct device *dev = &pdev->dev; 984 985 routing_data = kzalloc(sizeof(*routing_data), GFP_KERNEL); 986 if (!routing_data) 987 return -ENOMEM; 988 989 routing_data->dev = dev; 990 991 mutex_init(&routing_data->lock); 992 dev_set_drvdata(dev, routing_data); 993 994 return devm_snd_soc_register_component(dev, &msm_soc_routing_component, 995 NULL, 0); 996 } 997 998 static int q6pcm_routing_remove(struct platform_device *pdev) 999 { 1000 kfree(routing_data); 1001 routing_data = NULL; 1002 1003 return 0; 1004 } 1005 1006 static const struct of_device_id q6pcm_routing_device_id[] = { 1007 { .compatible = "qcom,q6adm-routing" }, 1008 {}, 1009 }; 1010 MODULE_DEVICE_TABLE(of, q6pcm_routing_device_id); 1011 1012 static struct platform_driver q6pcm_routing_platform_driver = { 1013 .driver = { 1014 .name = "q6routing", 1015 .of_match_table = of_match_ptr(q6pcm_routing_device_id), 1016 }, 1017 .probe = q6pcm_routing_probe, 1018 .remove = q6pcm_routing_remove, 1019 }; 1020 module_platform_driver(q6pcm_routing_platform_driver); 1021 1022 MODULE_DESCRIPTION("Q6 Routing platform"); 1023 MODULE_LICENSE("GPL v2"); 1024