kalama.c 57 KB

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