kona.c 171 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/delay.h>
  7. #include <linux/gpio.h>
  8. #include <linux/of_gpio.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/slab.h>
  11. #include <linux/io.h>
  12. #include <linux/module.h>
  13. #include <linux/input.h>
  14. #include <linux/of_device.h>
  15. #include <linux/soc/qcom/fsa4480-i2c.h>
  16. #include <sound/core.h>
  17. #include <sound/soc.h>
  18. #include <sound/soc-dapm.h>
  19. #include <sound/pcm.h>
  20. #include <sound/pcm_params.h>
  21. #include <sound/info.h>
  22. #include <soc/snd_event.h>
  23. #include <dsp/audio_notifier.h>
  24. #include <soc/swr-common.h>
  25. #include <dsp/q6afe-v2.h>
  26. #include <dsp/q6core.h>
  27. #include "device_event.h"
  28. #include "msm-pcm-routing-v2.h"
  29. #include "asoc/msm-cdc-pinctrl.h"
  30. #include "asoc/wcd-mbhc-v2.h"
  31. #include "codecs/wcd938x/wcd938x-mbhc.h"
  32. #include "codecs/wsa881x.h"
  33. #include "codecs/wcd938x/wcd938x.h"
  34. #include "codecs/bolero/bolero-cdc.h"
  35. #include <dt-bindings/sound/audio-codec-port-types.h>
  36. #include "codecs/bolero/wsa-macro.h"
  37. #include "sm8250-port-config.h"
  38. #define DRV_NAME "kona-asoc-snd"
  39. #define __CHIPSET__ "KONA "
  40. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  41. #define SAMPLING_RATE_8KHZ 8000
  42. #define SAMPLING_RATE_11P025KHZ 11025
  43. #define SAMPLING_RATE_16KHZ 16000
  44. #define SAMPLING_RATE_22P05KHZ 22050
  45. #define SAMPLING_RATE_32KHZ 32000
  46. #define SAMPLING_RATE_44P1KHZ 44100
  47. #define SAMPLING_RATE_48KHZ 48000
  48. #define SAMPLING_RATE_88P2KHZ 88200
  49. #define SAMPLING_RATE_96KHZ 96000
  50. #define SAMPLING_RATE_176P4KHZ 176400
  51. #define SAMPLING_RATE_192KHZ 192000
  52. #define SAMPLING_RATE_352P8KHZ 352800
  53. #define SAMPLING_RATE_384KHZ 384000
  54. #define WCD9XXX_MBHC_DEF_RLOADS 5
  55. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  56. #define CODEC_EXT_CLK_RATE 9600000
  57. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  58. #define DEV_NAME_STR_LEN 32
  59. #define WCD_MBHC_HS_V_MAX 1600
  60. #define TDM_CHANNEL_MAX 8
  61. #define DEV_NAME_STR_LEN 32
  62. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  63. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  64. #define WSA8810_NAME_1 "wsa881x.20170211"
  65. #define WSA8810_NAME_2 "wsa881x.20170212"
  66. #define WCN_CDC_SLIM_RX_CH_MAX 2
  67. #define WCN_CDC_SLIM_TX_CH_MAX 2
  68. enum {
  69. TDM_0 = 0,
  70. TDM_1,
  71. TDM_2,
  72. TDM_3,
  73. TDM_4,
  74. TDM_5,
  75. TDM_6,
  76. TDM_7,
  77. TDM_PORT_MAX,
  78. };
  79. enum {
  80. TDM_PRI = 0,
  81. TDM_SEC,
  82. TDM_TERT,
  83. TDM_INTERFACE_MAX,
  84. };
  85. enum {
  86. PRIM_AUX_PCM = 0,
  87. SEC_AUX_PCM,
  88. TERT_AUX_PCM,
  89. AUX_PCM_MAX,
  90. };
  91. enum {
  92. PRIM_MI2S = 0,
  93. SEC_MI2S,
  94. TERT_MI2S,
  95. MI2S_MAX,
  96. };
  97. enum {
  98. WSA_CDC_DMA_RX_0 = 0,
  99. WSA_CDC_DMA_RX_1,
  100. RX_CDC_DMA_RX_0,
  101. RX_CDC_DMA_RX_1,
  102. RX_CDC_DMA_RX_2,
  103. RX_CDC_DMA_RX_3,
  104. RX_CDC_DMA_RX_5,
  105. CDC_DMA_RX_MAX,
  106. };
  107. enum {
  108. WSA_CDC_DMA_TX_0 = 0,
  109. WSA_CDC_DMA_TX_1,
  110. WSA_CDC_DMA_TX_2,
  111. TX_CDC_DMA_TX_0,
  112. TX_CDC_DMA_TX_3,
  113. TX_CDC_DMA_TX_4,
  114. VA_CDC_DMA_TX_0,
  115. VA_CDC_DMA_TX_1,
  116. VA_CDC_DMA_TX_2,
  117. CDC_DMA_TX_MAX,
  118. };
  119. struct msm_asoc_mach_data {
  120. struct snd_info_entry *codec_root;
  121. int usbc_en2_gpio; /* used by gpio driver API */
  122. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  123. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  124. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  125. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  126. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  127. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  128. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  129. bool is_afe_config_done;
  130. struct device_node *fsa_handle;
  131. };
  132. struct tdm_port {
  133. u32 mode;
  134. u32 channel;
  135. };
  136. enum {
  137. EXT_DISP_RX_IDX_DP = 0,
  138. EXT_DISP_RX_IDX_MAX,
  139. };
  140. struct msm_wsa881x_dev_info {
  141. struct device_node *of_node;
  142. u32 index;
  143. };
  144. struct aux_codec_dev_info {
  145. struct device_node *of_node;
  146. u32 index;
  147. };
  148. struct dev_config {
  149. u32 sample_rate;
  150. u32 bit_format;
  151. u32 channels;
  152. };
  153. /* Default configuration of external display BE */
  154. static struct dev_config ext_disp_rx_cfg[] = {
  155. [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  156. };
  157. static struct dev_config usb_rx_cfg = {
  158. .sample_rate = SAMPLING_RATE_48KHZ,
  159. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  160. .channels = 2,
  161. };
  162. static struct dev_config usb_tx_cfg = {
  163. .sample_rate = SAMPLING_RATE_48KHZ,
  164. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  165. .channels = 1,
  166. };
  167. static struct dev_config proxy_rx_cfg = {
  168. .sample_rate = SAMPLING_RATE_48KHZ,
  169. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  170. .channels = 2,
  171. };
  172. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  173. {
  174. AFE_API_VERSION_I2S_CONFIG,
  175. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  176. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  177. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  178. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  179. 0,
  180. },
  181. {
  182. AFE_API_VERSION_I2S_CONFIG,
  183. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  184. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  185. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  186. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  187. 0,
  188. },
  189. {
  190. AFE_API_VERSION_I2S_CONFIG,
  191. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  192. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  193. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  194. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  195. 0,
  196. },
  197. };
  198. struct mi2s_conf {
  199. struct mutex lock;
  200. u32 ref_cnt;
  201. u32 msm_is_mi2s_master;
  202. };
  203. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  204. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  205. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  206. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  207. };
  208. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  209. /* Default configuration of TDM channels */
  210. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  211. { /* PRI TDM */
  212. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  213. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  214. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  215. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  216. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  217. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  218. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  219. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  220. },
  221. { /* SEC TDM */
  222. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  223. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  224. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  225. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  226. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  227. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  228. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  229. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  230. },
  231. { /* TERT TDM */
  232. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  233. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  234. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  235. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  236. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  237. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  238. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  239. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  240. },
  241. };
  242. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  243. { /* PRI TDM */
  244. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  245. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  246. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  247. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  248. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  249. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  250. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  251. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  252. },
  253. { /* SEC TDM */
  254. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  255. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  256. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  257. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  258. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  259. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  260. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  261. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  262. },
  263. { /* TERT TDM */
  264. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  265. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  266. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  267. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  268. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  269. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  270. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  271. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  272. },
  273. };
  274. /* Default configuration of AUX PCM channels */
  275. static struct dev_config aux_pcm_rx_cfg[] = {
  276. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  277. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  278. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  279. };
  280. static struct dev_config aux_pcm_tx_cfg[] = {
  281. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  282. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  283. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  284. };
  285. /* Default configuration of MI2S channels */
  286. static struct dev_config mi2s_rx_cfg[] = {
  287. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  288. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  289. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  290. };
  291. static struct dev_config mi2s_tx_cfg[] = {
  292. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  293. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  294. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  295. };
  296. /* Default configuration of Codec DMA Interface RX */
  297. static struct dev_config cdc_dma_rx_cfg[] = {
  298. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  299. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  300. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  301. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  302. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  303. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  304. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  305. };
  306. /* Default configuration of Codec DMA Interface TX */
  307. static struct dev_config cdc_dma_tx_cfg[] = {
  308. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  309. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  310. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  311. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  312. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  313. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  314. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  315. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  316. [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  317. };
  318. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  319. "S32_LE"};
  320. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  321. "Six", "Seven", "Eight"};
  322. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  323. "KHZ_16", "KHZ_22P05",
  324. "KHZ_32", "KHZ_44P1", "KHZ_48",
  325. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  326. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  327. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  328. "Five", "Six", "Seven",
  329. "Eight"};
  330. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  331. "KHZ_48", "KHZ_176P4",
  332. "KHZ_352P8"};
  333. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  334. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  335. "Five", "Six", "Seven", "Eight"};
  336. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  337. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  338. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  339. "KHZ_48", "KHZ_96", "KHZ_192"};
  340. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  341. "Five", "Six", "Seven",
  342. "Eight"};
  343. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  344. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  345. "Five", "Six", "Seven",
  346. "Eight"};
  347. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  348. "KHZ_16", "KHZ_22P05",
  349. "KHZ_32", "KHZ_44P1", "KHZ_48",
  350. "KHZ_88P2", "KHZ_96",
  351. "KHZ_176P4", "KHZ_192",
  352. "KHZ_352P8", "KHZ_384"};
  353. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  354. "S24_3LE"};
  355. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  356. "KHZ_192", "KHZ_32", "KHZ_44P1",
  357. "KHZ_88P2", "KHZ_176P4"};
  358. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  359. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  360. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  361. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  362. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  363. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  364. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  365. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  366. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  367. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  368. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  369. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  370. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  371. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  372. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  373. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  374. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  375. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  376. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  377. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  378. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  379. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  380. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  381. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  382. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  383. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  384. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  385. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  386. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  387. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  388. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  389. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  390. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  391. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  392. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  393. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  394. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  395. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  396. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  397. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  398. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  399. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  400. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  401. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  402. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  403. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  404. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  405. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  406. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  407. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  408. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  409. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  410. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  411. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_format, bit_format_text);
  412. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_format, bit_format_text);
  413. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_format, bit_format_text);
  414. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_format, bit_format_text);
  415. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_format, bit_format_text);
  416. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  417. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  418. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  419. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  420. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  421. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  422. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  423. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
  424. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  425. cdc_dma_sample_rate_text);
  426. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  427. cdc_dma_sample_rate_text);
  428. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_sample_rate,
  429. cdc_dma_sample_rate_text);
  430. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_sample_rate,
  431. cdc_dma_sample_rate_text);
  432. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_sample_rate,
  433. cdc_dma_sample_rate_text);
  434. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_sample_rate,
  435. cdc_dma_sample_rate_text);
  436. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_sample_rate,
  437. cdc_dma_sample_rate_text);
  438. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  439. cdc_dma_sample_rate_text);
  440. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  441. cdc_dma_sample_rate_text);
  442. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  443. cdc_dma_sample_rate_text);
  444. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  445. cdc_dma_sample_rate_text);
  446. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  447. cdc_dma_sample_rate_text);
  448. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  449. cdc_dma_sample_rate_text);
  450. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  451. cdc_dma_sample_rate_text);
  452. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  453. cdc_dma_sample_rate_text);
  454. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
  455. cdc_dma_sample_rate_text);
  456. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  457. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  458. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  459. ext_disp_sample_rate_text);
  460. static bool is_initial_boot;
  461. static bool codec_reg_done;
  462. static struct snd_soc_aux_dev *msm_aux_dev;
  463. static struct snd_soc_codec_conf *msm_codec_conf;
  464. static struct snd_soc_card snd_soc_card_kona_msm;
  465. static int dmic_0_1_gpio_cnt;
  466. static int dmic_2_3_gpio_cnt;
  467. static int dmic_4_5_gpio_cnt;
  468. static int msm_vi_feed_tx_ch = 2;
  469. static void *def_wcd_mbhc_cal(void);
  470. /*
  471. * Need to report LINEIN
  472. * if R/L channel impedance is larger than 5K ohm
  473. */
  474. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  475. .read_fw_bin = false,
  476. .calibration = NULL,
  477. .detect_extn_cable = true,
  478. .mono_stero_detection = false,
  479. .swap_gnd_mic = NULL,
  480. .hs_ext_micbias = true,
  481. .key_code[0] = KEY_MEDIA,
  482. .key_code[1] = KEY_VOICECOMMAND,
  483. .key_code[2] = KEY_VOLUMEUP,
  484. .key_code[3] = KEY_VOLUMEDOWN,
  485. .key_code[4] = 0,
  486. .key_code[5] = 0,
  487. .key_code[6] = 0,
  488. .key_code[7] = 0,
  489. .linein_th = 5000,
  490. .moisture_en = true,
  491. .mbhc_micbias = MIC_BIAS_2,
  492. .anc_micbias = MIC_BIAS_2,
  493. .enable_anc_mic_detect = false,
  494. };
  495. static inline int param_is_mask(int p)
  496. {
  497. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  498. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  499. }
  500. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  501. int n)
  502. {
  503. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  504. }
  505. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  506. unsigned int bit)
  507. {
  508. if (bit >= SNDRV_MASK_MAX)
  509. return;
  510. if (param_is_mask(n)) {
  511. struct snd_mask *m = param_to_mask(p, n);
  512. m->bits[0] = 0;
  513. m->bits[1] = 0;
  514. m->bits[bit >> 5] |= (1 << (bit & 31));
  515. }
  516. }
  517. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  518. struct snd_ctl_elem_value *ucontrol)
  519. {
  520. int sample_rate_val = 0;
  521. switch (usb_rx_cfg.sample_rate) {
  522. case SAMPLING_RATE_384KHZ:
  523. sample_rate_val = 12;
  524. break;
  525. case SAMPLING_RATE_352P8KHZ:
  526. sample_rate_val = 11;
  527. break;
  528. case SAMPLING_RATE_192KHZ:
  529. sample_rate_val = 10;
  530. break;
  531. case SAMPLING_RATE_176P4KHZ:
  532. sample_rate_val = 9;
  533. break;
  534. case SAMPLING_RATE_96KHZ:
  535. sample_rate_val = 8;
  536. break;
  537. case SAMPLING_RATE_88P2KHZ:
  538. sample_rate_val = 7;
  539. break;
  540. case SAMPLING_RATE_48KHZ:
  541. sample_rate_val = 6;
  542. break;
  543. case SAMPLING_RATE_44P1KHZ:
  544. sample_rate_val = 5;
  545. break;
  546. case SAMPLING_RATE_32KHZ:
  547. sample_rate_val = 4;
  548. break;
  549. case SAMPLING_RATE_22P05KHZ:
  550. sample_rate_val = 3;
  551. break;
  552. case SAMPLING_RATE_16KHZ:
  553. sample_rate_val = 2;
  554. break;
  555. case SAMPLING_RATE_11P025KHZ:
  556. sample_rate_val = 1;
  557. break;
  558. case SAMPLING_RATE_8KHZ:
  559. default:
  560. sample_rate_val = 0;
  561. break;
  562. }
  563. ucontrol->value.integer.value[0] = sample_rate_val;
  564. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  565. usb_rx_cfg.sample_rate);
  566. return 0;
  567. }
  568. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  569. struct snd_ctl_elem_value *ucontrol)
  570. {
  571. switch (ucontrol->value.integer.value[0]) {
  572. case 12:
  573. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  574. break;
  575. case 11:
  576. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  577. break;
  578. case 10:
  579. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  580. break;
  581. case 9:
  582. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  583. break;
  584. case 8:
  585. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  586. break;
  587. case 7:
  588. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  589. break;
  590. case 6:
  591. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  592. break;
  593. case 5:
  594. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  595. break;
  596. case 4:
  597. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  598. break;
  599. case 3:
  600. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  601. break;
  602. case 2:
  603. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  604. break;
  605. case 1:
  606. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  607. break;
  608. case 0:
  609. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  610. break;
  611. default:
  612. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  613. break;
  614. }
  615. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  616. __func__, ucontrol->value.integer.value[0],
  617. usb_rx_cfg.sample_rate);
  618. return 0;
  619. }
  620. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  621. struct snd_ctl_elem_value *ucontrol)
  622. {
  623. int sample_rate_val = 0;
  624. switch (usb_tx_cfg.sample_rate) {
  625. case SAMPLING_RATE_384KHZ:
  626. sample_rate_val = 12;
  627. break;
  628. case SAMPLING_RATE_352P8KHZ:
  629. sample_rate_val = 11;
  630. break;
  631. case SAMPLING_RATE_192KHZ:
  632. sample_rate_val = 10;
  633. break;
  634. case SAMPLING_RATE_176P4KHZ:
  635. sample_rate_val = 9;
  636. break;
  637. case SAMPLING_RATE_96KHZ:
  638. sample_rate_val = 8;
  639. break;
  640. case SAMPLING_RATE_88P2KHZ:
  641. sample_rate_val = 7;
  642. break;
  643. case SAMPLING_RATE_48KHZ:
  644. sample_rate_val = 6;
  645. break;
  646. case SAMPLING_RATE_44P1KHZ:
  647. sample_rate_val = 5;
  648. break;
  649. case SAMPLING_RATE_32KHZ:
  650. sample_rate_val = 4;
  651. break;
  652. case SAMPLING_RATE_22P05KHZ:
  653. sample_rate_val = 3;
  654. break;
  655. case SAMPLING_RATE_16KHZ:
  656. sample_rate_val = 2;
  657. break;
  658. case SAMPLING_RATE_11P025KHZ:
  659. sample_rate_val = 1;
  660. break;
  661. case SAMPLING_RATE_8KHZ:
  662. sample_rate_val = 0;
  663. break;
  664. default:
  665. sample_rate_val = 6;
  666. break;
  667. }
  668. ucontrol->value.integer.value[0] = sample_rate_val;
  669. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  670. usb_tx_cfg.sample_rate);
  671. return 0;
  672. }
  673. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  674. struct snd_ctl_elem_value *ucontrol)
  675. {
  676. switch (ucontrol->value.integer.value[0]) {
  677. case 12:
  678. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  679. break;
  680. case 11:
  681. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  682. break;
  683. case 10:
  684. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  685. break;
  686. case 9:
  687. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  688. break;
  689. case 8:
  690. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  691. break;
  692. case 7:
  693. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  694. break;
  695. case 6:
  696. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  697. break;
  698. case 5:
  699. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  700. break;
  701. case 4:
  702. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  703. break;
  704. case 3:
  705. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  706. break;
  707. case 2:
  708. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  709. break;
  710. case 1:
  711. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  712. break;
  713. case 0:
  714. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  715. break;
  716. default:
  717. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  718. break;
  719. }
  720. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  721. __func__, ucontrol->value.integer.value[0],
  722. usb_tx_cfg.sample_rate);
  723. return 0;
  724. }
  725. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  726. struct snd_ctl_elem_value *ucontrol)
  727. {
  728. switch (usb_rx_cfg.bit_format) {
  729. case SNDRV_PCM_FORMAT_S32_LE:
  730. ucontrol->value.integer.value[0] = 3;
  731. break;
  732. case SNDRV_PCM_FORMAT_S24_3LE:
  733. ucontrol->value.integer.value[0] = 2;
  734. break;
  735. case SNDRV_PCM_FORMAT_S24_LE:
  736. ucontrol->value.integer.value[0] = 1;
  737. break;
  738. case SNDRV_PCM_FORMAT_S16_LE:
  739. default:
  740. ucontrol->value.integer.value[0] = 0;
  741. break;
  742. }
  743. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  744. __func__, usb_rx_cfg.bit_format,
  745. ucontrol->value.integer.value[0]);
  746. return 0;
  747. }
  748. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  749. struct snd_ctl_elem_value *ucontrol)
  750. {
  751. int rc = 0;
  752. switch (ucontrol->value.integer.value[0]) {
  753. case 3:
  754. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  755. break;
  756. case 2:
  757. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  758. break;
  759. case 1:
  760. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  761. break;
  762. case 0:
  763. default:
  764. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  765. break;
  766. }
  767. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  768. __func__, usb_rx_cfg.bit_format,
  769. ucontrol->value.integer.value[0]);
  770. return rc;
  771. }
  772. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  773. struct snd_ctl_elem_value *ucontrol)
  774. {
  775. switch (usb_tx_cfg.bit_format) {
  776. case SNDRV_PCM_FORMAT_S32_LE:
  777. ucontrol->value.integer.value[0] = 3;
  778. break;
  779. case SNDRV_PCM_FORMAT_S24_3LE:
  780. ucontrol->value.integer.value[0] = 2;
  781. break;
  782. case SNDRV_PCM_FORMAT_S24_LE:
  783. ucontrol->value.integer.value[0] = 1;
  784. break;
  785. case SNDRV_PCM_FORMAT_S16_LE:
  786. default:
  787. ucontrol->value.integer.value[0] = 0;
  788. break;
  789. }
  790. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  791. __func__, usb_tx_cfg.bit_format,
  792. ucontrol->value.integer.value[0]);
  793. return 0;
  794. }
  795. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  796. struct snd_ctl_elem_value *ucontrol)
  797. {
  798. int rc = 0;
  799. switch (ucontrol->value.integer.value[0]) {
  800. case 3:
  801. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  802. break;
  803. case 2:
  804. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  805. break;
  806. case 1:
  807. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  808. break;
  809. case 0:
  810. default:
  811. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  812. break;
  813. }
  814. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  815. __func__, usb_tx_cfg.bit_format,
  816. ucontrol->value.integer.value[0]);
  817. return rc;
  818. }
  819. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  820. struct snd_ctl_elem_value *ucontrol)
  821. {
  822. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  823. usb_rx_cfg.channels);
  824. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  825. return 0;
  826. }
  827. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  828. struct snd_ctl_elem_value *ucontrol)
  829. {
  830. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  831. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  832. return 1;
  833. }
  834. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  835. struct snd_ctl_elem_value *ucontrol)
  836. {
  837. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  838. usb_tx_cfg.channels);
  839. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  840. return 0;
  841. }
  842. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  843. struct snd_ctl_elem_value *ucontrol)
  844. {
  845. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  846. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  847. return 1;
  848. }
  849. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  850. {
  851. int idx = 0;
  852. if (strnstr(kcontrol->id.name, "Display Port RX",
  853. sizeof("Display Port RX"))) {
  854. idx = EXT_DISP_RX_IDX_DP;
  855. } else {
  856. pr_err("%s: unsupported BE: %s\n",
  857. __func__, kcontrol->id.name);
  858. idx = -EINVAL;
  859. }
  860. return idx;
  861. }
  862. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  863. struct snd_ctl_elem_value *ucontrol)
  864. {
  865. int idx = ext_disp_get_port_idx(kcontrol);
  866. if (idx < 0)
  867. return idx;
  868. switch (ext_disp_rx_cfg[idx].bit_format) {
  869. case SNDRV_PCM_FORMAT_S24_3LE:
  870. ucontrol->value.integer.value[0] = 2;
  871. break;
  872. case SNDRV_PCM_FORMAT_S24_LE:
  873. ucontrol->value.integer.value[0] = 1;
  874. break;
  875. case SNDRV_PCM_FORMAT_S16_LE:
  876. default:
  877. ucontrol->value.integer.value[0] = 0;
  878. break;
  879. }
  880. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  881. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  882. ucontrol->value.integer.value[0]);
  883. return 0;
  884. }
  885. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  886. struct snd_ctl_elem_value *ucontrol)
  887. {
  888. int idx = ext_disp_get_port_idx(kcontrol);
  889. if (idx < 0)
  890. return idx;
  891. switch (ucontrol->value.integer.value[0]) {
  892. case 2:
  893. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  894. break;
  895. case 1:
  896. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  897. break;
  898. case 0:
  899. default:
  900. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  901. break;
  902. }
  903. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  904. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  905. ucontrol->value.integer.value[0]);
  906. return 0;
  907. }
  908. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  909. struct snd_ctl_elem_value *ucontrol)
  910. {
  911. int idx = ext_disp_get_port_idx(kcontrol);
  912. if (idx < 0)
  913. return idx;
  914. ucontrol->value.integer.value[0] =
  915. ext_disp_rx_cfg[idx].channels - 2;
  916. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  917. idx, ext_disp_rx_cfg[idx].channels);
  918. return 0;
  919. }
  920. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  921. struct snd_ctl_elem_value *ucontrol)
  922. {
  923. int idx = ext_disp_get_port_idx(kcontrol);
  924. if (idx < 0)
  925. return idx;
  926. ext_disp_rx_cfg[idx].channels =
  927. ucontrol->value.integer.value[0] + 2;
  928. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  929. idx, ext_disp_rx_cfg[idx].channels);
  930. return 1;
  931. }
  932. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  933. struct snd_ctl_elem_value *ucontrol)
  934. {
  935. int sample_rate_val;
  936. int idx = ext_disp_get_port_idx(kcontrol);
  937. if (idx < 0)
  938. return idx;
  939. switch (ext_disp_rx_cfg[idx].sample_rate) {
  940. case SAMPLING_RATE_176P4KHZ:
  941. sample_rate_val = 6;
  942. break;
  943. case SAMPLING_RATE_88P2KHZ:
  944. sample_rate_val = 5;
  945. break;
  946. case SAMPLING_RATE_44P1KHZ:
  947. sample_rate_val = 4;
  948. break;
  949. case SAMPLING_RATE_32KHZ:
  950. sample_rate_val = 3;
  951. break;
  952. case SAMPLING_RATE_192KHZ:
  953. sample_rate_val = 2;
  954. break;
  955. case SAMPLING_RATE_96KHZ:
  956. sample_rate_val = 1;
  957. break;
  958. case SAMPLING_RATE_48KHZ:
  959. default:
  960. sample_rate_val = 0;
  961. break;
  962. }
  963. ucontrol->value.integer.value[0] = sample_rate_val;
  964. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  965. idx, ext_disp_rx_cfg[idx].sample_rate);
  966. return 0;
  967. }
  968. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  969. struct snd_ctl_elem_value *ucontrol)
  970. {
  971. int idx = ext_disp_get_port_idx(kcontrol);
  972. if (idx < 0)
  973. return idx;
  974. switch (ucontrol->value.integer.value[0]) {
  975. case 6:
  976. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  977. break;
  978. case 5:
  979. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  980. break;
  981. case 4:
  982. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  983. break;
  984. case 3:
  985. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  986. break;
  987. case 2:
  988. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  989. break;
  990. case 1:
  991. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  992. break;
  993. case 0:
  994. default:
  995. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  996. break;
  997. }
  998. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  999. __func__, ucontrol->value.integer.value[0], idx,
  1000. ext_disp_rx_cfg[idx].sample_rate);
  1001. return 0;
  1002. }
  1003. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1004. struct snd_ctl_elem_value *ucontrol)
  1005. {
  1006. pr_debug("%s: proxy_rx channels = %d\n",
  1007. __func__, proxy_rx_cfg.channels);
  1008. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1009. return 0;
  1010. }
  1011. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1012. struct snd_ctl_elem_value *ucontrol)
  1013. {
  1014. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1015. pr_debug("%s: proxy_rx channels = %d\n",
  1016. __func__, proxy_rx_cfg.channels);
  1017. return 1;
  1018. }
  1019. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1020. struct tdm_port *port)
  1021. {
  1022. if (port) {
  1023. if (strnstr(kcontrol->id.name, "PRI",
  1024. sizeof(kcontrol->id.name))) {
  1025. port->mode = TDM_PRI;
  1026. } else if (strnstr(kcontrol->id.name, "SEC",
  1027. sizeof(kcontrol->id.name))) {
  1028. port->mode = TDM_SEC;
  1029. } else if (strnstr(kcontrol->id.name, "TERT",
  1030. sizeof(kcontrol->id.name))) {
  1031. port->mode = TDM_TERT;
  1032. } else {
  1033. pr_err("%s: unsupported mode in: %s\n",
  1034. __func__, kcontrol->id.name);
  1035. return -EINVAL;
  1036. }
  1037. if (strnstr(kcontrol->id.name, "RX_0",
  1038. sizeof(kcontrol->id.name)) ||
  1039. strnstr(kcontrol->id.name, "TX_0",
  1040. sizeof(kcontrol->id.name))) {
  1041. port->channel = TDM_0;
  1042. } else if (strnstr(kcontrol->id.name, "RX_1",
  1043. sizeof(kcontrol->id.name)) ||
  1044. strnstr(kcontrol->id.name, "TX_1",
  1045. sizeof(kcontrol->id.name))) {
  1046. port->channel = TDM_1;
  1047. } else if (strnstr(kcontrol->id.name, "RX_2",
  1048. sizeof(kcontrol->id.name)) ||
  1049. strnstr(kcontrol->id.name, "TX_2",
  1050. sizeof(kcontrol->id.name))) {
  1051. port->channel = TDM_2;
  1052. } else if (strnstr(kcontrol->id.name, "RX_3",
  1053. sizeof(kcontrol->id.name)) ||
  1054. strnstr(kcontrol->id.name, "TX_3",
  1055. sizeof(kcontrol->id.name))) {
  1056. port->channel = TDM_3;
  1057. } else if (strnstr(kcontrol->id.name, "RX_4",
  1058. sizeof(kcontrol->id.name)) ||
  1059. strnstr(kcontrol->id.name, "TX_4",
  1060. sizeof(kcontrol->id.name))) {
  1061. port->channel = TDM_4;
  1062. } else if (strnstr(kcontrol->id.name, "RX_5",
  1063. sizeof(kcontrol->id.name)) ||
  1064. strnstr(kcontrol->id.name, "TX_5",
  1065. sizeof(kcontrol->id.name))) {
  1066. port->channel = TDM_5;
  1067. } else if (strnstr(kcontrol->id.name, "RX_6",
  1068. sizeof(kcontrol->id.name)) ||
  1069. strnstr(kcontrol->id.name, "TX_6",
  1070. sizeof(kcontrol->id.name))) {
  1071. port->channel = TDM_6;
  1072. } else if (strnstr(kcontrol->id.name, "RX_7",
  1073. sizeof(kcontrol->id.name)) ||
  1074. strnstr(kcontrol->id.name, "TX_7",
  1075. sizeof(kcontrol->id.name))) {
  1076. port->channel = TDM_7;
  1077. } else {
  1078. pr_err("%s: unsupported channel in: %s\n",
  1079. __func__, kcontrol->id.name);
  1080. return -EINVAL;
  1081. }
  1082. } else {
  1083. return -EINVAL;
  1084. }
  1085. return 0;
  1086. }
  1087. static int tdm_get_sample_rate(int value)
  1088. {
  1089. int sample_rate = 0;
  1090. switch (value) {
  1091. case 0:
  1092. sample_rate = SAMPLING_RATE_8KHZ;
  1093. break;
  1094. case 1:
  1095. sample_rate = SAMPLING_RATE_16KHZ;
  1096. break;
  1097. case 2:
  1098. sample_rate = SAMPLING_RATE_32KHZ;
  1099. break;
  1100. case 3:
  1101. sample_rate = SAMPLING_RATE_48KHZ;
  1102. break;
  1103. case 4:
  1104. sample_rate = SAMPLING_RATE_176P4KHZ;
  1105. break;
  1106. case 5:
  1107. sample_rate = SAMPLING_RATE_352P8KHZ;
  1108. break;
  1109. default:
  1110. sample_rate = SAMPLING_RATE_48KHZ;
  1111. break;
  1112. }
  1113. return sample_rate;
  1114. }
  1115. static int tdm_get_sample_rate_val(int sample_rate)
  1116. {
  1117. int sample_rate_val = 0;
  1118. switch (sample_rate) {
  1119. case SAMPLING_RATE_8KHZ:
  1120. sample_rate_val = 0;
  1121. break;
  1122. case SAMPLING_RATE_16KHZ:
  1123. sample_rate_val = 1;
  1124. break;
  1125. case SAMPLING_RATE_32KHZ:
  1126. sample_rate_val = 2;
  1127. break;
  1128. case SAMPLING_RATE_48KHZ:
  1129. sample_rate_val = 3;
  1130. break;
  1131. case SAMPLING_RATE_176P4KHZ:
  1132. sample_rate_val = 4;
  1133. break;
  1134. case SAMPLING_RATE_352P8KHZ:
  1135. sample_rate_val = 5;
  1136. break;
  1137. default:
  1138. sample_rate_val = 3;
  1139. break;
  1140. }
  1141. return sample_rate_val;
  1142. }
  1143. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1144. struct snd_ctl_elem_value *ucontrol)
  1145. {
  1146. struct tdm_port port;
  1147. int ret = tdm_get_port_idx(kcontrol, &port);
  1148. if (ret) {
  1149. pr_err("%s: unsupported control: %s\n",
  1150. __func__, kcontrol->id.name);
  1151. } else {
  1152. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1153. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1154. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1155. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1156. ucontrol->value.enumerated.item[0]);
  1157. }
  1158. return ret;
  1159. }
  1160. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1161. struct snd_ctl_elem_value *ucontrol)
  1162. {
  1163. struct tdm_port port;
  1164. int ret = tdm_get_port_idx(kcontrol, &port);
  1165. if (ret) {
  1166. pr_err("%s: unsupported control: %s\n",
  1167. __func__, kcontrol->id.name);
  1168. } else {
  1169. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1170. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1171. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1172. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1173. ucontrol->value.enumerated.item[0]);
  1174. }
  1175. return ret;
  1176. }
  1177. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1178. struct snd_ctl_elem_value *ucontrol)
  1179. {
  1180. struct tdm_port port;
  1181. int ret = tdm_get_port_idx(kcontrol, &port);
  1182. if (ret) {
  1183. pr_err("%s: unsupported control: %s\n",
  1184. __func__, kcontrol->id.name);
  1185. } else {
  1186. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1187. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1188. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1189. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1190. ucontrol->value.enumerated.item[0]);
  1191. }
  1192. return ret;
  1193. }
  1194. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1195. struct snd_ctl_elem_value *ucontrol)
  1196. {
  1197. struct tdm_port port;
  1198. int ret = tdm_get_port_idx(kcontrol, &port);
  1199. if (ret) {
  1200. pr_err("%s: unsupported control: %s\n",
  1201. __func__, kcontrol->id.name);
  1202. } else {
  1203. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1204. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1205. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1206. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1207. ucontrol->value.enumerated.item[0]);
  1208. }
  1209. return ret;
  1210. }
  1211. static int tdm_get_format(int value)
  1212. {
  1213. int format = 0;
  1214. switch (value) {
  1215. case 0:
  1216. format = SNDRV_PCM_FORMAT_S16_LE;
  1217. break;
  1218. case 1:
  1219. format = SNDRV_PCM_FORMAT_S24_LE;
  1220. break;
  1221. case 2:
  1222. format = SNDRV_PCM_FORMAT_S32_LE;
  1223. break;
  1224. default:
  1225. format = SNDRV_PCM_FORMAT_S16_LE;
  1226. break;
  1227. }
  1228. return format;
  1229. }
  1230. static int tdm_get_format_val(int format)
  1231. {
  1232. int value = 0;
  1233. switch (format) {
  1234. case SNDRV_PCM_FORMAT_S16_LE:
  1235. value = 0;
  1236. break;
  1237. case SNDRV_PCM_FORMAT_S24_LE:
  1238. value = 1;
  1239. break;
  1240. case SNDRV_PCM_FORMAT_S32_LE:
  1241. value = 2;
  1242. break;
  1243. default:
  1244. value = 0;
  1245. break;
  1246. }
  1247. return value;
  1248. }
  1249. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1250. struct snd_ctl_elem_value *ucontrol)
  1251. {
  1252. struct tdm_port port;
  1253. int ret = tdm_get_port_idx(kcontrol, &port);
  1254. if (ret) {
  1255. pr_err("%s: unsupported control: %s\n",
  1256. __func__, kcontrol->id.name);
  1257. } else {
  1258. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1259. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1260. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1261. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1262. ucontrol->value.enumerated.item[0]);
  1263. }
  1264. return ret;
  1265. }
  1266. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1267. struct snd_ctl_elem_value *ucontrol)
  1268. {
  1269. struct tdm_port port;
  1270. int ret = tdm_get_port_idx(kcontrol, &port);
  1271. if (ret) {
  1272. pr_err("%s: unsupported control: %s\n",
  1273. __func__, kcontrol->id.name);
  1274. } else {
  1275. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1276. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1277. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1278. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1279. ucontrol->value.enumerated.item[0]);
  1280. }
  1281. return ret;
  1282. }
  1283. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1284. struct snd_ctl_elem_value *ucontrol)
  1285. {
  1286. struct tdm_port port;
  1287. int ret = tdm_get_port_idx(kcontrol, &port);
  1288. if (ret) {
  1289. pr_err("%s: unsupported control: %s\n",
  1290. __func__, kcontrol->id.name);
  1291. } else {
  1292. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1293. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1294. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1295. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1296. ucontrol->value.enumerated.item[0]);
  1297. }
  1298. return ret;
  1299. }
  1300. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1301. struct snd_ctl_elem_value *ucontrol)
  1302. {
  1303. struct tdm_port port;
  1304. int ret = tdm_get_port_idx(kcontrol, &port);
  1305. if (ret) {
  1306. pr_err("%s: unsupported control: %s\n",
  1307. __func__, kcontrol->id.name);
  1308. } else {
  1309. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1310. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1311. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1312. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1313. ucontrol->value.enumerated.item[0]);
  1314. }
  1315. return ret;
  1316. }
  1317. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1318. struct snd_ctl_elem_value *ucontrol)
  1319. {
  1320. struct tdm_port port;
  1321. int ret = tdm_get_port_idx(kcontrol, &port);
  1322. if (ret) {
  1323. pr_err("%s: unsupported control: %s\n",
  1324. __func__, kcontrol->id.name);
  1325. } else {
  1326. ucontrol->value.enumerated.item[0] =
  1327. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1328. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1329. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1330. ucontrol->value.enumerated.item[0]);
  1331. }
  1332. return ret;
  1333. }
  1334. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1335. struct snd_ctl_elem_value *ucontrol)
  1336. {
  1337. struct tdm_port port;
  1338. int ret = tdm_get_port_idx(kcontrol, &port);
  1339. if (ret) {
  1340. pr_err("%s: unsupported control: %s\n",
  1341. __func__, kcontrol->id.name);
  1342. } else {
  1343. tdm_rx_cfg[port.mode][port.channel].channels =
  1344. ucontrol->value.enumerated.item[0] + 1;
  1345. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1346. tdm_rx_cfg[port.mode][port.channel].channels,
  1347. ucontrol->value.enumerated.item[0] + 1);
  1348. }
  1349. return ret;
  1350. }
  1351. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1352. struct snd_ctl_elem_value *ucontrol)
  1353. {
  1354. struct tdm_port port;
  1355. int ret = tdm_get_port_idx(kcontrol, &port);
  1356. if (ret) {
  1357. pr_err("%s: unsupported control: %s\n",
  1358. __func__, kcontrol->id.name);
  1359. } else {
  1360. ucontrol->value.enumerated.item[0] =
  1361. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1362. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1363. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1364. ucontrol->value.enumerated.item[0]);
  1365. }
  1366. return ret;
  1367. }
  1368. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1369. struct snd_ctl_elem_value *ucontrol)
  1370. {
  1371. struct tdm_port port;
  1372. int ret = tdm_get_port_idx(kcontrol, &port);
  1373. if (ret) {
  1374. pr_err("%s: unsupported control: %s\n",
  1375. __func__, kcontrol->id.name);
  1376. } else {
  1377. tdm_tx_cfg[port.mode][port.channel].channels =
  1378. ucontrol->value.enumerated.item[0] + 1;
  1379. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1380. tdm_tx_cfg[port.mode][port.channel].channels,
  1381. ucontrol->value.enumerated.item[0] + 1);
  1382. }
  1383. return ret;
  1384. }
  1385. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1386. {
  1387. int idx = 0;
  1388. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1389. sizeof("PRIM_AUX_PCM"))) {
  1390. idx = PRIM_AUX_PCM;
  1391. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1392. sizeof("SEC_AUX_PCM"))) {
  1393. idx = SEC_AUX_PCM;
  1394. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1395. sizeof("TERT_AUX_PCM"))) {
  1396. idx = TERT_AUX_PCM;
  1397. } else {
  1398. pr_err("%s: unsupported port: %s\n",
  1399. __func__, kcontrol->id.name);
  1400. idx = -EINVAL;
  1401. }
  1402. return idx;
  1403. }
  1404. static int aux_pcm_get_sample_rate(int value)
  1405. {
  1406. int sample_rate = 0;
  1407. switch (value) {
  1408. case 1:
  1409. sample_rate = SAMPLING_RATE_16KHZ;
  1410. break;
  1411. case 0:
  1412. default:
  1413. sample_rate = SAMPLING_RATE_8KHZ;
  1414. break;
  1415. }
  1416. return sample_rate;
  1417. }
  1418. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1419. {
  1420. int sample_rate_val = 0;
  1421. switch (sample_rate) {
  1422. case SAMPLING_RATE_16KHZ:
  1423. sample_rate_val = 1;
  1424. break;
  1425. case SAMPLING_RATE_8KHZ:
  1426. default:
  1427. sample_rate_val = 0;
  1428. break;
  1429. }
  1430. return sample_rate_val;
  1431. }
  1432. static int mi2s_auxpcm_get_format(int value)
  1433. {
  1434. int format = 0;
  1435. switch (value) {
  1436. case 0:
  1437. format = SNDRV_PCM_FORMAT_S16_LE;
  1438. break;
  1439. case 1:
  1440. format = SNDRV_PCM_FORMAT_S24_LE;
  1441. break;
  1442. case 2:
  1443. format = SNDRV_PCM_FORMAT_S24_3LE;
  1444. break;
  1445. case 3:
  1446. format = SNDRV_PCM_FORMAT_S32_LE;
  1447. break;
  1448. default:
  1449. format = SNDRV_PCM_FORMAT_S16_LE;
  1450. break;
  1451. }
  1452. return format;
  1453. }
  1454. static int mi2s_auxpcm_get_format_value(int format)
  1455. {
  1456. int value = 0;
  1457. switch (format) {
  1458. case SNDRV_PCM_FORMAT_S16_LE:
  1459. value = 0;
  1460. break;
  1461. case SNDRV_PCM_FORMAT_S24_LE:
  1462. value = 1;
  1463. break;
  1464. case SNDRV_PCM_FORMAT_S24_3LE:
  1465. value = 2;
  1466. break;
  1467. case SNDRV_PCM_FORMAT_S32_LE:
  1468. value = 3;
  1469. break;
  1470. default:
  1471. value = 0;
  1472. break;
  1473. }
  1474. return value;
  1475. }
  1476. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1477. struct snd_ctl_elem_value *ucontrol)
  1478. {
  1479. int idx = aux_pcm_get_port_idx(kcontrol);
  1480. if (idx < 0)
  1481. return idx;
  1482. ucontrol->value.enumerated.item[0] =
  1483. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  1484. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1485. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1486. ucontrol->value.enumerated.item[0]);
  1487. return 0;
  1488. }
  1489. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1490. struct snd_ctl_elem_value *ucontrol)
  1491. {
  1492. int idx = aux_pcm_get_port_idx(kcontrol);
  1493. if (idx < 0)
  1494. return idx;
  1495. aux_pcm_rx_cfg[idx].sample_rate =
  1496. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1497. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1498. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1499. ucontrol->value.enumerated.item[0]);
  1500. return 0;
  1501. }
  1502. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1503. struct snd_ctl_elem_value *ucontrol)
  1504. {
  1505. int idx = aux_pcm_get_port_idx(kcontrol);
  1506. if (idx < 0)
  1507. return idx;
  1508. ucontrol->value.enumerated.item[0] =
  1509. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  1510. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1511. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1512. ucontrol->value.enumerated.item[0]);
  1513. return 0;
  1514. }
  1515. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1516. struct snd_ctl_elem_value *ucontrol)
  1517. {
  1518. int idx = aux_pcm_get_port_idx(kcontrol);
  1519. if (idx < 0)
  1520. return idx;
  1521. aux_pcm_tx_cfg[idx].sample_rate =
  1522. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1523. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1524. idx, aux_pcm_tx_cfg[idx].sample_rate,
  1525. ucontrol->value.enumerated.item[0]);
  1526. return 0;
  1527. }
  1528. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  1529. struct snd_ctl_elem_value *ucontrol)
  1530. {
  1531. int idx = aux_pcm_get_port_idx(kcontrol);
  1532. if (idx < 0)
  1533. return idx;
  1534. ucontrol->value.enumerated.item[0] =
  1535. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  1536. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1537. idx, aux_pcm_rx_cfg[idx].bit_format,
  1538. ucontrol->value.enumerated.item[0]);
  1539. return 0;
  1540. }
  1541. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  1542. struct snd_ctl_elem_value *ucontrol)
  1543. {
  1544. int idx = aux_pcm_get_port_idx(kcontrol);
  1545. if (idx < 0)
  1546. return idx;
  1547. aux_pcm_rx_cfg[idx].bit_format =
  1548. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1549. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1550. idx, aux_pcm_rx_cfg[idx].bit_format,
  1551. ucontrol->value.enumerated.item[0]);
  1552. return 0;
  1553. }
  1554. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  1555. struct snd_ctl_elem_value *ucontrol)
  1556. {
  1557. int idx = aux_pcm_get_port_idx(kcontrol);
  1558. if (idx < 0)
  1559. return idx;
  1560. ucontrol->value.enumerated.item[0] =
  1561. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  1562. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1563. idx, aux_pcm_tx_cfg[idx].bit_format,
  1564. ucontrol->value.enumerated.item[0]);
  1565. return 0;
  1566. }
  1567. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  1568. struct snd_ctl_elem_value *ucontrol)
  1569. {
  1570. int idx = aux_pcm_get_port_idx(kcontrol);
  1571. if (idx < 0)
  1572. return idx;
  1573. aux_pcm_tx_cfg[idx].bit_format =
  1574. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1575. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1576. idx, aux_pcm_tx_cfg[idx].bit_format,
  1577. ucontrol->value.enumerated.item[0]);
  1578. return 0;
  1579. }
  1580. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  1581. {
  1582. int idx = 0;
  1583. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  1584. sizeof("PRIM_MI2S_RX"))) {
  1585. idx = PRIM_MI2S;
  1586. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  1587. sizeof("SEC_MI2S_RX"))) {
  1588. idx = SEC_MI2S;
  1589. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  1590. sizeof("TERT_MI2S_RX"))) {
  1591. idx = TERT_MI2S;
  1592. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  1593. sizeof("PRIM_MI2S_TX"))) {
  1594. idx = PRIM_MI2S;
  1595. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  1596. sizeof("SEC_MI2S_TX"))) {
  1597. idx = SEC_MI2S;
  1598. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  1599. sizeof("TERT_MI2S_TX"))) {
  1600. idx = TERT_MI2S;
  1601. } else {
  1602. pr_err("%s: unsupported channel: %s\n",
  1603. __func__, kcontrol->id.name);
  1604. idx = -EINVAL;
  1605. }
  1606. return idx;
  1607. }
  1608. static int mi2s_get_sample_rate(int value)
  1609. {
  1610. int sample_rate = 0;
  1611. switch (value) {
  1612. case 0:
  1613. sample_rate = SAMPLING_RATE_8KHZ;
  1614. break;
  1615. case 1:
  1616. sample_rate = SAMPLING_RATE_11P025KHZ;
  1617. break;
  1618. case 2:
  1619. sample_rate = SAMPLING_RATE_16KHZ;
  1620. break;
  1621. case 3:
  1622. sample_rate = SAMPLING_RATE_22P05KHZ;
  1623. break;
  1624. case 4:
  1625. sample_rate = SAMPLING_RATE_32KHZ;
  1626. break;
  1627. case 5:
  1628. sample_rate = SAMPLING_RATE_44P1KHZ;
  1629. break;
  1630. case 6:
  1631. sample_rate = SAMPLING_RATE_48KHZ;
  1632. break;
  1633. case 7:
  1634. sample_rate = SAMPLING_RATE_96KHZ;
  1635. break;
  1636. case 8:
  1637. sample_rate = SAMPLING_RATE_192KHZ;
  1638. break;
  1639. default:
  1640. sample_rate = SAMPLING_RATE_48KHZ;
  1641. break;
  1642. }
  1643. return sample_rate;
  1644. }
  1645. static int mi2s_get_sample_rate_val(int sample_rate)
  1646. {
  1647. int sample_rate_val = 0;
  1648. switch (sample_rate) {
  1649. case SAMPLING_RATE_8KHZ:
  1650. sample_rate_val = 0;
  1651. break;
  1652. case SAMPLING_RATE_11P025KHZ:
  1653. sample_rate_val = 1;
  1654. break;
  1655. case SAMPLING_RATE_16KHZ:
  1656. sample_rate_val = 2;
  1657. break;
  1658. case SAMPLING_RATE_22P05KHZ:
  1659. sample_rate_val = 3;
  1660. break;
  1661. case SAMPLING_RATE_32KHZ:
  1662. sample_rate_val = 4;
  1663. break;
  1664. case SAMPLING_RATE_44P1KHZ:
  1665. sample_rate_val = 5;
  1666. break;
  1667. case SAMPLING_RATE_48KHZ:
  1668. sample_rate_val = 6;
  1669. break;
  1670. case SAMPLING_RATE_96KHZ:
  1671. sample_rate_val = 7;
  1672. break;
  1673. case SAMPLING_RATE_192KHZ:
  1674. sample_rate_val = 8;
  1675. break;
  1676. default:
  1677. sample_rate_val = 6;
  1678. break;
  1679. }
  1680. return sample_rate_val;
  1681. }
  1682. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1683. struct snd_ctl_elem_value *ucontrol)
  1684. {
  1685. int idx = mi2s_get_port_idx(kcontrol);
  1686. if (idx < 0)
  1687. return idx;
  1688. ucontrol->value.enumerated.item[0] =
  1689. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  1690. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1691. idx, mi2s_rx_cfg[idx].sample_rate,
  1692. ucontrol->value.enumerated.item[0]);
  1693. return 0;
  1694. }
  1695. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1696. struct snd_ctl_elem_value *ucontrol)
  1697. {
  1698. int idx = mi2s_get_port_idx(kcontrol);
  1699. if (idx < 0)
  1700. return idx;
  1701. mi2s_rx_cfg[idx].sample_rate =
  1702. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1703. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1704. idx, mi2s_rx_cfg[idx].sample_rate,
  1705. ucontrol->value.enumerated.item[0]);
  1706. return 0;
  1707. }
  1708. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1709. struct snd_ctl_elem_value *ucontrol)
  1710. {
  1711. int idx = mi2s_get_port_idx(kcontrol);
  1712. if (idx < 0)
  1713. return idx;
  1714. ucontrol->value.enumerated.item[0] =
  1715. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  1716. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1717. idx, mi2s_tx_cfg[idx].sample_rate,
  1718. ucontrol->value.enumerated.item[0]);
  1719. return 0;
  1720. }
  1721. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1722. struct snd_ctl_elem_value *ucontrol)
  1723. {
  1724. int idx = mi2s_get_port_idx(kcontrol);
  1725. if (idx < 0)
  1726. return idx;
  1727. mi2s_tx_cfg[idx].sample_rate =
  1728. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1729. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  1730. idx, mi2s_tx_cfg[idx].sample_rate,
  1731. ucontrol->value.enumerated.item[0]);
  1732. return 0;
  1733. }
  1734. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  1735. struct snd_ctl_elem_value *ucontrol)
  1736. {
  1737. int idx = mi2s_get_port_idx(kcontrol);
  1738. if (idx < 0)
  1739. return idx;
  1740. ucontrol->value.enumerated.item[0] =
  1741. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  1742. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1743. idx, mi2s_rx_cfg[idx].bit_format,
  1744. ucontrol->value.enumerated.item[0]);
  1745. return 0;
  1746. }
  1747. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  1748. struct snd_ctl_elem_value *ucontrol)
  1749. {
  1750. int idx = mi2s_get_port_idx(kcontrol);
  1751. if (idx < 0)
  1752. return idx;
  1753. mi2s_rx_cfg[idx].bit_format =
  1754. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1755. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  1756. idx, mi2s_rx_cfg[idx].bit_format,
  1757. ucontrol->value.enumerated.item[0]);
  1758. return 0;
  1759. }
  1760. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  1761. struct snd_ctl_elem_value *ucontrol)
  1762. {
  1763. int idx = mi2s_get_port_idx(kcontrol);
  1764. if (idx < 0)
  1765. return idx;
  1766. ucontrol->value.enumerated.item[0] =
  1767. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  1768. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1769. idx, mi2s_tx_cfg[idx].bit_format,
  1770. ucontrol->value.enumerated.item[0]);
  1771. return 0;
  1772. }
  1773. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  1774. struct snd_ctl_elem_value *ucontrol)
  1775. {
  1776. int idx = mi2s_get_port_idx(kcontrol);
  1777. if (idx < 0)
  1778. return idx;
  1779. mi2s_tx_cfg[idx].bit_format =
  1780. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  1781. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  1782. idx, mi2s_tx_cfg[idx].bit_format,
  1783. ucontrol->value.enumerated.item[0]);
  1784. return 0;
  1785. }
  1786. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  1787. struct snd_ctl_elem_value *ucontrol)
  1788. {
  1789. int idx = mi2s_get_port_idx(kcontrol);
  1790. if (idx < 0)
  1791. return idx;
  1792. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  1793. idx, mi2s_rx_cfg[idx].channels);
  1794. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  1795. return 0;
  1796. }
  1797. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  1798. struct snd_ctl_elem_value *ucontrol)
  1799. {
  1800. int idx = mi2s_get_port_idx(kcontrol);
  1801. if (idx < 0)
  1802. return idx;
  1803. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  1804. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  1805. idx, mi2s_rx_cfg[idx].channels);
  1806. return 1;
  1807. }
  1808. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  1809. struct snd_ctl_elem_value *ucontrol)
  1810. {
  1811. int idx = mi2s_get_port_idx(kcontrol);
  1812. if (idx < 0)
  1813. return idx;
  1814. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  1815. idx, mi2s_tx_cfg[idx].channels);
  1816. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  1817. return 0;
  1818. }
  1819. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  1820. struct snd_ctl_elem_value *ucontrol)
  1821. {
  1822. int idx = mi2s_get_port_idx(kcontrol);
  1823. if (idx < 0)
  1824. return idx;
  1825. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  1826. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  1827. idx, mi2s_tx_cfg[idx].channels);
  1828. return 1;
  1829. }
  1830. static int msm_get_port_id(int be_id)
  1831. {
  1832. int afe_port_id = 0;
  1833. switch (be_id) {
  1834. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  1835. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  1836. break;
  1837. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  1838. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  1839. break;
  1840. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  1841. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  1842. break;
  1843. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  1844. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  1845. break;
  1846. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  1847. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  1848. break;
  1849. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  1850. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  1851. break;
  1852. default:
  1853. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  1854. afe_port_id = -EINVAL;
  1855. }
  1856. return afe_port_id;
  1857. }
  1858. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  1859. {
  1860. u32 bit_per_sample = 0;
  1861. switch (bit_format) {
  1862. case SNDRV_PCM_FORMAT_S32_LE:
  1863. case SNDRV_PCM_FORMAT_S24_3LE:
  1864. case SNDRV_PCM_FORMAT_S24_LE:
  1865. bit_per_sample = 32;
  1866. break;
  1867. case SNDRV_PCM_FORMAT_S16_LE:
  1868. default:
  1869. bit_per_sample = 16;
  1870. break;
  1871. }
  1872. return bit_per_sample;
  1873. }
  1874. static void update_mi2s_clk_val(int dai_id, int stream)
  1875. {
  1876. u32 bit_per_sample = 0;
  1877. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  1878. bit_per_sample =
  1879. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  1880. mi2s_clk[dai_id].clk_freq_in_hz =
  1881. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  1882. } else {
  1883. bit_per_sample =
  1884. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  1885. mi2s_clk[dai_id].clk_freq_in_hz =
  1886. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  1887. }
  1888. }
  1889. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  1890. {
  1891. int ret = 0;
  1892. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  1893. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  1894. int port_id = 0;
  1895. int index = cpu_dai->id;
  1896. port_id = msm_get_port_id(rtd->dai_link->id);
  1897. if (port_id < 0) {
  1898. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  1899. ret = port_id;
  1900. goto err;
  1901. }
  1902. if (enable) {
  1903. update_mi2s_clk_val(index, substream->stream);
  1904. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  1905. mi2s_clk[index].clk_freq_in_hz);
  1906. }
  1907. mi2s_clk[index].enable = enable;
  1908. ret = afe_set_lpass_clock_v2(port_id,
  1909. &mi2s_clk[index]);
  1910. if (ret < 0) {
  1911. dev_err(rtd->card->dev,
  1912. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  1913. __func__, port_id, ret);
  1914. goto err;
  1915. }
  1916. err:
  1917. return ret;
  1918. }
  1919. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  1920. {
  1921. int idx = 0;
  1922. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  1923. sizeof("WSA_CDC_DMA_RX_0")))
  1924. idx = WSA_CDC_DMA_RX_0;
  1925. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  1926. sizeof("WSA_CDC_DMA_RX_0")))
  1927. idx = WSA_CDC_DMA_RX_1;
  1928. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  1929. sizeof("RX_CDC_DMA_RX_0")))
  1930. idx = RX_CDC_DMA_RX_0;
  1931. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  1932. sizeof("RX_CDC_DMA_RX_1")))
  1933. idx = RX_CDC_DMA_RX_1;
  1934. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  1935. sizeof("RX_CDC_DMA_RX_2")))
  1936. idx = RX_CDC_DMA_RX_2;
  1937. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  1938. sizeof("RX_CDC_DMA_RX_3")))
  1939. idx = RX_CDC_DMA_RX_3;
  1940. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  1941. sizeof("RX_CDC_DMA_RX_5")))
  1942. idx = RX_CDC_DMA_RX_5;
  1943. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  1944. sizeof("WSA_CDC_DMA_TX_0")))
  1945. idx = WSA_CDC_DMA_TX_0;
  1946. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  1947. sizeof("WSA_CDC_DMA_TX_1")))
  1948. idx = WSA_CDC_DMA_TX_1;
  1949. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  1950. sizeof("WSA_CDC_DMA_TX_2")))
  1951. idx = WSA_CDC_DMA_TX_2;
  1952. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  1953. sizeof("TX_CDC_DMA_TX_0")))
  1954. idx = TX_CDC_DMA_TX_0;
  1955. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  1956. sizeof("TX_CDC_DMA_TX_3")))
  1957. idx = TX_CDC_DMA_TX_3;
  1958. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  1959. sizeof("TX_CDC_DMA_TX_4")))
  1960. idx = TX_CDC_DMA_TX_4;
  1961. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  1962. sizeof("VA_CDC_DMA_TX_0")))
  1963. idx = VA_CDC_DMA_TX_0;
  1964. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  1965. sizeof("VA_CDC_DMA_TX_1")))
  1966. idx = VA_CDC_DMA_TX_1;
  1967. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  1968. sizeof("VA_CDC_DMA_TX_2")))
  1969. idx = VA_CDC_DMA_TX_2;
  1970. else {
  1971. pr_err("%s: unsupported channel: %s\n",
  1972. __func__, kcontrol->id.name);
  1973. return -EINVAL;
  1974. }
  1975. return idx;
  1976. }
  1977. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  1978. struct snd_ctl_elem_value *ucontrol)
  1979. {
  1980. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1981. if (ch_num < 0) {
  1982. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1983. return ch_num;
  1984. }
  1985. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  1986. cdc_dma_rx_cfg[ch_num].channels - 1);
  1987. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  1988. return 0;
  1989. }
  1990. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  1991. struct snd_ctl_elem_value *ucontrol)
  1992. {
  1993. int ch_num = cdc_dma_get_port_idx(kcontrol);
  1994. if (ch_num < 0) {
  1995. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  1996. return ch_num;
  1997. }
  1998. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  1999. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2000. cdc_dma_rx_cfg[ch_num].channels);
  2001. return 1;
  2002. }
  2003. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2004. struct snd_ctl_elem_value *ucontrol)
  2005. {
  2006. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2007. if (ch_num < 0) {
  2008. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2009. return ch_num;
  2010. }
  2011. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2012. case SNDRV_PCM_FORMAT_S32_LE:
  2013. ucontrol->value.integer.value[0] = 3;
  2014. break;
  2015. case SNDRV_PCM_FORMAT_S24_3LE:
  2016. ucontrol->value.integer.value[0] = 2;
  2017. break;
  2018. case SNDRV_PCM_FORMAT_S24_LE:
  2019. ucontrol->value.integer.value[0] = 1;
  2020. break;
  2021. case SNDRV_PCM_FORMAT_S16_LE:
  2022. default:
  2023. ucontrol->value.integer.value[0] = 0;
  2024. break;
  2025. }
  2026. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2027. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2028. ucontrol->value.integer.value[0]);
  2029. return 0;
  2030. }
  2031. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2032. struct snd_ctl_elem_value *ucontrol)
  2033. {
  2034. int rc = 0;
  2035. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2036. if (ch_num < 0) {
  2037. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2038. return ch_num;
  2039. }
  2040. switch (ucontrol->value.integer.value[0]) {
  2041. case 3:
  2042. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2043. break;
  2044. case 2:
  2045. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2046. break;
  2047. case 1:
  2048. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2049. break;
  2050. case 0:
  2051. default:
  2052. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2053. break;
  2054. }
  2055. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2056. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2057. ucontrol->value.integer.value[0]);
  2058. return rc;
  2059. }
  2060. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2061. {
  2062. int sample_rate_val = 0;
  2063. switch (sample_rate) {
  2064. case SAMPLING_RATE_8KHZ:
  2065. sample_rate_val = 0;
  2066. break;
  2067. case SAMPLING_RATE_11P025KHZ:
  2068. sample_rate_val = 1;
  2069. break;
  2070. case SAMPLING_RATE_16KHZ:
  2071. sample_rate_val = 2;
  2072. break;
  2073. case SAMPLING_RATE_22P05KHZ:
  2074. sample_rate_val = 3;
  2075. break;
  2076. case SAMPLING_RATE_32KHZ:
  2077. sample_rate_val = 4;
  2078. break;
  2079. case SAMPLING_RATE_44P1KHZ:
  2080. sample_rate_val = 5;
  2081. break;
  2082. case SAMPLING_RATE_48KHZ:
  2083. sample_rate_val = 6;
  2084. break;
  2085. case SAMPLING_RATE_88P2KHZ:
  2086. sample_rate_val = 7;
  2087. break;
  2088. case SAMPLING_RATE_96KHZ:
  2089. sample_rate_val = 8;
  2090. break;
  2091. case SAMPLING_RATE_176P4KHZ:
  2092. sample_rate_val = 9;
  2093. break;
  2094. case SAMPLING_RATE_192KHZ:
  2095. sample_rate_val = 10;
  2096. break;
  2097. case SAMPLING_RATE_352P8KHZ:
  2098. sample_rate_val = 11;
  2099. break;
  2100. case SAMPLING_RATE_384KHZ:
  2101. sample_rate_val = 12;
  2102. break;
  2103. default:
  2104. sample_rate_val = 6;
  2105. break;
  2106. }
  2107. return sample_rate_val;
  2108. }
  2109. static int cdc_dma_get_sample_rate(int value)
  2110. {
  2111. int sample_rate = 0;
  2112. switch (value) {
  2113. case 0:
  2114. sample_rate = SAMPLING_RATE_8KHZ;
  2115. break;
  2116. case 1:
  2117. sample_rate = SAMPLING_RATE_11P025KHZ;
  2118. break;
  2119. case 2:
  2120. sample_rate = SAMPLING_RATE_16KHZ;
  2121. break;
  2122. case 3:
  2123. sample_rate = SAMPLING_RATE_22P05KHZ;
  2124. break;
  2125. case 4:
  2126. sample_rate = SAMPLING_RATE_32KHZ;
  2127. break;
  2128. case 5:
  2129. sample_rate = SAMPLING_RATE_44P1KHZ;
  2130. break;
  2131. case 6:
  2132. sample_rate = SAMPLING_RATE_48KHZ;
  2133. break;
  2134. case 7:
  2135. sample_rate = SAMPLING_RATE_88P2KHZ;
  2136. break;
  2137. case 8:
  2138. sample_rate = SAMPLING_RATE_96KHZ;
  2139. break;
  2140. case 9:
  2141. sample_rate = SAMPLING_RATE_176P4KHZ;
  2142. break;
  2143. case 10:
  2144. sample_rate = SAMPLING_RATE_192KHZ;
  2145. break;
  2146. case 11:
  2147. sample_rate = SAMPLING_RATE_352P8KHZ;
  2148. break;
  2149. case 12:
  2150. sample_rate = SAMPLING_RATE_384KHZ;
  2151. break;
  2152. default:
  2153. sample_rate = SAMPLING_RATE_48KHZ;
  2154. break;
  2155. }
  2156. return sample_rate;
  2157. }
  2158. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2159. struct snd_ctl_elem_value *ucontrol)
  2160. {
  2161. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2162. if (ch_num < 0) {
  2163. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2164. return ch_num;
  2165. }
  2166. ucontrol->value.enumerated.item[0] =
  2167. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2168. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2169. cdc_dma_rx_cfg[ch_num].sample_rate);
  2170. return 0;
  2171. }
  2172. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2173. struct snd_ctl_elem_value *ucontrol)
  2174. {
  2175. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2176. if (ch_num < 0) {
  2177. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2178. return ch_num;
  2179. }
  2180. cdc_dma_rx_cfg[ch_num].sample_rate =
  2181. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2182. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2183. __func__, ucontrol->value.enumerated.item[0],
  2184. cdc_dma_rx_cfg[ch_num].sample_rate);
  2185. return 0;
  2186. }
  2187. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2188. struct snd_ctl_elem_value *ucontrol)
  2189. {
  2190. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2191. if (ch_num < 0) {
  2192. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2193. return ch_num;
  2194. }
  2195. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2196. cdc_dma_tx_cfg[ch_num].channels);
  2197. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2198. return 0;
  2199. }
  2200. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2201. struct snd_ctl_elem_value *ucontrol)
  2202. {
  2203. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2204. if (ch_num < 0) {
  2205. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2206. return ch_num;
  2207. }
  2208. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2209. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2210. cdc_dma_tx_cfg[ch_num].channels);
  2211. return 1;
  2212. }
  2213. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2214. struct snd_ctl_elem_value *ucontrol)
  2215. {
  2216. int sample_rate_val;
  2217. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2218. if (ch_num < 0) {
  2219. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2220. return ch_num;
  2221. }
  2222. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2223. case SAMPLING_RATE_384KHZ:
  2224. sample_rate_val = 12;
  2225. break;
  2226. case SAMPLING_RATE_352P8KHZ:
  2227. sample_rate_val = 11;
  2228. break;
  2229. case SAMPLING_RATE_192KHZ:
  2230. sample_rate_val = 10;
  2231. break;
  2232. case SAMPLING_RATE_176P4KHZ:
  2233. sample_rate_val = 9;
  2234. break;
  2235. case SAMPLING_RATE_96KHZ:
  2236. sample_rate_val = 8;
  2237. break;
  2238. case SAMPLING_RATE_88P2KHZ:
  2239. sample_rate_val = 7;
  2240. break;
  2241. case SAMPLING_RATE_48KHZ:
  2242. sample_rate_val = 6;
  2243. break;
  2244. case SAMPLING_RATE_44P1KHZ:
  2245. sample_rate_val = 5;
  2246. break;
  2247. case SAMPLING_RATE_32KHZ:
  2248. sample_rate_val = 4;
  2249. break;
  2250. case SAMPLING_RATE_22P05KHZ:
  2251. sample_rate_val = 3;
  2252. break;
  2253. case SAMPLING_RATE_16KHZ:
  2254. sample_rate_val = 2;
  2255. break;
  2256. case SAMPLING_RATE_11P025KHZ:
  2257. sample_rate_val = 1;
  2258. break;
  2259. case SAMPLING_RATE_8KHZ:
  2260. sample_rate_val = 0;
  2261. break;
  2262. default:
  2263. sample_rate_val = 6;
  2264. break;
  2265. }
  2266. ucontrol->value.integer.value[0] = sample_rate_val;
  2267. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2268. cdc_dma_tx_cfg[ch_num].sample_rate);
  2269. return 0;
  2270. }
  2271. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2272. struct snd_ctl_elem_value *ucontrol)
  2273. {
  2274. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2275. if (ch_num < 0) {
  2276. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2277. return ch_num;
  2278. }
  2279. switch (ucontrol->value.integer.value[0]) {
  2280. case 12:
  2281. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2282. break;
  2283. case 11:
  2284. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2285. break;
  2286. case 10:
  2287. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2288. break;
  2289. case 9:
  2290. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2291. break;
  2292. case 8:
  2293. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2294. break;
  2295. case 7:
  2296. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2297. break;
  2298. case 6:
  2299. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2300. break;
  2301. case 5:
  2302. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2303. break;
  2304. case 4:
  2305. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2306. break;
  2307. case 3:
  2308. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2309. break;
  2310. case 2:
  2311. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2312. break;
  2313. case 1:
  2314. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2315. break;
  2316. case 0:
  2317. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2318. break;
  2319. default:
  2320. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2321. break;
  2322. }
  2323. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2324. __func__, ucontrol->value.integer.value[0],
  2325. cdc_dma_tx_cfg[ch_num].sample_rate);
  2326. return 0;
  2327. }
  2328. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  2329. struct snd_ctl_elem_value *ucontrol)
  2330. {
  2331. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2332. if (ch_num < 0) {
  2333. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2334. return ch_num;
  2335. }
  2336. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  2337. case SNDRV_PCM_FORMAT_S32_LE:
  2338. ucontrol->value.integer.value[0] = 3;
  2339. break;
  2340. case SNDRV_PCM_FORMAT_S24_3LE:
  2341. ucontrol->value.integer.value[0] = 2;
  2342. break;
  2343. case SNDRV_PCM_FORMAT_S24_LE:
  2344. ucontrol->value.integer.value[0] = 1;
  2345. break;
  2346. case SNDRV_PCM_FORMAT_S16_LE:
  2347. default:
  2348. ucontrol->value.integer.value[0] = 0;
  2349. break;
  2350. }
  2351. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2352. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2353. ucontrol->value.integer.value[0]);
  2354. return 0;
  2355. }
  2356. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2357. struct snd_ctl_elem_value *ucontrol)
  2358. {
  2359. int rc = 0;
  2360. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2361. if (ch_num < 0) {
  2362. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2363. return ch_num;
  2364. }
  2365. switch (ucontrol->value.integer.value[0]) {
  2366. case 3:
  2367. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2368. break;
  2369. case 2:
  2370. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2371. break;
  2372. case 1:
  2373. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2374. break;
  2375. case 0:
  2376. default:
  2377. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2378. break;
  2379. }
  2380. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2381. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2382. ucontrol->value.integer.value[0]);
  2383. return rc;
  2384. }
  2385. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  2386. {
  2387. int idx = 0;
  2388. switch (be_id) {
  2389. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2390. idx = WSA_CDC_DMA_RX_0;
  2391. break;
  2392. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2393. idx = WSA_CDC_DMA_TX_0;
  2394. break;
  2395. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2396. idx = WSA_CDC_DMA_RX_1;
  2397. break;
  2398. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2399. idx = WSA_CDC_DMA_TX_1;
  2400. break;
  2401. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2402. idx = WSA_CDC_DMA_TX_2;
  2403. break;
  2404. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2405. idx = RX_CDC_DMA_RX_0;
  2406. break;
  2407. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2408. idx = RX_CDC_DMA_RX_1;
  2409. break;
  2410. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2411. idx = RX_CDC_DMA_RX_2;
  2412. break;
  2413. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2414. idx = RX_CDC_DMA_RX_3;
  2415. break;
  2416. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2417. idx = RX_CDC_DMA_RX_5;
  2418. break;
  2419. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2420. idx = TX_CDC_DMA_TX_0;
  2421. break;
  2422. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2423. idx = TX_CDC_DMA_TX_3;
  2424. break;
  2425. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2426. idx = TX_CDC_DMA_TX_4;
  2427. break;
  2428. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2429. idx = VA_CDC_DMA_TX_0;
  2430. break;
  2431. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2432. idx = VA_CDC_DMA_TX_1;
  2433. break;
  2434. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2435. idx = VA_CDC_DMA_TX_2;
  2436. break;
  2437. default:
  2438. idx = RX_CDC_DMA_RX_0;
  2439. break;
  2440. }
  2441. return idx;
  2442. }
  2443. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  2444. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  2445. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2446. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  2447. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2448. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  2449. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2450. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  2451. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2452. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  2453. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2454. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  2455. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2456. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  2457. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  2458. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  2459. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2460. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  2461. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2462. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  2463. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2464. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  2465. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2466. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  2467. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2468. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  2469. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2470. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  2471. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2472. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  2473. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2474. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  2475. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  2476. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  2477. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2478. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  2479. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2480. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc_dma_rx_0_format,
  2481. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2482. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc_dma_rx_1_format,
  2483. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2484. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc_dma_rx_2_format,
  2485. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2486. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc_dma_rx_3_format,
  2487. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2488. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc_dma_rx_5_format,
  2489. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  2490. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  2491. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2492. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  2493. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2494. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  2495. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2496. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  2497. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2498. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  2499. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2500. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  2501. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2502. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  2503. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2504. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  2505. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  2506. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  2507. wsa_cdc_dma_rx_0_sample_rate,
  2508. cdc_dma_rx_sample_rate_get,
  2509. cdc_dma_rx_sample_rate_put),
  2510. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  2511. wsa_cdc_dma_rx_1_sample_rate,
  2512. cdc_dma_rx_sample_rate_get,
  2513. cdc_dma_rx_sample_rate_put),
  2514. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  2515. rx_cdc_dma_rx_0_sample_rate,
  2516. cdc_dma_rx_sample_rate_get,
  2517. cdc_dma_rx_sample_rate_put),
  2518. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  2519. rx_cdc_dma_rx_1_sample_rate,
  2520. cdc_dma_rx_sample_rate_get,
  2521. cdc_dma_rx_sample_rate_put),
  2522. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  2523. rx_cdc_dma_rx_2_sample_rate,
  2524. cdc_dma_rx_sample_rate_get,
  2525. cdc_dma_rx_sample_rate_put),
  2526. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  2527. rx_cdc_dma_rx_3_sample_rate,
  2528. cdc_dma_rx_sample_rate_get,
  2529. cdc_dma_rx_sample_rate_put),
  2530. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  2531. rx_cdc_dma_rx_5_sample_rate,
  2532. cdc_dma_rx_sample_rate_get,
  2533. cdc_dma_rx_sample_rate_put),
  2534. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  2535. wsa_cdc_dma_tx_0_sample_rate,
  2536. cdc_dma_tx_sample_rate_get,
  2537. cdc_dma_tx_sample_rate_put),
  2538. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  2539. wsa_cdc_dma_tx_1_sample_rate,
  2540. cdc_dma_tx_sample_rate_get,
  2541. cdc_dma_tx_sample_rate_put),
  2542. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  2543. wsa_cdc_dma_tx_2_sample_rate,
  2544. cdc_dma_tx_sample_rate_get,
  2545. cdc_dma_tx_sample_rate_put),
  2546. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  2547. tx_cdc_dma_tx_0_sample_rate,
  2548. cdc_dma_tx_sample_rate_get,
  2549. cdc_dma_tx_sample_rate_put),
  2550. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  2551. tx_cdc_dma_tx_3_sample_rate,
  2552. cdc_dma_tx_sample_rate_get,
  2553. cdc_dma_tx_sample_rate_put),
  2554. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  2555. tx_cdc_dma_tx_4_sample_rate,
  2556. cdc_dma_tx_sample_rate_get,
  2557. cdc_dma_tx_sample_rate_put),
  2558. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  2559. va_cdc_dma_tx_0_sample_rate,
  2560. cdc_dma_tx_sample_rate_get,
  2561. cdc_dma_tx_sample_rate_put),
  2562. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  2563. va_cdc_dma_tx_1_sample_rate,
  2564. cdc_dma_tx_sample_rate_get,
  2565. cdc_dma_tx_sample_rate_put),
  2566. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  2567. va_cdc_dma_tx_2_sample_rate,
  2568. cdc_dma_tx_sample_rate_get,
  2569. cdc_dma_tx_sample_rate_put),
  2570. };
  2571. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  2572. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  2573. usb_audio_rx_sample_rate_get,
  2574. usb_audio_rx_sample_rate_put),
  2575. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  2576. usb_audio_tx_sample_rate_get,
  2577. usb_audio_tx_sample_rate_put),
  2578. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2579. tdm_rx_sample_rate_get,
  2580. tdm_rx_sample_rate_put),
  2581. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2582. tdm_rx_sample_rate_get,
  2583. tdm_rx_sample_rate_put),
  2584. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  2585. tdm_rx_sample_rate_get,
  2586. tdm_rx_sample_rate_put),
  2587. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2588. tdm_tx_sample_rate_get,
  2589. tdm_tx_sample_rate_put),
  2590. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2591. tdm_tx_sample_rate_get,
  2592. tdm_tx_sample_rate_put),
  2593. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  2594. tdm_tx_sample_rate_get,
  2595. tdm_tx_sample_rate_put),
  2596. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  2597. aux_pcm_rx_sample_rate_get,
  2598. aux_pcm_rx_sample_rate_put),
  2599. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  2600. aux_pcm_rx_sample_rate_get,
  2601. aux_pcm_rx_sample_rate_put),
  2602. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  2603. aux_pcm_rx_sample_rate_get,
  2604. aux_pcm_rx_sample_rate_put),
  2605. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  2606. aux_pcm_tx_sample_rate_get,
  2607. aux_pcm_tx_sample_rate_put),
  2608. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  2609. aux_pcm_tx_sample_rate_get,
  2610. aux_pcm_tx_sample_rate_put),
  2611. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  2612. aux_pcm_tx_sample_rate_get,
  2613. aux_pcm_tx_sample_rate_put),
  2614. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  2615. mi2s_rx_sample_rate_get,
  2616. mi2s_rx_sample_rate_put),
  2617. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  2618. mi2s_rx_sample_rate_get,
  2619. mi2s_rx_sample_rate_put),
  2620. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  2621. mi2s_rx_sample_rate_get,
  2622. mi2s_rx_sample_rate_put),
  2623. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  2624. mi2s_tx_sample_rate_get,
  2625. mi2s_tx_sample_rate_put),
  2626. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  2627. mi2s_tx_sample_rate_get,
  2628. mi2s_tx_sample_rate_put),
  2629. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  2630. mi2s_tx_sample_rate_get,
  2631. mi2s_tx_sample_rate_put),
  2632. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  2633. usb_audio_rx_format_get, usb_audio_rx_format_put),
  2634. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  2635. usb_audio_tx_format_get, usb_audio_tx_format_put),
  2636. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  2637. tdm_rx_format_get,
  2638. tdm_rx_format_put),
  2639. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  2640. tdm_rx_format_get,
  2641. tdm_rx_format_put),
  2642. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  2643. tdm_rx_format_get,
  2644. tdm_rx_format_put),
  2645. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  2646. tdm_tx_format_get,
  2647. tdm_tx_format_put),
  2648. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  2649. tdm_tx_format_get,
  2650. tdm_tx_format_put),
  2651. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  2652. tdm_tx_format_get,
  2653. tdm_tx_format_put),
  2654. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2655. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2656. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  2657. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2658. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  2659. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2660. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2661. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2662. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  2663. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2664. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  2665. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2666. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  2667. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2668. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  2669. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2670. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  2671. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  2672. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  2673. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2674. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  2675. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2676. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  2677. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  2678. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  2679. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  2680. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  2681. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  2682. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  2683. proxy_rx_ch_get, proxy_rx_ch_put),
  2684. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  2685. tdm_rx_ch_get,
  2686. tdm_rx_ch_put),
  2687. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  2688. tdm_rx_ch_get,
  2689. tdm_rx_ch_put),
  2690. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  2691. tdm_rx_ch_get,
  2692. tdm_rx_ch_put),
  2693. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  2694. tdm_tx_ch_get,
  2695. tdm_tx_ch_put),
  2696. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  2697. tdm_tx_ch_get,
  2698. tdm_tx_ch_put),
  2699. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  2700. tdm_tx_ch_get,
  2701. tdm_tx_ch_put),
  2702. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  2703. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2704. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  2705. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2706. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  2707. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  2708. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  2709. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2710. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  2711. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2712. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  2713. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  2714. };
  2715. static const struct snd_kcontrol_new msm_snd_controls[] = {
  2716. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  2717. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  2718. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  2719. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  2720. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  2721. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  2722. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  2723. ext_disp_rx_format_get, ext_disp_rx_format_put),
  2724. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  2725. aux_pcm_rx_sample_rate_get,
  2726. aux_pcm_rx_sample_rate_put),
  2727. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  2728. aux_pcm_tx_sample_rate_get,
  2729. aux_pcm_tx_sample_rate_put),
  2730. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  2731. ext_disp_rx_sample_rate_get,
  2732. ext_disp_rx_sample_rate_put),
  2733. };
  2734. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  2735. {
  2736. int idx;
  2737. switch (be_id) {
  2738. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  2739. idx = EXT_DISP_RX_IDX_DP;
  2740. break;
  2741. default:
  2742. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  2743. idx = -EINVAL;
  2744. break;
  2745. }
  2746. return idx;
  2747. }
  2748. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  2749. struct snd_pcm_hw_params *params)
  2750. {
  2751. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  2752. struct snd_interval *rate = hw_param_interval(params,
  2753. SNDRV_PCM_HW_PARAM_RATE);
  2754. struct snd_interval *channels = hw_param_interval(params,
  2755. SNDRV_PCM_HW_PARAM_CHANNELS);
  2756. int idx, rc = 0;
  2757. pr_debug("%s: format = %d, rate = %d\n",
  2758. __func__, params_format(params), params_rate(params));
  2759. switch (dai_link->id) {
  2760. case MSM_BACKEND_DAI_USB_RX:
  2761. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2762. usb_rx_cfg.bit_format);
  2763. rate->min = rate->max = usb_rx_cfg.sample_rate;
  2764. channels->min = channels->max = usb_rx_cfg.channels;
  2765. break;
  2766. case MSM_BACKEND_DAI_USB_TX:
  2767. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2768. usb_tx_cfg.bit_format);
  2769. rate->min = rate->max = usb_tx_cfg.sample_rate;
  2770. channels->min = channels->max = usb_tx_cfg.channels;
  2771. break;
  2772. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  2773. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  2774. if (idx < 0) {
  2775. pr_err("%s: Incorrect ext disp idx %d\n",
  2776. __func__, idx);
  2777. rc = idx;
  2778. goto done;
  2779. }
  2780. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2781. ext_disp_rx_cfg[idx].bit_format);
  2782. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  2783. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  2784. break;
  2785. case MSM_BACKEND_DAI_AFE_PCM_RX:
  2786. channels->min = channels->max = proxy_rx_cfg.channels;
  2787. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  2788. break;
  2789. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  2790. channels->min = channels->max =
  2791. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  2792. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2793. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  2794. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  2795. break;
  2796. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  2797. channels->min = channels->max =
  2798. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  2799. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2800. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  2801. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  2802. break;
  2803. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  2804. channels->min = channels->max =
  2805. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  2806. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2807. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  2808. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  2809. break;
  2810. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  2811. channels->min = channels->max =
  2812. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  2813. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2814. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  2815. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  2816. break;
  2817. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  2818. channels->min = channels->max =
  2819. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  2820. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2821. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  2822. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  2823. break;
  2824. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  2825. channels->min = channels->max =
  2826. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  2827. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2828. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  2829. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  2830. break;
  2831. case MSM_BACKEND_DAI_AUXPCM_RX:
  2832. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2833. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  2834. rate->min = rate->max =
  2835. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  2836. channels->min = channels->max =
  2837. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  2838. break;
  2839. case MSM_BACKEND_DAI_AUXPCM_TX:
  2840. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2841. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  2842. rate->min = rate->max =
  2843. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  2844. channels->min = channels->max =
  2845. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  2846. break;
  2847. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  2848. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2849. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  2850. rate->min = rate->max =
  2851. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  2852. channels->min = channels->max =
  2853. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  2854. break;
  2855. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  2856. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2857. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  2858. rate->min = rate->max =
  2859. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  2860. channels->min = channels->max =
  2861. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  2862. break;
  2863. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  2864. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2865. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  2866. rate->min = rate->max =
  2867. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  2868. channels->min = channels->max =
  2869. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  2870. break;
  2871. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  2872. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2873. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  2874. rate->min = rate->max =
  2875. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  2876. channels->min = channels->max =
  2877. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  2878. break;
  2879. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  2880. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2881. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  2882. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  2883. channels->min = channels->max =
  2884. mi2s_rx_cfg[PRIM_MI2S].channels;
  2885. break;
  2886. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  2887. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2888. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  2889. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  2890. channels->min = channels->max =
  2891. mi2s_tx_cfg[PRIM_MI2S].channels;
  2892. break;
  2893. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  2894. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2895. mi2s_rx_cfg[SEC_MI2S].bit_format);
  2896. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  2897. channels->min = channels->max =
  2898. mi2s_rx_cfg[SEC_MI2S].channels;
  2899. break;
  2900. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  2901. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2902. mi2s_tx_cfg[SEC_MI2S].bit_format);
  2903. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  2904. channels->min = channels->max =
  2905. mi2s_tx_cfg[SEC_MI2S].channels;
  2906. break;
  2907. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  2908. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2909. mi2s_rx_cfg[TERT_MI2S].bit_format);
  2910. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  2911. channels->min = channels->max =
  2912. mi2s_rx_cfg[TERT_MI2S].channels;
  2913. break;
  2914. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  2915. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2916. mi2s_tx_cfg[TERT_MI2S].bit_format);
  2917. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  2918. channels->min = channels->max =
  2919. mi2s_tx_cfg[TERT_MI2S].channels;
  2920. break;
  2921. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2922. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2923. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2924. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  2925. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  2926. cdc_dma_tx_cfg[idx].bit_format);
  2927. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  2928. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  2929. break;
  2930. default:
  2931. rate->min = rate->max = SAMPLING_RATE_8KHZ;
  2932. break;
  2933. }
  2934. done:
  2935. return rc;
  2936. }
  2937. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  2938. {
  2939. struct snd_soc_card *card = component->card;
  2940. struct msm_asoc_mach_data *pdata =
  2941. snd_soc_card_get_drvdata(card);
  2942. if (!pdata->fsa_handle)
  2943. return false;
  2944. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  2945. }
  2946. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  2947. {
  2948. int value = 0;
  2949. bool ret = false;
  2950. struct snd_soc_card *card;
  2951. struct msm_asoc_mach_data *pdata;
  2952. if (!component) {
  2953. pr_err("%s component is NULL\n", __func__);
  2954. return false;
  2955. }
  2956. card = component->card;
  2957. pdata = snd_soc_card_get_drvdata(card);
  2958. if (!pdata)
  2959. return false;
  2960. if (wcd_mbhc_cfg.enable_usbc_analog)
  2961. return msm_usbc_swap_gnd_mic(component, active);
  2962. /* if usbc is not defined, swap using us_euro_gpio_p */
  2963. if (pdata->us_euro_gpio_p) {
  2964. value = msm_cdc_pinctrl_get_state(
  2965. pdata->us_euro_gpio_p);
  2966. if (value)
  2967. msm_cdc_pinctrl_select_sleep_state(
  2968. pdata->us_euro_gpio_p);
  2969. else
  2970. msm_cdc_pinctrl_select_active_state(
  2971. pdata->us_euro_gpio_p);
  2972. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  2973. __func__, value, !value);
  2974. ret = true;
  2975. }
  2976. return ret;
  2977. }
  2978. static int kona_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  2979. struct snd_pcm_hw_params *params)
  2980. {
  2981. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2982. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2983. int ret = 0;
  2984. int slot_width = 32;
  2985. int channels, slots;
  2986. unsigned int slot_mask, rate, clk_freq;
  2987. unsigned int slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
  2988. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  2989. /* currently only supporting TDM_RX_0 and TDM_TX_0 */
  2990. switch (cpu_dai->id) {
  2991. case AFE_PORT_ID_PRIMARY_TDM_RX:
  2992. slots = tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  2993. break;
  2994. case AFE_PORT_ID_SECONDARY_TDM_RX:
  2995. slots = tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  2996. break;
  2997. case AFE_PORT_ID_TERTIARY_TDM_RX:
  2998. slots = tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  2999. break;
  3000. case AFE_PORT_ID_PRIMARY_TDM_TX:
  3001. slots = tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3002. break;
  3003. case AFE_PORT_ID_SECONDARY_TDM_TX:
  3004. slots = tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3005. break;
  3006. case AFE_PORT_ID_TERTIARY_TDM_TX:
  3007. slots = tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3008. break;
  3009. default:
  3010. pr_err("%s: dai id 0x%x not supported\n",
  3011. __func__, cpu_dai->id);
  3012. return -EINVAL;
  3013. }
  3014. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3015. /*2 slot config - bits 0 and 1 set for the first two slots */
  3016. slot_mask = 0x0000FFFF >> (16 - slots);
  3017. channels = slots;
  3018. pr_debug("%s: tdm rx slot_width %d slots %d\n",
  3019. __func__, slot_width, slots);
  3020. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  3021. slots, slot_width);
  3022. if (ret < 0) {
  3023. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  3024. __func__, ret);
  3025. goto end;
  3026. }
  3027. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3028. 0, NULL, channels, slot_offset);
  3029. if (ret < 0) {
  3030. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  3031. __func__, ret);
  3032. goto end;
  3033. }
  3034. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  3035. /*2 slot config - bits 0 and 1 set for the first two slots */
  3036. slot_mask = 0x0000FFFF >> (16 - slots);
  3037. channels = slots;
  3038. pr_debug("%s: tdm tx slot_width %d slots %d\n",
  3039. __func__, slot_width, slots);
  3040. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  3041. slots, slot_width);
  3042. if (ret < 0) {
  3043. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  3044. __func__, ret);
  3045. goto end;
  3046. }
  3047. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3048. channels, slot_offset, 0, NULL);
  3049. if (ret < 0) {
  3050. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  3051. __func__, ret);
  3052. goto end;
  3053. }
  3054. } else {
  3055. ret = -EINVAL;
  3056. pr_err("%s: invalid use case, err:%d\n",
  3057. __func__, ret);
  3058. goto end;
  3059. }
  3060. rate = params_rate(params);
  3061. clk_freq = rate * slot_width * slots;
  3062. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  3063. if (ret < 0)
  3064. pr_err("%s: failed to set tdm clk, err:%d\n",
  3065. __func__, ret);
  3066. end:
  3067. return ret;
  3068. }
  3069. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  3070. struct snd_pcm_hw_params *params)
  3071. {
  3072. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3073. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3074. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3075. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3076. int ret = 0;
  3077. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  3078. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3079. u32 user_set_tx_ch = 0;
  3080. u32 user_set_rx_ch = 0;
  3081. u32 ch_id;
  3082. ret = snd_soc_dai_get_channel_map(codec_dai,
  3083. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  3084. &rx_ch_cdc_dma);
  3085. if (ret < 0) {
  3086. pr_err("%s: failed to get codec chan map, err:%d\n",
  3087. __func__, ret);
  3088. goto err;
  3089. }
  3090. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  3091. switch (dai_link->id) {
  3092. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3093. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3094. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3095. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3096. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3097. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3098. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  3099. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  3100. {
  3101. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3102. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  3103. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  3104. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  3105. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  3106. user_set_rx_ch, &rx_ch_cdc_dma);
  3107. if (ret < 0) {
  3108. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3109. __func__, ret);
  3110. goto err;
  3111. }
  3112. }
  3113. break;
  3114. }
  3115. } else {
  3116. switch (dai_link->id) {
  3117. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3118. {
  3119. user_set_tx_ch = msm_vi_feed_tx_ch;
  3120. }
  3121. break;
  3122. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3123. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3124. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3125. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3126. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3127. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3128. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3129. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3130. {
  3131. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  3132. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  3133. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  3134. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  3135. }
  3136. break;
  3137. }
  3138. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  3139. &tx_ch_cdc_dma, 0, 0);
  3140. if (ret < 0) {
  3141. pr_err("%s: failed to set cpu chan map, err:%d\n",
  3142. __func__, ret);
  3143. goto err;
  3144. }
  3145. }
  3146. err:
  3147. return ret;
  3148. }
  3149. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  3150. {
  3151. cpumask_t mask;
  3152. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  3153. pm_qos_remove_request(&substream->latency_pm_qos_req);
  3154. cpumask_clear(&mask);
  3155. cpumask_set_cpu(1, &mask); /* affine to core 1 */
  3156. cpumask_set_cpu(2, &mask); /* affine to core 2 */
  3157. cpumask_copy(&substream->latency_pm_qos_req.cpus_affine, &mask);
  3158. substream->latency_pm_qos_req.type = PM_QOS_REQ_AFFINE_CORES;
  3159. pm_qos_add_request(&substream->latency_pm_qos_req,
  3160. PM_QOS_CPU_DMA_LATENCY,
  3161. MSM_LL_QOS_VALUE);
  3162. return 0;
  3163. }
  3164. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  3165. {
  3166. int ret = 0;
  3167. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3168. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3169. int index = cpu_dai->id;
  3170. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  3171. dev_dbg(rtd->card->dev,
  3172. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  3173. __func__, substream->name, substream->stream,
  3174. cpu_dai->name, cpu_dai->id);
  3175. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  3176. ret = -EINVAL;
  3177. dev_err(rtd->card->dev,
  3178. "%s: CPU DAI id (%d) out of range\n",
  3179. __func__, cpu_dai->id);
  3180. goto err;
  3181. }
  3182. /*
  3183. * Mutex protection in case the same MI2S
  3184. * interface using for both TX and RX so
  3185. * that the same clock won't be enable twice.
  3186. */
  3187. mutex_lock(&mi2s_intf_conf[index].lock);
  3188. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  3189. /* Check if msm needs to provide the clock to the interface */
  3190. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  3191. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  3192. fmt = SND_SOC_DAIFMT_CBM_CFM;
  3193. }
  3194. ret = msm_mi2s_set_sclk(substream, true);
  3195. if (ret < 0) {
  3196. dev_err(rtd->card->dev,
  3197. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  3198. __func__, ret);
  3199. goto clean_up;
  3200. }
  3201. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  3202. if (ret < 0) {
  3203. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  3204. __func__, index, ret);
  3205. goto clk_off;
  3206. }
  3207. }
  3208. clk_off:
  3209. if (ret < 0)
  3210. msm_mi2s_set_sclk(substream, false);
  3211. clean_up:
  3212. if (ret < 0)
  3213. mi2s_intf_conf[index].ref_cnt--;
  3214. mutex_unlock(&mi2s_intf_conf[index].lock);
  3215. err:
  3216. return ret;
  3217. }
  3218. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  3219. {
  3220. int ret = 0;
  3221. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3222. int index = rtd->cpu_dai->id;
  3223. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  3224. substream->name, substream->stream);
  3225. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  3226. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  3227. return;
  3228. }
  3229. mutex_lock(&mi2s_intf_conf[index].lock);
  3230. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  3231. ret = msm_mi2s_set_sclk(substream, false);
  3232. if (ret < 0)
  3233. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  3234. __func__, index, ret);
  3235. }
  3236. mutex_unlock(&mi2s_intf_conf[index].lock);
  3237. }
  3238. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  3239. struct snd_pcm_hw_params *params)
  3240. {
  3241. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  3242. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3243. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  3244. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3245. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  3246. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  3247. int ret = 0;
  3248. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  3249. codec_dai->name, codec_dai->id);
  3250. ret = snd_soc_dai_get_channel_map(codec_dai,
  3251. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  3252. if (ret) {
  3253. dev_err(rtd->dev,
  3254. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  3255. __func__, ret);
  3256. goto err;
  3257. }
  3258. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  3259. __func__, tx_ch_cnt, dai_link->id);
  3260. ret = snd_soc_dai_set_channel_map(cpu_dai,
  3261. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  3262. if (ret)
  3263. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  3264. __func__, ret);
  3265. err:
  3266. return ret;
  3267. }
  3268. static struct snd_soc_ops kona_tdm_be_ops = {
  3269. .hw_params = kona_tdm_snd_hw_params,
  3270. };
  3271. static struct snd_soc_ops msm_mi2s_be_ops = {
  3272. .startup = msm_mi2s_snd_startup,
  3273. .shutdown = msm_mi2s_snd_shutdown,
  3274. };
  3275. static struct snd_soc_ops msm_fe_qos_ops = {
  3276. .prepare = msm_fe_qos_prepare,
  3277. };
  3278. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  3279. .hw_params = msm_snd_cdc_dma_hw_params,
  3280. };
  3281. static struct snd_soc_ops msm_wcn_ops = {
  3282. .hw_params = msm_wcn_hw_params,
  3283. };
  3284. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  3285. struct snd_kcontrol *kcontrol, int event)
  3286. {
  3287. struct msm_asoc_mach_data *pdata = NULL;
  3288. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  3289. int ret = 0;
  3290. u32 dmic_idx;
  3291. int *dmic_gpio_cnt;
  3292. struct device_node *dmic_gpio;
  3293. char *wname;
  3294. wname = strpbrk(w->name, "012345");
  3295. if (!wname) {
  3296. dev_err(component->dev, "%s: widget not found\n", __func__);
  3297. return -EINVAL;
  3298. }
  3299. ret = kstrtouint(wname, 10, &dmic_idx);
  3300. if (ret < 0) {
  3301. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  3302. __func__);
  3303. return -EINVAL;
  3304. }
  3305. pdata = snd_soc_card_get_drvdata(component->card);
  3306. switch (dmic_idx) {
  3307. case 0:
  3308. case 1:
  3309. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  3310. dmic_gpio = pdata->dmic01_gpio_p;
  3311. break;
  3312. case 2:
  3313. case 3:
  3314. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  3315. dmic_gpio = pdata->dmic23_gpio_p;
  3316. break;
  3317. case 4:
  3318. case 5:
  3319. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  3320. dmic_gpio = pdata->dmic45_gpio_p;
  3321. break;
  3322. default:
  3323. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  3324. __func__);
  3325. return -EINVAL;
  3326. }
  3327. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  3328. __func__, event, dmic_idx, *dmic_gpio_cnt);
  3329. switch (event) {
  3330. case SND_SOC_DAPM_PRE_PMU:
  3331. (*dmic_gpio_cnt)++;
  3332. if (*dmic_gpio_cnt == 1) {
  3333. ret = msm_cdc_pinctrl_select_active_state(
  3334. dmic_gpio);
  3335. if (ret < 0) {
  3336. pr_err("%s: gpio set cannot be activated %sd",
  3337. __func__, "dmic_gpio");
  3338. return ret;
  3339. }
  3340. }
  3341. break;
  3342. case SND_SOC_DAPM_POST_PMD:
  3343. (*dmic_gpio_cnt)--;
  3344. if (*dmic_gpio_cnt == 0) {
  3345. ret = msm_cdc_pinctrl_select_sleep_state(
  3346. dmic_gpio);
  3347. if (ret < 0) {
  3348. pr_err("%s: gpio set cannot be de-activated %sd",
  3349. __func__, "dmic_gpio");
  3350. return ret;
  3351. }
  3352. }
  3353. break;
  3354. default:
  3355. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  3356. return -EINVAL;
  3357. }
  3358. return 0;
  3359. }
  3360. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  3361. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  3362. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  3363. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  3364. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  3365. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  3366. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  3367. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  3368. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  3369. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  3370. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  3371. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  3372. };
  3373. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  3374. {
  3375. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  3376. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  3377. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  3378. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  3379. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  3380. }
  3381. static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd)
  3382. {
  3383. int ret = -EINVAL;
  3384. struct snd_soc_component *component;
  3385. struct snd_soc_dapm_context *dapm;
  3386. struct snd_card *card;
  3387. struct snd_info_entry *entry;
  3388. struct snd_soc_component *aux_comp;
  3389. struct msm_asoc_mach_data *pdata =
  3390. snd_soc_card_get_drvdata(rtd->card);
  3391. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  3392. if (!component) {
  3393. pr_err("%s: could not find component for bolero_codec\n",
  3394. __func__);
  3395. return ret;
  3396. }
  3397. dapm = snd_soc_component_get_dapm(component);
  3398. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  3399. ARRAY_SIZE(msm_int_snd_controls));
  3400. if (ret < 0) {
  3401. pr_err("%s: add_component_controls failed: %d\n",
  3402. __func__, ret);
  3403. return ret;
  3404. }
  3405. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  3406. ARRAY_SIZE(msm_common_snd_controls));
  3407. if (ret < 0) {
  3408. pr_err("%s: add common snd controls failed: %d\n",
  3409. __func__, ret);
  3410. return ret;
  3411. }
  3412. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  3413. ARRAY_SIZE(msm_int_dapm_widgets));
  3414. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  3415. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  3416. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  3417. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  3418. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  3419. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  3420. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  3421. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  3422. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  3423. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  3424. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  3425. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  3426. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  3427. snd_soc_dapm_sync(dapm);
  3428. /*
  3429. * Send speaker configuration only for WSA8810.
  3430. * Default configuration is for WSA8815.
  3431. */
  3432. dev_dbg(component->dev, "%s: Number of aux devices: %d\n",
  3433. __func__, rtd->card->num_aux_devs);
  3434. if (rtd->card->num_aux_devs &&
  3435. !list_empty(&rtd->card->component_dev_list)) {
  3436. aux_comp = list_first_entry(
  3437. &rtd->card->component_dev_list,
  3438. struct snd_soc_component,
  3439. card_aux_list);
  3440. if (!strcmp(aux_comp->name, WSA8810_NAME_1) ||
  3441. !strcmp(aux_comp->name, WSA8810_NAME_2)) {
  3442. wsa_macro_set_spkr_mode(component,
  3443. WSA_MACRO_SPKR_MODE_1);
  3444. wsa_macro_set_spkr_gain_offset(component,
  3445. WSA_MACRO_GAIN_OFFSET_M1P5_DB);
  3446. }
  3447. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
  3448. sm_port_map);
  3449. }
  3450. card = rtd->card->snd_card;
  3451. if (!pdata->codec_root) {
  3452. entry = snd_info_create_subdir(card->module, "codecs",
  3453. card->proc_root);
  3454. if (!entry) {
  3455. pr_debug("%s: Cannot create codecs module entry\n",
  3456. __func__);
  3457. ret = 0;
  3458. goto err;
  3459. }
  3460. pdata->codec_root = entry;
  3461. }
  3462. bolero_info_create_codec_entry(pdata->codec_root, component);
  3463. bolero_register_wake_irq(component, false);
  3464. codec_reg_done = true;
  3465. return 0;
  3466. err:
  3467. return ret;
  3468. }
  3469. static void *def_wcd_mbhc_cal(void)
  3470. {
  3471. void *wcd_mbhc_cal;
  3472. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  3473. u16 *btn_high;
  3474. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  3475. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  3476. if (!wcd_mbhc_cal)
  3477. return NULL;
  3478. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  3479. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  3480. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  3481. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  3482. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  3483. btn_high[0] = 75;
  3484. btn_high[1] = 150;
  3485. btn_high[2] = 237;
  3486. btn_high[3] = 500;
  3487. btn_high[4] = 500;
  3488. btn_high[5] = 500;
  3489. btn_high[6] = 500;
  3490. btn_high[7] = 500;
  3491. return wcd_mbhc_cal;
  3492. }
  3493. /* Digital audio interface glue - connects codec <---> CPU */
  3494. static struct snd_soc_dai_link msm_common_dai_links[] = {
  3495. /* FrontEnd DAI Links */
  3496. {/* hw:x,0 */
  3497. .name = MSM_DAILINK_NAME(Media1),
  3498. .stream_name = "MultiMedia1",
  3499. .cpu_dai_name = "MultiMedia1",
  3500. .platform_name = "msm-pcm-dsp.0",
  3501. .dynamic = 1,
  3502. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3503. .dpcm_playback = 1,
  3504. .dpcm_capture = 1,
  3505. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3506. SND_SOC_DPCM_TRIGGER_POST},
  3507. .codec_dai_name = "snd-soc-dummy-dai",
  3508. .codec_name = "snd-soc-dummy",
  3509. .ignore_suspend = 1,
  3510. /* this dainlink has playback support */
  3511. .ignore_pmdown_time = 1,
  3512. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  3513. },
  3514. {/* hw:x,1 */
  3515. .name = MSM_DAILINK_NAME(Media2),
  3516. .stream_name = "MultiMedia2",
  3517. .cpu_dai_name = "MultiMedia2",
  3518. .platform_name = "msm-pcm-dsp.0",
  3519. .dynamic = 1,
  3520. .dpcm_playback = 1,
  3521. .dpcm_capture = 1,
  3522. .codec_dai_name = "snd-soc-dummy-dai",
  3523. .codec_name = "snd-soc-dummy",
  3524. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3525. SND_SOC_DPCM_TRIGGER_POST},
  3526. .ignore_suspend = 1,
  3527. /* this dainlink has playback support */
  3528. .ignore_pmdown_time = 1,
  3529. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  3530. },
  3531. {/* hw:x,2 */
  3532. .name = "VoiceMMode1",
  3533. .stream_name = "VoiceMMode1",
  3534. .cpu_dai_name = "VoiceMMode1",
  3535. .platform_name = "msm-pcm-voice",
  3536. .dynamic = 1,
  3537. .dpcm_playback = 1,
  3538. .dpcm_capture = 1,
  3539. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3540. SND_SOC_DPCM_TRIGGER_POST},
  3541. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3542. .ignore_suspend = 1,
  3543. .ignore_pmdown_time = 1,
  3544. .codec_dai_name = "snd-soc-dummy-dai",
  3545. .codec_name = "snd-soc-dummy",
  3546. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  3547. },
  3548. {/* hw:x,3 */
  3549. .name = "MSM VoIP",
  3550. .stream_name = "VoIP",
  3551. .cpu_dai_name = "VoIP",
  3552. .platform_name = "msm-voip-dsp",
  3553. .dynamic = 1,
  3554. .dpcm_playback = 1,
  3555. .dpcm_capture = 1,
  3556. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3557. SND_SOC_DPCM_TRIGGER_POST},
  3558. .codec_dai_name = "snd-soc-dummy-dai",
  3559. .codec_name = "snd-soc-dummy",
  3560. .ignore_suspend = 1,
  3561. /* this dainlink has playback support */
  3562. .ignore_pmdown_time = 1,
  3563. .id = MSM_FRONTEND_DAI_VOIP,
  3564. },
  3565. {/* hw:x,4 */
  3566. .name = MSM_DAILINK_NAME(ULL),
  3567. .stream_name = "MultiMedia3",
  3568. .cpu_dai_name = "MultiMedia3",
  3569. .platform_name = "msm-pcm-dsp.2",
  3570. .dynamic = 1,
  3571. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3572. .dpcm_playback = 1,
  3573. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3574. SND_SOC_DPCM_TRIGGER_POST},
  3575. .codec_dai_name = "snd-soc-dummy-dai",
  3576. .codec_name = "snd-soc-dummy",
  3577. .ignore_suspend = 1,
  3578. /* this dainlink has playback support */
  3579. .ignore_pmdown_time = 1,
  3580. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  3581. },
  3582. /* Hostless PCM purpose */
  3583. {/* hw:x,5 */
  3584. .name = "MSM AFE-PCM RX",
  3585. .stream_name = "AFE-PROXY RX",
  3586. .cpu_dai_name = "msm-dai-q6-dev.241",
  3587. .codec_name = "msm-stub-codec.1",
  3588. .codec_dai_name = "msm-stub-rx",
  3589. .platform_name = "msm-pcm-afe",
  3590. .dpcm_playback = 1,
  3591. .ignore_suspend = 1,
  3592. /* this dainlink has playback support */
  3593. .ignore_pmdown_time = 1,
  3594. },
  3595. {/* hw:x,6 */
  3596. .name = "MSM AFE-PCM TX",
  3597. .stream_name = "AFE-PROXY TX",
  3598. .cpu_dai_name = "msm-dai-q6-dev.240",
  3599. .codec_name = "msm-stub-codec.1",
  3600. .codec_dai_name = "msm-stub-tx",
  3601. .platform_name = "msm-pcm-afe",
  3602. .dpcm_capture = 1,
  3603. .ignore_suspend = 1,
  3604. },
  3605. {/* hw:x,7 */
  3606. .name = MSM_DAILINK_NAME(Compress1),
  3607. .stream_name = "Compress1",
  3608. .cpu_dai_name = "MultiMedia4",
  3609. .platform_name = "msm-compress-dsp",
  3610. .dynamic = 1,
  3611. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  3612. .dpcm_playback = 1,
  3613. .dpcm_capture = 1,
  3614. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3615. SND_SOC_DPCM_TRIGGER_POST},
  3616. .codec_dai_name = "snd-soc-dummy-dai",
  3617. .codec_name = "snd-soc-dummy",
  3618. .ignore_suspend = 1,
  3619. .ignore_pmdown_time = 1,
  3620. /* this dainlink has playback support */
  3621. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  3622. },
  3623. {/* hw:x,8 */
  3624. .name = "AUXPCM Hostless",
  3625. .stream_name = "AUXPCM Hostless",
  3626. .cpu_dai_name = "AUXPCM_HOSTLESS",
  3627. .platform_name = "msm-pcm-hostless",
  3628. .dynamic = 1,
  3629. .dpcm_playback = 1,
  3630. .dpcm_capture = 1,
  3631. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3632. SND_SOC_DPCM_TRIGGER_POST},
  3633. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3634. .ignore_suspend = 1,
  3635. /* this dainlink has playback support */
  3636. .ignore_pmdown_time = 1,
  3637. .codec_dai_name = "snd-soc-dummy-dai",
  3638. .codec_name = "snd-soc-dummy",
  3639. },
  3640. {/* hw:x,9 */
  3641. .name = MSM_DAILINK_NAME(LowLatency),
  3642. .stream_name = "MultiMedia5",
  3643. .cpu_dai_name = "MultiMedia5",
  3644. .platform_name = "msm-pcm-dsp.1",
  3645. .dynamic = 1,
  3646. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  3647. .dpcm_playback = 1,
  3648. .dpcm_capture = 1,
  3649. .codec_dai_name = "snd-soc-dummy-dai",
  3650. .codec_name = "snd-soc-dummy",
  3651. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3652. SND_SOC_DPCM_TRIGGER_POST},
  3653. .ignore_suspend = 1,
  3654. /* this dainlink has playback support */
  3655. .ignore_pmdown_time = 1,
  3656. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  3657. .ops = &msm_fe_qos_ops,
  3658. },
  3659. {/* hw:x,10 */
  3660. .name = "Listen 1 Audio Service",
  3661. .stream_name = "Listen 1 Audio Service",
  3662. .cpu_dai_name = "LSM1",
  3663. .platform_name = "msm-lsm-client",
  3664. .dynamic = 1,
  3665. .dpcm_capture = 1,
  3666. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3667. SND_SOC_DPCM_TRIGGER_POST },
  3668. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3669. .ignore_suspend = 1,
  3670. .codec_dai_name = "snd-soc-dummy-dai",
  3671. .codec_name = "snd-soc-dummy",
  3672. .id = MSM_FRONTEND_DAI_LSM1,
  3673. },
  3674. /* Multiple Tunnel instances */
  3675. {/* hw:x,11 */
  3676. .name = MSM_DAILINK_NAME(Compress2),
  3677. .stream_name = "Compress2",
  3678. .cpu_dai_name = "MultiMedia7",
  3679. .platform_name = "msm-compress-dsp",
  3680. .dynamic = 1,
  3681. .dpcm_playback = 1,
  3682. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3683. SND_SOC_DPCM_TRIGGER_POST},
  3684. .codec_dai_name = "snd-soc-dummy-dai",
  3685. .codec_name = "snd-soc-dummy",
  3686. .ignore_suspend = 1,
  3687. .ignore_pmdown_time = 1,
  3688. /* this dainlink has playback support */
  3689. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  3690. },
  3691. {/* hw:x,12 */
  3692. .name = MSM_DAILINK_NAME(MultiMedia10),
  3693. .stream_name = "MultiMedia10",
  3694. .cpu_dai_name = "MultiMedia10",
  3695. .platform_name = "msm-pcm-dsp.1",
  3696. .dynamic = 1,
  3697. .dpcm_playback = 1,
  3698. .dpcm_capture = 1,
  3699. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3700. SND_SOC_DPCM_TRIGGER_POST},
  3701. .codec_dai_name = "snd-soc-dummy-dai",
  3702. .codec_name = "snd-soc-dummy",
  3703. .ignore_suspend = 1,
  3704. .ignore_pmdown_time = 1,
  3705. /* this dainlink has playback support */
  3706. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  3707. },
  3708. {/* hw:x,13 */
  3709. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  3710. .stream_name = "MM_NOIRQ",
  3711. .cpu_dai_name = "MultiMedia8",
  3712. .platform_name = "msm-pcm-dsp-noirq",
  3713. .dynamic = 1,
  3714. .dpcm_playback = 1,
  3715. .dpcm_capture = 1,
  3716. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3717. SND_SOC_DPCM_TRIGGER_POST},
  3718. .codec_dai_name = "snd-soc-dummy-dai",
  3719. .codec_name = "snd-soc-dummy",
  3720. .ignore_suspend = 1,
  3721. .ignore_pmdown_time = 1,
  3722. /* this dainlink has playback support */
  3723. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  3724. .ops = &msm_fe_qos_ops,
  3725. },
  3726. /* HDMI Hostless */
  3727. {/* hw:x,14 */
  3728. .name = "HDMI_RX_HOSTLESS",
  3729. .stream_name = "HDMI_RX_HOSTLESS",
  3730. .cpu_dai_name = "HDMI_HOSTLESS",
  3731. .platform_name = "msm-pcm-hostless",
  3732. .dynamic = 1,
  3733. .dpcm_playback = 1,
  3734. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3735. SND_SOC_DPCM_TRIGGER_POST},
  3736. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3737. .ignore_suspend = 1,
  3738. .ignore_pmdown_time = 1,
  3739. .codec_dai_name = "snd-soc-dummy-dai",
  3740. .codec_name = "snd-soc-dummy",
  3741. },
  3742. {/* hw:x,15 */
  3743. .name = "VoiceMMode2",
  3744. .stream_name = "VoiceMMode2",
  3745. .cpu_dai_name = "VoiceMMode2",
  3746. .platform_name = "msm-pcm-voice",
  3747. .dynamic = 1,
  3748. .dpcm_playback = 1,
  3749. .dpcm_capture = 1,
  3750. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3751. SND_SOC_DPCM_TRIGGER_POST},
  3752. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3753. .ignore_suspend = 1,
  3754. .ignore_pmdown_time = 1,
  3755. .codec_dai_name = "snd-soc-dummy-dai",
  3756. .codec_name = "snd-soc-dummy",
  3757. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  3758. },
  3759. /* LSM FE */
  3760. {/* hw:x,16 */
  3761. .name = "Listen 2 Audio Service",
  3762. .stream_name = "Listen 2 Audio Service",
  3763. .cpu_dai_name = "LSM2",
  3764. .platform_name = "msm-lsm-client",
  3765. .dynamic = 1,
  3766. .dpcm_capture = 1,
  3767. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3768. SND_SOC_DPCM_TRIGGER_POST },
  3769. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3770. .ignore_suspend = 1,
  3771. .codec_dai_name = "snd-soc-dummy-dai",
  3772. .codec_name = "snd-soc-dummy",
  3773. .id = MSM_FRONTEND_DAI_LSM2,
  3774. },
  3775. {/* hw:x,17 */
  3776. .name = "Listen 3 Audio Service",
  3777. .stream_name = "Listen 3 Audio Service",
  3778. .cpu_dai_name = "LSM3",
  3779. .platform_name = "msm-lsm-client",
  3780. .dynamic = 1,
  3781. .dpcm_capture = 1,
  3782. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3783. SND_SOC_DPCM_TRIGGER_POST },
  3784. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3785. .ignore_suspend = 1,
  3786. .codec_dai_name = "snd-soc-dummy-dai",
  3787. .codec_name = "snd-soc-dummy",
  3788. .id = MSM_FRONTEND_DAI_LSM3,
  3789. },
  3790. {/* hw:x,18 */
  3791. .name = "Listen 4 Audio Service",
  3792. .stream_name = "Listen 4 Audio Service",
  3793. .cpu_dai_name = "LSM4",
  3794. .platform_name = "msm-lsm-client",
  3795. .dynamic = 1,
  3796. .dpcm_capture = 1,
  3797. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3798. SND_SOC_DPCM_TRIGGER_POST },
  3799. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3800. .ignore_suspend = 1,
  3801. .codec_dai_name = "snd-soc-dummy-dai",
  3802. .codec_name = "snd-soc-dummy",
  3803. .id = MSM_FRONTEND_DAI_LSM4,
  3804. },
  3805. {/* hw:x,19 */
  3806. .name = "Listen 5 Audio Service",
  3807. .stream_name = "Listen 5 Audio Service",
  3808. .cpu_dai_name = "LSM5",
  3809. .platform_name = "msm-lsm-client",
  3810. .dynamic = 1,
  3811. .dpcm_capture = 1,
  3812. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3813. SND_SOC_DPCM_TRIGGER_POST },
  3814. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3815. .ignore_suspend = 1,
  3816. .codec_dai_name = "snd-soc-dummy-dai",
  3817. .codec_name = "snd-soc-dummy",
  3818. .id = MSM_FRONTEND_DAI_LSM5,
  3819. },
  3820. {/* hw:x,20 */
  3821. .name = "Listen 6 Audio Service",
  3822. .stream_name = "Listen 6 Audio Service",
  3823. .cpu_dai_name = "LSM6",
  3824. .platform_name = "msm-lsm-client",
  3825. .dynamic = 1,
  3826. .dpcm_capture = 1,
  3827. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3828. SND_SOC_DPCM_TRIGGER_POST },
  3829. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3830. .ignore_suspend = 1,
  3831. .codec_dai_name = "snd-soc-dummy-dai",
  3832. .codec_name = "snd-soc-dummy",
  3833. .id = MSM_FRONTEND_DAI_LSM6,
  3834. },
  3835. {/* hw:x,21 */
  3836. .name = "Listen 7 Audio Service",
  3837. .stream_name = "Listen 7 Audio Service",
  3838. .cpu_dai_name = "LSM7",
  3839. .platform_name = "msm-lsm-client",
  3840. .dynamic = 1,
  3841. .dpcm_capture = 1,
  3842. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3843. SND_SOC_DPCM_TRIGGER_POST },
  3844. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3845. .ignore_suspend = 1,
  3846. .codec_dai_name = "snd-soc-dummy-dai",
  3847. .codec_name = "snd-soc-dummy",
  3848. .id = MSM_FRONTEND_DAI_LSM7,
  3849. },
  3850. {/* hw:x,22 */
  3851. .name = "Listen 8 Audio Service",
  3852. .stream_name = "Listen 8 Audio Service",
  3853. .cpu_dai_name = "LSM8",
  3854. .platform_name = "msm-lsm-client",
  3855. .dynamic = 1,
  3856. .dpcm_capture = 1,
  3857. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  3858. SND_SOC_DPCM_TRIGGER_POST },
  3859. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3860. .ignore_suspend = 1,
  3861. .codec_dai_name = "snd-soc-dummy-dai",
  3862. .codec_name = "snd-soc-dummy",
  3863. .id = MSM_FRONTEND_DAI_LSM8,
  3864. },
  3865. {/* hw:x,23 */
  3866. .name = MSM_DAILINK_NAME(Media9),
  3867. .stream_name = "MultiMedia9",
  3868. .cpu_dai_name = "MultiMedia9",
  3869. .platform_name = "msm-pcm-dsp.0",
  3870. .dynamic = 1,
  3871. .dpcm_playback = 1,
  3872. .dpcm_capture = 1,
  3873. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3874. SND_SOC_DPCM_TRIGGER_POST},
  3875. .codec_dai_name = "snd-soc-dummy-dai",
  3876. .codec_name = "snd-soc-dummy",
  3877. .ignore_suspend = 1,
  3878. /* this dainlink has playback support */
  3879. .ignore_pmdown_time = 1,
  3880. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  3881. },
  3882. {/* hw:x,24 */
  3883. .name = MSM_DAILINK_NAME(Compress4),
  3884. .stream_name = "Compress4",
  3885. .cpu_dai_name = "MultiMedia11",
  3886. .platform_name = "msm-compress-dsp",
  3887. .dynamic = 1,
  3888. .dpcm_playback = 1,
  3889. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3890. SND_SOC_DPCM_TRIGGER_POST},
  3891. .codec_dai_name = "snd-soc-dummy-dai",
  3892. .codec_name = "snd-soc-dummy",
  3893. .ignore_suspend = 1,
  3894. .ignore_pmdown_time = 1,
  3895. /* this dainlink has playback support */
  3896. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  3897. },
  3898. {/* hw:x,25 */
  3899. .name = MSM_DAILINK_NAME(Compress5),
  3900. .stream_name = "Compress5",
  3901. .cpu_dai_name = "MultiMedia12",
  3902. .platform_name = "msm-compress-dsp",
  3903. .dynamic = 1,
  3904. .dpcm_playback = 1,
  3905. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3906. SND_SOC_DPCM_TRIGGER_POST},
  3907. .codec_dai_name = "snd-soc-dummy-dai",
  3908. .codec_name = "snd-soc-dummy",
  3909. .ignore_suspend = 1,
  3910. .ignore_pmdown_time = 1,
  3911. /* this dainlink has playback support */
  3912. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  3913. },
  3914. {/* hw:x,26 */
  3915. .name = MSM_DAILINK_NAME(Compress6),
  3916. .stream_name = "Compress6",
  3917. .cpu_dai_name = "MultiMedia13",
  3918. .platform_name = "msm-compress-dsp",
  3919. .dynamic = 1,
  3920. .dpcm_playback = 1,
  3921. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3922. SND_SOC_DPCM_TRIGGER_POST},
  3923. .codec_dai_name = "snd-soc-dummy-dai",
  3924. .codec_name = "snd-soc-dummy",
  3925. .ignore_suspend = 1,
  3926. .ignore_pmdown_time = 1,
  3927. /* this dainlink has playback support */
  3928. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  3929. },
  3930. {/* hw:x,27 */
  3931. .name = MSM_DAILINK_NAME(Compress7),
  3932. .stream_name = "Compress7",
  3933. .cpu_dai_name = "MultiMedia14",
  3934. .platform_name = "msm-compress-dsp",
  3935. .dynamic = 1,
  3936. .dpcm_playback = 1,
  3937. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3938. SND_SOC_DPCM_TRIGGER_POST},
  3939. .codec_dai_name = "snd-soc-dummy-dai",
  3940. .codec_name = "snd-soc-dummy",
  3941. .ignore_suspend = 1,
  3942. .ignore_pmdown_time = 1,
  3943. /* this dainlink has playback support */
  3944. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  3945. },
  3946. {/* hw:x,28 */
  3947. .name = MSM_DAILINK_NAME(Compress8),
  3948. .stream_name = "Compress8",
  3949. .cpu_dai_name = "MultiMedia15",
  3950. .platform_name = "msm-compress-dsp",
  3951. .dynamic = 1,
  3952. .dpcm_playback = 1,
  3953. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3954. SND_SOC_DPCM_TRIGGER_POST},
  3955. .codec_dai_name = "snd-soc-dummy-dai",
  3956. .codec_name = "snd-soc-dummy",
  3957. .ignore_suspend = 1,
  3958. .ignore_pmdown_time = 1,
  3959. /* this dainlink has playback support */
  3960. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  3961. },
  3962. {/* hw:x,29 */
  3963. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  3964. .stream_name = "MM_NOIRQ_2",
  3965. .cpu_dai_name = "MultiMedia16",
  3966. .platform_name = "msm-pcm-dsp-noirq",
  3967. .dynamic = 1,
  3968. .dpcm_playback = 1,
  3969. .dpcm_capture = 1,
  3970. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3971. SND_SOC_DPCM_TRIGGER_POST},
  3972. .codec_dai_name = "snd-soc-dummy-dai",
  3973. .codec_name = "snd-soc-dummy",
  3974. .ignore_suspend = 1,
  3975. .ignore_pmdown_time = 1,
  3976. /* this dainlink has playback support */
  3977. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  3978. },
  3979. {/* hw:x,30 */
  3980. .name = "CDC_DMA Hostless",
  3981. .stream_name = "CDC_DMA Hostless",
  3982. .cpu_dai_name = "CDC_DMA_HOSTLESS",
  3983. .platform_name = "msm-pcm-hostless",
  3984. .dynamic = 1,
  3985. .dpcm_playback = 1,
  3986. .dpcm_capture = 1,
  3987. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  3988. SND_SOC_DPCM_TRIGGER_POST},
  3989. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  3990. .ignore_suspend = 1,
  3991. /* this dailink has playback support */
  3992. .ignore_pmdown_time = 1,
  3993. .codec_dai_name = "snd-soc-dummy-dai",
  3994. .codec_name = "snd-soc-dummy",
  3995. },
  3996. {/* hw:x,31 */
  3997. .name = "TX3_CDC_DMA Hostless",
  3998. .stream_name = "TX3_CDC_DMA Hostless",
  3999. .cpu_dai_name = "TX3_CDC_DMA_HOSTLESS",
  4000. .platform_name = "msm-pcm-hostless",
  4001. .dynamic = 1,
  4002. .dpcm_capture = 1,
  4003. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4004. SND_SOC_DPCM_TRIGGER_POST},
  4005. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4006. .ignore_suspend = 1,
  4007. .codec_dai_name = "snd-soc-dummy-dai",
  4008. .codec_name = "snd-soc-dummy",
  4009. },
  4010. };
  4011. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  4012. {/* hw:x,37 */
  4013. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  4014. .stream_name = "WSA CDC DMA0 Capture",
  4015. .cpu_dai_name = "msm-dai-cdc-dma-dev.45057",
  4016. .platform_name = "msm-pcm-hostless",
  4017. .codec_name = "bolero_codec",
  4018. .codec_dai_name = "wsa_macro_vifeedback",
  4019. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  4020. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4021. .ignore_suspend = 1,
  4022. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4023. .ops = &msm_cdc_dma_be_ops,
  4024. },
  4025. };
  4026. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  4027. {
  4028. .name = MSM_DAILINK_NAME(ASM Loopback),
  4029. .stream_name = "MultiMedia6",
  4030. .cpu_dai_name = "MultiMedia6",
  4031. .platform_name = "msm-pcm-loopback",
  4032. .dynamic = 1,
  4033. .dpcm_playback = 1,
  4034. .dpcm_capture = 1,
  4035. .codec_dai_name = "snd-soc-dummy-dai",
  4036. .codec_name = "snd-soc-dummy",
  4037. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4038. SND_SOC_DPCM_TRIGGER_POST},
  4039. .ignore_suspend = 1,
  4040. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4041. .ignore_pmdown_time = 1,
  4042. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  4043. },
  4044. {
  4045. .name = "USB Audio Hostless",
  4046. .stream_name = "USB Audio Hostless",
  4047. .cpu_dai_name = "USBAUDIO_HOSTLESS",
  4048. .platform_name = "msm-pcm-hostless",
  4049. .dynamic = 1,
  4050. .dpcm_playback = 1,
  4051. .dpcm_capture = 1,
  4052. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4053. SND_SOC_DPCM_TRIGGER_POST},
  4054. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4055. .ignore_suspend = 1,
  4056. .ignore_pmdown_time = 1,
  4057. .codec_dai_name = "snd-soc-dummy-dai",
  4058. .codec_name = "snd-soc-dummy",
  4059. },
  4060. {
  4061. .name = "SLIMBUS_7 Hostless",
  4062. .stream_name = "SLIMBUS_7 Hostless",
  4063. .cpu_dai_name = "SLIMBUS7_HOSTLESS",
  4064. .platform_name = "msm-pcm-hostless",
  4065. .dynamic = 1,
  4066. .dpcm_capture = 1,
  4067. .dpcm_playback = 1,
  4068. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4069. SND_SOC_DPCM_TRIGGER_POST},
  4070. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  4071. .ignore_suspend = 1,
  4072. .ignore_pmdown_time = 1,
  4073. .codec_dai_name = "snd-soc-dummy-dai",
  4074. .codec_name = "snd-soc-dummy",
  4075. },
  4076. {
  4077. .name = "Compress Capture",
  4078. .stream_name = "Compress9",
  4079. .cpu_dai_name = "MultiMedia17",
  4080. .platform_name = "msm-compress-dsp",
  4081. .dynamic = 1,
  4082. .dpcm_capture = 1,
  4083. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4084. SND_SOC_DPCM_TRIGGER_POST},
  4085. .codec_dai_name = "snd-soc-dummy-dai",
  4086. .codec_name = "snd-soc-dummy",
  4087. .ignore_suspend = 1,
  4088. .ignore_pmdown_time = 1,
  4089. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  4090. },
  4091. };
  4092. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  4093. /* Backend AFE DAI Links */
  4094. {
  4095. .name = LPASS_BE_AFE_PCM_RX,
  4096. .stream_name = "AFE Playback",
  4097. .cpu_dai_name = "msm-dai-q6-dev.224",
  4098. .platform_name = "msm-pcm-routing",
  4099. .codec_name = "msm-stub-codec.1",
  4100. .codec_dai_name = "msm-stub-rx",
  4101. .no_pcm = 1,
  4102. .dpcm_playback = 1,
  4103. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  4104. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4105. /* this dainlink has playback support */
  4106. .ignore_pmdown_time = 1,
  4107. .ignore_suspend = 1,
  4108. },
  4109. {
  4110. .name = LPASS_BE_AFE_PCM_TX,
  4111. .stream_name = "AFE Capture",
  4112. .cpu_dai_name = "msm-dai-q6-dev.225",
  4113. .platform_name = "msm-pcm-routing",
  4114. .codec_name = "msm-stub-codec.1",
  4115. .codec_dai_name = "msm-stub-tx",
  4116. .no_pcm = 1,
  4117. .dpcm_capture = 1,
  4118. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  4119. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4120. .ignore_suspend = 1,
  4121. },
  4122. /* Incall Record Uplink BACK END DAI Link */
  4123. {
  4124. .name = LPASS_BE_INCALL_RECORD_TX,
  4125. .stream_name = "Voice Uplink Capture",
  4126. .cpu_dai_name = "msm-dai-q6-dev.32772",
  4127. .platform_name = "msm-pcm-routing",
  4128. .codec_name = "msm-stub-codec.1",
  4129. .codec_dai_name = "msm-stub-tx",
  4130. .no_pcm = 1,
  4131. .dpcm_capture = 1,
  4132. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  4133. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4134. .ignore_suspend = 1,
  4135. },
  4136. /* Incall Record Downlink BACK END DAI Link */
  4137. {
  4138. .name = LPASS_BE_INCALL_RECORD_RX,
  4139. .stream_name = "Voice Downlink Capture",
  4140. .cpu_dai_name = "msm-dai-q6-dev.32771",
  4141. .platform_name = "msm-pcm-routing",
  4142. .codec_name = "msm-stub-codec.1",
  4143. .codec_dai_name = "msm-stub-tx",
  4144. .no_pcm = 1,
  4145. .dpcm_capture = 1,
  4146. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  4147. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4148. .ignore_suspend = 1,
  4149. },
  4150. /* Incall Music BACK END DAI Link */
  4151. {
  4152. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  4153. .stream_name = "Voice Farend Playback",
  4154. .cpu_dai_name = "msm-dai-q6-dev.32773",
  4155. .platform_name = "msm-pcm-routing",
  4156. .codec_name = "msm-stub-codec.1",
  4157. .codec_dai_name = "msm-stub-rx",
  4158. .no_pcm = 1,
  4159. .dpcm_playback = 1,
  4160. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  4161. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4162. .ignore_suspend = 1,
  4163. .ignore_pmdown_time = 1,
  4164. },
  4165. /* Incall Music 2 BACK END DAI Link */
  4166. {
  4167. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  4168. .stream_name = "Voice2 Farend Playback",
  4169. .cpu_dai_name = "msm-dai-q6-dev.32770",
  4170. .platform_name = "msm-pcm-routing",
  4171. .codec_name = "msm-stub-codec.1",
  4172. .codec_dai_name = "msm-stub-rx",
  4173. .no_pcm = 1,
  4174. .dpcm_playback = 1,
  4175. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  4176. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4177. .ignore_suspend = 1,
  4178. .ignore_pmdown_time = 1,
  4179. },
  4180. {
  4181. .name = LPASS_BE_USB_AUDIO_RX,
  4182. .stream_name = "USB Audio Playback",
  4183. .cpu_dai_name = "msm-dai-q6-dev.28672",
  4184. .platform_name = "msm-pcm-routing",
  4185. .codec_name = "msm-stub-codec.1",
  4186. .codec_dai_name = "msm-stub-rx",
  4187. .no_pcm = 1,
  4188. .dpcm_playback = 1,
  4189. .id = MSM_BACKEND_DAI_USB_RX,
  4190. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4191. .ignore_pmdown_time = 1,
  4192. .ignore_suspend = 1,
  4193. },
  4194. {
  4195. .name = LPASS_BE_USB_AUDIO_TX,
  4196. .stream_name = "USB Audio Capture",
  4197. .cpu_dai_name = "msm-dai-q6-dev.28673",
  4198. .platform_name = "msm-pcm-routing",
  4199. .codec_name = "msm-stub-codec.1",
  4200. .codec_dai_name = "msm-stub-tx",
  4201. .no_pcm = 1,
  4202. .dpcm_capture = 1,
  4203. .id = MSM_BACKEND_DAI_USB_TX,
  4204. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4205. .ignore_suspend = 1,
  4206. },
  4207. {
  4208. .name = LPASS_BE_PRI_TDM_RX_0,
  4209. .stream_name = "Primary TDM0 Playback",
  4210. .cpu_dai_name = "msm-dai-q6-tdm.36864",
  4211. .platform_name = "msm-pcm-routing",
  4212. .codec_name = "msm-stub-codec.1",
  4213. .codec_dai_name = "msm-stub-rx",
  4214. .no_pcm = 1,
  4215. .dpcm_playback = 1,
  4216. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  4217. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4218. .ops = &kona_tdm_be_ops,
  4219. .ignore_suspend = 1,
  4220. .ignore_pmdown_time = 1,
  4221. },
  4222. {
  4223. .name = LPASS_BE_PRI_TDM_TX_0,
  4224. .stream_name = "Primary TDM0 Capture",
  4225. .cpu_dai_name = "msm-dai-q6-tdm.36865",
  4226. .platform_name = "msm-pcm-routing",
  4227. .codec_name = "msm-stub-codec.1",
  4228. .codec_dai_name = "msm-stub-tx",
  4229. .no_pcm = 1,
  4230. .dpcm_capture = 1,
  4231. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  4232. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4233. .ops = &kona_tdm_be_ops,
  4234. .ignore_suspend = 1,
  4235. },
  4236. {
  4237. .name = LPASS_BE_SEC_TDM_RX_0,
  4238. .stream_name = "Secondary TDM0 Playback",
  4239. .cpu_dai_name = "msm-dai-q6-tdm.36880",
  4240. .platform_name = "msm-pcm-routing",
  4241. .codec_name = "msm-stub-codec.1",
  4242. .codec_dai_name = "msm-stub-rx",
  4243. .no_pcm = 1,
  4244. .dpcm_playback = 1,
  4245. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  4246. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4247. .ops = &kona_tdm_be_ops,
  4248. .ignore_suspend = 1,
  4249. .ignore_pmdown_time = 1,
  4250. },
  4251. {
  4252. .name = LPASS_BE_SEC_TDM_TX_0,
  4253. .stream_name = "Secondary TDM0 Capture",
  4254. .cpu_dai_name = "msm-dai-q6-tdm.36881",
  4255. .platform_name = "msm-pcm-routing",
  4256. .codec_name = "msm-stub-codec.1",
  4257. .codec_dai_name = "msm-stub-tx",
  4258. .no_pcm = 1,
  4259. .dpcm_capture = 1,
  4260. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  4261. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4262. .ops = &kona_tdm_be_ops,
  4263. .ignore_suspend = 1,
  4264. },
  4265. {
  4266. .name = LPASS_BE_TERT_TDM_RX_0,
  4267. .stream_name = "Tertiary TDM0 Playback",
  4268. .cpu_dai_name = "msm-dai-q6-tdm.36896",
  4269. .platform_name = "msm-pcm-routing",
  4270. .codec_name = "msm-stub-codec.1",
  4271. .codec_dai_name = "msm-stub-rx",
  4272. .no_pcm = 1,
  4273. .dpcm_playback = 1,
  4274. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  4275. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4276. .ops = &kona_tdm_be_ops,
  4277. .ignore_suspend = 1,
  4278. .ignore_pmdown_time = 1,
  4279. },
  4280. {
  4281. .name = LPASS_BE_TERT_TDM_TX_0,
  4282. .stream_name = "Tertiary TDM0 Capture",
  4283. .cpu_dai_name = "msm-dai-q6-tdm.36897",
  4284. .platform_name = "msm-pcm-routing",
  4285. .codec_name = "msm-stub-codec.1",
  4286. .codec_dai_name = "msm-stub-tx",
  4287. .no_pcm = 1,
  4288. .dpcm_capture = 1,
  4289. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  4290. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4291. .ops = &kona_tdm_be_ops,
  4292. .ignore_suspend = 1,
  4293. },
  4294. };
  4295. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  4296. {
  4297. .name = LPASS_BE_SLIMBUS_7_RX,
  4298. .stream_name = "Slimbus7 Playback",
  4299. .cpu_dai_name = "msm-dai-q6-dev.16398",
  4300. .platform_name = "msm-pcm-routing",
  4301. .codec_name = "btfmslim_slave",
  4302. /* BT codec driver determines capabilities based on
  4303. * dai name, bt codecdai name should always contains
  4304. * supported usecase information
  4305. */
  4306. .codec_dai_name = "btfm_bt_sco_a2dp_slim_rx",
  4307. .no_pcm = 1,
  4308. .dpcm_playback = 1,
  4309. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  4310. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4311. .init = &msm_wcn_init,
  4312. .ops = &msm_wcn_ops,
  4313. /* dai link has playback support */
  4314. .ignore_pmdown_time = 1,
  4315. .ignore_suspend = 1,
  4316. },
  4317. {
  4318. .name = LPASS_BE_SLIMBUS_7_TX,
  4319. .stream_name = "Slimbus7 Capture",
  4320. .cpu_dai_name = "msm-dai-q6-dev.16399",
  4321. .platform_name = "msm-pcm-routing",
  4322. .codec_name = "btfmslim_slave",
  4323. .codec_dai_name = "btfm_bt_sco_slim_tx",
  4324. .no_pcm = 1,
  4325. .dpcm_capture = 1,
  4326. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  4327. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4328. .ops = &msm_wcn_ops,
  4329. .ignore_suspend = 1,
  4330. },
  4331. };
  4332. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  4333. /* DISP PORT BACK END DAI Link */
  4334. {
  4335. .name = LPASS_BE_DISPLAY_PORT,
  4336. .stream_name = "Display Port Playback",
  4337. .cpu_dai_name = "msm-dai-q6-dp.24608",
  4338. .platform_name = "msm-pcm-routing",
  4339. .codec_name = "msm-ext-disp-audio-codec-rx",
  4340. .codec_dai_name = "msm_dp_audio_codec_rx_dai",
  4341. .no_pcm = 1,
  4342. .dpcm_playback = 1,
  4343. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  4344. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4345. .ignore_pmdown_time = 1,
  4346. .ignore_suspend = 1,
  4347. },
  4348. /* DISP PORT 1 BACK END DAI Link */
  4349. {
  4350. .name = LPASS_BE_DISPLAY_PORT1,
  4351. .stream_name = "Display Port1 Playback",
  4352. .cpu_dai_name = "msm-dai-q6-dp.24608",
  4353. .platform_name = "msm-pcm-routing",
  4354. .codec_name = "msm-ext-disp-audio-codec-rx",
  4355. .codec_dai_name = "msm_dp_audio_codec_rx1_dai",
  4356. .no_pcm = 1,
  4357. .dpcm_playback = 1,
  4358. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  4359. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4360. .ignore_pmdown_time = 1,
  4361. .ignore_suspend = 1,
  4362. },
  4363. };
  4364. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  4365. {
  4366. .name = LPASS_BE_PRI_MI2S_RX,
  4367. .stream_name = "Primary MI2S Playback",
  4368. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  4369. .platform_name = "msm-pcm-routing",
  4370. .codec_name = "msm-stub-codec.1",
  4371. .codec_dai_name = "msm-stub-rx",
  4372. .no_pcm = 1,
  4373. .dpcm_playback = 1,
  4374. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  4375. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4376. .ops = &msm_mi2s_be_ops,
  4377. .ignore_suspend = 1,
  4378. .ignore_pmdown_time = 1,
  4379. },
  4380. {
  4381. .name = LPASS_BE_PRI_MI2S_TX,
  4382. .stream_name = "Primary MI2S Capture",
  4383. .cpu_dai_name = "msm-dai-q6-mi2s.0",
  4384. .platform_name = "msm-pcm-routing",
  4385. .codec_name = "msm-stub-codec.1",
  4386. .codec_dai_name = "msm-stub-tx",
  4387. .no_pcm = 1,
  4388. .dpcm_capture = 1,
  4389. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  4390. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4391. .ops = &msm_mi2s_be_ops,
  4392. .ignore_suspend = 1,
  4393. },
  4394. {
  4395. .name = LPASS_BE_SEC_MI2S_RX,
  4396. .stream_name = "Secondary MI2S Playback",
  4397. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  4398. .platform_name = "msm-pcm-routing",
  4399. .codec_name = "msm-stub-codec.1",
  4400. .codec_dai_name = "msm-stub-rx",
  4401. .no_pcm = 1,
  4402. .dpcm_playback = 1,
  4403. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  4404. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4405. .ops = &msm_mi2s_be_ops,
  4406. .ignore_suspend = 1,
  4407. .ignore_pmdown_time = 1,
  4408. },
  4409. {
  4410. .name = LPASS_BE_SEC_MI2S_TX,
  4411. .stream_name = "Secondary MI2S Capture",
  4412. .cpu_dai_name = "msm-dai-q6-mi2s.1",
  4413. .platform_name = "msm-pcm-routing",
  4414. .codec_name = "msm-stub-codec.1",
  4415. .codec_dai_name = "msm-stub-tx",
  4416. .no_pcm = 1,
  4417. .dpcm_capture = 1,
  4418. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  4419. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4420. .ops = &msm_mi2s_be_ops,
  4421. .ignore_suspend = 1,
  4422. },
  4423. {
  4424. .name = LPASS_BE_TERT_MI2S_RX,
  4425. .stream_name = "Tertiary MI2S Playback",
  4426. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  4427. .platform_name = "msm-pcm-routing",
  4428. .codec_name = "msm-stub-codec.1",
  4429. .codec_dai_name = "msm-stub-rx",
  4430. .no_pcm = 1,
  4431. .dpcm_playback = 1,
  4432. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  4433. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4434. .ops = &msm_mi2s_be_ops,
  4435. .ignore_suspend = 1,
  4436. .ignore_pmdown_time = 1,
  4437. },
  4438. {
  4439. .name = LPASS_BE_TERT_MI2S_TX,
  4440. .stream_name = "Tertiary MI2S Capture",
  4441. .cpu_dai_name = "msm-dai-q6-mi2s.2",
  4442. .platform_name = "msm-pcm-routing",
  4443. .codec_name = "msm-stub-codec.1",
  4444. .codec_dai_name = "msm-stub-tx",
  4445. .no_pcm = 1,
  4446. .dpcm_capture = 1,
  4447. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  4448. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4449. .ops = &msm_mi2s_be_ops,
  4450. .ignore_suspend = 1,
  4451. },
  4452. };
  4453. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  4454. /* Primary AUX PCM Backend DAI Links */
  4455. {
  4456. .name = LPASS_BE_AUXPCM_RX,
  4457. .stream_name = "AUX PCM Playback",
  4458. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4459. .platform_name = "msm-pcm-routing",
  4460. .codec_name = "msm-stub-codec.1",
  4461. .codec_dai_name = "msm-stub-rx",
  4462. .no_pcm = 1,
  4463. .dpcm_playback = 1,
  4464. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  4465. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4466. .ignore_pmdown_time = 1,
  4467. .ignore_suspend = 1,
  4468. },
  4469. {
  4470. .name = LPASS_BE_AUXPCM_TX,
  4471. .stream_name = "AUX PCM Capture",
  4472. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4473. .platform_name = "msm-pcm-routing",
  4474. .codec_name = "msm-stub-codec.1",
  4475. .codec_dai_name = "msm-stub-tx",
  4476. .no_pcm = 1,
  4477. .dpcm_capture = 1,
  4478. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  4479. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4480. .ignore_suspend = 1,
  4481. },
  4482. /* Secondary AUX PCM Backend DAI Links */
  4483. {
  4484. .name = LPASS_BE_SEC_AUXPCM_RX,
  4485. .stream_name = "Sec AUX PCM Playback",
  4486. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  4487. .platform_name = "msm-pcm-routing",
  4488. .codec_name = "msm-stub-codec.1",
  4489. .codec_dai_name = "msm-stub-rx",
  4490. .no_pcm = 1,
  4491. .dpcm_playback = 1,
  4492. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  4493. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4494. .ignore_pmdown_time = 1,
  4495. .ignore_suspend = 1,
  4496. },
  4497. {
  4498. .name = LPASS_BE_SEC_AUXPCM_TX,
  4499. .stream_name = "Sec AUX PCM Capture",
  4500. .cpu_dai_name = "msm-dai-q6-auxpcm.2",
  4501. .platform_name = "msm-pcm-routing",
  4502. .codec_name = "msm-stub-codec.1",
  4503. .codec_dai_name = "msm-stub-tx",
  4504. .no_pcm = 1,
  4505. .dpcm_capture = 1,
  4506. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  4507. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4508. .ignore_suspend = 1,
  4509. },
  4510. /* Tertiary AUX PCM Backend DAI Links */
  4511. {
  4512. .name = LPASS_BE_TERT_AUXPCM_RX,
  4513. .stream_name = "Tert AUX PCM Playback",
  4514. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  4515. .platform_name = "msm-pcm-routing",
  4516. .codec_name = "msm-stub-codec.1",
  4517. .codec_dai_name = "msm-stub-rx",
  4518. .no_pcm = 1,
  4519. .dpcm_playback = 1,
  4520. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  4521. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4522. .ignore_suspend = 1,
  4523. },
  4524. {
  4525. .name = LPASS_BE_TERT_AUXPCM_TX,
  4526. .stream_name = "Tert AUX PCM Capture",
  4527. .cpu_dai_name = "msm-dai-q6-auxpcm.3",
  4528. .platform_name = "msm-pcm-routing",
  4529. .codec_name = "msm-stub-codec.1",
  4530. .codec_dai_name = "msm-stub-tx",
  4531. .no_pcm = 1,
  4532. .dpcm_capture = 1,
  4533. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  4534. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4535. .ignore_suspend = 1,
  4536. },
  4537. };
  4538. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  4539. /* WSA CDC DMA Backend DAI Links */
  4540. {
  4541. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  4542. .stream_name = "WSA CDC DMA0 Playback",
  4543. .cpu_dai_name = "msm-dai-cdc-dma-dev.45056",
  4544. .platform_name = "msm-pcm-routing",
  4545. .codec_name = "bolero_codec",
  4546. .codec_dai_name = "wsa_macro_rx1",
  4547. .no_pcm = 1,
  4548. .dpcm_playback = 1,
  4549. .init = &msm_int_audrx_init,
  4550. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  4551. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4552. .ignore_pmdown_time = 1,
  4553. .ignore_suspend = 1,
  4554. .ops = &msm_cdc_dma_be_ops,
  4555. },
  4556. {
  4557. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  4558. .stream_name = "WSA CDC DMA1 Playback",
  4559. .cpu_dai_name = "msm-dai-cdc-dma-dev.45058",
  4560. .platform_name = "msm-pcm-routing",
  4561. .codec_name = "bolero_codec",
  4562. .codec_dai_name = "wsa_macro_rx_mix",
  4563. .no_pcm = 1,
  4564. .dpcm_playback = 1,
  4565. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  4566. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4567. .ignore_pmdown_time = 1,
  4568. .ignore_suspend = 1,
  4569. .ops = &msm_cdc_dma_be_ops,
  4570. },
  4571. {
  4572. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  4573. .stream_name = "WSA CDC DMA1 Capture",
  4574. .cpu_dai_name = "msm-dai-cdc-dma-dev.45059",
  4575. .platform_name = "msm-pcm-routing",
  4576. .codec_name = "bolero_codec",
  4577. .codec_dai_name = "wsa_macro_echo",
  4578. .no_pcm = 1,
  4579. .dpcm_capture = 1,
  4580. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  4581. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4582. .ignore_suspend = 1,
  4583. .ops = &msm_cdc_dma_be_ops,
  4584. },
  4585. };
  4586. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  4587. /* RX CDC DMA Backend DAI Links */
  4588. {
  4589. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  4590. .stream_name = "RX CDC DMA0 Playback",
  4591. .cpu_dai_name = "msm-dai-cdc-dma-dev.45104",
  4592. .platform_name = "msm-pcm-routing",
  4593. .codec_name = "bolero_codec",
  4594. .codec_dai_name = "rx_macro_rx1",
  4595. .no_pcm = 1,
  4596. .dpcm_playback = 1,
  4597. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  4598. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4599. .ignore_pmdown_time = 1,
  4600. .ignore_suspend = 1,
  4601. .ops = &msm_cdc_dma_be_ops,
  4602. },
  4603. {
  4604. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  4605. .stream_name = "RX CDC DMA1 Playback",
  4606. .cpu_dai_name = "msm-dai-cdc-dma-dev.45106",
  4607. .platform_name = "msm-pcm-routing",
  4608. .codec_name = "bolero_codec",
  4609. .codec_dai_name = "rx_macro_rx2",
  4610. .no_pcm = 1,
  4611. .dpcm_playback = 1,
  4612. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  4613. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4614. .ignore_pmdown_time = 1,
  4615. .ignore_suspend = 1,
  4616. .ops = &msm_cdc_dma_be_ops,
  4617. },
  4618. {
  4619. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  4620. .stream_name = "RX CDC DMA2 Playback",
  4621. .cpu_dai_name = "msm-dai-cdc-dma-dev.45108",
  4622. .platform_name = "msm-pcm-routing",
  4623. .codec_name = "bolero_codec",
  4624. .codec_dai_name = "rx_macro_rx3",
  4625. .no_pcm = 1,
  4626. .dpcm_playback = 1,
  4627. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  4628. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4629. .ignore_pmdown_time = 1,
  4630. .ignore_suspend = 1,
  4631. .ops = &msm_cdc_dma_be_ops,
  4632. },
  4633. {
  4634. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  4635. .stream_name = "RX CDC DMA3 Playback",
  4636. .cpu_dai_name = "msm-dai-cdc-dma-dev.45110",
  4637. .platform_name = "msm-pcm-routing",
  4638. .codec_name = "bolero_codec",
  4639. .codec_dai_name = "rx_macro_rx4",
  4640. .no_pcm = 1,
  4641. .dpcm_playback = 1,
  4642. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  4643. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4644. .ignore_pmdown_time = 1,
  4645. .ignore_suspend = 1,
  4646. .ops = &msm_cdc_dma_be_ops,
  4647. },
  4648. /* TX CDC DMA Backend DAI Links */
  4649. {
  4650. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  4651. .stream_name = "TX CDC DMA3 Capture",
  4652. .cpu_dai_name = "msm-dai-cdc-dma-dev.45111",
  4653. .platform_name = "msm-pcm-routing",
  4654. .codec_name = "bolero_codec",
  4655. .codec_dai_name = "tx_macro_tx1",
  4656. .no_pcm = 1,
  4657. .dpcm_capture = 1,
  4658. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  4659. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4660. .ignore_suspend = 1,
  4661. .ops = &msm_cdc_dma_be_ops,
  4662. },
  4663. {
  4664. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  4665. .stream_name = "TX CDC DMA4 Capture",
  4666. .cpu_dai_name = "msm-dai-cdc-dma-dev.45113",
  4667. .platform_name = "msm-pcm-routing",
  4668. .codec_name = "bolero_codec",
  4669. .codec_dai_name = "tx_macro_tx2",
  4670. .no_pcm = 1,
  4671. .dpcm_capture = 1,
  4672. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  4673. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4674. .ignore_suspend = 1,
  4675. .ops = &msm_cdc_dma_be_ops,
  4676. },
  4677. };
  4678. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  4679. {
  4680. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  4681. .stream_name = "VA CDC DMA0 Capture",
  4682. .cpu_dai_name = "msm-dai-cdc-dma-dev.45089",
  4683. .platform_name = "msm-pcm-routing",
  4684. .codec_name = "bolero_codec",
  4685. .codec_dai_name = "va_macro_tx1",
  4686. .no_pcm = 1,
  4687. .dpcm_capture = 1,
  4688. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  4689. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4690. .ignore_suspend = 1,
  4691. .ops = &msm_cdc_dma_be_ops,
  4692. },
  4693. {
  4694. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  4695. .stream_name = "VA CDC DMA1 Capture",
  4696. .cpu_dai_name = "msm-dai-cdc-dma-dev.45091",
  4697. .platform_name = "msm-pcm-routing",
  4698. .codec_name = "bolero_codec",
  4699. .codec_dai_name = "va_macro_tx2",
  4700. .no_pcm = 1,
  4701. .dpcm_capture = 1,
  4702. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  4703. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4704. .ignore_suspend = 1,
  4705. .ops = &msm_cdc_dma_be_ops,
  4706. },
  4707. {
  4708. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  4709. .stream_name = "VA CDC DMA2 Capture",
  4710. .cpu_dai_name = "msm-dai-cdc-dma-dev.45093",
  4711. .platform_name = "msm-pcm-routing",
  4712. .codec_name = "bolero_codec",
  4713. .codec_dai_name = "va_macro_tx3",
  4714. .no_pcm = 1,
  4715. .dpcm_capture = 1,
  4716. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  4717. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4718. .ignore_suspend = 1,
  4719. .ops = &msm_cdc_dma_be_ops,
  4720. },
  4721. };
  4722. static struct snd_soc_dai_link msm_kona_dai_links[
  4723. ARRAY_SIZE(msm_common_dai_links) +
  4724. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  4725. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  4726. ARRAY_SIZE(msm_common_be_dai_links) +
  4727. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  4728. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  4729. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  4730. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  4731. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  4732. ARRAY_SIZE(ext_disp_be_dai_link) +
  4733. ARRAY_SIZE(msm_wcn_be_dai_links)];
  4734. static int msm_populate_dai_link_component_of_node(
  4735. struct snd_soc_card *card)
  4736. {
  4737. int i, index, ret = 0;
  4738. struct device *cdev = card->dev;
  4739. struct snd_soc_dai_link *dai_link = card->dai_link;
  4740. struct device_node *np;
  4741. if (!cdev) {
  4742. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  4743. return -ENODEV;
  4744. }
  4745. for (i = 0; i < card->num_links; i++) {
  4746. if (dai_link[i].platform_of_node && dai_link[i].cpu_of_node)
  4747. continue;
  4748. /* populate platform_of_node for snd card dai links */
  4749. if (dai_link[i].platform_name &&
  4750. !dai_link[i].platform_of_node) {
  4751. index = of_property_match_string(cdev->of_node,
  4752. "asoc-platform-names",
  4753. dai_link[i].platform_name);
  4754. if (index < 0) {
  4755. dev_err(cdev, "%s: No match found for platform name: %s\n",
  4756. __func__, dai_link[i].platform_name);
  4757. ret = index;
  4758. goto err;
  4759. }
  4760. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  4761. index);
  4762. if (!np) {
  4763. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  4764. __func__, dai_link[i].platform_name,
  4765. index);
  4766. ret = -ENODEV;
  4767. goto err;
  4768. }
  4769. dai_link[i].platform_of_node = np;
  4770. dai_link[i].platform_name = NULL;
  4771. }
  4772. /* populate cpu_of_node for snd card dai links */
  4773. if (dai_link[i].cpu_dai_name && !dai_link[i].cpu_of_node) {
  4774. index = of_property_match_string(cdev->of_node,
  4775. "asoc-cpu-names",
  4776. dai_link[i].cpu_dai_name);
  4777. if (index >= 0) {
  4778. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  4779. index);
  4780. if (!np) {
  4781. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  4782. __func__,
  4783. dai_link[i].cpu_dai_name);
  4784. ret = -ENODEV;
  4785. goto err;
  4786. }
  4787. dai_link[i].cpu_of_node = np;
  4788. dai_link[i].cpu_dai_name = NULL;
  4789. }
  4790. }
  4791. /* populate codec_of_node for snd card dai links */
  4792. if (dai_link[i].codec_name && !dai_link[i].codec_of_node) {
  4793. index = of_property_match_string(cdev->of_node,
  4794. "asoc-codec-names",
  4795. dai_link[i].codec_name);
  4796. if (index < 0)
  4797. continue;
  4798. np = of_parse_phandle(cdev->of_node, "asoc-codec",
  4799. index);
  4800. if (!np) {
  4801. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  4802. __func__, dai_link[i].codec_name);
  4803. ret = -ENODEV;
  4804. goto err;
  4805. }
  4806. dai_link[i].codec_of_node = np;
  4807. dai_link[i].codec_name = NULL;
  4808. }
  4809. }
  4810. err:
  4811. return ret;
  4812. }
  4813. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  4814. {
  4815. int ret = -EINVAL;
  4816. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  4817. if (!component) {
  4818. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  4819. return ret;
  4820. }
  4821. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  4822. ARRAY_SIZE(msm_snd_controls));
  4823. if (ret < 0) {
  4824. dev_err(component->dev,
  4825. "%s: add_codec_controls failed, err = %d\n",
  4826. __func__, ret);
  4827. return ret;
  4828. }
  4829. return ret;
  4830. }
  4831. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  4832. struct snd_pcm_hw_params *params)
  4833. {
  4834. return 0;
  4835. }
  4836. static struct snd_soc_ops msm_stub_be_ops = {
  4837. .hw_params = msm_snd_stub_hw_params,
  4838. };
  4839. struct snd_soc_card snd_soc_card_stub_msm = {
  4840. .name = "kona-stub-snd-card",
  4841. };
  4842. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  4843. /* FrontEnd DAI Links */
  4844. {
  4845. .name = "MSMSTUB Media1",
  4846. .stream_name = "MultiMedia1",
  4847. .cpu_dai_name = "MultiMedia1",
  4848. .platform_name = "msm-pcm-dsp.0",
  4849. .dynamic = 1,
  4850. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  4851. .dpcm_playback = 1,
  4852. .dpcm_capture = 1,
  4853. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  4854. SND_SOC_DPCM_TRIGGER_POST},
  4855. .codec_dai_name = "snd-soc-dummy-dai",
  4856. .codec_name = "snd-soc-dummy",
  4857. .ignore_suspend = 1,
  4858. /* this dainlink has playback support */
  4859. .ignore_pmdown_time = 1,
  4860. .id = MSM_FRONTEND_DAI_MULTIMEDIA1
  4861. },
  4862. };
  4863. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  4864. /* Backend DAI Links */
  4865. {
  4866. .name = LPASS_BE_AUXPCM_RX,
  4867. .stream_name = "AUX PCM Playback",
  4868. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4869. .platform_name = "msm-pcm-routing",
  4870. .codec_name = "msm-stub-codec.1",
  4871. .codec_dai_name = "msm-stub-rx",
  4872. .no_pcm = 1,
  4873. .dpcm_playback = 1,
  4874. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  4875. .init = &msm_audrx_stub_init,
  4876. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4877. .ignore_pmdown_time = 1,
  4878. .ignore_suspend = 1,
  4879. .ops = &msm_stub_be_ops,
  4880. },
  4881. {
  4882. .name = LPASS_BE_AUXPCM_TX,
  4883. .stream_name = "AUX PCM Capture",
  4884. .cpu_dai_name = "msm-dai-q6-auxpcm.1",
  4885. .platform_name = "msm-pcm-routing",
  4886. .codec_name = "msm-stub-codec.1",
  4887. .codec_dai_name = "msm-stub-tx",
  4888. .no_pcm = 1,
  4889. .dpcm_capture = 1,
  4890. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  4891. .be_hw_params_fixup = msm_be_hw_params_fixup,
  4892. .ignore_suspend = 1,
  4893. .ops = &msm_stub_be_ops,
  4894. },
  4895. };
  4896. static struct snd_soc_dai_link msm_stub_dai_links[
  4897. ARRAY_SIZE(msm_stub_fe_dai_links) +
  4898. ARRAY_SIZE(msm_stub_be_dai_links)];
  4899. static const struct of_device_id kona_asoc_machine_of_match[] = {
  4900. { .compatible = "qcom,kona-asoc-snd",
  4901. .data = "codec"},
  4902. { .compatible = "qcom,kona-asoc-snd-stub",
  4903. .data = "stub_codec"},
  4904. {},
  4905. };
  4906. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  4907. {
  4908. struct snd_soc_card *card = NULL;
  4909. struct snd_soc_dai_link *dailink = NULL;
  4910. int len_1 = 0;
  4911. int len_2 = 0;
  4912. int total_links = 0;
  4913. int rc = 0;
  4914. u32 mi2s_audio_intf = 0;
  4915. u32 auxpcm_audio_intf = 0;
  4916. u32 val = 0;
  4917. const struct of_device_id *match;
  4918. match = of_match_node(kona_asoc_machine_of_match, dev->of_node);
  4919. if (!match) {
  4920. dev_err(dev, "%s: No DT match found for sound card\n",
  4921. __func__);
  4922. return NULL;
  4923. }
  4924. if (!strcmp(match->data, "codec")) {
  4925. card = &snd_soc_card_kona_msm;
  4926. memcpy(msm_kona_dai_links + total_links,
  4927. msm_common_dai_links,
  4928. sizeof(msm_common_dai_links));
  4929. total_links += ARRAY_SIZE(msm_common_dai_links);
  4930. memcpy(msm_kona_dai_links + total_links,
  4931. msm_bolero_fe_dai_links,
  4932. sizeof(msm_bolero_fe_dai_links));
  4933. total_links +=
  4934. ARRAY_SIZE(msm_bolero_fe_dai_links);
  4935. memcpy(msm_kona_dai_links + total_links,
  4936. msm_common_misc_fe_dai_links,
  4937. sizeof(msm_common_misc_fe_dai_links));
  4938. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  4939. memcpy(msm_kona_dai_links + total_links,
  4940. msm_common_be_dai_links,
  4941. sizeof(msm_common_be_dai_links));
  4942. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  4943. memcpy(msm_kona_dai_links + total_links,
  4944. msm_wsa_cdc_dma_be_dai_links,
  4945. sizeof(msm_wsa_cdc_dma_be_dai_links));
  4946. total_links +=
  4947. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  4948. memcpy(msm_kona_dai_links + total_links,
  4949. msm_rx_tx_cdc_dma_be_dai_links,
  4950. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  4951. total_links +=
  4952. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  4953. memcpy(msm_kona_dai_links + total_links,
  4954. msm_va_cdc_dma_be_dai_links,
  4955. sizeof(msm_va_cdc_dma_be_dai_links));
  4956. total_links +=
  4957. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  4958. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  4959. &mi2s_audio_intf);
  4960. if (rc) {
  4961. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  4962. __func__);
  4963. } else {
  4964. if (mi2s_audio_intf) {
  4965. memcpy(msm_kona_dai_links + total_links,
  4966. msm_mi2s_be_dai_links,
  4967. sizeof(msm_mi2s_be_dai_links));
  4968. total_links +=
  4969. ARRAY_SIZE(msm_mi2s_be_dai_links);
  4970. }
  4971. }
  4972. rc = of_property_read_u32(dev->of_node,
  4973. "qcom,auxpcm-audio-intf",
  4974. &auxpcm_audio_intf);
  4975. if (rc) {
  4976. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  4977. __func__);
  4978. } else {
  4979. if (auxpcm_audio_intf) {
  4980. memcpy(msm_kona_dai_links + total_links,
  4981. msm_auxpcm_be_dai_links,
  4982. sizeof(msm_auxpcm_be_dai_links));
  4983. total_links +=
  4984. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  4985. }
  4986. }
  4987. rc = of_property_read_u32(dev->of_node,
  4988. "qcom,ext-disp-audio-rx", &val);
  4989. if (!rc && val) {
  4990. dev_dbg(dev, "%s(): ext disp audio support present\n",
  4991. __func__);
  4992. memcpy(msm_kona_dai_links + total_links,
  4993. ext_disp_be_dai_link,
  4994. sizeof(ext_disp_be_dai_link));
  4995. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  4996. }
  4997. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  4998. if (!rc && val) {
  4999. dev_dbg(dev, "%s(): WCN BT support present\n",
  5000. __func__);
  5001. memcpy(msm_kona_dai_links + total_links,
  5002. msm_wcn_be_dai_links,
  5003. sizeof(msm_wcn_be_dai_links));
  5004. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  5005. }
  5006. dailink = msm_kona_dai_links;
  5007. } else if(!strcmp(match->data, "stub_codec")) {
  5008. card = &snd_soc_card_stub_msm;
  5009. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  5010. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  5011. memcpy(msm_stub_dai_links,
  5012. msm_stub_fe_dai_links,
  5013. sizeof(msm_stub_fe_dai_links));
  5014. memcpy(msm_stub_dai_links + len_1,
  5015. msm_stub_be_dai_links,
  5016. sizeof(msm_stub_be_dai_links));
  5017. dailink = msm_stub_dai_links;
  5018. total_links = len_2;
  5019. }
  5020. if (card) {
  5021. card->dai_link = dailink;
  5022. card->num_links = total_links;
  5023. }
  5024. return card;
  5025. }
  5026. static int msm_wsa881x_init(struct snd_soc_component *component)
  5027. {
  5028. u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  5029. u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  5030. u8 spkleft_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  5031. SPKR_L_BOOST, SPKR_L_VI};
  5032. u8 spkright_port_types[WSA881X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  5033. SPKR_R_BOOST, SPKR_R_VI};
  5034. unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
  5035. unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  5036. struct msm_asoc_mach_data *pdata;
  5037. struct snd_soc_dapm_context *dapm;
  5038. struct snd_card *card;
  5039. struct snd_info_entry *entry;
  5040. int ret = 0;
  5041. if (!component) {
  5042. pr_err("%s component is NULL\n", __func__);
  5043. return -EINVAL;
  5044. }
  5045. card = component->card->snd_card;
  5046. dapm = snd_soc_component_get_dapm(component);
  5047. if (!strcmp(component->name_prefix, "SpkrLeft")) {
  5048. dev_dbg(component->dev, "%s: setting left ch map to codec %s\n",
  5049. __func__, component->name);
  5050. wsa881x_set_channel_map(component, &spkleft_ports[0],
  5051. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  5052. &ch_rate[0], &spkleft_port_types[0]);
  5053. if (dapm->component) {
  5054. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft IN");
  5055. snd_soc_dapm_ignore_suspend(dapm, "SpkrLeft SPKR");
  5056. }
  5057. } else if (!strcmp(component->name_prefix, "SpkrRight")) {
  5058. dev_dbg(component->dev, "%s: setting right ch map to codec %s\n",
  5059. __func__, component->name);
  5060. wsa881x_set_channel_map(component, &spkright_ports[0],
  5061. WSA881X_MAX_SWR_PORTS, &ch_mask[0],
  5062. &ch_rate[0], &spkright_port_types[0]);
  5063. if (dapm->component) {
  5064. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight IN");
  5065. snd_soc_dapm_ignore_suspend(dapm, "SpkrRight SPKR");
  5066. }
  5067. } else {
  5068. dev_err(component->dev, "%s: wrong codec name %s\n", __func__,
  5069. component->name);
  5070. ret = -EINVAL;
  5071. goto err;
  5072. }
  5073. pdata = snd_soc_card_get_drvdata(component->card);
  5074. if (!pdata->codec_root) {
  5075. entry = snd_info_create_subdir(card->module, "codecs",
  5076. card->proc_root);
  5077. if (!entry) {
  5078. pr_err("%s: Cannot create codecs module entry\n",
  5079. __func__);
  5080. ret = 0;
  5081. goto err;
  5082. }
  5083. pdata->codec_root = entry;
  5084. }
  5085. wsa881x_codec_info_create_codec_entry(pdata->codec_root,
  5086. component);
  5087. err:
  5088. return ret;
  5089. }
  5090. static int msm_aux_codec_init(struct snd_soc_component *component)
  5091. {
  5092. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  5093. int ret = 0;
  5094. void *mbhc_calibration;
  5095. struct snd_info_entry *entry;
  5096. struct snd_card *card = component->card->snd_card;
  5097. struct msm_asoc_mach_data *pdata;
  5098. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  5099. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  5100. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  5101. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  5102. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  5103. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  5104. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  5105. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  5106. snd_soc_dapm_sync(dapm);
  5107. pdata = snd_soc_card_get_drvdata(component->card);
  5108. if (!pdata->codec_root) {
  5109. entry = snd_info_create_subdir(card->module, "codecs",
  5110. card->proc_root);
  5111. if (!entry) {
  5112. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  5113. __func__);
  5114. ret = 0;
  5115. goto mbhc_cfg_cal;
  5116. }
  5117. pdata->codec_root = entry;
  5118. }
  5119. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  5120. mbhc_cfg_cal:
  5121. mbhc_calibration = def_wcd_mbhc_cal();
  5122. if (!mbhc_calibration)
  5123. return -ENOMEM;
  5124. wcd_mbhc_cfg.calibration = mbhc_calibration;
  5125. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  5126. if (ret) {
  5127. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  5128. __func__, ret);
  5129. goto err_hs_detect;
  5130. }
  5131. return 0;
  5132. err_hs_detect:
  5133. kfree(mbhc_calibration);
  5134. return ret;
  5135. }
  5136. static int msm_init_aux_dev(struct platform_device *pdev,
  5137. struct snd_soc_card *card)
  5138. {
  5139. struct device_node *wsa_of_node;
  5140. struct device_node *aux_codec_of_node;
  5141. u32 wsa_max_devs;
  5142. u32 wsa_dev_cnt;
  5143. u32 codec_aux_dev_cnt = 0;
  5144. int i;
  5145. struct msm_wsa881x_dev_info *wsa881x_dev_info;
  5146. struct aux_codec_dev_info *aux_cdc_dev_info;
  5147. const char *auxdev_name_prefix[1];
  5148. char *dev_name_str = NULL;
  5149. int found = 0;
  5150. int codecs_found = 0;
  5151. int ret = 0;
  5152. /* Get maximum WSA device count for this platform */
  5153. ret = of_property_read_u32(pdev->dev.of_node,
  5154. "qcom,wsa-max-devs", &wsa_max_devs);
  5155. if (ret) {
  5156. dev_info(&pdev->dev,
  5157. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  5158. __func__, pdev->dev.of_node->full_name, ret);
  5159. wsa_max_devs = 0;
  5160. goto codec_aux_dev;
  5161. }
  5162. if (wsa_max_devs == 0) {
  5163. dev_warn(&pdev->dev,
  5164. "%s: Max WSA devices is 0 for this target?\n",
  5165. __func__);
  5166. goto codec_aux_dev;
  5167. }
  5168. /* Get count of WSA device phandles for this platform */
  5169. wsa_dev_cnt = of_count_phandle_with_args(pdev->dev.of_node,
  5170. "qcom,wsa-devs", NULL);
  5171. if (wsa_dev_cnt == -ENOENT) {
  5172. dev_warn(&pdev->dev, "%s: No wsa device defined in DT.\n",
  5173. __func__);
  5174. goto err;
  5175. } else if (wsa_dev_cnt <= 0) {
  5176. dev_err(&pdev->dev,
  5177. "%s: Error reading wsa device from DT. wsa_dev_cnt = %d\n",
  5178. __func__, wsa_dev_cnt);
  5179. ret = -EINVAL;
  5180. goto err;
  5181. }
  5182. /*
  5183. * Expect total phandles count to be NOT less than maximum possible
  5184. * WSA count. However, if it is less, then assign same value to
  5185. * max count as well.
  5186. */
  5187. if (wsa_dev_cnt < wsa_max_devs) {
  5188. dev_dbg(&pdev->dev,
  5189. "%s: wsa_max_devs = %d cannot exceed wsa_dev_cnt = %d\n",
  5190. __func__, wsa_max_devs, wsa_dev_cnt);
  5191. wsa_max_devs = wsa_dev_cnt;
  5192. }
  5193. /* Make sure prefix string passed for each WSA device */
  5194. ret = of_property_count_strings(pdev->dev.of_node,
  5195. "qcom,wsa-aux-dev-prefix");
  5196. if (ret != wsa_dev_cnt) {
  5197. dev_err(&pdev->dev,
  5198. "%s: expecting %d wsa prefix. Defined only %d in DT\n",
  5199. __func__, wsa_dev_cnt, ret);
  5200. ret = -EINVAL;
  5201. goto err;
  5202. }
  5203. /*
  5204. * Alloc mem to store phandle and index info of WSA device, if already
  5205. * registered with ALSA core
  5206. */
  5207. wsa881x_dev_info = devm_kcalloc(&pdev->dev, wsa_max_devs,
  5208. sizeof(struct msm_wsa881x_dev_info),
  5209. GFP_KERNEL);
  5210. if (!wsa881x_dev_info) {
  5211. ret = -ENOMEM;
  5212. goto err;
  5213. }
  5214. /*
  5215. * search and check whether all WSA devices are already
  5216. * registered with ALSA core or not. If found a node, store
  5217. * the node and the index in a local array of struct for later
  5218. * use.
  5219. */
  5220. for (i = 0; i < wsa_dev_cnt; i++) {
  5221. wsa_of_node = of_parse_phandle(pdev->dev.of_node,
  5222. "qcom,wsa-devs", i);
  5223. if (unlikely(!wsa_of_node)) {
  5224. /* we should not be here */
  5225. dev_err(&pdev->dev,
  5226. "%s: wsa dev node is not present\n",
  5227. __func__);
  5228. ret = -EINVAL;
  5229. goto err;
  5230. }
  5231. if (soc_find_component(wsa_of_node, NULL)) {
  5232. /* WSA device registered with ALSA core */
  5233. wsa881x_dev_info[found].of_node = wsa_of_node;
  5234. wsa881x_dev_info[found].index = i;
  5235. found++;
  5236. if (found == wsa_max_devs)
  5237. break;
  5238. }
  5239. }
  5240. if (found < wsa_max_devs) {
  5241. dev_dbg(&pdev->dev,
  5242. "%s: failed to find %d components. Found only %d\n",
  5243. __func__, wsa_max_devs, found);
  5244. return -EPROBE_DEFER;
  5245. }
  5246. dev_info(&pdev->dev,
  5247. "%s: found %d wsa881x devices registered with ALSA core\n",
  5248. __func__, found);
  5249. codec_aux_dev:
  5250. /* Get count of aux codec device phandles for this platform */
  5251. codec_aux_dev_cnt = of_count_phandle_with_args(
  5252. pdev->dev.of_node,
  5253. "qcom,codec-aux-devs", NULL);
  5254. if (codec_aux_dev_cnt == -ENOENT) {
  5255. dev_warn(&pdev->dev, "%s: No aux codec defined in DT.\n",
  5256. __func__);
  5257. goto err;
  5258. } else if (codec_aux_dev_cnt <= 0) {
  5259. dev_err(&pdev->dev,
  5260. "%s: Error reading aux codec device from DT, dev_cnt=%d\n",
  5261. __func__, codec_aux_dev_cnt);
  5262. ret = -EINVAL;
  5263. goto err;
  5264. }
  5265. /*
  5266. * Alloc mem to store phandle and index info of aux codec
  5267. * if already registered with ALSA core
  5268. */
  5269. aux_cdc_dev_info = devm_kcalloc(&pdev->dev, codec_aux_dev_cnt,
  5270. sizeof(struct aux_codec_dev_info),
  5271. GFP_KERNEL);
  5272. if (!aux_cdc_dev_info) {
  5273. ret = -ENOMEM;
  5274. goto err;
  5275. }
  5276. /*
  5277. * search and check whether all aux codecs are already
  5278. * registered with ALSA core or not. If found a node, store
  5279. * the node and the index in a local array of struct for later
  5280. * use.
  5281. */
  5282. for (i = 0; i < codec_aux_dev_cnt; i++) {
  5283. aux_codec_of_node = of_parse_phandle(pdev->dev.of_node,
  5284. "qcom,codec-aux-devs", i);
  5285. if (unlikely(!aux_codec_of_node)) {
  5286. /* we should not be here */
  5287. dev_err(&pdev->dev,
  5288. "%s: aux codec dev node is not present\n",
  5289. __func__);
  5290. ret = -EINVAL;
  5291. goto err;
  5292. }
  5293. if (soc_find_component(aux_codec_of_node, NULL)) {
  5294. /* AUX codec registered with ALSA core */
  5295. aux_cdc_dev_info[codecs_found].of_node =
  5296. aux_codec_of_node;
  5297. aux_cdc_dev_info[codecs_found].index = i;
  5298. codecs_found++;
  5299. }
  5300. }
  5301. if (codecs_found < codec_aux_dev_cnt) {
  5302. dev_dbg(&pdev->dev,
  5303. "%s: failed to find %d components. Found only %d\n",
  5304. __func__, codec_aux_dev_cnt, codecs_found);
  5305. return -EPROBE_DEFER;
  5306. }
  5307. dev_info(&pdev->dev,
  5308. "%s: found %d AUX codecs registered with ALSA core\n",
  5309. __func__, codecs_found);
  5310. card->num_aux_devs = wsa_max_devs + codec_aux_dev_cnt;
  5311. card->num_configs = wsa_max_devs + codec_aux_dev_cnt;
  5312. /* Alloc array of AUX devs struct */
  5313. msm_aux_dev = devm_kcalloc(&pdev->dev, card->num_aux_devs,
  5314. sizeof(struct snd_soc_aux_dev),
  5315. GFP_KERNEL);
  5316. if (!msm_aux_dev) {
  5317. ret = -ENOMEM;
  5318. goto err;
  5319. }
  5320. /* Alloc array of codec conf struct */
  5321. msm_codec_conf = devm_kcalloc(&pdev->dev, card->num_configs,
  5322. sizeof(struct snd_soc_codec_conf),
  5323. GFP_KERNEL);
  5324. if (!msm_codec_conf) {
  5325. ret = -ENOMEM;
  5326. goto err;
  5327. }
  5328. for (i = 0; i < wsa_max_devs; i++) {
  5329. dev_name_str = devm_kzalloc(&pdev->dev, DEV_NAME_STR_LEN,
  5330. GFP_KERNEL);
  5331. if (!dev_name_str) {
  5332. ret = -ENOMEM;
  5333. goto err;
  5334. }
  5335. ret = of_property_read_string_index(pdev->dev.of_node,
  5336. "qcom,wsa-aux-dev-prefix",
  5337. wsa881x_dev_info[i].index,
  5338. auxdev_name_prefix);
  5339. if (ret) {
  5340. dev_err(&pdev->dev,
  5341. "%s: failed to read wsa aux dev prefix, ret = %d\n",
  5342. __func__, ret);
  5343. ret = -EINVAL;
  5344. goto err;
  5345. }
  5346. snprintf(dev_name_str, strlen("wsa881x.%d"), "wsa881x.%d", i);
  5347. msm_aux_dev[i].name = dev_name_str;
  5348. msm_aux_dev[i].codec_name = NULL;
  5349. msm_aux_dev[i].codec_of_node =
  5350. wsa881x_dev_info[i].of_node;
  5351. msm_aux_dev[i].init = msm_wsa881x_init;
  5352. msm_codec_conf[i].dev_name = NULL;
  5353. msm_codec_conf[i].name_prefix = auxdev_name_prefix[0];
  5354. msm_codec_conf[i].of_node =
  5355. wsa881x_dev_info[i].of_node;
  5356. }
  5357. for (i = 0; i < codec_aux_dev_cnt; i++) {
  5358. msm_aux_dev[wsa_max_devs + i].name = NULL;
  5359. msm_aux_dev[wsa_max_devs + i].codec_name = NULL;
  5360. msm_aux_dev[wsa_max_devs + i].codec_of_node =
  5361. aux_cdc_dev_info[i].of_node;
  5362. msm_aux_dev[wsa_max_devs + i].init = msm_aux_codec_init;
  5363. msm_codec_conf[wsa_max_devs + i].dev_name = NULL;
  5364. msm_codec_conf[wsa_max_devs + i].name_prefix =
  5365. NULL;
  5366. msm_codec_conf[wsa_max_devs + i].of_node =
  5367. aux_cdc_dev_info[i].of_node;
  5368. }
  5369. card->codec_conf = msm_codec_conf;
  5370. card->aux_dev = msm_aux_dev;
  5371. err:
  5372. return ret;
  5373. }
  5374. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  5375. {
  5376. int count = 0;
  5377. u32 mi2s_master_slave[MI2S_MAX];
  5378. int ret = 0;
  5379. for (count = 0; count < MI2S_MAX; count++) {
  5380. mutex_init(&mi2s_intf_conf[count].lock);
  5381. mi2s_intf_conf[count].ref_cnt = 0;
  5382. }
  5383. ret = of_property_read_u32_array(pdev->dev.of_node,
  5384. "qcom,msm-mi2s-master",
  5385. mi2s_master_slave, MI2S_MAX);
  5386. if (ret) {
  5387. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  5388. __func__);
  5389. } else {
  5390. for (count = 0; count < MI2S_MAX; count++) {
  5391. mi2s_intf_conf[count].msm_is_mi2s_master =
  5392. mi2s_master_slave[count];
  5393. }
  5394. }
  5395. }
  5396. static void msm_i2s_auxpcm_deinit(void)
  5397. {
  5398. int count = 0;
  5399. for (count = 0; count < MI2S_MAX; count++) {
  5400. mutex_destroy(&mi2s_intf_conf[count].lock);
  5401. mi2s_intf_conf[count].ref_cnt = 0;
  5402. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  5403. }
  5404. }
  5405. static int kona_ssr_enable(struct device *dev, void *data)
  5406. {
  5407. struct platform_device *pdev = to_platform_device(dev);
  5408. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5409. int ret = 0;
  5410. if (!card) {
  5411. dev_err(dev, "%s: card is NULL\n", __func__);
  5412. ret = -EINVAL;
  5413. goto err;
  5414. }
  5415. if (!strcmp(card->name, "kona-stub-snd-card")) {
  5416. /* TODO */
  5417. dev_dbg(dev, "%s: TODO \n", __func__);
  5418. }
  5419. snd_soc_card_change_online_state(card, 1);
  5420. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  5421. err:
  5422. return ret;
  5423. }
  5424. static void kona_ssr_disable(struct device *dev, void *data)
  5425. {
  5426. struct platform_device *pdev = to_platform_device(dev);
  5427. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5428. if (!card) {
  5429. dev_err(dev, "%s: card is NULL\n", __func__);
  5430. return;
  5431. }
  5432. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  5433. snd_soc_card_change_online_state(card, 0);
  5434. if (!strcmp(card->name, "kona-stub-snd-card")) {
  5435. /* TODO */
  5436. dev_dbg(dev, "%s: TODO \n", __func__);
  5437. }
  5438. }
  5439. static const struct snd_event_ops kona_ssr_ops = {
  5440. .enable = kona_ssr_enable,
  5441. .disable = kona_ssr_disable,
  5442. };
  5443. static int msm_audio_ssr_compare(struct device *dev, void *data)
  5444. {
  5445. struct device_node *node = data;
  5446. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  5447. __func__, dev->of_node, node);
  5448. return (dev->of_node && dev->of_node == node);
  5449. }
  5450. static int msm_audio_ssr_register(struct device *dev)
  5451. {
  5452. struct device_node *np = dev->of_node;
  5453. struct snd_event_clients *ssr_clients = NULL;
  5454. struct device_node *node = NULL;
  5455. int ret = 0;
  5456. int i = 0;
  5457. for (i = 0; ; i++) {
  5458. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  5459. if (!node)
  5460. break;
  5461. snd_event_mstr_add_client(&ssr_clients,
  5462. msm_audio_ssr_compare, node);
  5463. }
  5464. ret = snd_event_master_register(dev, &kona_ssr_ops,
  5465. ssr_clients, NULL);
  5466. if (!ret)
  5467. snd_event_notify(dev, SND_EVENT_UP);
  5468. return ret;
  5469. }
  5470. static int msm_asoc_machine_probe(struct platform_device *pdev)
  5471. {
  5472. struct snd_soc_card *card = NULL;
  5473. struct msm_asoc_mach_data *pdata = NULL;
  5474. const char *mbhc_audio_jack_type = NULL;
  5475. int ret = 0;
  5476. if (!pdev->dev.of_node) {
  5477. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  5478. return -EINVAL;
  5479. }
  5480. pdata = devm_kzalloc(&pdev->dev,
  5481. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  5482. if (!pdata)
  5483. return -ENOMEM;
  5484. card = populate_snd_card_dailinks(&pdev->dev);
  5485. if (!card) {
  5486. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  5487. ret = -EINVAL;
  5488. goto err;
  5489. }
  5490. card->dev = &pdev->dev;
  5491. platform_set_drvdata(pdev, card);
  5492. snd_soc_card_set_drvdata(card, pdata);
  5493. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  5494. if (ret) {
  5495. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  5496. __func__, ret);
  5497. goto err;
  5498. }
  5499. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  5500. if (ret) {
  5501. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  5502. __func__, ret);
  5503. goto err;
  5504. }
  5505. ret = msm_populate_dai_link_component_of_node(card);
  5506. if (ret) {
  5507. ret = -EPROBE_DEFER;
  5508. goto err;
  5509. }
  5510. ret = msm_init_aux_dev(pdev, card);
  5511. if (ret)
  5512. goto err;
  5513. ret = devm_snd_soc_register_card(&pdev->dev, card);
  5514. if (ret == -EPROBE_DEFER) {
  5515. if (codec_reg_done)
  5516. ret = -EINVAL;
  5517. goto err;
  5518. } else if (ret) {
  5519. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  5520. __func__, ret);
  5521. goto err;
  5522. }
  5523. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  5524. __func__, card->name);
  5525. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5526. "qcom,hph-en1-gpio", 0);
  5527. if (!pdata->hph_en1_gpio_p) {
  5528. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  5529. __func__, "qcom,hph-en1-gpio",
  5530. pdev->dev.of_node->full_name);
  5531. }
  5532. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5533. "qcom,hph-en0-gpio", 0);
  5534. if (!pdata->hph_en0_gpio_p) {
  5535. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  5536. __func__, "qcom,hph-en0-gpio",
  5537. pdev->dev.of_node->full_name);
  5538. }
  5539. ret = of_property_read_string(pdev->dev.of_node,
  5540. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  5541. if (ret) {
  5542. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  5543. __func__, "qcom,mbhc-audio-jack-type",
  5544. pdev->dev.of_node->full_name);
  5545. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  5546. } else {
  5547. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  5548. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  5549. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  5550. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  5551. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  5552. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  5553. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  5554. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  5555. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  5556. } else {
  5557. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  5558. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  5559. }
  5560. }
  5561. /*
  5562. * Parse US-Euro gpio info from DT. Report no error if us-euro
  5563. * entry is not found in DT file as some targets do not support
  5564. * US-Euro detection
  5565. */
  5566. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5567. "qcom,us-euro-gpios", 0);
  5568. if (!pdata->us_euro_gpio_p) {
  5569. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  5570. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  5571. } else {
  5572. dev_dbg(&pdev->dev, "%s detected\n",
  5573. "qcom,us-euro-gpios");
  5574. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  5575. }
  5576. msm_i2s_auxpcm_init(pdev);
  5577. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5578. "qcom,cdc-dmic01-gpios",
  5579. 0);
  5580. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5581. "qcom,cdc-dmic23-gpios",
  5582. 0);
  5583. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  5584. "qcom,cdc-dmic45-gpios",
  5585. 0);
  5586. ret = msm_audio_ssr_register(&pdev->dev);
  5587. if (ret)
  5588. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  5589. __func__, ret);
  5590. is_initial_boot = true;
  5591. return 0;
  5592. err:
  5593. devm_kfree(&pdev->dev, pdata);
  5594. return ret;
  5595. }
  5596. static int msm_asoc_machine_remove(struct platform_device *pdev)
  5597. {
  5598. struct snd_soc_card *card = platform_get_drvdata(pdev);
  5599. snd_event_master_deregister(&pdev->dev);
  5600. snd_soc_unregister_card(card);
  5601. msm_i2s_auxpcm_deinit();
  5602. return 0;
  5603. }
  5604. static struct platform_driver kona_asoc_machine_driver = {
  5605. .driver = {
  5606. .name = DRV_NAME,
  5607. .owner = THIS_MODULE,
  5608. .pm = &snd_soc_pm_ops,
  5609. .of_match_table = kona_asoc_machine_of_match,
  5610. },
  5611. .probe = msm_asoc_machine_probe,
  5612. .remove = msm_asoc_machine_remove,
  5613. };
  5614. module_platform_driver(kona_asoc_machine_driver);
  5615. MODULE_DESCRIPTION("ALSA SoC msm");
  5616. MODULE_LICENSE("GPL v2");
  5617. MODULE_ALIAS("platform:" DRV_NAME);
  5618. MODULE_DEVICE_TABLE(of, kona_asoc_machine_of_match);