pineapple.c 57 KB

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