waipio.c 51 KB

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