sdm660-internal.c 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157
  1. /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/of_gpio.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/module.h>
  15. #include <sound/pcm_params.h>
  16. #include "msm-pcm-routing-v2.h"
  17. #include "sdm660-common.h"
  18. #include "codecs/msm-cdc-pinctrl.h"
  19. #include "codecs/sdm660_cdc/msm-digital-cdc.h"
  20. #include "codecs/sdm660_cdc/msm-analog-cdc.h"
  21. #include "codecs/msm_sdw/msm_sdw.h"
  22. #define __CHIPSET__ "SDM660 "
  23. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  24. #define DEFAULT_MCLK_RATE 9600000
  25. #define NATIVE_MCLK_RATE 11289600
  26. #define WCD_MBHC_DEF_RLOADS 5
  27. #define WCN_CDC_SLIM_RX_CH_MAX 2
  28. #define WCN_CDC_SLIM_TX_CH_MAX 3
  29. #define WSA8810_NAME_1 "wsa881x.20170211"
  30. #define WSA8810_NAME_2 "wsa881x.20170212"
  31. enum {
  32. INT0_MI2S = 0,
  33. INT1_MI2S,
  34. INT2_MI2S,
  35. INT3_MI2S,
  36. INT4_MI2S,
  37. INT5_MI2S,
  38. INT6_MI2S,
  39. INT_MI2S_MAX,
  40. };
  41. enum {
  42. BT_SLIM7,
  43. FM_SLIM8,
  44. SLIM_MAX,
  45. };
  46. /*TDM default offset currently only supporting TDM_RX_0 and TDM_TX_0 */
  47. static unsigned int tdm_slot_offset[TDM_PORT_MAX][TDM_SLOT_OFFSET_MAX] = {
  48. {0, 4, 8, 12, 16, 20, 24, 28},/* TX_0 | RX_0 */
  49. {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_1 | RX_1 */
  50. {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_2 | RX_2 */
  51. {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_3 | RX_3 */
  52. {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_4 | RX_4 */
  53. {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_5 | RX_5 */
  54. {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_6 | RX_6 */
  55. {AFE_SLOT_MAPPING_OFFSET_INVALID},/* TX_7 | RX_7 */
  56. };
  57. static struct afe_clk_set int_mi2s_clk[INT_MI2S_MAX] = {
  58. {
  59. AFE_API_VERSION_I2S_CONFIG,
  60. Q6AFE_LPASS_CLK_ID_INT0_MI2S_IBIT,
  61. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  62. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  63. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  64. 0,
  65. },
  66. {
  67. AFE_API_VERSION_I2S_CONFIG,
  68. Q6AFE_LPASS_CLK_ID_INT1_MI2S_IBIT,
  69. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  70. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  71. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  72. 0,
  73. },
  74. {
  75. AFE_API_VERSION_I2S_CONFIG,
  76. Q6AFE_LPASS_CLK_ID_INT2_MI2S_IBIT,
  77. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  78. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  79. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  80. 0,
  81. },
  82. {
  83. AFE_API_VERSION_I2S_CONFIG,
  84. Q6AFE_LPASS_CLK_ID_INT3_MI2S_IBIT,
  85. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  86. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  87. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  88. 0,
  89. },
  90. {
  91. AFE_API_VERSION_I2S_CONFIG,
  92. Q6AFE_LPASS_CLK_ID_INT4_MI2S_IBIT,
  93. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  94. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  95. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  96. 0,
  97. },
  98. {
  99. AFE_API_VERSION_I2S_CONFIG,
  100. Q6AFE_LPASS_CLK_ID_INT5_MI2S_IBIT,
  101. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  102. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  103. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  104. 0,
  105. },
  106. {
  107. AFE_API_VERSION_I2S_CONFIG,
  108. Q6AFE_LPASS_CLK_ID_INT6_MI2S_IBIT,
  109. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  110. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  111. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  112. 0,
  113. },
  114. };
  115. struct dev_config {
  116. u32 sample_rate;
  117. u32 bit_format;
  118. u32 channels;
  119. };
  120. /* Default configuration of MI2S channels */
  121. static struct dev_config int_mi2s_cfg[] = {
  122. [INT0_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  123. [INT1_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  124. [INT2_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  125. [INT3_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  126. [INT4_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  127. [INT5_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  128. [INT6_MI2S] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  129. };
  130. static struct dev_config bt_fm_cfg[] = {
  131. [BT_SLIM7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  132. [FM_SLIM8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  133. };
  134. static char const *int_mi2s_rate_text[] = {"KHZ_8", "KHZ_16",
  135. "KHZ_32", "KHZ_44P1", "KHZ_48",
  136. "KHZ_96", "KHZ_192"};
  137. static const char *const int_mi2s_ch_text[] = {"One", "Two"};
  138. static const char *const int_mi2s_tx_ch_text[] = {"One", "Two",
  139. "Three", "Four"};
  140. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"};
  141. static const char *const loopback_mclk_text[] = {"DISABLE", "ENABLE"};
  142. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_48"};
  143. static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_sample_rate, int_mi2s_rate_text);
  144. static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_chs, int_mi2s_ch_text);
  145. static SOC_ENUM_SINGLE_EXT_DECL(int0_mi2s_rx_format, bit_format_text);
  146. static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_sample_rate, int_mi2s_rate_text);
  147. static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_chs, int_mi2s_tx_ch_text);
  148. static SOC_ENUM_SINGLE_EXT_DECL(int2_mi2s_tx_format, bit_format_text);
  149. static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_sample_rate, int_mi2s_rate_text);
  150. static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_chs, int_mi2s_tx_ch_text);
  151. static SOC_ENUM_SINGLE_EXT_DECL(int3_mi2s_tx_format, bit_format_text);
  152. static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_sample_rate, int_mi2s_rate_text);
  153. static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_chs, int_mi2s_ch_text);
  154. static SOC_ENUM_SINGLE_EXT_DECL(int4_mi2s_rx_format, bit_format_text);
  155. static SOC_ENUM_SINGLE_EXT_DECL(int5_mi2s_tx_chs, int_mi2s_ch_text);
  156. static SOC_ENUM_SINGLE_EXT_DECL(loopback_mclk_en, loopback_mclk_text);
  157. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  158. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  159. struct snd_kcontrol *kcontrol, int event);
  160. static int msm_int_enable_dig_cdc_clk(struct snd_soc_codec *codec, int enable,
  161. bool dapm);
  162. static int msm_int_mclk0_event(struct snd_soc_dapm_widget *w,
  163. struct snd_kcontrol *kcontrol, int event);
  164. static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream);
  165. static void msm_int_mi2s_snd_shutdown(struct snd_pcm_substream *substream);
  166. static struct wcd_mbhc_config *mbhc_cfg_ptr;
  167. static struct snd_info_entry *codec_root;
  168. static int int_mi2s_get_bit_format_val(int bit_format)
  169. {
  170. int val = 0;
  171. switch (bit_format) {
  172. case SNDRV_PCM_FORMAT_S24_3LE:
  173. val = 2;
  174. break;
  175. case SNDRV_PCM_FORMAT_S24_LE:
  176. val = 1;
  177. break;
  178. case SNDRV_PCM_FORMAT_S16_LE:
  179. default:
  180. val = 0;
  181. break;
  182. }
  183. return val;
  184. }
  185. static int int_mi2s_get_bit_format(int val)
  186. {
  187. int bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  188. switch (val) {
  189. case 0:
  190. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  191. break;
  192. case 1:
  193. bit_fmt = SNDRV_PCM_FORMAT_S24_LE;
  194. break;
  195. case 2:
  196. bit_fmt = SNDRV_PCM_FORMAT_S24_3LE;
  197. break;
  198. default:
  199. bit_fmt = SNDRV_PCM_FORMAT_S16_LE;
  200. break;
  201. }
  202. return bit_fmt;
  203. }
  204. static int int_mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  205. {
  206. int port_id = 0;
  207. if (strnstr(kcontrol->id.name, "INT0_MI2S", sizeof("INT0_MI2S")))
  208. port_id = INT0_MI2S;
  209. else if (strnstr(kcontrol->id.name, "INT2_MI2S", sizeof("INT2_MI2S")))
  210. port_id = INT2_MI2S;
  211. else if (strnstr(kcontrol->id.name, "INT3_MI2S", sizeof("INT3_MI2S")))
  212. port_id = INT3_MI2S;
  213. else if (strnstr(kcontrol->id.name, "INT4_MI2S", sizeof("INT4_MI2S")))
  214. port_id = INT4_MI2S;
  215. else {
  216. pr_err("%s: unsupported channel: %s",
  217. __func__, kcontrol->id.name);
  218. return -EINVAL;
  219. }
  220. return port_id;
  221. }
  222. static int int_mi2s_bit_format_get(struct snd_kcontrol *kcontrol,
  223. struct snd_ctl_elem_value *ucontrol)
  224. {
  225. int ch_num = int_mi2s_get_port_idx(kcontrol);
  226. if (ch_num < 0)
  227. return ch_num;
  228. ucontrol->value.enumerated.item[0] =
  229. int_mi2s_get_bit_format_val(int_mi2s_cfg[ch_num].bit_format);
  230. pr_debug("%s: int_mi2s[%d]_bit_format = %d, ucontrol value = %d\n",
  231. __func__, ch_num, int_mi2s_cfg[ch_num].bit_format,
  232. ucontrol->value.enumerated.item[0]);
  233. return 0;
  234. }
  235. static int int_mi2s_bit_format_put(struct snd_kcontrol *kcontrol,
  236. struct snd_ctl_elem_value *ucontrol)
  237. {
  238. int ch_num = int_mi2s_get_port_idx(kcontrol);
  239. if (ch_num < 0)
  240. return ch_num;
  241. int_mi2s_cfg[ch_num].bit_format =
  242. int_mi2s_get_bit_format(ucontrol->value.enumerated.item[0]);
  243. pr_debug("%s: int_mi2s[%d]_rx_bit_format = %d, ucontrol value = %d\n",
  244. __func__, ch_num, int_mi2s_cfg[ch_num].bit_format,
  245. ucontrol->value.enumerated.item[0]);
  246. return 0;
  247. }
  248. static inline int param_is_mask(int p)
  249. {
  250. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  251. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  252. }
  253. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  254. int n)
  255. {
  256. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  257. }
  258. static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit)
  259. {
  260. if (bit >= SNDRV_MASK_MAX)
  261. return;
  262. if (param_is_mask(n)) {
  263. struct snd_mask *m = param_to_mask(p, n);
  264. m->bits[0] = 0;
  265. m->bits[1] = 0;
  266. m->bits[bit >> 5] |= (1 << (bit & 31));
  267. }
  268. }
  269. static int int_mi2s_get_sample_rate_val(int sample_rate)
  270. {
  271. int sample_rate_val;
  272. switch (sample_rate) {
  273. case SAMPLING_RATE_8KHZ:
  274. sample_rate_val = 0;
  275. break;
  276. case SAMPLING_RATE_16KHZ:
  277. sample_rate_val = 1;
  278. break;
  279. case SAMPLING_RATE_32KHZ:
  280. sample_rate_val = 2;
  281. break;
  282. case SAMPLING_RATE_44P1KHZ:
  283. sample_rate_val = 3;
  284. break;
  285. case SAMPLING_RATE_48KHZ:
  286. sample_rate_val = 4;
  287. break;
  288. case SAMPLING_RATE_96KHZ:
  289. sample_rate_val = 5;
  290. break;
  291. case SAMPLING_RATE_192KHZ:
  292. sample_rate_val = 6;
  293. break;
  294. default:
  295. sample_rate_val = 4;
  296. break;
  297. }
  298. return sample_rate_val;
  299. }
  300. static int int_mi2s_get_sample_rate(int value)
  301. {
  302. int sample_rate;
  303. switch (value) {
  304. case 0:
  305. sample_rate = SAMPLING_RATE_8KHZ;
  306. break;
  307. case 1:
  308. sample_rate = SAMPLING_RATE_16KHZ;
  309. break;
  310. case 2:
  311. sample_rate = SAMPLING_RATE_32KHZ;
  312. break;
  313. case 3:
  314. sample_rate = SAMPLING_RATE_44P1KHZ;
  315. break;
  316. case 4:
  317. sample_rate = SAMPLING_RATE_48KHZ;
  318. break;
  319. case 5:
  320. sample_rate = SAMPLING_RATE_96KHZ;
  321. break;
  322. case 6:
  323. sample_rate = SAMPLING_RATE_192KHZ;
  324. break;
  325. default:
  326. sample_rate = SAMPLING_RATE_48KHZ;
  327. break;
  328. }
  329. return sample_rate;
  330. }
  331. static int int_mi2s_sample_rate_put(struct snd_kcontrol *kcontrol,
  332. struct snd_ctl_elem_value *ucontrol)
  333. {
  334. int idx = int_mi2s_get_port_idx(kcontrol);
  335. if (idx < 0)
  336. return idx;
  337. int_mi2s_cfg[idx].sample_rate =
  338. int_mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  339. pr_debug("%s: idx[%d]_sample_rate = %d, item = %d\n", __func__,
  340. idx, int_mi2s_cfg[idx].sample_rate,
  341. ucontrol->value.enumerated.item[0]);
  342. return 0;
  343. }
  344. static int int_mi2s_sample_rate_get(struct snd_kcontrol *kcontrol,
  345. struct snd_ctl_elem_value *ucontrol)
  346. {
  347. int idx = int_mi2s_get_port_idx(kcontrol);
  348. if (idx < 0)
  349. return idx;
  350. ucontrol->value.enumerated.item[0] =
  351. int_mi2s_get_sample_rate_val(int_mi2s_cfg[idx].sample_rate);
  352. pr_debug("%s: idx[%d]_sample_rate = %d, item = %d\n", __func__,
  353. idx, int_mi2s_cfg[idx].sample_rate,
  354. ucontrol->value.enumerated.item[0]);
  355. return 0;
  356. }
  357. static int int_mi2s_ch_get(struct snd_kcontrol *kcontrol,
  358. struct snd_ctl_elem_value *ucontrol)
  359. {
  360. int idx = int_mi2s_get_port_idx(kcontrol);
  361. if (idx < 0)
  362. return idx;
  363. pr_debug("%s: int_mi2s_[%d]_rx_ch = %d\n", __func__,
  364. idx, int_mi2s_cfg[idx].channels);
  365. ucontrol->value.enumerated.item[0] = int_mi2s_cfg[idx].channels - 1;
  366. return 0;
  367. }
  368. static int int_mi2s_ch_put(struct snd_kcontrol *kcontrol,
  369. struct snd_ctl_elem_value *ucontrol)
  370. {
  371. int idx = int_mi2s_get_port_idx(kcontrol);
  372. if (idx < 0)
  373. return idx;
  374. int_mi2s_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  375. pr_debug("%s: int_mi2s_[%d]_ch = %d\n", __func__,
  376. idx, int_mi2s_cfg[idx].channels);
  377. return 1;
  378. }
  379. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  380. SND_SOC_DAPM_SUPPLY_S("INT_MCLK0", -1, SND_SOC_NOPM, 0, 0,
  381. msm_int_mclk0_event, SND_SOC_DAPM_POST_PMD),
  382. SND_SOC_DAPM_MIC("Handset Mic", NULL),
  383. SND_SOC_DAPM_MIC("Headset Mic", NULL),
  384. SND_SOC_DAPM_MIC("Secondary Mic", NULL),
  385. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  386. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  387. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  388. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  389. };
  390. static int msm_config_hph_compander_gpio(bool enable,
  391. struct snd_soc_codec *codec)
  392. {
  393. struct snd_soc_card *card = codec->component.card;
  394. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  395. int ret = 0;
  396. pr_debug("%s: %s HPH Compander\n", __func__,
  397. enable ? "Enable" : "Disable");
  398. if (enable) {
  399. ret = msm_cdc_pinctrl_select_active_state(pdata->comp_gpio_p);
  400. if (ret) {
  401. pr_err("%s: gpio set cannot be activated %s\n",
  402. __func__, "comp_gpio");
  403. goto done;
  404. }
  405. } else {
  406. ret = msm_cdc_pinctrl_select_sleep_state(pdata->comp_gpio_p);
  407. if (ret) {
  408. pr_err("%s: gpio set cannot be de-activated %s\n",
  409. __func__, "comp_gpio");
  410. goto done;
  411. }
  412. }
  413. done:
  414. return ret;
  415. }
  416. static int is_ext_spk_gpio_support(struct platform_device *pdev,
  417. struct msm_asoc_mach_data *pdata)
  418. {
  419. const char *spk_ext_pa = "qcom,msm-spk-ext-pa";
  420. pr_debug("%s:Enter\n", __func__);
  421. pdata->spk_ext_pa_gpio = of_get_named_gpio(pdev->dev.of_node,
  422. spk_ext_pa, 0);
  423. if (pdata->spk_ext_pa_gpio < 0) {
  424. dev_dbg(&pdev->dev,
  425. "%s: missing %s in dt node\n", __func__, spk_ext_pa);
  426. } else {
  427. if (!gpio_is_valid(pdata->spk_ext_pa_gpio)) {
  428. pr_err("%s: Invalid external speaker gpio: %d",
  429. __func__, pdata->spk_ext_pa_gpio);
  430. return -EINVAL;
  431. }
  432. }
  433. return 0;
  434. }
  435. static int enable_spk_ext_pa(struct snd_soc_codec *codec, int enable)
  436. {
  437. struct snd_soc_card *card = codec->component.card;
  438. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  439. int ret;
  440. if (!gpio_is_valid(pdata->spk_ext_pa_gpio)) {
  441. pr_err("%s: Invalid gpio: %d\n", __func__,
  442. pdata->spk_ext_pa_gpio);
  443. return false;
  444. }
  445. pr_debug("%s: %s external speaker PA\n", __func__,
  446. enable ? "Enable" : "Disable");
  447. if (enable) {
  448. ret = msm_cdc_pinctrl_select_active_state(
  449. pdata->ext_spk_gpio_p);
  450. if (ret) {
  451. pr_err("%s: gpio set cannot be de-activated %s\n",
  452. __func__, "ext_spk_gpio");
  453. return ret;
  454. }
  455. gpio_set_value_cansleep(pdata->spk_ext_pa_gpio, enable);
  456. } else {
  457. gpio_set_value_cansleep(pdata->spk_ext_pa_gpio, enable);
  458. ret = msm_cdc_pinctrl_select_sleep_state(
  459. pdata->ext_spk_gpio_p);
  460. if (ret) {
  461. pr_err("%s: gpio set cannot be de-activated %s\n",
  462. __func__, "ext_spk_gpio");
  463. return ret;
  464. }
  465. }
  466. return 0;
  467. }
  468. static int int_mi2s_get_idx_from_beid(int32_t id)
  469. {
  470. int idx = 0;
  471. switch (id) {
  472. case MSM_BACKEND_DAI_INT0_MI2S_RX:
  473. idx = INT0_MI2S;
  474. break;
  475. case MSM_BACKEND_DAI_INT2_MI2S_TX:
  476. idx = INT2_MI2S;
  477. break;
  478. case MSM_BACKEND_DAI_INT3_MI2S_TX:
  479. idx = INT3_MI2S;
  480. break;
  481. case MSM_BACKEND_DAI_INT4_MI2S_RX:
  482. idx = INT4_MI2S;
  483. break;
  484. case MSM_BACKEND_DAI_INT5_MI2S_TX:
  485. idx = INT5_MI2S;
  486. break;
  487. default:
  488. idx = INT0_MI2S;
  489. break;
  490. }
  491. return idx;
  492. }
  493. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  494. struct snd_pcm_hw_params *params)
  495. {
  496. struct snd_interval *rate = hw_param_interval(params,
  497. SNDRV_PCM_HW_PARAM_RATE);
  498. struct snd_interval *channels = hw_param_interval(params,
  499. SNDRV_PCM_HW_PARAM_CHANNELS);
  500. pr_debug("%s()\n", __func__);
  501. rate->min = rate->max = 48000;
  502. channels->min = channels->max = 2;
  503. return 0;
  504. }
  505. static int int_mi2s_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  506. struct snd_pcm_hw_params *params)
  507. {
  508. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  509. struct snd_interval *rate = hw_param_interval(params,
  510. SNDRV_PCM_HW_PARAM_RATE);
  511. struct snd_interval *channels = hw_param_interval(params,
  512. SNDRV_PCM_HW_PARAM_CHANNELS);
  513. int idx;
  514. pr_debug("%s: format = %d, rate = %d\n",
  515. __func__, params_format(params), params_rate(params));
  516. switch (dai_link->id) {
  517. case MSM_BACKEND_DAI_INT0_MI2S_RX:
  518. case MSM_BACKEND_DAI_INT2_MI2S_TX:
  519. case MSM_BACKEND_DAI_INT3_MI2S_TX:
  520. case MSM_BACKEND_DAI_INT4_MI2S_RX:
  521. case MSM_BACKEND_DAI_INT5_MI2S_TX:
  522. idx = int_mi2s_get_idx_from_beid(dai_link->id);
  523. rate->min = rate->max = int_mi2s_cfg[idx].sample_rate;
  524. channels->min = channels->max =
  525. int_mi2s_cfg[idx].channels;
  526. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  527. int_mi2s_cfg[idx].bit_format);
  528. break;
  529. default:
  530. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  531. break;
  532. }
  533. return 0;
  534. }
  535. static int msm_btfm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  536. struct snd_pcm_hw_params *params)
  537. {
  538. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  539. struct snd_interval *rate = hw_param_interval(params,
  540. SNDRV_PCM_HW_PARAM_RATE);
  541. struct snd_interval *channels = hw_param_interval(params,
  542. SNDRV_PCM_HW_PARAM_CHANNELS);
  543. switch (dai_link->id) {
  544. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  545. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  546. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  547. bt_fm_cfg[BT_SLIM7].bit_format);
  548. rate->min = rate->max = bt_fm_cfg[BT_SLIM7].sample_rate;
  549. channels->min = channels->max =
  550. bt_fm_cfg[BT_SLIM7].channels;
  551. break;
  552. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  553. rate->min = rate->max = bt_fm_cfg[FM_SLIM8].sample_rate;
  554. channels->min = channels->max =
  555. bt_fm_cfg[FM_SLIM8].channels;
  556. break;
  557. default:
  558. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  559. break;
  560. }
  561. return 0;
  562. }
  563. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  564. struct snd_ctl_elem_value *ucontrol)
  565. {
  566. ucontrol->value.integer.value[0] =
  567. (int_mi2s_cfg[INT5_MI2S].channels/2 - 1);
  568. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  569. ucontrol->value.integer.value[0]);
  570. return 0;
  571. }
  572. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  573. struct snd_ctl_elem_value *ucontrol)
  574. {
  575. int_mi2s_cfg[INT5_MI2S].channels =
  576. roundup_pow_of_two(ucontrol->value.integer.value[0] + 2);
  577. pr_debug("%s: msm_vi_feed_tx_ch = %d\n",
  578. __func__, int_mi2s_cfg[INT5_MI2S].channels);
  579. return 1;
  580. }
  581. static int msm_int_enable_dig_cdc_clk(struct snd_soc_codec *codec,
  582. int enable, bool dapm)
  583. {
  584. int ret = 0;
  585. struct msm_asoc_mach_data *pdata = NULL;
  586. int clk_freq_in_hz;
  587. bool int_mclk0_freq_chg = false;
  588. pdata = snd_soc_card_get_drvdata(codec->component.card);
  589. pr_debug("%s: enable %d mclk ref counter %d\n",
  590. __func__, enable,
  591. atomic_read(&pdata->int_mclk0_rsc_ref));
  592. if (enable) {
  593. if (int_mi2s_cfg[INT0_MI2S].sample_rate ==
  594. SAMPLING_RATE_44P1KHZ) {
  595. clk_freq_in_hz = NATIVE_MCLK_RATE;
  596. pdata->native_clk_set = true;
  597. } else {
  598. clk_freq_in_hz = pdata->mclk_freq;
  599. pdata->native_clk_set = false;
  600. }
  601. if (pdata->digital_cdc_core_clk.clk_freq_in_hz
  602. != clk_freq_in_hz)
  603. int_mclk0_freq_chg = true;
  604. if (!atomic_read(&pdata->int_mclk0_rsc_ref) ||
  605. int_mclk0_freq_chg) {
  606. cancel_delayed_work_sync(
  607. &pdata->disable_int_mclk0_work);
  608. mutex_lock(&pdata->cdc_int_mclk0_mutex);
  609. if (atomic_read(&pdata->int_mclk0_enabled) == false ||
  610. int_mclk0_freq_chg) {
  611. if (atomic_read(&pdata->int_mclk0_enabled)) {
  612. pdata->digital_cdc_core_clk.enable = 0;
  613. afe_set_lpass_clock_v2(
  614. AFE_PORT_ID_INT0_MI2S_RX,
  615. &pdata->digital_cdc_core_clk);
  616. }
  617. pdata->digital_cdc_core_clk.clk_freq_in_hz =
  618. clk_freq_in_hz;
  619. pdata->digital_cdc_core_clk.enable = 1;
  620. ret = afe_set_lpass_clock_v2(
  621. AFE_PORT_ID_INT0_MI2S_RX,
  622. &pdata->digital_cdc_core_clk);
  623. if (ret < 0) {
  624. pr_err("%s: failed to enable CCLK\n",
  625. __func__);
  626. mutex_unlock(
  627. &pdata->cdc_int_mclk0_mutex);
  628. return ret;
  629. }
  630. pr_debug("enabled digital codec core clk\n");
  631. atomic_set(&pdata->int_mclk0_enabled, true);
  632. }
  633. mutex_unlock(&pdata->cdc_int_mclk0_mutex);
  634. }
  635. atomic_inc(&pdata->int_mclk0_rsc_ref);
  636. } else {
  637. cancel_delayed_work_sync(&pdata->disable_int_mclk0_work);
  638. mutex_lock(&pdata->cdc_int_mclk0_mutex);
  639. if (atomic_read(&pdata->int_mclk0_enabled) == true) {
  640. pdata->digital_cdc_core_clk.enable = 0;
  641. ret = afe_set_lpass_clock_v2(
  642. AFE_PORT_ID_INT0_MI2S_RX,
  643. &pdata->digital_cdc_core_clk);
  644. if (ret < 0)
  645. pr_err("%s: failed to disable CCLK\n",
  646. __func__);
  647. atomic_set(&pdata->int_mclk0_enabled, false);
  648. }
  649. mutex_unlock(&pdata->cdc_int_mclk0_mutex);
  650. }
  651. return ret;
  652. }
  653. static int loopback_mclk_get(struct snd_kcontrol *kcontrol,
  654. struct snd_ctl_elem_value *ucontrol)
  655. {
  656. pr_debug("%s\n", __func__);
  657. return 0;
  658. }
  659. static int loopback_mclk_put(struct snd_kcontrol *kcontrol,
  660. struct snd_ctl_elem_value *ucontrol)
  661. {
  662. int ret = -EINVAL;
  663. struct msm_asoc_mach_data *pdata = NULL;
  664. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  665. pdata = snd_soc_card_get_drvdata(codec->component.card);
  666. pr_debug("%s: mclk_rsc_ref %d enable %ld\n",
  667. __func__, atomic_read(&pdata->int_mclk0_rsc_ref),
  668. ucontrol->value.integer.value[0]);
  669. switch (ucontrol->value.integer.value[0]) {
  670. case 1:
  671. ret = msm_cdc_pinctrl_select_active_state(pdata->pdm_gpio_p);
  672. if (ret) {
  673. pr_err("%s: failed to enable the pri gpios: %d\n",
  674. __func__, ret);
  675. break;
  676. }
  677. mutex_lock(&pdata->cdc_int_mclk0_mutex);
  678. if ((!atomic_read(&pdata->int_mclk0_rsc_ref)) &&
  679. (!atomic_read(&pdata->int_mclk0_enabled))) {
  680. pdata->digital_cdc_core_clk.enable = 1;
  681. ret = afe_set_lpass_clock_v2(
  682. AFE_PORT_ID_INT0_MI2S_RX,
  683. &pdata->digital_cdc_core_clk);
  684. if (ret < 0) {
  685. pr_err("%s: failed to enable the MCLK: %d\n",
  686. __func__, ret);
  687. mutex_unlock(&pdata->cdc_int_mclk0_mutex);
  688. ret = msm_cdc_pinctrl_select_sleep_state(
  689. pdata->pdm_gpio_p);
  690. if (ret)
  691. pr_err("%s: failed to disable the pri gpios: %d\n",
  692. __func__, ret);
  693. break;
  694. }
  695. atomic_set(&pdata->int_mclk0_enabled, true);
  696. }
  697. mutex_unlock(&pdata->cdc_int_mclk0_mutex);
  698. atomic_inc(&pdata->int_mclk0_rsc_ref);
  699. msm_anlg_cdc_mclk_enable(codec, 1, true);
  700. break;
  701. case 0:
  702. if (atomic_read(&pdata->int_mclk0_rsc_ref) <= 0)
  703. break;
  704. msm_anlg_cdc_mclk_enable(codec, 0, true);
  705. mutex_lock(&pdata->cdc_int_mclk0_mutex);
  706. if ((!atomic_dec_return(&pdata->int_mclk0_rsc_ref)) &&
  707. (atomic_read(&pdata->int_mclk0_enabled))) {
  708. pdata->digital_cdc_core_clk.enable = 0;
  709. ret = afe_set_lpass_clock_v2(
  710. AFE_PORT_ID_INT0_MI2S_RX,
  711. &pdata->digital_cdc_core_clk);
  712. if (ret < 0) {
  713. pr_err("%s: failed to disable the CCLK: %d\n",
  714. __func__, ret);
  715. mutex_unlock(&pdata->cdc_int_mclk0_mutex);
  716. break;
  717. }
  718. atomic_set(&pdata->int_mclk0_enabled, false);
  719. }
  720. mutex_unlock(&pdata->cdc_int_mclk0_mutex);
  721. ret = msm_cdc_pinctrl_select_sleep_state(pdata->pdm_gpio_p);
  722. if (ret)
  723. pr_err("%s: failed to disable the pri gpios: %d\n",
  724. __func__, ret);
  725. break;
  726. default:
  727. pr_err("%s: Unexpected input value\n", __func__);
  728. break;
  729. }
  730. return ret;
  731. }
  732. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  733. struct snd_ctl_elem_value *ucontrol)
  734. {
  735. /*
  736. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  737. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  738. * value.
  739. */
  740. switch (bt_fm_cfg[BT_SLIM7].sample_rate) {
  741. case SAMPLING_RATE_48KHZ:
  742. ucontrol->value.integer.value[0] = 2;
  743. break;
  744. case SAMPLING_RATE_16KHZ:
  745. ucontrol->value.integer.value[0] = 1;
  746. break;
  747. case SAMPLING_RATE_8KHZ:
  748. default:
  749. ucontrol->value.integer.value[0] = 0;
  750. break;
  751. }
  752. pr_debug("%s: sample rate = %d", __func__,
  753. bt_fm_cfg[BT_SLIM7].sample_rate);
  754. return 0;
  755. }
  756. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  757. struct snd_ctl_elem_value *ucontrol)
  758. {
  759. switch (ucontrol->value.integer.value[0]) {
  760. case 1:
  761. bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_16KHZ;
  762. break;
  763. case 2:
  764. bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_48KHZ;
  765. break;
  766. case 0:
  767. default:
  768. bt_fm_cfg[BT_SLIM7].sample_rate = SAMPLING_RATE_8KHZ;
  769. break;
  770. }
  771. pr_debug("%s: sample rates: slim7_rx = %d, value = %d\n",
  772. __func__,
  773. bt_fm_cfg[BT_SLIM7].sample_rate,
  774. ucontrol->value.enumerated.item[0]);
  775. return 0;
  776. }
  777. static const struct snd_kcontrol_new msm_snd_controls[] = {
  778. SOC_ENUM_EXT("INT0_MI2S_RX Format", int0_mi2s_rx_format,
  779. int_mi2s_bit_format_get, int_mi2s_bit_format_put),
  780. SOC_ENUM_EXT("INT2_MI2S_TX Format", int2_mi2s_tx_format,
  781. int_mi2s_bit_format_get, int_mi2s_bit_format_put),
  782. SOC_ENUM_EXT("INT3_MI2S_TX Format", int3_mi2s_tx_format,
  783. int_mi2s_bit_format_get, int_mi2s_bit_format_put),
  784. SOC_ENUM_EXT("INT0_MI2S_RX SampleRate", int0_mi2s_rx_sample_rate,
  785. int_mi2s_sample_rate_get,
  786. int_mi2s_sample_rate_put),
  787. SOC_ENUM_EXT("INT2_MI2S_TX SampleRate", int2_mi2s_tx_sample_rate,
  788. int_mi2s_sample_rate_get,
  789. int_mi2s_sample_rate_put),
  790. SOC_ENUM_EXT("INT3_MI2S_TX SampleRate", int3_mi2s_tx_sample_rate,
  791. int_mi2s_sample_rate_get,
  792. int_mi2s_sample_rate_put),
  793. SOC_ENUM_EXT("INT0_MI2S_RX Channels", int0_mi2s_rx_chs,
  794. int_mi2s_ch_get, int_mi2s_ch_put),
  795. SOC_ENUM_EXT("INT2_MI2S_TX Channels", int2_mi2s_tx_chs,
  796. int_mi2s_ch_get, int_mi2s_ch_put),
  797. SOC_ENUM_EXT("INT3_MI2S_TX Channels", int3_mi2s_tx_chs,
  798. int_mi2s_ch_get, int_mi2s_ch_put),
  799. SOC_ENUM_EXT("Loopback MCLK", loopback_mclk_en,
  800. loopback_mclk_get, loopback_mclk_put),
  801. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  802. msm_bt_sample_rate_get,
  803. msm_bt_sample_rate_put),
  804. };
  805. static const struct snd_kcontrol_new msm_sdw_controls[] = {
  806. SOC_ENUM_EXT("INT4_MI2S_RX Format", int4_mi2s_rx_format,
  807. int_mi2s_bit_format_get, int_mi2s_bit_format_put),
  808. SOC_ENUM_EXT("INT4_MI2S_RX SampleRate", int4_mi2s_rx_sample_rate,
  809. int_mi2s_sample_rate_get,
  810. int_mi2s_sample_rate_put),
  811. SOC_ENUM_EXT("INT4_MI2S_RX Channels", int4_mi2s_rx_chs,
  812. int_mi2s_ch_get, int_mi2s_ch_put),
  813. SOC_ENUM_EXT("VI_FEED_TX Channels", int5_mi2s_tx_chs,
  814. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  815. };
  816. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  817. struct snd_kcontrol *kcontrol, int event)
  818. {
  819. struct msm_asoc_mach_data *pdata = NULL;
  820. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  821. int ret = 0;
  822. pdata = snd_soc_card_get_drvdata(codec->component.card);
  823. pr_debug("%s: event = %d\n", __func__, event);
  824. switch (event) {
  825. case SND_SOC_DAPM_PRE_PMU:
  826. ret = msm_cdc_pinctrl_select_active_state(pdata->dmic_gpio_p);
  827. if (ret < 0) {
  828. pr_err("%s: gpio set cannot be activated %sd",
  829. __func__, "dmic_gpio");
  830. return ret;
  831. }
  832. break;
  833. case SND_SOC_DAPM_POST_PMD:
  834. ret = msm_cdc_pinctrl_select_sleep_state(pdata->dmic_gpio_p);
  835. if (ret < 0) {
  836. pr_err("%s: gpio set cannot be de-activated %sd",
  837. __func__, "dmic_gpio");
  838. return ret;
  839. }
  840. break;
  841. default:
  842. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  843. return -EINVAL;
  844. }
  845. return 0;
  846. }
  847. static int msm_int_mclk0_event(struct snd_soc_dapm_widget *w,
  848. struct snd_kcontrol *kcontrol, int event)
  849. {
  850. struct msm_asoc_mach_data *pdata = NULL;
  851. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  852. int ret = 0;
  853. pdata = snd_soc_card_get_drvdata(codec->component.card);
  854. pr_debug("%s: event = %d\n", __func__, event);
  855. switch (event) {
  856. case SND_SOC_DAPM_POST_PMD:
  857. pr_debug("%s: mclk_res_ref = %d\n",
  858. __func__, atomic_read(&pdata->int_mclk0_rsc_ref));
  859. ret = msm_cdc_pinctrl_select_sleep_state(pdata->pdm_gpio_p);
  860. if (ret < 0) {
  861. pr_err("%s: gpio set cannot be de-activated %sd",
  862. __func__, "int_pdm");
  863. return ret;
  864. }
  865. if (atomic_read(&pdata->int_mclk0_rsc_ref) == 0) {
  866. pr_debug("%s: disabling MCLK\n", __func__);
  867. /* disable the codec mclk config*/
  868. msm_anlg_cdc_mclk_enable(codec, 0, true);
  869. msm_int_enable_dig_cdc_clk(codec, 0, true);
  870. }
  871. break;
  872. default:
  873. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  874. return -EINVAL;
  875. }
  876. return 0;
  877. }
  878. static int int_mi2s_get_port_id(int id)
  879. {
  880. int afe_port_id;
  881. switch (id) {
  882. case MSM_BACKEND_DAI_INT0_MI2S_RX:
  883. afe_port_id = AFE_PORT_ID_INT0_MI2S_RX;
  884. break;
  885. case MSM_BACKEND_DAI_INT2_MI2S_TX:
  886. afe_port_id = AFE_PORT_ID_INT2_MI2S_TX;
  887. break;
  888. case MSM_BACKEND_DAI_INT3_MI2S_TX:
  889. afe_port_id = AFE_PORT_ID_INT3_MI2S_TX;
  890. break;
  891. case MSM_BACKEND_DAI_INT4_MI2S_RX:
  892. afe_port_id = AFE_PORT_ID_INT4_MI2S_RX;
  893. break;
  894. case MSM_BACKEND_DAI_INT5_MI2S_TX:
  895. afe_port_id = AFE_PORT_ID_INT5_MI2S_TX;
  896. break;
  897. default:
  898. pr_err("%s: Invalid id: %d\n", __func__, id);
  899. afe_port_id = -EINVAL;
  900. }
  901. return afe_port_id;
  902. }
  903. static int int_mi2s_get_index(int port_id)
  904. {
  905. int index;
  906. switch (port_id) {
  907. case AFE_PORT_ID_INT0_MI2S_RX:
  908. index = INT0_MI2S;
  909. break;
  910. case AFE_PORT_ID_INT2_MI2S_TX:
  911. index = INT2_MI2S;
  912. break;
  913. case AFE_PORT_ID_INT3_MI2S_TX:
  914. index = INT3_MI2S;
  915. break;
  916. case AFE_PORT_ID_INT4_MI2S_RX:
  917. index = INT4_MI2S;
  918. break;
  919. case AFE_PORT_ID_INT5_MI2S_TX:
  920. index = INT5_MI2S;
  921. break;
  922. default:
  923. pr_err("%s: Invalid port_id: %d\n", __func__, port_id);
  924. index = -EINVAL;
  925. }
  926. return index;
  927. }
  928. static u32 get_int_mi2s_bits_per_sample(u32 bit_format)
  929. {
  930. u32 bit_per_sample;
  931. switch (bit_format) {
  932. case SNDRV_PCM_FORMAT_S24_3LE:
  933. case SNDRV_PCM_FORMAT_S24_LE:
  934. bit_per_sample = 32;
  935. break;
  936. case SNDRV_PCM_FORMAT_S16_LE:
  937. default:
  938. bit_per_sample = 16;
  939. break;
  940. }
  941. return bit_per_sample;
  942. }
  943. static void update_int_mi2s_clk_val(int idx, int stream)
  944. {
  945. u32 bit_per_sample;
  946. bit_per_sample =
  947. get_int_mi2s_bits_per_sample(int_mi2s_cfg[idx].bit_format);
  948. int_mi2s_clk[idx].clk_freq_in_hz =
  949. (int_mi2s_cfg[idx].sample_rate * 2 * bit_per_sample);
  950. }
  951. static int int_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  952. {
  953. int ret = 0;
  954. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  955. int port_id = 0;
  956. int index;
  957. port_id = int_mi2s_get_port_id(rtd->dai_link->id);
  958. if (port_id < 0) {
  959. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  960. ret = port_id;
  961. goto done;
  962. }
  963. index = int_mi2s_get_index(port_id);
  964. if (index < 0) {
  965. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  966. ret = port_id;
  967. goto done;
  968. }
  969. if (enable) {
  970. update_int_mi2s_clk_val(index, substream->stream);
  971. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  972. int_mi2s_clk[index].clk_freq_in_hz);
  973. }
  974. int_mi2s_clk[index].enable = enable;
  975. ret = afe_set_lpass_clock_v2(port_id,
  976. &int_mi2s_clk[index]);
  977. if (ret < 0) {
  978. dev_err(rtd->card->dev,
  979. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  980. __func__, port_id, ret);
  981. goto done;
  982. }
  983. done:
  984. return ret;
  985. }
  986. static int msm_sdw_mi2s_snd_startup(struct snd_pcm_substream *substream)
  987. {
  988. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  989. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  990. int ret = 0;
  991. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  992. substream->name, substream->stream);
  993. ret = int_mi2s_set_sclk(substream, true);
  994. if (ret < 0) {
  995. pr_err("%s: failed to enable sclk %d\n",
  996. __func__, ret);
  997. return ret;
  998. }
  999. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
  1000. if (ret < 0)
  1001. pr_err("%s: set fmt cpu dai failed; ret=%d\n", __func__, ret);
  1002. return ret;
  1003. }
  1004. static void msm_sdw_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  1005. {
  1006. int ret;
  1007. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  1008. substream->name, substream->stream);
  1009. ret = int_mi2s_set_sclk(substream, false);
  1010. if (ret < 0)
  1011. pr_err("%s:clock disable failed; ret=%d\n", __func__,
  1012. ret);
  1013. }
  1014. static int msm_int_mi2s_snd_startup(struct snd_pcm_substream *substream)
  1015. {
  1016. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1017. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1018. struct snd_soc_codec *codec = rtd->codec_dais[ANA_CDC]->codec;
  1019. int ret = 0;
  1020. struct msm_asoc_mach_data *pdata = NULL;
  1021. pdata = snd_soc_card_get_drvdata(codec->component.card);
  1022. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  1023. substream->name, substream->stream);
  1024. ret = int_mi2s_set_sclk(substream, true);
  1025. if (ret < 0) {
  1026. pr_err("%s: failed to enable sclk %d\n",
  1027. __func__, ret);
  1028. return ret;
  1029. }
  1030. ret = msm_int_enable_dig_cdc_clk(codec, 1, true);
  1031. if (ret < 0) {
  1032. pr_err("failed to enable mclk\n");
  1033. return ret;
  1034. }
  1035. /* Enable the codec mclk config */
  1036. ret = msm_cdc_pinctrl_select_active_state(pdata->pdm_gpio_p);
  1037. if (ret < 0) {
  1038. pr_err("%s: gpio set cannot be activated %s\n",
  1039. __func__, "int_pdm");
  1040. return ret;
  1041. }
  1042. msm_anlg_cdc_mclk_enable(codec, 1, true);
  1043. ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBS_CFS);
  1044. if (ret < 0)
  1045. pr_err("%s: set fmt cpu dai failed; ret=%d\n", __func__, ret);
  1046. return ret;
  1047. }
  1048. static void msm_int_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  1049. {
  1050. int ret;
  1051. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1052. struct snd_soc_card *card = rtd->card;
  1053. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1054. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  1055. substream->name, substream->stream);
  1056. ret = int_mi2s_set_sclk(substream, false);
  1057. if (ret < 0)
  1058. pr_err("%s:clock disable failed; ret=%d\n", __func__,
  1059. ret);
  1060. if (atomic_read(&pdata->int_mclk0_rsc_ref) > 0) {
  1061. atomic_dec(&pdata->int_mclk0_rsc_ref);
  1062. pr_debug("%s: decrementing mclk_res_ref %d\n",
  1063. __func__,
  1064. atomic_read(&pdata->int_mclk0_rsc_ref));
  1065. }
  1066. }
  1067. static void *def_msm_int_wcd_mbhc_cal(void)
  1068. {
  1069. void *msm_int_wcd_cal;
  1070. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  1071. u16 *btn_low, *btn_high;
  1072. msm_int_wcd_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  1073. WCD_MBHC_DEF_RLOADS), GFP_KERNEL);
  1074. if (!msm_int_wcd_cal)
  1075. return NULL;
  1076. #define S(X, Y) ((WCD_MBHC_CAL_PLUG_TYPE_PTR(msm_int_wcd_cal)->X) = (Y))
  1077. S(v_hs_max, 1500);
  1078. #undef S
  1079. #define S(X, Y) ((WCD_MBHC_CAL_BTN_DET_PTR(msm_int_wcd_cal)->X) = (Y))
  1080. S(num_btn, WCD_MBHC_DEF_BUTTONS);
  1081. #undef S
  1082. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(msm_int_wcd_cal);
  1083. btn_low = btn_cfg->_v_btn_low;
  1084. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  1085. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  1086. /*
  1087. * In SW we are maintaining two sets of threshold register
  1088. * one for current source and another for Micbias.
  1089. * all btn_low corresponds to threshold for current source
  1090. * all bt_high corresponds to threshold for Micbias
  1091. * Below thresholds are based on following resistances
  1092. * 0-70 == Button 0
  1093. * 110-180 == Button 1
  1094. * 210-290 == Button 2
  1095. * 360-680 == Button 3
  1096. */
  1097. btn_low[0] = 75;
  1098. btn_high[0] = 75;
  1099. btn_low[1] = 150;
  1100. btn_high[1] = 150;
  1101. btn_low[2] = 225;
  1102. btn_high[2] = 225;
  1103. btn_low[3] = 450;
  1104. btn_high[3] = 450;
  1105. btn_low[4] = 500;
  1106. btn_high[4] = 500;
  1107. return msm_int_wcd_cal;
  1108. }
  1109. static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
  1110. {
  1111. struct snd_soc_codec *dig_cdc = rtd->codec_dais[DIG_CDC]->codec;
  1112. struct snd_soc_codec *ana_cdc = rtd->codec_dais[ANA_CDC]->codec;
  1113. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(ana_cdc);
  1114. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1115. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card);
  1116. struct snd_card *card;
  1117. int ret = -ENOMEM;
  1118. pr_debug("%s(),dev_name%s\n", __func__, dev_name(cpu_dai->dev));
  1119. ret = snd_soc_add_codec_controls(ana_cdc, msm_snd_controls,
  1120. ARRAY_SIZE(msm_snd_controls));
  1121. if (ret < 0) {
  1122. pr_err("%s: add_codec_controls failed: %d\n",
  1123. __func__, ret);
  1124. return ret;
  1125. }
  1126. ret = snd_soc_add_codec_controls(ana_cdc, msm_common_snd_controls,
  1127. msm_common_snd_controls_size());
  1128. if (ret < 0) {
  1129. pr_err("%s: add common snd controls failed: %d\n",
  1130. __func__, ret);
  1131. return ret;
  1132. }
  1133. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  1134. ARRAY_SIZE(msm_int_dapm_widgets));
  1135. snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
  1136. snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
  1137. snd_soc_dapm_ignore_suspend(dapm, "Secondary Mic");
  1138. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  1139. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  1140. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  1141. snd_soc_dapm_ignore_suspend(dapm, "HEADPHONE");
  1142. snd_soc_dapm_ignore_suspend(dapm, "SPK_OUT");
  1143. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  1144. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  1145. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  1146. snd_soc_dapm_ignore_suspend(dapm, "DMIC1");
  1147. snd_soc_dapm_ignore_suspend(dapm, "DMIC2");
  1148. snd_soc_dapm_ignore_suspend(dapm, "DMIC3");
  1149. snd_soc_dapm_ignore_suspend(dapm, "DMIC4");
  1150. snd_soc_dapm_sync(dapm);
  1151. msm_anlg_cdc_spk_ext_pa_cb(enable_spk_ext_pa, ana_cdc);
  1152. msm_dig_cdc_hph_comp_cb(msm_config_hph_compander_gpio, dig_cdc);
  1153. card = rtd->card->snd_card;
  1154. if (!codec_root)
  1155. codec_root = snd_info_create_subdir(card->module, "codecs",
  1156. card->proc_root);
  1157. if (!codec_root) {
  1158. pr_debug("%s: Cannot create codecs module entry\n",
  1159. __func__);
  1160. goto done;
  1161. }
  1162. pdata->codec_root = codec_root;
  1163. msm_dig_codec_info_create_codec_entry(codec_root, dig_cdc);
  1164. msm_anlg_codec_info_create_codec_entry(codec_root, ana_cdc);
  1165. done:
  1166. msm_set_codec_reg_done(true);
  1167. return 0;
  1168. }
  1169. static int msm_sdw_audrx_init(struct snd_soc_pcm_runtime *rtd)
  1170. {
  1171. struct snd_soc_codec *codec = rtd->codec;
  1172. struct snd_soc_dapm_context *dapm =
  1173. snd_soc_codec_get_dapm(codec);
  1174. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card);
  1175. struct snd_soc_component *aux_comp;
  1176. struct snd_card *card;
  1177. snd_soc_add_codec_controls(codec, msm_sdw_controls,
  1178. ARRAY_SIZE(msm_sdw_controls));
  1179. snd_soc_dapm_ignore_suspend(dapm, "AIF1_SDW Playback");
  1180. snd_soc_dapm_ignore_suspend(dapm, "VIfeed_SDW");
  1181. snd_soc_dapm_ignore_suspend(dapm, "SPK1 OUT");
  1182. snd_soc_dapm_ignore_suspend(dapm, "SPK2 OUT");
  1183. snd_soc_dapm_ignore_suspend(dapm, "AIF1_SDW VI");
  1184. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_SDW");
  1185. snd_soc_dapm_sync(dapm);
  1186. /*
  1187. * Send speaker configuration only for WSA8810.
  1188. * Default configuration is for WSA8815.
  1189. */
  1190. pr_debug("%s: Number of aux devices: %d\n",
  1191. __func__, rtd->card->num_aux_devs);
  1192. if (rtd->card->num_aux_devs &&
  1193. !list_empty(&rtd->card->aux_comp_list)) {
  1194. aux_comp = list_first_entry(&rtd->card->aux_comp_list,
  1195. struct snd_soc_component, list_aux);
  1196. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  1197. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  1198. msm_sdw_set_spkr_mode(rtd->codec, SPKR_MODE_1);
  1199. msm_sdw_set_spkr_gain_offset(rtd->codec,
  1200. RX_GAIN_OFFSET_M1P5_DB);
  1201. }
  1202. }
  1203. card = rtd->card->snd_card;
  1204. if (!codec_root)
  1205. codec_root = snd_info_create_subdir(card->module, "codecs",
  1206. card->proc_root);
  1207. if (!codec_root) {
  1208. pr_debug("%s: Cannot create codecs module entry\n",
  1209. __func__);
  1210. goto done;
  1211. }
  1212. pdata->codec_root = codec_root;
  1213. msm_sdw_codec_info_create_codec_entry(codec_root, codec);
  1214. done:
  1215. return 0;
  1216. }
  1217. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  1218. {
  1219. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  1220. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160, 161};
  1221. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1222. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  1223. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  1224. }
  1225. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  1226. struct snd_pcm_hw_params *params)
  1227. {
  1228. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1229. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  1230. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1231. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  1232. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  1233. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  1234. int ret;
  1235. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  1236. codec_dai->name, codec_dai->id);
  1237. ret = snd_soc_dai_get_channel_map(codec_dai,
  1238. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  1239. if (ret) {
  1240. dev_err(rtd->dev,
  1241. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  1242. __func__, ret);
  1243. goto exit;
  1244. }
  1245. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) id %d\n",
  1246. __func__, tx_ch_cnt, dai_link->id);
  1247. ret = snd_soc_dai_set_channel_map(cpu_dai,
  1248. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  1249. if (ret)
  1250. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  1251. __func__, ret);
  1252. exit:
  1253. return ret;
  1254. }
  1255. static unsigned int tdm_param_set_slot_mask(u16 port_id, int slot_width,
  1256. int slots)
  1257. {
  1258. unsigned int slot_mask = 0;
  1259. int i, j;
  1260. unsigned int *slot_offset;
  1261. for (i = TDM_0; i < TDM_PORT_MAX; i++) {
  1262. slot_offset = tdm_slot_offset[i];
  1263. for (j = 0; j < TDM_SLOT_OFFSET_MAX; j++) {
  1264. if (slot_offset[j] != AFE_SLOT_MAPPING_OFFSET_INVALID)
  1265. slot_mask |=
  1266. (1 << ((slot_offset[j] * 8) / slot_width));
  1267. else
  1268. break;
  1269. }
  1270. }
  1271. return slot_mask;
  1272. }
  1273. static int msm_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  1274. struct snd_pcm_hw_params *params)
  1275. {
  1276. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1277. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1278. int ret = 0;
  1279. int channels, slot_width, slots;
  1280. unsigned int slot_mask;
  1281. unsigned int *slot_offset;
  1282. int offset_channels = 0;
  1283. int i;
  1284. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  1285. channels = params_channels(params);
  1286. switch (channels) {
  1287. case 1:
  1288. case 2:
  1289. case 3:
  1290. case 4:
  1291. case 5:
  1292. case 6:
  1293. case 7:
  1294. case 8:
  1295. switch (params_format(params)) {
  1296. case SNDRV_PCM_FORMAT_S32_LE:
  1297. case SNDRV_PCM_FORMAT_S24_LE:
  1298. case SNDRV_PCM_FORMAT_S16_LE:
  1299. /*
  1300. * up to 8 channels HW config should
  1301. * use 32 bit slot width for max support of
  1302. * stream bit width. (slot_width > bit_width)
  1303. */
  1304. slot_width = 32;
  1305. break;
  1306. default:
  1307. pr_err("%s: invalid param format 0x%x\n",
  1308. __func__, params_format(params));
  1309. return -EINVAL;
  1310. }
  1311. slots = 8;
  1312. slot_mask = tdm_param_set_slot_mask(cpu_dai->id,
  1313. slot_width,
  1314. slots);
  1315. if (!slot_mask) {
  1316. pr_err("%s: invalid slot_mask 0x%x\n",
  1317. __func__, slot_mask);
  1318. return -EINVAL;
  1319. }
  1320. break;
  1321. default:
  1322. pr_err("%s: invalid param channels %d\n",
  1323. __func__, channels);
  1324. return -EINVAL;
  1325. }
  1326. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  1327. switch (cpu_dai->id) {
  1328. case AFE_PORT_ID_PRIMARY_TDM_RX:
  1329. case AFE_PORT_ID_SECONDARY_TDM_RX:
  1330. case AFE_PORT_ID_TERTIARY_TDM_RX:
  1331. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  1332. case AFE_PORT_ID_PRIMARY_TDM_TX:
  1333. case AFE_PORT_ID_SECONDARY_TDM_TX:
  1334. case AFE_PORT_ID_TERTIARY_TDM_TX:
  1335. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  1336. slot_offset = tdm_slot_offset[TDM_0];
  1337. break;
  1338. default:
  1339. pr_err("%s: dai id 0x%x not supported\n",
  1340. __func__, cpu_dai->id);
  1341. return -EINVAL;
  1342. }
  1343. for (i = 0; i < TDM_SLOT_OFFSET_MAX; i++) {
  1344. if (slot_offset[i] != AFE_SLOT_MAPPING_OFFSET_INVALID)
  1345. offset_channels++;
  1346. else
  1347. break;
  1348. }
  1349. if (offset_channels == 0) {
  1350. pr_err("%s: slot offset not supported, offset_channels %d\n",
  1351. __func__, offset_channels);
  1352. return -EINVAL;
  1353. }
  1354. if (channels > offset_channels) {
  1355. pr_err("%s: channels %d exceed offset_channels %d\n",
  1356. __func__, channels, offset_channels);
  1357. return -EINVAL;
  1358. }
  1359. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1360. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  1361. slots, slot_width);
  1362. if (ret < 0) {
  1363. pr_err("%s: failed to set tdm slot, err:%d\n",
  1364. __func__, ret);
  1365. goto end;
  1366. }
  1367. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL,
  1368. channels, slot_offset);
  1369. if (ret < 0) {
  1370. pr_err("%s: failed to set channel map, err:%d\n",
  1371. __func__, ret);
  1372. goto end;
  1373. }
  1374. } else {
  1375. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  1376. slots, slot_width);
  1377. if (ret < 0) {
  1378. pr_err("%s: failed to set tdm slot, err:%d\n",
  1379. __func__, ret);
  1380. goto end;
  1381. }
  1382. ret = snd_soc_dai_set_channel_map(cpu_dai, channels,
  1383. slot_offset, 0, NULL);
  1384. if (ret < 0) {
  1385. pr_err("%s: failed to set channel map, err:%d\n",
  1386. __func__, ret);
  1387. goto end;
  1388. }
  1389. }
  1390. end:
  1391. return ret;
  1392. }
  1393. static int msm_snd_card_late_probe(struct snd_soc_card *card)
  1394. {
  1395. const char *be_dl_name = LPASS_BE_INT0_MI2S_RX;
  1396. struct snd_soc_codec *ana_cdc;
  1397. struct snd_soc_pcm_runtime *rtd;
  1398. int ret = 0;
  1399. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  1400. if (!rtd) {
  1401. dev_err(card->dev,
  1402. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1403. __func__, be_dl_name);
  1404. return -EINVAL;
  1405. }
  1406. ana_cdc = rtd->codec_dais[ANA_CDC]->codec;
  1407. mbhc_cfg_ptr->calibration = def_msm_int_wcd_mbhc_cal();
  1408. if (!mbhc_cfg_ptr->calibration)
  1409. return -ENOMEM;
  1410. ret = msm_anlg_cdc_hs_detect(ana_cdc, mbhc_cfg_ptr);
  1411. if (ret) {
  1412. dev_err(card->dev,
  1413. "%s: msm_anlg_cdc_hs_detect failed\n", __func__);
  1414. kfree(mbhc_cfg_ptr->calibration);
  1415. }
  1416. return ret;
  1417. }
  1418. static struct snd_soc_ops msm_tdm_be_ops = {
  1419. .hw_params = msm_tdm_snd_hw_params
  1420. };
  1421. static struct snd_soc_ops msm_wcn_ops = {
  1422. .hw_params = msm_wcn_hw_params,
  1423. };
  1424. static struct snd_soc_ops msm_mi2s_be_ops = {
  1425. .startup = msm_mi2s_snd_startup,
  1426. .shutdown = msm_mi2s_snd_shutdown,
  1427. };
  1428. static struct snd_soc_ops msm_aux_pcm_be_ops = {
  1429. .startup = msm_aux_pcm_snd_startup,
  1430. .shutdown = msm_aux_pcm_snd_shutdown,
  1431. };
  1432. static struct snd_soc_ops msm_int_mi2s_be_ops = {
  1433. .startup = msm_int_mi2s_snd_startup,
  1434. .shutdown = msm_int_mi2s_snd_shutdown,
  1435. };
  1436. static struct snd_soc_ops msm_sdw_mi2s_be_ops = {
  1437. .startup = msm_sdw_mi2s_snd_startup,
  1438. .shutdown = msm_sdw_mi2s_snd_shutdown,
  1439. };
  1440. struct snd_soc_dai_link_component dlc_rx1[] = {
  1441. {
  1442. .of_node = NULL,
  1443. .dai_name = "msm_dig_cdc_dai_rx1",
  1444. },
  1445. {
  1446. .of_node = NULL,
  1447. .dai_name = "msm_anlg_cdc_i2s_rx1",
  1448. },
  1449. };
  1450. struct snd_soc_dai_link_component dlc_tx1[] = {
  1451. {
  1452. .of_node = NULL,
  1453. .dai_name = "msm_dig_cdc_dai_tx1",
  1454. },
  1455. {
  1456. .of_node = NULL,
  1457. .dai_name = "msm_anlg_cdc_i2s_tx1",
  1458. },
  1459. };
  1460. struct snd_soc_dai_link_component dlc_tx2[] = {
  1461. {
  1462. .of_node = NULL,
  1463. .dai_name = "msm_dig_cdc_dai_tx2",
  1464. },
  1465. {
  1466. .of_node = NULL,
  1467. .dai_name = "msm_anlg_cdc_i2s_tx2",
  1468. },
  1469. };
  1470. /* Digital audio interface glue - connects codec <---> CPU */
  1471. static struct snd_soc_dai_link msm_int_dai[] = {
  1472. /* FrontEnd DAI Links */
  1473. {/* hw:x,0 */
  1474. .name = MSM_DAILINK_NAME(Media1),
  1475. .stream_name = "MultiMedia1",
  1476. .cpu_dai_name = "MultiMedia1",
  1477. .platform_name = "msm-pcm-dsp.0",
  1478. .dynamic = 1,
  1479. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1480. SND_SOC_DPCM_TRIGGER_POST},
  1481. .codec_dai_name = "snd-soc-dummy-dai",
  1482. .codec_name = "snd-soc-dummy",
  1483. .ignore_suspend = 1,
  1484. .dpcm_playback = 1,
  1485. .dpcm_capture = 1,
  1486. /* this dai link has playback support */
  1487. .ignore_pmdown_time = 1,
  1488. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  1489. },
  1490. {/* hw:x,1 */
  1491. .name = MSM_DAILINK_NAME(Media2),
  1492. .stream_name = "MultiMedia2",
  1493. .cpu_dai_name = "MultiMedia2",
  1494. .platform_name = "msm-pcm-dsp.0",
  1495. .dynamic = 1,
  1496. .dpcm_playback = 1,
  1497. .dpcm_capture = 1,
  1498. .codec_dai_name = "snd-soc-dummy-dai",
  1499. .codec_name = "snd-soc-dummy",
  1500. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1501. SND_SOC_DPCM_TRIGGER_POST},
  1502. .ignore_suspend = 1,
  1503. /* this dai link has playback support */
  1504. .ignore_pmdown_time = 1,
  1505. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  1506. },
  1507. {/* hw:x,2 */
  1508. .name = "VoiceMMode1",
  1509. .stream_name = "VoiceMMode1",
  1510. .cpu_dai_name = "VoiceMMode1",
  1511. .platform_name = "msm-pcm-voice",
  1512. .dynamic = 1,
  1513. .dpcm_capture = 1,
  1514. .dpcm_playback = 1,
  1515. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1516. SND_SOC_DPCM_TRIGGER_POST},
  1517. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1518. .ignore_suspend = 1,
  1519. .ignore_pmdown_time = 1,
  1520. .codec_dai_name = "snd-soc-dummy-dai",
  1521. .codec_name = "snd-soc-dummy",
  1522. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  1523. },
  1524. {/* hw:x,3 */
  1525. .name = "MSM VoIP",
  1526. .stream_name = "VoIP",
  1527. .cpu_dai_name = "VoIP",
  1528. .platform_name = "msm-voip-dsp",
  1529. .dynamic = 1,
  1530. .dpcm_playback = 1,
  1531. .dpcm_capture = 1,
  1532. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1533. SND_SOC_DPCM_TRIGGER_POST},
  1534. .codec_dai_name = "snd-soc-dummy-dai",
  1535. .codec_name = "snd-soc-dummy",
  1536. .ignore_suspend = 1,
  1537. /* this dai link has playback support */
  1538. .ignore_pmdown_time = 1,
  1539. .id = MSM_FRONTEND_DAI_VOIP,
  1540. },
  1541. {/* hw:x,4 */
  1542. .name = MSM_DAILINK_NAME(ULL),
  1543. .stream_name = "ULL",
  1544. .cpu_dai_name = "MultiMedia3",
  1545. .platform_name = "msm-pcm-dsp.2",
  1546. .dynamic = 1,
  1547. .dpcm_playback = 1,
  1548. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1549. SND_SOC_DPCM_TRIGGER_POST},
  1550. .codec_dai_name = "snd-soc-dummy-dai",
  1551. .codec_name = "snd-soc-dummy",
  1552. .ignore_suspend = 1,
  1553. /* this dai link has playback support */
  1554. .ignore_pmdown_time = 1,
  1555. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  1556. },
  1557. /* Hostless PCM purpose */
  1558. {/* hw:x,5 */
  1559. .name = "INT4 MI2S_RX Hostless",
  1560. .stream_name = "INT4 MI2S_RX Hostless",
  1561. .cpu_dai_name = "INT4_MI2S_RX_HOSTLESS",
  1562. .platform_name = "msm-pcm-hostless",
  1563. .dynamic = 1,
  1564. .dpcm_playback = 1,
  1565. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1566. SND_SOC_DPCM_TRIGGER_POST},
  1567. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1568. .ignore_suspend = 1,
  1569. /* this dailink has playback support */
  1570. .ignore_pmdown_time = 1,
  1571. /* This dainlink has MI2S support */
  1572. .codec_dai_name = "snd-soc-dummy-dai",
  1573. .codec_name = "snd-soc-dummy",
  1574. },
  1575. {/* hw:x,6 */
  1576. .name = "MSM AFE-PCM RX",
  1577. .stream_name = "AFE-PROXY RX",
  1578. .cpu_dai_name = "msm-dai-q6-dev.241",
  1579. .codec_name = "msm-stub-codec.1",
  1580. .codec_dai_name = "msm-stub-rx",
  1581. .platform_name = "msm-pcm-afe",
  1582. .ignore_suspend = 1,
  1583. /* this dai link has playback support */
  1584. .ignore_pmdown_time = 1,
  1585. },
  1586. {/* hw:x,7 */
  1587. .name = "MSM AFE-PCM TX",
  1588. .stream_name = "AFE-PROXY TX",
  1589. .cpu_dai_name = "msm-dai-q6-dev.240",
  1590. .codec_name = "msm-stub-codec.1",
  1591. .codec_dai_name = "msm-stub-tx",
  1592. .platform_name = "msm-pcm-afe",
  1593. .ignore_suspend = 1,
  1594. },
  1595. {/* hw:x,8 */
  1596. .name = MSM_DAILINK_NAME(Compress1),
  1597. .stream_name = "Compress1",
  1598. .cpu_dai_name = "MultiMedia4",
  1599. .platform_name = "msm-compress-dsp",
  1600. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  1601. .dynamic = 1,
  1602. .dpcm_capture = 1,
  1603. .dpcm_playback = 1,
  1604. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1605. SND_SOC_DPCM_TRIGGER_POST},
  1606. .codec_dai_name = "snd-soc-dummy-dai",
  1607. .codec_name = "snd-soc-dummy",
  1608. .ignore_suspend = 1,
  1609. .ignore_pmdown_time = 1,
  1610. /* this dai link has playback support */
  1611. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  1612. },
  1613. {/* hw:x,9*/
  1614. .name = "AUXPCM Hostless",
  1615. .stream_name = "AUXPCM Hostless",
  1616. .cpu_dai_name = "AUXPCM_HOSTLESS",
  1617. .platform_name = "msm-pcm-hostless",
  1618. .dynamic = 1,
  1619. .dpcm_capture = 1,
  1620. .dpcm_playback = 1,
  1621. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1622. SND_SOC_DPCM_TRIGGER_POST},
  1623. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1624. .ignore_suspend = 1,
  1625. /* this dai link has playback support */
  1626. .ignore_pmdown_time = 1,
  1627. .codec_dai_name = "snd-soc-dummy-dai",
  1628. .codec_name = "snd-soc-dummy",
  1629. },
  1630. {/* hw:x,10 */
  1631. .name = "SLIMBUS_1 Hostless",
  1632. .stream_name = "SLIMBUS_1 Hostless",
  1633. .cpu_dai_name = "SLIMBUS1_HOSTLESS",
  1634. .platform_name = "msm-pcm-hostless",
  1635. .dynamic = 1,
  1636. .dpcm_capture = 1,
  1637. .dpcm_playback = 1,
  1638. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1639. SND_SOC_DPCM_TRIGGER_POST},
  1640. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1641. .ignore_suspend = 1,
  1642. .ignore_pmdown_time = 1, /* dai link has playback support */
  1643. .codec_dai_name = "snd-soc-dummy-dai",
  1644. .codec_name = "snd-soc-dummy",
  1645. },
  1646. {/* hw:x,11 */
  1647. .name = "INT3 MI2S_TX Hostless",
  1648. .stream_name = "INT3 MI2S_TX Hostless",
  1649. .cpu_dai_name = "INT3_MI2S_TX_HOSTLESS",
  1650. .platform_name = "msm-pcm-hostless",
  1651. .dynamic = 1,
  1652. .dpcm_capture = 1,
  1653. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1654. SND_SOC_DPCM_TRIGGER_POST},
  1655. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1656. .ignore_suspend = 1,
  1657. .ignore_pmdown_time = 1,
  1658. .codec_dai_name = "snd-soc-dummy-dai",
  1659. .codec_name = "snd-soc-dummy",
  1660. },
  1661. {/* hw:x,12 */
  1662. .name = "SLIMBUS_7 Hostless",
  1663. .stream_name = "SLIMBUS_7 Hostless",
  1664. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  1665. .platform_name = "msm-pcm-hostless",
  1666. .dynamic = 1,
  1667. .dpcm_capture = 1,
  1668. .dpcm_playback = 1,
  1669. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1670. SND_SOC_DPCM_TRIGGER_POST},
  1671. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1672. .ignore_suspend = 1,
  1673. .ignore_pmdown_time = 1, /* dai link has playback support */
  1674. .codec_dai_name = "snd-soc-dummy-dai",
  1675. .codec_name = "snd-soc-dummy",
  1676. },
  1677. {/* hw:x,13 */
  1678. .name = MSM_DAILINK_NAME(LowLatency),
  1679. .stream_name = "MultiMedia5",
  1680. .cpu_dai_name = "MultiMedia5",
  1681. .platform_name = "msm-pcm-dsp.1",
  1682. .dynamic = 1,
  1683. .dpcm_capture = 1,
  1684. .dpcm_playback = 1,
  1685. .codec_dai_name = "snd-soc-dummy-dai",
  1686. .codec_name = "snd-soc-dummy",
  1687. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1688. SND_SOC_DPCM_TRIGGER_POST},
  1689. .ignore_suspend = 1,
  1690. /* this dai link has playback support */
  1691. .ignore_pmdown_time = 1,
  1692. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  1693. },
  1694. /* LSM FE */
  1695. {/* hw:x,14 */
  1696. .name = "Listen 1 Audio Service",
  1697. .stream_name = "Listen 1 Audio Service",
  1698. .cpu_dai_name = "LSM1",
  1699. .platform_name = "msm-lsm-client",
  1700. .dynamic = 1,
  1701. .dpcm_capture = 1,
  1702. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1703. SND_SOC_DPCM_TRIGGER_POST },
  1704. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1705. .ignore_suspend = 1,
  1706. .ignore_pmdown_time = 1,
  1707. .codec_dai_name = "snd-soc-dummy-dai",
  1708. .codec_name = "snd-soc-dummy",
  1709. .id = MSM_FRONTEND_DAI_LSM1,
  1710. },
  1711. {/* hw:x,15 */
  1712. .name = MSM_DAILINK_NAME(Compress2),
  1713. .stream_name = "Compress2",
  1714. .cpu_dai_name = "MultiMedia7",
  1715. .platform_name = "msm-compress-dsp",
  1716. .dynamic = 1,
  1717. .dpcm_capture = 1,
  1718. .dpcm_playback = 1,
  1719. .codec_dai_name = "snd-soc-dummy-dai",
  1720. .codec_name = "snd-soc-dummy",
  1721. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1722. SND_SOC_DPCM_TRIGGER_POST},
  1723. .ignore_suspend = 1,
  1724. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  1725. },
  1726. {/* hw:x,16 */
  1727. .name = MSM_DAILINK_NAME(MultiMedia10),
  1728. .stream_name = "MultiMedia10",
  1729. .cpu_dai_name = "MultiMedia10",
  1730. .platform_name = "msm-pcm-dsp.1",
  1731. .dynamic = 1,
  1732. .dpcm_capture = 1,
  1733. .dpcm_playback = 1,
  1734. .dpcm_capture = 1,
  1735. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1736. SND_SOC_DPCM_TRIGGER_POST},
  1737. .codec_dai_name = "snd-soc-dummy-dai",
  1738. .codec_name = "snd-soc-dummy",
  1739. .ignore_suspend = 1,
  1740. .ignore_pmdown_time = 1,
  1741. /* this dai link has playback support */
  1742. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  1743. },
  1744. {/* hw:x,17 */
  1745. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  1746. .stream_name = "MM_NOIRQ",
  1747. .cpu_dai_name = "MultiMedia8",
  1748. .platform_name = "msm-pcm-dsp-noirq",
  1749. .dynamic = 1,
  1750. .dpcm_capture = 1,
  1751. .dpcm_playback = 1,
  1752. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1753. SND_SOC_DPCM_TRIGGER_POST},
  1754. .codec_dai_name = "snd-soc-dummy-dai",
  1755. .codec_name = "snd-soc-dummy",
  1756. .ignore_suspend = 1,
  1757. .ignore_pmdown_time = 1,
  1758. /* this dai link has playback support */
  1759. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  1760. },
  1761. {/* hw:x,18 */
  1762. .name = "HDMI_RX_HOSTLESS",
  1763. .stream_name = "HDMI_RX_HOSTLESS",
  1764. .cpu_dai_name = "HDMI_HOSTLESS",
  1765. .platform_name = "msm-pcm-hostless",
  1766. .dynamic = 1,
  1767. .dpcm_playback = 1,
  1768. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1769. SND_SOC_DPCM_TRIGGER_POST},
  1770. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1771. .ignore_suspend = 1,
  1772. .ignore_pmdown_time = 1,
  1773. .codec_dai_name = "snd-soc-dummy-dai",
  1774. .codec_name = "snd-soc-dummy",
  1775. },
  1776. {/* hw:x,19 */
  1777. .name = "VoiceMMode2",
  1778. .stream_name = "VoiceMMode2",
  1779. .cpu_dai_name = "VoiceMMode2",
  1780. .platform_name = "msm-pcm-voice",
  1781. .dynamic = 1,
  1782. .dpcm_capture = 1,
  1783. .dpcm_playback = 1,
  1784. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1785. SND_SOC_DPCM_TRIGGER_POST},
  1786. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1787. .ignore_suspend = 1,
  1788. .ignore_pmdown_time = 1,
  1789. .codec_dai_name = "snd-soc-dummy-dai",
  1790. .codec_name = "snd-soc-dummy",
  1791. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  1792. },
  1793. {/* hw:x,20 */
  1794. .name = "Listen 2 Audio Service",
  1795. .stream_name = "Listen 2 Audio Service",
  1796. .cpu_dai_name = "LSM2",
  1797. .platform_name = "msm-lsm-client",
  1798. .dynamic = 1,
  1799. .dpcm_capture = 1,
  1800. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1801. SND_SOC_DPCM_TRIGGER_POST },
  1802. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1803. .ignore_suspend = 1,
  1804. .ignore_pmdown_time = 1,
  1805. .codec_dai_name = "snd-soc-dummy-dai",
  1806. .codec_name = "snd-soc-dummy",
  1807. .id = MSM_FRONTEND_DAI_LSM2,
  1808. },
  1809. {/* hw:x,21 */
  1810. .name = "Listen 3 Audio Service",
  1811. .stream_name = "Listen 3 Audio Service",
  1812. .cpu_dai_name = "LSM3",
  1813. .platform_name = "msm-lsm-client",
  1814. .dynamic = 1,
  1815. .dpcm_capture = 1,
  1816. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1817. SND_SOC_DPCM_TRIGGER_POST },
  1818. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1819. .ignore_suspend = 1,
  1820. .ignore_pmdown_time = 1,
  1821. .codec_dai_name = "snd-soc-dummy-dai",
  1822. .codec_name = "snd-soc-dummy",
  1823. .id = MSM_FRONTEND_DAI_LSM3,
  1824. },
  1825. {/* hw:x,22 */
  1826. .name = "Listen 4 Audio Service",
  1827. .stream_name = "Listen 4 Audio Service",
  1828. .cpu_dai_name = "LSM4",
  1829. .platform_name = "msm-lsm-client",
  1830. .dynamic = 1,
  1831. .dpcm_capture = 1,
  1832. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1833. SND_SOC_DPCM_TRIGGER_POST },
  1834. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1835. .ignore_suspend = 1,
  1836. .ignore_pmdown_time = 1,
  1837. .codec_dai_name = "snd-soc-dummy-dai",
  1838. .codec_name = "snd-soc-dummy",
  1839. .id = MSM_FRONTEND_DAI_LSM4,
  1840. },
  1841. {/* hw:x,23 */
  1842. .name = "Listen 5 Audio Service",
  1843. .stream_name = "Listen 5 Audio Service",
  1844. .cpu_dai_name = "LSM5",
  1845. .platform_name = "msm-lsm-client",
  1846. .dynamic = 1,
  1847. .dpcm_capture = 1,
  1848. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1849. SND_SOC_DPCM_TRIGGER_POST },
  1850. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1851. .ignore_suspend = 1,
  1852. .ignore_pmdown_time = 1,
  1853. .codec_dai_name = "snd-soc-dummy-dai",
  1854. .codec_name = "snd-soc-dummy",
  1855. .id = MSM_FRONTEND_DAI_LSM5,
  1856. },
  1857. {/* hw:x,24 */
  1858. .name = "Listen 6 Audio Service",
  1859. .stream_name = "Listen 6 Audio Service",
  1860. .cpu_dai_name = "LSM6",
  1861. .platform_name = "msm-lsm-client",
  1862. .dynamic = 1,
  1863. .dpcm_capture = 1,
  1864. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1865. SND_SOC_DPCM_TRIGGER_POST },
  1866. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1867. .ignore_suspend = 1,
  1868. .ignore_pmdown_time = 1,
  1869. .codec_dai_name = "snd-soc-dummy-dai",
  1870. .codec_name = "snd-soc-dummy",
  1871. .id = MSM_FRONTEND_DAI_LSM6
  1872. },
  1873. {/* hw:x,25 */
  1874. .name = "Listen 7 Audio Service",
  1875. .stream_name = "Listen 7 Audio Service",
  1876. .cpu_dai_name = "LSM7",
  1877. .platform_name = "msm-lsm-client",
  1878. .dynamic = 1,
  1879. .dpcm_capture = 1,
  1880. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1881. SND_SOC_DPCM_TRIGGER_POST },
  1882. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1883. .ignore_suspend = 1,
  1884. .ignore_pmdown_time = 1,
  1885. .codec_dai_name = "snd-soc-dummy-dai",
  1886. .codec_name = "snd-soc-dummy",
  1887. .id = MSM_FRONTEND_DAI_LSM7,
  1888. },
  1889. {/* hw:x,26 */
  1890. .name = "Listen 8 Audio Service",
  1891. .stream_name = "Listen 8 Audio Service",
  1892. .cpu_dai_name = "LSM8",
  1893. .platform_name = "msm-lsm-client",
  1894. .dynamic = 1,
  1895. .dpcm_capture = 1,
  1896. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1897. SND_SOC_DPCM_TRIGGER_POST },
  1898. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  1899. .ignore_suspend = 1,
  1900. .ignore_pmdown_time = 1,
  1901. .codec_dai_name = "snd-soc-dummy-dai",
  1902. .codec_name = "snd-soc-dummy",
  1903. .id = MSM_FRONTEND_DAI_LSM8,
  1904. },
  1905. {/* hw:x,27 */
  1906. .name = MSM_DAILINK_NAME(Media9),
  1907. .stream_name = "MultiMedia9",
  1908. .cpu_dai_name = "MultiMedia9",
  1909. .platform_name = "msm-pcm-dsp.0",
  1910. .dynamic = 1,
  1911. .dpcm_capture = 1,
  1912. .dpcm_playback = 1,
  1913. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1914. SND_SOC_DPCM_TRIGGER_POST},
  1915. .codec_dai_name = "snd-soc-dummy-dai",
  1916. .codec_name = "snd-soc-dummy",
  1917. .ignore_suspend = 1,
  1918. .ignore_pmdown_time = 1,
  1919. /* this dai link has playback support */
  1920. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  1921. },
  1922. {/* hw:x,28 */
  1923. .name = MSM_DAILINK_NAME(Compress4),
  1924. .stream_name = "Compress4",
  1925. .cpu_dai_name = "MultiMedia11",
  1926. .platform_name = "msm-compress-dsp",
  1927. .dynamic = 1,
  1928. .dpcm_capture = 1,
  1929. .dpcm_playback = 1,
  1930. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1931. SND_SOC_DPCM_TRIGGER_POST},
  1932. .codec_dai_name = "snd-soc-dummy-dai",
  1933. .codec_name = "snd-soc-dummy",
  1934. .ignore_suspend = 1,
  1935. .ignore_pmdown_time = 1,
  1936. /* this dai link has playback support */
  1937. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  1938. },
  1939. {/* hw:x,29 */
  1940. .name = MSM_DAILINK_NAME(Compress5),
  1941. .stream_name = "Compress5",
  1942. .cpu_dai_name = "MultiMedia12",
  1943. .platform_name = "msm-compress-dsp",
  1944. .dynamic = 1,
  1945. .dpcm_capture = 1,
  1946. .dpcm_playback = 1,
  1947. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1948. SND_SOC_DPCM_TRIGGER_POST},
  1949. .codec_dai_name = "snd-soc-dummy-dai",
  1950. .codec_name = "snd-soc-dummy",
  1951. .ignore_suspend = 1,
  1952. .ignore_pmdown_time = 1,
  1953. /* this dai link has playback support */
  1954. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  1955. },
  1956. {/* hw:x,30 */
  1957. .name = MSM_DAILINK_NAME(Compress6),
  1958. .stream_name = "Compress6",
  1959. .cpu_dai_name = "MultiMedia13",
  1960. .platform_name = "msm-compress-dsp",
  1961. .dynamic = 1,
  1962. .dpcm_capture = 1,
  1963. .dpcm_playback = 1,
  1964. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1965. SND_SOC_DPCM_TRIGGER_POST},
  1966. .codec_dai_name = "snd-soc-dummy-dai",
  1967. .codec_name = "snd-soc-dummy",
  1968. .ignore_suspend = 1,
  1969. .ignore_pmdown_time = 1,
  1970. /* this dai link has playback support */
  1971. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  1972. },
  1973. {/* hw:x,31 */
  1974. .name = MSM_DAILINK_NAME(Compress7),
  1975. .stream_name = "Compress7",
  1976. .cpu_dai_name = "MultiMedia14",
  1977. .platform_name = "msm-compress-dsp",
  1978. .dynamic = 1,
  1979. .dpcm_capture = 1,
  1980. .dpcm_playback = 1,
  1981. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1982. SND_SOC_DPCM_TRIGGER_POST},
  1983. .codec_dai_name = "snd-soc-dummy-dai",
  1984. .codec_name = "snd-soc-dummy",
  1985. .ignore_suspend = 1,
  1986. .ignore_pmdown_time = 1,
  1987. /* this dai link has playback support */
  1988. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  1989. },
  1990. {/* hw:x,32 */
  1991. .name = MSM_DAILINK_NAME(Compress8),
  1992. .stream_name = "Compress8",
  1993. .cpu_dai_name = "MultiMedia15",
  1994. .platform_name = "msm-compress-dsp",
  1995. .dynamic = 1,
  1996. .dpcm_capture = 1,
  1997. .dpcm_playback = 1,
  1998. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1999. SND_SOC_DPCM_TRIGGER_POST},
  2000. .codec_dai_name = "snd-soc-dummy-dai",
  2001. .codec_name = "snd-soc-dummy",
  2002. .ignore_suspend = 1,
  2003. .ignore_pmdown_time = 1,
  2004. /* this dai link has playback support */
  2005. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  2006. },
  2007. {/* hw:x,33 */
  2008. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  2009. .stream_name = "MM_NOIRQ_2",
  2010. .cpu_dai_name = "MultiMedia16",
  2011. .platform_name = "msm-pcm-dsp-noirq",
  2012. .dynamic = 1,
  2013. .dpcm_capture = 1,
  2014. .dpcm_playback = 1,
  2015. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2016. SND_SOC_DPCM_TRIGGER_POST},
  2017. .codec_dai_name = "snd-soc-dummy-dai",
  2018. .codec_name = "snd-soc-dummy",
  2019. .ignore_suspend = 1,
  2020. .ignore_pmdown_time = 1,
  2021. /* this dai link has playback support */
  2022. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  2023. },
  2024. {/* hw:x,34 */
  2025. .name = "SLIMBUS_8 Hostless",
  2026. .stream_name = "SLIMBUS8_HOSTLESS Capture",
  2027. .cpu_dai_name = "SLIMBUS8_HOSTLESS",
  2028. .platform_name = "msm-pcm-hostless",
  2029. .dynamic = 1,
  2030. .dpcm_capture = 1,
  2031. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2032. SND_SOC_DPCM_TRIGGER_POST},
  2033. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2034. .ignore_suspend = 1,
  2035. .ignore_pmdown_time = 1,
  2036. .codec_dai_name = "snd-soc-dummy-dai",
  2037. .codec_name = "snd-soc-dummy",
  2038. },
  2039. {/* hw:x,35 */
  2040. .name = "Primary MI2S_RX Hostless",
  2041. .stream_name = "Primary MI2S_RX Hostless",
  2042. .cpu_dai_name = "PRI_MI2S_RX_HOSTLESS",
  2043. .platform_name = "msm-pcm-hostless",
  2044. .dynamic = 1,
  2045. .dpcm_playback = 1,
  2046. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2047. SND_SOC_DPCM_TRIGGER_POST},
  2048. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2049. .ignore_suspend = 1,
  2050. /* this dailink has playback support */
  2051. .ignore_pmdown_time = 1,
  2052. /* This dainlink has MI2S support */
  2053. .codec_dai_name = "snd-soc-dummy-dai",
  2054. .codec_name = "snd-soc-dummy",
  2055. },
  2056. {/* hw:x,36 */
  2057. .name = "Secondary MI2S_RX Hostless",
  2058. .stream_name = "Secondary MI2S_RX Hostless",
  2059. .cpu_dai_name = "SEC_MI2S_RX_HOSTLESS",
  2060. .platform_name = "msm-pcm-hostless",
  2061. .dynamic = 1,
  2062. .dpcm_playback = 1,
  2063. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2064. SND_SOC_DPCM_TRIGGER_POST},
  2065. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2066. .ignore_suspend = 1,
  2067. /* this dailink has playback support */
  2068. .ignore_pmdown_time = 1,
  2069. /* This dainlink has MI2S support */
  2070. .codec_dai_name = "snd-soc-dummy-dai",
  2071. .codec_name = "snd-soc-dummy",
  2072. },
  2073. {/* hw:x,37 */
  2074. .name = "Tertiary MI2S_RX Hostless",
  2075. .stream_name = "Tertiary MI2S_RX Hostless",
  2076. .cpu_dai_name = "TERT_MI2S_RX_HOSTLESS",
  2077. .platform_name = "msm-pcm-hostless",
  2078. .dynamic = 1,
  2079. .dpcm_playback = 1,
  2080. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2081. SND_SOC_DPCM_TRIGGER_POST},
  2082. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2083. .ignore_suspend = 1,
  2084. /* this dailink has playback support */
  2085. .ignore_pmdown_time = 1,
  2086. /* This dainlink has MI2S support */
  2087. .codec_dai_name = "snd-soc-dummy-dai",
  2088. .codec_name = "snd-soc-dummy",
  2089. },
  2090. {/* hw:x,38 */
  2091. .name = "INT0 MI2S_RX Hostless",
  2092. .stream_name = "INT0 MI2S_RX Hostless",
  2093. .cpu_dai_name = "INT0_MI2S_RX_HOSTLESS",
  2094. .platform_name = "msm-pcm-hostless",
  2095. .dynamic = 1,
  2096. .dpcm_playback = 1,
  2097. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2098. SND_SOC_DPCM_TRIGGER_POST},
  2099. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2100. .ignore_suspend = 1,
  2101. /* this dailink has playback support */
  2102. .ignore_pmdown_time = 1,
  2103. /* This dainlink has MI2S support */
  2104. .codec_dai_name = "snd-soc-dummy-dai",
  2105. .codec_name = "snd-soc-dummy",
  2106. },
  2107. {/* hw:x,39 */
  2108. .name = "SDM660 HFP TX",
  2109. .stream_name = "MultiMedia6",
  2110. .cpu_dai_name = "MultiMedia6",
  2111. .platform_name = "msm-pcm-loopback",
  2112. .dynamic = 1,
  2113. .dpcm_playback = 1,
  2114. .dpcm_capture = 1,
  2115. .codec_dai_name = "snd-soc-dummy-dai",
  2116. .codec_name = "snd-soc-dummy",
  2117. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  2118. SND_SOC_DPCM_TRIGGER_POST},
  2119. .ignore_suspend = 1,
  2120. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2121. .ignore_pmdown_time = 1,
  2122. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  2123. },
  2124. };
  2125. static struct snd_soc_dai_link msm_int_wsa_dai[] = {
  2126. {/* hw:x,40 */
  2127. .name = LPASS_BE_INT5_MI2S_TX,
  2128. .stream_name = "INT5_mi2s Capture",
  2129. .cpu_dai_name = "msm-dai-q6-mi2s.12",
  2130. .platform_name = "msm-pcm-hostless",
  2131. .codec_name = "msm_sdw_codec",
  2132. .codec_dai_name = "msm_sdw_vifeedback",
  2133. .id = MSM_BACKEND_DAI_INT5_MI2S_TX,
  2134. .be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
  2135. .ops = &msm_sdw_mi2s_be_ops,
  2136. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  2137. .ignore_suspend = 1,
  2138. .dpcm_capture = 1,
  2139. .ignore_pmdown_time = 1,
  2140. },
  2141. };
  2142. static struct snd_soc_dai_link msm_int_be_dai[] = {
  2143. /* Backend I2S DAI Links */
  2144. {
  2145. .name = LPASS_BE_INT0_MI2S_RX,
  2146. .stream_name = "INT0 MI2S Playback",
  2147. .cpu_dai_name = "msm-dai-q6-mi2s.7",
  2148. .platform_name = "msm-pcm-routing",
  2149. .codecs = dlc_rx1,
  2150. .num_codecs = CODECS_MAX,
  2151. .no_pcm = 1,
  2152. .dpcm_playback = 1,
  2153. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE |
  2154. ASYNC_DPCM_SND_SOC_HW_PARAMS,
  2155. .id = MSM_BACKEND_DAI_INT0_MI2S_RX,
  2156. .init = &msm_audrx_init,
  2157. .be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
  2158. .ops = &msm_int_mi2s_be_ops,
  2159. .ignore_suspend = 1,
  2160. },
  2161. {
  2162. .name = LPASS_BE_INT3_MI2S_TX,
  2163. .stream_name = "INT3 MI2S Capture",
  2164. .cpu_dai_name = "msm-dai-q6-mi2s.10",
  2165. .platform_name = "msm-pcm-routing",
  2166. .codecs = dlc_tx1,
  2167. .num_codecs = CODECS_MAX,
  2168. .no_pcm = 1,
  2169. .dpcm_capture = 1,
  2170. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE |
  2171. ASYNC_DPCM_SND_SOC_HW_PARAMS,
  2172. .id = MSM_BACKEND_DAI_INT3_MI2S_TX,
  2173. .be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
  2174. .ops = &msm_int_mi2s_be_ops,
  2175. .ignore_suspend = 1,
  2176. },
  2177. {
  2178. .name = LPASS_BE_INT2_MI2S_TX,
  2179. .stream_name = "INT2 MI2S Capture",
  2180. .cpu_dai_name = "msm-dai-q6-mi2s.9",
  2181. .platform_name = "msm-pcm-routing",
  2182. .codecs = dlc_tx2,
  2183. .num_codecs = CODECS_MAX,
  2184. .no_pcm = 1,
  2185. .dpcm_capture = 1,
  2186. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE |
  2187. ASYNC_DPCM_SND_SOC_HW_PARAMS,
  2188. .id = MSM_BACKEND_DAI_INT2_MI2S_TX,
  2189. .be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
  2190. .ops = &msm_int_mi2s_be_ops,
  2191. .ignore_suspend = 1,
  2192. },
  2193. {
  2194. .name = LPASS_BE_AFE_PCM_RX,
  2195. .stream_name = "AFE Playback",
  2196. .cpu_dai_name = "msm-dai-q6-dev.224",
  2197. .platform_name = "msm-pcm-routing",
  2198. .codec_name = "msm-stub-codec.1",
  2199. .codec_dai_name = "msm-stub-rx",
  2200. .no_pcm = 1,
  2201. .dpcm_playback = 1,
  2202. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  2203. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2204. /* this dainlink has playback support */
  2205. .ignore_pmdown_time = 1,
  2206. .ignore_suspend = 1,
  2207. },
  2208. {
  2209. .name = LPASS_BE_AFE_PCM_TX,
  2210. .stream_name = "AFE Capture",
  2211. .cpu_dai_name = "msm-dai-q6-dev.225",
  2212. .platform_name = "msm-pcm-routing",
  2213. .codec_name = "msm-stub-codec.1",
  2214. .codec_dai_name = "msm-stub-tx",
  2215. .no_pcm = 1,
  2216. .dpcm_capture = 1,
  2217. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  2218. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2219. .ignore_suspend = 1,
  2220. },
  2221. /* Incall Record Uplink BACK END DAI Link */
  2222. {
  2223. .name = LPASS_BE_INCALL_RECORD_TX,
  2224. .stream_name = "Voice Uplink Capture",
  2225. .cpu_dai_name = "msm-dai-q6-dev.32772",
  2226. .platform_name = "msm-pcm-routing",
  2227. .codec_name = "msm-stub-codec.1",
  2228. .codec_dai_name = "msm-stub-tx",
  2229. .no_pcm = 1,
  2230. .dpcm_capture = 1,
  2231. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  2232. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2233. .ignore_suspend = 1,
  2234. },
  2235. /* Incall Record Downlink BACK END DAI Link */
  2236. {
  2237. .name = LPASS_BE_INCALL_RECORD_RX,
  2238. .stream_name = "Voice Downlink Capture",
  2239. .cpu_dai_name = "msm-dai-q6-dev.32771",
  2240. .platform_name = "msm-pcm-routing",
  2241. .codec_name = "msm-stub-codec.1",
  2242. .codec_dai_name = "msm-stub-tx",
  2243. .no_pcm = 1,
  2244. .dpcm_capture = 1,
  2245. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  2246. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2247. .ignore_suspend = 1,
  2248. },
  2249. /* Incall Music BACK END DAI Link */
  2250. {
  2251. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  2252. .stream_name = "Voice Farend Playback",
  2253. .cpu_dai_name = "msm-dai-q6-dev.32773",
  2254. .platform_name = "msm-pcm-routing",
  2255. .codec_name = "msm-stub-codec.1",
  2256. .codec_dai_name = "msm-stub-rx",
  2257. .no_pcm = 1,
  2258. .dpcm_playback = 1,
  2259. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  2260. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2261. .ignore_suspend = 1,
  2262. },
  2263. /* Incall Music 2 BACK END DAI Link */
  2264. {
  2265. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  2266. .stream_name = "Voice2 Farend Playback",
  2267. .cpu_dai_name = "msm-dai-q6-dev.32770",
  2268. .platform_name = "msm-pcm-routing",
  2269. .codec_name = "msm-stub-codec.1",
  2270. .codec_dai_name = "msm-stub-rx",
  2271. .no_pcm = 1,
  2272. .dpcm_playback = 1,
  2273. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  2274. .be_hw_params_fixup = msm_be_hw_params_fixup,
  2275. .ignore_suspend = 1,
  2276. },
  2277. {
  2278. .name = LPASS_BE_USB_AUDIO_RX,
  2279. .stream_name = "USB Audio Playback",
  2280. .cpu_dai_name = "msm-dai-q6-dev.28672",
  2281. .platform_name = "msm-pcm-routing",
  2282. .codec_name = "msm-stub-codec.1",
  2283. .codec_dai_name = "msm-stub-rx",
  2284. .no_pcm = 1,
  2285. .dpcm_playback = 1,
  2286. .id = MSM_BACKEND_DAI_USB_RX,
  2287. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2288. .ignore_pmdown_time = 1,
  2289. .ignore_suspend = 1,
  2290. },
  2291. {
  2292. .name = LPASS_BE_USB_AUDIO_TX,
  2293. .stream_name = "USB Audio Capture",
  2294. .cpu_dai_name = "msm-dai-q6-dev.28673",
  2295. .platform_name = "msm-pcm-routing",
  2296. .codec_name = "msm-stub-codec.1",
  2297. .codec_dai_name = "msm-stub-tx",
  2298. .no_pcm = 1,
  2299. .dpcm_capture = 1,
  2300. .id = MSM_BACKEND_DAI_USB_TX,
  2301. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2302. .ignore_suspend = 1,
  2303. },
  2304. {
  2305. .name = LPASS_BE_PRI_TDM_RX_0,
  2306. .stream_name = "Primary TDM0 Playback",
  2307. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  2308. .platform_name = "msm-pcm-routing",
  2309. .codec_name = "msm-stub-codec.1",
  2310. .codec_dai_name = "msm-stub-rx",
  2311. .no_pcm = 1,
  2312. .dpcm_playback = 1,
  2313. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  2314. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2315. .ops = &msm_tdm_be_ops,
  2316. .ignore_suspend = 1,
  2317. },
  2318. {
  2319. .name = LPASS_BE_PRI_TDM_TX_0,
  2320. .stream_name = "Primary TDM0 Capture",
  2321. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  2322. .platform_name = "msm-pcm-routing",
  2323. .codec_name = "msm-stub-codec.1",
  2324. .codec_dai_name = "msm-stub-tx",
  2325. .no_pcm = 1,
  2326. .dpcm_capture = 1,
  2327. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  2328. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2329. .ops = &msm_tdm_be_ops,
  2330. .ignore_suspend = 1,
  2331. },
  2332. {
  2333. .name = LPASS_BE_SEC_TDM_RX_0,
  2334. .stream_name = "Secondary TDM0 Playback",
  2335. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  2336. .platform_name = "msm-pcm-routing",
  2337. .codec_name = "msm-stub-codec.1",
  2338. .codec_dai_name = "msm-stub-rx",
  2339. .no_pcm = 1,
  2340. .dpcm_playback = 1,
  2341. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  2342. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2343. .ops = &msm_tdm_be_ops,
  2344. .ignore_suspend = 1,
  2345. },
  2346. {
  2347. .name = LPASS_BE_SEC_TDM_TX_0,
  2348. .stream_name = "Secondary TDM0 Capture",
  2349. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  2350. .platform_name = "msm-pcm-routing",
  2351. .codec_name = "msm-stub-codec.1",
  2352. .codec_dai_name = "msm-stub-tx",
  2353. .no_pcm = 1,
  2354. .dpcm_capture = 1,
  2355. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  2356. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2357. .ops = &msm_tdm_be_ops,
  2358. .ignore_suspend = 1,
  2359. },
  2360. {
  2361. .name = LPASS_BE_TERT_TDM_RX_0,
  2362. .stream_name = "Tertiary TDM0 Playback",
  2363. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  2364. .platform_name = "msm-pcm-routing",
  2365. .codec_name = "msm-stub-codec.1",
  2366. .codec_dai_name = "msm-stub-rx",
  2367. .no_pcm = 1,
  2368. .dpcm_playback = 1,
  2369. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  2370. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2371. .ops = &msm_tdm_be_ops,
  2372. .ignore_suspend = 1,
  2373. },
  2374. {
  2375. .name = LPASS_BE_TERT_TDM_TX_0,
  2376. .stream_name = "Tertiary TDM0 Capture",
  2377. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  2378. .platform_name = "msm-pcm-routing",
  2379. .codec_name = "msm-stub-codec.1",
  2380. .codec_dai_name = "msm-stub-tx",
  2381. .no_pcm = 1,
  2382. .dpcm_capture = 1,
  2383. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  2384. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2385. .ops = &msm_tdm_be_ops,
  2386. .ignore_suspend = 1,
  2387. },
  2388. {
  2389. .name = LPASS_BE_QUAT_TDM_RX_0,
  2390. .stream_name = "Quaternary TDM0 Playback",
  2391. .cpu_dai_name = "msm-dai-q6-tdm.36912",
  2392. .platform_name = "msm-pcm-routing",
  2393. .codec_name = "msm-stub-codec.1",
  2394. .codec_dai_name = "msm-stub-rx",
  2395. .no_pcm = 1,
  2396. .dpcm_playback = 1,
  2397. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  2398. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2399. .ops = &msm_tdm_be_ops,
  2400. .ignore_suspend = 1,
  2401. },
  2402. {
  2403. .name = LPASS_BE_QUAT_TDM_TX_0,
  2404. .stream_name = "Quaternary TDM0 Capture",
  2405. .cpu_dai_name = "msm-dai-q6-tdm.36913",
  2406. .platform_name = "msm-pcm-routing",
  2407. .codec_name = "msm-stub-codec.1",
  2408. .codec_dai_name = "msm-stub-tx",
  2409. .no_pcm = 1,
  2410. .dpcm_capture = 1,
  2411. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  2412. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2413. .ops = &msm_tdm_be_ops,
  2414. .ignore_suspend = 1,
  2415. },
  2416. };
  2417. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  2418. {
  2419. .name = LPASS_BE_PRI_MI2S_RX,
  2420. .stream_name = "Primary MI2S Playback",
  2421. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  2422. .platform_name = "msm-pcm-routing",
  2423. .codec_name = "msm-stub-codec.1",
  2424. .codec_dai_name = "msm-stub-rx",
  2425. .no_pcm = 1,
  2426. .dpcm_playback = 1,
  2427. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  2428. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2429. .ops = &msm_mi2s_be_ops,
  2430. .ignore_suspend = 1,
  2431. .ignore_pmdown_time = 1,
  2432. },
  2433. {
  2434. .name = LPASS_BE_PRI_MI2S_TX,
  2435. .stream_name = "Primary MI2S Capture",
  2436. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  2437. .platform_name = "msm-pcm-routing",
  2438. .codec_name = "msm-stub-codec.1",
  2439. .codec_dai_name = "msm-stub-tx",
  2440. .no_pcm = 1,
  2441. .dpcm_capture = 1,
  2442. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  2443. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2444. .ops = &msm_mi2s_be_ops,
  2445. .ignore_suspend = 1,
  2446. },
  2447. {
  2448. .name = LPASS_BE_SEC_MI2S_RX,
  2449. .stream_name = "Secondary MI2S Playback",
  2450. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  2451. .platform_name = "msm-pcm-routing",
  2452. .codec_name = "msm-stub-codec.1",
  2453. .codec_dai_name = "msm-stub-rx",
  2454. .no_pcm = 1,
  2455. .dpcm_playback = 1,
  2456. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  2457. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2458. .ops = &msm_mi2s_be_ops,
  2459. .ignore_suspend = 1,
  2460. .ignore_pmdown_time = 1,
  2461. },
  2462. {
  2463. .name = LPASS_BE_SEC_MI2S_TX,
  2464. .stream_name = "Secondary MI2S Capture",
  2465. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  2466. .platform_name = "msm-pcm-routing",
  2467. .codec_name = "msm-stub-codec.1",
  2468. .codec_dai_name = "msm-stub-tx",
  2469. .no_pcm = 1,
  2470. .dpcm_capture = 1,
  2471. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  2472. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2473. .ops = &msm_mi2s_be_ops,
  2474. .ignore_suspend = 1,
  2475. },
  2476. {
  2477. .name = LPASS_BE_TERT_MI2S_RX,
  2478. .stream_name = "Tertiary MI2S Playback",
  2479. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  2480. .platform_name = "msm-pcm-routing",
  2481. .codec_name = "msm-stub-codec.1",
  2482. .codec_dai_name = "msm-stub-rx",
  2483. .no_pcm = 1,
  2484. .dpcm_playback = 1,
  2485. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  2486. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2487. .ops = &msm_mi2s_be_ops,
  2488. .ignore_suspend = 1,
  2489. .ignore_pmdown_time = 1,
  2490. },
  2491. {
  2492. .name = LPASS_BE_TERT_MI2S_TX,
  2493. .stream_name = "Tertiary MI2S Capture",
  2494. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  2495. .platform_name = "msm-pcm-routing",
  2496. .codec_name = "msm-stub-codec.1",
  2497. .codec_dai_name = "msm-stub-tx",
  2498. .no_pcm = 1,
  2499. .dpcm_capture = 1,
  2500. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  2501. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2502. .ops = &msm_mi2s_be_ops,
  2503. .ignore_suspend = 1,
  2504. },
  2505. {
  2506. .name = LPASS_BE_QUAT_MI2S_RX,
  2507. .stream_name = "Quaternary MI2S Playback",
  2508. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  2509. .platform_name = "msm-pcm-routing",
  2510. .codec_name = "msm-stub-codec.1",
  2511. .codec_dai_name = "msm-stub-rx",
  2512. .no_pcm = 1,
  2513. .dpcm_playback = 1,
  2514. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  2515. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2516. .ops = &msm_mi2s_be_ops,
  2517. .ignore_suspend = 1,
  2518. .ignore_pmdown_time = 1,
  2519. },
  2520. {
  2521. .name = LPASS_BE_QUAT_MI2S_TX,
  2522. .stream_name = "Quaternary MI2S Capture",
  2523. .cpu_dai_name = "msm-dai-q6-mi2s.3",
  2524. .platform_name = "msm-pcm-routing",
  2525. .codec_name = "msm-stub-codec.1",
  2526. .codec_dai_name = "msm-stub-tx",
  2527. .no_pcm = 1,
  2528. .dpcm_capture = 1,
  2529. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  2530. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2531. .ops = &msm_mi2s_be_ops,
  2532. .ignore_suspend = 1,
  2533. },
  2534. };
  2535. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  2536. /* Primary AUX PCM Backend DAI Links */
  2537. {
  2538. .name = LPASS_BE_AUXPCM_RX,
  2539. .stream_name = "AUX PCM Playback",
  2540. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  2541. .platform_name = "msm-pcm-routing",
  2542. .codec_name = "msm-stub-codec.1",
  2543. .codec_dai_name = "msm-stub-rx",
  2544. .no_pcm = 1,
  2545. .dpcm_playback = 1,
  2546. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  2547. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2548. .ignore_pmdown_time = 1,
  2549. .ignore_suspend = 1,
  2550. .ops = &msm_aux_pcm_be_ops,
  2551. },
  2552. {
  2553. .name = LPASS_BE_AUXPCM_TX,
  2554. .stream_name = "AUX PCM Capture",
  2555. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  2556. .platform_name = "msm-pcm-routing",
  2557. .codec_name = "msm-stub-codec.1",
  2558. .codec_dai_name = "msm-stub-tx",
  2559. .no_pcm = 1,
  2560. .dpcm_capture = 1,
  2561. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  2562. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2563. .ignore_pmdown_time = 1,
  2564. .ignore_suspend = 1,
  2565. .ops = &msm_aux_pcm_be_ops,
  2566. },
  2567. /* Secondary AUX PCM Backend DAI Links */
  2568. {
  2569. .name = LPASS_BE_SEC_AUXPCM_RX,
  2570. .stream_name = "Sec AUX PCM Playback",
  2571. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  2572. .platform_name = "msm-pcm-routing",
  2573. .codec_name = "msm-stub-codec.1",
  2574. .codec_dai_name = "msm-stub-rx",
  2575. .no_pcm = 1,
  2576. .dpcm_playback = 1,
  2577. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  2578. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2579. .ignore_pmdown_time = 1,
  2580. .ignore_suspend = 1,
  2581. .ops = &msm_aux_pcm_be_ops,
  2582. },
  2583. {
  2584. .name = LPASS_BE_SEC_AUXPCM_TX,
  2585. .stream_name = "Sec AUX PCM Capture",
  2586. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  2587. .platform_name = "msm-pcm-routing",
  2588. .codec_name = "msm-stub-codec.1",
  2589. .codec_dai_name = "msm-stub-tx",
  2590. .no_pcm = 1,
  2591. .dpcm_capture = 1,
  2592. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  2593. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2594. .ignore_suspend = 1,
  2595. .ignore_pmdown_time = 1,
  2596. .ops = &msm_aux_pcm_be_ops,
  2597. },
  2598. /* Tertiary AUX PCM Backend DAI Links */
  2599. {
  2600. .name = LPASS_BE_TERT_AUXPCM_RX,
  2601. .stream_name = "Tert AUX PCM Playback",
  2602. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  2603. .platform_name = "msm-pcm-routing",
  2604. .codec_name = "msm-stub-codec.1",
  2605. .codec_dai_name = "msm-stub-rx",
  2606. .no_pcm = 1,
  2607. .dpcm_playback = 1,
  2608. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  2609. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2610. .ignore_pmdown_time = 1,
  2611. .ignore_suspend = 1,
  2612. .ops = &msm_aux_pcm_be_ops,
  2613. },
  2614. {
  2615. .name = LPASS_BE_TERT_AUXPCM_TX,
  2616. .stream_name = "Tert AUX PCM Capture",
  2617. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  2618. .platform_name = "msm-pcm-routing",
  2619. .codec_name = "msm-stub-codec.1",
  2620. .codec_dai_name = "msm-stub-tx",
  2621. .no_pcm = 1,
  2622. .dpcm_capture = 1,
  2623. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  2624. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2625. .ignore_suspend = 1,
  2626. .ignore_pmdown_time = 1,
  2627. .ops = &msm_aux_pcm_be_ops,
  2628. },
  2629. /* Quaternary AUX PCM Backend DAI Links */
  2630. {
  2631. .name = LPASS_BE_QUAT_AUXPCM_RX,
  2632. .stream_name = "Quat AUX PCM Playback",
  2633. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  2634. .platform_name = "msm-pcm-routing",
  2635. .codec_name = "msm-stub-codec.1",
  2636. .codec_dai_name = "msm-stub-rx",
  2637. .no_pcm = 1,
  2638. .dpcm_playback = 1,
  2639. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  2640. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2641. .ignore_pmdown_time = 1,
  2642. .ignore_suspend = 1,
  2643. .ops = &msm_aux_pcm_be_ops,
  2644. },
  2645. {
  2646. .name = LPASS_BE_QUAT_AUXPCM_TX,
  2647. .stream_name = "Quat AUX PCM Capture",
  2648. .cpu_dai_name = "msm-dai-q6-auxpcm.4",
  2649. .platform_name = "msm-pcm-routing",
  2650. .codec_name = "msm-stub-codec.1",
  2651. .codec_dai_name = "msm-stub-tx",
  2652. .no_pcm = 1,
  2653. .dpcm_capture = 1,
  2654. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  2655. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2656. .ignore_suspend = 1,
  2657. .ignore_pmdown_time = 1,
  2658. .ops = &msm_aux_pcm_be_ops,
  2659. },
  2660. };
  2661. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  2662. {
  2663. .name = LPASS_BE_SLIMBUS_7_RX,
  2664. .stream_name = "Slimbus7 Playback",
  2665. .cpu_dai_name = "msm-dai-q6-dev.16398",
  2666. .platform_name = "msm-pcm-routing",
  2667. .codec_name = "btfmslim_slave",
  2668. /* BT codec driver determines capabilities based on
  2669. * dai name, bt codecdai name should always contains
  2670. * supported usecase information
  2671. */
  2672. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  2673. .no_pcm = 1,
  2674. .dpcm_playback = 1,
  2675. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  2676. .be_hw_params_fixup = msm_btfm_be_hw_params_fixup,
  2677. .ops = &msm_wcn_ops,
  2678. /* dai link has playback support */
  2679. .ignore_pmdown_time = 1,
  2680. .ignore_suspend = 1,
  2681. },
  2682. {
  2683. .name = LPASS_BE_SLIMBUS_7_TX,
  2684. .stream_name = "Slimbus7 Capture",
  2685. .cpu_dai_name = "msm-dai-q6-dev.16399",
  2686. .platform_name = "msm-pcm-routing",
  2687. .codec_name = "btfmslim_slave",
  2688. .codec_dai_name = "btfm_bt_sco_slim_tx",
  2689. .no_pcm = 1,
  2690. .dpcm_capture = 1,
  2691. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  2692. .be_hw_params_fixup = msm_btfm_be_hw_params_fixup,
  2693. .ops = &msm_wcn_ops,
  2694. .ignore_suspend = 1,
  2695. },
  2696. {
  2697. .name = LPASS_BE_SLIMBUS_8_TX,
  2698. .stream_name = "Slimbus8 Capture",
  2699. .cpu_dai_name = "msm-dai-q6-dev.16401",
  2700. .platform_name = "msm-pcm-routing",
  2701. .codec_name = "btfmslim_slave",
  2702. .codec_dai_name = "btfm_fm_slim_tx",
  2703. .no_pcm = 1,
  2704. .dpcm_capture = 1,
  2705. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  2706. .be_hw_params_fixup = msm_btfm_be_hw_params_fixup,
  2707. .init = &msm_wcn_init,
  2708. .ops = &msm_wcn_ops,
  2709. .ignore_suspend = 1,
  2710. },
  2711. };
  2712. static struct snd_soc_dai_link msm_wsa_be_dai_links[] = {
  2713. {
  2714. .name = LPASS_BE_INT4_MI2S_RX,
  2715. .stream_name = "INT4 MI2S Playback",
  2716. .cpu_dai_name = "msm-dai-q6-mi2s.11",
  2717. .platform_name = "msm-pcm-routing",
  2718. .codec_name = "msm_sdw_codec",
  2719. .codec_dai_name = "msm_sdw_i2s_rx1",
  2720. .no_pcm = 1,
  2721. .dpcm_playback = 1,
  2722. .id = MSM_BACKEND_DAI_INT4_MI2S_RX,
  2723. .init = &msm_sdw_audrx_init,
  2724. .be_hw_params_fixup = int_mi2s_be_hw_params_fixup,
  2725. .ops = &msm_sdw_mi2s_be_ops,
  2726. .ignore_suspend = 1,
  2727. },
  2728. };
  2729. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  2730. /* DISP PORT BACK END DAI Link */
  2731. {
  2732. .name = LPASS_BE_DISPLAY_PORT,
  2733. .stream_name = "Display Port Playback",
  2734. .cpu_dai_name = "msm-dai-q6-dp.24608",
  2735. .platform_name = "msm-pcm-routing",
  2736. .codec_name = "msm-ext-disp-audio-codec-rx",
  2737. .codec_dai_name = "msm_dp_audio_codec_rx_dai",
  2738. .no_pcm = 1,
  2739. .dpcm_playback = 1,
  2740. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  2741. .be_hw_params_fixup = msm_common_be_hw_params_fixup,
  2742. .ignore_pmdown_time = 1,
  2743. .ignore_suspend = 1,
  2744. },
  2745. };
  2746. static struct snd_soc_dai_link msm_int_dai_links[
  2747. ARRAY_SIZE(msm_int_dai) +
  2748. ARRAY_SIZE(msm_int_wsa_dai) +
  2749. ARRAY_SIZE(msm_int_be_dai) +
  2750. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  2751. ARRAY_SIZE(msm_auxpcm_be_dai_links)+
  2752. ARRAY_SIZE(msm_wcn_be_dai_links) +
  2753. ARRAY_SIZE(msm_wsa_be_dai_links) +
  2754. ARRAY_SIZE(ext_disp_be_dai_link)];
  2755. static struct snd_soc_card sdm660_card = {
  2756. /* snd_soc_card_sdm660 */
  2757. .name = "sdm660-snd-card",
  2758. .dai_link = msm_int_dai,
  2759. .num_links = ARRAY_SIZE(msm_int_dai),
  2760. .late_probe = msm_snd_card_late_probe,
  2761. };
  2762. static void msm_disable_int_mclk0(struct work_struct *work)
  2763. {
  2764. struct msm_asoc_mach_data *pdata = NULL;
  2765. struct delayed_work *dwork;
  2766. int ret = 0;
  2767. dwork = to_delayed_work(work);
  2768. pdata = container_of(dwork, struct msm_asoc_mach_data,
  2769. disable_int_mclk0_work);
  2770. mutex_lock(&pdata->cdc_int_mclk0_mutex);
  2771. pr_debug("%s: mclk_enabled %d mclk_rsc_ref %d\n", __func__,
  2772. atomic_read(&pdata->int_mclk0_enabled),
  2773. atomic_read(&pdata->int_mclk0_rsc_ref));
  2774. if (atomic_read(&pdata->int_mclk0_enabled) == true
  2775. && atomic_read(&pdata->int_mclk0_rsc_ref) == 0) {
  2776. pr_debug("Disable the mclk\n");
  2777. pdata->digital_cdc_core_clk.enable = 0;
  2778. ret = afe_set_lpass_clock_v2(
  2779. AFE_PORT_ID_INT0_MI2S_RX,
  2780. &pdata->digital_cdc_core_clk);
  2781. if (ret < 0)
  2782. pr_err("%s failed to disable the CCLK\n", __func__);
  2783. atomic_set(&pdata->int_mclk0_enabled, false);
  2784. }
  2785. mutex_unlock(&pdata->cdc_int_mclk0_mutex);
  2786. }
  2787. static void msm_int_dt_parse_cap_info(struct platform_device *pdev,
  2788. struct msm_asoc_mach_data *pdata)
  2789. {
  2790. const char *ext1_cap = "qcom,msm-micbias1-ext-cap";
  2791. const char *ext2_cap = "qcom,msm-micbias2-ext-cap";
  2792. pdata->micbias1_cap_mode =
  2793. (of_property_read_bool(pdev->dev.of_node, ext1_cap) ?
  2794. MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP);
  2795. pdata->micbias2_cap_mode =
  2796. (of_property_read_bool(pdev->dev.of_node, ext2_cap) ?
  2797. MICBIAS_EXT_BYP_CAP : MICBIAS_NO_EXT_BYP_CAP);
  2798. }
  2799. static struct snd_soc_card *msm_int_populate_sndcard_dailinks(
  2800. struct device *dev)
  2801. {
  2802. struct snd_soc_card *card = &sdm660_card;
  2803. struct snd_soc_dai_link *dailink;
  2804. int len1;
  2805. card->name = dev_name(dev);
  2806. len1 = ARRAY_SIZE(msm_int_dai);
  2807. memcpy(msm_int_dai_links, msm_int_dai, sizeof(msm_int_dai));
  2808. dailink = msm_int_dai_links;
  2809. if (!of_property_read_bool(dev->of_node,
  2810. "qcom,wsa-disable")) {
  2811. memcpy(dailink + len1,
  2812. msm_int_wsa_dai,
  2813. sizeof(msm_int_wsa_dai));
  2814. len1 += ARRAY_SIZE(msm_int_wsa_dai);
  2815. }
  2816. memcpy(dailink + len1, msm_int_be_dai, sizeof(msm_int_be_dai));
  2817. len1 += ARRAY_SIZE(msm_int_be_dai);
  2818. if (of_property_read_bool(dev->of_node,
  2819. "qcom,mi2s-audio-intf")) {
  2820. memcpy(dailink + len1,
  2821. msm_mi2s_be_dai_links,
  2822. sizeof(msm_mi2s_be_dai_links));
  2823. len1 += ARRAY_SIZE(msm_mi2s_be_dai_links);
  2824. }
  2825. if (of_property_read_bool(dev->of_node,
  2826. "qcom,auxpcm-audio-intf")) {
  2827. memcpy(dailink + len1,
  2828. msm_auxpcm_be_dai_links,
  2829. sizeof(msm_auxpcm_be_dai_links));
  2830. len1 += ARRAY_SIZE(msm_auxpcm_be_dai_links);
  2831. }
  2832. if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
  2833. dev_dbg(dev, "%s(): WCN BTFM support present\n",
  2834. __func__);
  2835. memcpy(dailink + len1,
  2836. msm_wcn_be_dai_links,
  2837. sizeof(msm_wcn_be_dai_links));
  2838. len1 += ARRAY_SIZE(msm_wcn_be_dai_links);
  2839. }
  2840. if (!of_property_read_bool(dev->of_node, "qcom,wsa-disable")) {
  2841. memcpy(dailink + len1,
  2842. msm_wsa_be_dai_links,
  2843. sizeof(msm_wsa_be_dai_links));
  2844. len1 += ARRAY_SIZE(msm_wsa_be_dai_links);
  2845. }
  2846. if (of_property_read_bool(dev->of_node, "qcom,ext-disp-audio-rx")) {
  2847. dev_dbg(dev, "%s(): ext disp audio support present\n",
  2848. __func__);
  2849. memcpy(dailink + len1,
  2850. ext_disp_be_dai_link,
  2851. sizeof(ext_disp_be_dai_link));
  2852. len1 += ARRAY_SIZE(ext_disp_be_dai_link);
  2853. }
  2854. card->dai_link = dailink;
  2855. card->num_links = len1;
  2856. return card;
  2857. }
  2858. static int msm_internal_init(struct platform_device *pdev,
  2859. struct msm_asoc_mach_data *pdata,
  2860. struct snd_soc_card *card)
  2861. {
  2862. const char *type = NULL;
  2863. const char *hs_micbias_type = "qcom,msm-hs-micbias-type";
  2864. int ret;
  2865. ret = is_ext_spk_gpio_support(pdev, pdata);
  2866. if (ret < 0)
  2867. dev_dbg(&pdev->dev,
  2868. "%s: doesn't support external speaker pa\n",
  2869. __func__);
  2870. ret = of_property_read_string(pdev->dev.of_node,
  2871. hs_micbias_type, &type);
  2872. if (ret) {
  2873. dev_err(&pdev->dev, "%s: missing %s in dt node\n",
  2874. __func__, hs_micbias_type);
  2875. goto err;
  2876. }
  2877. if (!strcmp(type, "external")) {
  2878. dev_dbg(&pdev->dev, "Headset is using external micbias\n");
  2879. mbhc_cfg_ptr->hs_ext_micbias = true;
  2880. } else {
  2881. dev_dbg(&pdev->dev, "Headset is using internal micbias\n");
  2882. mbhc_cfg_ptr->hs_ext_micbias = false;
  2883. }
  2884. /* initialize the int_mclk0 */
  2885. pdata->digital_cdc_core_clk.clk_set_minor_version =
  2886. AFE_API_VERSION_I2S_CONFIG;
  2887. pdata->digital_cdc_core_clk.clk_id =
  2888. Q6AFE_LPASS_CLK_ID_INT_MCLK_0;
  2889. pdata->digital_cdc_core_clk.clk_freq_in_hz = pdata->mclk_freq;
  2890. pdata->digital_cdc_core_clk.clk_attri =
  2891. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO;
  2892. pdata->digital_cdc_core_clk.clk_root =
  2893. Q6AFE_LPASS_CLK_ROOT_DEFAULT;
  2894. pdata->digital_cdc_core_clk.enable = 1;
  2895. /* Initialize loopback mode to false */
  2896. pdata->lb_mode = false;
  2897. msm_int_dt_parse_cap_info(pdev, pdata);
  2898. card->dev = &pdev->dev;
  2899. platform_set_drvdata(pdev, card);
  2900. snd_soc_card_set_drvdata(card, pdata);
  2901. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  2902. if (ret)
  2903. goto err;
  2904. /* initialize timer */
  2905. INIT_DELAYED_WORK(&pdata->disable_int_mclk0_work,
  2906. msm_disable_int_mclk0);
  2907. mutex_init(&pdata->cdc_int_mclk0_mutex);
  2908. atomic_set(&pdata->int_mclk0_rsc_ref, 0);
  2909. atomic_set(&pdata->int_mclk0_enabled, false);
  2910. dev_info(&pdev->dev, "%s: default codec configured\n", __func__);
  2911. return 0;
  2912. err:
  2913. return ret;
  2914. }
  2915. /**
  2916. * msm_int_cdc_init - internal codec machine specific init.
  2917. *
  2918. * @pdev: platform device handle
  2919. * @pdata: private data of machine driver
  2920. * @card: sound card pointer reference
  2921. * @mbhc_cfg: MBHC config reference
  2922. *
  2923. * Returns 0.
  2924. */
  2925. int msm_int_cdc_init(struct platform_device *pdev,
  2926. struct msm_asoc_mach_data *pdata,
  2927. struct snd_soc_card **card,
  2928. struct wcd_mbhc_config *mbhc_cfg)
  2929. {
  2930. mbhc_cfg_ptr = mbhc_cfg;
  2931. *card = msm_int_populate_sndcard_dailinks(&pdev->dev);
  2932. msm_internal_init(pdev, pdata, *card);
  2933. return 0;
  2934. }
  2935. EXPORT_SYMBOL(msm_int_cdc_init);