Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/err.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/bitops.h> |
| 16 | #include <linux/mutex.h> |
| 17 | #include <sound/control.h> |
| 18 | #include <sound/q6adm-v2.h> |
| 19 | #include <sound/q6asm-v2.h> |
| 20 | #include <sound/q6afe-v2.h> |
| 21 | #include <sound/asound.h> |
| 22 | #include <sound/q6audio-v2.h> |
| 23 | #include <sound/tlv.h> |
| 24 | |
| 25 | #include "msm-qti-pp-config.h" |
| 26 | #include "msm-pcm-routing-v2.h" |
| 27 | |
| 28 | /* EQUALIZER */ |
| 29 | /* Equal to Frontend after last of the MULTIMEDIA SESSIONS */ |
| 30 | #define MAX_EQ_SESSIONS MSM_FRONTEND_DAI_CS_VOICE |
| 31 | |
| 32 | enum { |
| 33 | EQ_BAND1 = 0, |
| 34 | EQ_BAND2, |
| 35 | EQ_BAND3, |
| 36 | EQ_BAND4, |
| 37 | EQ_BAND5, |
| 38 | EQ_BAND6, |
| 39 | EQ_BAND7, |
| 40 | EQ_BAND8, |
| 41 | EQ_BAND9, |
| 42 | EQ_BAND10, |
| 43 | EQ_BAND11, |
| 44 | EQ_BAND12, |
| 45 | EQ_BAND_MAX, |
| 46 | }; |
| 47 | |
| 48 | struct msm_audio_eq_band { |
| 49 | uint16_t band_idx; /* The band index, 0 .. 11 */ |
| 50 | uint32_t filter_type; /* Filter band type */ |
| 51 | uint32_t center_freq_hz; /* Filter band center frequency */ |
| 52 | uint32_t filter_gain; /* Filter band initial gain (dB) */ |
| 53 | /* Range is +12 dB to -12 dB with 1dB increments. */ |
| 54 | uint32_t q_factor; |
| 55 | } __packed; |
| 56 | |
| 57 | struct msm_audio_eq_stream_config { |
| 58 | uint32_t enable; /* Number of consequtive bands specified */ |
| 59 | uint32_t num_bands; |
| 60 | struct msm_audio_eq_band eq_bands[EQ_BAND_MAX]; |
| 61 | } __packed; |
| 62 | |
| 63 | /* Audio Sphere data structures */ |
| 64 | struct msm_audio_pp_asphere_state_s { |
| 65 | uint32_t enabled; |
| 66 | uint32_t strength; |
| 67 | uint32_t mode; |
| 68 | uint32_t version; |
| 69 | int port_id[AFE_MAX_PORTS]; |
| 70 | int copp_idx[AFE_MAX_PORTS]; |
| 71 | bool initialized; |
| 72 | uint32_t enabled_prev; |
| 73 | uint32_t strength_prev; |
| 74 | }; |
| 75 | |
| 76 | static struct msm_audio_pp_asphere_state_s asphere_state; |
| 77 | |
| 78 | struct msm_audio_eq_stream_config eq_data[MAX_EQ_SESSIONS]; |
| 79 | |
| 80 | static int msm_route_hfp_vol_control; |
| 81 | static const DECLARE_TLV_DB_LINEAR(hfp_rx_vol_gain, 0, |
| 82 | INT_RX_VOL_MAX_STEPS); |
| 83 | |
Derek Chen | 5dea59a | 2016-06-06 20:40:29 -0400 | [diff] [blame] | 84 | static int msm_route_icc_vol_control; |
| 85 | static const DECLARE_TLV_DB_LINEAR(icc_rx_vol_gain, 0, |
| 86 | INT_RX_VOL_MAX_STEPS); |
| 87 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 88 | static int msm_route_pri_auxpcm_lb_vol_ctrl; |
| 89 | static const DECLARE_TLV_DB_LINEAR(pri_auxpcm_lb_vol_gain, 0, |
| 90 | INT_RX_VOL_MAX_STEPS); |
| 91 | |
| 92 | static int msm_route_sec_auxpcm_lb_vol_ctrl; |
| 93 | static const DECLARE_TLV_DB_LINEAR(sec_auxpcm_lb_vol_gain, 0, |
| 94 | INT_RX_VOL_MAX_STEPS); |
| 95 | |
Rahul Sharma | 6e83698 | 2016-12-09 00:45:44 +0530 | [diff] [blame] | 96 | static int msm_multichannel_ec_primary_mic_ch; |
| 97 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 98 | static void msm_qti_pp_send_eq_values_(int eq_idx) |
| 99 | { |
| 100 | int result; |
| 101 | struct msm_pcm_routing_fdai_data fe_dai; |
| 102 | struct audio_client *ac = NULL; |
| 103 | |
| 104 | msm_pcm_routing_get_fedai_info(eq_idx, SESSION_TYPE_RX, &fe_dai); |
| 105 | ac = q6asm_get_audio_client(fe_dai.strm_id); |
| 106 | |
| 107 | if (ac == NULL) { |
| 108 | pr_err("%s: Could not get audio client for session: %d\n", |
| 109 | __func__, fe_dai.strm_id); |
| 110 | goto done; |
| 111 | } |
| 112 | |
| 113 | result = q6asm_equalizer(ac, &eq_data[eq_idx]); |
| 114 | |
| 115 | if (result < 0) |
| 116 | pr_err("%s: Call to ASM equalizer failed, returned = %d\n", |
| 117 | __func__, result); |
| 118 | done: |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | static int msm_qti_pp_get_eq_enable_mixer(struct snd_kcontrol *kcontrol, |
| 123 | struct snd_ctl_elem_value *ucontrol) |
| 124 | { |
| 125 | int eq_idx = ((struct soc_multi_mixer_control *) |
| 126 | kcontrol->private_value)->reg; |
| 127 | |
| 128 | if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS)) |
| 129 | return -EINVAL; |
| 130 | |
| 131 | ucontrol->value.integer.value[0] = eq_data[eq_idx].enable; |
| 132 | |
| 133 | pr_debug("%s: EQ #%d enable %d\n", __func__, |
| 134 | eq_idx, eq_data[eq_idx].enable); |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | static int msm_qti_pp_put_eq_enable_mixer(struct snd_kcontrol *kcontrol, |
| 139 | struct snd_ctl_elem_value *ucontrol) |
| 140 | { |
| 141 | int eq_idx = ((struct soc_multi_mixer_control *) |
| 142 | kcontrol->private_value)->reg; |
| 143 | int value = ucontrol->value.integer.value[0]; |
| 144 | |
| 145 | if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS)) |
| 146 | return -EINVAL; |
| 147 | pr_debug("%s: EQ #%d enable %d\n", __func__, |
| 148 | eq_idx, value); |
| 149 | eq_data[eq_idx].enable = value; |
| 150 | msm_pcm_routing_acquire_lock(); |
| 151 | msm_qti_pp_send_eq_values_(eq_idx); |
| 152 | msm_pcm_routing_release_lock(); |
| 153 | return 0; |
| 154 | } |
| 155 | |
| 156 | static int msm_qti_pp_get_eq_band_count_audio_mixer( |
| 157 | struct snd_kcontrol *kcontrol, |
| 158 | struct snd_ctl_elem_value *ucontrol) |
| 159 | { |
| 160 | int eq_idx = ((struct soc_multi_mixer_control *) |
| 161 | kcontrol->private_value)->reg; |
| 162 | |
| 163 | if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS)) |
| 164 | return -EINVAL; |
| 165 | ucontrol->value.integer.value[0] = eq_data[eq_idx].num_bands; |
| 166 | |
| 167 | pr_debug("%s: EQ #%d bands %d\n", __func__, |
| 168 | eq_idx, eq_data[eq_idx].num_bands); |
| 169 | return eq_data[eq_idx].num_bands; |
| 170 | } |
| 171 | |
| 172 | static int msm_qti_pp_put_eq_band_count_audio_mixer( |
| 173 | struct snd_kcontrol *kcontrol, |
| 174 | struct snd_ctl_elem_value *ucontrol) |
| 175 | { |
| 176 | int eq_idx = ((struct soc_multi_mixer_control *) |
| 177 | kcontrol->private_value)->reg; |
| 178 | int value = ucontrol->value.integer.value[0]; |
| 179 | |
| 180 | if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS)) |
| 181 | return -EINVAL; |
| 182 | |
| 183 | pr_debug("%s: EQ #%d bands %d\n", __func__, |
| 184 | eq_idx, value); |
| 185 | eq_data[eq_idx].num_bands = value; |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | static int msm_qti_pp_get_eq_band_audio_mixer(struct snd_kcontrol *kcontrol, |
| 190 | struct snd_ctl_elem_value *ucontrol) |
| 191 | { |
| 192 | int eq_idx = ((struct soc_multi_mixer_control *) |
| 193 | kcontrol->private_value)->reg; |
| 194 | int band_idx = ((struct soc_multi_mixer_control *) |
| 195 | kcontrol->private_value)->shift; |
| 196 | |
| 197 | if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS) || |
| 198 | (band_idx < EQ_BAND1) || (band_idx >= EQ_BAND_MAX)) |
| 199 | return -EINVAL; |
| 200 | |
| 201 | ucontrol->value.integer.value[0] = |
| 202 | eq_data[eq_idx].eq_bands[band_idx].band_idx; |
| 203 | ucontrol->value.integer.value[1] = |
| 204 | eq_data[eq_idx].eq_bands[band_idx].filter_type; |
| 205 | ucontrol->value.integer.value[2] = |
| 206 | eq_data[eq_idx].eq_bands[band_idx].center_freq_hz; |
| 207 | ucontrol->value.integer.value[3] = |
| 208 | eq_data[eq_idx].eq_bands[band_idx].filter_gain; |
| 209 | ucontrol->value.integer.value[4] = |
| 210 | eq_data[eq_idx].eq_bands[band_idx].q_factor; |
| 211 | |
| 212 | pr_debug("%s: band_idx = %d\n", __func__, |
| 213 | eq_data[eq_idx].eq_bands[band_idx].band_idx); |
| 214 | pr_debug("%s: filter_type = %d\n", __func__, |
| 215 | eq_data[eq_idx].eq_bands[band_idx].filter_type); |
| 216 | pr_debug("%s: center_freq_hz = %d\n", __func__, |
| 217 | eq_data[eq_idx].eq_bands[band_idx].center_freq_hz); |
| 218 | pr_debug("%s: filter_gain = %d\n", __func__, |
| 219 | eq_data[eq_idx].eq_bands[band_idx].filter_gain); |
| 220 | pr_debug("%s: q_factor = %d\n", __func__, |
| 221 | eq_data[eq_idx].eq_bands[band_idx].q_factor); |
| 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | static int msm_qti_pp_put_eq_band_audio_mixer(struct snd_kcontrol *kcontrol, |
| 226 | struct snd_ctl_elem_value *ucontrol) |
| 227 | { |
| 228 | int eq_idx = ((struct soc_multi_mixer_control *) |
| 229 | kcontrol->private_value)->reg; |
| 230 | int band_idx = ((struct soc_multi_mixer_control *) |
| 231 | kcontrol->private_value)->shift; |
| 232 | |
| 233 | if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS) || |
| 234 | (band_idx < EQ_BAND1) || (band_idx >= EQ_BAND_MAX)) |
| 235 | return -EINVAL; |
| 236 | |
| 237 | eq_data[eq_idx].eq_bands[band_idx].band_idx = |
| 238 | ucontrol->value.integer.value[0]; |
| 239 | eq_data[eq_idx].eq_bands[band_idx].filter_type = |
| 240 | ucontrol->value.integer.value[1]; |
| 241 | eq_data[eq_idx].eq_bands[band_idx].center_freq_hz = |
| 242 | ucontrol->value.integer.value[2]; |
| 243 | eq_data[eq_idx].eq_bands[band_idx].filter_gain = |
| 244 | ucontrol->value.integer.value[3]; |
| 245 | eq_data[eq_idx].eq_bands[band_idx].q_factor = |
| 246 | ucontrol->value.integer.value[4]; |
| 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | #ifdef CONFIG_QTI_PP |
| 251 | void msm_qti_pp_send_eq_values(int fedai_id) |
| 252 | { |
| 253 | if (eq_data[fedai_id].enable) |
| 254 | msm_qti_pp_send_eq_values_(fedai_id); |
| 255 | } |
| 256 | |
| 257 | /* CUSTOM MIXING */ |
| 258 | int msm_qti_pp_send_stereo_to_custom_stereo_cmd(int port_id, int copp_idx, |
| 259 | unsigned int session_id, |
| 260 | uint16_t op_FL_ip_FL_weight, |
| 261 | uint16_t op_FL_ip_FR_weight, |
| 262 | uint16_t op_FR_ip_FL_weight, |
| 263 | uint16_t op_FR_ip_FR_weight) |
| 264 | { |
| 265 | char *params_value; |
| 266 | int *update_params_value32, rc = 0; |
| 267 | int16_t *update_params_value16 = 0; |
| 268 | uint32_t params_length = CUSTOM_STEREO_PAYLOAD_SIZE * sizeof(uint32_t); |
| 269 | uint32_t avail_length = params_length; |
| 270 | |
| 271 | pr_debug("%s: port_id - %d, session id - %d\n", __func__, port_id, |
| 272 | session_id); |
| 273 | params_value = kzalloc(params_length, GFP_KERNEL); |
| 274 | if (!params_value) { |
| 275 | pr_err("%s, params memory alloc failed\n", __func__); |
| 276 | return -ENOMEM; |
| 277 | } |
| 278 | update_params_value32 = (int *)params_value; |
| 279 | if (avail_length < 2 * sizeof(uint32_t)) |
| 280 | goto skip_send_cmd; |
| 281 | *update_params_value32++ = MTMX_MODULE_ID_DEFAULT_CHMIXER; |
| 282 | *update_params_value32++ = DEFAULT_CHMIXER_PARAM_ID_COEFF; |
| 283 | avail_length = avail_length - (2 * sizeof(uint32_t)); |
| 284 | |
| 285 | update_params_value16 = (int16_t *)update_params_value32; |
| 286 | if (avail_length < 10 * sizeof(uint16_t)) |
| 287 | goto skip_send_cmd; |
| 288 | *update_params_value16++ = CUSTOM_STEREO_CMD_PARAM_SIZE; |
| 289 | /*for alignment only*/ |
| 290 | *update_params_value16++ = 0; |
| 291 | /*index is 32-bit param in little endian*/ |
| 292 | *update_params_value16++ = CUSTOM_STEREO_INDEX_PARAM; |
| 293 | *update_params_value16++ = 0; |
| 294 | /*for stereo mixing num out ch*/ |
| 295 | *update_params_value16++ = CUSTOM_STEREO_NUM_OUT_CH; |
| 296 | /*for stereo mixing num in ch*/ |
| 297 | *update_params_value16++ = CUSTOM_STEREO_NUM_IN_CH; |
| 298 | |
| 299 | /* Out ch map FL/FR*/ |
| 300 | *update_params_value16++ = PCM_CHANNEL_FL; |
| 301 | *update_params_value16++ = PCM_CHANNEL_FR; |
| 302 | |
| 303 | /* In ch map FL/FR*/ |
| 304 | *update_params_value16++ = PCM_CHANNEL_FL; |
| 305 | *update_params_value16++ = PCM_CHANNEL_FR; |
| 306 | avail_length = avail_length - (10 * sizeof(uint16_t)); |
| 307 | /* weighting coefficients as name suggests, |
| 308 | * mixing will be done according to these coefficients |
| 309 | */ |
| 310 | if (avail_length < 4 * sizeof(uint16_t)) |
| 311 | goto skip_send_cmd; |
| 312 | *update_params_value16++ = op_FL_ip_FL_weight; |
| 313 | *update_params_value16++ = op_FL_ip_FR_weight; |
| 314 | *update_params_value16++ = op_FR_ip_FL_weight; |
| 315 | *update_params_value16++ = op_FR_ip_FR_weight; |
| 316 | avail_length = avail_length - (4 * sizeof(uint16_t)); |
| 317 | if (params_length) { |
| 318 | rc = adm_set_stereo_to_custom_stereo(port_id, |
| 319 | copp_idx, |
| 320 | session_id, |
| 321 | params_value, |
| 322 | params_length); |
| 323 | if (rc) { |
| 324 | pr_err("%s: send params failed rc=%d\n", __func__, rc); |
| 325 | kfree(params_value); |
| 326 | return -EINVAL; |
| 327 | } |
| 328 | } |
| 329 | kfree(params_value); |
| 330 | return 0; |
| 331 | skip_send_cmd: |
| 332 | pr_err("%s: insufficient memory, send cmd failed\n", |
| 333 | __func__); |
| 334 | kfree(params_value); |
| 335 | return -ENOMEM; |
| 336 | } |
| 337 | #endif /* CONFIG_QTI_PP */ |
| 338 | |
| 339 | /* RMS */ |
| 340 | static int msm_qti_pp_get_rms_value_control(struct snd_kcontrol *kcontrol, |
| 341 | struct snd_ctl_elem_value *ucontrol) |
| 342 | { |
| 343 | int rc = 0; |
| 344 | int be_idx = 0, copp_idx; |
| 345 | char *param_value; |
| 346 | int *update_param_value; |
| 347 | uint32_t param_length = sizeof(uint32_t); |
| 348 | uint32_t param_payload_len = RMS_PAYLOAD_LEN * sizeof(uint32_t); |
| 349 | struct msm_pcm_routing_bdai_data msm_bedai; |
| 350 | |
Rohit Kumar | c70da54 | 2016-12-29 11:23:59 +0530 | [diff] [blame] | 351 | param_value = kzalloc(param_length + param_payload_len, GFP_KERNEL); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 352 | if (!param_value) |
| 353 | return -ENOMEM; |
| 354 | |
| 355 | msm_pcm_routing_acquire_lock(); |
| 356 | for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) { |
| 357 | msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai); |
| 358 | if (msm_bedai.port_id == SLIMBUS_0_TX) |
| 359 | break; |
| 360 | } |
| 361 | if ((be_idx >= MSM_BACKEND_DAI_MAX) || !msm_bedai.active) { |
| 362 | pr_err("%s, back not active to query rms be_idx:%d\n", |
| 363 | __func__, be_idx); |
| 364 | rc = -EINVAL; |
| 365 | goto get_rms_value_err; |
| 366 | } |
| 367 | copp_idx = adm_get_default_copp_idx(SLIMBUS_0_TX); |
| 368 | if ((copp_idx < 0) || (copp_idx > MAX_COPPS_PER_PORT)) { |
| 369 | pr_err("%s, no active copp to query rms copp_idx:%d\n", |
| 370 | __func__, copp_idx); |
| 371 | rc = -EINVAL; |
| 372 | goto get_rms_value_err; |
| 373 | } |
| 374 | rc = adm_get_params(SLIMBUS_0_TX, copp_idx, |
| 375 | RMS_MODULEID_APPI_PASSTHRU, |
| 376 | RMS_PARAM_FIRST_SAMPLE, |
| 377 | param_length + param_payload_len, |
| 378 | param_value); |
| 379 | if (rc) { |
| 380 | pr_err("%s: get parameters failed rc=%d\n", __func__, rc); |
| 381 | rc = -EINVAL; |
| 382 | goto get_rms_value_err; |
| 383 | } |
| 384 | update_param_value = (int *)param_value; |
| 385 | ucontrol->value.integer.value[0] = update_param_value[0]; |
| 386 | |
| 387 | pr_debug("%s: FROM DSP value[0] 0x%x\n", |
| 388 | __func__, update_param_value[0]); |
| 389 | get_rms_value_err: |
| 390 | msm_pcm_routing_release_lock(); |
| 391 | kfree(param_value); |
| 392 | return rc; |
| 393 | } |
| 394 | |
| 395 | static int msm_qti_pp_put_rms_value_control(struct snd_kcontrol *kcontrol, |
| 396 | struct snd_ctl_elem_value *ucontrol) |
| 397 | { |
| 398 | /* not used */ |
| 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | /* VOLUME */ |
| 403 | static int msm_route_fm_vol_control; |
| 404 | static int msm_afe_lb_vol_ctrl; |
| 405 | static int msm_afe_sec_mi2s_lb_vol_ctrl; |
| 406 | static int msm_afe_tert_mi2s_lb_vol_ctrl; |
| 407 | static int msm_afe_quat_mi2s_lb_vol_ctrl; |
| 408 | static int msm_afe_slimbus_8_lb_vol_ctrl; |
| 409 | static const DECLARE_TLV_DB_LINEAR(fm_rx_vol_gain, 0, INT_RX_VOL_MAX_STEPS); |
| 410 | static const DECLARE_TLV_DB_LINEAR(afe_lb_vol_gain, 0, INT_RX_VOL_MAX_STEPS); |
| 411 | |
| 412 | static int msm_qti_pp_get_fm_vol_mixer(struct snd_kcontrol *kcontrol, |
| 413 | struct snd_ctl_elem_value *ucontrol) |
| 414 | { |
| 415 | ucontrol->value.integer.value[0] = msm_route_fm_vol_control; |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | static int msm_qti_pp_set_fm_vol_mixer(struct snd_kcontrol *kcontrol, |
| 420 | struct snd_ctl_elem_value *ucontrol) |
| 421 | { |
| 422 | afe_loopback_gain(INT_FM_TX, ucontrol->value.integer.value[0]); |
| 423 | |
| 424 | msm_route_fm_vol_control = ucontrol->value.integer.value[0]; |
| 425 | |
| 426 | return 0; |
| 427 | } |
| 428 | |
| 429 | static int msm_qti_pp_get_pri_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol, |
| 430 | struct snd_ctl_elem_value *ucontrol) |
| 431 | { |
| 432 | ucontrol->value.integer.value[0] = msm_afe_lb_vol_ctrl; |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | static int msm_qti_pp_set_pri_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol, |
| 437 | struct snd_ctl_elem_value *ucontrol) |
| 438 | { |
| 439 | afe_loopback_gain(AFE_PORT_ID_PRIMARY_MI2S_TX, |
| 440 | ucontrol->value.integer.value[0]); |
| 441 | |
| 442 | msm_afe_lb_vol_ctrl = ucontrol->value.integer.value[0]; |
| 443 | |
| 444 | return 0; |
| 445 | } |
| 446 | |
| 447 | static int msm_qti_pp_get_sec_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol, |
| 448 | struct snd_ctl_elem_value *ucontrol) |
| 449 | { |
| 450 | ucontrol->value.integer.value[0] = msm_afe_sec_mi2s_lb_vol_ctrl; |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | static int msm_qti_pp_set_sec_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol, |
| 455 | struct snd_ctl_elem_value *ucontrol) |
| 456 | { |
| 457 | afe_loopback_gain(AFE_PORT_ID_SECONDARY_MI2S_TX, |
| 458 | ucontrol->value.integer.value[0]); |
| 459 | msm_afe_sec_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0]; |
| 460 | |
| 461 | return 0; |
| 462 | } |
| 463 | |
| 464 | static int msm_qti_pp_get_tert_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol, |
| 465 | struct snd_ctl_elem_value *ucontrol) |
| 466 | { |
| 467 | ucontrol->value.integer.value[0] = msm_afe_tert_mi2s_lb_vol_ctrl; |
| 468 | return 0; |
| 469 | } |
| 470 | |
| 471 | static int msm_qti_pp_set_tert_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol, |
| 472 | struct snd_ctl_elem_value *ucontrol) |
| 473 | { |
| 474 | afe_loopback_gain(AFE_PORT_ID_TERTIARY_MI2S_TX, |
| 475 | ucontrol->value.integer.value[0]); |
| 476 | msm_afe_tert_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0]; |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | static int msm_qti_pp_get_slimbus_8_lb_vol_mixer(struct snd_kcontrol *kcontrol, |
| 481 | struct snd_ctl_elem_value *ucontrol) |
| 482 | { |
| 483 | ucontrol->value.integer.value[0] = msm_afe_slimbus_8_lb_vol_ctrl; |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | static int msm_qti_pp_set_slimbus_8_lb_vol_mixer(struct snd_kcontrol *kcontrol, |
| 488 | struct snd_ctl_elem_value *ucontrol) |
| 489 | { |
| 490 | int ret = 0; |
| 491 | |
| 492 | ret = afe_loopback_gain(SLIMBUS_8_TX, |
| 493 | ucontrol->value.integer.value[0]); |
| 494 | |
| 495 | if (ret) |
| 496 | pr_err("%s: failed to set LB vol for SLIMBUS_8_TX", __func__); |
| 497 | else |
| 498 | msm_afe_slimbus_8_lb_vol_ctrl = |
| 499 | ucontrol->value.integer.value[0]; |
| 500 | |
| 501 | return ret; |
| 502 | } |
| 503 | |
Derek Chen | 5dea59a | 2016-06-06 20:40:29 -0400 | [diff] [blame] | 504 | static int msm_qti_pp_get_icc_vol_mixer(struct snd_kcontrol *kcontrol, |
| 505 | struct snd_ctl_elem_value *ucontrol) |
| 506 | { |
| 507 | ucontrol->value.integer.value[0] = msm_route_icc_vol_control; |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | static int msm_qti_pp_set_icc_vol_mixer(struct snd_kcontrol *kcontrol, |
| 512 | struct snd_ctl_elem_value *ucontrol) |
| 513 | { |
| 514 | adm_set_mic_gain(AFE_PORT_ID_QUATERNARY_TDM_TX, |
| 515 | adm_get_default_copp_idx(AFE_PORT_ID_QUATERNARY_TDM_TX), |
| 516 | ucontrol->value.integer.value[0]); |
| 517 | msm_route_icc_vol_control = ucontrol->value.integer.value[0]; |
| 518 | return 0; |
| 519 | } |
| 520 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 521 | static int msm_qti_pp_get_quat_mi2s_fm_vol_mixer(struct snd_kcontrol *kcontrol, |
| 522 | struct snd_ctl_elem_value *ucontrol) |
| 523 | { |
| 524 | ucontrol->value.integer.value[0] = msm_afe_quat_mi2s_lb_vol_ctrl; |
| 525 | return 0; |
| 526 | } |
| 527 | |
| 528 | static int msm_qti_pp_set_quat_mi2s_fm_vol_mixer(struct snd_kcontrol *kcontrol, |
| 529 | struct snd_ctl_elem_value *ucontrol) |
| 530 | { |
| 531 | afe_loopback_gain(AFE_PORT_ID_QUATERNARY_MI2S_TX, |
| 532 | ucontrol->value.integer.value[0]); |
| 533 | |
| 534 | msm_afe_quat_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0]; |
| 535 | |
| 536 | return 0; |
| 537 | } |
| 538 | |
| 539 | static int msm_qti_pp_get_hfp_vol_mixer(struct snd_kcontrol *kcontrol, |
| 540 | struct snd_ctl_elem_value *ucontrol) |
| 541 | { |
| 542 | ucontrol->value.integer.value[0] = msm_route_hfp_vol_control; |
| 543 | return 0; |
| 544 | } |
| 545 | |
| 546 | static int msm_qti_pp_set_hfp_vol_mixer(struct snd_kcontrol *kcontrol, |
| 547 | struct snd_ctl_elem_value *ucontrol) |
| 548 | { |
| 549 | afe_loopback_gain(INT_BT_SCO_TX, ucontrol->value.integer.value[0]); |
| 550 | |
| 551 | msm_route_hfp_vol_control = ucontrol->value.integer.value[0]; |
| 552 | |
| 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | static int msm_qti_pp_get_pri_auxpcm_lb_vol_mixer( |
| 557 | struct snd_kcontrol *kcontrol, |
| 558 | struct snd_ctl_elem_value *ucontrol) |
| 559 | { |
| 560 | ucontrol->value.integer.value[0] = msm_route_pri_auxpcm_lb_vol_ctrl; |
| 561 | pr_debug("%s: Volume = %ld\n", __func__, |
| 562 | ucontrol->value.integer.value[0]); |
| 563 | return 0; |
| 564 | } |
| 565 | |
| 566 | static int msm_qti_pp_set_pri_auxpcm_lb_vol_mixer( |
| 567 | struct snd_kcontrol *kcontrol, |
| 568 | struct snd_ctl_elem_value *ucontrol) |
| 569 | { |
| 570 | struct soc_mixer_control *mc = |
| 571 | (struct soc_mixer_control *)kcontrol->private_value; |
| 572 | |
| 573 | afe_loopback_gain(mc->reg, ucontrol->value.integer.value[0]); |
| 574 | |
| 575 | msm_route_pri_auxpcm_lb_vol_ctrl = ucontrol->value.integer.value[0]; |
| 576 | |
| 577 | return 0; |
| 578 | } |
| 579 | |
| 580 | static int msm_qti_pp_get_sec_auxpcm_lb_vol_mixer( |
| 581 | struct snd_kcontrol *kcontrol, |
| 582 | struct snd_ctl_elem_value *ucontrol) |
| 583 | { |
| 584 | ucontrol->value.integer.value[0] = msm_route_sec_auxpcm_lb_vol_ctrl; |
| 585 | pr_debug("%s: Volume = %ld\n", __func__, |
| 586 | ucontrol->value.integer.value[0]); |
| 587 | return 0; |
| 588 | } |
| 589 | |
| 590 | static int msm_qti_pp_set_sec_auxpcm_lb_vol_mixer( |
| 591 | struct snd_kcontrol *kcontrol, |
| 592 | struct snd_ctl_elem_value *ucontrol) |
| 593 | { |
| 594 | struct soc_mixer_control *mc = |
| 595 | (struct soc_mixer_control *)kcontrol->private_value; |
| 596 | |
| 597 | afe_loopback_gain(mc->reg, ucontrol->value.integer.value[0]); |
| 598 | |
| 599 | msm_route_sec_auxpcm_lb_vol_ctrl = ucontrol->value.integer.value[0]; |
| 600 | |
| 601 | return 0; |
| 602 | } |
| 603 | |
| 604 | static int msm_qti_pp_get_channel_map_mixer(struct snd_kcontrol *kcontrol, |
| 605 | struct snd_ctl_elem_value *ucontrol) |
| 606 | { |
Xiaojun Sang | 09c837c | 2016-12-16 16:25:27 +0800 | [diff] [blame] | 607 | char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL] = {0}; |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 608 | int i; |
| 609 | |
| 610 | adm_get_multi_ch_map(channel_map, ADM_PATH_PLAYBACK); |
| 611 | for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++) |
| 612 | ucontrol->value.integer.value[i] = |
| 613 | (unsigned int) channel_map[i]; |
| 614 | return 0; |
| 615 | } |
| 616 | |
| 617 | static int msm_qti_pp_put_channel_map_mixer(struct snd_kcontrol *kcontrol, |
| 618 | struct snd_ctl_elem_value *ucontrol) |
| 619 | { |
| 620 | char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL]; |
| 621 | int i; |
| 622 | |
| 623 | for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL; i++) |
| 624 | channel_map[i] = (char)(ucontrol->value.integer.value[i]); |
| 625 | adm_set_multi_ch_map(channel_map, ADM_PATH_PLAYBACK); |
| 626 | |
| 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | /* Audio Sphere functions */ |
| 631 | |
| 632 | static void msm_qti_pp_asphere_init_state(void) |
| 633 | { |
| 634 | int i; |
| 635 | |
| 636 | if (asphere_state.initialized) |
| 637 | return; |
| 638 | asphere_state.initialized = true; |
| 639 | for (i = 0; i < AFE_MAX_PORTS; i++) { |
| 640 | asphere_state.port_id[i] = -1; |
| 641 | asphere_state.copp_idx[i] = -1; |
| 642 | } |
| 643 | asphere_state.enabled = 0; |
| 644 | asphere_state.strength = 0; |
| 645 | asphere_state.mode = 0; |
| 646 | asphere_state.version = 0; |
| 647 | asphere_state.enabled_prev = 0; |
| 648 | asphere_state.strength_prev = 0; |
| 649 | } |
| 650 | |
| 651 | static int msm_qti_pp_asphere_send_params(int port_id, int copp_idx, bool force) |
| 652 | { |
| 653 | char *params_value = NULL; |
| 654 | uint32_t *update_params_value = NULL; |
| 655 | uint32_t param_size = sizeof(uint32_t) + |
| 656 | sizeof(struct adm_param_data_v5); |
| 657 | int params_length = 0, param_count = 0, ret = 0; |
| 658 | bool set_enable = force || |
| 659 | (asphere_state.enabled != asphere_state.enabled_prev); |
| 660 | bool set_strength = asphere_state.enabled == 1 && (set_enable || |
| 661 | (asphere_state.strength != asphere_state.strength_prev)); |
| 662 | |
| 663 | if (set_enable) |
| 664 | param_count++; |
| 665 | if (set_strength) |
| 666 | param_count++; |
| 667 | params_length = param_count * param_size; |
| 668 | |
| 669 | pr_debug("%s: port_id %d, copp_id %d, forced %d, param_count %d\n", |
| 670 | __func__, port_id, copp_idx, force, param_count); |
| 671 | pr_debug("%s: enable prev:%u cur:%u, strength prev:%u cur:%u\n", |
| 672 | __func__, asphere_state.enabled_prev, asphere_state.enabled, |
| 673 | asphere_state.strength_prev, asphere_state.strength); |
| 674 | |
| 675 | if (params_length > 0) |
| 676 | params_value = kzalloc(params_length, GFP_KERNEL); |
| 677 | if (!params_value) { |
| 678 | pr_err("%s, params memory alloc failed\n", __func__); |
| 679 | return -ENOMEM; |
| 680 | } |
| 681 | update_params_value = (uint32_t *)params_value; |
| 682 | params_length = 0; |
| 683 | if (set_strength) { |
| 684 | /* add strength command */ |
| 685 | *update_params_value++ = AUDPROC_MODULE_ID_AUDIOSPHERE; |
| 686 | *update_params_value++ = AUDPROC_PARAM_ID_AUDIOSPHERE_STRENGTH; |
| 687 | *update_params_value++ = sizeof(uint32_t); |
| 688 | *update_params_value++ = asphere_state.strength; |
| 689 | params_length += param_size; |
| 690 | } |
| 691 | if (set_enable) { |
| 692 | /* add enable command */ |
| 693 | *update_params_value++ = AUDPROC_MODULE_ID_AUDIOSPHERE; |
| 694 | *update_params_value++ = AUDPROC_PARAM_ID_AUDIOSPHERE_ENABLE; |
| 695 | *update_params_value++ = sizeof(uint32_t); |
| 696 | *update_params_value++ = asphere_state.enabled; |
| 697 | params_length += param_size; |
| 698 | } |
| 699 | pr_debug("%s, param length: %d\n", __func__, params_length); |
| 700 | if (params_length) { |
| 701 | ret = adm_send_params_v5(port_id, copp_idx, |
| 702 | params_value, params_length); |
| 703 | if (ret) { |
| 704 | pr_err("%s: setting param failed with err=%d\n", |
| 705 | __func__, ret); |
| 706 | kfree(params_value); |
| 707 | return -EINVAL; |
| 708 | } |
| 709 | } |
| 710 | kfree(params_value); |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | #if defined(CONFIG_QTI_PP) && defined(CONFIG_QTI_PP_AUDIOSPHERE) |
| 715 | int msm_qti_pp_asphere_init(int port_id, int copp_idx) |
| 716 | { |
| 717 | int index = adm_validate_and_get_port_index(port_id); |
| 718 | |
| 719 | pr_debug("%s, port_id %d, copp_id %d\n", __func__, port_id, copp_idx); |
| 720 | if (index < 0) { |
| 721 | pr_err("%s: Invalid port idx %d port_id %#x\n", __func__, index, |
| 722 | port_id); |
| 723 | return -EINVAL; |
| 724 | } |
| 725 | msm_qti_pp_asphere_init_state(); |
| 726 | |
| 727 | asphere_state.port_id[index] = port_id; |
| 728 | asphere_state.copp_idx[index] = copp_idx; |
| 729 | |
| 730 | if (asphere_state.enabled) |
| 731 | msm_qti_pp_asphere_send_params(port_id, copp_idx, true); |
| 732 | |
| 733 | return 0; |
| 734 | } |
| 735 | |
| 736 | void msm_qti_pp_asphere_deinit(int port_id) |
| 737 | { |
| 738 | int index = adm_validate_and_get_port_index(port_id); |
| 739 | |
| 740 | pr_debug("%s, port_id %d\n", __func__, port_id); |
| 741 | if (index < 0) { |
| 742 | pr_err("%s: Invalid port idx %d port_id %#x\n", __func__, index, |
| 743 | port_id); |
| 744 | return; |
| 745 | } |
| 746 | |
| 747 | if (asphere_state.port_id[index] == port_id) { |
| 748 | asphere_state.port_id[index] = -1; |
| 749 | asphere_state.copp_idx[index] = -1; |
| 750 | } |
| 751 | } |
| 752 | #endif |
| 753 | |
| 754 | static int msm_qti_pp_asphere_get(struct snd_kcontrol *kcontrol, |
| 755 | struct snd_ctl_elem_value *ucontrol) |
| 756 | { |
| 757 | if (!asphere_state.initialized) |
| 758 | return -EAGAIN; |
| 759 | ucontrol->value.integer.value[0] = asphere_state.enabled; |
| 760 | ucontrol->value.integer.value[1] = asphere_state.strength; |
| 761 | pr_debug("%s, enable %u, strength %u\n", __func__, |
| 762 | asphere_state.enabled, asphere_state.strength); |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | static int msm_qti_pp_asphere_set(struct snd_kcontrol *kcontrol, |
| 767 | struct snd_ctl_elem_value *ucontrol) |
| 768 | { |
| 769 | int32_t enable = ucontrol->value.integer.value[0]; |
| 770 | int32_t strength = ucontrol->value.integer.value[1]; |
| 771 | int i; |
| 772 | |
| 773 | pr_debug("%s, enable %u, strength %u\n", __func__, enable, strength); |
| 774 | |
| 775 | msm_qti_pp_asphere_init_state(); |
| 776 | |
| 777 | if (enable == 0 || enable == 1) { |
| 778 | asphere_state.enabled_prev = asphere_state.enabled; |
| 779 | asphere_state.enabled = enable; |
| 780 | } |
| 781 | |
| 782 | if (strength >= 0 && strength <= 1000) { |
| 783 | asphere_state.strength_prev = asphere_state.strength; |
| 784 | asphere_state.strength = strength; |
| 785 | } |
| 786 | |
| 787 | if (asphere_state.strength != asphere_state.strength_prev || |
| 788 | asphere_state.enabled != asphere_state.enabled_prev) { |
| 789 | for (i = 0; i < AFE_MAX_PORTS; i++) { |
| 790 | if (asphere_state.port_id[i] >= 0) |
| 791 | msm_qti_pp_asphere_send_params( |
| 792 | asphere_state.port_id[i], |
| 793 | asphere_state.copp_idx[i], |
| 794 | false); |
| 795 | } |
| 796 | } |
| 797 | return 0; |
| 798 | } |
| 799 | |
Rahul Sharma | 6e83698 | 2016-12-09 00:45:44 +0530 | [diff] [blame] | 800 | static int msm_multichannel_ec_primary_mic_ch_put(struct snd_kcontrol *kcontrol, |
| 801 | struct snd_ctl_elem_value *ucontrol) |
| 802 | { |
| 803 | int ret = 0; |
| 804 | int copp_idx = 0; |
| 805 | int port_id = AFE_PORT_ID_QUATERNARY_TDM_TX; |
| 806 | |
| 807 | msm_multichannel_ec_primary_mic_ch = ucontrol->value.integer.value[0]; |
| 808 | pr_debug("%s: msm_multichannel_ec_primary_mic_ch = %u\n", |
| 809 | __func__, msm_multichannel_ec_primary_mic_ch); |
| 810 | copp_idx = adm_get_default_copp_idx(port_id); |
| 811 | if ((copp_idx < 0) || (copp_idx > MAX_COPPS_PER_PORT)) { |
| 812 | pr_err("%s : no active copp to query multichannel ec copp_idx: %u\n", |
| 813 | __func__, copp_idx); |
| 814 | return -EINVAL; |
| 815 | } |
| 816 | adm_send_set_multichannel_ec_primary_mic_ch(port_id, copp_idx, |
| 817 | msm_multichannel_ec_primary_mic_ch); |
| 818 | |
| 819 | return ret; |
| 820 | } |
| 821 | |
| 822 | static int msm_multichannel_ec_primary_mic_ch_get(struct snd_kcontrol *kcontrol, |
| 823 | struct snd_ctl_elem_value *ucontrol) |
| 824 | { |
| 825 | ucontrol->value.integer.value[0] = msm_multichannel_ec_primary_mic_ch; |
| 826 | pr_debug("%s: msm_multichannel_ec_primary_mic_ch = %lu\n", |
| 827 | __func__, ucontrol->value.integer.value[0]); |
| 828 | return 0; |
| 829 | } |
| 830 | |
| 831 | static const struct snd_kcontrol_new msm_multichannel_ec_controls[] = { |
| 832 | SOC_SINGLE_EXT("Multichannel EC Primary Mic Ch", SND_SOC_NOPM, 0, |
| 833 | 0xFFFFFFFF, 0, msm_multichannel_ec_primary_mic_ch_get, |
| 834 | msm_multichannel_ec_primary_mic_ch_put), |
| 835 | }; |
| 836 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 837 | static const struct snd_kcontrol_new int_fm_vol_mixer_controls[] = { |
| 838 | SOC_SINGLE_EXT_TLV("Internal FM RX Volume", SND_SOC_NOPM, 0, |
| 839 | INT_RX_VOL_GAIN, 0, msm_qti_pp_get_fm_vol_mixer, |
| 840 | msm_qti_pp_set_fm_vol_mixer, fm_rx_vol_gain), |
| 841 | SOC_SINGLE_EXT_TLV("Quat MI2S FM RX Volume", SND_SOC_NOPM, 0, |
| 842 | INT_RX_VOL_GAIN, 0, msm_qti_pp_get_quat_mi2s_fm_vol_mixer, |
| 843 | msm_qti_pp_set_quat_mi2s_fm_vol_mixer, fm_rx_vol_gain), |
| 844 | }; |
| 845 | |
| 846 | static const struct snd_kcontrol_new pri_mi2s_lb_vol_mixer_controls[] = { |
| 847 | SOC_SINGLE_EXT_TLV("PRI MI2S LOOPBACK Volume", SND_SOC_NOPM, 0, |
| 848 | INT_RX_VOL_GAIN, 0, msm_qti_pp_get_pri_mi2s_lb_vol_mixer, |
| 849 | msm_qti_pp_set_pri_mi2s_lb_vol_mixer, afe_lb_vol_gain), |
| 850 | }; |
| 851 | |
| 852 | static const struct snd_kcontrol_new sec_mi2s_lb_vol_mixer_controls[] = { |
| 853 | SOC_SINGLE_EXT_TLV("SEC MI2S LOOPBACK Volume", SND_SOC_NOPM, 0, |
| 854 | INT_RX_VOL_GAIN, 0, msm_qti_pp_get_sec_mi2s_lb_vol_mixer, |
| 855 | msm_qti_pp_set_sec_mi2s_lb_vol_mixer, afe_lb_vol_gain), |
| 856 | }; |
| 857 | |
| 858 | static const struct snd_kcontrol_new tert_mi2s_lb_vol_mixer_controls[] = { |
| 859 | SOC_SINGLE_EXT_TLV("Tert MI2S LOOPBACK Volume", SND_SOC_NOPM, 0, |
| 860 | INT_RX_VOL_GAIN, 0, msm_qti_pp_get_tert_mi2s_lb_vol_mixer, |
| 861 | msm_qti_pp_set_tert_mi2s_lb_vol_mixer, afe_lb_vol_gain), |
| 862 | }; |
| 863 | |
| 864 | static const struct snd_kcontrol_new slimbus_8_lb_vol_mixer_controls[] = { |
| 865 | SOC_SINGLE_EXT_TLV("SLIMBUS_8 LOOPBACK Volume", SND_SOC_NOPM, 0, |
| 866 | INT_RX_VOL_GAIN, 0, msm_qti_pp_get_slimbus_8_lb_vol_mixer, |
| 867 | msm_qti_pp_set_slimbus_8_lb_vol_mixer, afe_lb_vol_gain), |
| 868 | }; |
| 869 | |
| 870 | static const struct snd_kcontrol_new int_hfp_vol_mixer_controls[] = { |
| 871 | SOC_SINGLE_EXT_TLV("Internal HFP RX Volume", SND_SOC_NOPM, 0, |
| 872 | INT_RX_VOL_GAIN, 0, msm_qti_pp_get_hfp_vol_mixer, |
| 873 | msm_qti_pp_set_hfp_vol_mixer, hfp_rx_vol_gain), |
| 874 | }; |
| 875 | |
Derek Chen | 5dea59a | 2016-06-06 20:40:29 -0400 | [diff] [blame] | 876 | static const struct snd_kcontrol_new int_icc_vol_mixer_controls[] = { |
| 877 | SOC_SINGLE_EXT_TLV("Internal ICC Volume", SND_SOC_NOPM, 0, |
| 878 | INT_RX_VOL_GAIN, 0, msm_qti_pp_get_icc_vol_mixer, |
| 879 | msm_qti_pp_set_icc_vol_mixer, icc_rx_vol_gain), |
| 880 | }; |
| 881 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 882 | static const struct snd_kcontrol_new pri_auxpcm_lb_vol_mixer_controls[] = { |
| 883 | SOC_SINGLE_EXT_TLV("PRI AUXPCM LOOPBACK Volume", |
| 884 | AFE_PORT_ID_PRIMARY_PCM_TX, 0, INT_RX_VOL_GAIN, 0, |
| 885 | msm_qti_pp_get_pri_auxpcm_lb_vol_mixer, |
| 886 | msm_qti_pp_set_pri_auxpcm_lb_vol_mixer, |
| 887 | pri_auxpcm_lb_vol_gain), |
| 888 | }; |
| 889 | |
| 890 | static const struct snd_kcontrol_new sec_auxpcm_lb_vol_mixer_controls[] = { |
| 891 | SOC_SINGLE_EXT_TLV("SEC AUXPCM LOOPBACK Volume", |
| 892 | AFE_PORT_ID_SECONDARY_PCM_TX, 0, INT_RX_VOL_GAIN, 0, |
| 893 | msm_qti_pp_get_sec_auxpcm_lb_vol_mixer, |
| 894 | msm_qti_pp_set_sec_auxpcm_lb_vol_mixer, |
| 895 | sec_auxpcm_lb_vol_gain), |
| 896 | }; |
| 897 | |
| 898 | static const struct snd_kcontrol_new multi_ch_channel_map_mixer_controls[] = { |
| 899 | SOC_SINGLE_MULTI_EXT("Playback Device Channel Map", SND_SOC_NOPM, 0, 16, |
| 900 | 0, 8, msm_qti_pp_get_channel_map_mixer, |
| 901 | msm_qti_pp_put_channel_map_mixer), |
| 902 | }; |
| 903 | |
| 904 | |
| 905 | static const struct snd_kcontrol_new get_rms_controls[] = { |
| 906 | SOC_SINGLE_EXT("Get RMS", SND_SOC_NOPM, 0, 0xFFFFFFFF, |
| 907 | 0, msm_qti_pp_get_rms_value_control, msm_qti_pp_put_rms_value_control), |
| 908 | }; |
| 909 | |
| 910 | static const struct snd_kcontrol_new eq_enable_mixer_controls[] = { |
| 911 | SOC_SINGLE_EXT("MultiMedia1 EQ Enable", SND_SOC_NOPM, |
| 912 | MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_qti_pp_get_eq_enable_mixer, |
| 913 | msm_qti_pp_put_eq_enable_mixer), |
| 914 | SOC_SINGLE_EXT("MultiMedia2 EQ Enable", SND_SOC_NOPM, |
| 915 | MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_qti_pp_get_eq_enable_mixer, |
| 916 | msm_qti_pp_put_eq_enable_mixer), |
| 917 | SOC_SINGLE_EXT("MultiMedia3 EQ Enable", SND_SOC_NOPM, |
| 918 | MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_qti_pp_get_eq_enable_mixer, |
| 919 | msm_qti_pp_put_eq_enable_mixer), |
| 920 | }; |
| 921 | |
| 922 | static const struct snd_kcontrol_new eq_band_mixer_controls[] = { |
| 923 | SOC_SINGLE_EXT("MultiMedia1 EQ Band Count", SND_SOC_NOPM, |
| 924 | MSM_FRONTEND_DAI_MULTIMEDIA1, 11, 0, |
| 925 | msm_qti_pp_get_eq_band_count_audio_mixer, |
| 926 | msm_qti_pp_put_eq_band_count_audio_mixer), |
| 927 | SOC_SINGLE_EXT("MultiMedia2 EQ Band Count", SND_SOC_NOPM, |
| 928 | MSM_FRONTEND_DAI_MULTIMEDIA2, 11, 0, |
| 929 | msm_qti_pp_get_eq_band_count_audio_mixer, |
| 930 | msm_qti_pp_put_eq_band_count_audio_mixer), |
| 931 | SOC_SINGLE_EXT("MultiMedia3 EQ Band Count", SND_SOC_NOPM, |
| 932 | MSM_FRONTEND_DAI_MULTIMEDIA3, 11, 0, |
| 933 | msm_qti_pp_get_eq_band_count_audio_mixer, |
| 934 | msm_qti_pp_put_eq_band_count_audio_mixer), |
| 935 | }; |
| 936 | |
| 937 | static const struct snd_kcontrol_new eq_coeff_mixer_controls[] = { |
| 938 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band1", EQ_BAND1, |
| 939 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 940 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 941 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band2", EQ_BAND2, |
| 942 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 943 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 944 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band3", EQ_BAND3, |
| 945 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 946 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 947 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band4", EQ_BAND4, |
| 948 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 949 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 950 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band5", EQ_BAND5, |
| 951 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 952 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 953 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band6", EQ_BAND6, |
| 954 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 955 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 956 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band7", EQ_BAND7, |
| 957 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 958 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 959 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band8", EQ_BAND8, |
| 960 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 961 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 962 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band9", EQ_BAND9, |
| 963 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 964 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 965 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band10", EQ_BAND10, |
| 966 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 967 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 968 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band11", EQ_BAND11, |
| 969 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 970 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 971 | SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band12", EQ_BAND12, |
| 972 | MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5, |
| 973 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 974 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band1", EQ_BAND1, |
| 975 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 976 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 977 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band2", EQ_BAND2, |
| 978 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 979 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 980 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band3", EQ_BAND3, |
| 981 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 982 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 983 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band4", EQ_BAND4, |
| 984 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 985 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 986 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band5", EQ_BAND5, |
| 987 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 988 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 989 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band6", EQ_BAND6, |
| 990 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 991 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 992 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band7", EQ_BAND7, |
| 993 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 994 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 995 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band8", EQ_BAND8, |
| 996 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 997 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 998 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band9", EQ_BAND9, |
| 999 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 1000 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1001 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band10", EQ_BAND10, |
| 1002 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 1003 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1004 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band11", EQ_BAND11, |
| 1005 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 1006 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1007 | SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band12", EQ_BAND12, |
| 1008 | MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5, |
| 1009 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1010 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band1", EQ_BAND1, |
| 1011 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1012 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1013 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band2", EQ_BAND2, |
| 1014 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1015 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1016 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band3", EQ_BAND3, |
| 1017 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1018 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1019 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band4", EQ_BAND4, |
| 1020 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1021 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1022 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band5", EQ_BAND5, |
| 1023 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1024 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1025 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band6", EQ_BAND6, |
| 1026 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1027 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1028 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band7", EQ_BAND7, |
| 1029 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1030 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1031 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band8", EQ_BAND8, |
| 1032 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1033 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1034 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band9", EQ_BAND9, |
| 1035 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1036 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1037 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band10", EQ_BAND10, |
| 1038 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1039 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1040 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band11", EQ_BAND11, |
| 1041 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1042 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1043 | SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band12", EQ_BAND12, |
| 1044 | MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5, |
| 1045 | msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer), |
| 1046 | }; |
| 1047 | |
| 1048 | static const struct snd_kcontrol_new asphere_mixer_controls[] = { |
| 1049 | SOC_SINGLE_MULTI_EXT("MSM ASphere Set Param", SND_SOC_NOPM, 0, |
| 1050 | 0xFFFFFFFF, 0, 2, msm_qti_pp_asphere_get, msm_qti_pp_asphere_set), |
| 1051 | }; |
| 1052 | |
| 1053 | #ifdef CONFIG_QTI_PP |
| 1054 | void msm_qti_pp_add_controls(struct snd_soc_platform *platform) |
| 1055 | { |
| 1056 | snd_soc_add_platform_controls(platform, int_fm_vol_mixer_controls, |
| 1057 | ARRAY_SIZE(int_fm_vol_mixer_controls)); |
| 1058 | |
| 1059 | snd_soc_add_platform_controls(platform, pri_mi2s_lb_vol_mixer_controls, |
| 1060 | ARRAY_SIZE(pri_mi2s_lb_vol_mixer_controls)); |
| 1061 | |
| 1062 | snd_soc_add_platform_controls(platform, sec_mi2s_lb_vol_mixer_controls, |
| 1063 | ARRAY_SIZE(sec_mi2s_lb_vol_mixer_controls)); |
| 1064 | |
| 1065 | snd_soc_add_platform_controls(platform, tert_mi2s_lb_vol_mixer_controls, |
| 1066 | ARRAY_SIZE(tert_mi2s_lb_vol_mixer_controls)); |
| 1067 | |
| 1068 | snd_soc_add_platform_controls(platform, slimbus_8_lb_vol_mixer_controls, |
| 1069 | ARRAY_SIZE(slimbus_8_lb_vol_mixer_controls)); |
| 1070 | |
| 1071 | snd_soc_add_platform_controls(platform, int_hfp_vol_mixer_controls, |
| 1072 | ARRAY_SIZE(int_hfp_vol_mixer_controls)); |
| 1073 | |
Derek Chen | 5dea59a | 2016-06-06 20:40:29 -0400 | [diff] [blame] | 1074 | snd_soc_add_platform_controls(platform, int_icc_vol_mixer_controls, |
| 1075 | ARRAY_SIZE(int_icc_vol_mixer_controls)); |
| 1076 | |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1077 | snd_soc_add_platform_controls(platform, |
| 1078 | pri_auxpcm_lb_vol_mixer_controls, |
| 1079 | ARRAY_SIZE(pri_auxpcm_lb_vol_mixer_controls)); |
| 1080 | |
| 1081 | snd_soc_add_platform_controls(platform, |
| 1082 | sec_auxpcm_lb_vol_mixer_controls, |
| 1083 | ARRAY_SIZE(sec_auxpcm_lb_vol_mixer_controls)); |
| 1084 | |
| 1085 | snd_soc_add_platform_controls(platform, |
| 1086 | multi_ch_channel_map_mixer_controls, |
| 1087 | ARRAY_SIZE(multi_ch_channel_map_mixer_controls)); |
| 1088 | |
| 1089 | snd_soc_add_platform_controls(platform, get_rms_controls, |
| 1090 | ARRAY_SIZE(get_rms_controls)); |
| 1091 | |
| 1092 | snd_soc_add_platform_controls(platform, eq_enable_mixer_controls, |
| 1093 | ARRAY_SIZE(eq_enable_mixer_controls)); |
| 1094 | |
| 1095 | snd_soc_add_platform_controls(platform, eq_band_mixer_controls, |
| 1096 | ARRAY_SIZE(eq_band_mixer_controls)); |
| 1097 | |
| 1098 | snd_soc_add_platform_controls(platform, eq_coeff_mixer_controls, |
| 1099 | ARRAY_SIZE(eq_coeff_mixer_controls)); |
| 1100 | |
| 1101 | snd_soc_add_platform_controls(platform, asphere_mixer_controls, |
| 1102 | ARRAY_SIZE(asphere_mixer_controls)); |
Rahul Sharma | 6e83698 | 2016-12-09 00:45:44 +0530 | [diff] [blame] | 1103 | |
| 1104 | snd_soc_add_platform_controls(platform, msm_multichannel_ec_controls, |
| 1105 | ARRAY_SIZE(msm_multichannel_ec_controls)); |
Banajit Goswami | 0530e2f | 2016-12-09 21:34:37 -0800 | [diff] [blame] | 1106 | } |
| 1107 | #endif /* CONFIG_QTI_PP */ |