holi.c 47 KB

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