msm-qti-pp-config.c 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/err.h>
  5. #include <linux/module.h>
  6. #include <linux/bitops.h>
  7. #include <linux/mutex.h>
  8. #include <sound/control.h>
  9. #include <sound/asound.h>
  10. #include <sound/tlv.h>
  11. #include <dsp/q6adm-v2.h>
  12. #include <dsp/q6asm-v2.h>
  13. #include <dsp/q6afe-v2.h>
  14. #include <dsp/q6audio-v2.h>
  15. #include <dsp/q6common.h>
  16. #include "msm-qti-pp-config.h"
  17. #include "msm-pcm-routing-v2.h"
  18. /* EQUALIZER */
  19. /* Equal to Frontend after last of the MULTIMEDIA SESSIONS */
  20. #define MAX_EQ_SESSIONS (MSM_FRONTEND_DAI_MAX + 1)
  21. #define CHMIX_CFG_CONST_PARAM_SIZE 4
  22. enum {
  23. EQ_BAND1 = 0,
  24. EQ_BAND2,
  25. EQ_BAND3,
  26. EQ_BAND4,
  27. EQ_BAND5,
  28. EQ_BAND6,
  29. EQ_BAND7,
  30. EQ_BAND8,
  31. EQ_BAND9,
  32. EQ_BAND10,
  33. EQ_BAND11,
  34. EQ_BAND12,
  35. EQ_BAND_MAX,
  36. };
  37. /* Audio Sphere data structures */
  38. struct msm_audio_pp_asphere_state_s {
  39. uint32_t enabled;
  40. uint32_t strength;
  41. uint32_t mode;
  42. uint32_t version;
  43. int port_id[AFE_MAX_PORTS];
  44. int copp_idx[AFE_MAX_PORTS];
  45. bool initialized;
  46. uint32_t enabled_prev;
  47. uint32_t strength_prev;
  48. };
  49. static struct msm_audio_pp_asphere_state_s asphere_state;
  50. struct msm_audio_eq_stream_config eq_data[MAX_EQ_SESSIONS];
  51. static int msm_route_hfp_vol_control;
  52. static const DECLARE_TLV_DB_LINEAR(hfp_rx_vol_gain, 0,
  53. INT_RX_VOL_MAX_STEPS);
  54. static int msm_route_icc_vol_control;
  55. static const DECLARE_TLV_DB_LINEAR(icc_rx_vol_gain, 0,
  56. INT_RX_VOL_MAX_STEPS);
  57. static int msm_route_pri_auxpcm_lb_vol_ctrl;
  58. static const DECLARE_TLV_DB_LINEAR(pri_auxpcm_lb_vol_gain, 0,
  59. INT_RX_VOL_MAX_STEPS);
  60. static int msm_route_sec_auxpcm_lb_vol_ctrl;
  61. static const DECLARE_TLV_DB_LINEAR(sec_auxpcm_lb_vol_gain, 0,
  62. INT_RX_VOL_MAX_STEPS);
  63. static int msm_multichannel_ec_primary_mic_ch;
  64. static int msm_ffecns_effect;
  65. static void msm_qti_pp_send_eq_values_(int eq_idx)
  66. {
  67. int result;
  68. struct msm_pcm_routing_fdai_data fe_dai;
  69. struct audio_client *ac = NULL;
  70. msm_pcm_routing_get_fedai_info(eq_idx, SESSION_TYPE_RX, &fe_dai);
  71. ac = q6asm_get_audio_client(fe_dai.strm_id);
  72. if (ac == NULL) {
  73. pr_err("%s: Could not get audio client for session: %d\n",
  74. __func__, fe_dai.strm_id);
  75. goto done;
  76. }
  77. result = q6asm_equalizer(ac, &eq_data[eq_idx]);
  78. if (result < 0)
  79. pr_err("%s: Call to ASM equalizer failed, returned = %d\n",
  80. __func__, result);
  81. done:
  82. return;
  83. }
  84. static int msm_qti_pp_get_eq_enable_mixer(struct snd_kcontrol *kcontrol,
  85. struct snd_ctl_elem_value *ucontrol)
  86. {
  87. int eq_idx = ((struct soc_multi_mixer_control *)
  88. kcontrol->private_value)->reg;
  89. if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS))
  90. return -EINVAL;
  91. ucontrol->value.integer.value[0] = eq_data[eq_idx].enable;
  92. pr_debug("%s: EQ #%d enable %d\n", __func__,
  93. eq_idx, eq_data[eq_idx].enable);
  94. return 0;
  95. }
  96. static int msm_qti_pp_put_eq_enable_mixer(struct snd_kcontrol *kcontrol,
  97. struct snd_ctl_elem_value *ucontrol)
  98. {
  99. int eq_idx = ((struct soc_multi_mixer_control *)
  100. kcontrol->private_value)->reg;
  101. int value = ucontrol->value.integer.value[0];
  102. if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS))
  103. return -EINVAL;
  104. pr_debug("%s: EQ #%d enable %d\n", __func__,
  105. eq_idx, value);
  106. eq_data[eq_idx].enable = value;
  107. msm_pcm_routing_acquire_lock();
  108. msm_qti_pp_send_eq_values_(eq_idx);
  109. msm_pcm_routing_release_lock();
  110. return 0;
  111. }
  112. static int msm_qti_pp_get_eq_band_count_audio_mixer(
  113. struct snd_kcontrol *kcontrol,
  114. struct snd_ctl_elem_value *ucontrol)
  115. {
  116. int eq_idx = ((struct soc_multi_mixer_control *)
  117. kcontrol->private_value)->reg;
  118. if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS))
  119. return -EINVAL;
  120. ucontrol->value.integer.value[0] = eq_data[eq_idx].num_bands;
  121. pr_debug("%s: EQ #%d bands %d\n", __func__,
  122. eq_idx, eq_data[eq_idx].num_bands);
  123. return eq_data[eq_idx].num_bands;
  124. }
  125. static int msm_qti_pp_put_eq_band_count_audio_mixer(
  126. struct snd_kcontrol *kcontrol,
  127. struct snd_ctl_elem_value *ucontrol)
  128. {
  129. int eq_idx = ((struct soc_multi_mixer_control *)
  130. kcontrol->private_value)->reg;
  131. int value = ucontrol->value.integer.value[0];
  132. if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS))
  133. return -EINVAL;
  134. pr_debug("%s: EQ #%d bands %d\n", __func__,
  135. eq_idx, value);
  136. eq_data[eq_idx].num_bands = value;
  137. return 0;
  138. }
  139. static int msm_qti_pp_get_eq_band_audio_mixer(struct snd_kcontrol *kcontrol,
  140. struct snd_ctl_elem_value *ucontrol)
  141. {
  142. int eq_idx = ((struct soc_multi_mixer_control *)
  143. kcontrol->private_value)->reg;
  144. int band_idx = ((struct soc_multi_mixer_control *)
  145. kcontrol->private_value)->shift;
  146. if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS) ||
  147. (band_idx < EQ_BAND1) || (band_idx >= EQ_BAND_MAX))
  148. return -EINVAL;
  149. ucontrol->value.integer.value[0] =
  150. eq_data[eq_idx].eq_bands[band_idx].band_idx;
  151. ucontrol->value.integer.value[1] =
  152. eq_data[eq_idx].eq_bands[band_idx].filter_type;
  153. ucontrol->value.integer.value[2] =
  154. eq_data[eq_idx].eq_bands[band_idx].center_freq_hz;
  155. ucontrol->value.integer.value[3] =
  156. eq_data[eq_idx].eq_bands[band_idx].filter_gain;
  157. ucontrol->value.integer.value[4] =
  158. eq_data[eq_idx].eq_bands[band_idx].q_factor;
  159. pr_debug("%s: band_idx = %d\n", __func__,
  160. eq_data[eq_idx].eq_bands[band_idx].band_idx);
  161. pr_debug("%s: filter_type = %d\n", __func__,
  162. eq_data[eq_idx].eq_bands[band_idx].filter_type);
  163. pr_debug("%s: center_freq_hz = %d\n", __func__,
  164. eq_data[eq_idx].eq_bands[band_idx].center_freq_hz);
  165. pr_debug("%s: filter_gain = %d\n", __func__,
  166. eq_data[eq_idx].eq_bands[band_idx].filter_gain);
  167. pr_debug("%s: q_factor = %d\n", __func__,
  168. eq_data[eq_idx].eq_bands[band_idx].q_factor);
  169. return 0;
  170. }
  171. static int msm_qti_pp_put_eq_band_audio_mixer(struct snd_kcontrol *kcontrol,
  172. struct snd_ctl_elem_value *ucontrol)
  173. {
  174. int eq_idx = ((struct soc_multi_mixer_control *)
  175. kcontrol->private_value)->reg;
  176. int band_idx = ((struct soc_multi_mixer_control *)
  177. kcontrol->private_value)->shift;
  178. if ((eq_idx < 0) || (eq_idx >= MAX_EQ_SESSIONS) ||
  179. (band_idx < EQ_BAND1) || (band_idx >= EQ_BAND_MAX))
  180. return -EINVAL;
  181. eq_data[eq_idx].eq_bands[band_idx].band_idx =
  182. ucontrol->value.integer.value[0];
  183. eq_data[eq_idx].eq_bands[band_idx].filter_type =
  184. ucontrol->value.integer.value[1];
  185. eq_data[eq_idx].eq_bands[band_idx].center_freq_hz =
  186. ucontrol->value.integer.value[2];
  187. eq_data[eq_idx].eq_bands[band_idx].filter_gain =
  188. ucontrol->value.integer.value[3];
  189. eq_data[eq_idx].eq_bands[band_idx].q_factor =
  190. ucontrol->value.integer.value[4];
  191. return 0;
  192. }
  193. #ifdef CONFIG_QTI_PP
  194. void msm_qti_pp_send_eq_values(int fedai_id)
  195. {
  196. if (eq_data[fedai_id].enable)
  197. msm_qti_pp_send_eq_values_(fedai_id);
  198. }
  199. /* CUSTOM MIXING */
  200. int msm_qti_pp_send_stereo_to_custom_stereo_cmd(int port_id, int copp_idx,
  201. unsigned int session_id,
  202. uint16_t op_FL_ip_FL_weight,
  203. uint16_t op_FL_ip_FR_weight,
  204. uint16_t op_FR_ip_FL_weight,
  205. uint16_t op_FR_ip_FR_weight)
  206. {
  207. char *params_value;
  208. int *update_params_value32, rc = 0;
  209. int16_t *update_params_value16 = 0;
  210. uint32_t params_length = CUSTOM_STEREO_PAYLOAD_SIZE * sizeof(uint32_t);
  211. uint32_t avail_length = params_length;
  212. pr_debug("%s: port_id - %d, session id - %d\n", __func__, port_id,
  213. session_id);
  214. params_value = kzalloc(params_length, GFP_KERNEL);
  215. if (!params_value) {
  216. pr_err("%s, params memory alloc failed\n", __func__);
  217. return -ENOMEM;
  218. }
  219. update_params_value32 = (int *)params_value;
  220. if (avail_length < 2 * sizeof(uint32_t))
  221. goto skip_send_cmd;
  222. /*
  223. * This module is internal to ADSP and cannot be configured with
  224. * an instance id
  225. */
  226. *update_params_value32++ = MTMX_MODULE_ID_DEFAULT_CHMIXER;
  227. *update_params_value32++ = DEFAULT_CHMIXER_PARAM_ID_COEFF;
  228. avail_length = avail_length - (2 * sizeof(uint32_t));
  229. update_params_value16 = (int16_t *)update_params_value32;
  230. if (avail_length < 10 * sizeof(uint16_t))
  231. goto skip_send_cmd;
  232. *update_params_value16++ = CUSTOM_STEREO_CMD_PARAM_SIZE;
  233. /*for alignment only*/
  234. *update_params_value16++ = 0;
  235. /*index is 32-bit param in little endian*/
  236. *update_params_value16++ = CUSTOM_STEREO_INDEX_PARAM;
  237. *update_params_value16++ = 0;
  238. /*for stereo mixing num out ch*/
  239. *update_params_value16++ = CUSTOM_STEREO_NUM_OUT_CH;
  240. /*for stereo mixing num in ch*/
  241. *update_params_value16++ = CUSTOM_STEREO_NUM_IN_CH;
  242. /* Out ch map FL/FR*/
  243. *update_params_value16++ = PCM_CHANNEL_FL;
  244. *update_params_value16++ = PCM_CHANNEL_FR;
  245. /* In ch map FL/FR*/
  246. *update_params_value16++ = PCM_CHANNEL_FL;
  247. *update_params_value16++ = PCM_CHANNEL_FR;
  248. avail_length = avail_length - (10 * sizeof(uint16_t));
  249. /* weighting coefficients as name suggests,
  250. * mixing will be done according to these coefficients
  251. */
  252. if (avail_length < 4 * sizeof(uint16_t))
  253. goto skip_send_cmd;
  254. *update_params_value16++ = op_FL_ip_FL_weight;
  255. *update_params_value16++ = op_FL_ip_FR_weight;
  256. *update_params_value16++ = op_FR_ip_FL_weight;
  257. *update_params_value16++ = op_FR_ip_FR_weight;
  258. avail_length = avail_length - (4 * sizeof(uint16_t));
  259. if (params_length) {
  260. rc = adm_set_stereo_to_custom_stereo(port_id,
  261. copp_idx,
  262. session_id,
  263. params_value,
  264. params_length);
  265. if (rc) {
  266. pr_err("%s: send params failed rc=%d\n", __func__, rc);
  267. kfree(params_value);
  268. return -EINVAL;
  269. }
  270. }
  271. kfree(params_value);
  272. return 0;
  273. skip_send_cmd:
  274. pr_err("%s: insufficient memory, send cmd failed\n",
  275. __func__);
  276. kfree(params_value);
  277. return -ENOMEM;
  278. }
  279. static int msm_qti_pp_arrange_mch_map(int16_t *update_params_value16,
  280. int channel_count)
  281. {
  282. int i;
  283. int16_t ch_map[PCM_FORMAT_MAX_CHANNELS_9] = {
  284. PCM_CHANNEL_FL, PCM_CHANNEL_FR, PCM_CHANNEL_FC,
  285. PCM_CHANNEL_LS, PCM_CHANNEL_RS, PCM_CHANNEL_LFE,
  286. PCM_CHANNEL_LB, PCM_CHANNEL_RB, PCM_CHANNEL_CS };
  287. if (channel_count < 1 ||
  288. channel_count > PCM_FORMAT_MAX_CHANNELS_9) {
  289. pr_err("%s: invalid ch_cnt %d\n",
  290. __func__, channel_count);
  291. return -EINVAL;
  292. }
  293. switch (channel_count) {
  294. /* Add special cases here */
  295. case 1:
  296. *update_params_value16++ = PCM_CHANNEL_FC;
  297. break;
  298. case 4:
  299. *update_params_value16++ = PCM_CHANNEL_FL;
  300. *update_params_value16++ = PCM_CHANNEL_FR;
  301. *update_params_value16++ = PCM_CHANNEL_LS;
  302. *update_params_value16++ = PCM_CHANNEL_RS;
  303. break;
  304. /* Add standard cases here */
  305. default:
  306. for (i = 0; i < channel_count; i++)
  307. *update_params_value16++ = ch_map[i];
  308. break;
  309. }
  310. return 0;
  311. }
  312. static uint32_t msm_qti_pp_get_chmix_param_size(int ip_ch_cnt, int op_ch_cnt)
  313. {
  314. uint32_t param_size;
  315. /* Assign constant part of param length initially -
  316. * Index, Num out channels, Num in channels.
  317. */
  318. param_size = CHMIX_CFG_CONST_PARAM_SIZE * sizeof(uint16_t);
  319. /* Calculate variable part of param length using ip and op channels */
  320. /* channel map for input and output channels */
  321. param_size += op_ch_cnt * sizeof(uint16_t);
  322. param_size += ip_ch_cnt * sizeof(uint16_t);
  323. /* weightage coeff for each op ch corresponding to each ip ch */
  324. param_size += (ip_ch_cnt * op_ch_cnt) * sizeof(uint16_t);
  325. /* Params length should be multiple of 4 bytes i.e 32bit aligned*/
  326. param_size = (param_size + 3) & 0xFFFFFFFC;
  327. return param_size;
  328. }
  329. /*
  330. * msm_qti_pp_send_chmix_cfg_cmd:
  331. * Send the custom channel mixer configuration command.
  332. *
  333. * @port_id: Backend port id
  334. * @copp_idx: ADM copp index
  335. * @session_id: id for the session requesting channel mixer
  336. * @ip_channel_cnt: Input channel count
  337. * @op_channel_cnt: Output channel count
  338. * @ch_wght_coeff: Channel weight co-efficients for mixing
  339. * @session_type: Indicates TX or RX session
  340. * @stream_type: Indicates Audio or Listen stream type
  341. */
  342. int msm_qti_pp_send_chmix_cfg_cmd(int port_id, int copp_idx,
  343. unsigned int session_id, int ip_channel_cnt,
  344. int op_channel_cnt, int *ch_wght_coeff,
  345. int session_type, int stream_type)
  346. {
  347. char *params_value;
  348. int rc = 0, i, direction;
  349. u8 *param_ptr;
  350. int16_t *update_params_value16 = 0;
  351. uint32_t param_size = msm_qti_pp_get_chmix_param_size(ip_channel_cnt,
  352. op_channel_cnt);
  353. struct param_hdr_v3 *param_hdr;
  354. /* constant payload data size represents module_id, param_id,
  355. * param size, reserved field.
  356. */
  357. uint32_t params_length = param_size + sizeof(*param_hdr);
  358. pr_debug("%s: port_id - %d, session id - %d\n", __func__, port_id,
  359. session_id);
  360. params_value = kzalloc(params_length, GFP_KERNEL);
  361. if (!params_value)
  362. return -ENOMEM;
  363. param_ptr = params_value;
  364. param_hdr = (struct param_hdr_v3 *) param_ptr;
  365. param_hdr->module_id = MTMX_MODULE_ID_DEFAULT_CHMIXER;
  366. param_hdr->instance_id = INSTANCE_ID_0;
  367. param_hdr->param_id = DEFAULT_CHMIXER_PARAM_ID_COEFF;
  368. param_hdr->param_size = param_size;
  369. param_ptr += sizeof(*param_hdr);
  370. update_params_value16 = (int16_t *) param_ptr;
  371. /*for alignment only*/
  372. *update_params_value16++ = 0;
  373. /*index is 32-bit param in little endian*/
  374. *update_params_value16++ = CUSTOM_STEREO_INDEX_PARAM;
  375. *update_params_value16++ = 0;
  376. /*number of out ch*/
  377. *update_params_value16++ = op_channel_cnt;
  378. /*number of in ch*/
  379. *update_params_value16++ = ip_channel_cnt;
  380. /* Out ch map FL/FR*/
  381. msm_qti_pp_arrange_mch_map(update_params_value16, op_channel_cnt);
  382. update_params_value16 += op_channel_cnt;
  383. /* In ch map FL/FR*/
  384. msm_qti_pp_arrange_mch_map(update_params_value16, ip_channel_cnt);
  385. update_params_value16 += ip_channel_cnt;
  386. /* weighting coefficients as name suggests,
  387. * mixing will be done according to these coefficients.
  388. */
  389. for (i = 0; i < ip_channel_cnt * op_channel_cnt; i++)
  390. *update_params_value16++ =
  391. ch_wght_coeff[i] ? Q14_GAIN_UNITY : 0;
  392. if (params_length) {
  393. direction = (session_type == SESSION_TYPE_RX) ?
  394. ADM_MATRIX_ID_AUDIO_RX : ADM_MATRIX_ID_AUDIO_TX;
  395. rc = adm_set_custom_chmix_cfg(port_id,
  396. copp_idx,
  397. session_id,
  398. params_value,
  399. params_length,
  400. direction,
  401. stream_type);
  402. if (rc) {
  403. pr_err("%s: send params failed rc=%d\n", __func__, rc);
  404. kfree(params_value);
  405. return -EINVAL;
  406. }
  407. }
  408. kfree(params_value);
  409. return 0;
  410. }
  411. EXPORT_SYMBOL(msm_qti_pp_send_chmix_cfg_cmd);
  412. #endif /* CONFIG_QTI_PP */
  413. /* RMS */
  414. static int msm_qti_pp_get_rms_value_control(struct snd_kcontrol *kcontrol,
  415. struct snd_ctl_elem_value *ucontrol)
  416. {
  417. int rc = 0;
  418. int be_idx = 0, copp_idx;
  419. char *param_value;
  420. int *update_param_value;
  421. uint32_t param_size = (RMS_PAYLOAD_LEN + 1) * sizeof(uint32_t);
  422. struct msm_pcm_routing_bdai_data msm_bedai;
  423. struct param_hdr_v3 param_hdr;
  424. param_value = kzalloc(param_size, GFP_KERNEL);
  425. if (!param_value)
  426. return -ENOMEM;
  427. msm_pcm_routing_acquire_lock();
  428. for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
  429. msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
  430. if (msm_bedai.port_id == SLIMBUS_0_TX)
  431. break;
  432. }
  433. if ((be_idx >= MSM_BACKEND_DAI_MAX) || !msm_bedai.active) {
  434. pr_err("%s, back not active to query rms be_idx:%d\n",
  435. __func__, be_idx);
  436. rc = -EINVAL;
  437. goto get_rms_value_err;
  438. }
  439. copp_idx = adm_get_default_copp_idx(SLIMBUS_0_TX);
  440. if ((copp_idx < 0) || (copp_idx > MAX_COPPS_PER_PORT)) {
  441. pr_err("%s, no active copp to query rms copp_idx:%d\n",
  442. __func__, copp_idx);
  443. rc = -EINVAL;
  444. goto get_rms_value_err;
  445. }
  446. memset(&param_hdr, 0, sizeof(param_hdr));
  447. param_hdr.module_id = RMS_MODULEID_APPI_PASSTHRU;
  448. param_hdr.instance_id = INSTANCE_ID_0;
  449. param_hdr.param_id = RMS_PARAM_FIRST_SAMPLE;
  450. param_hdr.param_size = param_size;
  451. rc = adm_get_pp_params(SLIMBUS_0_TX, copp_idx, ADM_CLIENT_ID_DEFAULT,
  452. NULL, &param_hdr, param_value);
  453. if (rc) {
  454. pr_err("%s: get parameters failed rc=%d\n", __func__, rc);
  455. rc = -EINVAL;
  456. goto get_rms_value_err;
  457. }
  458. update_param_value = (int *)param_value;
  459. ucontrol->value.integer.value[0] = update_param_value[0];
  460. pr_debug("%s: FROM DSP value[0] 0x%x\n",
  461. __func__, update_param_value[0]);
  462. get_rms_value_err:
  463. msm_pcm_routing_release_lock();
  464. kfree(param_value);
  465. return rc;
  466. }
  467. static int msm_qti_pp_put_rms_value_control(struct snd_kcontrol *kcontrol,
  468. struct snd_ctl_elem_value *ucontrol)
  469. {
  470. /* not used */
  471. return 0;
  472. }
  473. /* VOLUME */
  474. static int msm_route_fm_vol_control;
  475. static int msm_afe_lb_vol_ctrl;
  476. static int msm_afe_sec_mi2s_lb_vol_ctrl;
  477. static int msm_afe_tert_mi2s_lb_vol_ctrl;
  478. static int msm_afe_quat_mi2s_lb_vol_ctrl;
  479. static int msm_afe_slimbus_7_lb_vol_ctrl;
  480. static int msm_afe_slimbus_8_lb_vol_ctrl;
  481. static int msm_asm_bit_width;
  482. static const DECLARE_TLV_DB_LINEAR(fm_rx_vol_gain, 0, INT_RX_VOL_MAX_STEPS);
  483. static const DECLARE_TLV_DB_LINEAR(afe_lb_vol_gain, 0, INT_RX_VOL_MAX_STEPS);
  484. static int msm_qti_pp_get_fm_vol_mixer(struct snd_kcontrol *kcontrol,
  485. struct snd_ctl_elem_value *ucontrol)
  486. {
  487. ucontrol->value.integer.value[0] = msm_route_fm_vol_control;
  488. return 0;
  489. }
  490. static int msm_qti_pp_set_fm_vol_mixer(struct snd_kcontrol *kcontrol,
  491. struct snd_ctl_elem_value *ucontrol)
  492. {
  493. afe_loopback_gain(INT_FM_TX, ucontrol->value.integer.value[0]);
  494. msm_route_fm_vol_control = ucontrol->value.integer.value[0];
  495. return 0;
  496. }
  497. static int msm_asm_bit_width_get(struct snd_kcontrol *kcontrol,
  498. struct snd_ctl_elem_value *ucontrol)
  499. {
  500. pr_debug("%s get ASM bitwidth = %d\n",
  501. __func__, msm_asm_bit_width);
  502. ucontrol->value.integer.value[0] = msm_asm_bit_width;
  503. return 0;
  504. }
  505. static int msm_asm_bit_width_put(struct snd_kcontrol *kcontrol,
  506. struct snd_ctl_elem_value *ucontrol)
  507. {
  508. switch (ucontrol->value.integer.value[0]) {
  509. case 16:
  510. msm_asm_bit_width = 16;
  511. break;
  512. case 24:
  513. msm_asm_bit_width = 24;
  514. break;
  515. case 32:
  516. msm_asm_bit_width = 32;
  517. break;
  518. default:
  519. msm_asm_bit_width = 0;
  520. break;
  521. }
  522. return 0;
  523. }
  524. static int msm_qti_pp_get_pri_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  525. struct snd_ctl_elem_value *ucontrol)
  526. {
  527. ucontrol->value.integer.value[0] = msm_afe_lb_vol_ctrl;
  528. return 0;
  529. }
  530. static int msm_qti_pp_set_pri_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  531. struct snd_ctl_elem_value *ucontrol)
  532. {
  533. afe_loopback_gain(AFE_PORT_ID_PRIMARY_MI2S_TX,
  534. ucontrol->value.integer.value[0]);
  535. msm_afe_lb_vol_ctrl = ucontrol->value.integer.value[0];
  536. return 0;
  537. }
  538. static int msm_qti_pp_get_sec_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  539. struct snd_ctl_elem_value *ucontrol)
  540. {
  541. ucontrol->value.integer.value[0] = msm_afe_sec_mi2s_lb_vol_ctrl;
  542. return 0;
  543. }
  544. static int msm_qti_pp_set_sec_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  545. struct snd_ctl_elem_value *ucontrol)
  546. {
  547. afe_loopback_gain(AFE_PORT_ID_SECONDARY_MI2S_TX,
  548. ucontrol->value.integer.value[0]);
  549. msm_afe_sec_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0];
  550. return 0;
  551. }
  552. static int msm_qti_pp_get_tert_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  553. struct snd_ctl_elem_value *ucontrol)
  554. {
  555. ucontrol->value.integer.value[0] = msm_afe_tert_mi2s_lb_vol_ctrl;
  556. return 0;
  557. }
  558. static int msm_qti_pp_set_tert_mi2s_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  559. struct snd_ctl_elem_value *ucontrol)
  560. {
  561. afe_loopback_gain(AFE_PORT_ID_TERTIARY_MI2S_TX,
  562. ucontrol->value.integer.value[0]);
  563. msm_afe_tert_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0];
  564. return 0;
  565. }
  566. static int msm_qti_pp_get_slimbus_7_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  567. struct snd_ctl_elem_value *ucontrol)
  568. {
  569. ucontrol->value.integer.value[0] = msm_afe_slimbus_7_lb_vol_ctrl;
  570. return 0;
  571. }
  572. static int msm_qti_pp_set_slimbus_7_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  573. struct snd_ctl_elem_value *ucontrol)
  574. {
  575. int ret = afe_loopback_gain(SLIMBUS_7_TX,
  576. ucontrol->value.integer.value[0]);
  577. if (ret)
  578. pr_err("%s: failed to set LB vol for SLIMBUS_7_TX, err %d\n",
  579. __func__, ret);
  580. else
  581. msm_afe_slimbus_7_lb_vol_ctrl =
  582. ucontrol->value.integer.value[0];
  583. return ret;
  584. }
  585. static int msm_qti_pp_get_slimbus_8_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  586. struct snd_ctl_elem_value *ucontrol)
  587. {
  588. ucontrol->value.integer.value[0] = msm_afe_slimbus_8_lb_vol_ctrl;
  589. return 0;
  590. }
  591. static int msm_qti_pp_set_slimbus_8_lb_vol_mixer(struct snd_kcontrol *kcontrol,
  592. struct snd_ctl_elem_value *ucontrol)
  593. {
  594. int ret = 0;
  595. ret = afe_loopback_gain(SLIMBUS_8_TX,
  596. ucontrol->value.integer.value[0]);
  597. if (ret)
  598. pr_err("%s: failed to set LB vol for SLIMBUS_8_TX", __func__);
  599. else
  600. msm_afe_slimbus_8_lb_vol_ctrl =
  601. ucontrol->value.integer.value[0];
  602. return ret;
  603. }
  604. static int msm_qti_pp_get_icc_vol_mixer(struct snd_kcontrol *kcontrol,
  605. struct snd_ctl_elem_value *ucontrol)
  606. {
  607. ucontrol->value.integer.value[0] = msm_route_icc_vol_control;
  608. return 0;
  609. }
  610. static int msm_qti_pp_set_icc_vol_mixer(struct snd_kcontrol *kcontrol,
  611. struct snd_ctl_elem_value *ucontrol)
  612. {
  613. adm_set_mic_gain(AFE_PORT_ID_QUATERNARY_TDM_TX,
  614. adm_get_default_copp_idx(AFE_PORT_ID_QUATERNARY_TDM_TX),
  615. ucontrol->value.integer.value[0]);
  616. msm_route_icc_vol_control = ucontrol->value.integer.value[0];
  617. return 0;
  618. }
  619. static int msm_qti_pp_get_quat_mi2s_fm_vol_mixer(struct snd_kcontrol *kcontrol,
  620. struct snd_ctl_elem_value *ucontrol)
  621. {
  622. ucontrol->value.integer.value[0] = msm_afe_quat_mi2s_lb_vol_ctrl;
  623. return 0;
  624. }
  625. static int msm_qti_pp_set_quat_mi2s_fm_vol_mixer(struct snd_kcontrol *kcontrol,
  626. struct snd_ctl_elem_value *ucontrol)
  627. {
  628. afe_loopback_gain(AFE_PORT_ID_QUATERNARY_MI2S_TX,
  629. ucontrol->value.integer.value[0]);
  630. msm_afe_quat_mi2s_lb_vol_ctrl = ucontrol->value.integer.value[0];
  631. return 0;
  632. }
  633. static int msm_qti_pp_get_hfp_vol_mixer(struct snd_kcontrol *kcontrol,
  634. struct snd_ctl_elem_value *ucontrol)
  635. {
  636. ucontrol->value.integer.value[0] = msm_route_hfp_vol_control;
  637. return 0;
  638. }
  639. static int msm_qti_pp_set_hfp_vol_mixer(struct snd_kcontrol *kcontrol,
  640. struct snd_ctl_elem_value *ucontrol)
  641. {
  642. afe_loopback_gain(INT_BT_SCO_TX, ucontrol->value.integer.value[0]);
  643. msm_route_hfp_vol_control = ucontrol->value.integer.value[0];
  644. return 0;
  645. }
  646. static int msm_qti_pp_get_pri_auxpcm_lb_vol_mixer(
  647. struct snd_kcontrol *kcontrol,
  648. struct snd_ctl_elem_value *ucontrol)
  649. {
  650. ucontrol->value.integer.value[0] = msm_route_pri_auxpcm_lb_vol_ctrl;
  651. pr_debug("%s: Volume = %ld\n", __func__,
  652. ucontrol->value.integer.value[0]);
  653. return 0;
  654. }
  655. static int msm_qti_pp_set_pri_auxpcm_lb_vol_mixer(
  656. struct snd_kcontrol *kcontrol,
  657. struct snd_ctl_elem_value *ucontrol)
  658. {
  659. struct soc_mixer_control *mc =
  660. (struct soc_mixer_control *)kcontrol->private_value;
  661. afe_loopback_gain(mc->reg, ucontrol->value.integer.value[0]);
  662. msm_route_pri_auxpcm_lb_vol_ctrl = ucontrol->value.integer.value[0];
  663. return 0;
  664. }
  665. static int msm_qti_pp_get_sec_auxpcm_lb_vol_mixer(
  666. struct snd_kcontrol *kcontrol,
  667. struct snd_ctl_elem_value *ucontrol)
  668. {
  669. ucontrol->value.integer.value[0] = msm_route_sec_auxpcm_lb_vol_ctrl;
  670. pr_debug("%s: Volume = %ld\n", __func__,
  671. ucontrol->value.integer.value[0]);
  672. return 0;
  673. }
  674. static int msm_qti_pp_set_sec_auxpcm_lb_vol_mixer(
  675. struct snd_kcontrol *kcontrol,
  676. struct snd_ctl_elem_value *ucontrol)
  677. {
  678. struct soc_mixer_control *mc =
  679. (struct soc_mixer_control *)kcontrol->private_value;
  680. afe_loopback_gain(mc->reg, ucontrol->value.integer.value[0]);
  681. msm_route_sec_auxpcm_lb_vol_ctrl = ucontrol->value.integer.value[0];
  682. return 0;
  683. }
  684. static int msm_qti_pp_get_channel_map_mixer(struct snd_kcontrol *kcontrol,
  685. struct snd_ctl_elem_value *ucontrol)
  686. {
  687. char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL_V8] = {0};
  688. int i;
  689. adm_get_multi_ch_map(channel_map, ADM_PATH_PLAYBACK);
  690. for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
  691. ucontrol->value.integer.value[i] =
  692. (unsigned int) channel_map[i];
  693. return 0;
  694. }
  695. static int msm_qti_pp_put_channel_map_mixer(struct snd_kcontrol *kcontrol,
  696. struct snd_ctl_elem_value *ucontrol)
  697. {
  698. char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL_V8];
  699. int i;
  700. for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
  701. channel_map[i] = (char)(ucontrol->value.integer.value[i]);
  702. adm_set_multi_ch_map(channel_map, ADM_PATH_PLAYBACK);
  703. return 0;
  704. }
  705. static int msm_qti_pp_get_channel_map_capture(struct snd_kcontrol *kcontrol,
  706. struct snd_ctl_elem_value *ucontrol)
  707. {
  708. char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL_V8] = {0};
  709. int i;
  710. adm_get_multi_ch_map(channel_map, ADM_PATH_LIVE_REC);
  711. for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
  712. ucontrol->value.integer.value[i] =
  713. (unsigned int) channel_map[i];
  714. return 0;
  715. }
  716. static int msm_qti_pp_put_channel_map_capture(struct snd_kcontrol *kcontrol,
  717. struct snd_ctl_elem_value *ucontrol)
  718. {
  719. char channel_map[PCM_FORMAT_MAX_NUM_CHANNEL_V8];
  720. int i;
  721. for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
  722. channel_map[i] = (char)(ucontrol->value.integer.value[i]);
  723. adm_set_multi_ch_map(channel_map, ADM_PATH_LIVE_REC);
  724. return 0;
  725. }
  726. /* Audio Sphere functions */
  727. static void msm_qti_pp_asphere_init_state(void)
  728. {
  729. int i;
  730. if (asphere_state.initialized)
  731. return;
  732. asphere_state.initialized = true;
  733. for (i = 0; i < AFE_MAX_PORTS; i++) {
  734. asphere_state.port_id[i] = -1;
  735. asphere_state.copp_idx[i] = -1;
  736. }
  737. asphere_state.enabled = 0;
  738. asphere_state.strength = 0;
  739. asphere_state.mode = 0;
  740. asphere_state.version = 0;
  741. asphere_state.enabled_prev = 0;
  742. asphere_state.strength_prev = 0;
  743. }
  744. static int msm_qti_pp_asphere_send_params(int port_id, int copp_idx, bool force)
  745. {
  746. u8 *packed_params = NULL;
  747. u32 packed_params_size = 0;
  748. u32 param_size = 0;
  749. struct param_hdr_v3 param_hdr;
  750. bool set_enable = force ||
  751. (asphere_state.enabled != asphere_state.enabled_prev);
  752. bool set_strength = asphere_state.enabled == 1 && (set_enable ||
  753. (asphere_state.strength != asphere_state.strength_prev));
  754. int param_count = 0;
  755. int ret = 0;
  756. if (set_enable)
  757. param_count++;
  758. if (set_strength)
  759. param_count++;
  760. if (param_count == 0) {
  761. pr_debug("%s: Nothing to send, exiting\n", __func__);
  762. return 0;
  763. }
  764. pr_debug("%s: port_id %d, copp_id %d, forced %d, param_count %d\n",
  765. __func__, port_id, copp_idx, force, param_count);
  766. pr_debug("%s: enable prev:%u cur:%u, strength prev:%u cur:%u\n",
  767. __func__, asphere_state.enabled_prev, asphere_state.enabled,
  768. asphere_state.strength_prev, asphere_state.strength);
  769. packed_params_size =
  770. param_count * (sizeof(struct param_hdr_v3) + sizeof(uint32_t));
  771. packed_params = kzalloc(packed_params_size, GFP_KERNEL);
  772. if (!packed_params)
  773. return -ENOMEM;
  774. memset(&param_hdr, 0, sizeof(param_hdr));
  775. packed_params_size = 0;
  776. param_hdr.module_id = AUDPROC_MODULE_ID_AUDIOSPHERE;
  777. param_hdr.instance_id = INSTANCE_ID_0;
  778. if (set_strength) {
  779. /* add strength command */
  780. param_hdr.param_id = AUDPROC_PARAM_ID_AUDIOSPHERE_STRENGTH;
  781. param_hdr.param_size = sizeof(asphere_state.strength);
  782. ret = q6common_pack_pp_params(packed_params +
  783. packed_params_size,
  784. &param_hdr,
  785. (u8 *) &asphere_state.strength,
  786. &param_size);
  787. if (ret) {
  788. pr_err("%s: Failed to pack params for audio sphere"
  789. " strength, error %d\n", __func__, ret);
  790. goto done;
  791. }
  792. packed_params_size += param_size;
  793. }
  794. if (set_enable) {
  795. /* add enable command */
  796. param_hdr.param_id = AUDPROC_PARAM_ID_AUDIOSPHERE_ENABLE;
  797. param_hdr.param_size = sizeof(asphere_state.enabled);
  798. q6common_pack_pp_params(packed_params + packed_params_size,
  799. &param_hdr,
  800. (u8 *) &asphere_state.enabled,
  801. &param_size);
  802. if (ret) {
  803. pr_err("%s: Failed to pack params for audio sphere"
  804. " enable, error %d\n", __func__, ret);
  805. goto done;
  806. }
  807. packed_params_size += param_size;
  808. }
  809. pr_debug("%s: packed data size: %d\n", __func__, packed_params_size);
  810. ret = adm_set_pp_params(port_id, copp_idx, NULL, packed_params,
  811. packed_params_size);
  812. if (ret)
  813. pr_err("%s: set param failed with err=%d\n", __func__, ret);
  814. done:
  815. kfree(packed_params);
  816. return 0;
  817. }
  818. #if defined(CONFIG_QTI_PP) && defined(CONFIG_QTI_PP_AUDIOSPHERE)
  819. int msm_qti_pp_asphere_init(int port_id, int copp_idx)
  820. {
  821. int index = adm_validate_and_get_port_index(port_id);
  822. pr_debug("%s, port_id %d, copp_id %d\n", __func__, port_id, copp_idx);
  823. if (index < 0) {
  824. pr_err("%s: Invalid port idx %d port_id %#x\n", __func__, index,
  825. port_id);
  826. return -EINVAL;
  827. }
  828. msm_qti_pp_asphere_init_state();
  829. asphere_state.port_id[index] = port_id;
  830. asphere_state.copp_idx[index] = copp_idx;
  831. if (asphere_state.enabled)
  832. msm_qti_pp_asphere_send_params(port_id, copp_idx, true);
  833. return 0;
  834. }
  835. void msm_qti_pp_asphere_deinit(int port_id)
  836. {
  837. int index = adm_validate_and_get_port_index(port_id);
  838. pr_debug("%s, port_id %d\n", __func__, port_id);
  839. if (index < 0) {
  840. pr_err("%s: Invalid port idx %d port_id %#x\n", __func__, index,
  841. port_id);
  842. return;
  843. }
  844. if (asphere_state.port_id[index] == port_id) {
  845. asphere_state.port_id[index] = -1;
  846. asphere_state.copp_idx[index] = -1;
  847. }
  848. }
  849. #endif
  850. static int msm_qti_pp_asphere_get(struct snd_kcontrol *kcontrol,
  851. struct snd_ctl_elem_value *ucontrol)
  852. {
  853. if (!asphere_state.initialized)
  854. return -EAGAIN;
  855. ucontrol->value.integer.value[0] = asphere_state.enabled;
  856. ucontrol->value.integer.value[1] = asphere_state.strength;
  857. pr_debug("%s, enable %u, strength %u\n", __func__,
  858. asphere_state.enabled, asphere_state.strength);
  859. return 0;
  860. }
  861. static int msm_qti_pp_asphere_set(struct snd_kcontrol *kcontrol,
  862. struct snd_ctl_elem_value *ucontrol)
  863. {
  864. int32_t enable = ucontrol->value.integer.value[0];
  865. int32_t strength = ucontrol->value.integer.value[1];
  866. int i;
  867. pr_debug("%s, enable %u, strength %u\n", __func__, enable, strength);
  868. msm_qti_pp_asphere_init_state();
  869. if (enable == 0 || enable == 1) {
  870. asphere_state.enabled_prev = asphere_state.enabled;
  871. asphere_state.enabled = enable;
  872. }
  873. if (strength >= 0 && strength <= 1000) {
  874. asphere_state.strength_prev = asphere_state.strength;
  875. asphere_state.strength = strength;
  876. }
  877. if (asphere_state.strength != asphere_state.strength_prev ||
  878. asphere_state.enabled != asphere_state.enabled_prev) {
  879. for (i = 0; i < AFE_MAX_PORTS; i++) {
  880. if (asphere_state.port_id[i] >= 0)
  881. msm_qti_pp_asphere_send_params(
  882. asphere_state.port_id[i],
  883. asphere_state.copp_idx[i],
  884. false);
  885. }
  886. }
  887. return 0;
  888. }
  889. int msm_adsp_init_mixer_ctl_pp_event_queue(struct snd_soc_pcm_runtime *rtd)
  890. {
  891. struct snd_kcontrol *kctl;
  892. const char *deviceNo = "NN";
  893. char *mixer_str = NULL;
  894. int ctl_len = 0, ret = 0;
  895. const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
  896. struct dsp_stream_callback_prtd *kctl_prtd = NULL;
  897. if (!rtd) {
  898. pr_err("%s: rtd is NULL\n", __func__);
  899. ret = -EINVAL;
  900. goto done;
  901. }
  902. ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
  903. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  904. if (!mixer_str) {
  905. ret = -EINVAL;
  906. goto done;
  907. }
  908. snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name,
  909. rtd->pcm->device);
  910. kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
  911. kfree(mixer_str);
  912. if (!kctl) {
  913. pr_err("%s: failed to get kctl.\n", __func__);
  914. ret = -EINVAL;
  915. goto done;
  916. }
  917. if (kctl->private_data != NULL) {
  918. pr_err("%s: kctl_prtd is not NULL at initialization.\n",
  919. __func__);
  920. return -EINVAL;
  921. }
  922. kctl_prtd = kzalloc(sizeof(struct dsp_stream_callback_prtd),
  923. GFP_KERNEL);
  924. if (!kctl_prtd) {
  925. ret = -ENOMEM;
  926. goto done;
  927. }
  928. spin_lock_init(&kctl_prtd->prtd_spin_lock);
  929. INIT_LIST_HEAD(&kctl_prtd->event_queue);
  930. kctl_prtd->event_count = 0;
  931. kctl->private_data = kctl_prtd;
  932. done:
  933. return ret;
  934. }
  935. int msm_adsp_clean_mixer_ctl_pp_event_queue(struct snd_soc_pcm_runtime *rtd)
  936. {
  937. struct snd_kcontrol *kctl;
  938. const char *deviceNo = "NN";
  939. char *mixer_str = NULL;
  940. int ctl_len = 0, ret = 0;
  941. struct dsp_stream_callback_list *node, *n;
  942. unsigned long spin_flags;
  943. const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
  944. struct dsp_stream_callback_prtd *kctl_prtd = NULL;
  945. if (!rtd) {
  946. pr_err("%s: rtd is NULL\n", __func__);
  947. ret = -EINVAL;
  948. goto done;
  949. }
  950. ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
  951. mixer_str = kzalloc(ctl_len, GFP_KERNEL);
  952. if (!mixer_str) {
  953. ret = -EINVAL;
  954. goto done;
  955. }
  956. snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name,
  957. rtd->pcm->device);
  958. kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
  959. kfree(mixer_str);
  960. if (!kctl) {
  961. pr_err("%s: failed to get kctl.\n", __func__);
  962. ret = -EINVAL;
  963. goto done;
  964. }
  965. kctl_prtd = (struct dsp_stream_callback_prtd *)
  966. kctl->private_data;
  967. if (kctl_prtd != NULL) {
  968. spin_lock_irqsave(&kctl_prtd->prtd_spin_lock, spin_flags);
  969. /* clean the queue */
  970. list_for_each_entry_safe(node, n,
  971. &kctl_prtd->event_queue, list) {
  972. list_del(&node->list);
  973. kctl_prtd->event_count--;
  974. pr_debug("%s: %d remaining events after del.\n",
  975. __func__, kctl_prtd->event_count);
  976. kfree(node);
  977. }
  978. spin_unlock_irqrestore(&kctl_prtd->prtd_spin_lock, spin_flags);
  979. }
  980. kfree(kctl_prtd);
  981. kctl->private_data = NULL;
  982. done:
  983. return ret;
  984. }
  985. int msm_adsp_inform_mixer_ctl(struct snd_soc_pcm_runtime *rtd,
  986. uint32_t *payload)
  987. {
  988. /* adsp pp event notifier */
  989. struct snd_kcontrol *kctl;
  990. struct snd_ctl_elem_value control;
  991. const char *deviceNo = "NN";
  992. char *mixer_str = NULL;
  993. int ctl_len = 0, ret = 0;
  994. struct dsp_stream_callback_list *new_event;
  995. struct dsp_stream_callback_list *oldest_event;
  996. unsigned long spin_flags;
  997. struct dsp_stream_callback_prtd *kctl_prtd = NULL;
  998. struct msm_adsp_event_data *event_data = NULL;
  999. const char *mixer_ctl_name = DSP_STREAM_CALLBACK;
  1000. struct snd_ctl_elem_info kctl_info;
  1001. if (!rtd || !payload) {
  1002. pr_err("%s: %s is NULL\n", __func__,
  1003. (!rtd) ? "rtd" : "payload");
  1004. ret = -EINVAL;
  1005. goto done;
  1006. }
  1007. if (rtd->card->snd_card == NULL) {
  1008. pr_err("%s: snd_card is null.\n", __func__);
  1009. ret = -EINVAL;
  1010. goto done;
  1011. }
  1012. ctl_len = strlen(mixer_ctl_name) + 1 + strlen(deviceNo) + 1;
  1013. mixer_str = kzalloc(ctl_len, GFP_ATOMIC);
  1014. if (!mixer_str) {
  1015. ret = -EINVAL;
  1016. goto done;
  1017. }
  1018. snprintf(mixer_str, ctl_len, "%s %d", mixer_ctl_name,
  1019. rtd->pcm->device);
  1020. kctl = snd_soc_card_get_kcontrol(rtd->card, mixer_str);
  1021. kfree(mixer_str);
  1022. if (!kctl) {
  1023. pr_err("%s: failed to get kctl.\n", __func__);
  1024. ret = -EINVAL;
  1025. goto done;
  1026. }
  1027. event_data = (struct msm_adsp_event_data *)payload;
  1028. if (event_data->payload_len < sizeof(struct msm_adsp_event_data)) {
  1029. pr_err("%s: event_data size of %x is less than expected.\n",
  1030. __func__, event_data->payload_len);
  1031. ret = -EINVAL;
  1032. goto done;
  1033. }
  1034. kctl->info(kctl, &kctl_info);
  1035. if (event_data->payload_len >
  1036. kctl_info.count - sizeof(struct msm_adsp_event_data)) {
  1037. pr_err("%s: payload length exceeds limit of %u bytes.\n",
  1038. __func__, kctl_info.count);
  1039. ret = -EINVAL;
  1040. goto done;
  1041. }
  1042. kctl_prtd = (struct dsp_stream_callback_prtd *)
  1043. kctl->private_data;
  1044. if (kctl_prtd == NULL) {
  1045. /* queue is not initialized */
  1046. ret = -EINVAL;
  1047. pr_err("%s: event queue is not initialized.\n", __func__);
  1048. goto done;
  1049. }
  1050. new_event = kzalloc(sizeof(struct dsp_stream_callback_list)
  1051. + event_data->payload_len,
  1052. GFP_ATOMIC);
  1053. if (new_event == NULL) {
  1054. ret = -ENOMEM;
  1055. goto done;
  1056. }
  1057. memcpy((void *)&new_event->event, (void *)payload,
  1058. event_data->payload_len
  1059. + sizeof(struct msm_adsp_event_data));
  1060. spin_lock_irqsave(&kctl_prtd->prtd_spin_lock, spin_flags);
  1061. while (kctl_prtd->event_count >= DSP_STREAM_CALLBACK_QUEUE_SIZE) {
  1062. pr_info("%s: queue of size %d is full. delete oldest one.\n",
  1063. __func__, DSP_STREAM_CALLBACK_QUEUE_SIZE);
  1064. oldest_event = list_first_entry(&kctl_prtd->event_queue,
  1065. struct dsp_stream_callback_list, list);
  1066. pr_info("%s: event deleted: type %d length %d\n",
  1067. __func__, oldest_event->event.event_type,
  1068. oldest_event->event.payload_len);
  1069. list_del(&oldest_event->list);
  1070. kctl_prtd->event_count--;
  1071. kfree(oldest_event);
  1072. }
  1073. list_add_tail(&new_event->list, &kctl_prtd->event_queue);
  1074. kctl_prtd->event_count++;
  1075. spin_unlock_irqrestore(&kctl_prtd->prtd_spin_lock, spin_flags);
  1076. control.id = kctl->id;
  1077. snd_ctl_notify(rtd->card->snd_card,
  1078. SNDRV_CTL_EVENT_MASK_INFO,
  1079. &control.id);
  1080. done:
  1081. return ret;
  1082. }
  1083. int msm_adsp_stream_cmd_info(struct snd_kcontrol *kcontrol,
  1084. struct snd_ctl_elem_info *uinfo)
  1085. {
  1086. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  1087. uinfo->count =
  1088. sizeof(((struct snd_ctl_elem_value *)0)->value.bytes.data);
  1089. return 0;
  1090. }
  1091. int msm_adsp_stream_callback_get(struct snd_kcontrol *kcontrol,
  1092. struct snd_ctl_elem_value *ucontrol)
  1093. {
  1094. uint32_t payload_size = 0;
  1095. struct dsp_stream_callback_list *oldest_event;
  1096. unsigned long spin_flags;
  1097. struct dsp_stream_callback_prtd *kctl_prtd = NULL;
  1098. int ret = 0;
  1099. kctl_prtd = (struct dsp_stream_callback_prtd *)
  1100. kcontrol->private_data;
  1101. if (kctl_prtd == NULL) {
  1102. pr_debug("%s: ASM Stream PP event queue is not initialized.\n",
  1103. __func__);
  1104. ret = -EINVAL;
  1105. goto done;
  1106. }
  1107. spin_lock_irqsave(&kctl_prtd->prtd_spin_lock, spin_flags);
  1108. pr_debug("%s: %d events in queue.\n", __func__, kctl_prtd->event_count);
  1109. if (list_empty(&kctl_prtd->event_queue)) {
  1110. pr_err("%s: ASM Stream PP event queue is empty.\n", __func__);
  1111. ret = -EINVAL;
  1112. spin_unlock_irqrestore(&kctl_prtd->prtd_spin_lock, spin_flags);
  1113. goto done;
  1114. }
  1115. oldest_event = list_first_entry(&kctl_prtd->event_queue,
  1116. struct dsp_stream_callback_list, list);
  1117. list_del(&oldest_event->list);
  1118. kctl_prtd->event_count--;
  1119. spin_unlock_irqrestore(&kctl_prtd->prtd_spin_lock, spin_flags);
  1120. payload_size = oldest_event->event.payload_len;
  1121. pr_debug("%s: event fetched: type %d length %d\n",
  1122. __func__, oldest_event->event.event_type,
  1123. oldest_event->event.payload_len);
  1124. memcpy(ucontrol->value.bytes.data, &oldest_event->event,
  1125. sizeof(struct msm_adsp_event_data) + payload_size);
  1126. kfree(oldest_event);
  1127. done:
  1128. return ret;
  1129. }
  1130. int msm_adsp_stream_callback_info(struct snd_kcontrol *kcontrol,
  1131. struct snd_ctl_elem_info *uinfo)
  1132. {
  1133. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  1134. uinfo->count =
  1135. sizeof(((struct snd_ctl_elem_value *)0)->value.bytes.data);
  1136. return 0;
  1137. }
  1138. static int msm_multichannel_ec_primary_mic_ch_put(struct snd_kcontrol *kcontrol,
  1139. struct snd_ctl_elem_value *ucontrol)
  1140. {
  1141. int ret = 0;
  1142. int copp_idx = 0;
  1143. int port_id = AFE_PORT_ID_QUATERNARY_TDM_TX;
  1144. msm_multichannel_ec_primary_mic_ch = ucontrol->value.integer.value[0];
  1145. pr_debug("%s: msm_multichannel_ec_primary_mic_ch = %u\n",
  1146. __func__, msm_multichannel_ec_primary_mic_ch);
  1147. copp_idx = adm_get_default_copp_idx(port_id);
  1148. if ((copp_idx < 0) || (copp_idx > MAX_COPPS_PER_PORT)) {
  1149. pr_err("%s : no active copp to query multichannel ec copp_idx: %u\n",
  1150. __func__, copp_idx);
  1151. return -EINVAL;
  1152. }
  1153. adm_send_set_multichannel_ec_primary_mic_ch(port_id, copp_idx,
  1154. msm_multichannel_ec_primary_mic_ch);
  1155. return ret;
  1156. }
  1157. static int msm_multichannel_ec_primary_mic_ch_get(struct snd_kcontrol *kcontrol,
  1158. struct snd_ctl_elem_value *ucontrol)
  1159. {
  1160. ucontrol->value.integer.value[0] = msm_multichannel_ec_primary_mic_ch;
  1161. pr_debug("%s: msm_multichannel_ec_primary_mic_ch = %lu\n",
  1162. __func__, ucontrol->value.integer.value[0]);
  1163. return 0;
  1164. }
  1165. static const struct snd_kcontrol_new msm_multichannel_ec_controls[] = {
  1166. SOC_SINGLE_EXT("Multichannel EC Primary Mic Ch", SND_SOC_NOPM, 0,
  1167. 0xFFFFFFFF, 0, msm_multichannel_ec_primary_mic_ch_get,
  1168. msm_multichannel_ec_primary_mic_ch_put),
  1169. };
  1170. static char const *ffecns_effect_text[] = {"NO_EFFECT", "EC_ONLY", "NS_ONLY", "ECNS"};
  1171. static int msm_ffecns_put(struct snd_kcontrol *kcontrol,
  1172. struct snd_ctl_elem_value *ucontrol)
  1173. {
  1174. int ret = -EINVAL;
  1175. if (ucontrol->value.integer.value[0] < 0 ||
  1176. ucontrol->value.integer.value[0] >= ARRAY_SIZE(ffecns_effect_text)) {
  1177. pr_err("%s: invalid ffecns effect value %ld\n",
  1178. __func__, ucontrol->value.integer.value[0]);
  1179. return -EINVAL;
  1180. }
  1181. msm_ffecns_effect = ucontrol->value.integer.value[0];
  1182. pr_debug("%s: set %s for ffecns\n", __func__,
  1183. ffecns_effect_text[msm_ffecns_effect]);
  1184. ret = adm_set_ffecns_effect(msm_ffecns_effect);
  1185. if (ret)
  1186. pr_err("%s: failed to set %s for ffecns\n",
  1187. __func__, ffecns_effect_text[msm_ffecns_effect]);
  1188. return ret;
  1189. }
  1190. static int msm_ffecns_get(struct snd_kcontrol *kcontrol,
  1191. struct snd_ctl_elem_value *ucontrol)
  1192. {
  1193. ucontrol->value.integer.value[0] = msm_ffecns_effect;
  1194. pr_debug("%s: ffecns effect = %ld\n",
  1195. __func__, ucontrol->value.integer.value[0]);
  1196. return 0;
  1197. }
  1198. static SOC_ENUM_SINGLE_EXT_DECL(ffecns_effect_enum, ffecns_effect_text);
  1199. static const struct snd_kcontrol_new ec_ffecns_controls[] = {
  1200. SOC_ENUM_EXT("FFECNS Effect", ffecns_effect_enum,
  1201. msm_ffecns_get, msm_ffecns_put),
  1202. };
  1203. static const struct snd_kcontrol_new int_fm_vol_mixer_controls[] = {
  1204. SOC_SINGLE_EXT_TLV("Internal FM RX Volume", SND_SOC_NOPM, 0,
  1205. INT_RX_VOL_GAIN, 0, msm_qti_pp_get_fm_vol_mixer,
  1206. msm_qti_pp_set_fm_vol_mixer, fm_rx_vol_gain),
  1207. SOC_SINGLE_EXT_TLV("Quat MI2S FM RX Volume", SND_SOC_NOPM, 0,
  1208. INT_RX_VOL_GAIN, 0, msm_qti_pp_get_quat_mi2s_fm_vol_mixer,
  1209. msm_qti_pp_set_quat_mi2s_fm_vol_mixer, fm_rx_vol_gain),
  1210. };
  1211. static const struct snd_kcontrol_new dsp_bit_width_controls[] = {
  1212. SOC_SINGLE_EXT(DSP_BIT_WIDTH_MIXER_CTL, SND_SOC_NOPM, 0, 0x20,
  1213. 0, msm_asm_bit_width_get, msm_asm_bit_width_put),
  1214. };
  1215. static const struct snd_kcontrol_new pri_mi2s_lb_vol_mixer_controls[] = {
  1216. SOC_SINGLE_EXT_TLV("PRI MI2S LOOPBACK Volume", SND_SOC_NOPM, 0,
  1217. INT_RX_VOL_GAIN, 0, msm_qti_pp_get_pri_mi2s_lb_vol_mixer,
  1218. msm_qti_pp_set_pri_mi2s_lb_vol_mixer, afe_lb_vol_gain),
  1219. };
  1220. static const struct snd_kcontrol_new sec_mi2s_lb_vol_mixer_controls[] = {
  1221. SOC_SINGLE_EXT_TLV("SEC MI2S LOOPBACK Volume", SND_SOC_NOPM, 0,
  1222. INT_RX_VOL_GAIN, 0, msm_qti_pp_get_sec_mi2s_lb_vol_mixer,
  1223. msm_qti_pp_set_sec_mi2s_lb_vol_mixer, afe_lb_vol_gain),
  1224. };
  1225. static const struct snd_kcontrol_new tert_mi2s_lb_vol_mixer_controls[] = {
  1226. SOC_SINGLE_EXT_TLV("Tert MI2S LOOPBACK Volume", SND_SOC_NOPM, 0,
  1227. INT_RX_VOL_GAIN, 0, msm_qti_pp_get_tert_mi2s_lb_vol_mixer,
  1228. msm_qti_pp_set_tert_mi2s_lb_vol_mixer, afe_lb_vol_gain),
  1229. };
  1230. static const struct snd_kcontrol_new slimbus_7_lb_vol_mixer_controls[] = {
  1231. SOC_SINGLE_EXT_TLV("SLIMBUS_7 LOOPBACK Volume", SND_SOC_NOPM, 0,
  1232. INT_RX_VOL_GAIN, 0,
  1233. msm_qti_pp_get_slimbus_7_lb_vol_mixer,
  1234. msm_qti_pp_set_slimbus_7_lb_vol_mixer,
  1235. afe_lb_vol_gain),
  1236. };
  1237. static const struct snd_kcontrol_new slimbus_8_lb_vol_mixer_controls[] = {
  1238. SOC_SINGLE_EXT_TLV("SLIMBUS_8 LOOPBACK Volume", SND_SOC_NOPM, 0,
  1239. INT_RX_VOL_GAIN, 0, msm_qti_pp_get_slimbus_8_lb_vol_mixer,
  1240. msm_qti_pp_set_slimbus_8_lb_vol_mixer, afe_lb_vol_gain),
  1241. };
  1242. static const struct snd_kcontrol_new int_hfp_vol_mixer_controls[] = {
  1243. SOC_SINGLE_EXT_TLV("Internal HFP RX Volume", SND_SOC_NOPM, 0,
  1244. INT_RX_VOL_GAIN, 0, msm_qti_pp_get_hfp_vol_mixer,
  1245. msm_qti_pp_set_hfp_vol_mixer, hfp_rx_vol_gain),
  1246. };
  1247. static const struct snd_kcontrol_new int_icc_vol_mixer_controls[] = {
  1248. SOC_SINGLE_EXT_TLV("Internal ICC Volume", SND_SOC_NOPM, 0,
  1249. INT_RX_VOL_GAIN, 0, msm_qti_pp_get_icc_vol_mixer,
  1250. msm_qti_pp_set_icc_vol_mixer, icc_rx_vol_gain),
  1251. };
  1252. static const struct snd_kcontrol_new pri_auxpcm_lb_vol_mixer_controls[] = {
  1253. SOC_SINGLE_EXT_TLV("PRI AUXPCM LOOPBACK Volume",
  1254. AFE_PORT_ID_PRIMARY_PCM_TX, 0, INT_RX_VOL_GAIN, 0,
  1255. msm_qti_pp_get_pri_auxpcm_lb_vol_mixer,
  1256. msm_qti_pp_set_pri_auxpcm_lb_vol_mixer,
  1257. pri_auxpcm_lb_vol_gain),
  1258. };
  1259. static const struct snd_kcontrol_new sec_auxpcm_lb_vol_mixer_controls[] = {
  1260. SOC_SINGLE_EXT_TLV("SEC AUXPCM LOOPBACK Volume",
  1261. AFE_PORT_ID_SECONDARY_PCM_TX, 0, INT_RX_VOL_GAIN, 0,
  1262. msm_qti_pp_get_sec_auxpcm_lb_vol_mixer,
  1263. msm_qti_pp_set_sec_auxpcm_lb_vol_mixer,
  1264. sec_auxpcm_lb_vol_gain),
  1265. };
  1266. static const struct snd_kcontrol_new multi_ch_channel_map_mixer_controls[] = {
  1267. SOC_SINGLE_MULTI_EXT("Playback Device Channel Map", SND_SOC_NOPM, 0, 47,
  1268. 0, PCM_FORMAT_MAX_NUM_CHANNEL_V8, msm_qti_pp_get_channel_map_mixer,
  1269. msm_qti_pp_put_channel_map_mixer),
  1270. };
  1271. static const struct snd_kcontrol_new multi_ch_channel_map_capture_controls[] = {
  1272. SOC_SINGLE_MULTI_EXT("Capture Device Channel Map", SND_SOC_NOPM, 0, 47,
  1273. 0, PCM_FORMAT_MAX_NUM_CHANNEL_V8, msm_qti_pp_get_channel_map_capture,
  1274. msm_qti_pp_put_channel_map_capture),
  1275. };
  1276. static const struct snd_kcontrol_new get_rms_controls[] = {
  1277. SOC_SINGLE_EXT("Get RMS", SND_SOC_NOPM, 0, 0xFFFFFFFF,
  1278. 0, msm_qti_pp_get_rms_value_control, msm_qti_pp_put_rms_value_control),
  1279. };
  1280. static const struct snd_kcontrol_new eq_enable_mixer_controls[] = {
  1281. SOC_SINGLE_EXT("MultiMedia1 EQ Enable", SND_SOC_NOPM,
  1282. MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_qti_pp_get_eq_enable_mixer,
  1283. msm_qti_pp_put_eq_enable_mixer),
  1284. SOC_SINGLE_EXT("MultiMedia2 EQ Enable", SND_SOC_NOPM,
  1285. MSM_FRONTEND_DAI_MULTIMEDIA2, 1, 0, msm_qti_pp_get_eq_enable_mixer,
  1286. msm_qti_pp_put_eq_enable_mixer),
  1287. SOC_SINGLE_EXT("MultiMedia3 EQ Enable", SND_SOC_NOPM,
  1288. MSM_FRONTEND_DAI_MULTIMEDIA3, 1, 0, msm_qti_pp_get_eq_enable_mixer,
  1289. msm_qti_pp_put_eq_enable_mixer),
  1290. };
  1291. static const struct snd_kcontrol_new eq_band_mixer_controls[] = {
  1292. SOC_SINGLE_EXT("MultiMedia1 EQ Band Count", SND_SOC_NOPM,
  1293. MSM_FRONTEND_DAI_MULTIMEDIA1, 11, 0,
  1294. msm_qti_pp_get_eq_band_count_audio_mixer,
  1295. msm_qti_pp_put_eq_band_count_audio_mixer),
  1296. SOC_SINGLE_EXT("MultiMedia2 EQ Band Count", SND_SOC_NOPM,
  1297. MSM_FRONTEND_DAI_MULTIMEDIA2, 11, 0,
  1298. msm_qti_pp_get_eq_band_count_audio_mixer,
  1299. msm_qti_pp_put_eq_band_count_audio_mixer),
  1300. SOC_SINGLE_EXT("MultiMedia3 EQ Band Count", SND_SOC_NOPM,
  1301. MSM_FRONTEND_DAI_MULTIMEDIA3, 11, 0,
  1302. msm_qti_pp_get_eq_band_count_audio_mixer,
  1303. msm_qti_pp_put_eq_band_count_audio_mixer),
  1304. };
  1305. static const struct snd_kcontrol_new eq_coeff_mixer_controls[] = {
  1306. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band1", EQ_BAND1,
  1307. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1308. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1309. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band2", EQ_BAND2,
  1310. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1311. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1312. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band3", EQ_BAND3,
  1313. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1314. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1315. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band4", EQ_BAND4,
  1316. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1317. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1318. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band5", EQ_BAND5,
  1319. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1320. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1321. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band6", EQ_BAND6,
  1322. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1323. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1324. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band7", EQ_BAND7,
  1325. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1326. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1327. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band8", EQ_BAND8,
  1328. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1329. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1330. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band9", EQ_BAND9,
  1331. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1332. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1333. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band10", EQ_BAND10,
  1334. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1335. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1336. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band11", EQ_BAND11,
  1337. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1338. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1339. SOC_SINGLE_MULTI_EXT("MultiMedia1 EQ Band12", EQ_BAND12,
  1340. MSM_FRONTEND_DAI_MULTIMEDIA1, 255, 0, 5,
  1341. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1342. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band1", EQ_BAND1,
  1343. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1344. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1345. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band2", EQ_BAND2,
  1346. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1347. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1348. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band3", EQ_BAND3,
  1349. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1350. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1351. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band4", EQ_BAND4,
  1352. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1353. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1354. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band5", EQ_BAND5,
  1355. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1356. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1357. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band6", EQ_BAND6,
  1358. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1359. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1360. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band7", EQ_BAND7,
  1361. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1362. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1363. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band8", EQ_BAND8,
  1364. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1365. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1366. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band9", EQ_BAND9,
  1367. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1368. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1369. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band10", EQ_BAND10,
  1370. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1371. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1372. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band11", EQ_BAND11,
  1373. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1374. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1375. SOC_SINGLE_MULTI_EXT("MultiMedia2 EQ Band12", EQ_BAND12,
  1376. MSM_FRONTEND_DAI_MULTIMEDIA2, 255, 0, 5,
  1377. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1378. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band1", EQ_BAND1,
  1379. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1380. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1381. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band2", EQ_BAND2,
  1382. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1383. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1384. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band3", EQ_BAND3,
  1385. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1386. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1387. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band4", EQ_BAND4,
  1388. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1389. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1390. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band5", EQ_BAND5,
  1391. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1392. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1393. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band6", EQ_BAND6,
  1394. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1395. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1396. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band7", EQ_BAND7,
  1397. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1398. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1399. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band8", EQ_BAND8,
  1400. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1401. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1402. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band9", EQ_BAND9,
  1403. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1404. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1405. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band10", EQ_BAND10,
  1406. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1407. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1408. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band11", EQ_BAND11,
  1409. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1410. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1411. SOC_SINGLE_MULTI_EXT("MultiMedia3 EQ Band12", EQ_BAND12,
  1412. MSM_FRONTEND_DAI_MULTIMEDIA3, 255, 0, 5,
  1413. msm_qti_pp_get_eq_band_audio_mixer, msm_qti_pp_put_eq_band_audio_mixer),
  1414. };
  1415. static const struct snd_kcontrol_new asphere_mixer_controls[] = {
  1416. SOC_SINGLE_MULTI_EXT("MSM ASphere Set Param", SND_SOC_NOPM, 0,
  1417. 0xFFFFFFFF, 0, 2, msm_qti_pp_asphere_get, msm_qti_pp_asphere_set),
  1418. };
  1419. #ifdef CONFIG_QTI_PP
  1420. void msm_qti_pp_add_controls(struct snd_soc_component *component)
  1421. {
  1422. snd_soc_add_component_controls(component, int_fm_vol_mixer_controls,
  1423. ARRAY_SIZE(int_fm_vol_mixer_controls));
  1424. snd_soc_add_component_controls(component,
  1425. pri_mi2s_lb_vol_mixer_controls,
  1426. ARRAY_SIZE(pri_mi2s_lb_vol_mixer_controls));
  1427. snd_soc_add_component_controls(component,
  1428. sec_mi2s_lb_vol_mixer_controls,
  1429. ARRAY_SIZE(sec_mi2s_lb_vol_mixer_controls));
  1430. snd_soc_add_component_controls(component,
  1431. tert_mi2s_lb_vol_mixer_controls,
  1432. ARRAY_SIZE(tert_mi2s_lb_vol_mixer_controls));
  1433. snd_soc_add_component_controls(component,
  1434. slimbus_7_lb_vol_mixer_controls,
  1435. ARRAY_SIZE(slimbus_7_lb_vol_mixer_controls));
  1436. snd_soc_add_component_controls(component,
  1437. slimbus_8_lb_vol_mixer_controls,
  1438. ARRAY_SIZE(slimbus_8_lb_vol_mixer_controls));
  1439. snd_soc_add_component_controls(component, int_hfp_vol_mixer_controls,
  1440. ARRAY_SIZE(int_hfp_vol_mixer_controls));
  1441. snd_soc_add_component_controls(component, int_icc_vol_mixer_controls,
  1442. ARRAY_SIZE(int_icc_vol_mixer_controls));
  1443. snd_soc_add_component_controls(component,
  1444. pri_auxpcm_lb_vol_mixer_controls,
  1445. ARRAY_SIZE(pri_auxpcm_lb_vol_mixer_controls));
  1446. snd_soc_add_component_controls(component,
  1447. sec_auxpcm_lb_vol_mixer_controls,
  1448. ARRAY_SIZE(sec_auxpcm_lb_vol_mixer_controls));
  1449. snd_soc_add_component_controls(component,
  1450. multi_ch_channel_map_mixer_controls,
  1451. ARRAY_SIZE(multi_ch_channel_map_mixer_controls));
  1452. snd_soc_add_component_controls(component, get_rms_controls,
  1453. ARRAY_SIZE(get_rms_controls));
  1454. snd_soc_add_component_controls(component,
  1455. multi_ch_channel_map_capture_controls,
  1456. ARRAY_SIZE(multi_ch_channel_map_capture_controls));
  1457. snd_soc_add_component_controls(component, eq_enable_mixer_controls,
  1458. ARRAY_SIZE(eq_enable_mixer_controls));
  1459. snd_soc_add_component_controls(component, eq_band_mixer_controls,
  1460. ARRAY_SIZE(eq_band_mixer_controls));
  1461. snd_soc_add_component_controls(component, eq_coeff_mixer_controls,
  1462. ARRAY_SIZE(eq_coeff_mixer_controls));
  1463. snd_soc_add_component_controls(component, asphere_mixer_controls,
  1464. ARRAY_SIZE(asphere_mixer_controls));
  1465. snd_soc_add_component_controls(component, msm_multichannel_ec_controls,
  1466. ARRAY_SIZE(msm_multichannel_ec_controls));
  1467. snd_soc_add_component_controls(component, dsp_bit_width_controls,
  1468. ARRAY_SIZE(dsp_bit_width_controls));
  1469. snd_soc_add_component_controls(component, ec_ffecns_controls,
  1470. ARRAY_SIZE(ec_ffecns_controls));
  1471. }
  1472. #endif /* CONFIG_QTI_PP */