msm-qti-pp-config.c 51 KB

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