pineapple.c 69 KB

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