pineapple.c 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/clk.h>
  7. #include <linux/delay.h>
  8. #include <linux/gpio.h>
  9. #include <linux/of_gpio.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/slab.h>
  12. #include <linux/io.h>
  13. #include <linux/module.h>
  14. #include <linux/input.h>
  15. #include <linux/of_device.h>
  16. #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. }
  154. #endif
  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. if (codec_variant == WCD9395)
  1941. ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, true);
  1942. else
  1943. ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, false);
  1944. }
  1945. if (ret < 0) {
  1946. dev_err_ratelimited(component->dev, "%s: set fir capability failed: %d\n",
  1947. __func__, ret);
  1948. return ret;
  1949. }
  1950. done:
  1951. codec_reg_done = true;
  1952. msm_common_dai_link_init(rtd);
  1953. exit:
  1954. return ret;
  1955. }
  1956. static int pineapple_ssr_enable(struct device *dev, void *data)
  1957. {
  1958. struct platform_device *pdev = to_platform_device(dev);
  1959. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1960. struct snd_soc_pcm_runtime *rtd = NULL, *rtd_wcd = NULL, *rtd_wsa = NULL;
  1961. struct msm_asoc_mach_data *pdata = NULL;
  1962. int ret = 0;
  1963. if (!card) {
  1964. dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
  1965. ret = -EINVAL;
  1966. goto err;
  1967. }
  1968. if (!strcmp(card->name, "pineapple-stub-snd-card")) {
  1969. /* TODO */
  1970. dev_dbg(dev, "%s: TODO \n", __func__);
  1971. }
  1972. snd_card_notify_user(SND_CARD_STATUS_ONLINE);
  1973. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  1974. pdata = snd_soc_card_get_drvdata(card);
  1975. if (!pdata) {
  1976. dev_dbg(dev, "%s: pdata is NULL \n", __func__);
  1977. goto err;
  1978. }
  1979. rtd_wcd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
  1980. if (!rtd_wcd) {
  1981. dev_dbg(dev,
  1982. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1983. __func__, card->dai_link[0]);
  1984. }
  1985. if (pdata->wsa_max_devs > 0) {
  1986. rtd_wsa = snd_soc_get_pcm_runtime(card,
  1987. &card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
  1988. if (!rtd_wsa) {
  1989. dev_dbg(dev,
  1990. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1991. __func__, card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
  1992. }
  1993. }
  1994. /* set UPD configuration */
  1995. if(!pdata->upd_config.backend_used) {
  1996. dev_dbg(dev,
  1997. "%s: upd- backend_used is NULL\n", __func__);
  1998. goto err;
  1999. }
  2000. if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
  2001. if (!rtd_wsa)
  2002. goto err;
  2003. else
  2004. rtd = rtd_wsa;
  2005. } else if(!strcmp(pdata->upd_config.backend_used, "wcd")) {
  2006. if (!rtd_wcd &&!pdata->wcd_disabled)
  2007. goto err;
  2008. else
  2009. rtd = rtd_wcd;
  2010. } else {
  2011. dev_err_ratelimited(card->dev, "%s: Invalid backend to set UPD config\n",
  2012. __func__);
  2013. goto err;
  2014. }
  2015. msm_set_upd_config(rtd);
  2016. err:
  2017. return ret;
  2018. }
  2019. static void pineapple_ssr_disable(struct device *dev, void *data)
  2020. {
  2021. struct platform_device *pdev = to_platform_device(dev);
  2022. struct snd_soc_card *card = platform_get_drvdata(pdev);
  2023. if (!card) {
  2024. dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
  2025. return;
  2026. }
  2027. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  2028. snd_card_notify_user(SND_CARD_STATUS_OFFLINE);
  2029. if (!strcmp(card->name, "pineapple-stub-snd-card")) {
  2030. /* TODO */
  2031. dev_dbg(dev, "%s: TODO \n", __func__);
  2032. }
  2033. }
  2034. static const struct snd_event_ops pineapple_ssr_ops = {
  2035. .enable = pineapple_ssr_enable,
  2036. .disable = pineapple_ssr_disable,
  2037. };
  2038. static int msm_audio_ssr_compare(struct device *dev, void *data)
  2039. {
  2040. struct device_node *node = data;
  2041. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  2042. __func__, dev->of_node, node);
  2043. return (dev->of_node && dev->of_node == node);
  2044. }
  2045. static int msm_audio_ssr_register(struct device *dev)
  2046. {
  2047. struct device_node *np = dev->of_node;
  2048. struct snd_event_clients *ssr_clients = NULL;
  2049. struct device_node *node = NULL;
  2050. int ret = 0;
  2051. int i = 0;
  2052. for (i = 0; ; i++) {
  2053. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  2054. if (!node)
  2055. break;
  2056. snd_event_mstr_add_client(&ssr_clients,
  2057. msm_audio_ssr_compare, node);
  2058. }
  2059. ret = snd_event_master_register(dev, &pineapple_ssr_ops,
  2060. ssr_clients, NULL);
  2061. if (!ret)
  2062. snd_event_notify(dev, SND_EVENT_UP);
  2063. return ret;
  2064. }
  2065. struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card)
  2066. {
  2067. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  2068. if (!pdata)
  2069. return NULL;
  2070. return pdata->common_pdata;
  2071. }
  2072. void msm_common_set_pdata(struct snd_soc_card *card,
  2073. struct msm_common_pdata *common_pdata)
  2074. {
  2075. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  2076. if (!pdata)
  2077. return;
  2078. pdata->common_pdata = common_pdata;
  2079. }
  2080. static int msm_asoc_machine_probe(struct platform_device *pdev)
  2081. {
  2082. struct snd_soc_card *card = NULL;
  2083. struct msm_asoc_mach_data *pdata = NULL;
  2084. int ret = 0;
  2085. struct clk *lpass_audio_hw_vote = NULL;
  2086. const struct of_device_id *match;
  2087. if (!pdev->dev.of_node) {
  2088. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  2089. return -EINVAL;
  2090. }
  2091. pdata = devm_kzalloc(&pdev->dev,
  2092. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  2093. if (!pdata)
  2094. return -ENOMEM;
  2095. of_property_read_u32(pdev->dev.of_node,
  2096. "qcom,wcd-disabled",
  2097. &pdata->wcd_disabled);
  2098. /* Get maximum WSA device count for this platform */
  2099. ret = of_property_read_u32(pdev->dev.of_node,
  2100. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  2101. if (ret) {
  2102. dev_info(&pdev->dev,
  2103. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  2104. __func__, pdev->dev.of_node->full_name, ret);
  2105. pdata->wsa_max_devs = 0;
  2106. }
  2107. /* Check if WSA2 Backends were used for dedicated usecase */
  2108. pdata->dedicated_wsa2 = of_find_property(pdev->dev.of_node,
  2109. "qcom,dedicated-wsa2", NULL);
  2110. card = populate_snd_card_dailinks(&pdev->dev, pdata->wsa_max_devs);
  2111. if (!card) {
  2112. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  2113. ret = -EINVAL;
  2114. goto err;
  2115. }
  2116. match = of_match_node(pineapple_asoc_machine_of_match, pdev->dev.of_node);
  2117. if (!match) {
  2118. dev_err(&pdev->dev, "%s: No DT match found for sound card\n",
  2119. __func__);
  2120. ret = -EINVAL;
  2121. goto err;
  2122. }
  2123. card->dev = &pdev->dev;
  2124. platform_set_drvdata(pdev, card);
  2125. snd_soc_card_set_drvdata(card, pdata);
  2126. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  2127. if (ret) {
  2128. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  2129. __func__, ret);
  2130. goto err;
  2131. }
  2132. if(!strcmp(match->data, "codec")) {
  2133. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  2134. if (ret) {
  2135. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  2136. __func__, ret);
  2137. goto err;
  2138. }
  2139. }
  2140. ret = msm_populate_dai_link_component_of_node(card);
  2141. if (ret) {
  2142. ret = -EPROBE_DEFER;
  2143. goto err;
  2144. }
  2145. /* parse upd configuration */
  2146. msm_parse_upd_configuration(pdev, pdata);
  2147. ret = devm_snd_soc_register_card(&pdev->dev, card);
  2148. if (ret == -EPROBE_DEFER) {
  2149. if (codec_reg_done)
  2150. ret = -EINVAL;
  2151. goto err;
  2152. } else if (ret) {
  2153. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  2154. __func__, ret);
  2155. goto err;
  2156. }
  2157. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  2158. __func__, card->name);
  2159. if (wcd_mbhc_cfg.enable_usbc_analog)
  2160. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  2161. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  2162. "fsa4480-i2c-handle", 0);
  2163. if (!pdata->fsa_handle)
  2164. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  2165. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  2166. pdata->wcd_usbss_handle = of_parse_phandle(pdev->dev.of_node,
  2167. "wcd939x-i2c-handle", 0);
  2168. if (!pdata->wcd_usbss_handle)
  2169. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  2170. "wcd939x-i2c-handle", pdev->dev.of_node->full_name);
  2171. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2172. "qcom,cdc-dmic01-gpios",
  2173. 0);
  2174. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2175. "qcom,cdc-dmic23-gpios",
  2176. 0);
  2177. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2178. "qcom,cdc-dmic45-gpios",
  2179. 0);
  2180. pdata->dmic67_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2181. "qcom,cdc-dmic67-gpios",
  2182. 0);
  2183. if (pdata->dmic01_gpio_p)
  2184. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  2185. if (pdata->dmic23_gpio_p)
  2186. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  2187. if (pdata->dmic45_gpio_p)
  2188. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  2189. if (pdata->dmic67_gpio_p)
  2190. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic67_gpio_p, false);
  2191. msm_common_snd_init(pdev, card);
  2192. /* Register LPASS audio hw vote */
  2193. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  2194. if (IS_ERR(lpass_audio_hw_vote)) {
  2195. ret = PTR_ERR(lpass_audio_hw_vote);
  2196. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  2197. __func__, "lpass_audio_hw_vote", ret);
  2198. lpass_audio_hw_vote = NULL;
  2199. ret = 0;
  2200. }
  2201. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  2202. pdata->core_audio_vote_count = 0;
  2203. ret = msm_audio_ssr_register(&pdev->dev);
  2204. if (ret)
  2205. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  2206. __func__, ret);
  2207. is_initial_boot = true;
  2208. /* change card status to ONLINE */
  2209. dev_dbg(&pdev->dev, "%s: setting snd_card to ONLINE\n", __func__);
  2210. snd_card_set_card_status(SND_CARD_STATUS_ONLINE);
  2211. return 0;
  2212. err:
  2213. devm_kfree(&pdev->dev, pdata);
  2214. return ret;
  2215. }
  2216. static int msm_asoc_machine_remove(struct platform_device *pdev)
  2217. {
  2218. struct snd_soc_card *card = platform_get_drvdata(pdev);
  2219. struct msm_asoc_mach_data *pdata = NULL;
  2220. struct msm_common_pdata *common_pdata = NULL;
  2221. if (card)
  2222. pdata = snd_soc_card_get_drvdata(card);
  2223. if (pdata)
  2224. common_pdata = pdata->common_pdata;
  2225. msm_common_snd_deinit(common_pdata);
  2226. snd_event_master_deregister(&pdev->dev);
  2227. snd_soc_unregister_card(card);
  2228. return 0;
  2229. }
  2230. static struct platform_driver pineapple_asoc_machine_driver = {
  2231. .driver = {
  2232. .name = DRV_NAME,
  2233. .owner = THIS_MODULE,
  2234. .pm = &snd_soc_pm_ops,
  2235. .of_match_table = pineapple_asoc_machine_of_match,
  2236. .suppress_bind_attrs = true,
  2237. },
  2238. .probe = msm_asoc_machine_probe,
  2239. .remove = msm_asoc_machine_remove,
  2240. };
  2241. static int __init msm_asoc_machine_init(void)
  2242. {
  2243. snd_card_sysfs_init();
  2244. return platform_driver_register(&pineapple_asoc_machine_driver);
  2245. }
  2246. module_init(msm_asoc_machine_init);
  2247. static void __exit msm_asoc_machine_exit(void)
  2248. {
  2249. platform_driver_unregister(&pineapple_asoc_machine_driver);
  2250. }
  2251. module_exit(msm_asoc_machine_exit);
  2252. #ifndef CONFIG_AUDIO_BTFM_PROXY
  2253. MODULE_SOFTDEP("pre: bt_fm_slim");
  2254. #else
  2255. MODULE_SOFTDEP("pre: btfmcodec");
  2256. #endif
  2257. MODULE_DESCRIPTION("ALSA SoC msm");
  2258. MODULE_LICENSE("GPL v2");
  2259. MODULE_ALIAS("platform:" DRV_NAME);
  2260. MODULE_DEVICE_TABLE(of, pineapple_asoc_machine_of_match);