msm-qti-pp-config.c 53 KB

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