pineapple.c 68 KB

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