sdm660-internal.c 87 KB

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