holi.c 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/clk.h>
  7. #include <linux/delay.h>
  8. #include <linux/gpio.h>
  9. #include <linux/of_gpio.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/slab.h>
  12. #include <linux/io.h>
  13. #include <linux/module.h>
  14. #include <linux/input.h>
  15. #include <linux/of_device.h>
  16. #include <linux/soc/qcom/fsa4480-i2c.h>
  17. #include <linux/pm_qos.h>
  18. #include <linux/nvmem-consumer.h>
  19. #include <sound/control.h>
  20. #include <sound/core.h>
  21. #include <sound/soc.h>
  22. #include <sound/soc-dapm.h>
  23. #include <sound/pcm.h>
  24. #include <sound/pcm_params.h>
  25. #include <sound/info.h>
  26. #include <soc/snd_event.h>
  27. #include <dsp/audio_prm.h>
  28. #include <soc/swr-common.h>
  29. #include <soc/soundwire.h>
  30. #include "device_event.h"
  31. #include "asoc/msm-cdc-pinctrl.h"
  32. #include "asoc/wcd-mbhc-v2.h"
  33. #include "codecs/wsa881x-analog.h"
  34. #include "codecs/wcd937x/wcd937x-mbhc.h"
  35. #include "codecs/wcd937x/wcd937x.h"
  36. #include "codecs/wcd938x/wcd938x-mbhc.h"
  37. #include "codecs/wcd938x/wcd938x.h"
  38. #include "codecs/bolero/bolero-cdc.h"
  39. #include <bindings/audio-codec-port-types.h>
  40. #include "holi-port-config.h"
  41. #include "msm-audio-defs.h"
  42. #include "msm_common.h"
  43. #include "msm_holi_dailink.h"
  44. #define DRV_NAME "holi-asoc-snd"
  45. #define __CHIPSET__ "HOLI "
  46. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  47. #define SAMPLING_RATE_8KHZ 8000
  48. #define SAMPLING_RATE_11P025KHZ 11025
  49. #define SAMPLING_RATE_16KHZ 16000
  50. #define SAMPLING_RATE_22P05KHZ 22050
  51. #define SAMPLING_RATE_32KHZ 32000
  52. #define SAMPLING_RATE_44P1KHZ 44100
  53. #define SAMPLING_RATE_48KHZ 48000
  54. #define SAMPLING_RATE_88P2KHZ 88200
  55. #define SAMPLING_RATE_96KHZ 96000
  56. #define SAMPLING_RATE_176P4KHZ 176400
  57. #define SAMPLING_RATE_192KHZ 192000
  58. #define SAMPLING_RATE_352P8KHZ 352800
  59. #define SAMPLING_RATE_384KHZ 384000
  60. #define IS_FRACTIONAL(x) \
  61. ((x == SAMPLING_RATE_11P025KHZ) || (x == SAMPLING_RATE_22P05KHZ) || \
  62. (x == SAMPLING_RATE_44P1KHZ) || (x == SAMPLING_RATE_88P2KHZ) || \
  63. (x == SAMPLING_RATE_176P4KHZ) || (x == SAMPLING_RATE_352P8KHZ))
  64. #define IS_MSM_INTERFACE_MI2S(x) \
  65. ((x == PRIM_MI2S) || (x == SEC_MI2S) || (x == TERT_MI2S))
  66. #define WCD9XXX_MBHC_DEF_RLOADS 5
  67. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  68. #define CODEC_EXT_CLK_RATE 9600000
  69. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  70. #define DEV_NAME_STR_LEN 32
  71. #define WCD_MBHC_HS_V_MAX 1600
  72. #define TDM_CHANNEL_MAX 8
  73. #define DEV_NAME_STR_LEN 32
  74. /* time in us to ensure LPM doesn't go in C3/C4 */
  75. #define MSM_LL_QOS_VALUE 300
  76. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  77. #define WCN_CDC_SLIM_RX_CH_MAX 2
  78. #define WCN_CDC_SLIM_TX_CH_MAX 3
  79. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  80. enum {
  81. RX_PATH = 0,
  82. TX_PATH,
  83. MAX_PATH,
  84. };
  85. enum {
  86. TDM_0 = 0,
  87. TDM_1,
  88. TDM_2,
  89. TDM_3,
  90. TDM_4,
  91. TDM_5,
  92. TDM_6,
  93. TDM_7,
  94. TDM_PORT_MAX,
  95. };
  96. #define TDM_MAX_SLOTS 8
  97. #define TDM_SLOT_WIDTH_BITS 32
  98. enum {
  99. TDM_PRI = 0,
  100. TDM_SEC,
  101. TDM_TERT,
  102. TDM_QUAT,
  103. TDM_INTERFACE_MAX,
  104. };
  105. enum {
  106. PRIM_AUX_PCM = 0,
  107. SEC_AUX_PCM,
  108. TERT_AUX_PCM,
  109. QUAT_AUX_PCM,
  110. AUX_PCM_MAX,
  111. };
  112. enum {
  113. PRIM_MI2S = 0,
  114. SEC_MI2S,
  115. TERT_MI2S,
  116. QUAT_MI2S,
  117. MI2S_MAX,
  118. };
  119. enum {
  120. RX_CDC_DMA_RX_0 = 0,
  121. RX_CDC_DMA_RX_1,
  122. RX_CDC_DMA_RX_2,
  123. RX_CDC_DMA_RX_3,
  124. RX_CDC_DMA_RX_5,
  125. RX_CDC_DMA_RX_6,
  126. CDC_DMA_RX_MAX,
  127. };
  128. enum {
  129. TX_CDC_DMA_TX_0 = 0,
  130. TX_CDC_DMA_TX_3,
  131. TX_CDC_DMA_TX_4,
  132. VA_CDC_DMA_TX_0,
  133. VA_CDC_DMA_TX_1,
  134. VA_CDC_DMA_TX_2,
  135. CDC_DMA_TX_MAX,
  136. };
  137. enum {
  138. SLIM_RX_7 = 0,
  139. SLIM_RX_MAX,
  140. };
  141. enum {
  142. SLIM_TX_7 = 0,
  143. SLIM_TX_8,
  144. SLIM_TX_MAX,
  145. };
  146. enum {
  147. AFE_LOOPBACK_TX_IDX = 0,
  148. AFE_LOOPBACK_TX_IDX_MAX,
  149. };
  150. struct msm_asoc_mach_data {
  151. struct snd_info_entry *codec_root;
  152. struct msm_common_pdata *common_pdata;
  153. int usbc_en2_gpio; /* used by gpio driver API */
  154. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  155. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  156. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  157. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  158. atomic_t mi2s_gpio_ref_count[MI2S_MAX]; /* used by pinctrl API */
  159. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  160. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  161. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  162. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  163. bool is_afe_config_done;
  164. struct device_node *fsa_handle;
  165. struct clk *lpass_audio_hw_vote;
  166. int core_audio_vote_count;
  167. u32 wcd_disabled;
  168. u32 wsa_max_devs;
  169. };
  170. struct tdm_port {
  171. u32 mode;
  172. u32 channel;
  173. };
  174. struct tdm_dev_config {
  175. unsigned int tdm_slot_offset[TDM_MAX_SLOTS];
  176. };
  177. struct dev_config {
  178. u32 sample_rate;
  179. u32 bit_format;
  180. u32 channels;
  181. };
  182. struct mi2s_conf {
  183. struct mutex lock;
  184. u32 ref_cnt;
  185. u32 msm_is_mi2s_master;
  186. };
  187. static bool is_initial_boot;
  188. static bool codec_reg_done;
  189. static struct snd_soc_card snd_soc_card_holi_msm;
  190. static int dmic_0_1_gpio_cnt;
  191. static int dmic_2_3_gpio_cnt;
  192. static int dmic_4_5_gpio_cnt;
  193. static void *def_wcd_mbhc_cal(void);
  194. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *);
  195. static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd);
  196. /*
  197. * Need to report LINEIN
  198. * if R/L channel impedance is larger than 5K ohm
  199. */
  200. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  201. .read_fw_bin = false,
  202. .calibration = NULL,
  203. .detect_extn_cable = true,
  204. .mono_stero_detection = false,
  205. .swap_gnd_mic = NULL,
  206. .hs_ext_micbias = true,
  207. .key_code[0] = KEY_MEDIA,
  208. .key_code[1] = KEY_VOICECOMMAND,
  209. .key_code[2] = KEY_VOLUMEUP,
  210. .key_code[3] = KEY_VOLUMEDOWN,
  211. .key_code[4] = 0,
  212. .key_code[5] = 0,
  213. .key_code[6] = 0,
  214. .key_code[7] = 0,
  215. .linein_th = 5000,
  216. .moisture_en = false,
  217. .mbhc_micbias = MIC_BIAS_2,
  218. .anc_micbias = MIC_BIAS_2,
  219. .enable_anc_mic_detect = false,
  220. .moisture_duty_cycle_en = true,
  221. };
  222. struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card)
  223. {
  224. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  225. if (!pdata)
  226. return NULL;
  227. return pdata->common_pdata;
  228. }
  229. void msm_common_set_pdata(struct snd_soc_card *card,
  230. struct msm_common_pdata *common_pdata)
  231. {
  232. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  233. if (!pdata)
  234. return;
  235. pdata->common_pdata = common_pdata;
  236. }
  237. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component,
  238. bool active)
  239. {
  240. struct snd_soc_card *card = component->card;
  241. struct msm_asoc_mach_data *pdata =
  242. snd_soc_card_get_drvdata(card);
  243. if (!pdata->fsa_handle)
  244. return false;
  245. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  246. }
  247. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  248. {
  249. int value = 0;
  250. bool ret = false;
  251. struct snd_soc_card *card;
  252. struct msm_asoc_mach_data *pdata;
  253. if (!component) {
  254. pr_err("%s component is NULL\n", __func__);
  255. return false;
  256. }
  257. card = component->card;
  258. pdata = snd_soc_card_get_drvdata(card);
  259. if (!pdata)
  260. return false;
  261. if (wcd_mbhc_cfg.enable_usbc_analog)
  262. return msm_usbc_swap_gnd_mic(component, active);
  263. /* if usbc is not defined, swap using us_euro_gpio_p */
  264. if (pdata->us_euro_gpio_p) {
  265. value = msm_cdc_pinctrl_get_state(
  266. pdata->us_euro_gpio_p);
  267. if (value)
  268. msm_cdc_pinctrl_select_sleep_state(
  269. pdata->us_euro_gpio_p);
  270. else
  271. msm_cdc_pinctrl_select_active_state(
  272. pdata->us_euro_gpio_p);
  273. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  274. __func__, value, !value);
  275. ret = true;
  276. }
  277. return ret;
  278. }
  279. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  280. struct snd_kcontrol *kcontrol, int event)
  281. {
  282. struct msm_asoc_mach_data *pdata = NULL;
  283. struct snd_soc_component *component =
  284. snd_soc_dapm_to_component(w->dapm);
  285. int ret = 0;
  286. u32 dmic_idx;
  287. int *dmic_gpio_cnt;
  288. struct device_node *dmic_gpio;
  289. char *wname;
  290. wname = strpbrk(w->name, "0123");
  291. if (!wname) {
  292. dev_err(component->dev, "%s: widget not found\n", __func__);
  293. return -EINVAL;
  294. }
  295. ret = kstrtouint(wname, 10, &dmic_idx);
  296. if (ret < 0) {
  297. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  298. __func__);
  299. return -EINVAL;
  300. }
  301. pdata = snd_soc_card_get_drvdata(component->card);
  302. switch (dmic_idx) {
  303. case 0:
  304. case 1:
  305. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  306. dmic_gpio = pdata->dmic01_gpio_p;
  307. break;
  308. case 2:
  309. case 3:
  310. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  311. dmic_gpio = pdata->dmic23_gpio_p;
  312. break;
  313. case 4:
  314. case 5:
  315. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  316. dmic_gpio = pdata->dmic45_gpio_p;
  317. break;
  318. default:
  319. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  320. __func__);
  321. return -EINVAL;
  322. }
  323. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  324. __func__, event, dmic_idx, *dmic_gpio_cnt);
  325. switch (event) {
  326. case SND_SOC_DAPM_PRE_PMU:
  327. (*dmic_gpio_cnt)++;
  328. if (*dmic_gpio_cnt == 1) {
  329. ret = msm_cdc_pinctrl_select_active_state(
  330. dmic_gpio);
  331. if (ret < 0) {
  332. pr_err("%s: gpio set cannot be activated %sd",
  333. __func__, "dmic_gpio");
  334. return ret;
  335. }
  336. }
  337. break;
  338. case SND_SOC_DAPM_POST_PMD:
  339. (*dmic_gpio_cnt)--;
  340. if (*dmic_gpio_cnt == 0) {
  341. ret = msm_cdc_pinctrl_select_sleep_state(
  342. dmic_gpio);
  343. if (ret < 0) {
  344. pr_err("%s: gpio set cannot be de-activated %sd",
  345. __func__, "dmic_gpio");
  346. return ret;
  347. }
  348. }
  349. break;
  350. default:
  351. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  352. return -EINVAL;
  353. }
  354. return 0;
  355. }
  356. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  357. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  358. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  359. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  360. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  361. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  362. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  363. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  364. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  365. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  366. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  367. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  368. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  369. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  370. };
  371. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  372. {
  373. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  374. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160, 161};
  375. struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
  376. int ret = 0;
  377. ret = snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  378. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  379. if (ret)
  380. return ret;
  381. msm_common_dai_link_init(rtd);
  382. return ret;
  383. }
  384. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  385. const char *name,
  386. struct snd_info_entry *parent)
  387. {
  388. struct snd_info_entry *entry;
  389. entry = snd_info_create_module_entry(mod, name, parent);
  390. if (!entry)
  391. return NULL;
  392. entry->mode = S_IFDIR | 0555;
  393. if (snd_info_register(entry) < 0) {
  394. snd_info_free_entry(entry);
  395. return NULL;
  396. }
  397. return entry;
  398. }
  399. static void *def_wcd_mbhc_cal(void)
  400. {
  401. void *wcd_mbhc_cal;
  402. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  403. u16 *btn_high;
  404. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  405. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  406. if (!wcd_mbhc_cal)
  407. return NULL;
  408. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  409. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  410. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  411. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  412. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  413. btn_high[0] = 75;
  414. btn_high[1] = 150;
  415. btn_high[2] = 237;
  416. btn_high[3] = 500;
  417. btn_high[4] = 500;
  418. btn_high[5] = 500;
  419. btn_high[6] = 500;
  420. btn_high[7] = 500;
  421. return wcd_mbhc_cal;
  422. }
  423. static struct snd_soc_ops msm_common_be_ops = {
  424. .hw_params = msm_common_snd_hw_params,
  425. .startup = msm_common_snd_startup,
  426. .shutdown = msm_common_snd_shutdown,
  427. };
  428. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  429. /* Backend AFE DAI Links */
  430. #if 0
  431. /* Incall Record Uplink BACK END DAI Link */
  432. {
  433. .name = LPASS_BE_INCALL_RECORD_TX,
  434. .stream_name = "Voice Uplink Capture",
  435. .cpu_dai_name = "msm-dai-q6-dev.32772",
  436. .platform_name = "msm-pcm-routing",
  437. .codec_name = "msm-stub-codec.1",
  438. .codec_dai_name = "msm-stub-tx",
  439. .no_pcm = 1,
  440. .dpcm_capture = 1,
  441. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  442. .be_hw_params_fixup = msm_be_hw_params_fixup,
  443. .ignore_suspend = 1,
  444. },
  445. /* Incall Record Downlink BACK END DAI Link */
  446. {
  447. .name = LPASS_BE_INCALL_RECORD_RX,
  448. .stream_name = "Voice Downlink Capture",
  449. .cpu_dai_name = "msm-dai-q6-dev.32771",
  450. .platform_name = "msm-pcm-routing",
  451. .codec_name = "msm-stub-codec.1",
  452. .codec_dai_name = "msm-stub-tx",
  453. .no_pcm = 1,
  454. .dpcm_capture = 1,
  455. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  456. .be_hw_params_fixup = msm_be_hw_params_fixup,
  457. .ignore_suspend = 1,
  458. },
  459. /* Incall Music BACK END DAI Link */
  460. {
  461. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  462. .stream_name = "Voice Farend Playback",
  463. .cpu_dai_name = "msm-dai-q6-dev.32773",
  464. .platform_name = "msm-pcm-routing",
  465. .codec_name = "msm-stub-codec.1",
  466. .codec_dai_name = "msm-stub-rx",
  467. .no_pcm = 1,
  468. .dpcm_playback = 1,
  469. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  470. .be_hw_params_fixup = msm_be_hw_params_fixup,
  471. .ignore_suspend = 1,
  472. .ignore_pmdown_time = 1,
  473. },
  474. /* Incall Music 2 BACK END DAI Link */
  475. {
  476. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  477. .stream_name = "Voice2 Farend Playback",
  478. .cpu_dai_name = "msm-dai-q6-dev.32770",
  479. .platform_name = "msm-pcm-routing",
  480. .codec_name = "msm-stub-codec.1",
  481. .codec_dai_name = "msm-stub-rx",
  482. .no_pcm = 1,
  483. .dpcm_playback = 1,
  484. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  485. .be_hw_params_fixup = msm_be_hw_params_fixup,
  486. .ignore_suspend = 1,
  487. .ignore_pmdown_time = 1,
  488. },
  489. #endif
  490. /* Proxy Tx BACK END DAI Link */
  491. {
  492. .name = LPASS_BE_RT_PROXY_PCM_TX,
  493. .stream_name = LPASS_BE_RT_PROXY_PCM_TX,
  494. .capture_only = 1,
  495. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  496. SND_SOC_DPCM_TRIGGER_POST},
  497. .ignore_suspend = 1,
  498. .ops = &msm_common_be_ops,
  499. SND_SOC_DAILINK_REG(proxy_tx),
  500. },
  501. /* Proxy Rx BACK END DAI Link */
  502. {
  503. .name = LPASS_BE_RT_PROXY_PCM_RX,
  504. .stream_name = LPASS_BE_RT_PROXY_PCM_RX,
  505. .playback_only = 1,
  506. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  507. SND_SOC_DPCM_TRIGGER_POST},
  508. .ignore_pmdown_time = 1,
  509. .ignore_suspend = 1,
  510. .ops = &msm_common_be_ops,
  511. SND_SOC_DAILINK_REG(proxy_rx),
  512. },
  513. {
  514. .name = LPASS_BE_USB_AUDIO_RX,
  515. .stream_name = LPASS_BE_USB_AUDIO_RX,
  516. .playback_only = 1,
  517. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  518. SND_SOC_DPCM_TRIGGER_POST},
  519. .ignore_pmdown_time = 1,
  520. .ignore_suspend = 1,
  521. .ops = &msm_common_be_ops,
  522. SND_SOC_DAILINK_REG(usb_audio_rx),
  523. },
  524. {
  525. .name = LPASS_BE_USB_AUDIO_TX,
  526. .stream_name = LPASS_BE_USB_AUDIO_TX,
  527. .capture_only = 1,
  528. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  529. SND_SOC_DPCM_TRIGGER_POST},
  530. .ignore_suspend = 1,
  531. .ops = &msm_common_be_ops,
  532. SND_SOC_DAILINK_REG(usb_audio_tx),
  533. },
  534. };
  535. static struct snd_soc_dai_link msm_tdm_be_dai_links[] = {
  536. {
  537. .name = LPASS_BE_PRI_TDM_RX_0,
  538. .stream_name = LPASS_BE_PRI_TDM_RX_0,
  539. .playback_only = 1,
  540. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  541. SND_SOC_DPCM_TRIGGER_POST},
  542. .ops = &msm_common_be_ops,
  543. .ignore_suspend = 1,
  544. .ignore_pmdown_time = 1,
  545. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  546. },
  547. {
  548. .name = LPASS_BE_PRI_TDM_TX_0,
  549. .stream_name = LPASS_BE_PRI_TDM_TX_0,
  550. .capture_only = 1,
  551. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  552. SND_SOC_DPCM_TRIGGER_POST},
  553. .ops = &msm_common_be_ops,
  554. .ignore_suspend = 1,
  555. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  556. },
  557. {
  558. .name = LPASS_BE_SEC_TDM_RX_0,
  559. .stream_name = LPASS_BE_SEC_TDM_RX_0,
  560. .playback_only = 1,
  561. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  562. SND_SOC_DPCM_TRIGGER_POST},
  563. .ops = &msm_common_be_ops,
  564. .ignore_suspend = 1,
  565. .ignore_pmdown_time = 1,
  566. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  567. },
  568. {
  569. .name = LPASS_BE_SEC_TDM_TX_0,
  570. .stream_name = LPASS_BE_SEC_TDM_TX_0,
  571. .capture_only = 1,
  572. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  573. SND_SOC_DPCM_TRIGGER_POST},
  574. .ops = &msm_common_be_ops,
  575. .ignore_suspend = 1,
  576. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  577. },
  578. {
  579. .name = LPASS_BE_TERT_TDM_RX_0,
  580. .stream_name = LPASS_BE_TERT_TDM_RX_0,
  581. .playback_only = 1,
  582. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  583. SND_SOC_DPCM_TRIGGER_POST},
  584. .ops = &msm_common_be_ops,
  585. .ignore_suspend = 1,
  586. .ignore_pmdown_time = 1,
  587. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  588. },
  589. {
  590. .name = LPASS_BE_TERT_TDM_TX_0,
  591. .stream_name = LPASS_BE_TERT_TDM_TX_0,
  592. .capture_only = 1,
  593. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  594. SND_SOC_DPCM_TRIGGER_POST},
  595. .ops = &msm_common_be_ops,
  596. .ignore_suspend = 1,
  597. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  598. },
  599. {
  600. .name = LPASS_BE_QUAT_TDM_RX_0,
  601. .stream_name = LPASS_BE_QUAT_TDM_RX_0,
  602. .playback_only = 1,
  603. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  604. SND_SOC_DPCM_TRIGGER_POST},
  605. .ops = &msm_common_be_ops,
  606. .ignore_suspend = 1,
  607. .ignore_pmdown_time = 1,
  608. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  609. },
  610. {
  611. .name = LPASS_BE_QUAT_TDM_TX_0,
  612. .stream_name = LPASS_BE_QUAT_TDM_TX_0,
  613. .capture_only = 1,
  614. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  615. SND_SOC_DPCM_TRIGGER_POST},
  616. .ops = &msm_common_be_ops,
  617. .ignore_suspend = 1,
  618. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  619. },
  620. };
  621. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  622. {
  623. .name = LPASS_BE_SLIMBUS_7_RX,
  624. .stream_name = LPASS_BE_SLIMBUS_7_RX,
  625. .playback_only = 1,
  626. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  627. SND_SOC_DPCM_TRIGGER_POST},
  628. .init = &msm_wcn_init,
  629. .ops = &msm_common_be_ops,
  630. /* dai link has playback support */
  631. .ignore_pmdown_time = 1,
  632. .ignore_suspend = 1,
  633. SND_SOC_DAILINK_REG(slimbus_7_rx),
  634. },
  635. {
  636. .name = LPASS_BE_SLIMBUS_7_TX,
  637. .stream_name = LPASS_BE_SLIMBUS_7_TX,
  638. .capture_only = 1,
  639. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  640. SND_SOC_DPCM_TRIGGER_POST},
  641. .ops = &msm_common_be_ops,
  642. .ignore_suspend = 1,
  643. SND_SOC_DAILINK_REG(slimbus_7_tx),
  644. },
  645. {
  646. .name = LPASS_BE_SLIMBUS_8_TX,
  647. .stream_name = LPASS_BE_SLIMBUS_8_TX,
  648. .capture_only = 1,
  649. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  650. SND_SOC_DPCM_TRIGGER_POST},
  651. .ops = &msm_common_be_ops,
  652. .ignore_suspend = 1,
  653. SND_SOC_DAILINK_REG(slimbus_8_tx),
  654. },
  655. };
  656. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  657. {
  658. .name = LPASS_BE_PRI_MI2S_RX,
  659. .stream_name = LPASS_BE_PRI_MI2S_RX,
  660. .playback_only = 1,
  661. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  662. SND_SOC_DPCM_TRIGGER_POST},
  663. .ops = &msm_common_be_ops,
  664. .ignore_suspend = 1,
  665. .ignore_pmdown_time = 1,
  666. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  667. },
  668. {
  669. .name = LPASS_BE_PRI_MI2S_TX,
  670. .stream_name = LPASS_BE_PRI_MI2S_TX,
  671. .capture_only = 1,
  672. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  673. SND_SOC_DPCM_TRIGGER_POST},
  674. .ops = &msm_common_be_ops,
  675. .ignore_suspend = 1,
  676. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  677. },
  678. {
  679. .name = LPASS_BE_SEC_MI2S_RX,
  680. .stream_name = LPASS_BE_SEC_MI2S_RX,
  681. .playback_only = 1,
  682. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  683. SND_SOC_DPCM_TRIGGER_POST},
  684. .ops = &msm_common_be_ops,
  685. .ignore_suspend = 1,
  686. .ignore_pmdown_time = 1,
  687. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  688. },
  689. {
  690. .name = LPASS_BE_SEC_MI2S_TX,
  691. .stream_name = LPASS_BE_SEC_MI2S_TX,
  692. .capture_only = 1,
  693. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  694. SND_SOC_DPCM_TRIGGER_POST},
  695. .ops = &msm_common_be_ops,
  696. .ignore_suspend = 1,
  697. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  698. },
  699. {
  700. .name = LPASS_BE_TERT_MI2S_RX,
  701. .stream_name = LPASS_BE_TERT_MI2S_RX,
  702. .playback_only = 1,
  703. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  704. SND_SOC_DPCM_TRIGGER_POST},
  705. .ops = &msm_common_be_ops,
  706. .ignore_suspend = 1,
  707. .ignore_pmdown_time = 1,
  708. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  709. },
  710. {
  711. .name = LPASS_BE_TERT_MI2S_TX,
  712. .stream_name = LPASS_BE_TERT_MI2S_TX,
  713. .capture_only = 1,
  714. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  715. SND_SOC_DPCM_TRIGGER_POST},
  716. .ops = &msm_common_be_ops,
  717. .ignore_suspend = 1,
  718. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  719. },
  720. {
  721. .name = LPASS_BE_QUAT_MI2S_RX,
  722. .stream_name = LPASS_BE_QUAT_MI2S_RX,
  723. .playback_only = 1,
  724. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  725. SND_SOC_DPCM_TRIGGER_POST},
  726. .ops = &msm_common_be_ops,
  727. .ignore_suspend = 1,
  728. .ignore_pmdown_time = 1,
  729. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  730. },
  731. {
  732. .name = LPASS_BE_QUAT_MI2S_TX,
  733. .stream_name = LPASS_BE_QUAT_MI2S_TX,
  734. .capture_only = 1,
  735. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  736. SND_SOC_DPCM_TRIGGER_POST},
  737. .ops = &msm_common_be_ops,
  738. .ignore_suspend = 1,
  739. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  740. },
  741. };
  742. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  743. /* Primary AUX PCM Backend DAI Links */
  744. {
  745. .name = LPASS_BE_PRI_AUXPCM_RX,
  746. .stream_name = LPASS_BE_PRI_AUXPCM_RX,
  747. .playback_only = 1,
  748. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  749. SND_SOC_DPCM_TRIGGER_POST},
  750. .ops = &msm_common_be_ops,// TODO for AUX
  751. .ignore_pmdown_time = 1,
  752. .ignore_suspend = 1,
  753. SND_SOC_DAILINK_REG(auxpcm_rx),
  754. },
  755. {
  756. .name = LPASS_BE_PRI_AUXPCM_TX,
  757. .stream_name = LPASS_BE_PRI_AUXPCM_TX,
  758. .capture_only = 1,
  759. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  760. SND_SOC_DPCM_TRIGGER_POST},
  761. .ops = &msm_common_be_ops,
  762. .ignore_suspend = 1,
  763. SND_SOC_DAILINK_REG(auxpcm_tx),
  764. },
  765. /* Secondary AUX PCM Backend DAI Links */
  766. {
  767. .name = LPASS_BE_SEC_AUXPCM_RX,
  768. .stream_name = LPASS_BE_SEC_AUXPCM_RX,
  769. .playback_only = 1,
  770. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  771. SND_SOC_DPCM_TRIGGER_POST},
  772. .ops = &msm_common_be_ops,// TODO for AUX
  773. .ignore_pmdown_time = 1,
  774. .ignore_suspend = 1,
  775. SND_SOC_DAILINK_REG(sec_auxpcm_rx),
  776. },
  777. {
  778. .name = LPASS_BE_SEC_AUXPCM_TX,
  779. .stream_name = LPASS_BE_SEC_AUXPCM_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(sec_auxpcm_tx),
  786. },
  787. /* Tertiary AUX PCM Backend DAI Links */
  788. {
  789. .name = LPASS_BE_TERT_AUXPCM_RX,
  790. .stream_name = LPASS_BE_TERT_AUXPCM_RX,
  791. .playback_only = 1,
  792. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  793. SND_SOC_DPCM_TRIGGER_POST},
  794. .ops = &msm_common_be_ops,// TODO for AUX
  795. .ignore_suspend = 1,
  796. SND_SOC_DAILINK_REG(tert_auxpcm_rx),
  797. },
  798. {
  799. .name = LPASS_BE_TERT_AUXPCM_TX,
  800. .stream_name = LPASS_BE_TERT_AUXPCM_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(tert_auxpcm_tx),
  807. },
  808. /* Quaternary AUX PCM Backend DAI Links */
  809. {
  810. .name = LPASS_BE_QUAT_AUXPCM_RX,
  811. .stream_name = LPASS_BE_QUAT_AUXPCM_RX,
  812. .playback_only = 1,
  813. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  814. SND_SOC_DPCM_TRIGGER_POST},
  815. .ops = &msm_common_be_ops,// TODO for AUX
  816. .ignore_suspend = 1,
  817. SND_SOC_DAILINK_REG(quat_auxpcm_rx),
  818. },
  819. {
  820. .name = LPASS_BE_QUAT_AUXPCM_TX,
  821. .stream_name = LPASS_BE_QUAT_AUXPCM_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(quat_auxpcm_tx),
  828. },
  829. };
  830. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  831. /* RX CDC DMA Backend DAI Links */
  832. {
  833. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  834. .stream_name = LPASS_BE_RX_CDC_DMA_RX_0,
  835. .playback_only = 1,
  836. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  837. SND_SOC_DPCM_TRIGGER_POST},
  838. .ignore_pmdown_time = 1,
  839. .ignore_suspend = 1,
  840. .ops = &msm_common_be_ops,
  841. SND_SOC_DAILINK_REG(rx_dma_rx0),
  842. .init = &msm_rx_tx_codec_init,
  843. },
  844. {
  845. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  846. .stream_name = LPASS_BE_RX_CDC_DMA_RX_1,
  847. .playback_only = 1,
  848. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  849. SND_SOC_DPCM_TRIGGER_POST},
  850. .ignore_pmdown_time = 1,
  851. .ignore_suspend = 1,
  852. .ops = &msm_common_be_ops,
  853. SND_SOC_DAILINK_REG(rx_dma_rx1),
  854. .init = &msm_int_wsa_init,
  855. },
  856. {
  857. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  858. .stream_name = LPASS_BE_RX_CDC_DMA_RX_2,
  859. .playback_only = 1,
  860. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  861. SND_SOC_DPCM_TRIGGER_POST},
  862. .ignore_pmdown_time = 1,
  863. .ignore_suspend = 1,
  864. .ops = &msm_common_be_ops,
  865. SND_SOC_DAILINK_REG(rx_dma_rx2),
  866. },
  867. {
  868. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  869. .stream_name = LPASS_BE_RX_CDC_DMA_RX_3,
  870. .playback_only = 1,
  871. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  872. SND_SOC_DPCM_TRIGGER_POST},
  873. .ignore_pmdown_time = 1,
  874. .ignore_suspend = 1,
  875. .ops = &msm_common_be_ops,
  876. SND_SOC_DAILINK_REG(rx_dma_rx3),
  877. },
  878. /* TX CDC DMA Backend DAI Links */
  879. {
  880. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  881. .stream_name = LPASS_BE_TX_CDC_DMA_TX_3,
  882. .capture_only = 1,
  883. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  884. SND_SOC_DPCM_TRIGGER_POST},
  885. .ignore_suspend = 1,
  886. .ops = &msm_common_be_ops,
  887. SND_SOC_DAILINK_REG(tx_dma_tx3),
  888. },
  889. {
  890. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  891. .stream_name = LPASS_BE_TX_CDC_DMA_TX_4,
  892. .capture_only = 1,
  893. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  894. SND_SOC_DPCM_TRIGGER_POST},
  895. .ignore_suspend = 1,
  896. .ops = &msm_common_be_ops,
  897. SND_SOC_DAILINK_REG(tx_dma_tx4),
  898. },
  899. };
  900. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  901. {
  902. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  903. .stream_name = LPASS_BE_VA_CDC_DMA_TX_0,
  904. .capture_only = 1,
  905. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  906. SND_SOC_DPCM_TRIGGER_POST},
  907. .ignore_suspend = 1,
  908. .ops = &msm_common_be_ops,
  909. SND_SOC_DAILINK_REG(va_dma_tx0),
  910. },
  911. {
  912. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  913. .stream_name = LPASS_BE_VA_CDC_DMA_TX_1,
  914. .capture_only = 1,
  915. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  916. SND_SOC_DPCM_TRIGGER_POST},
  917. .ignore_suspend = 1,
  918. .ops = &msm_common_be_ops,
  919. SND_SOC_DAILINK_REG(va_dma_tx1),
  920. },
  921. {
  922. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  923. .stream_name = LPASS_BE_VA_CDC_DMA_TX_2,
  924. .capture_only = 1,
  925. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  926. SND_SOC_DPCM_TRIGGER_POST},
  927. .ignore_suspend = 1,
  928. .ops = &msm_common_be_ops,
  929. SND_SOC_DAILINK_REG(va_dma_tx2),
  930. },
  931. };
  932. static struct snd_soc_dai_link msm_holi_dai_links[
  933. ARRAY_SIZE(msm_common_be_dai_links) +
  934. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  935. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  936. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  937. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  938. ARRAY_SIZE(msm_wcn_btfm_be_dai_links) +
  939. ARRAY_SIZE(msm_tdm_be_dai_links)];
  940. static int msm_populate_dai_link_component_of_node(
  941. struct snd_soc_card *card)
  942. {
  943. int i, j, index, ret = 0;
  944. struct device *cdev = card->dev;
  945. struct snd_soc_dai_link *dai_link = card->dai_link;
  946. struct device_node *np = NULL;
  947. int codecs_enabled = 0;
  948. struct snd_soc_dai_link_component *codecs_comp = NULL;
  949. if (!cdev) {
  950. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  951. return -ENODEV;
  952. }
  953. for (i = 0; i < card->num_links; i++) {
  954. if (dai_link[i].init == NULL)
  955. dai_link[i].init = &msm_common_dai_link_init;
  956. /* populate codec_of_node for snd card dai links */
  957. if (dai_link[i].num_codecs > 0) {
  958. for (j = 0; j < dai_link[i].num_codecs; j++) {
  959. if (dai_link[i].codecs[j].of_node ||
  960. !dai_link[i].codecs[j].name)
  961. continue;
  962. index = of_property_match_string(cdev->of_node,
  963. "asoc-codec-names",
  964. dai_link[i].codecs[j].name);
  965. if (index < 0)
  966. continue;
  967. np = of_parse_phandle(cdev->of_node,
  968. "asoc-codec",
  969. index);
  970. if (!np) {
  971. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  972. __func__,
  973. dai_link[i].codecs[j].name);
  974. ret = -ENODEV;
  975. goto err;
  976. }
  977. dai_link[i].codecs[j].of_node = np;
  978. dai_link[i].codecs[j].name = NULL;
  979. }
  980. }
  981. }
  982. /* In multi-codec scenario, check if codecs are enabled for this platform */
  983. for (i = 0; i < card->num_links; i++) {
  984. codecs_enabled = 0;
  985. if (dai_link[i].num_codecs > 1) {
  986. for (j = 0; j < dai_link[i].num_codecs; j++) {
  987. if (!dai_link[i].codecs[j].of_node)
  988. continue;
  989. np = dai_link[i].codecs[j].of_node;
  990. if (!of_device_is_available(np)) {
  991. dev_err(cdev, "%s: codec is disabled: %s\n",
  992. __func__,
  993. np->full_name);
  994. dai_link[i].codecs[j].of_node = NULL;
  995. continue;
  996. }
  997. codecs_enabled++;
  998. }
  999. if (codecs_enabled > 0 &&
  1000. codecs_enabled < dai_link[i].num_codecs) {
  1001. codecs_comp = devm_kzalloc(cdev,
  1002. sizeof(struct snd_soc_dai_link_component)
  1003. * codecs_enabled, GFP_KERNEL);
  1004. if (!codecs_comp) {
  1005. dev_err(cdev, "%s: %s dailink codec component alloc failed\n",
  1006. __func__, dai_link[i].name);
  1007. ret = -ENOMEM;
  1008. goto err;
  1009. }
  1010. index = 0;
  1011. for (j = 0; j < dai_link[i].num_codecs; j++) {
  1012. if (dai_link[i].codecs[j].of_node) {
  1013. codecs_comp[index].of_node =
  1014. dai_link[i].codecs[j].of_node;
  1015. codecs_comp[index].dai_name =
  1016. dai_link[i].codecs[j].dai_name;
  1017. codecs_comp[index].name = NULL;
  1018. index++;
  1019. }
  1020. }
  1021. dai_link[i].codecs = codecs_comp;
  1022. dai_link[i].num_codecs = codecs_enabled;
  1023. }
  1024. }
  1025. }
  1026. err:
  1027. return ret;
  1028. }
  1029. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  1030. {
  1031. return 0;
  1032. }
  1033. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  1034. struct snd_pcm_hw_params *params)
  1035. {
  1036. return 0;
  1037. }
  1038. static struct snd_soc_ops msm_stub_be_ops = {
  1039. .hw_params = msm_snd_stub_hw_params,
  1040. };
  1041. struct snd_soc_card snd_soc_card_stub_msm = {
  1042. .name = "holi-stub-snd-card",
  1043. };
  1044. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  1045. /* Backend DAI Links */
  1046. {
  1047. .name = LPASS_BE_PRI_AUXPCM_RX,
  1048. .stream_name = LPASS_BE_PRI_AUXPCM_RX,
  1049. .playback_only = 1,
  1050. .init = &msm_audrx_stub_init,
  1051. .ignore_pmdown_time = 1,
  1052. .ignore_suspend = 1,
  1053. .ops = &msm_stub_be_ops,
  1054. SND_SOC_DAILINK_REG(auxpcm_rx),
  1055. },
  1056. {
  1057. .name = LPASS_BE_PRI_AUXPCM_TX,
  1058. .stream_name = LPASS_BE_PRI_AUXPCM_TX,
  1059. .capture_only = 1,
  1060. .ignore_suspend = 1,
  1061. .ops = &msm_stub_be_ops,
  1062. SND_SOC_DAILINK_REG(auxpcm_tx),
  1063. },
  1064. };
  1065. static struct snd_soc_dai_link msm_stub_dai_links[
  1066. ARRAY_SIZE(msm_stub_be_dai_links)];
  1067. static const struct of_device_id holi_asoc_machine_of_match[] = {
  1068. { .compatible = "qcom,holi-asoc-snd",
  1069. .data = "codec"},
  1070. { .compatible = "qcom,holi-asoc-snd-stub",
  1071. .data = "stub_codec"},
  1072. {},
  1073. };
  1074. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  1075. {
  1076. struct snd_soc_card *card = NULL;
  1077. struct snd_soc_dai_link *dailink = NULL;
  1078. int total_links = 0;
  1079. int len_1 = 0;
  1080. int rc = 0;
  1081. u32 mi2s_audio_intf = 0;
  1082. u32 auxpcm_audio_intf = 0;
  1083. u32 rxtx_bolero_codec = 0;
  1084. u32 va_bolero_codec = 0;
  1085. u32 val = 0;
  1086. u32 wcn_btfm_intf = 0;
  1087. const struct of_device_id *match;
  1088. match = of_match_node(holi_asoc_machine_of_match, dev->of_node);
  1089. if (!match) {
  1090. dev_err(dev, "%s: No DT match found for sound card\n",
  1091. __func__);
  1092. return NULL;
  1093. }
  1094. if (!strcmp(match->data, "codec")) {
  1095. card = &snd_soc_card_holi_msm;
  1096. memcpy(msm_holi_dai_links + total_links,
  1097. msm_common_be_dai_links,
  1098. sizeof(msm_common_be_dai_links));
  1099. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  1100. rc = of_property_read_u32(dev->of_node,
  1101. "qcom,rxtx-bolero-codec",
  1102. &rxtx_bolero_codec);
  1103. if (rc) {
  1104. dev_dbg(dev, "%s: No DT match RXTX Macro codec\n",
  1105. __func__);
  1106. } else {
  1107. if (rxtx_bolero_codec) {
  1108. memcpy(msm_holi_dai_links + total_links,
  1109. msm_rx_tx_cdc_dma_be_dai_links,
  1110. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  1111. total_links +=
  1112. ARRAY_SIZE(
  1113. msm_rx_tx_cdc_dma_be_dai_links);
  1114. }
  1115. }
  1116. rc = of_property_read_u32(dev->of_node, "qcom,va-bolero-codec",
  1117. &va_bolero_codec);
  1118. if (rc) {
  1119. dev_dbg(dev, "%s: No DT match VA Macro codec\n",
  1120. __func__);
  1121. } else {
  1122. if (va_bolero_codec) {
  1123. memcpy(msm_holi_dai_links + total_links,
  1124. msm_va_cdc_dma_be_dai_links,
  1125. sizeof(msm_va_cdc_dma_be_dai_links));
  1126. total_links +=
  1127. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  1128. }
  1129. }
  1130. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  1131. &mi2s_audio_intf);
  1132. if (rc) {
  1133. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  1134. __func__);
  1135. } else {
  1136. if (mi2s_audio_intf) {
  1137. memcpy(msm_holi_dai_links + total_links,
  1138. msm_mi2s_be_dai_links,
  1139. sizeof(msm_mi2s_be_dai_links));
  1140. total_links +=
  1141. ARRAY_SIZE(msm_mi2s_be_dai_links);
  1142. }
  1143. }
  1144. rc = of_property_read_u32(dev->of_node,
  1145. "qcom,auxpcm-audio-intf",
  1146. &auxpcm_audio_intf);
  1147. if (rc) {
  1148. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  1149. __func__);
  1150. } else {
  1151. if (auxpcm_audio_intf) {
  1152. memcpy(msm_holi_dai_links + total_links,
  1153. msm_auxpcm_be_dai_links,
  1154. sizeof(msm_auxpcm_be_dai_links));
  1155. total_links +=
  1156. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  1157. }
  1158. }
  1159. rc = of_property_read_u32(dev->of_node, "qcom,tdm-audio-intf",
  1160. &val);
  1161. if (!rc && val) {
  1162. memcpy(msm_holi_dai_links + total_links,
  1163. msm_tdm_be_dai_links,
  1164. sizeof(msm_tdm_be_dai_links));
  1165. total_links +=
  1166. ARRAY_SIZE(msm_tdm_be_dai_links);
  1167. }
  1168. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  1169. &wcn_btfm_intf);
  1170. if (rc) {
  1171. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  1172. __func__);
  1173. } else {
  1174. if (wcn_btfm_intf) {
  1175. memcpy(msm_holi_dai_links + total_links,
  1176. msm_wcn_btfm_be_dai_links,
  1177. sizeof(msm_wcn_btfm_be_dai_links));
  1178. total_links +=
  1179. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  1180. }
  1181. }
  1182. dailink = msm_holi_dai_links;
  1183. }
  1184. else if (!strcmp(match->data, "stub_codec")) {
  1185. card = &snd_soc_card_stub_msm;
  1186. len_1 = ARRAY_SIZE(msm_stub_be_dai_links);
  1187. memcpy(msm_stub_dai_links,
  1188. msm_stub_be_dai_links,
  1189. sizeof(msm_stub_be_dai_links));
  1190. dailink = msm_stub_dai_links;
  1191. total_links = len_1;
  1192. }
  1193. if (card) {
  1194. card->dai_link = dailink;
  1195. card->num_links = total_links;
  1196. }
  1197. return card;
  1198. }
  1199. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
  1200. {
  1201. struct snd_soc_component *bolero_component = NULL;
  1202. struct snd_soc_component *component = NULL;
  1203. struct snd_soc_dapm_context *dapm = NULL;
  1204. bool is_wcd937x = false;
  1205. int ret = 0;
  1206. void *mbhc_calibration;
  1207. struct snd_info_entry *entry;
  1208. struct snd_card *card = NULL;
  1209. struct msm_asoc_mach_data *pdata =
  1210. snd_soc_card_get_drvdata(rtd->card);
  1211. pr_err("%s:: enter \n", __func__);
  1212. bolero_component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  1213. if (!bolero_component) {
  1214. pr_err("%s: could not find component for bolero_codec\n",
  1215. __func__);
  1216. return -EINVAL;
  1217. }
  1218. pr_err("%s:: bolero comp lookup done\n", __func__);
  1219. dapm = snd_soc_component_get_dapm(bolero_component);
  1220. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  1221. ARRAY_SIZE(msm_int_dapm_widgets));
  1222. pr_err("%s:: dapm new controls msm_int_dapm_widgets \n", __func__);
  1223. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  1224. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  1225. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  1226. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  1227. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  1228. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  1229. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  1230. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  1231. snd_soc_dapm_sync(dapm);
  1232. card = rtd->card->snd_card;
  1233. if (!pdata->codec_root) {
  1234. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1235. card->proc_root);
  1236. if (!entry) {
  1237. pr_debug("%s: Cannot create codecs module entry\n",
  1238. __func__);
  1239. ret = 0;
  1240. goto err;
  1241. }
  1242. pdata->codec_root = entry;
  1243. }
  1244. bolero_info_create_codec_entry(pdata->codec_root, bolero_component);
  1245. bolero_register_wake_irq(bolero_component, false);
  1246. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  1247. if (!component) {
  1248. component = snd_soc_rtdcom_lookup(rtd, WCD937X_DRV_NAME);
  1249. if (!component) {
  1250. pr_err("%s component is NULL\n", __func__);
  1251. return -EINVAL;
  1252. }
  1253. is_wcd937x = true;
  1254. }
  1255. dapm = snd_soc_component_get_dapm(component);
  1256. card = component->card->snd_card;
  1257. pdata = snd_soc_card_get_drvdata(component->card);
  1258. if (!pdata)
  1259. return -EINVAL;
  1260. if (!pdata->codec_root) {
  1261. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1262. card->proc_root);
  1263. if (!entry) {
  1264. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  1265. __func__);
  1266. ret = 0;
  1267. goto mbhc_cfg_cal;
  1268. }
  1269. pdata->codec_root = entry;
  1270. }
  1271. if (!strncmp(component->driver->name, WCD937X_DRV_NAME, 13)) {
  1272. wcd937x_info_create_codec_entry(pdata->codec_root, component);
  1273. bolero_set_port_map(bolero_component,
  1274. ARRAY_SIZE(sm_port_map),
  1275. sm_port_map);
  1276. } else {
  1277. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  1278. bolero_set_port_map(bolero_component,
  1279. ARRAY_SIZE(sm_port_map),
  1280. sm_port_map);
  1281. }
  1282. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  1283. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  1284. snd_soc_dapm_ignore_suspend(dapm, "LO");
  1285. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  1286. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  1287. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  1288. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  1289. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  1290. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  1291. snd_soc_dapm_sync(dapm);
  1292. codec_reg_done = true;
  1293. msm_common_dai_link_init(rtd);
  1294. mbhc_cfg_cal:
  1295. mbhc_calibration = def_wcd_mbhc_cal();
  1296. if (!mbhc_calibration)
  1297. return -ENOMEM;
  1298. wcd_mbhc_cfg.calibration = mbhc_calibration;
  1299. if (!is_wcd937x)
  1300. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  1301. else
  1302. ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  1303. if (ret) {
  1304. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  1305. __func__, ret);
  1306. goto err_hs_detect;
  1307. }
  1308. return 0;
  1309. err_hs_detect:
  1310. kfree(mbhc_calibration);
  1311. err:
  1312. pr_err("%s:: return %d \n", __func__, ret);
  1313. return ret;
  1314. }
  1315. static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd)
  1316. {
  1317. struct msm_asoc_mach_data *pdata =
  1318. snd_soc_card_get_drvdata(rtd->card);
  1319. int ret = 0;
  1320. if (pdata->wsa_max_devs == 0)
  1321. pr_info("%s: WSA is not enabled\n", __func__);
  1322. msm_common_dai_link_init(rtd);
  1323. return ret;
  1324. }
  1325. static int holi_ssr_enable(struct device *dev, void *data)
  1326. {
  1327. struct platform_device *pdev = to_platform_device(dev);
  1328. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1329. int ret = 0;
  1330. if (!card) {
  1331. dev_err(dev, "%s: card is NULL\n", __func__);
  1332. ret = -EINVAL;
  1333. goto err;
  1334. }
  1335. if (!strcmp(card->name, "holi-stub-snd-card")) {
  1336. /* TODO */
  1337. dev_dbg(dev, "%s: TODO \n", __func__);
  1338. }
  1339. snd_card_notify_user(SND_CARD_STATUS_ONLINE);
  1340. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  1341. err:
  1342. return ret;
  1343. }
  1344. static void holi_ssr_disable(struct device *dev, void *data)
  1345. {
  1346. struct platform_device *pdev = to_platform_device(dev);
  1347. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1348. if (!card) {
  1349. dev_err(dev, "%s: card is NULL\n", __func__);
  1350. return;
  1351. }
  1352. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  1353. snd_card_notify_user(SND_CARD_STATUS_OFFLINE);
  1354. if (!strcmp(card->name, "holi-stub-snd-card")) {
  1355. /* TODO */
  1356. dev_dbg(dev, "%s: TODO \n", __func__);
  1357. }
  1358. }
  1359. static const struct snd_event_ops holi_ssr_ops = {
  1360. .enable = holi_ssr_enable,
  1361. .disable = holi_ssr_disable,
  1362. };
  1363. static int msm_audio_ssr_compare(struct device *dev, void *data)
  1364. {
  1365. struct device_node *node = data;
  1366. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  1367. __func__, dev->of_node, node);
  1368. return (dev->of_node && dev->of_node == node);
  1369. }
  1370. static int msm_audio_ssr_register(struct device *dev)
  1371. {
  1372. struct device_node *np = dev->of_node;
  1373. struct snd_event_clients *ssr_clients = NULL;
  1374. struct device_node *node = NULL;
  1375. int ret = 0;
  1376. int i = 0;
  1377. for (i = 0; ; i++) {
  1378. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  1379. if (!node)
  1380. break;
  1381. snd_event_mstr_add_client(&ssr_clients,
  1382. msm_audio_ssr_compare, node);
  1383. }
  1384. ret = snd_event_master_register(dev, &holi_ssr_ops,
  1385. ssr_clients, NULL);
  1386. if (!ret)
  1387. snd_event_notify(dev, SND_EVENT_UP);
  1388. return ret;
  1389. }
  1390. static int msm_asoc_parse_soundcard_name(struct platform_device *pdev,
  1391. struct snd_soc_card *card)
  1392. {
  1393. struct nvmem_cell *cell;
  1394. size_t len;
  1395. u32 *buf;
  1396. u32 adsp_var_idx = 0;
  1397. int ret = 0;
  1398. /* get adsp variant idx */
  1399. cell = nvmem_cell_get(&pdev->dev, "adsp_variant");
  1400. if (IS_ERR_OR_NULL(cell)) {
  1401. dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell \n", __func__);
  1402. goto parse;
  1403. }
  1404. buf = nvmem_cell_read(cell, &len);
  1405. nvmem_cell_put(cell);
  1406. if (IS_ERR_OR_NULL(buf)) {
  1407. dev_dbg(&pdev->dev, "%s: FAILED to read nvmem cell \n", __func__);
  1408. goto parse;
  1409. }
  1410. if (len <= 0 || len > sizeof(u32)) {
  1411. dev_dbg(&pdev->dev, "%s: nvmem cell length out of range: %d\n",
  1412. __func__, len);
  1413. kfree(buf);
  1414. goto parse;
  1415. }
  1416. memcpy(&adsp_var_idx, buf, len);
  1417. kfree(buf);
  1418. parse:
  1419. if(adsp_var_idx == 1)
  1420. ret = snd_soc_of_parse_card_name(card, "qcom,sku-model");
  1421. else
  1422. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  1423. if (ret)
  1424. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  1425. __func__, ret);
  1426. return ret;
  1427. }
  1428. static int msm_asoc_machine_probe(struct platform_device *pdev)
  1429. {
  1430. struct snd_soc_card *card = NULL;
  1431. struct msm_asoc_mach_data *pdata = NULL;
  1432. const char *mbhc_audio_jack_type = NULL;
  1433. int ret = 0;
  1434. uint index = 0;
  1435. struct clk *lpass_audio_hw_vote = NULL;
  1436. if (!pdev->dev.of_node) {
  1437. dev_err(&pdev->dev,
  1438. "%s: No platform supplied from device tree\n", __func__);
  1439. return -EINVAL;
  1440. }
  1441. pdata = devm_kzalloc(&pdev->dev,
  1442. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  1443. if (!pdata)
  1444. return -ENOMEM;
  1445. of_property_read_u32(pdev->dev.of_node,
  1446. "qcom,wcd-disabled",
  1447. &pdata->wcd_disabled);
  1448. card = populate_snd_card_dailinks(&pdev->dev);
  1449. if (!card) {
  1450. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  1451. ret = -EINVAL;
  1452. goto err;
  1453. }
  1454. card->dev = &pdev->dev;
  1455. platform_set_drvdata(pdev, card);
  1456. snd_soc_card_set_drvdata(card, pdata);
  1457. ret = msm_asoc_parse_soundcard_name(pdev, card);
  1458. if (ret) {
  1459. dev_err(&pdev->dev, "%s: parse soundcard name failed, err:%d\n",
  1460. __func__, ret);
  1461. goto err;
  1462. }
  1463. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  1464. if (ret) {
  1465. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  1466. __func__, ret);
  1467. goto err;
  1468. }
  1469. ret = msm_populate_dai_link_component_of_node(card);
  1470. if (ret) {
  1471. ret = -EPROBE_DEFER;
  1472. goto err;
  1473. }
  1474. /* Get maximum WSA device count for this platform */
  1475. ret = of_property_read_u32(pdev->dev.of_node,
  1476. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  1477. if (ret) {
  1478. dev_err(&pdev->dev,
  1479. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  1480. __func__, pdev->dev.of_node->full_name, ret);
  1481. pdata->wsa_max_devs = 0;
  1482. }
  1483. /* Make sure prefix string passed for each WSA device */
  1484. ret = of_property_count_strings(pdev->dev.of_node,
  1485. "qcom,wsa-aux-dev-prefix");
  1486. if (!ret) {
  1487. dev_err(&pdev->dev,
  1488. "%s: property %s not defined in DT\n",
  1489. __func__, "qcom,wsa-aux-dev-prefix");
  1490. }
  1491. ret = devm_snd_soc_register_card(&pdev->dev, card);
  1492. if (ret == -EPROBE_DEFER) {
  1493. if (codec_reg_done)
  1494. ret = -EINVAL;
  1495. goto err;
  1496. } else if (ret) {
  1497. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  1498. __func__, ret);
  1499. goto err;
  1500. }
  1501. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  1502. __func__, card->name);
  1503. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1504. "qcom,hph-en1-gpio", 0);
  1505. if (!pdata->hph_en1_gpio_p) {
  1506. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  1507. __func__, "qcom,hph-en1-gpio",
  1508. pdev->dev.of_node->full_name);
  1509. }
  1510. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1511. "qcom,hph-en0-gpio", 0);
  1512. if (!pdata->hph_en0_gpio_p) {
  1513. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  1514. __func__, "qcom,hph-en0-gpio",
  1515. pdev->dev.of_node->full_name);
  1516. }
  1517. ret = of_property_read_string(pdev->dev.of_node,
  1518. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  1519. if (ret) {
  1520. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  1521. __func__, "qcom,mbhc-audio-jack-type",
  1522. pdev->dev.of_node->full_name);
  1523. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  1524. } else {
  1525. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  1526. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  1527. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  1528. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  1529. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  1530. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  1531. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  1532. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  1533. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  1534. } else {
  1535. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  1536. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  1537. }
  1538. }
  1539. /*
  1540. * Parse US-Euro gpio info from DT. Report no error if us-euro
  1541. * entry is not found in DT file as some targets do not support
  1542. * US-Euro detection
  1543. */
  1544. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1545. "qcom,us-euro-gpios", 0);
  1546. if (!pdata->us_euro_gpio_p) {
  1547. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  1548. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  1549. } else {
  1550. dev_dbg(&pdev->dev, "%s detected\n",
  1551. "qcom,us-euro-gpios");
  1552. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  1553. }
  1554. if (wcd_mbhc_cfg.enable_usbc_analog)
  1555. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  1556. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  1557. "fsa4480-i2c-handle", 0);
  1558. if (!pdata->fsa_handle)
  1559. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  1560. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  1561. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1562. "qcom,cdc-dmic01-gpios",
  1563. 0);
  1564. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1565. "qcom,cdc-dmic23-gpios",
  1566. 0);
  1567. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1568. "qcom,cdc-dmic45-gpios",
  1569. 0);
  1570. if (pdata->dmic01_gpio_p)
  1571. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  1572. if (pdata->dmic23_gpio_p)
  1573. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  1574. if (pdata->dmic45_gpio_p)
  1575. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  1576. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  1577. "qcom,pri-mi2s-gpios", 0);
  1578. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  1579. "qcom,sec-mi2s-gpios", 0);
  1580. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  1581. "qcom,tert-mi2s-gpios", 0);
  1582. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  1583. "qcom,quat-mi2s-gpios", 0);
  1584. for (index = PRIM_MI2S; index < MI2S_MAX; index++)
  1585. atomic_set(&(pdata->mi2s_gpio_ref_count[index]), 0);
  1586. /* Register LPASS audio hw vote */
  1587. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  1588. if (IS_ERR(lpass_audio_hw_vote)) {
  1589. ret = PTR_ERR(lpass_audio_hw_vote);
  1590. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  1591. __func__, "lpass_audio_hw_vote", ret);
  1592. lpass_audio_hw_vote = NULL;
  1593. ret = 0;
  1594. }
  1595. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  1596. pdata->core_audio_vote_count = 0;
  1597. msm_common_snd_init(pdev, card);
  1598. ret = msm_audio_ssr_register(&pdev->dev);
  1599. if (ret)
  1600. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  1601. __func__, ret);
  1602. is_initial_boot = true;
  1603. /* change card status to ONLINE */
  1604. dev_dbg(&pdev->dev, "%s: setting snd_card to ONLINE\n", __func__);
  1605. snd_card_set_card_status(SND_CARD_STATUS_ONLINE);
  1606. return 0;
  1607. err:
  1608. devm_kfree(&pdev->dev, pdata);
  1609. return ret;
  1610. }
  1611. static int msm_asoc_machine_remove(struct platform_device *pdev)
  1612. {
  1613. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1614. struct msm_asoc_mach_data *pdata = NULL;
  1615. struct msm_common_pdata *common_pdata = NULL;
  1616. if (card)
  1617. pdata = snd_soc_card_get_drvdata(card);
  1618. if (pdata)
  1619. common_pdata = pdata->common_pdata;
  1620. msm_common_snd_deinit(common_pdata);
  1621. snd_event_master_deregister(&pdev->dev);
  1622. snd_soc_unregister_card(card);
  1623. return 0;
  1624. }
  1625. static struct platform_driver holi_asoc_machine_driver = {
  1626. .driver = {
  1627. .name = DRV_NAME,
  1628. .owner = THIS_MODULE,
  1629. .pm = &snd_soc_pm_ops,
  1630. .of_match_table = holi_asoc_machine_of_match,
  1631. .suppress_bind_attrs = true,
  1632. },
  1633. .probe = msm_asoc_machine_probe,
  1634. .remove = msm_asoc_machine_remove,
  1635. };
  1636. static int __init msm_asoc_machine_init(void)
  1637. {
  1638. snd_card_sysfs_init();
  1639. return platform_driver_register(&holi_asoc_machine_driver);
  1640. }
  1641. module_init(msm_asoc_machine_init);
  1642. static void __exit msm_asoc_machine_exit(void)
  1643. {
  1644. platform_driver_unregister(&holi_asoc_machine_driver);
  1645. }
  1646. module_exit(msm_asoc_machine_exit);
  1647. MODULE_SOFTDEP("pre: bt_fm_slim");
  1648. MODULE_DESCRIPTION("ALSA SoC msm");
  1649. MODULE_LICENSE("GPL v2");
  1650. MODULE_ALIAS("platform:" DRV_NAME);
  1651. MODULE_DEVICE_TABLE(of, holi_asoc_machine_of_match);