pineapple.c 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574
  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. return -EINVAL;
  1635. }
  1636. wsa883x_set_channel_map(component, &spkleft_ports[0],
  1637. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1638. &ch_rate[0], &spkleft_port_types[0]);
  1639. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1640. component);
  1641. }
  1642. /* If current platform has more than one WSA */
  1643. if (pdata->wsa_max_devs > 1) {
  1644. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  1645. if (!component) {
  1646. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  1647. return -EINVAL;
  1648. }
  1649. wsa883x_set_channel_map(component, &spkright_ports[0],
  1650. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1651. &ch_rate[0], &spkright_port_types[0]);
  1652. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1653. component);
  1654. }
  1655. if (!pdata->dedicated_wsa2) {
  1656. if (pdata->wsa_max_devs > 2) {
  1657. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
  1658. if (!component) {
  1659. pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
  1660. return -EINVAL;
  1661. }
  1662. wsa883x_set_channel_map(component, &spkleft_ports[0],
  1663. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1664. &ch_rate[0], &spkleft_port_types[0]);
  1665. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1666. component);
  1667. }
  1668. if (pdata->wsa_max_devs > 3) {
  1669. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
  1670. if (!component) {
  1671. pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
  1672. return -EINVAL;
  1673. }
  1674. wsa883x_set_channel_map(component, &spkright_ports[0],
  1675. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1676. &ch_rate[0], &spkright_port_types[0]);
  1677. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1678. component);
  1679. }
  1680. }
  1681. msm_common_dai_link_init(rtd);
  1682. return 0;
  1683. }
  1684. static int msm_int_wsa884x_init(struct snd_soc_pcm_runtime *rtd)
  1685. {
  1686. u8 spkleft_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
  1687. u8 spkright_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
  1688. u8 spkleft_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  1689. SPKR_L_BOOST, PBR, SPKR_L_VI, CPS};
  1690. u8 spkright_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  1691. SPKR_R_BOOST, PBR, SPKR_R_VI, CPS};
  1692. unsigned int ch_rate[WSA884X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  1693. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_48KHZ,
  1694. SWR_CLK_RATE_1P2MHZ, SWR_CLK_RATE_24KHZ};
  1695. unsigned int ch_mask[WSA884X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x1, 0x3, 0x3};
  1696. struct snd_soc_component *component = NULL;
  1697. struct msm_asoc_mach_data *pdata =
  1698. snd_soc_card_get_drvdata(rtd->card);
  1699. if (pdata->wsa_max_devs > 0) {
  1700. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  1701. if (!component) {
  1702. pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
  1703. return -EINVAL;
  1704. }
  1705. wsa884x_set_channel_map(component, &spkleft_ports[0],
  1706. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1707. &ch_rate[0], &spkleft_port_types[0]);
  1708. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1709. component);
  1710. }
  1711. /* If current platform has more than one WSA */
  1712. if (pdata->wsa_max_devs > 1) {
  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. }
  1724. if (!pdata->dedicated_wsa2) {
  1725. if (pdata->wsa_max_devs > 2) {
  1726. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
  1727. if (!component) {
  1728. pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
  1729. return -EINVAL;
  1730. }
  1731. wsa884x_set_channel_map(component, &spkleft_ports[0],
  1732. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1733. &ch_rate[0], &spkleft_port_types[0]);
  1734. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1735. component);
  1736. }
  1737. if (pdata->wsa_max_devs > 3) {
  1738. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
  1739. if (!component) {
  1740. pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
  1741. return -EINVAL;
  1742. }
  1743. wsa884x_set_channel_map(component, &spkright_ports[0],
  1744. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1745. &ch_rate[0], &spkright_port_types[0]);
  1746. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1747. component);
  1748. }
  1749. }
  1750. msm_common_dai_link_init(rtd);
  1751. return 0;
  1752. }
  1753. static int msm_int_wsa881x_init(struct snd_soc_pcm_runtime *rtd)
  1754. {
  1755. struct msm_asoc_mach_data *pdata =
  1756. snd_soc_card_get_drvdata(rtd->card);
  1757. if (pdata->wsa_max_devs == 0)
  1758. pr_info("%s: WSA is not enabled\n", __func__);
  1759. msm_common_dai_link_init(rtd);
  1760. return 0;
  1761. }
  1762. static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd)
  1763. {
  1764. if (strstr(rtd->card->name, "wsa883x"))
  1765. return msm_int_wsa883x_init(rtd);
  1766. return msm_int_wsa884x_init(rtd);
  1767. }
  1768. static int msm_int_wsa883x_2_init(struct snd_soc_pcm_runtime *rtd)
  1769. {
  1770. u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  1771. u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  1772. u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  1773. SPKR_L_BOOST, SPKR_L_VI};
  1774. u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  1775. SPKR_R_BOOST, SPKR_R_VI};
  1776. unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  1777. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
  1778. unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  1779. struct snd_soc_component *component = NULL;
  1780. struct msm_asoc_mach_data *pdata =
  1781. snd_soc_card_get_drvdata(rtd->card);
  1782. if (pdata->dedicated_wsa2) {
  1783. if (pdata->wsa_max_devs > 2) {
  1784. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
  1785. if (!component) {
  1786. pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
  1787. return -EINVAL;
  1788. }
  1789. wsa883x_set_channel_map(component, &spkleft_ports[0],
  1790. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1791. &ch_rate[0], &spkleft_port_types[0]);
  1792. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1793. component);
  1794. }
  1795. if (pdata->wsa_max_devs > 3) {
  1796. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
  1797. if (!component) {
  1798. pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
  1799. return -EINVAL;
  1800. }
  1801. wsa883x_set_channel_map(component, &spkright_ports[0],
  1802. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1803. &ch_rate[0], &spkright_port_types[0]);
  1804. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1805. component);
  1806. }
  1807. msm_common_dai_link_init(rtd);
  1808. }
  1809. return 0;
  1810. }
  1811. static int msm_int_wsa884x_2_init(struct snd_soc_pcm_runtime *rtd)
  1812. {
  1813. u8 spkleft_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
  1814. u8 spkright_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
  1815. u8 spkleft_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  1816. SPKR_L_BOOST, PBR, SPKR_L_VI, CPS};
  1817. u8 spkright_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  1818. SPKR_R_BOOST, PBR, SPKR_R_VI, CPS};
  1819. unsigned int ch_rate[WSA884X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  1820. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_48KHZ,
  1821. SWR_CLK_RATE_1P2MHZ, SWR_CLK_RATE_24KHZ};
  1822. unsigned int ch_mask[WSA884X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x1, 0x3, 0x3};
  1823. struct snd_soc_component *component = NULL;
  1824. struct msm_asoc_mach_data *pdata =
  1825. snd_soc_card_get_drvdata(rtd->card);
  1826. if (pdata->dedicated_wsa2) {
  1827. if (pdata->wsa_max_devs > 2) {
  1828. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
  1829. if (!component) {
  1830. pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
  1831. return -EINVAL;
  1832. }
  1833. wsa884x_set_channel_map(component, &spkleft_ports[0],
  1834. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1835. &ch_rate[0], &spkleft_port_types[0]);
  1836. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1837. component);
  1838. }
  1839. if (pdata->wsa_max_devs > 3) {
  1840. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
  1841. if (!component) {
  1842. pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
  1843. return -EINVAL;
  1844. }
  1845. wsa884x_set_channel_map(component, &spkright_ports[0],
  1846. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1847. &ch_rate[0], &spkright_port_types[0]);
  1848. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1849. component);
  1850. }
  1851. msm_common_dai_link_init(rtd);
  1852. }
  1853. return 0;
  1854. }
  1855. static int msm_int_wsa2_init(struct snd_soc_pcm_runtime *rtd)
  1856. {
  1857. if (strstr(rtd->card->name, "wsa883x"))
  1858. return msm_int_wsa883x_2_init(rtd);
  1859. return msm_int_wsa884x_2_init(rtd);
  1860. }
  1861. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
  1862. {
  1863. int codec_variant = -1;
  1864. struct snd_soc_component *component = NULL;
  1865. struct snd_soc_component *lpass_cdc_component = NULL;
  1866. struct snd_soc_dapm_context *dapm = NULL;
  1867. struct snd_info_entry *entry = NULL;
  1868. struct snd_card *card = NULL;
  1869. struct msm_asoc_mach_data *pdata =
  1870. snd_soc_card_get_drvdata(rtd->card);
  1871. int ret = 0;
  1872. lpass_cdc_component = snd_soc_rtdcom_lookup(rtd, "lpass-cdc");
  1873. if (!lpass_cdc_component) {
  1874. pr_err("%s: could not find component for lpass-cdc\n",
  1875. __func__);
  1876. return ret;
  1877. }
  1878. dapm = snd_soc_component_get_dapm(lpass_cdc_component);
  1879. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  1880. ARRAY_SIZE(msm_int_dapm_widgets));
  1881. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  1882. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  1883. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  1884. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  1885. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  1886. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  1887. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  1888. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  1889. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  1890. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  1891. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  1892. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  1893. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  1894. lpass_cdc_set_port_map(lpass_cdc_component, ARRAY_SIZE(sm_port_map), sm_port_map);
  1895. card = rtd->card->snd_card;
  1896. if (!pdata->codec_root) {
  1897. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1898. card->proc_root);
  1899. if (!entry) {
  1900. pr_debug("%s: Cannot create codecs module entry\n",
  1901. __func__);
  1902. return ret;
  1903. }
  1904. pdata->codec_root = entry;
  1905. }
  1906. lpass_cdc_info_create_codec_entry(pdata->codec_root, lpass_cdc_component);
  1907. lpass_cdc_register_wake_irq(lpass_cdc_component, false);
  1908. if (pdata->wcd_disabled)
  1909. goto done;
  1910. component = snd_soc_rtdcom_lookup(rtd, WCD939X_DRV_NAME);
  1911. if (!component) {
  1912. component = snd_soc_rtdcom_lookup(rtd, WCD937X_DRV_NAME);
  1913. if (!component) {
  1914. component = snd_soc_rtdcom_lookup(rtd, WCD9378_DRV_NAME);
  1915. if (!component) {
  1916. pr_err("%s component is NULL\n", __func__);
  1917. ret = -EINVAL;
  1918. goto exit;
  1919. } else {
  1920. pdata->wcd_used = WCD9378_DEV_INDEX;
  1921. }
  1922. } else {
  1923. pdata->wcd_used = WCD937X_DEV_INDEX;
  1924. }
  1925. } else {
  1926. pdata->wcd_used = WCD939X_DEV_INDEX;
  1927. }
  1928. dapm = snd_soc_component_get_dapm(component);
  1929. card = component->card->snd_card;
  1930. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  1931. if (pdata->wcd_used != WCD939X_DEV_INDEX)
  1932. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  1933. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  1934. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  1935. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  1936. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  1937. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  1938. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  1939. snd_soc_dapm_sync(dapm);
  1940. pdata = snd_soc_card_get_drvdata(component->card);
  1941. if (!pdata->codec_root) {
  1942. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1943. card->proc_root);
  1944. if (!entry) {
  1945. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  1946. __func__);
  1947. return 0;
  1948. }
  1949. pdata->codec_root = entry;
  1950. }
  1951. if (pdata->wcd_used == WCD937X_DEV_INDEX) {
  1952. wcd937x_info_create_codec_entry(pdata->codec_root, component);
  1953. codec_variant = wcd937x_get_codec_variant(component);
  1954. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  1955. } else if (pdata->wcd_used == WCD9378_DEV_INDEX) {
  1956. wcd9378_info_create_codec_entry(pdata->codec_root, component);
  1957. } else {
  1958. wcd939x_info_create_codec_entry(pdata->codec_root, component);
  1959. codec_variant = wcd939x_get_codec_variant(component);
  1960. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  1961. #ifdef CONFIG_BOLERO_VER_2P6
  1962. if (codec_variant == WCD9395)
  1963. ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, true);
  1964. else
  1965. ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, false);
  1966. #endif
  1967. }
  1968. if (ret < 0) {
  1969. dev_err_ratelimited(component->dev, "%s: set fir capability failed: %d\n",
  1970. __func__, ret);
  1971. return ret;
  1972. }
  1973. done:
  1974. codec_reg_done = true;
  1975. msm_common_dai_link_init(rtd);
  1976. exit:
  1977. return ret;
  1978. }
  1979. static int pineapple_ssr_enable(struct device *dev, void *data)
  1980. {
  1981. struct platform_device *pdev = to_platform_device(dev);
  1982. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1983. struct snd_soc_pcm_runtime *rtd = NULL, *rtd_wcd = NULL, *rtd_wsa = NULL;
  1984. struct msm_asoc_mach_data *pdata = NULL;
  1985. int ret = 0;
  1986. if (!card) {
  1987. dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
  1988. ret = -EINVAL;
  1989. goto err;
  1990. }
  1991. if (!strcmp(card->name, "pineapple-stub-snd-card")) {
  1992. /* TODO */
  1993. dev_dbg(dev, "%s: TODO \n", __func__);
  1994. }
  1995. snd_card_notify_user(SND_CARD_STATUS_ONLINE);
  1996. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  1997. pdata = snd_soc_card_get_drvdata(card);
  1998. if (!pdata) {
  1999. dev_dbg(dev, "%s: pdata is NULL \n", __func__);
  2000. goto err;
  2001. }
  2002. rtd_wcd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
  2003. if (!rtd_wcd) {
  2004. dev_dbg(dev,
  2005. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  2006. __func__, card->dai_link[0]);
  2007. }
  2008. if (pdata->wsa_max_devs > 0) {
  2009. rtd_wsa = snd_soc_get_pcm_runtime(card,
  2010. &card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
  2011. if (!rtd_wsa) {
  2012. dev_dbg(dev,
  2013. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  2014. __func__, card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
  2015. }
  2016. }
  2017. /* set UPD configuration */
  2018. if(!pdata->upd_config.backend_used) {
  2019. dev_dbg(dev,
  2020. "%s: upd- backend_used is NULL\n", __func__);
  2021. goto err;
  2022. }
  2023. if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
  2024. if (!rtd_wsa)
  2025. goto err;
  2026. else
  2027. rtd = rtd_wsa;
  2028. } else if(!strcmp(pdata->upd_config.backend_used, "wcd")) {
  2029. if (!rtd_wcd &&!pdata->wcd_disabled)
  2030. goto err;
  2031. else
  2032. rtd = rtd_wcd;
  2033. } else {
  2034. dev_err_ratelimited(card->dev, "%s: Invalid backend to set UPD config\n",
  2035. __func__);
  2036. goto err;
  2037. }
  2038. msm_set_upd_config(rtd);
  2039. err:
  2040. return ret;
  2041. }
  2042. static void pineapple_ssr_disable(struct device *dev, void *data)
  2043. {
  2044. struct platform_device *pdev = to_platform_device(dev);
  2045. struct snd_soc_card *card = platform_get_drvdata(pdev);
  2046. if (!card) {
  2047. dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
  2048. return;
  2049. }
  2050. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  2051. snd_card_notify_user(SND_CARD_STATUS_OFFLINE);
  2052. if (!strcmp(card->name, "pineapple-stub-snd-card")) {
  2053. /* TODO */
  2054. dev_dbg(dev, "%s: TODO \n", __func__);
  2055. }
  2056. }
  2057. static const struct snd_event_ops pineapple_ssr_ops = {
  2058. .enable = pineapple_ssr_enable,
  2059. .disable = pineapple_ssr_disable,
  2060. };
  2061. static int msm_audio_ssr_compare(struct device *dev, void *data)
  2062. {
  2063. struct device_node *node = data;
  2064. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  2065. __func__, dev->of_node, node);
  2066. return (dev->of_node && dev->of_node == node);
  2067. }
  2068. static int msm_audio_ssr_register(struct device *dev)
  2069. {
  2070. struct device_node *np = dev->of_node;
  2071. struct snd_event_clients *ssr_clients = NULL;
  2072. struct device_node *node = NULL;
  2073. int ret = 0;
  2074. int i = 0;
  2075. for (i = 0; ; i++) {
  2076. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  2077. if (!node)
  2078. break;
  2079. snd_event_mstr_add_client(&ssr_clients,
  2080. msm_audio_ssr_compare, node);
  2081. }
  2082. ret = snd_event_master_register(dev, &pineapple_ssr_ops,
  2083. ssr_clients, NULL);
  2084. if (!ret)
  2085. snd_event_notify(dev, SND_EVENT_UP);
  2086. return ret;
  2087. }
  2088. struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card)
  2089. {
  2090. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  2091. if (!pdata)
  2092. return NULL;
  2093. return pdata->common_pdata;
  2094. }
  2095. void msm_common_set_pdata(struct snd_soc_card *card,
  2096. struct msm_common_pdata *common_pdata)
  2097. {
  2098. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  2099. if (!pdata)
  2100. return;
  2101. pdata->common_pdata = common_pdata;
  2102. }
  2103. static int msm_asoc_parse_soundcard_name(struct platform_device *pdev,
  2104. struct snd_soc_card *card)
  2105. {
  2106. struct nvmem_cell *cell = NULL;
  2107. size_t len = 0;
  2108. u32 *buf = NULL;
  2109. u32 adsp_var_idx = 0;
  2110. int ret = 0;
  2111. /* get adsp variant idx */
  2112. cell = nvmem_cell_get(&pdev->dev, "adsp_variant");
  2113. if (IS_ERR_OR_NULL(cell)) {
  2114. dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell\n", __func__);
  2115. goto parse;
  2116. }
  2117. buf = nvmem_cell_read(cell, &len);
  2118. nvmem_cell_put(cell);
  2119. if (IS_ERR_OR_NULL(buf)) {
  2120. dev_dbg(&pdev->dev, "%s: FAILED to read nvmem cell\n", __func__);
  2121. goto parse;
  2122. }
  2123. if (len <= 0 || len > sizeof(u32)) {
  2124. dev_dbg(&pdev->dev, "%s: nvmem cell length out of range: %d\n",
  2125. __func__, len);
  2126. kfree(buf);
  2127. goto parse;
  2128. }
  2129. memcpy(&adsp_var_idx, buf, len);
  2130. kfree(buf);
  2131. parse:
  2132. if (adsp_var_idx)
  2133. ret = snd_soc_of_parse_card_name(card, "qcom,sku-model");
  2134. else
  2135. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  2136. if (ret)
  2137. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  2138. __func__, ret);
  2139. return ret;
  2140. }
  2141. static int msm_asoc_machine_probe(struct platform_device *pdev)
  2142. {
  2143. struct snd_soc_card *card = NULL;
  2144. struct msm_asoc_mach_data *pdata = NULL;
  2145. int ret = 0;
  2146. struct clk *lpass_audio_hw_vote = NULL;
  2147. const struct of_device_id *match;
  2148. if (!pdev->dev.of_node) {
  2149. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  2150. return -EINVAL;
  2151. }
  2152. pdata = devm_kzalloc(&pdev->dev,
  2153. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  2154. if (!pdata)
  2155. return -ENOMEM;
  2156. of_property_read_u32(pdev->dev.of_node,
  2157. "qcom,wcd-disabled",
  2158. &pdata->wcd_disabled);
  2159. /* Get maximum WSA device count for this platform */
  2160. ret = of_property_read_u32(pdev->dev.of_node,
  2161. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  2162. if (ret) {
  2163. dev_info(&pdev->dev,
  2164. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  2165. __func__, pdev->dev.of_node->full_name, ret);
  2166. pdata->wsa_max_devs = 0;
  2167. }
  2168. /* Check if WSA2 Backends were used for dedicated usecase */
  2169. pdata->dedicated_wsa2 = of_find_property(pdev->dev.of_node,
  2170. "qcom,dedicated-wsa2", NULL);
  2171. card = populate_snd_card_dailinks(&pdev->dev, pdata->wsa_max_devs);
  2172. if (!card) {
  2173. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  2174. ret = -EINVAL;
  2175. goto err;
  2176. }
  2177. match = of_match_node(pineapple_asoc_machine_of_match, pdev->dev.of_node);
  2178. if (!match) {
  2179. dev_err(&pdev->dev, "%s: No DT match found for sound card\n",
  2180. __func__);
  2181. ret = -EINVAL;
  2182. goto err;
  2183. }
  2184. card->dev = &pdev->dev;
  2185. platform_set_drvdata(pdev, card);
  2186. snd_soc_card_set_drvdata(card, pdata);
  2187. ret = msm_asoc_parse_soundcard_name(pdev, card);
  2188. if (ret) {
  2189. dev_err(&pdev->dev, "%s: parse soundcard name failed, err:%d\n",
  2190. __func__, ret);
  2191. goto err;
  2192. }
  2193. if(!strcmp(match->data, "codec")) {
  2194. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  2195. if (ret) {
  2196. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  2197. __func__, ret);
  2198. goto err;
  2199. }
  2200. }
  2201. ret = msm_populate_dai_link_component_of_node(card);
  2202. if (ret) {
  2203. ret = -EPROBE_DEFER;
  2204. goto err;
  2205. }
  2206. /* parse upd configuration */
  2207. msm_parse_upd_configuration(pdev, pdata);
  2208. ret = devm_snd_soc_register_card(&pdev->dev, card);
  2209. if (ret == -EPROBE_DEFER) {
  2210. if (codec_reg_done)
  2211. ret = -EINVAL;
  2212. goto err;
  2213. } else if (ret) {
  2214. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  2215. __func__, ret);
  2216. goto err;
  2217. }
  2218. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  2219. __func__, card->name);
  2220. if (wcd_mbhc_cfg.enable_usbc_analog)
  2221. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  2222. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  2223. "fsa4480-i2c-handle", 0);
  2224. if (!pdata->fsa_handle)
  2225. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  2226. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  2227. pdata->wcd_usbss_handle = of_parse_phandle(pdev->dev.of_node,
  2228. "wcd939x-i2c-handle", 0);
  2229. if (!pdata->wcd_usbss_handle)
  2230. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  2231. "wcd939x-i2c-handle", pdev->dev.of_node->full_name);
  2232. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2233. "qcom,cdc-dmic01-gpios",
  2234. 0);
  2235. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2236. "qcom,cdc-dmic23-gpios",
  2237. 0);
  2238. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2239. "qcom,cdc-dmic45-gpios",
  2240. 0);
  2241. pdata->dmic67_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2242. "qcom,cdc-dmic67-gpios",
  2243. 0);
  2244. if (pdata->dmic01_gpio_p)
  2245. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  2246. if (pdata->dmic23_gpio_p)
  2247. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  2248. if (pdata->dmic45_gpio_p)
  2249. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  2250. if (pdata->dmic67_gpio_p)
  2251. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic67_gpio_p, false);
  2252. msm_common_snd_init(pdev, card);
  2253. /* Register LPASS audio hw vote */
  2254. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  2255. if (IS_ERR(lpass_audio_hw_vote)) {
  2256. ret = PTR_ERR(lpass_audio_hw_vote);
  2257. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  2258. __func__, "lpass_audio_hw_vote", ret);
  2259. lpass_audio_hw_vote = NULL;
  2260. ret = 0;
  2261. }
  2262. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  2263. pdata->core_audio_vote_count = 0;
  2264. ret = msm_audio_ssr_register(&pdev->dev);
  2265. if (ret)
  2266. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  2267. __func__, ret);
  2268. is_initial_boot = true;
  2269. /* change card status to ONLINE */
  2270. dev_dbg(&pdev->dev, "%s: setting snd_card to ONLINE\n", __func__);
  2271. snd_card_set_card_status(SND_CARD_STATUS_ONLINE);
  2272. return 0;
  2273. err:
  2274. devm_kfree(&pdev->dev, pdata);
  2275. return ret;
  2276. }
  2277. static int msm_asoc_machine_remove(struct platform_device *pdev)
  2278. {
  2279. struct snd_soc_card *card = platform_get_drvdata(pdev);
  2280. struct msm_asoc_mach_data *pdata = NULL;
  2281. struct msm_common_pdata *common_pdata = NULL;
  2282. if (card)
  2283. pdata = snd_soc_card_get_drvdata(card);
  2284. if (pdata)
  2285. common_pdata = pdata->common_pdata;
  2286. msm_common_snd_deinit(common_pdata);
  2287. snd_event_master_deregister(&pdev->dev);
  2288. snd_soc_unregister_card(card);
  2289. return 0;
  2290. }
  2291. static struct platform_driver pineapple_asoc_machine_driver = {
  2292. .driver = {
  2293. .name = DRV_NAME,
  2294. .owner = THIS_MODULE,
  2295. .pm = &snd_soc_pm_ops,
  2296. .of_match_table = pineapple_asoc_machine_of_match,
  2297. .suppress_bind_attrs = true,
  2298. },
  2299. .probe = msm_asoc_machine_probe,
  2300. .remove = msm_asoc_machine_remove,
  2301. };
  2302. static int __init msm_asoc_machine_init(void)
  2303. {
  2304. snd_card_sysfs_init();
  2305. return platform_driver_register(&pineapple_asoc_machine_driver);
  2306. }
  2307. module_init(msm_asoc_machine_init);
  2308. static void __exit msm_asoc_machine_exit(void)
  2309. {
  2310. platform_driver_unregister(&pineapple_asoc_machine_driver);
  2311. }
  2312. module_exit(msm_asoc_machine_exit);
  2313. #ifndef CONFIG_AUDIO_BTFM_PROXY
  2314. MODULE_SOFTDEP("pre: bt_fm_slim");
  2315. #else
  2316. MODULE_SOFTDEP("pre: btfmcodec");
  2317. #endif
  2318. MODULE_DESCRIPTION("ALSA SoC msm");
  2319. MODULE_LICENSE("GPL v2");
  2320. MODULE_ALIAS("platform:" DRV_NAME);
  2321. MODULE_DEVICE_TABLE(of, pineapple_asoc_machine_of_match);