kalama.c 56 KB

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