sdm660-internal.c 90 KB

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