sdm660-internal.c 90 KB

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