pineapple.c 57 KB

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