waipio.c 47 KB

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