msm-qti-pp-config.c 54 KB

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