pineapple.c 70 KB

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