pineapple.c 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022. Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/clk.h>
  7. #include <linux/delay.h>
  8. #include <linux/gpio.h>
  9. #include <linux/of_gpio.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/slab.h>
  12. #include <linux/io.h>
  13. #include <linux/module.h>
  14. #include <linux/input.h>
  15. #include <linux/of_device.h>
  16. #include <linux/soc/qcom/fsa4480-i2c.h>
  17. #include <linux/pm_qos.h>
  18. #include <sound/control.h>
  19. #include <sound/core.h>
  20. #include <sound/soc.h>
  21. #include <sound/soc-dapm.h>
  22. #include <sound/pcm.h>
  23. #include <sound/pcm_params.h>
  24. #include <sound/info.h>
  25. #include <soc/snd_event.h>
  26. #include <dsp/audio_prm.h>
  27. #include <soc/swr-common.h>
  28. #include <soc/soundwire.h>
  29. #include "device_event.h"
  30. #include "asoc/msm-cdc-pinctrl.h"
  31. #include "asoc/wcd-mbhc-v2.h"
  32. #include "codecs/wcd938x/wcd938x-mbhc.h"
  33. #include "codecs/wsa884x/wsa884x.h"
  34. #include "codecs/wsa883x/wsa883x.h"
  35. #include "codecs/wcd938x/wcd938x.h"
  36. #include "codecs/lpass-cdc/lpass-cdc.h"
  37. #include <bindings/audio-codec-port-types.h>
  38. #include "codecs/lpass-cdc/lpass-cdc-wsa-macro.h"
  39. #include "pineapple-port-config.h"
  40. #include "msm-audio-defs.h"
  41. #include "msm_common.h"
  42. #include "msm_dailink.h"
  43. #define DRV_NAME "pineapple-asoc-snd"
  44. #define __CHIPSET__ "PINEAPPLE "
  45. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  46. #define WCD9XXX_MBHC_DEF_RLOADS 5
  47. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  48. #define CODEC_EXT_CLK_RATE 9600000
  49. #define DEV_NAME_STR_LEN 32
  50. #define WCD_MBHC_HS_V_MAX 1600
  51. #define WCN_CDC_SLIM_RX_CH_MAX 2
  52. #define WCN_CDC_SLIM_TX_CH_MAX 2
  53. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  54. /* Number of WSAs */
  55. #define MONO_SPEAKER 1
  56. #define STEREO_SPEAKER 2
  57. #define QUAD_SPEAKER 4
  58. struct msm_asoc_mach_data {
  59. struct snd_info_entry *codec_root;
  60. struct msm_common_pdata *common_pdata;
  61. int usbc_en2_gpio; /* used by gpio driver API */
  62. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  63. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  64. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  65. struct device_node *dmic67_gpio_p; /* used by pinctrl API */
  66. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  67. bool is_afe_config_done;
  68. struct device_node *fsa_handle;
  69. struct clk *lpass_audio_hw_vote;
  70. int core_audio_vote_count;
  71. u32 wsa_max_devs;
  72. int wcd_disabled;
  73. int (*get_dev_num)(struct snd_soc_component *);
  74. int backend_used;
  75. struct prm_earpa_hw_intf_config upd_config;
  76. };
  77. static bool is_initial_boot;
  78. static bool codec_reg_done;
  79. static struct snd_soc_card snd_soc_card_pineapple_msm;
  80. static int dmic_0_1_gpio_cnt;
  81. static int dmic_2_3_gpio_cnt;
  82. static int dmic_4_5_gpio_cnt;
  83. static int dmic_6_7_gpio_cnt;
  84. static void *def_wcd_mbhc_cal(void);
  85. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime*);
  86. static int msm_int_wsa_init(struct snd_soc_pcm_runtime*);
  87. static int msm_int_wsa884x_init(struct snd_soc_pcm_runtime*);
  88. static int msm_int_wsa883x_init(struct snd_soc_pcm_runtime*);
  89. /*
  90. * Need to report LINEIN
  91. * if R/L channel impedance is larger than 5K ohm
  92. */
  93. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  94. .read_fw_bin = false,
  95. .calibration = NULL,
  96. .detect_extn_cable = true,
  97. .mono_stero_detection = false,
  98. .swap_gnd_mic = NULL,
  99. .hs_ext_micbias = true,
  100. .key_code[0] = KEY_MEDIA,
  101. .key_code[1] = KEY_VOICECOMMAND,
  102. .key_code[2] = KEY_VOLUMEUP,
  103. .key_code[3] = KEY_VOLUMEDOWN,
  104. .key_code[4] = 0,
  105. .key_code[5] = 0,
  106. .key_code[6] = 0,
  107. .key_code[7] = 0,
  108. .linein_th = 5000,
  109. .moisture_en = false,
  110. .mbhc_micbias = MIC_BIAS_2,
  111. .anc_micbias = MIC_BIAS_2,
  112. .enable_anc_mic_detect = false,
  113. .moisture_duty_cycle_en = true,
  114. };
  115. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  116. {
  117. struct snd_soc_card *card = component->card;
  118. struct msm_asoc_mach_data *pdata =
  119. snd_soc_card_get_drvdata(card);
  120. if (!pdata->fsa_handle)
  121. return false;
  122. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  123. }
  124. static void msm_parse_upd_configuration(struct platform_device *pdev,
  125. struct msm_asoc_mach_data *pdata)
  126. {
  127. int ret = 0;
  128. u32 dt_values[2];
  129. struct snd_soc_card *card = NULL;
  130. if (!pdev || !pdata)
  131. return;
  132. ret = of_property_read_string(pdev->dev.of_node,
  133. "qcom,upd_backends_used", &pdata->upd_config.backend_used);
  134. if (ret) {
  135. pr_debug("%s:could not find %s entry in dt\n",
  136. __func__, "qcom,upd_backends_used");
  137. return;
  138. }
  139. if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
  140. card = (struct snd_soc_card *)platform_get_drvdata(pdev);
  141. if (strstr(card->name, "wsa883x"))
  142. pdata->get_dev_num = wsa883x_codec_get_dev_num;
  143. else
  144. pdata->get_dev_num = wsa884x_codec_get_dev_num;
  145. } else {
  146. pdata->get_dev_num = wcd938x_codec_get_dev_num;
  147. }
  148. ret = of_property_read_u32_array(pdev->dev.of_node,
  149. "qcom,upd_lpass_reg_addr", dt_values, MAX_EARPA_REG);
  150. if (ret) {
  151. pr_debug("%s: could not find %s entry in dt\n",
  152. __func__, "qcom,upd_lpass_reg_addr");
  153. return;
  154. } else {
  155. pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr =
  156. dt_values[0];
  157. pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr =
  158. dt_values[1];
  159. }
  160. ret = of_property_read_u32(pdev->dev.of_node,
  161. "qcom,upd_ear_pa_reg_addr", &pdata->upd_config.ear_pa_pkd_reg_addr);
  162. if (ret) {
  163. pr_debug("%s: could not find %s entry in dt\n",
  164. __func__, "qcom,upd_ear_pa_reg_addr");
  165. }
  166. }
  167. static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
  168. {
  169. int val1 = 0, val2 = 0, ret = 0;
  170. u8 dev_num = 0;
  171. char cdc_name[DEV_NAME_STR_LEN];
  172. struct snd_soc_component *component = NULL;
  173. struct msm_asoc_mach_data *pdata = NULL;
  174. if (!rtd) {
  175. pr_err_ratelimited("%s: rtd is NULL\n", __func__);
  176. return;
  177. }
  178. pdata = snd_soc_card_get_drvdata(rtd->card);
  179. if (!pdata) {
  180. pr_err_ratelimited("%s: pdata is NULL\n", __func__);
  181. return;
  182. }
  183. if (!pdata->get_dev_num) {
  184. pr_err_ratelimited("%s: get_dev_num is NULL\n", __func__);
  185. return;
  186. }
  187. if (!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr ||
  188. !pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr ||
  189. !pdata->upd_config.ear_pa_pkd_reg_addr) {
  190. pr_err_ratelimited("%s: upd static configuration is not set\n", __func__);
  191. return;
  192. }
  193. memset(cdc_name, '\0', DEV_NAME_STR_LEN);
  194. if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
  195. if (pdata->wsa_max_devs > 0)
  196. memcpy(cdc_name, "wsa-codec.1", strlen("wsa-codec.1"));
  197. }
  198. else
  199. memcpy(cdc_name, WCD938X_DRV_NAME, sizeof(WCD938X_DRV_NAME));
  200. component = snd_soc_rtdcom_lookup(rtd, cdc_name);
  201. if (!component) {
  202. pr_err_ratelimited("%s: %s component is NULL\n", __func__,
  203. cdc_name);
  204. return;
  205. }
  206. dev_num = pdata->get_dev_num(component);
  207. if (dev_num < 0 || dev_num > 6) {
  208. pr_err_ratelimited("%s: invalid slave dev num : %d\n", __func__,
  209. dev_num);
  210. return;
  211. }
  212. pdata->upd_config.ear_pa_pkd_cfg.ear_pa_enable_pkd_reg_addr =
  213. pdata->upd_config.ear_pa_pkd_reg_addr & 0xFFFF;
  214. pdata->upd_config.ear_pa_pkd_cfg.ear_pa_disable_pkd_reg_addr =
  215. pdata->upd_config.ear_pa_pkd_reg_addr & 0xFFFF;
  216. val1 = val2 = 0;
  217. /* bits 16:19 carry command id */
  218. val1 |= 1 << 16;
  219. /* bits 20:23 carry swr device number */
  220. val1 |= dev_num << 20;
  221. /*
  222. * bits 24:31 carry 8 bit data to disable or enable ear pa
  223. * for wcd 7bit is global enable bit - 1 -enable. 0 - disable
  224. * for wsa 0bit is global enable bit - 1 -enable, 0 - disable
  225. */
  226. val2 = val1;
  227. if (!strcmp(pdata->upd_config.backend_used, "wsa"))
  228. val1 |= 1 << 24;
  229. else
  230. val1 |= 1 << 31;
  231. pdata->upd_config.ear_pa_pkd_cfg.ear_pa_enable_pkd_reg_addr |= val1;
  232. pdata->upd_config.ear_pa_pkd_cfg.ear_pa_disable_pkd_reg_addr |= val2;
  233. ret = audio_prm_set_cdc_earpa_duty_cycling_req(&pdata->upd_config, 1);
  234. if (ret < 0)
  235. pr_err_ratelimited("%s: upd cdc duty cycling registration failed\n", __func__);
  236. }
  237. static struct snd_soc_ops msm_common_be_ops = {
  238. .hw_params = msm_common_snd_hw_params,
  239. .startup = msm_common_snd_startup,
  240. .shutdown = msm_common_snd_shutdown,
  241. };
  242. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  243. struct snd_kcontrol *kcontrol, int event)
  244. {
  245. struct msm_asoc_mach_data *pdata = NULL;
  246. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  247. int ret = 0;
  248. u32 dmic_idx;
  249. int *dmic_gpio_cnt;
  250. struct device_node *dmic_gpio;
  251. char *wname;
  252. wname = strpbrk(w->name, "01234567");
  253. if (!wname) {
  254. dev_err_ratelimited(component->dev, "%s: widget not found\n", __func__);
  255. return -EINVAL;
  256. }
  257. ret = kstrtouint(wname, 10, &dmic_idx);
  258. if (ret < 0) {
  259. dev_err_ratelimited(component->dev, "%s: Invalid DMIC line on the codec\n",
  260. __func__);
  261. return -EINVAL;
  262. }
  263. pdata = snd_soc_card_get_drvdata(component->card);
  264. switch (dmic_idx) {
  265. case 0:
  266. case 1:
  267. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  268. dmic_gpio = pdata->dmic01_gpio_p;
  269. break;
  270. case 2:
  271. case 3:
  272. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  273. dmic_gpio = pdata->dmic23_gpio_p;
  274. break;
  275. case 4:
  276. case 5:
  277. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  278. dmic_gpio = pdata->dmic45_gpio_p;
  279. break;
  280. case 6:
  281. case 7:
  282. dmic_gpio_cnt = &dmic_6_7_gpio_cnt;
  283. dmic_gpio = pdata->dmic67_gpio_p;
  284. break;
  285. default:
  286. dev_err_ratelimited(component->dev, "%s: Invalid DMIC Selection\n",
  287. __func__);
  288. return -EINVAL;
  289. }
  290. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  291. __func__, event, dmic_idx, *dmic_gpio_cnt);
  292. switch (event) {
  293. case SND_SOC_DAPM_PRE_PMU:
  294. (*dmic_gpio_cnt)++;
  295. if (*dmic_gpio_cnt == 1) {
  296. ret = msm_cdc_pinctrl_select_active_state(
  297. dmic_gpio);
  298. if (ret < 0) {
  299. pr_err_ratelimited("%s: gpio set cannot be activated %sd",
  300. __func__, "dmic_gpio");
  301. return ret;
  302. }
  303. }
  304. break;
  305. case SND_SOC_DAPM_POST_PMD:
  306. (*dmic_gpio_cnt)--;
  307. if (*dmic_gpio_cnt == 0) {
  308. ret = msm_cdc_pinctrl_select_sleep_state(
  309. dmic_gpio);
  310. if (ret < 0) {
  311. pr_err_ratelimited("%s: gpio set cannot be de-activated %sd",
  312. __func__, "dmic_gpio");
  313. return ret;
  314. }
  315. }
  316. break;
  317. default:
  318. pr_err_ratelimited("%s: invalid DAPM event %d\n", __func__, event);
  319. return -EINVAL;
  320. }
  321. return 0;
  322. }
  323. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  324. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  325. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  326. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  327. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  328. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  329. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  330. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  331. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  332. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  333. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  334. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  335. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  336. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  337. };
  338. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  339. {
  340. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  341. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  342. struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
  343. int ret = 0;
  344. ret = snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  345. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  346. if (ret)
  347. return ret;
  348. msm_common_dai_link_init(rtd);
  349. return ret;
  350. }
  351. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  352. const char *name,
  353. struct snd_info_entry *parent)
  354. {
  355. struct snd_info_entry *entry;
  356. entry = snd_info_create_module_entry(mod, name, parent);
  357. if (!entry)
  358. return NULL;
  359. entry->mode = S_IFDIR | 0555;
  360. if (snd_info_register(entry) < 0) {
  361. snd_info_free_entry(entry);
  362. return NULL;
  363. }
  364. return entry;
  365. }
  366. static void *def_wcd_mbhc_cal(void)
  367. {
  368. void *wcd_mbhc_cal;
  369. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  370. u16 *btn_high;
  371. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  372. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  373. if (!wcd_mbhc_cal)
  374. return NULL;
  375. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  376. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  377. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  378. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  379. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  380. btn_high[0] = 75;
  381. btn_high[1] = 150;
  382. btn_high[2] = 237;
  383. btn_high[3] = 500;
  384. btn_high[4] = 500;
  385. btn_high[5] = 500;
  386. btn_high[6] = 500;
  387. btn_high[7] = 500;
  388. return wcd_mbhc_cal;
  389. }
  390. /* Digital audio interface glue - connects codec <---> CPU */
  391. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  392. /* Proxy Tx BACK END DAI Link */
  393. {
  394. .name = LPASS_BE_RT_PROXY_PCM_TX,
  395. .stream_name = LPASS_BE_RT_PROXY_PCM_TX,
  396. .capture_only = 1,
  397. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  398. SND_SOC_DPCM_TRIGGER_POST},
  399. .ignore_suspend = 1,
  400. .ops = &msm_common_be_ops,
  401. SND_SOC_DAILINK_REG(proxy_tx),
  402. },
  403. /* Proxy Rx BACK END DAI Link */
  404. {
  405. .name = LPASS_BE_RT_PROXY_PCM_RX,
  406. .stream_name = LPASS_BE_RT_PROXY_PCM_RX,
  407. .playback_only = 1,
  408. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  409. SND_SOC_DPCM_TRIGGER_POST},
  410. .ignore_pmdown_time = 1,
  411. .ignore_suspend = 1,
  412. .ops = &msm_common_be_ops,
  413. SND_SOC_DAILINK_REG(proxy_rx),
  414. },
  415. {
  416. .name = LPASS_BE_USB_AUDIO_RX,
  417. .stream_name = LPASS_BE_USB_AUDIO_RX,
  418. .playback_only = 1,
  419. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  420. SND_SOC_DPCM_TRIGGER_POST},
  421. .ignore_pmdown_time = 1,
  422. .ignore_suspend = 1,
  423. .ops = &msm_common_be_ops,
  424. SND_SOC_DAILINK_REG(usb_audio_rx),
  425. },
  426. {
  427. .name = LPASS_BE_USB_AUDIO_TX,
  428. .stream_name = LPASS_BE_USB_AUDIO_TX,
  429. .capture_only = 1,
  430. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  431. SND_SOC_DPCM_TRIGGER_POST},
  432. .ignore_suspend = 1,
  433. .ops = &msm_common_be_ops,
  434. SND_SOC_DAILINK_REG(usb_audio_tx),
  435. },
  436. {
  437. .name = LPASS_BE_PCM_DUMMY_TX_0,
  438. .stream_name = LPASS_BE_PCM_DUMMY_TX_0,
  439. .capture_only = 1,
  440. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  441. SND_SOC_DPCM_TRIGGER_POST},
  442. .ignore_suspend = 1,
  443. .ops = &msm_common_be_ops,
  444. SND_SOC_DAILINK_REG(pcm_dummy_tx0),
  445. },
  446. };
  447. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  448. {
  449. .name = LPASS_BE_SLIMBUS_7_RX,
  450. .stream_name = LPASS_BE_SLIMBUS_7_RX,
  451. .playback_only = 1,
  452. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  453. SND_SOC_DPCM_TRIGGER_POST},
  454. .init = &msm_wcn_init,
  455. .ops = &msm_common_be_ops,
  456. /* dai link has playback support */
  457. .ignore_pmdown_time = 1,
  458. .ignore_suspend = 1,
  459. SND_SOC_DAILINK_REG(slimbus_7_rx),
  460. },
  461. {
  462. .name = LPASS_BE_SLIMBUS_7_TX,
  463. .stream_name = LPASS_BE_SLIMBUS_7_TX,
  464. .capture_only = 1,
  465. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  466. SND_SOC_DPCM_TRIGGER_POST},
  467. .ops = &msm_common_be_ops,
  468. .ignore_suspend = 1,
  469. SND_SOC_DAILINK_REG(slimbus_7_tx),
  470. },
  471. };
  472. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  473. /* DISP PORT BACK END DAI Link */
  474. {
  475. .name = LPASS_BE_DISPLAY_PORT_RX,
  476. .stream_name = LPASS_BE_DISPLAY_PORT_RX,
  477. .playback_only = 1,
  478. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  479. SND_SOC_DPCM_TRIGGER_POST},
  480. .ignore_pmdown_time = 1,
  481. .ignore_suspend = 1,
  482. SND_SOC_DAILINK_REG(display_port),
  483. },
  484. };
  485. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  486. /* WSA CDC DMA Backend DAI Links */
  487. {
  488. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  489. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0,
  490. .playback_only = 1,
  491. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  492. SND_SOC_DPCM_TRIGGER_POST},
  493. .ignore_pmdown_time = 1,
  494. .ignore_suspend = 1,
  495. .ops = &msm_common_be_ops,
  496. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  497. .init = &msm_int_wsa_init,
  498. },
  499. {
  500. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  501. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_1,
  502. .playback_only = 1,
  503. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  504. SND_SOC_DPCM_TRIGGER_POST},
  505. .ignore_pmdown_time = 1,
  506. .ignore_suspend = 1,
  507. .ops = &msm_common_be_ops,
  508. SND_SOC_DAILINK_REG(wsa_dma_rx1),
  509. },
  510. {
  511. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  512. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_1,
  513. .capture_only = 1,
  514. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  515. SND_SOC_DPCM_TRIGGER_POST},
  516. .ignore_suspend = 1,
  517. .ops = &msm_common_be_ops,
  518. SND_SOC_DAILINK_REG(wsa_dma_tx1),
  519. },
  520. {
  521. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  522. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_0,
  523. .capture_only = 1,
  524. .ignore_suspend = 1,
  525. .ops = &msm_common_be_ops,
  526. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  527. SND_SOC_DAILINK_REG(vi_feedback),
  528. },
  529. {
  530. .name = LPASS_BE_WSA_CDC_DMA_TX_2,
  531. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_2,
  532. .capture_only = 1,
  533. .ignore_suspend = 1,
  534. .ops = &msm_common_be_ops,
  535. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  536. SND_SOC_DAILINK_REG(cps_feedback),
  537. },
  538. {
  539. .name = LPASS_BE_WSA_CDC_DMA_RX_0_VIRT,
  540. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0_VIRT,
  541. .playback_only = 1,
  542. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  543. SND_SOC_DPCM_TRIGGER_POST},
  544. .ignore_pmdown_time = 1,
  545. .ignore_suspend = 1,
  546. .ops = &msm_common_be_ops,
  547. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  548. .init = &msm_int_wsa_init,
  549. },
  550. };
  551. static struct snd_soc_dai_link msm_wsa2_cdc_dma_be_dai_links[] = {
  552. /* WSA2 CDC DMA Backend DAI Links */
  553. {
  554. .name = LPASS_BE_WSA2_CDC_DMA_RX_0,
  555. .stream_name = LPASS_BE_WSA2_CDC_DMA_RX_0,
  556. .playback_only = 1,
  557. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  558. SND_SOC_DPCM_TRIGGER_POST},
  559. .ignore_pmdown_time = 1,
  560. .ignore_suspend = 1,
  561. .ops = &msm_common_be_ops,
  562. SND_SOC_DAILINK_REG(wsa2_dma_rx0),
  563. },
  564. {
  565. .name = LPASS_BE_WSA2_CDC_DMA_RX_1,
  566. .stream_name = LPASS_BE_WSA2_CDC_DMA_RX_1,
  567. .playback_only = 1,
  568. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  569. SND_SOC_DPCM_TRIGGER_POST},
  570. .ignore_pmdown_time = 1,
  571. .ignore_suspend = 1,
  572. .ops = &msm_common_be_ops,
  573. SND_SOC_DAILINK_REG(wsa2_dma_rx1),
  574. },
  575. {
  576. .name = LPASS_BE_WSA2_CDC_DMA_TX_1,
  577. .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_1,
  578. .capture_only = 1,
  579. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  580. SND_SOC_DPCM_TRIGGER_POST},
  581. .ignore_suspend = 1,
  582. .ops = &msm_common_be_ops,
  583. SND_SOC_DAILINK_REG(wsa2_dma_tx1),
  584. },
  585. {
  586. .name = LPASS_BE_WSA2_CDC_DMA_TX_0,
  587. .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_0,
  588. .capture_only = 1,
  589. .ignore_suspend = 1,
  590. .ops = &msm_common_be_ops,
  591. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  592. SND_SOC_DAILINK_REG(wsa2_vi_feedback),
  593. },
  594. {
  595. .name = LPASS_BE_WSA2_CDC_DMA_TX_2,
  596. .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_2,
  597. .capture_only = 1,
  598. .ignore_suspend = 1,
  599. .ops = &msm_common_be_ops,
  600. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  601. SND_SOC_DAILINK_REG(wsa2_cps_feedback),
  602. },
  603. };
  604. static struct snd_soc_dai_link msm_wsa_wsa2_cdc_dma_be_dai_links[] = {
  605. /* WSA CDC DMA Backend DAI Links */
  606. {
  607. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  608. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0,
  609. .playback_only = 1,
  610. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  611. SND_SOC_DPCM_TRIGGER_POST},
  612. .ignore_pmdown_time = 1,
  613. .ignore_suspend = 1,
  614. .ops = &msm_common_be_ops,
  615. SND_SOC_DAILINK_REG(wsa_wsa2_dma_rx0),
  616. .init = &msm_int_wsa_init,
  617. },
  618. {
  619. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  620. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_1,
  621. .playback_only = 1,
  622. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  623. SND_SOC_DPCM_TRIGGER_POST},
  624. .ignore_pmdown_time = 1,
  625. .ignore_suspend = 1,
  626. .ops = &msm_common_be_ops,
  627. SND_SOC_DAILINK_REG(wsa_wsa2_dma_rx1),
  628. },
  629. {
  630. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  631. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_1,
  632. .capture_only = 1,
  633. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  634. SND_SOC_DPCM_TRIGGER_POST},
  635. .ignore_suspend = 1,
  636. .ops = &msm_common_be_ops,
  637. SND_SOC_DAILINK_REG(wsa_wsa2_dma_tx1),
  638. },
  639. {
  640. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  641. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_0,
  642. .capture_only = 1,
  643. .ignore_suspend = 1,
  644. .ops = &msm_common_be_ops,
  645. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  646. SND_SOC_DAILINK_REG(wsa_wsa2_vi_feedback),
  647. },
  648. {
  649. .name = LPASS_BE_WSA_CDC_DMA_TX_2,
  650. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_2,
  651. .capture_only = 1,
  652. .ignore_suspend = 1,
  653. .ops = &msm_common_be_ops,
  654. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  655. SND_SOC_DAILINK_REG(wsa_wsa2_cps_feedback),
  656. },
  657. };
  658. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  659. /* RX CDC DMA Backend DAI Links */
  660. {
  661. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  662. .stream_name = LPASS_BE_RX_CDC_DMA_RX_0,
  663. .playback_only = 1,
  664. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  665. SND_SOC_DPCM_TRIGGER_POST},
  666. .ignore_pmdown_time = 1,
  667. .ignore_suspend = 1,
  668. .ops = &msm_common_be_ops,
  669. SND_SOC_DAILINK_REG(rx_dma_rx0),
  670. .init = &msm_rx_tx_codec_init,
  671. },
  672. {
  673. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  674. .stream_name = LPASS_BE_RX_CDC_DMA_RX_1,
  675. .playback_only = 1,
  676. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  677. SND_SOC_DPCM_TRIGGER_POST},
  678. .ignore_pmdown_time = 1,
  679. .ignore_suspend = 1,
  680. .ops = &msm_common_be_ops,
  681. SND_SOC_DAILINK_REG(rx_dma_rx1),
  682. },
  683. {
  684. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  685. .stream_name = LPASS_BE_RX_CDC_DMA_RX_2,
  686. .playback_only = 1,
  687. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  688. SND_SOC_DPCM_TRIGGER_POST},
  689. .ignore_pmdown_time = 1,
  690. .ignore_suspend = 1,
  691. .ops = &msm_common_be_ops,
  692. SND_SOC_DAILINK_REG(rx_dma_rx2),
  693. },
  694. {
  695. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  696. .stream_name = LPASS_BE_RX_CDC_DMA_RX_3,
  697. .playback_only = 1,
  698. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  699. SND_SOC_DPCM_TRIGGER_POST},
  700. .ignore_pmdown_time = 1,
  701. .ignore_suspend = 1,
  702. .ops = &msm_common_be_ops,
  703. SND_SOC_DAILINK_REG(rx_dma_rx3),
  704. },
  705. {
  706. .name = LPASS_BE_RX_CDC_DMA_RX_5,
  707. .stream_name = LPASS_BE_RX_CDC_DMA_RX_5,
  708. .playback_only = 1,
  709. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  710. SND_SOC_DPCM_TRIGGER_POST},
  711. .ignore_pmdown_time = 1,
  712. .ignore_suspend = 1,
  713. .ops = &msm_common_be_ops,
  714. SND_SOC_DAILINK_REG(rx_dma_rx5),
  715. },
  716. {
  717. .name = LPASS_BE_RX_CDC_DMA_RX_6,
  718. .stream_name = LPASS_BE_RX_CDC_DMA_RX_6,
  719. .playback_only = 1,
  720. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  721. SND_SOC_DPCM_TRIGGER_POST},
  722. .ignore_pmdown_time = 1,
  723. .ignore_suspend = 1,
  724. .ops = &msm_common_be_ops,
  725. SND_SOC_DAILINK_REG(rx_dma_rx6),
  726. },
  727. /* TX CDC DMA Backend DAI Links */
  728. {
  729. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  730. .stream_name = LPASS_BE_TX_CDC_DMA_TX_3,
  731. .capture_only = 1,
  732. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  733. SND_SOC_DPCM_TRIGGER_POST},
  734. .ignore_suspend = 1,
  735. .ops = &msm_common_be_ops,
  736. SND_SOC_DAILINK_REG(tx_dma_tx3),
  737. },
  738. {
  739. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  740. .stream_name = LPASS_BE_TX_CDC_DMA_TX_4,
  741. .capture_only = 1,
  742. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  743. SND_SOC_DPCM_TRIGGER_POST},
  744. .ignore_suspend = 1,
  745. .ops = &msm_common_be_ops,
  746. SND_SOC_DAILINK_REG(tx_dma_tx4),
  747. },
  748. };
  749. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  750. {
  751. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  752. .stream_name = LPASS_BE_VA_CDC_DMA_TX_0,
  753. .capture_only = 1,
  754. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  755. SND_SOC_DPCM_TRIGGER_POST},
  756. .ignore_suspend = 1,
  757. .ops = &msm_common_be_ops,
  758. SND_SOC_DAILINK_REG(va_dma_tx0),
  759. },
  760. {
  761. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  762. .stream_name = LPASS_BE_VA_CDC_DMA_TX_1,
  763. .capture_only = 1,
  764. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  765. SND_SOC_DPCM_TRIGGER_POST},
  766. .ignore_suspend = 1,
  767. .ops = &msm_common_be_ops,
  768. SND_SOC_DAILINK_REG(va_dma_tx1),
  769. },
  770. {
  771. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  772. .stream_name = LPASS_BE_VA_CDC_DMA_TX_2,
  773. .capture_only = 1,
  774. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  775. SND_SOC_DPCM_TRIGGER_POST},
  776. .ignore_suspend = 1,
  777. .ops = &msm_common_be_ops,
  778. SND_SOC_DAILINK_REG(va_dma_tx2),
  779. },
  780. };
  781. /*
  782. * I2S interface pinctrl mapping
  783. * ------------------------------------
  784. * Primary - pri_mi2s
  785. * Secondary - lpi_i2s3
  786. * Tertiary - tert_mi2s
  787. * Quaternary - quat_mi2s (lpi_i2s0)
  788. * Quinary - lpi_i2s1
  789. * Senary - lpi_i2s2
  790. * ------------------------------------
  791. */
  792. static struct snd_soc_dai_link msm_mi2s_dai_links[] = {
  793. {
  794. .name = LPASS_BE_PRI_MI2S_RX,
  795. .stream_name = LPASS_BE_PRI_MI2S_RX,
  796. .playback_only = 1,
  797. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  798. SND_SOC_DPCM_TRIGGER_POST},
  799. .ops = &msm_common_be_ops,
  800. .ignore_suspend = 1,
  801. .ignore_pmdown_time = 1,
  802. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  803. },
  804. {
  805. .name = LPASS_BE_PRI_MI2S_TX,
  806. .stream_name = LPASS_BE_PRI_MI2S_TX,
  807. .capture_only = 1,
  808. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  809. SND_SOC_DPCM_TRIGGER_POST},
  810. .ops = &msm_common_be_ops,
  811. .ignore_suspend = 1,
  812. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  813. },
  814. {
  815. .name = LPASS_BE_SEC_MI2S_RX,
  816. .stream_name = LPASS_BE_SEC_MI2S_RX,
  817. .playback_only = 1,
  818. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  819. SND_SOC_DPCM_TRIGGER_POST},
  820. .ops = &msm_common_be_ops,
  821. .ignore_suspend = 1,
  822. .ignore_pmdown_time = 1,
  823. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  824. },
  825. {
  826. .name = LPASS_BE_SEC_MI2S_TX,
  827. .stream_name = LPASS_BE_SEC_MI2S_TX,
  828. .capture_only = 1,
  829. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  830. SND_SOC_DPCM_TRIGGER_POST},
  831. .ops = &msm_common_be_ops,
  832. .ignore_suspend = 1,
  833. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  834. },
  835. {
  836. .name = LPASS_BE_TERT_MI2S_RX,
  837. .stream_name = LPASS_BE_TERT_MI2S_RX,
  838. .playback_only = 1,
  839. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  840. SND_SOC_DPCM_TRIGGER_POST},
  841. .ops = &msm_common_be_ops,
  842. .ignore_suspend = 1,
  843. .ignore_pmdown_time = 1,
  844. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  845. },
  846. {
  847. .name = LPASS_BE_TERT_MI2S_TX,
  848. .stream_name = LPASS_BE_TERT_MI2S_TX,
  849. .capture_only = 1,
  850. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  851. SND_SOC_DPCM_TRIGGER_POST},
  852. .ops = &msm_common_be_ops,
  853. .ignore_suspend = 1,
  854. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  855. },
  856. {
  857. .name = LPASS_BE_QUAT_MI2S_RX,
  858. .stream_name = LPASS_BE_QUAT_MI2S_RX,
  859. .playback_only = 1,
  860. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  861. SND_SOC_DPCM_TRIGGER_POST},
  862. .ops = &msm_common_be_ops,
  863. .ignore_suspend = 1,
  864. .ignore_pmdown_time = 1,
  865. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  866. },
  867. {
  868. .name = LPASS_BE_QUAT_MI2S_TX,
  869. .stream_name = LPASS_BE_QUAT_MI2S_TX,
  870. .capture_only = 1,
  871. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  872. SND_SOC_DPCM_TRIGGER_POST},
  873. .ops = &msm_common_be_ops,
  874. .ignore_suspend = 1,
  875. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  876. },
  877. {
  878. .name = LPASS_BE_QUIN_MI2S_RX,
  879. .stream_name = LPASS_BE_QUIN_MI2S_RX,
  880. .playback_only = 1,
  881. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  882. SND_SOC_DPCM_TRIGGER_POST},
  883. .ops = &msm_common_be_ops,
  884. .ignore_suspend = 1,
  885. .ignore_pmdown_time = 1,
  886. SND_SOC_DAILINK_REG(quin_mi2s_rx),
  887. },
  888. {
  889. .name = LPASS_BE_QUIN_MI2S_TX,
  890. .stream_name = LPASS_BE_QUIN_MI2S_TX,
  891. .capture_only = 1,
  892. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  893. SND_SOC_DPCM_TRIGGER_POST},
  894. .ops = &msm_common_be_ops,
  895. .ignore_suspend = 1,
  896. SND_SOC_DAILINK_REG(quin_mi2s_tx),
  897. },
  898. {
  899. .name = LPASS_BE_SEN_MI2S_RX,
  900. .stream_name = LPASS_BE_SEN_MI2S_RX,
  901. .playback_only = 1,
  902. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  903. SND_SOC_DPCM_TRIGGER_POST},
  904. .ops = &msm_common_be_ops,
  905. .ignore_suspend = 1,
  906. .ignore_pmdown_time = 1,
  907. SND_SOC_DAILINK_REG(sen_mi2s_rx),
  908. },
  909. {
  910. .name = LPASS_BE_SEN_MI2S_TX,
  911. .stream_name = LPASS_BE_SEN_MI2S_TX,
  912. .capture_only = 1,
  913. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  914. SND_SOC_DPCM_TRIGGER_POST},
  915. .ops = &msm_common_be_ops,
  916. .ignore_suspend = 1,
  917. SND_SOC_DAILINK_REG(sen_mi2s_tx),
  918. },
  919. {
  920. .name = LPASS_BE_SEP_MI2S_RX,
  921. .stream_name = LPASS_BE_SEP_MI2S_RX,
  922. .playback_only = 1,
  923. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  924. SND_SOC_DPCM_TRIGGER_POST},
  925. .ops = &msm_common_be_ops,
  926. .ignore_suspend = 1,
  927. .ignore_pmdown_time = 1,
  928. SND_SOC_DAILINK_REG(sep_mi2s_rx),
  929. },
  930. {
  931. .name = LPASS_BE_SEP_MI2S_TX,
  932. .stream_name = LPASS_BE_SEP_MI2S_TX,
  933. .capture_only = 1,
  934. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  935. SND_SOC_DPCM_TRIGGER_POST},
  936. .ops = &msm_common_be_ops,
  937. .ignore_suspend = 1,
  938. SND_SOC_DAILINK_REG(sep_mi2s_tx),
  939. },
  940. };
  941. static struct snd_soc_dai_link msm_tdm_dai_links[] = {
  942. {
  943. .name = LPASS_BE_PRI_TDM_RX_0,
  944. .stream_name = LPASS_BE_PRI_TDM_RX_0,
  945. .playback_only = 1,
  946. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  947. SND_SOC_DPCM_TRIGGER_POST},
  948. .ops = &msm_common_be_ops,
  949. .ignore_suspend = 1,
  950. .ignore_pmdown_time = 1,
  951. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  952. },
  953. {
  954. .name = LPASS_BE_PRI_TDM_TX_0,
  955. .stream_name = LPASS_BE_PRI_TDM_TX_0,
  956. .capture_only = 1,
  957. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  958. SND_SOC_DPCM_TRIGGER_POST},
  959. .ops = &msm_common_be_ops,
  960. .ignore_suspend = 1,
  961. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  962. },
  963. {
  964. .name = LPASS_BE_SEC_TDM_RX_0,
  965. .stream_name = LPASS_BE_SEC_TDM_RX_0,
  966. .playback_only = 1,
  967. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  968. SND_SOC_DPCM_TRIGGER_POST},
  969. .ops = &msm_common_be_ops,
  970. .ignore_suspend = 1,
  971. .ignore_pmdown_time = 1,
  972. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  973. },
  974. {
  975. .name = LPASS_BE_SEC_TDM_TX_0,
  976. .stream_name = LPASS_BE_SEC_TDM_TX_0,
  977. .capture_only = 1,
  978. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  979. SND_SOC_DPCM_TRIGGER_POST},
  980. .ops = &msm_common_be_ops,
  981. .ignore_suspend = 1,
  982. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  983. },
  984. {
  985. .name = LPASS_BE_TERT_TDM_RX_0,
  986. .stream_name = LPASS_BE_TERT_TDM_RX_0,
  987. .playback_only = 1,
  988. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  989. SND_SOC_DPCM_TRIGGER_POST},
  990. .ops = &msm_common_be_ops,
  991. .ignore_suspend = 1,
  992. .ignore_pmdown_time = 1,
  993. SND_SOC_DAILINK_REG(tert_tdm_rx_0),
  994. },
  995. {
  996. .name = LPASS_BE_TERT_TDM_TX_0,
  997. .stream_name = LPASS_BE_TERT_TDM_TX_0,
  998. .capture_only = 1,
  999. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1000. SND_SOC_DPCM_TRIGGER_POST},
  1001. .ops = &msm_common_be_ops,
  1002. .ignore_suspend = 1,
  1003. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  1004. },
  1005. {
  1006. .name = LPASS_BE_QUAT_TDM_RX_0,
  1007. .stream_name = LPASS_BE_QUAT_TDM_RX_0,
  1008. .playback_only = 1,
  1009. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1010. SND_SOC_DPCM_TRIGGER_POST},
  1011. .ops = &msm_common_be_ops,
  1012. .ignore_suspend = 1,
  1013. .ignore_pmdown_time = 1,
  1014. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  1015. },
  1016. {
  1017. .name = LPASS_BE_QUAT_TDM_TX_0,
  1018. .stream_name = LPASS_BE_QUAT_TDM_TX_0,
  1019. .capture_only = 1,
  1020. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1021. SND_SOC_DPCM_TRIGGER_POST},
  1022. .ops = &msm_common_be_ops,
  1023. .ignore_suspend = 1,
  1024. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  1025. },
  1026. {
  1027. .name = LPASS_BE_QUIN_TDM_RX_0,
  1028. .stream_name = LPASS_BE_QUIN_TDM_RX_0,
  1029. .playback_only = 1,
  1030. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1031. SND_SOC_DPCM_TRIGGER_POST},
  1032. .ops = &msm_common_be_ops,
  1033. .ignore_suspend = 1,
  1034. .ignore_pmdown_time = 1,
  1035. SND_SOC_DAILINK_REG(quin_tdm_rx_0),
  1036. },
  1037. {
  1038. .name = LPASS_BE_QUIN_TDM_TX_0,
  1039. .stream_name = LPASS_BE_QUIN_TDM_TX_0,
  1040. .capture_only = 1,
  1041. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1042. SND_SOC_DPCM_TRIGGER_POST},
  1043. .ops = &msm_common_be_ops,
  1044. .ignore_suspend = 1,
  1045. SND_SOC_DAILINK_REG(quin_tdm_tx_0),
  1046. },
  1047. {
  1048. .name = LPASS_BE_SEN_TDM_RX_0,
  1049. .stream_name = LPASS_BE_SEN_TDM_RX_0,
  1050. .playback_only = 1,
  1051. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1052. SND_SOC_DPCM_TRIGGER_POST},
  1053. .ops = &msm_common_be_ops,
  1054. .ignore_suspend = 1,
  1055. .ignore_pmdown_time = 1,
  1056. SND_SOC_DAILINK_REG(sen_tdm_rx_0),
  1057. },
  1058. {
  1059. .name = LPASS_BE_SEN_TDM_TX_0,
  1060. .stream_name = LPASS_BE_SEN_TDM_TX_0,
  1061. .capture_only = 1,
  1062. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1063. SND_SOC_DPCM_TRIGGER_POST},
  1064. .ops = &msm_common_be_ops,
  1065. .ignore_suspend = 1,
  1066. SND_SOC_DAILINK_REG(sen_tdm_tx_0),
  1067. },
  1068. {
  1069. .name = LPASS_BE_SEP_TDM_RX_0,
  1070. .stream_name = LPASS_BE_SEP_TDM_RX_0,
  1071. .playback_only = 1,
  1072. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1073. SND_SOC_DPCM_TRIGGER_POST},
  1074. .ops = &msm_common_be_ops,
  1075. .ignore_suspend = 1,
  1076. .ignore_pmdown_time = 1,
  1077. SND_SOC_DAILINK_REG(sep_tdm_rx_0),
  1078. },
  1079. {
  1080. .name = LPASS_BE_SEP_TDM_TX_0,
  1081. .stream_name = LPASS_BE_SEP_TDM_TX_0,
  1082. .capture_only = 1,
  1083. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1084. SND_SOC_DPCM_TRIGGER_POST},
  1085. .ops = &msm_common_be_ops,
  1086. .ignore_suspend = 1,
  1087. SND_SOC_DAILINK_REG(sep_tdm_tx_0),
  1088. },
  1089. };
  1090. static struct snd_soc_dai_link msm_pineapple_dai_links[
  1091. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  1092. ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links) +
  1093. ARRAY_SIZE(msm_wsa_wsa2_cdc_dma_be_dai_links) +
  1094. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  1095. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  1096. ARRAY_SIZE(ext_disp_be_dai_link) +
  1097. ARRAY_SIZE(msm_common_be_dai_links) +
  1098. ARRAY_SIZE(msm_wcn_be_dai_links) +
  1099. ARRAY_SIZE(msm_mi2s_dai_links) +
  1100. ARRAY_SIZE(msm_tdm_dai_links)];
  1101. static int msm_populate_dai_link_component_of_node(
  1102. struct snd_soc_card *card)
  1103. {
  1104. int i, j, index, ret = 0;
  1105. struct device *cdev = card->dev;
  1106. struct snd_soc_dai_link *dai_link = card->dai_link;
  1107. struct device_node *np = NULL;
  1108. int codecs_enabled = 0;
  1109. struct snd_soc_dai_link_component *codecs_comp = NULL;
  1110. if (!cdev) {
  1111. dev_err_ratelimited(cdev, "%s: Sound card device memory NULL\n", __func__);
  1112. return -ENODEV;
  1113. }
  1114. for (i = 0; i < card->num_links; i++) {
  1115. if (dai_link[i].init == NULL)
  1116. dai_link[i].init = &msm_common_dai_link_init;
  1117. /* populate codec_of_node for snd card dai links */
  1118. if (dai_link[i].num_codecs > 0) {
  1119. for (j = 0; j < dai_link[i].num_codecs; j++) {
  1120. if (dai_link[i].codecs[j].of_node ||
  1121. !dai_link[i].codecs[j].name)
  1122. continue;
  1123. index = of_property_match_string(cdev->of_node,
  1124. "asoc-codec-names",
  1125. dai_link[i].codecs[j].name);
  1126. if (index < 0)
  1127. continue;
  1128. np = of_parse_phandle(cdev->of_node,
  1129. "asoc-codec",
  1130. index);
  1131. if (!np) {
  1132. dev_err_ratelimited(cdev,
  1133. "%s: retrieving phandle for codec %s failed\n",
  1134. __func__,
  1135. dai_link[i].codecs[j].name);
  1136. ret = -ENODEV;
  1137. goto err;
  1138. }
  1139. dai_link[i].codecs[j].of_node = np;
  1140. dai_link[i].codecs[j].name = NULL;
  1141. }
  1142. }
  1143. }
  1144. /* In multi-codec scenario, check if codecs are enabled for this platform */
  1145. for (i = 0; i < card->num_links; i++) {
  1146. codecs_enabled = 0;
  1147. if (dai_link[i].num_codecs > 1) {
  1148. for (j = 0; j < dai_link[i].num_codecs; j++) {
  1149. if (!dai_link[i].codecs[j].of_node)
  1150. continue;
  1151. np = dai_link[i].codecs[j].of_node;
  1152. if (!of_device_is_available(np)) {
  1153. dev_err_ratelimited(cdev, "%s: codec is disabled: %s\n",
  1154. __func__,
  1155. np->full_name);
  1156. dai_link[i].codecs[j].of_node = NULL;
  1157. continue;
  1158. }
  1159. codecs_enabled++;
  1160. }
  1161. if (codecs_enabled > 0 &&
  1162. codecs_enabled < dai_link[i].num_codecs) {
  1163. codecs_comp = devm_kzalloc(cdev,
  1164. sizeof(struct snd_soc_dai_link_component)
  1165. * codecs_enabled, GFP_KERNEL);
  1166. if (!codecs_comp) {
  1167. dev_err_ratelimited(cdev,
  1168. "%s: %s dailink codec component alloc failed\n",
  1169. __func__, dai_link[i].name);
  1170. ret = -ENOMEM;
  1171. goto err;
  1172. }
  1173. index = 0;
  1174. for (j = 0; j < dai_link[i].num_codecs; j++) {
  1175. if(dai_link[i].codecs[j].of_node) {
  1176. codecs_comp[index].of_node =
  1177. dai_link[i].codecs[j].of_node;
  1178. codecs_comp[index].dai_name =
  1179. dai_link[i].codecs[j].dai_name;
  1180. codecs_comp[index].name = NULL;
  1181. index++;
  1182. }
  1183. }
  1184. dai_link[i].codecs = codecs_comp;
  1185. dai_link[i].num_codecs = codecs_enabled;
  1186. }
  1187. }
  1188. }
  1189. err:
  1190. return ret;
  1191. }
  1192. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  1193. {
  1194. return 0;
  1195. }
  1196. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  1197. struct snd_pcm_hw_params *params)
  1198. {
  1199. return 0;
  1200. }
  1201. static struct snd_soc_ops msm_stub_be_ops = {
  1202. .hw_params = msm_snd_stub_hw_params,
  1203. };
  1204. struct snd_soc_card snd_soc_card_stub_msm = {
  1205. .name = "pineapple-stub-snd-card",
  1206. };
  1207. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  1208. /* Backend DAI Links */
  1209. {
  1210. .name = LPASS_BE_PRI_AUXPCM_RX,
  1211. .stream_name = LPASS_BE_PRI_AUXPCM_RX,
  1212. .playback_only = 1,
  1213. .init = &msm_audrx_stub_init,
  1214. .ignore_pmdown_time = 1,
  1215. .ignore_suspend = 1,
  1216. .ops = &msm_stub_be_ops,
  1217. SND_SOC_DAILINK_REG(auxpcm_rx),
  1218. },
  1219. {
  1220. .name = LPASS_BE_PRI_AUXPCM_TX,
  1221. .stream_name = LPASS_BE_PRI_AUXPCM_TX,
  1222. .capture_only = 1,
  1223. .ignore_suspend = 1,
  1224. .ops = &msm_stub_be_ops,
  1225. SND_SOC_DAILINK_REG(auxpcm_tx),
  1226. },
  1227. };
  1228. static struct snd_soc_dai_link msm_stub_dai_links[
  1229. ARRAY_SIZE(msm_stub_be_dai_links)];
  1230. static const struct of_device_id pineapple_asoc_machine_of_match[] = {
  1231. { .compatible = "qcom,pineapple-asoc-snd",
  1232. .data = "codec"},
  1233. { .compatible = "qcom,pineapple-asoc-snd-stub",
  1234. .data = "stub_codec"},
  1235. {},
  1236. };
  1237. static int msm_snd_card_late_probe(struct snd_soc_card *card)
  1238. {
  1239. struct snd_soc_component *component = NULL;
  1240. struct snd_soc_pcm_runtime *rtd;
  1241. struct msm_asoc_mach_data *pdata;
  1242. int ret = 0;
  1243. void *mbhc_calibration;
  1244. pdata = snd_soc_card_get_drvdata(card);
  1245. if (!pdata)
  1246. return -EINVAL;
  1247. if (pdata->wcd_disabled)
  1248. return 0;
  1249. rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
  1250. if (!rtd) {
  1251. dev_err(card->dev,
  1252. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1253. __func__, card->dai_link[0]);
  1254. return -EINVAL;
  1255. }
  1256. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  1257. if (!component) {
  1258. pr_err("%s component is NULL\n", __func__);
  1259. return -EINVAL;
  1260. }
  1261. mbhc_calibration = def_wcd_mbhc_cal();
  1262. if (!mbhc_calibration)
  1263. return -ENOMEM;
  1264. wcd_mbhc_cfg.calibration = mbhc_calibration;
  1265. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  1266. if (ret) {
  1267. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  1268. __func__, ret);
  1269. goto err_hs_detect;
  1270. }
  1271. return 0;
  1272. err_hs_detect:
  1273. kfree(mbhc_calibration);
  1274. return ret;
  1275. }
  1276. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev, int wsa_max_devs)
  1277. {
  1278. struct snd_soc_card *card = NULL;
  1279. struct snd_soc_dai_link *dailink = NULL;
  1280. int total_links = 0;
  1281. int rc = 0;
  1282. u32 val = 0;
  1283. const struct of_device_id *match;
  1284. match = of_match_node(pineapple_asoc_machine_of_match, dev->of_node);
  1285. if (!match) {
  1286. dev_err_ratelimited(dev, "%s: No DT match found for sound card\n",
  1287. __func__);
  1288. return NULL;
  1289. }
  1290. if (!strcmp(match->data, "codec")) {
  1291. card = &snd_soc_card_pineapple_msm;
  1292. /* late probe uses dai link at index '0' to get wcd component */
  1293. memcpy(msm_pineapple_dai_links + total_links,
  1294. msm_rx_tx_cdc_dma_be_dai_links,
  1295. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  1296. total_links +=
  1297. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  1298. switch (wsa_max_devs) {
  1299. case MONO_SPEAKER:
  1300. case STEREO_SPEAKER:
  1301. memcpy(msm_pineapple_dai_links + total_links,
  1302. msm_wsa_cdc_dma_be_dai_links,
  1303. sizeof(msm_wsa_cdc_dma_be_dai_links));
  1304. total_links += ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  1305. break;
  1306. case QUAD_SPEAKER:
  1307. memcpy(msm_pineapple_dai_links + total_links,
  1308. msm_wsa2_cdc_dma_be_dai_links,
  1309. sizeof(msm_wsa2_cdc_dma_be_dai_links));
  1310. total_links += ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links);
  1311. memcpy(msm_pineapple_dai_links + total_links,
  1312. msm_wsa_wsa2_cdc_dma_be_dai_links,
  1313. sizeof(msm_wsa_wsa2_cdc_dma_be_dai_links));
  1314. total_links += ARRAY_SIZE(msm_wsa_wsa2_cdc_dma_be_dai_links);
  1315. break;
  1316. default:
  1317. dev_dbg(dev,
  1318. "%s: Unexpected number of WSAs, wsa_max_devs: %d\n",
  1319. __func__, wsa_max_devs);
  1320. break;
  1321. }
  1322. memcpy(msm_pineapple_dai_links + total_links,
  1323. msm_va_cdc_dma_be_dai_links,
  1324. sizeof(msm_va_cdc_dma_be_dai_links));
  1325. total_links += ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  1326. memcpy(msm_pineapple_dai_links + total_links,
  1327. msm_common_be_dai_links,
  1328. sizeof(msm_common_be_dai_links));
  1329. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  1330. rc = of_property_read_u32(dev->of_node,
  1331. "qcom,mi2s-audio-intf", &val);
  1332. if (!rc && val) {
  1333. memcpy(msm_pineapple_dai_links + total_links,
  1334. msm_mi2s_dai_links,
  1335. sizeof(msm_mi2s_dai_links));
  1336. total_links += ARRAY_SIZE(msm_mi2s_dai_links);
  1337. }
  1338. rc = of_property_read_u32(dev->of_node,
  1339. "qcom,tdm-audio-intf", &val);
  1340. if (!rc && val) {
  1341. memcpy(msm_pineapple_dai_links + total_links,
  1342. msm_tdm_dai_links,
  1343. sizeof(msm_tdm_dai_links));
  1344. total_links += ARRAY_SIZE(msm_tdm_dai_links);
  1345. }
  1346. rc = of_property_read_u32(dev->of_node,
  1347. "qcom,ext-disp-audio-rx", &val);
  1348. if (!rc && val) {
  1349. dev_dbg(dev, "%s(): ext disp audio support present\n",
  1350. __func__);
  1351. memcpy(msm_pineapple_dai_links + total_links,
  1352. ext_disp_be_dai_link,
  1353. sizeof(ext_disp_be_dai_link));
  1354. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  1355. }
  1356. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  1357. if (!rc && val) {
  1358. dev_dbg(dev, "%s(): WCN BT support present\n",
  1359. __func__);
  1360. memcpy(msm_pineapple_dai_links + total_links,
  1361. msm_wcn_be_dai_links,
  1362. sizeof(msm_wcn_be_dai_links));
  1363. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  1364. }
  1365. dailink = msm_pineapple_dai_links;
  1366. } else if(!strcmp(match->data, "stub_codec")) {
  1367. card = &snd_soc_card_stub_msm;
  1368. memcpy(msm_stub_dai_links,
  1369. msm_stub_be_dai_links,
  1370. sizeof(msm_stub_be_dai_links));
  1371. dailink = msm_stub_dai_links;
  1372. total_links = ARRAY_SIZE(msm_stub_be_dai_links);
  1373. }
  1374. if (card) {
  1375. card->dai_link = dailink;
  1376. card->num_links = total_links;
  1377. if (!strcmp(match->data, "codec"))
  1378. card->late_probe = msm_snd_card_late_probe;
  1379. }
  1380. return card;
  1381. }
  1382. static int msm_int_wsa883x_init(struct snd_soc_pcm_runtime *rtd)
  1383. {
  1384. u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  1385. u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  1386. u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  1387. SPKR_L_BOOST, SPKR_L_VI};
  1388. u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  1389. SPKR_R_BOOST, SPKR_R_VI};
  1390. unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  1391. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
  1392. unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  1393. struct snd_soc_component *component = NULL;
  1394. struct msm_asoc_mach_data *pdata =
  1395. snd_soc_card_get_drvdata(rtd->card);
  1396. if (pdata->wsa_max_devs > 0) {
  1397. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  1398. if (!component) {
  1399. pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
  1400. return -EINVAL;
  1401. }
  1402. wsa883x_set_channel_map(component, &spkleft_ports[0],
  1403. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1404. &ch_rate[0], &spkleft_port_types[0]);
  1405. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1406. component);
  1407. }
  1408. /* If current platform has more than one WSA */
  1409. if (pdata->wsa_max_devs > 1) {
  1410. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  1411. if (!component) {
  1412. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  1413. return -EINVAL;
  1414. }
  1415. wsa883x_set_channel_map(component, &spkright_ports[0],
  1416. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1417. &ch_rate[0], &spkright_port_types[0]);
  1418. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1419. component);
  1420. }
  1421. if (pdata->wsa_max_devs > 2) {
  1422. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
  1423. if (!component) {
  1424. pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
  1425. return -EINVAL;
  1426. }
  1427. wsa883x_set_channel_map(component, &spkleft_ports[0],
  1428. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1429. &ch_rate[0], &spkleft_port_types[0]);
  1430. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1431. component);
  1432. }
  1433. if (pdata->wsa_max_devs > 3) {
  1434. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
  1435. if (!component) {
  1436. pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
  1437. return -EINVAL;
  1438. }
  1439. wsa883x_set_channel_map(component, &spkright_ports[0],
  1440. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1441. &ch_rate[0], &spkright_port_types[0]);
  1442. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1443. component);
  1444. }
  1445. msm_common_dai_link_init(rtd);
  1446. return 0;
  1447. }
  1448. static int msm_int_wsa884x_init(struct snd_soc_pcm_runtime *rtd)
  1449. {
  1450. u8 spkleft_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
  1451. u8 spkright_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
  1452. u8 spkleft_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  1453. SPKR_L_BOOST, PBR, SPKR_L_VI, CPS};
  1454. u8 spkright_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  1455. SPKR_R_BOOST, PBR, SPKR_R_VI, CPS};
  1456. unsigned int ch_rate[WSA884X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  1457. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_48KHZ,
  1458. SWR_CLK_RATE_1P2MHZ, SWR_CLK_RATE_24KHZ};
  1459. unsigned int ch_mask[WSA884X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x1, 0x3, 0x3};
  1460. struct snd_soc_component *component = NULL;
  1461. struct msm_asoc_mach_data *pdata =
  1462. snd_soc_card_get_drvdata(rtd->card);
  1463. if (pdata->wsa_max_devs > 0) {
  1464. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  1465. if (!component) {
  1466. pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
  1467. return -EINVAL;
  1468. }
  1469. wsa884x_set_channel_map(component, &spkleft_ports[0],
  1470. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1471. &ch_rate[0], &spkleft_port_types[0]);
  1472. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1473. component);
  1474. }
  1475. /* If current platform has more than one WSA */
  1476. if (pdata->wsa_max_devs > 1) {
  1477. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  1478. if (!component) {
  1479. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  1480. return -EINVAL;
  1481. }
  1482. wsa884x_set_channel_map(component, &spkright_ports[0],
  1483. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1484. &ch_rate[0], &spkright_port_types[0]);
  1485. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1486. component);
  1487. }
  1488. if (pdata->wsa_max_devs > 2) {
  1489. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
  1490. if (!component) {
  1491. pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
  1492. return -EINVAL;
  1493. }
  1494. wsa884x_set_channel_map(component, &spkleft_ports[0],
  1495. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1496. &ch_rate[0], &spkleft_port_types[0]);
  1497. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1498. component);
  1499. }
  1500. if (pdata->wsa_max_devs > 3) {
  1501. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
  1502. if (!component) {
  1503. pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
  1504. return -EINVAL;
  1505. }
  1506. wsa884x_set_channel_map(component, &spkright_ports[0],
  1507. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1508. &ch_rate[0], &spkright_port_types[0]);
  1509. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1510. component);
  1511. }
  1512. msm_common_dai_link_init(rtd);
  1513. return 0;
  1514. }
  1515. static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd)
  1516. {
  1517. if (strstr(rtd->card->name, "wsa883x"))
  1518. return msm_int_wsa883x_init(rtd);
  1519. return msm_int_wsa884x_init(rtd);
  1520. }
  1521. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
  1522. {
  1523. int codec_variant = -1;
  1524. struct snd_soc_component *component = NULL;
  1525. struct snd_soc_component *lpass_cdc_component = NULL;
  1526. struct snd_soc_dapm_context *dapm = NULL;
  1527. struct snd_info_entry *entry = NULL;
  1528. struct snd_card *card = NULL;
  1529. struct msm_asoc_mach_data *pdata =
  1530. snd_soc_card_get_drvdata(rtd->card);
  1531. int ret = 0;
  1532. lpass_cdc_component = snd_soc_rtdcom_lookup(rtd, "lpass-cdc");
  1533. if (!lpass_cdc_component) {
  1534. pr_err("%s: could not find component for lpass-cdc\n",
  1535. __func__);
  1536. return ret;
  1537. }
  1538. dapm = snd_soc_component_get_dapm(lpass_cdc_component);
  1539. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  1540. ARRAY_SIZE(msm_int_dapm_widgets));
  1541. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  1542. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  1543. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  1544. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  1545. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  1546. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  1547. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  1548. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  1549. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  1550. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  1551. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  1552. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  1553. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  1554. lpass_cdc_set_port_map(lpass_cdc_component, ARRAY_SIZE(sm_port_map), sm_port_map);
  1555. card = rtd->card->snd_card;
  1556. if (!pdata->codec_root) {
  1557. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1558. card->proc_root);
  1559. if (!entry) {
  1560. pr_debug("%s: Cannot create codecs module entry\n",
  1561. __func__);
  1562. return ret;
  1563. }
  1564. pdata->codec_root = entry;
  1565. }
  1566. lpass_cdc_info_create_codec_entry(pdata->codec_root, lpass_cdc_component);
  1567. lpass_cdc_register_wake_irq(lpass_cdc_component, false);
  1568. if (pdata->wcd_disabled)
  1569. goto done;
  1570. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  1571. if (!component) {
  1572. pr_err("%s could not find component for %s\n",
  1573. __func__, WCD938X_DRV_NAME);
  1574. return -EINVAL;
  1575. }
  1576. dapm = snd_soc_component_get_dapm(component);
  1577. card = component->card->snd_card;
  1578. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  1579. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  1580. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  1581. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  1582. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  1583. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  1584. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  1585. snd_soc_dapm_sync(dapm);
  1586. pdata = snd_soc_card_get_drvdata(component->card);
  1587. if (!pdata->codec_root) {
  1588. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1589. card->proc_root);
  1590. if (!entry) {
  1591. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  1592. __func__);
  1593. return 0;
  1594. }
  1595. pdata->codec_root = entry;
  1596. }
  1597. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  1598. codec_variant = wcd938x_get_codec_variant(component);
  1599. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  1600. if (codec_variant == WCD9385)
  1601. ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, true);
  1602. else
  1603. ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, false);
  1604. if (ret < 0) {
  1605. dev_err_ratelimited(component->dev, "%s: set fir capability failed: %d\n",
  1606. __func__, ret);
  1607. return ret;
  1608. }
  1609. done:
  1610. codec_reg_done = true;
  1611. msm_common_dai_link_init(rtd);
  1612. return ret;
  1613. }
  1614. static int pineapple_ssr_enable(struct device *dev, void *data)
  1615. {
  1616. struct platform_device *pdev = to_platform_device(dev);
  1617. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1618. struct snd_soc_pcm_runtime *rtd = NULL, *rtd_wcd = NULL, *rtd_wsa = NULL;
  1619. struct msm_asoc_mach_data *pdata = NULL;
  1620. int ret = 0;
  1621. if (!card) {
  1622. dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
  1623. ret = -EINVAL;
  1624. goto err;
  1625. }
  1626. if (!strcmp(card->name, "pineapple-stub-snd-card")) {
  1627. /* TODO */
  1628. dev_dbg(dev, "%s: TODO \n", __func__);
  1629. }
  1630. snd_card_notify_user(SND_CARD_STATUS_ONLINE);
  1631. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  1632. pdata = snd_soc_card_get_drvdata(card);
  1633. if (!pdata) {
  1634. dev_dbg(dev, "%s: pdata is NULL \n", __func__);
  1635. goto err;
  1636. }
  1637. rtd_wcd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
  1638. if (!rtd_wcd) {
  1639. dev_dbg(dev,
  1640. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1641. __func__, card->dai_link[0]);
  1642. }
  1643. if (pdata->wsa_max_devs > 0) {
  1644. rtd_wsa = snd_soc_get_pcm_runtime(card,
  1645. &card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
  1646. if (!rtd_wsa) {
  1647. dev_dbg(dev,
  1648. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1649. __func__, card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
  1650. }
  1651. }
  1652. /* set UPD configuration */
  1653. if(!pdata->upd_config.backend_used) {
  1654. dev_dbg(dev,
  1655. "%s: upd- backend_used is NULL\n", __func__);
  1656. goto err;
  1657. }
  1658. if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
  1659. if (!rtd_wsa)
  1660. goto err;
  1661. else
  1662. rtd = rtd_wsa;
  1663. } else if(!strcmp(pdata->upd_config.backend_used, "wcd")) {
  1664. if (!rtd_wcd &&!pdata->wcd_disabled)
  1665. goto err;
  1666. else
  1667. rtd = rtd_wcd;
  1668. } else {
  1669. dev_err_ratelimited(card->dev, "%s: Invalid backend to set UPD config\n",
  1670. __func__);
  1671. goto err;
  1672. }
  1673. msm_set_upd_config(rtd);
  1674. err:
  1675. return ret;
  1676. }
  1677. static void pineapple_ssr_disable(struct device *dev, void *data)
  1678. {
  1679. struct platform_device *pdev = to_platform_device(dev);
  1680. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1681. if (!card) {
  1682. dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
  1683. return;
  1684. }
  1685. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  1686. snd_card_notify_user(SND_CARD_STATUS_OFFLINE);
  1687. if (!strcmp(card->name, "pineapple-stub-snd-card")) {
  1688. /* TODO */
  1689. dev_dbg(dev, "%s: TODO \n", __func__);
  1690. }
  1691. }
  1692. static const struct snd_event_ops pineapple_ssr_ops = {
  1693. .enable = pineapple_ssr_enable,
  1694. .disable = pineapple_ssr_disable,
  1695. };
  1696. static int msm_audio_ssr_compare(struct device *dev, void *data)
  1697. {
  1698. struct device_node *node = data;
  1699. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  1700. __func__, dev->of_node, node);
  1701. return (dev->of_node && dev->of_node == node);
  1702. }
  1703. static int msm_audio_ssr_register(struct device *dev)
  1704. {
  1705. struct device_node *np = dev->of_node;
  1706. struct snd_event_clients *ssr_clients = NULL;
  1707. struct device_node *node = NULL;
  1708. int ret = 0;
  1709. int i = 0;
  1710. for (i = 0; ; i++) {
  1711. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  1712. if (!node)
  1713. break;
  1714. snd_event_mstr_add_client(&ssr_clients,
  1715. msm_audio_ssr_compare, node);
  1716. }
  1717. ret = snd_event_master_register(dev, &pineapple_ssr_ops,
  1718. ssr_clients, NULL);
  1719. if (!ret)
  1720. snd_event_notify(dev, SND_EVENT_UP);
  1721. return ret;
  1722. }
  1723. struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card)
  1724. {
  1725. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1726. if (!pdata)
  1727. return NULL;
  1728. return pdata->common_pdata;
  1729. }
  1730. void msm_common_set_pdata(struct snd_soc_card *card,
  1731. struct msm_common_pdata *common_pdata)
  1732. {
  1733. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1734. if (!pdata)
  1735. return;
  1736. pdata->common_pdata = common_pdata;
  1737. }
  1738. static int msm_asoc_machine_probe(struct platform_device *pdev)
  1739. {
  1740. struct snd_soc_card *card = NULL;
  1741. struct msm_asoc_mach_data *pdata = NULL;
  1742. int ret = 0;
  1743. struct clk *lpass_audio_hw_vote = NULL;
  1744. const struct of_device_id *match;
  1745. if (!pdev->dev.of_node) {
  1746. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  1747. return -EINVAL;
  1748. }
  1749. pdata = devm_kzalloc(&pdev->dev,
  1750. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  1751. if (!pdata)
  1752. return -ENOMEM;
  1753. of_property_read_u32(pdev->dev.of_node,
  1754. "qcom,wcd-disabled",
  1755. &pdata->wcd_disabled);
  1756. /* Get maximum WSA device count for this platform */
  1757. ret = of_property_read_u32(pdev->dev.of_node,
  1758. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  1759. if (ret) {
  1760. dev_info(&pdev->dev,
  1761. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  1762. __func__, pdev->dev.of_node->full_name, ret);
  1763. pdata->wsa_max_devs = 0;
  1764. }
  1765. card = populate_snd_card_dailinks(&pdev->dev, pdata->wsa_max_devs);
  1766. if (!card) {
  1767. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  1768. ret = -EINVAL;
  1769. goto err;
  1770. }
  1771. match = of_match_node(pineapple_asoc_machine_of_match, pdev->dev.of_node);
  1772. if (!match) {
  1773. dev_err(&pdev->dev, "%s: No DT match found for sound card\n",
  1774. __func__);
  1775. ret = -EINVAL;
  1776. goto err;
  1777. }
  1778. card->dev = &pdev->dev;
  1779. platform_set_drvdata(pdev, card);
  1780. snd_soc_card_set_drvdata(card, pdata);
  1781. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  1782. if (ret) {
  1783. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  1784. __func__, ret);
  1785. goto err;
  1786. }
  1787. if(!strcmp(match->data, "codec")) {
  1788. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  1789. if (ret) {
  1790. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  1791. __func__, ret);
  1792. goto err;
  1793. }
  1794. }
  1795. ret = msm_populate_dai_link_component_of_node(card);
  1796. if (ret) {
  1797. ret = -EPROBE_DEFER;
  1798. goto err;
  1799. }
  1800. /* parse upd configuration */
  1801. msm_parse_upd_configuration(pdev, pdata);
  1802. ret = devm_snd_soc_register_card(&pdev->dev, card);
  1803. if (ret == -EPROBE_DEFER) {
  1804. if (codec_reg_done)
  1805. ret = -EINVAL;
  1806. goto err;
  1807. } else if (ret) {
  1808. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  1809. __func__, ret);
  1810. goto err;
  1811. }
  1812. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  1813. __func__, card->name);
  1814. if (wcd_mbhc_cfg.enable_usbc_analog)
  1815. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  1816. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  1817. "fsa4480-i2c-handle", 0);
  1818. if (!pdata->fsa_handle)
  1819. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  1820. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  1821. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1822. "qcom,cdc-dmic01-gpios",
  1823. 0);
  1824. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1825. "qcom,cdc-dmic23-gpios",
  1826. 0);
  1827. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1828. "qcom,cdc-dmic45-gpios",
  1829. 0);
  1830. pdata->dmic67_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1831. "qcom,cdc-dmic67-gpios",
  1832. 0);
  1833. if (pdata->dmic01_gpio_p)
  1834. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  1835. if (pdata->dmic23_gpio_p)
  1836. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  1837. if (pdata->dmic45_gpio_p)
  1838. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  1839. if (pdata->dmic67_gpio_p)
  1840. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic67_gpio_p, false);
  1841. msm_common_snd_init(pdev, card);
  1842. /* Register LPASS audio hw vote */
  1843. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  1844. if (IS_ERR(lpass_audio_hw_vote)) {
  1845. ret = PTR_ERR(lpass_audio_hw_vote);
  1846. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  1847. __func__, "lpass_audio_hw_vote", ret);
  1848. lpass_audio_hw_vote = NULL;
  1849. ret = 0;
  1850. }
  1851. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  1852. pdata->core_audio_vote_count = 0;
  1853. ret = msm_audio_ssr_register(&pdev->dev);
  1854. if (ret)
  1855. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  1856. __func__, ret);
  1857. is_initial_boot = true;
  1858. /* change card status to ONLINE */
  1859. dev_dbg(&pdev->dev, "%s: setting snd_card to ONLINE\n", __func__);
  1860. snd_card_set_card_status(SND_CARD_STATUS_ONLINE);
  1861. return 0;
  1862. err:
  1863. devm_kfree(&pdev->dev, pdata);
  1864. return ret;
  1865. }
  1866. static int msm_asoc_machine_remove(struct platform_device *pdev)
  1867. {
  1868. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1869. struct msm_asoc_mach_data *pdata = NULL;
  1870. struct msm_common_pdata *common_pdata = NULL;
  1871. if (card)
  1872. pdata = snd_soc_card_get_drvdata(card);
  1873. if (pdata)
  1874. common_pdata = pdata->common_pdata;
  1875. msm_common_snd_deinit(common_pdata);
  1876. snd_event_master_deregister(&pdev->dev);
  1877. snd_soc_unregister_card(card);
  1878. return 0;
  1879. }
  1880. static struct platform_driver pineapple_asoc_machine_driver = {
  1881. .driver = {
  1882. .name = DRV_NAME,
  1883. .owner = THIS_MODULE,
  1884. .pm = &snd_soc_pm_ops,
  1885. .of_match_table = pineapple_asoc_machine_of_match,
  1886. .suppress_bind_attrs = true,
  1887. },
  1888. .probe = msm_asoc_machine_probe,
  1889. .remove = msm_asoc_machine_remove,
  1890. };
  1891. static int __init msm_asoc_machine_init(void)
  1892. {
  1893. snd_card_sysfs_init();
  1894. return platform_driver_register(&pineapple_asoc_machine_driver);
  1895. }
  1896. module_init(msm_asoc_machine_init);
  1897. static void __exit msm_asoc_machine_exit(void)
  1898. {
  1899. platform_driver_unregister(&pineapple_asoc_machine_driver);
  1900. }
  1901. module_exit(msm_asoc_machine_exit);
  1902. MODULE_SOFTDEP("pre: bt_fm_slim");
  1903. MODULE_DESCRIPTION("ALSA SoC msm");
  1904. MODULE_LICENSE("GPL v2");
  1905. MODULE_ALIAS("platform:" DRV_NAME);
  1906. MODULE_DEVICE_TABLE(of, pineapple_asoc_machine_of_match);