pineapple.c 71 KB

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