msm-qti-pp-config.c 54 KB

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