pineapple.c 57 KB

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