lahaina.c 234 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2020, 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 <soc/soundwire.h>
  28. #include "device_event.h"
  29. #include "msm-pcm-routing-v2.h"
  30. #include "asoc/msm-cdc-pinctrl.h"
  31. #include "asoc/wcd-mbhc-v2.h"
  32. #include "codecs/wcd938x/wcd938x-mbhc.h"
  33. #include "codecs/wsa883x/wsa883x.h"
  34. #include "codecs/wcd938x/wcd938x.h"
  35. #include "codecs/bolero/bolero-cdc.h"
  36. #include <dt-bindings/sound/audio-codec-port-types.h>
  37. #include "codecs/bolero/wsa-macro.h"
  38. #include "lahaina-port-config.h"
  39. #include "msm_dailink.h"
  40. #define DRV_NAME "lahaina-asoc-snd"
  41. #define __CHIPSET__ "LAHAINA "
  42. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  43. #define SAMPLING_RATE_8KHZ 8000
  44. #define SAMPLING_RATE_11P025KHZ 11025
  45. #define SAMPLING_RATE_16KHZ 16000
  46. #define SAMPLING_RATE_22P05KHZ 22050
  47. #define SAMPLING_RATE_32KHZ 32000
  48. #define SAMPLING_RATE_44P1KHZ 44100
  49. #define SAMPLING_RATE_48KHZ 48000
  50. #define SAMPLING_RATE_88P2KHZ 88200
  51. #define SAMPLING_RATE_96KHZ 96000
  52. #define SAMPLING_RATE_176P4KHZ 176400
  53. #define SAMPLING_RATE_192KHZ 192000
  54. #define SAMPLING_RATE_352P8KHZ 352800
  55. #define SAMPLING_RATE_384KHZ 384000
  56. #define IS_FRACTIONAL(x) \
  57. ((x == SAMPLING_RATE_11P025KHZ) || (x == SAMPLING_RATE_22P05KHZ) || \
  58. (x == SAMPLING_RATE_44P1KHZ) || (x == SAMPLING_RATE_88P2KHZ) || \
  59. (x == SAMPLING_RATE_176P4KHZ) || (x == SAMPLING_RATE_352P8KHZ))
  60. #define IS_MSM_INTERFACE_MI2S(x) \
  61. ((x == PRIM_MI2S) || (x == SEC_MI2S) || (x == TERT_MI2S))
  62. #define WCD9XXX_MBHC_DEF_RLOADS 5
  63. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  64. #define CODEC_EXT_CLK_RATE 9600000
  65. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  66. #define DEV_NAME_STR_LEN 32
  67. #define WCD_MBHC_HS_V_MAX 1600
  68. #define TDM_CHANNEL_MAX 8
  69. #define MSM_LL_QOS_VALUE 300 /* time in us to ensure LPM doesn't go in C3/C4 */
  70. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  71. #define WCN_CDC_SLIM_RX_CH_MAX 2
  72. #define WCN_CDC_SLIM_TX_CH_MAX 2
  73. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  74. #define SWR_MAX_SLAVE_DEVICES 6
  75. enum {
  76. RX_PATH = 0,
  77. TX_PATH,
  78. MAX_PATH,
  79. };
  80. enum {
  81. TDM_0 = 0,
  82. TDM_1,
  83. TDM_2,
  84. TDM_3,
  85. TDM_4,
  86. TDM_5,
  87. TDM_6,
  88. TDM_7,
  89. TDM_PORT_MAX,
  90. };
  91. #define TDM_MAX_SLOTS 8
  92. #define TDM_SLOT_WIDTH_BITS 32
  93. #define TDM_SLOT_WIDTH_BYTES TDM_SLOT_WIDTH_BITS/8
  94. enum {
  95. TDM_PRI = 0,
  96. TDM_SEC,
  97. TDM_TERT,
  98. TDM_QUAT,
  99. TDM_QUIN,
  100. TDM_SEN,
  101. TDM_INTERFACE_MAX,
  102. };
  103. enum {
  104. PRIM_AUX_PCM = 0,
  105. SEC_AUX_PCM,
  106. TERT_AUX_PCM,
  107. QUAT_AUX_PCM,
  108. QUIN_AUX_PCM,
  109. SEN_AUX_PCM,
  110. AUX_PCM_MAX,
  111. };
  112. enum {
  113. PRIM_MI2S = 0,
  114. SEC_MI2S,
  115. TERT_MI2S,
  116. QUAT_MI2S,
  117. QUIN_MI2S,
  118. SEN_MI2S,
  119. MI2S_MAX,
  120. };
  121. enum {
  122. WSA_CDC_DMA_RX_0 = 0,
  123. WSA_CDC_DMA_RX_1,
  124. RX_CDC_DMA_RX_0,
  125. RX_CDC_DMA_RX_1,
  126. RX_CDC_DMA_RX_2,
  127. RX_CDC_DMA_RX_3,
  128. RX_CDC_DMA_RX_5,
  129. RX_CDC_DMA_RX_6,
  130. CDC_DMA_RX_MAX,
  131. };
  132. enum {
  133. WSA_CDC_DMA_TX_0 = 0,
  134. WSA_CDC_DMA_TX_1,
  135. WSA_CDC_DMA_TX_2,
  136. TX_CDC_DMA_TX_0,
  137. TX_CDC_DMA_TX_3,
  138. TX_CDC_DMA_TX_4,
  139. VA_CDC_DMA_TX_0,
  140. VA_CDC_DMA_TX_1,
  141. VA_CDC_DMA_TX_2,
  142. CDC_DMA_TX_MAX,
  143. };
  144. enum {
  145. SLIM_RX_7 = 0,
  146. SLIM_RX_MAX,
  147. };
  148. enum {
  149. SLIM_TX_7 = 0,
  150. SLIM_TX_8,
  151. SLIM_TX_MAX,
  152. };
  153. enum {
  154. AFE_LOOPBACK_TX_IDX = 0,
  155. AFE_LOOPBACK_TX_IDX_MAX,
  156. };
  157. struct msm_asoc_mach_data {
  158. struct snd_info_entry *codec_root;
  159. int usbc_en2_gpio; /* used by gpio driver API */
  160. int lito_v2_enabled;
  161. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  162. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  163. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  164. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  165. atomic_t mi2s_gpio_ref_count[MI2S_MAX]; /* used by pinctrl API */
  166. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  167. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  168. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  169. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  170. bool is_afe_config_done;
  171. struct device_node *fsa_handle;
  172. struct clk *lpass_audio_hw_vote;
  173. int core_audio_vote_count;
  174. u32 wsa_max_devs;
  175. u32 tdm_max_slots; /* Max TDM slots used */
  176. int wcd_disabled;
  177. int (*get_wsa_dev_num)(struct snd_soc_component*);
  178. struct afe_cps_hw_intf_cfg cps_config;
  179. };
  180. struct tdm_port {
  181. u32 mode;
  182. u32 channel;
  183. };
  184. struct tdm_dev_config {
  185. unsigned int tdm_slot_offset[TDM_MAX_SLOTS];
  186. };
  187. enum {
  188. EXT_DISP_RX_IDX_DP = 0,
  189. EXT_DISP_RX_IDX_DP1,
  190. EXT_DISP_RX_IDX_MAX,
  191. };
  192. struct dev_config {
  193. u32 sample_rate;
  194. u32 bit_format;
  195. u32 channels;
  196. };
  197. /* Default configuration of slimbus channels */
  198. static struct dev_config slim_rx_cfg[] = {
  199. [SLIM_RX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  200. };
  201. static struct dev_config slim_tx_cfg[] = {
  202. [SLIM_TX_7] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  203. [SLIM_TX_8] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  204. };
  205. /* Default configuration of external display BE */
  206. static struct dev_config ext_disp_rx_cfg[] = {
  207. [EXT_DISP_RX_IDX_DP] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  208. [EXT_DISP_RX_IDX_DP1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  209. };
  210. static struct dev_config usb_rx_cfg = {
  211. .sample_rate = SAMPLING_RATE_48KHZ,
  212. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  213. .channels = 2,
  214. };
  215. static struct dev_config usb_tx_cfg = {
  216. .sample_rate = SAMPLING_RATE_48KHZ,
  217. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  218. .channels = 1,
  219. };
  220. static struct dev_config proxy_rx_cfg = {
  221. .sample_rate = SAMPLING_RATE_48KHZ,
  222. .bit_format = SNDRV_PCM_FORMAT_S16_LE,
  223. .channels = 2,
  224. };
  225. static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
  226. {
  227. AFE_API_VERSION_I2S_CONFIG,
  228. Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT,
  229. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  230. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  231. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  232. 0,
  233. },
  234. {
  235. AFE_API_VERSION_I2S_CONFIG,
  236. Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT,
  237. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  238. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  239. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  240. 0,
  241. },
  242. {
  243. AFE_API_VERSION_I2S_CONFIG,
  244. Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT,
  245. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  246. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  247. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  248. 0,
  249. },
  250. {
  251. AFE_API_VERSION_I2S_CONFIG,
  252. Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
  253. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  254. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  255. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  256. 0,
  257. },
  258. {
  259. AFE_API_VERSION_I2S_CONFIG,
  260. Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT,
  261. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  262. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  263. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  264. 0,
  265. },
  266. {
  267. AFE_API_VERSION_I2S_CONFIG,
  268. Q6AFE_LPASS_CLK_ID_SEN_MI2S_IBIT,
  269. Q6AFE_LPASS_IBIT_CLK_1_P536_MHZ,
  270. Q6AFE_LPASS_CLK_ATTRIBUTE_COUPLE_NO,
  271. Q6AFE_LPASS_CLK_ROOT_DEFAULT,
  272. 0,
  273. },
  274. };
  275. struct mi2s_conf {
  276. struct mutex lock;
  277. u32 ref_cnt;
  278. u32 msm_is_mi2s_master;
  279. };
  280. static u32 mi2s_ebit_clk[MI2S_MAX] = {
  281. Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
  282. Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
  283. Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
  284. };
  285. static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
  286. /* Default configuration of TDM channels */
  287. static struct dev_config tdm_rx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  288. { /* PRI TDM */
  289. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  290. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  291. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  292. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  293. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  294. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  295. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  296. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  297. },
  298. { /* SEC TDM */
  299. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  300. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  301. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  302. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  303. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  304. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  305. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  306. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  307. },
  308. { /* TERT TDM */
  309. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  310. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  311. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  312. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  313. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  314. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  315. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  316. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  317. },
  318. { /* QUAT TDM */
  319. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  320. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  321. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  322. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  323. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  324. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  325. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  326. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  327. },
  328. { /* QUIN TDM */
  329. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  330. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  331. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  332. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  333. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  334. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  335. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  336. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  337. },
  338. { /* SEN TDM */
  339. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_0 */
  340. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_1 */
  341. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_2 */
  342. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_3 */
  343. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_4 */
  344. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_5 */
  345. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_6 */
  346. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* RX_7 */
  347. },
  348. };
  349. static struct dev_config tdm_tx_cfg[TDM_INTERFACE_MAX][TDM_PORT_MAX] = {
  350. { /* PRI TDM */
  351. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  352. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  353. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  354. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  355. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  356. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  357. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  358. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  359. },
  360. { /* SEC TDM */
  361. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  362. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  363. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  364. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  365. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  366. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  367. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  368. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  369. },
  370. { /* TERT TDM */
  371. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  372. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  373. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  374. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  375. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  376. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  377. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  378. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  379. },
  380. { /* QUAT TDM */
  381. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  382. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  383. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  384. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  385. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  386. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  387. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  388. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  389. },
  390. { /* QUIN TDM */
  391. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  392. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  393. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  394. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  395. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  396. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  397. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  398. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  399. },
  400. { /* SEN TDM */
  401. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_0 */
  402. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_1 */
  403. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_2 */
  404. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_3 */
  405. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_4 */
  406. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_5 */
  407. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_6 */
  408. {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1}, /* TX_7 */
  409. },
  410. };
  411. /* Default configuration of AUX PCM channels */
  412. static struct dev_config aux_pcm_rx_cfg[] = {
  413. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  414. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  415. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  416. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  417. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  418. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  419. };
  420. static struct dev_config aux_pcm_tx_cfg[] = {
  421. [PRIM_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  422. [SEC_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  423. [TERT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  424. [QUAT_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  425. [QUIN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  426. [SEN_AUX_PCM] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  427. };
  428. /* Default configuration of MI2S channels */
  429. static struct dev_config mi2s_rx_cfg[] = {
  430. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  431. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  432. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  433. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  434. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  435. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  436. };
  437. static struct dev_config mi2s_tx_cfg[] = {
  438. [PRIM_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  439. [SEC_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  440. [TERT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  441. [QUAT_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  442. [QUIN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  443. [SEN_MI2S] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  444. };
  445. static struct tdm_dev_config pri_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  446. { /* PRI TDM */
  447. { {0, 4, 0xFFFF} }, /* RX_0 */
  448. { {8, 12, 0xFFFF} }, /* RX_1 */
  449. { {16, 20, 0xFFFF} }, /* RX_2 */
  450. { {24, 28, 0xFFFF} }, /* RX_3 */
  451. { {0xFFFF} }, /* RX_4 */
  452. { {0xFFFF} }, /* RX_5 */
  453. { {0xFFFF} }, /* RX_6 */
  454. { {0xFFFF} }, /* RX_7 */
  455. },
  456. {
  457. { {0, 4, 8, 12, 0xFFFF} }, /* TX_0 */
  458. { {8, 12, 0xFFFF} }, /* TX_1 */
  459. { {16, 20, 0xFFFF} }, /* TX_2 */
  460. { {24, 28, 0xFFFF} }, /* TX_3 */
  461. { {0xFFFF} }, /* TX_4 */
  462. { {0xFFFF} }, /* TX_5 */
  463. { {0xFFFF} }, /* TX_6 */
  464. { {0xFFFF} }, /* TX_7 */
  465. },
  466. };
  467. static struct tdm_dev_config sec_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  468. { /* SEC TDM */
  469. { {0, 4, 0xFFFF} }, /* RX_0 */
  470. { {8, 12, 0xFFFF} }, /* RX_1 */
  471. { {16, 20, 0xFFFF} }, /* RX_2 */
  472. { {24, 28, 0xFFFF} }, /* RX_3 */
  473. { {0xFFFF} }, /* RX_4 */
  474. { {0xFFFF} }, /* RX_5 */
  475. { {0xFFFF} }, /* RX_6 */
  476. { {0xFFFF} }, /* RX_7 */
  477. },
  478. {
  479. { {0, 4, 0xFFFF} }, /* TX_0 */
  480. { {8, 12, 0xFFFF} }, /* TX_1 */
  481. { {16, 20, 0xFFFF} }, /* TX_2 */
  482. { {24, 28, 0xFFFF} }, /* TX_3 */
  483. { {0xFFFF} }, /* TX_4 */
  484. { {0xFFFF} }, /* TX_5 */
  485. { {0xFFFF} }, /* TX_6 */
  486. { {0xFFFF} }, /* TX_7 */
  487. },
  488. };
  489. static struct tdm_dev_config tert_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  490. { /* TERT TDM */
  491. { {0, 4, 0xFFFF} }, /* RX_0 */
  492. { {8, 12, 0xFFFF} }, /* RX_1 */
  493. { {16, 20, 0xFFFF} }, /* RX_2 */
  494. { {24, 28, 0xFFFF} }, /* RX_3 */
  495. { {0xFFFF} }, /* RX_4 */
  496. { {0xFFFF} }, /* RX_5 */
  497. { {0xFFFF} }, /* RX_6 */
  498. { {0xFFFF} }, /* RX_7 */
  499. },
  500. {
  501. { {0, 4, 0xFFFF} }, /* TX_0 */
  502. { {8, 12, 0xFFFF} }, /* TX_1 */
  503. { {16, 20, 0xFFFF} }, /* TX_2 */
  504. { {24, 28, 0xFFFF} }, /* TX_3 */
  505. { {0xFFFF} }, /* TX_4 */
  506. { {0xFFFF} }, /* TX_5 */
  507. { {0xFFFF} }, /* TX_6 */
  508. { {0xFFFF} }, /* TX_7 */
  509. },
  510. };
  511. static struct tdm_dev_config quat_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  512. { /* QUAT TDM */
  513. { {0, 4, 0xFFFF} }, /* RX_0 */
  514. { {8, 12, 0xFFFF} }, /* RX_1 */
  515. { {16, 20, 0xFFFF} }, /* RX_2 */
  516. { {24, 28, 0xFFFF} }, /* RX_3 */
  517. { {0xFFFF} }, /* RX_4 */
  518. { {0xFFFF} }, /* RX_5 */
  519. { {0xFFFF} }, /* RX_6 */
  520. { {0xFFFF} }, /* RX_7 */
  521. },
  522. {
  523. { {0, 4, 0xFFFF} }, /* TX_0 */
  524. { {8, 12, 0xFFFF} }, /* TX_1 */
  525. { {16, 20, 0xFFFF} }, /* TX_2 */
  526. { {24, 28, 0xFFFF} }, /* TX_3 */
  527. { {0xFFFF} }, /* TX_4 */
  528. { {0xFFFF} }, /* TX_5 */
  529. { {0xFFFF} }, /* TX_6 */
  530. { {0xFFFF} }, /* TX_7 */
  531. },
  532. };
  533. static struct tdm_dev_config quin_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  534. { /* QUIN TDM */
  535. { {0, 4, 0xFFFF} }, /* RX_0 */
  536. { {8, 12, 0xFFFF} }, /* RX_1 */
  537. { {16, 20, 0xFFFF} }, /* RX_2 */
  538. { {24, 28, 0xFFFF} }, /* RX_3 */
  539. { {0xFFFF} }, /* RX_4 */
  540. { {0xFFFF} }, /* RX_5 */
  541. { {0xFFFF} }, /* RX_6 */
  542. { {0xFFFF} }, /* RX_7 */
  543. },
  544. {
  545. { {0, 4, 0xFFFF} }, /* TX_0 */
  546. { {8, 12, 0xFFFF} }, /* TX_1 */
  547. { {16, 20, 0xFFFF} }, /* TX_2 */
  548. { {24, 28, 0xFFFF} }, /* TX_3 */
  549. { {0xFFFF} }, /* TX_4 */
  550. { {0xFFFF} }, /* TX_5 */
  551. { {0xFFFF} }, /* TX_6 */
  552. { {0xFFFF} }, /* TX_7 */
  553. },
  554. };
  555. static struct tdm_dev_config sen_tdm_dev_config[MAX_PATH][TDM_PORT_MAX] = {
  556. { /* SEN TDM */
  557. { {0, 4, 0xFFFF} }, /* RX_0 */
  558. { {8, 12, 0xFFFF} }, /* RX_1 */
  559. { {16, 20, 0xFFFF} }, /* RX_2 */
  560. { {24, 28, 0xFFFF} }, /* RX_3 */
  561. { {0xFFFF} }, /* RX_4 */
  562. { {0xFFFF} }, /* RX_5 */
  563. { {0xFFFF} }, /* RX_6 */
  564. { {0xFFFF} }, /* RX_7 */
  565. },
  566. {
  567. { {0, 4, 0xFFFF} }, /* TX_0 */
  568. { {8, 12, 0xFFFF} }, /* TX_1 */
  569. { {16, 20, 0xFFFF} }, /* TX_2 */
  570. { {24, 28, 0xFFFF} }, /* TX_3 */
  571. { {0xFFFF} }, /* TX_4 */
  572. { {0xFFFF} }, /* TX_5 */
  573. { {0xFFFF} }, /* TX_6 */
  574. { {0xFFFF} }, /* TX_7 */
  575. },
  576. };
  577. static void *tdm_cfg[TDM_INTERFACE_MAX] = {
  578. pri_tdm_dev_config,
  579. sec_tdm_dev_config,
  580. tert_tdm_dev_config,
  581. quat_tdm_dev_config,
  582. quin_tdm_dev_config,
  583. sen_tdm_dev_config,
  584. };
  585. /* Default configuration of Codec DMA Interface RX */
  586. static struct dev_config cdc_dma_rx_cfg[] = {
  587. [WSA_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  588. [WSA_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  589. [RX_CDC_DMA_RX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  590. [RX_CDC_DMA_RX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  591. [RX_CDC_DMA_RX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  592. [RX_CDC_DMA_RX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  593. [RX_CDC_DMA_RX_5] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  594. [RX_CDC_DMA_RX_6] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  595. };
  596. /* Default configuration of Codec DMA Interface TX */
  597. static struct dev_config cdc_dma_tx_cfg[] = {
  598. [WSA_CDC_DMA_TX_0] = {SAMPLING_RATE_8KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  599. [WSA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  600. [WSA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  601. [TX_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  602. [TX_CDC_DMA_TX_3] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  603. [TX_CDC_DMA_TX_4] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 2},
  604. [VA_CDC_DMA_TX_0] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  605. [VA_CDC_DMA_TX_1] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  606. [VA_CDC_DMA_TX_2] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 8},
  607. };
  608. static struct dev_config afe_loopback_tx_cfg[] = {
  609. [AFE_LOOPBACK_TX_IDX] = {SAMPLING_RATE_48KHZ, SNDRV_PCM_FORMAT_S16_LE, 1},
  610. };
  611. static int msm_vi_feed_tx_ch = 2;
  612. static const char *const vi_feed_ch_text[] = {"One", "Two"};
  613. static char const *bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE",
  614. "S32_LE"};
  615. static char const *cdc80_bit_format_text[] = {"S16_LE", "S24_LE", "S24_3LE"};
  616. static char const *ch_text[] = {"Two", "Three", "Four", "Five",
  617. "Six", "Seven", "Eight"};
  618. static char const *usb_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  619. "KHZ_16", "KHZ_22P05",
  620. "KHZ_32", "KHZ_44P1", "KHZ_48",
  621. "KHZ_88P2", "KHZ_96", "KHZ_176P4",
  622. "KHZ_192", "KHZ_352P8", "KHZ_384"};
  623. static const char *const usb_ch_text[] = {"One", "Two", "Three", "Four",
  624. "Five", "Six", "Seven",
  625. "Eight"};
  626. static char const *tdm_sample_rate_text[] = {"KHZ_8", "KHZ_16", "KHZ_32",
  627. "KHZ_48", "KHZ_176P4",
  628. "KHZ_352P8"};
  629. static char const *tdm_bit_format_text[] = {"S16_LE", "S24_LE", "S32_LE"};
  630. static char const *tdm_ch_text[] = {"One", "Two", "Three", "Four",
  631. "Five", "Six", "Seven", "Eight"};
  632. static const char *const auxpcm_rate_text[] = {"KHZ_8", "KHZ_16"};
  633. static char const *mi2s_rate_text[] = {"KHZ_8", "KHZ_11P025", "KHZ_16",
  634. "KHZ_22P05", "KHZ_32", "KHZ_44P1",
  635. "KHZ_48", "KHZ_88P2", "KHZ_96",
  636. "KHZ_176P4", "KHZ_192","KHZ_352P8",
  637. "KHZ_384"};
  638. static const char *const mi2s_ch_text[] = {"One", "Two", "Three", "Four",
  639. "Five", "Six", "Seven",
  640. "Eight"};
  641. static const char *const cdc_dma_rx_ch_text[] = {"One", "Two"};
  642. static const char *const cdc_dma_tx_ch_text[] = {"One", "Two", "Three", "Four",
  643. "Five", "Six", "Seven",
  644. "Eight"};
  645. static char const *cdc_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  646. "KHZ_16", "KHZ_22P05",
  647. "KHZ_32", "KHZ_44P1", "KHZ_48",
  648. "KHZ_88P2", "KHZ_96",
  649. "KHZ_176P4", "KHZ_192",
  650. "KHZ_352P8", "KHZ_384"};
  651. static char const *cdc80_dma_sample_rate_text[] = {"KHZ_8", "KHZ_11P025",
  652. "KHZ_16", "KHZ_22P05",
  653. "KHZ_32", "KHZ_44P1", "KHZ_48",
  654. "KHZ_88P2", "KHZ_96",
  655. "KHZ_176P4", "KHZ_192"};
  656. static char const *ext_disp_bit_format_text[] = {"S16_LE", "S24_LE",
  657. "S24_3LE"};
  658. static char const *ext_disp_sample_rate_text[] = {"KHZ_48", "KHZ_96",
  659. "KHZ_192", "KHZ_32", "KHZ_44P1",
  660. "KHZ_88P2", "KHZ_176P4"};
  661. static char const *bt_sample_rate_text[] = {"KHZ_8", "KHZ_16",
  662. "KHZ_44P1", "KHZ_48",
  663. "KHZ_88P2", "KHZ_96"};
  664. static char const *bt_sample_rate_rx_text[] = {"KHZ_8", "KHZ_16",
  665. "KHZ_44P1", "KHZ_48",
  666. "KHZ_88P2", "KHZ_96"};
  667. static char const *bt_sample_rate_tx_text[] = {"KHZ_8", "KHZ_16",
  668. "KHZ_44P1", "KHZ_48",
  669. "KHZ_88P2", "KHZ_96"};
  670. static const char *const afe_loopback_tx_ch_text[] = {"One", "Two"};
  671. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_sample_rate, usb_sample_rate_text);
  672. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_sample_rate, usb_sample_rate_text);
  673. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_format, bit_format_text);
  674. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_format, bit_format_text);
  675. static SOC_ENUM_SINGLE_EXT_DECL(usb_rx_chs, usb_ch_text);
  676. static SOC_ENUM_SINGLE_EXT_DECL(usb_tx_chs, usb_ch_text);
  677. static SOC_ENUM_SINGLE_EXT_DECL(vi_feed_tx_chs, vi_feed_ch_text);
  678. static SOC_ENUM_SINGLE_EXT_DECL(proxy_rx_chs, ch_text);
  679. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_sample_rate, tdm_sample_rate_text);
  680. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_sample_rate, tdm_sample_rate_text);
  681. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_format, tdm_bit_format_text);
  682. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_format, tdm_bit_format_text);
  683. static SOC_ENUM_SINGLE_EXT_DECL(tdm_tx_chs, tdm_ch_text);
  684. static SOC_ENUM_SINGLE_EXT_DECL(tdm_rx_chs, tdm_ch_text);
  685. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  686. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  687. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  688. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  689. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  690. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_rx_sample_rate, auxpcm_rate_text);
  691. static SOC_ENUM_SINGLE_EXT_DECL(prim_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  692. static SOC_ENUM_SINGLE_EXT_DECL(sec_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  693. static SOC_ENUM_SINGLE_EXT_DECL(tert_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  694. static SOC_ENUM_SINGLE_EXT_DECL(quat_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  695. static SOC_ENUM_SINGLE_EXT_DECL(quin_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  696. static SOC_ENUM_SINGLE_EXT_DECL(sen_aux_pcm_tx_sample_rate, auxpcm_rate_text);
  697. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_rx_format, bit_format_text);
  698. static SOC_ENUM_SINGLE_EXT_DECL(aux_pcm_tx_format, bit_format_text);
  699. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_sample_rate, mi2s_rate_text);
  700. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_sample_rate, mi2s_rate_text);
  701. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_sample_rate, mi2s_rate_text);
  702. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_sample_rate, mi2s_rate_text);
  703. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_sample_rate, mi2s_rate_text);
  704. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_sample_rate, mi2s_rate_text);
  705. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_sample_rate, mi2s_rate_text);
  706. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_sample_rate, mi2s_rate_text);
  707. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_sample_rate, mi2s_rate_text);
  708. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_sample_rate, mi2s_rate_text);
  709. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_sample_rate, mi2s_rate_text);
  710. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_sample_rate, mi2s_rate_text);
  711. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_rx_format, bit_format_text);
  712. static SOC_ENUM_SINGLE_EXT_DECL(mi2s_tx_format, bit_format_text);
  713. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_rx_chs, mi2s_ch_text);
  714. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_rx_chs, mi2s_ch_text);
  715. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_rx_chs, mi2s_ch_text);
  716. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_rx_chs, mi2s_ch_text);
  717. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_rx_chs, mi2s_ch_text);
  718. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_rx_chs, mi2s_ch_text);
  719. static SOC_ENUM_SINGLE_EXT_DECL(prim_mi2s_tx_chs, mi2s_ch_text);
  720. static SOC_ENUM_SINGLE_EXT_DECL(sec_mi2s_tx_chs, mi2s_ch_text);
  721. static SOC_ENUM_SINGLE_EXT_DECL(tert_mi2s_tx_chs, mi2s_ch_text);
  722. static SOC_ENUM_SINGLE_EXT_DECL(quat_mi2s_tx_chs, mi2s_ch_text);
  723. static SOC_ENUM_SINGLE_EXT_DECL(quin_mi2s_tx_chs, mi2s_ch_text);
  724. static SOC_ENUM_SINGLE_EXT_DECL(sen_mi2s_tx_chs, mi2s_ch_text);
  725. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  726. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  727. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_0_chs, cdc_dma_rx_ch_text);
  728. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_1_chs, cdc_dma_rx_ch_text);
  729. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_2_chs, cdc_dma_rx_ch_text);
  730. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_3_chs, cdc_dma_rx_ch_text);
  731. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_5_chs, cdc_dma_rx_ch_text);
  732. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc_dma_rx_6_chs, cdc_dma_rx_ch_text);
  733. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  734. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  735. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  736. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  737. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_chs, cdc_dma_tx_ch_text);
  738. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_chs, cdc_dma_tx_ch_text);
  739. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_chs, cdc_dma_tx_ch_text);
  740. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_chs, cdc_dma_tx_ch_text);
  741. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_chs, cdc_dma_tx_ch_text);
  742. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_format, bit_format_text);
  743. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_format, bit_format_text);
  744. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_format, bit_format_text);
  745. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_format, bit_format_text);
  746. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_format, bit_format_text);
  747. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_format, bit_format_text);
  748. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_format, bit_format_text);
  749. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_format, bit_format_text);
  750. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_format, bit_format_text);
  751. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_format, bit_format_text);
  752. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_0_sample_rate,
  753. cdc_dma_sample_rate_text);
  754. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_rx_1_sample_rate,
  755. cdc_dma_sample_rate_text);
  756. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_0_sample_rate,
  757. cdc_dma_sample_rate_text);
  758. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_1_sample_rate,
  759. cdc_dma_sample_rate_text);
  760. static SOC_ENUM_SINGLE_EXT_DECL(wsa_cdc_dma_tx_2_sample_rate,
  761. cdc_dma_sample_rate_text);
  762. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_0_sample_rate,
  763. cdc_dma_sample_rate_text);
  764. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_3_sample_rate,
  765. cdc_dma_sample_rate_text);
  766. static SOC_ENUM_SINGLE_EXT_DECL(tx_cdc_dma_tx_4_sample_rate,
  767. cdc_dma_sample_rate_text);
  768. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_0_sample_rate,
  769. cdc_dma_sample_rate_text);
  770. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_1_sample_rate,
  771. cdc_dma_sample_rate_text);
  772. static SOC_ENUM_SINGLE_EXT_DECL(va_cdc_dma_tx_2_sample_rate,
  773. cdc_dma_sample_rate_text);
  774. /* WCD9380 */
  775. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_0_format, cdc80_bit_format_text);
  776. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_1_format, cdc80_bit_format_text);
  777. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_2_format, cdc80_bit_format_text);
  778. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_3_format, cdc80_bit_format_text);
  779. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_5_format, cdc80_bit_format_text);
  780. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_6_format, cdc80_bit_format_text);
  781. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_0_sample_rate,
  782. cdc80_dma_sample_rate_text);
  783. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_1_sample_rate,
  784. cdc80_dma_sample_rate_text);
  785. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_2_sample_rate,
  786. cdc80_dma_sample_rate_text);
  787. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_3_sample_rate,
  788. cdc80_dma_sample_rate_text);
  789. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_5_sample_rate,
  790. cdc80_dma_sample_rate_text);
  791. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc80_dma_rx_6_sample_rate,
  792. cdc80_dma_sample_rate_text);
  793. /* WCD9385 */
  794. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_0_format, bit_format_text);
  795. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_1_format, bit_format_text);
  796. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_2_format, bit_format_text);
  797. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_3_format, bit_format_text);
  798. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_5_format, bit_format_text);
  799. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_6_format, bit_format_text);
  800. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_0_sample_rate,
  801. cdc_dma_sample_rate_text);
  802. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_1_sample_rate,
  803. cdc_dma_sample_rate_text);
  804. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_2_sample_rate,
  805. cdc_dma_sample_rate_text);
  806. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_3_sample_rate,
  807. cdc_dma_sample_rate_text);
  808. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_5_sample_rate,
  809. cdc_dma_sample_rate_text);
  810. static SOC_ENUM_SINGLE_EXT_DECL(rx_cdc85_dma_rx_6_sample_rate,
  811. cdc_dma_sample_rate_text);
  812. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_chs, ch_text);
  813. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_format, ext_disp_bit_format_text);
  814. static SOC_ENUM_SINGLE_EXT_DECL(ext_disp_rx_sample_rate,
  815. ext_disp_sample_rate_text);
  816. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate, bt_sample_rate_text);
  817. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_rx, bt_sample_rate_rx_text);
  818. static SOC_ENUM_SINGLE_EXT_DECL(bt_sample_rate_tx, bt_sample_rate_tx_text);
  819. static SOC_ENUM_SINGLE_EXT_DECL(afe_loopback_tx_chs, afe_loopback_tx_ch_text);
  820. static bool is_initial_boot;
  821. static bool codec_reg_done;
  822. static struct snd_soc_card snd_soc_card_lahaina_msm;
  823. static int dmic_0_1_gpio_cnt;
  824. static int dmic_2_3_gpio_cnt;
  825. static int dmic_4_5_gpio_cnt;
  826. static void *def_wcd_mbhc_cal(void);
  827. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime*);
  828. static int msm_int_wsa_init(struct snd_soc_pcm_runtime*);
  829. /*
  830. * Need to report LINEIN
  831. * if R/L channel impedance is larger than 5K ohm
  832. */
  833. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  834. .read_fw_bin = false,
  835. .calibration = NULL,
  836. .detect_extn_cable = true,
  837. .mono_stero_detection = false,
  838. .swap_gnd_mic = NULL,
  839. .hs_ext_micbias = true,
  840. .key_code[0] = KEY_MEDIA,
  841. .key_code[1] = KEY_VOICECOMMAND,
  842. .key_code[2] = KEY_VOLUMEUP,
  843. .key_code[3] = KEY_VOLUMEDOWN,
  844. .key_code[4] = 0,
  845. .key_code[5] = 0,
  846. .key_code[6] = 0,
  847. .key_code[7] = 0,
  848. .linein_th = 5000,
  849. .moisture_en = false,
  850. .mbhc_micbias = MIC_BIAS_2,
  851. .anc_micbias = MIC_BIAS_2,
  852. .enable_anc_mic_detect = false,
  853. .moisture_duty_cycle_en = true,
  854. };
  855. /* set audio task affinity to core 1 & 2 */
  856. static const unsigned int audio_core_list[] = {1, 2};
  857. static cpumask_t audio_cpu_map = CPU_MASK_NONE;
  858. static struct dev_pm_qos_request *msm_audio_req = NULL;
  859. static unsigned int qos_client_active_cnt = 0;
  860. static void msm_audio_add_qos_request()
  861. {
  862. int i;
  863. int cpu = 0;
  864. msm_audio_req = kzalloc(sizeof(struct dev_pm_qos_request) * NR_CPUS,
  865. GFP_KERNEL);
  866. if (!msm_audio_req) {
  867. pr_err("%s failed to alloc mem for qos req.\n", __func__);
  868. return;
  869. }
  870. for (i = 0; i < ARRAY_SIZE(audio_core_list); i++) {
  871. if (audio_core_list[i] >= NR_CPUS)
  872. pr_err("%s incorrect cpu id: %d specified.\n", __func__, audio_core_list[i]);
  873. else
  874. cpumask_set_cpu(audio_core_list[i], &audio_cpu_map);
  875. }
  876. for_each_cpu(cpu, &audio_cpu_map) {
  877. dev_pm_qos_add_request(get_cpu_device(cpu),
  878. &msm_audio_req[cpu],
  879. DEV_PM_QOS_RESUME_LATENCY,
  880. PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE);
  881. pr_debug("%s set cpu affinity to core %d.\n", __func__, cpu);
  882. }
  883. }
  884. static void msm_audio_remove_qos_request()
  885. {
  886. int cpu = 0;
  887. if (msm_audio_req) {
  888. for_each_cpu(cpu, &audio_cpu_map) {
  889. dev_pm_qos_remove_request(
  890. &msm_audio_req[cpu]);
  891. pr_debug("%s remove cpu affinity of core %d.\n", __func__, cpu);
  892. }
  893. kfree(msm_audio_req);
  894. }
  895. }
  896. static void msm_audio_update_qos_request(u32 latency)
  897. {
  898. int cpu = 0;
  899. if (msm_audio_req) {
  900. for_each_cpu(cpu, &audio_cpu_map) {
  901. dev_pm_qos_update_request(
  902. &msm_audio_req[cpu], latency);
  903. pr_debug("%s update latency of core %d to %ul.\n", __func__, cpu, latency);
  904. }
  905. }
  906. }
  907. static inline int param_is_mask(int p)
  908. {
  909. return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
  910. (p <= SNDRV_PCM_HW_PARAM_LAST_MASK);
  911. }
  912. static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p,
  913. int n)
  914. {
  915. return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
  916. }
  917. static void param_set_mask(struct snd_pcm_hw_params *p, int n,
  918. unsigned int bit)
  919. {
  920. if (bit >= SNDRV_MASK_MAX)
  921. return;
  922. if (param_is_mask(n)) {
  923. struct snd_mask *m = param_to_mask(p, n);
  924. m->bits[0] = 0;
  925. m->bits[1] = 0;
  926. m->bits[bit >> 5] |= (1 << (bit & 31));
  927. }
  928. }
  929. static int usb_audio_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  930. struct snd_ctl_elem_value *ucontrol)
  931. {
  932. int sample_rate_val = 0;
  933. switch (usb_rx_cfg.sample_rate) {
  934. case SAMPLING_RATE_384KHZ:
  935. sample_rate_val = 12;
  936. break;
  937. case SAMPLING_RATE_352P8KHZ:
  938. sample_rate_val = 11;
  939. break;
  940. case SAMPLING_RATE_192KHZ:
  941. sample_rate_val = 10;
  942. break;
  943. case SAMPLING_RATE_176P4KHZ:
  944. sample_rate_val = 9;
  945. break;
  946. case SAMPLING_RATE_96KHZ:
  947. sample_rate_val = 8;
  948. break;
  949. case SAMPLING_RATE_88P2KHZ:
  950. sample_rate_val = 7;
  951. break;
  952. case SAMPLING_RATE_48KHZ:
  953. sample_rate_val = 6;
  954. break;
  955. case SAMPLING_RATE_44P1KHZ:
  956. sample_rate_val = 5;
  957. break;
  958. case SAMPLING_RATE_32KHZ:
  959. sample_rate_val = 4;
  960. break;
  961. case SAMPLING_RATE_22P05KHZ:
  962. sample_rate_val = 3;
  963. break;
  964. case SAMPLING_RATE_16KHZ:
  965. sample_rate_val = 2;
  966. break;
  967. case SAMPLING_RATE_11P025KHZ:
  968. sample_rate_val = 1;
  969. break;
  970. case SAMPLING_RATE_8KHZ:
  971. default:
  972. sample_rate_val = 0;
  973. break;
  974. }
  975. ucontrol->value.integer.value[0] = sample_rate_val;
  976. pr_debug("%s: usb_audio_rx_sample_rate = %d\n", __func__,
  977. usb_rx_cfg.sample_rate);
  978. return 0;
  979. }
  980. static int usb_audio_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  981. struct snd_ctl_elem_value *ucontrol)
  982. {
  983. switch (ucontrol->value.integer.value[0]) {
  984. case 12:
  985. usb_rx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  986. break;
  987. case 11:
  988. usb_rx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  989. break;
  990. case 10:
  991. usb_rx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  992. break;
  993. case 9:
  994. usb_rx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  995. break;
  996. case 8:
  997. usb_rx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  998. break;
  999. case 7:
  1000. usb_rx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1001. break;
  1002. case 6:
  1003. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1004. break;
  1005. case 5:
  1006. usb_rx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1007. break;
  1008. case 4:
  1009. usb_rx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1010. break;
  1011. case 3:
  1012. usb_rx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1013. break;
  1014. case 2:
  1015. usb_rx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1016. break;
  1017. case 1:
  1018. usb_rx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1019. break;
  1020. case 0:
  1021. usb_rx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1022. break;
  1023. default:
  1024. usb_rx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1025. break;
  1026. }
  1027. pr_debug("%s: control value = %ld, usb_audio_rx_sample_rate = %d\n",
  1028. __func__, ucontrol->value.integer.value[0],
  1029. usb_rx_cfg.sample_rate);
  1030. return 0;
  1031. }
  1032. static int usb_audio_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1033. struct snd_ctl_elem_value *ucontrol)
  1034. {
  1035. int sample_rate_val = 0;
  1036. switch (usb_tx_cfg.sample_rate) {
  1037. case SAMPLING_RATE_384KHZ:
  1038. sample_rate_val = 12;
  1039. break;
  1040. case SAMPLING_RATE_352P8KHZ:
  1041. sample_rate_val = 11;
  1042. break;
  1043. case SAMPLING_RATE_192KHZ:
  1044. sample_rate_val = 10;
  1045. break;
  1046. case SAMPLING_RATE_176P4KHZ:
  1047. sample_rate_val = 9;
  1048. break;
  1049. case SAMPLING_RATE_96KHZ:
  1050. sample_rate_val = 8;
  1051. break;
  1052. case SAMPLING_RATE_88P2KHZ:
  1053. sample_rate_val = 7;
  1054. break;
  1055. case SAMPLING_RATE_48KHZ:
  1056. sample_rate_val = 6;
  1057. break;
  1058. case SAMPLING_RATE_44P1KHZ:
  1059. sample_rate_val = 5;
  1060. break;
  1061. case SAMPLING_RATE_32KHZ:
  1062. sample_rate_val = 4;
  1063. break;
  1064. case SAMPLING_RATE_22P05KHZ:
  1065. sample_rate_val = 3;
  1066. break;
  1067. case SAMPLING_RATE_16KHZ:
  1068. sample_rate_val = 2;
  1069. break;
  1070. case SAMPLING_RATE_11P025KHZ:
  1071. sample_rate_val = 1;
  1072. break;
  1073. case SAMPLING_RATE_8KHZ:
  1074. sample_rate_val = 0;
  1075. break;
  1076. default:
  1077. sample_rate_val = 6;
  1078. break;
  1079. }
  1080. ucontrol->value.integer.value[0] = sample_rate_val;
  1081. pr_debug("%s: usb_audio_tx_sample_rate = %d\n", __func__,
  1082. usb_tx_cfg.sample_rate);
  1083. return 0;
  1084. }
  1085. static int usb_audio_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1086. struct snd_ctl_elem_value *ucontrol)
  1087. {
  1088. switch (ucontrol->value.integer.value[0]) {
  1089. case 12:
  1090. usb_tx_cfg.sample_rate = SAMPLING_RATE_384KHZ;
  1091. break;
  1092. case 11:
  1093. usb_tx_cfg.sample_rate = SAMPLING_RATE_352P8KHZ;
  1094. break;
  1095. case 10:
  1096. usb_tx_cfg.sample_rate = SAMPLING_RATE_192KHZ;
  1097. break;
  1098. case 9:
  1099. usb_tx_cfg.sample_rate = SAMPLING_RATE_176P4KHZ;
  1100. break;
  1101. case 8:
  1102. usb_tx_cfg.sample_rate = SAMPLING_RATE_96KHZ;
  1103. break;
  1104. case 7:
  1105. usb_tx_cfg.sample_rate = SAMPLING_RATE_88P2KHZ;
  1106. break;
  1107. case 6:
  1108. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1109. break;
  1110. case 5:
  1111. usb_tx_cfg.sample_rate = SAMPLING_RATE_44P1KHZ;
  1112. break;
  1113. case 4:
  1114. usb_tx_cfg.sample_rate = SAMPLING_RATE_32KHZ;
  1115. break;
  1116. case 3:
  1117. usb_tx_cfg.sample_rate = SAMPLING_RATE_22P05KHZ;
  1118. break;
  1119. case 2:
  1120. usb_tx_cfg.sample_rate = SAMPLING_RATE_16KHZ;
  1121. break;
  1122. case 1:
  1123. usb_tx_cfg.sample_rate = SAMPLING_RATE_11P025KHZ;
  1124. break;
  1125. case 0:
  1126. usb_tx_cfg.sample_rate = SAMPLING_RATE_8KHZ;
  1127. break;
  1128. default:
  1129. usb_tx_cfg.sample_rate = SAMPLING_RATE_48KHZ;
  1130. break;
  1131. }
  1132. pr_debug("%s: control value = %ld, usb_audio_tx_sample_rate = %d\n",
  1133. __func__, ucontrol->value.integer.value[0],
  1134. usb_tx_cfg.sample_rate);
  1135. return 0;
  1136. }
  1137. static int afe_loopback_tx_ch_get(struct snd_kcontrol *kcontrol,
  1138. struct snd_ctl_elem_value *ucontrol)
  1139. {
  1140. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  1141. afe_loopback_tx_cfg[0].channels);
  1142. ucontrol->value.enumerated.item[0] =
  1143. afe_loopback_tx_cfg[0].channels - 1;
  1144. return 0;
  1145. }
  1146. static int afe_loopback_tx_ch_put(struct snd_kcontrol *kcontrol,
  1147. struct snd_ctl_elem_value *ucontrol)
  1148. {
  1149. afe_loopback_tx_cfg[0].channels =
  1150. ucontrol->value.enumerated.item[0] + 1;
  1151. pr_debug("%s: afe_loopback_tx_ch = %d\n", __func__,
  1152. afe_loopback_tx_cfg[0].channels);
  1153. return 1;
  1154. }
  1155. static int usb_audio_rx_format_get(struct snd_kcontrol *kcontrol,
  1156. struct snd_ctl_elem_value *ucontrol)
  1157. {
  1158. switch (usb_rx_cfg.bit_format) {
  1159. case SNDRV_PCM_FORMAT_S32_LE:
  1160. ucontrol->value.integer.value[0] = 3;
  1161. break;
  1162. case SNDRV_PCM_FORMAT_S24_3LE:
  1163. ucontrol->value.integer.value[0] = 2;
  1164. break;
  1165. case SNDRV_PCM_FORMAT_S24_LE:
  1166. ucontrol->value.integer.value[0] = 1;
  1167. break;
  1168. case SNDRV_PCM_FORMAT_S16_LE:
  1169. default:
  1170. ucontrol->value.integer.value[0] = 0;
  1171. break;
  1172. }
  1173. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1174. __func__, usb_rx_cfg.bit_format,
  1175. ucontrol->value.integer.value[0]);
  1176. return 0;
  1177. }
  1178. static int usb_audio_rx_format_put(struct snd_kcontrol *kcontrol,
  1179. struct snd_ctl_elem_value *ucontrol)
  1180. {
  1181. int rc = 0;
  1182. switch (ucontrol->value.integer.value[0]) {
  1183. case 3:
  1184. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1185. break;
  1186. case 2:
  1187. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1188. break;
  1189. case 1:
  1190. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1191. break;
  1192. case 0:
  1193. default:
  1194. usb_rx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1195. break;
  1196. }
  1197. pr_debug("%s: usb_audio_rx_format = %d, ucontrol value = %ld\n",
  1198. __func__, usb_rx_cfg.bit_format,
  1199. ucontrol->value.integer.value[0]);
  1200. return rc;
  1201. }
  1202. static int usb_audio_tx_format_get(struct snd_kcontrol *kcontrol,
  1203. struct snd_ctl_elem_value *ucontrol)
  1204. {
  1205. switch (usb_tx_cfg.bit_format) {
  1206. case SNDRV_PCM_FORMAT_S32_LE:
  1207. ucontrol->value.integer.value[0] = 3;
  1208. break;
  1209. case SNDRV_PCM_FORMAT_S24_3LE:
  1210. ucontrol->value.integer.value[0] = 2;
  1211. break;
  1212. case SNDRV_PCM_FORMAT_S24_LE:
  1213. ucontrol->value.integer.value[0] = 1;
  1214. break;
  1215. case SNDRV_PCM_FORMAT_S16_LE:
  1216. default:
  1217. ucontrol->value.integer.value[0] = 0;
  1218. break;
  1219. }
  1220. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1221. __func__, usb_tx_cfg.bit_format,
  1222. ucontrol->value.integer.value[0]);
  1223. return 0;
  1224. }
  1225. static int usb_audio_tx_format_put(struct snd_kcontrol *kcontrol,
  1226. struct snd_ctl_elem_value *ucontrol)
  1227. {
  1228. int rc = 0;
  1229. switch (ucontrol->value.integer.value[0]) {
  1230. case 3:
  1231. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S32_LE;
  1232. break;
  1233. case 2:
  1234. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1235. break;
  1236. case 1:
  1237. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1238. break;
  1239. case 0:
  1240. default:
  1241. usb_tx_cfg.bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1242. break;
  1243. }
  1244. pr_debug("%s: usb_audio_tx_format = %d, ucontrol value = %ld\n",
  1245. __func__, usb_tx_cfg.bit_format,
  1246. ucontrol->value.integer.value[0]);
  1247. return rc;
  1248. }
  1249. static int usb_audio_rx_ch_get(struct snd_kcontrol *kcontrol,
  1250. struct snd_ctl_elem_value *ucontrol)
  1251. {
  1252. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__,
  1253. usb_rx_cfg.channels);
  1254. ucontrol->value.integer.value[0] = usb_rx_cfg.channels - 1;
  1255. return 0;
  1256. }
  1257. static int usb_audio_rx_ch_put(struct snd_kcontrol *kcontrol,
  1258. struct snd_ctl_elem_value *ucontrol)
  1259. {
  1260. usb_rx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1261. pr_debug("%s: usb_audio_rx_ch = %d\n", __func__, usb_rx_cfg.channels);
  1262. return 1;
  1263. }
  1264. static int usb_audio_tx_ch_get(struct snd_kcontrol *kcontrol,
  1265. struct snd_ctl_elem_value *ucontrol)
  1266. {
  1267. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__,
  1268. usb_tx_cfg.channels);
  1269. ucontrol->value.integer.value[0] = usb_tx_cfg.channels - 1;
  1270. return 0;
  1271. }
  1272. static int usb_audio_tx_ch_put(struct snd_kcontrol *kcontrol,
  1273. struct snd_ctl_elem_value *ucontrol)
  1274. {
  1275. usb_tx_cfg.channels = ucontrol->value.integer.value[0] + 1;
  1276. pr_debug("%s: usb_audio_tx_ch = %d\n", __func__, usb_tx_cfg.channels);
  1277. return 1;
  1278. }
  1279. static int msm_vi_feed_tx_ch_get(struct snd_kcontrol *kcontrol,
  1280. struct snd_ctl_elem_value *ucontrol)
  1281. {
  1282. ucontrol->value.integer.value[0] = msm_vi_feed_tx_ch - 1;
  1283. pr_debug("%s: msm_vi_feed_tx_ch = %ld\n", __func__,
  1284. ucontrol->value.integer.value[0]);
  1285. return 0;
  1286. }
  1287. static int msm_vi_feed_tx_ch_put(struct snd_kcontrol *kcontrol,
  1288. struct snd_ctl_elem_value *ucontrol)
  1289. {
  1290. msm_vi_feed_tx_ch = ucontrol->value.integer.value[0] + 1;
  1291. pr_debug("%s: msm_vi_feed_tx_ch = %d\n", __func__, msm_vi_feed_tx_ch);
  1292. return 1;
  1293. }
  1294. static int ext_disp_get_port_idx(struct snd_kcontrol *kcontrol)
  1295. {
  1296. int idx = 0;
  1297. if (strnstr(kcontrol->id.name, "Display Port RX",
  1298. sizeof("Display Port RX"))) {
  1299. idx = EXT_DISP_RX_IDX_DP;
  1300. } else if (strnstr(kcontrol->id.name, "Display Port1 RX",
  1301. sizeof("Display Port1 RX"))) {
  1302. idx = EXT_DISP_RX_IDX_DP1;
  1303. } else {
  1304. pr_err("%s: unsupported BE: %s\n",
  1305. __func__, kcontrol->id.name);
  1306. idx = -EINVAL;
  1307. }
  1308. return idx;
  1309. }
  1310. static int ext_disp_rx_format_get(struct snd_kcontrol *kcontrol,
  1311. struct snd_ctl_elem_value *ucontrol)
  1312. {
  1313. int idx = ext_disp_get_port_idx(kcontrol);
  1314. if (idx < 0)
  1315. return idx;
  1316. switch (ext_disp_rx_cfg[idx].bit_format) {
  1317. case SNDRV_PCM_FORMAT_S24_3LE:
  1318. ucontrol->value.integer.value[0] = 2;
  1319. break;
  1320. case SNDRV_PCM_FORMAT_S24_LE:
  1321. ucontrol->value.integer.value[0] = 1;
  1322. break;
  1323. case SNDRV_PCM_FORMAT_S16_LE:
  1324. default:
  1325. ucontrol->value.integer.value[0] = 0;
  1326. break;
  1327. }
  1328. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1329. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1330. ucontrol->value.integer.value[0]);
  1331. return 0;
  1332. }
  1333. static int ext_disp_rx_format_put(struct snd_kcontrol *kcontrol,
  1334. struct snd_ctl_elem_value *ucontrol)
  1335. {
  1336. int idx = ext_disp_get_port_idx(kcontrol);
  1337. if (idx < 0)
  1338. return idx;
  1339. switch (ucontrol->value.integer.value[0]) {
  1340. case 2:
  1341. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  1342. break;
  1343. case 1:
  1344. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  1345. break;
  1346. case 0:
  1347. default:
  1348. ext_disp_rx_cfg[idx].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  1349. break;
  1350. }
  1351. pr_debug("%s: ext_disp_rx[%d].format = %d, ucontrol value = %ld\n",
  1352. __func__, idx, ext_disp_rx_cfg[idx].bit_format,
  1353. ucontrol->value.integer.value[0]);
  1354. return 0;
  1355. }
  1356. static int ext_disp_rx_ch_get(struct snd_kcontrol *kcontrol,
  1357. struct snd_ctl_elem_value *ucontrol)
  1358. {
  1359. int idx = ext_disp_get_port_idx(kcontrol);
  1360. if (idx < 0)
  1361. return idx;
  1362. ucontrol->value.integer.value[0] =
  1363. ext_disp_rx_cfg[idx].channels - 2;
  1364. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1365. idx, ext_disp_rx_cfg[idx].channels);
  1366. return 0;
  1367. }
  1368. static int ext_disp_rx_ch_put(struct snd_kcontrol *kcontrol,
  1369. struct snd_ctl_elem_value *ucontrol)
  1370. {
  1371. int idx = ext_disp_get_port_idx(kcontrol);
  1372. if (idx < 0)
  1373. return idx;
  1374. ext_disp_rx_cfg[idx].channels =
  1375. ucontrol->value.integer.value[0] + 2;
  1376. pr_debug("%s: ext_disp_rx[%d].ch = %d\n", __func__,
  1377. idx, ext_disp_rx_cfg[idx].channels);
  1378. return 1;
  1379. }
  1380. static int ext_disp_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1381. struct snd_ctl_elem_value *ucontrol)
  1382. {
  1383. int sample_rate_val;
  1384. int idx = ext_disp_get_port_idx(kcontrol);
  1385. if (idx < 0)
  1386. return idx;
  1387. switch (ext_disp_rx_cfg[idx].sample_rate) {
  1388. case SAMPLING_RATE_176P4KHZ:
  1389. sample_rate_val = 6;
  1390. break;
  1391. case SAMPLING_RATE_88P2KHZ:
  1392. sample_rate_val = 5;
  1393. break;
  1394. case SAMPLING_RATE_44P1KHZ:
  1395. sample_rate_val = 4;
  1396. break;
  1397. case SAMPLING_RATE_32KHZ:
  1398. sample_rate_val = 3;
  1399. break;
  1400. case SAMPLING_RATE_192KHZ:
  1401. sample_rate_val = 2;
  1402. break;
  1403. case SAMPLING_RATE_96KHZ:
  1404. sample_rate_val = 1;
  1405. break;
  1406. case SAMPLING_RATE_48KHZ:
  1407. default:
  1408. sample_rate_val = 0;
  1409. break;
  1410. }
  1411. ucontrol->value.integer.value[0] = sample_rate_val;
  1412. pr_debug("%s: ext_disp_rx[%d].sample_rate = %d\n", __func__,
  1413. idx, ext_disp_rx_cfg[idx].sample_rate);
  1414. return 0;
  1415. }
  1416. static int ext_disp_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1417. struct snd_ctl_elem_value *ucontrol)
  1418. {
  1419. int idx = ext_disp_get_port_idx(kcontrol);
  1420. if (idx < 0)
  1421. return idx;
  1422. switch (ucontrol->value.integer.value[0]) {
  1423. case 6:
  1424. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_176P4KHZ;
  1425. break;
  1426. case 5:
  1427. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_88P2KHZ;
  1428. break;
  1429. case 4:
  1430. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_44P1KHZ;
  1431. break;
  1432. case 3:
  1433. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_32KHZ;
  1434. break;
  1435. case 2:
  1436. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_192KHZ;
  1437. break;
  1438. case 1:
  1439. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_96KHZ;
  1440. break;
  1441. case 0:
  1442. default:
  1443. ext_disp_rx_cfg[idx].sample_rate = SAMPLING_RATE_48KHZ;
  1444. break;
  1445. }
  1446. pr_debug("%s: control value = %ld, ext_disp_rx[%d].sample_rate = %d\n",
  1447. __func__, ucontrol->value.integer.value[0], idx,
  1448. ext_disp_rx_cfg[idx].sample_rate);
  1449. return 0;
  1450. }
  1451. static int proxy_rx_ch_get(struct snd_kcontrol *kcontrol,
  1452. struct snd_ctl_elem_value *ucontrol)
  1453. {
  1454. pr_debug("%s: proxy_rx channels = %d\n",
  1455. __func__, proxy_rx_cfg.channels);
  1456. ucontrol->value.integer.value[0] = proxy_rx_cfg.channels - 2;
  1457. return 0;
  1458. }
  1459. static int proxy_rx_ch_put(struct snd_kcontrol *kcontrol,
  1460. struct snd_ctl_elem_value *ucontrol)
  1461. {
  1462. proxy_rx_cfg.channels = ucontrol->value.integer.value[0] + 2;
  1463. pr_debug("%s: proxy_rx channels = %d\n",
  1464. __func__, proxy_rx_cfg.channels);
  1465. return 1;
  1466. }
  1467. static int tdm_get_port_idx(struct snd_kcontrol *kcontrol,
  1468. struct tdm_port *port)
  1469. {
  1470. if (port) {
  1471. if (strnstr(kcontrol->id.name, "PRI",
  1472. sizeof(kcontrol->id.name))) {
  1473. port->mode = TDM_PRI;
  1474. } else if (strnstr(kcontrol->id.name, "SEC",
  1475. sizeof(kcontrol->id.name))) {
  1476. port->mode = TDM_SEC;
  1477. } else if (strnstr(kcontrol->id.name, "TERT",
  1478. sizeof(kcontrol->id.name))) {
  1479. port->mode = TDM_TERT;
  1480. } else if (strnstr(kcontrol->id.name, "QUAT",
  1481. sizeof(kcontrol->id.name))) {
  1482. port->mode = TDM_QUAT;
  1483. } else if (strnstr(kcontrol->id.name, "QUIN",
  1484. sizeof(kcontrol->id.name))) {
  1485. port->mode = TDM_QUIN;
  1486. } else if (strnstr(kcontrol->id.name, "SEN",
  1487. sizeof(kcontrol->id.name))) {
  1488. port->mode = TDM_SEN;
  1489. } else {
  1490. pr_err("%s: unsupported mode in: %s\n",
  1491. __func__, kcontrol->id.name);
  1492. return -EINVAL;
  1493. }
  1494. if (strnstr(kcontrol->id.name, "RX_0",
  1495. sizeof(kcontrol->id.name)) ||
  1496. strnstr(kcontrol->id.name, "TX_0",
  1497. sizeof(kcontrol->id.name))) {
  1498. port->channel = TDM_0;
  1499. } else if (strnstr(kcontrol->id.name, "RX_1",
  1500. sizeof(kcontrol->id.name)) ||
  1501. strnstr(kcontrol->id.name, "TX_1",
  1502. sizeof(kcontrol->id.name))) {
  1503. port->channel = TDM_1;
  1504. } else if (strnstr(kcontrol->id.name, "RX_2",
  1505. sizeof(kcontrol->id.name)) ||
  1506. strnstr(kcontrol->id.name, "TX_2",
  1507. sizeof(kcontrol->id.name))) {
  1508. port->channel = TDM_2;
  1509. } else if (strnstr(kcontrol->id.name, "RX_3",
  1510. sizeof(kcontrol->id.name)) ||
  1511. strnstr(kcontrol->id.name, "TX_3",
  1512. sizeof(kcontrol->id.name))) {
  1513. port->channel = TDM_3;
  1514. } else if (strnstr(kcontrol->id.name, "RX_4",
  1515. sizeof(kcontrol->id.name)) ||
  1516. strnstr(kcontrol->id.name, "TX_4",
  1517. sizeof(kcontrol->id.name))) {
  1518. port->channel = TDM_4;
  1519. } else if (strnstr(kcontrol->id.name, "RX_5",
  1520. sizeof(kcontrol->id.name)) ||
  1521. strnstr(kcontrol->id.name, "TX_5",
  1522. sizeof(kcontrol->id.name))) {
  1523. port->channel = TDM_5;
  1524. } else if (strnstr(kcontrol->id.name, "RX_6",
  1525. sizeof(kcontrol->id.name)) ||
  1526. strnstr(kcontrol->id.name, "TX_6",
  1527. sizeof(kcontrol->id.name))) {
  1528. port->channel = TDM_6;
  1529. } else if (strnstr(kcontrol->id.name, "RX_7",
  1530. sizeof(kcontrol->id.name)) ||
  1531. strnstr(kcontrol->id.name, "TX_7",
  1532. sizeof(kcontrol->id.name))) {
  1533. port->channel = TDM_7;
  1534. } else {
  1535. pr_err("%s: unsupported channel in: %s\n",
  1536. __func__, kcontrol->id.name);
  1537. return -EINVAL;
  1538. }
  1539. } else {
  1540. return -EINVAL;
  1541. }
  1542. return 0;
  1543. }
  1544. static int tdm_get_sample_rate(int value)
  1545. {
  1546. int sample_rate = 0;
  1547. switch (value) {
  1548. case 0:
  1549. sample_rate = SAMPLING_RATE_8KHZ;
  1550. break;
  1551. case 1:
  1552. sample_rate = SAMPLING_RATE_16KHZ;
  1553. break;
  1554. case 2:
  1555. sample_rate = SAMPLING_RATE_32KHZ;
  1556. break;
  1557. case 3:
  1558. sample_rate = SAMPLING_RATE_48KHZ;
  1559. break;
  1560. case 4:
  1561. sample_rate = SAMPLING_RATE_176P4KHZ;
  1562. break;
  1563. case 5:
  1564. sample_rate = SAMPLING_RATE_352P8KHZ;
  1565. break;
  1566. default:
  1567. sample_rate = SAMPLING_RATE_48KHZ;
  1568. break;
  1569. }
  1570. return sample_rate;
  1571. }
  1572. static int tdm_get_sample_rate_val(int sample_rate)
  1573. {
  1574. int sample_rate_val = 0;
  1575. switch (sample_rate) {
  1576. case SAMPLING_RATE_8KHZ:
  1577. sample_rate_val = 0;
  1578. break;
  1579. case SAMPLING_RATE_16KHZ:
  1580. sample_rate_val = 1;
  1581. break;
  1582. case SAMPLING_RATE_32KHZ:
  1583. sample_rate_val = 2;
  1584. break;
  1585. case SAMPLING_RATE_48KHZ:
  1586. sample_rate_val = 3;
  1587. break;
  1588. case SAMPLING_RATE_176P4KHZ:
  1589. sample_rate_val = 4;
  1590. break;
  1591. case SAMPLING_RATE_352P8KHZ:
  1592. sample_rate_val = 5;
  1593. break;
  1594. default:
  1595. sample_rate_val = 3;
  1596. break;
  1597. }
  1598. return sample_rate_val;
  1599. }
  1600. static int tdm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1601. struct snd_ctl_elem_value *ucontrol)
  1602. {
  1603. struct tdm_port port;
  1604. int ret = tdm_get_port_idx(kcontrol, &port);
  1605. if (ret) {
  1606. pr_err("%s: unsupported control: %s\n",
  1607. __func__, kcontrol->id.name);
  1608. } else {
  1609. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1610. tdm_rx_cfg[port.mode][port.channel].sample_rate);
  1611. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1612. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1613. ucontrol->value.enumerated.item[0]);
  1614. }
  1615. return ret;
  1616. }
  1617. static int tdm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1618. struct snd_ctl_elem_value *ucontrol)
  1619. {
  1620. struct tdm_port port;
  1621. int ret = tdm_get_port_idx(kcontrol, &port);
  1622. if (ret) {
  1623. pr_err("%s: unsupported control: %s\n",
  1624. __func__, kcontrol->id.name);
  1625. } else {
  1626. tdm_rx_cfg[port.mode][port.channel].sample_rate =
  1627. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1628. pr_debug("%s: tdm_rx_sample_rate = %d, item = %d\n", __func__,
  1629. tdm_rx_cfg[port.mode][port.channel].sample_rate,
  1630. ucontrol->value.enumerated.item[0]);
  1631. }
  1632. return ret;
  1633. }
  1634. static int tdm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1635. struct snd_ctl_elem_value *ucontrol)
  1636. {
  1637. struct tdm_port port;
  1638. int ret = tdm_get_port_idx(kcontrol, &port);
  1639. if (ret) {
  1640. pr_err("%s: unsupported control: %s\n",
  1641. __func__, kcontrol->id.name);
  1642. } else {
  1643. ucontrol->value.enumerated.item[0] = tdm_get_sample_rate_val(
  1644. tdm_tx_cfg[port.mode][port.channel].sample_rate);
  1645. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1646. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1647. ucontrol->value.enumerated.item[0]);
  1648. }
  1649. return ret;
  1650. }
  1651. static int tdm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  1652. struct snd_ctl_elem_value *ucontrol)
  1653. {
  1654. struct tdm_port port;
  1655. int ret = tdm_get_port_idx(kcontrol, &port);
  1656. if (ret) {
  1657. pr_err("%s: unsupported control: %s\n",
  1658. __func__, kcontrol->id.name);
  1659. } else {
  1660. tdm_tx_cfg[port.mode][port.channel].sample_rate =
  1661. tdm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  1662. pr_debug("%s: tdm_tx_sample_rate = %d, item = %d\n", __func__,
  1663. tdm_tx_cfg[port.mode][port.channel].sample_rate,
  1664. ucontrol->value.enumerated.item[0]);
  1665. }
  1666. return ret;
  1667. }
  1668. static int tdm_get_format(int value)
  1669. {
  1670. int format = 0;
  1671. switch (value) {
  1672. case 0:
  1673. format = SNDRV_PCM_FORMAT_S16_LE;
  1674. break;
  1675. case 1:
  1676. format = SNDRV_PCM_FORMAT_S24_LE;
  1677. break;
  1678. case 2:
  1679. format = SNDRV_PCM_FORMAT_S32_LE;
  1680. break;
  1681. default:
  1682. format = SNDRV_PCM_FORMAT_S16_LE;
  1683. break;
  1684. }
  1685. return format;
  1686. }
  1687. static int tdm_get_format_val(int format)
  1688. {
  1689. int value = 0;
  1690. switch (format) {
  1691. case SNDRV_PCM_FORMAT_S16_LE:
  1692. value = 0;
  1693. break;
  1694. case SNDRV_PCM_FORMAT_S24_LE:
  1695. value = 1;
  1696. break;
  1697. case SNDRV_PCM_FORMAT_S32_LE:
  1698. value = 2;
  1699. break;
  1700. default:
  1701. value = 0;
  1702. break;
  1703. }
  1704. return value;
  1705. }
  1706. static int tdm_rx_format_get(struct snd_kcontrol *kcontrol,
  1707. struct snd_ctl_elem_value *ucontrol)
  1708. {
  1709. struct tdm_port port;
  1710. int ret = tdm_get_port_idx(kcontrol, &port);
  1711. if (ret) {
  1712. pr_err("%s: unsupported control: %s\n",
  1713. __func__, kcontrol->id.name);
  1714. } else {
  1715. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1716. tdm_rx_cfg[port.mode][port.channel].bit_format);
  1717. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1718. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1719. ucontrol->value.enumerated.item[0]);
  1720. }
  1721. return ret;
  1722. }
  1723. static int tdm_rx_format_put(struct snd_kcontrol *kcontrol,
  1724. struct snd_ctl_elem_value *ucontrol)
  1725. {
  1726. struct tdm_port port;
  1727. int ret = tdm_get_port_idx(kcontrol, &port);
  1728. if (ret) {
  1729. pr_err("%s: unsupported control: %s\n",
  1730. __func__, kcontrol->id.name);
  1731. } else {
  1732. tdm_rx_cfg[port.mode][port.channel].bit_format =
  1733. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1734. pr_debug("%s: tdm_rx_bit_format = %d, item = %d\n", __func__,
  1735. tdm_rx_cfg[port.mode][port.channel].bit_format,
  1736. ucontrol->value.enumerated.item[0]);
  1737. }
  1738. return ret;
  1739. }
  1740. static int tdm_tx_format_get(struct snd_kcontrol *kcontrol,
  1741. struct snd_ctl_elem_value *ucontrol)
  1742. {
  1743. struct tdm_port port;
  1744. int ret = tdm_get_port_idx(kcontrol, &port);
  1745. if (ret) {
  1746. pr_err("%s: unsupported control: %s\n",
  1747. __func__, kcontrol->id.name);
  1748. } else {
  1749. ucontrol->value.enumerated.item[0] = tdm_get_format_val(
  1750. tdm_tx_cfg[port.mode][port.channel].bit_format);
  1751. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1752. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1753. ucontrol->value.enumerated.item[0]);
  1754. }
  1755. return ret;
  1756. }
  1757. static int tdm_tx_format_put(struct snd_kcontrol *kcontrol,
  1758. struct snd_ctl_elem_value *ucontrol)
  1759. {
  1760. struct tdm_port port;
  1761. int ret = tdm_get_port_idx(kcontrol, &port);
  1762. if (ret) {
  1763. pr_err("%s: unsupported control: %s\n",
  1764. __func__, kcontrol->id.name);
  1765. } else {
  1766. tdm_tx_cfg[port.mode][port.channel].bit_format =
  1767. tdm_get_format(ucontrol->value.enumerated.item[0]);
  1768. pr_debug("%s: tdm_tx_bit_format = %d, item = %d\n", __func__,
  1769. tdm_tx_cfg[port.mode][port.channel].bit_format,
  1770. ucontrol->value.enumerated.item[0]);
  1771. }
  1772. return ret;
  1773. }
  1774. static int tdm_rx_ch_get(struct snd_kcontrol *kcontrol,
  1775. struct snd_ctl_elem_value *ucontrol)
  1776. {
  1777. struct tdm_port port;
  1778. int ret = tdm_get_port_idx(kcontrol, &port);
  1779. if (ret) {
  1780. pr_err("%s: unsupported control: %s\n",
  1781. __func__, kcontrol->id.name);
  1782. } else {
  1783. ucontrol->value.enumerated.item[0] =
  1784. tdm_rx_cfg[port.mode][port.channel].channels - 1;
  1785. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1786. tdm_rx_cfg[port.mode][port.channel].channels - 1,
  1787. ucontrol->value.enumerated.item[0]);
  1788. }
  1789. return ret;
  1790. }
  1791. static int tdm_rx_ch_put(struct snd_kcontrol *kcontrol,
  1792. struct snd_ctl_elem_value *ucontrol)
  1793. {
  1794. struct tdm_port port;
  1795. int ret = tdm_get_port_idx(kcontrol, &port);
  1796. if (ret) {
  1797. pr_err("%s: unsupported control: %s\n",
  1798. __func__, kcontrol->id.name);
  1799. } else {
  1800. tdm_rx_cfg[port.mode][port.channel].channels =
  1801. ucontrol->value.enumerated.item[0] + 1;
  1802. pr_debug("%s: tdm_rx_ch = %d, item = %d\n", __func__,
  1803. tdm_rx_cfg[port.mode][port.channel].channels,
  1804. ucontrol->value.enumerated.item[0] + 1);
  1805. }
  1806. return ret;
  1807. }
  1808. static int tdm_tx_ch_get(struct snd_kcontrol *kcontrol,
  1809. struct snd_ctl_elem_value *ucontrol)
  1810. {
  1811. struct tdm_port port;
  1812. int ret = tdm_get_port_idx(kcontrol, &port);
  1813. if (ret) {
  1814. pr_err("%s: unsupported control: %s\n",
  1815. __func__, kcontrol->id.name);
  1816. } else {
  1817. ucontrol->value.enumerated.item[0] =
  1818. tdm_tx_cfg[port.mode][port.channel].channels - 1;
  1819. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1820. tdm_tx_cfg[port.mode][port.channel].channels - 1,
  1821. ucontrol->value.enumerated.item[0]);
  1822. }
  1823. return ret;
  1824. }
  1825. static int tdm_tx_ch_put(struct snd_kcontrol *kcontrol,
  1826. struct snd_ctl_elem_value *ucontrol)
  1827. {
  1828. struct tdm_port port;
  1829. int ret = tdm_get_port_idx(kcontrol, &port);
  1830. if (ret) {
  1831. pr_err("%s: unsupported control: %s\n",
  1832. __func__, kcontrol->id.name);
  1833. } else {
  1834. tdm_tx_cfg[port.mode][port.channel].channels =
  1835. ucontrol->value.enumerated.item[0] + 1;
  1836. pr_debug("%s: tdm_tx_ch = %d, item = %d\n", __func__,
  1837. tdm_tx_cfg[port.mode][port.channel].channels,
  1838. ucontrol->value.enumerated.item[0] + 1);
  1839. }
  1840. return ret;
  1841. }
  1842. static int tdm_slot_map_put(struct snd_kcontrol *kcontrol,
  1843. struct snd_ctl_elem_value *ucontrol)
  1844. {
  1845. int slot_index = 0;
  1846. int interface = ucontrol->value.integer.value[0];
  1847. int channel = ucontrol->value.integer.value[1];
  1848. unsigned int offset_val = 0;
  1849. unsigned int *slot_offset = NULL;
  1850. struct tdm_dev_config *config = NULL;
  1851. unsigned int max_slot_offset = 0;
  1852. struct msm_asoc_mach_data *pdata = NULL;
  1853. struct snd_soc_component *component = NULL;
  1854. if (interface < 0 || interface >= (TDM_INTERFACE_MAX * MAX_PATH)) {
  1855. pr_err("%s: incorrect interface = %d\n", __func__, interface);
  1856. return -EINVAL;
  1857. }
  1858. if (channel < 0 || channel >= TDM_PORT_MAX) {
  1859. pr_err("%s: incorrect channel = %d\n", __func__, channel);
  1860. return -EINVAL;
  1861. }
  1862. pr_debug("%s: interface = %d, channel = %d\n", __func__,
  1863. interface, channel);
  1864. component = snd_soc_kcontrol_component(kcontrol);
  1865. pdata = snd_soc_card_get_drvdata(component->card);
  1866. config = ((struct tdm_dev_config *) tdm_cfg[interface / MAX_PATH]) +
  1867. ((interface % MAX_PATH) * TDM_PORT_MAX) + channel;
  1868. if (!config) {
  1869. pr_err("%s: tdm config is NULL\n", __func__);
  1870. return -EINVAL;
  1871. }
  1872. slot_offset = config->tdm_slot_offset;
  1873. if (!slot_offset) {
  1874. pr_err("%s: slot offset is NULL\n", __func__);
  1875. return -EINVAL;
  1876. }
  1877. max_slot_offset = TDM_SLOT_WIDTH_BYTES * (pdata->tdm_max_slots - 1);
  1878. for (slot_index = 0; slot_index < pdata->tdm_max_slots; slot_index++) {
  1879. offset_val = ucontrol->value.integer.value[MAX_PATH +
  1880. slot_index];
  1881. /* Offset value can only be 0, 4, 8, .. */
  1882. if (offset_val % 4 == 0 && offset_val <= max_slot_offset)
  1883. slot_offset[slot_index] = offset_val;
  1884. pr_debug("%s: slot offset[%d] = %d\n", __func__,
  1885. slot_index, slot_offset[slot_index]);
  1886. }
  1887. return 0;
  1888. }
  1889. static int aux_pcm_get_port_idx(struct snd_kcontrol *kcontrol)
  1890. {
  1891. int idx = 0;
  1892. if (strnstr(kcontrol->id.name, "PRIM_AUX_PCM",
  1893. sizeof("PRIM_AUX_PCM"))) {
  1894. idx = PRIM_AUX_PCM;
  1895. } else if (strnstr(kcontrol->id.name, "SEC_AUX_PCM",
  1896. sizeof("SEC_AUX_PCM"))) {
  1897. idx = SEC_AUX_PCM;
  1898. } else if (strnstr(kcontrol->id.name, "TERT_AUX_PCM",
  1899. sizeof("TERT_AUX_PCM"))) {
  1900. idx = TERT_AUX_PCM;
  1901. } else if (strnstr(kcontrol->id.name, "QUAT_AUX_PCM",
  1902. sizeof("QUAT_AUX_PCM"))) {
  1903. idx = QUAT_AUX_PCM;
  1904. } else if (strnstr(kcontrol->id.name, "QUIN_AUX_PCM",
  1905. sizeof("QUIN_AUX_PCM"))) {
  1906. idx = QUIN_AUX_PCM;
  1907. } else if (strnstr(kcontrol->id.name, "SEN_AUX_PCM",
  1908. sizeof("SEN_AUX_PCM"))) {
  1909. idx = SEN_AUX_PCM;
  1910. } else {
  1911. pr_err("%s: unsupported port: %s\n",
  1912. __func__, kcontrol->id.name);
  1913. idx = -EINVAL;
  1914. }
  1915. return idx;
  1916. }
  1917. static int aux_pcm_get_sample_rate(int value)
  1918. {
  1919. int sample_rate = 0;
  1920. switch (value) {
  1921. case 1:
  1922. sample_rate = SAMPLING_RATE_16KHZ;
  1923. break;
  1924. case 0:
  1925. default:
  1926. sample_rate = SAMPLING_RATE_8KHZ;
  1927. break;
  1928. }
  1929. return sample_rate;
  1930. }
  1931. static int aux_pcm_get_sample_rate_val(int sample_rate)
  1932. {
  1933. int sample_rate_val = 0;
  1934. switch (sample_rate) {
  1935. case SAMPLING_RATE_16KHZ:
  1936. sample_rate_val = 1;
  1937. break;
  1938. case SAMPLING_RATE_8KHZ:
  1939. default:
  1940. sample_rate_val = 0;
  1941. break;
  1942. }
  1943. return sample_rate_val;
  1944. }
  1945. static int mi2s_auxpcm_get_format(int value)
  1946. {
  1947. int format = 0;
  1948. switch (value) {
  1949. case 0:
  1950. format = SNDRV_PCM_FORMAT_S16_LE;
  1951. break;
  1952. case 1:
  1953. format = SNDRV_PCM_FORMAT_S24_LE;
  1954. break;
  1955. case 2:
  1956. format = SNDRV_PCM_FORMAT_S24_3LE;
  1957. break;
  1958. case 3:
  1959. format = SNDRV_PCM_FORMAT_S32_LE;
  1960. break;
  1961. default:
  1962. format = SNDRV_PCM_FORMAT_S16_LE;
  1963. break;
  1964. }
  1965. return format;
  1966. }
  1967. static int mi2s_auxpcm_get_format_value(int format)
  1968. {
  1969. int value = 0;
  1970. switch (format) {
  1971. case SNDRV_PCM_FORMAT_S16_LE:
  1972. value = 0;
  1973. break;
  1974. case SNDRV_PCM_FORMAT_S24_LE:
  1975. value = 1;
  1976. break;
  1977. case SNDRV_PCM_FORMAT_S24_3LE:
  1978. value = 2;
  1979. break;
  1980. case SNDRV_PCM_FORMAT_S32_LE:
  1981. value = 3;
  1982. break;
  1983. default:
  1984. value = 0;
  1985. break;
  1986. }
  1987. return value;
  1988. }
  1989. static int aux_pcm_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  1990. struct snd_ctl_elem_value *ucontrol)
  1991. {
  1992. int idx = aux_pcm_get_port_idx(kcontrol);
  1993. if (idx < 0)
  1994. return idx;
  1995. ucontrol->value.enumerated.item[0] =
  1996. aux_pcm_get_sample_rate_val(aux_pcm_rx_cfg[idx].sample_rate);
  1997. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  1998. idx, aux_pcm_rx_cfg[idx].sample_rate,
  1999. ucontrol->value.enumerated.item[0]);
  2000. return 0;
  2001. }
  2002. static int aux_pcm_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2003. struct snd_ctl_elem_value *ucontrol)
  2004. {
  2005. int idx = aux_pcm_get_port_idx(kcontrol);
  2006. if (idx < 0)
  2007. return idx;
  2008. aux_pcm_rx_cfg[idx].sample_rate =
  2009. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2010. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2011. idx, aux_pcm_rx_cfg[idx].sample_rate,
  2012. ucontrol->value.enumerated.item[0]);
  2013. return 0;
  2014. }
  2015. static int aux_pcm_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2016. struct snd_ctl_elem_value *ucontrol)
  2017. {
  2018. int idx = aux_pcm_get_port_idx(kcontrol);
  2019. if (idx < 0)
  2020. return idx;
  2021. ucontrol->value.enumerated.item[0] =
  2022. aux_pcm_get_sample_rate_val(aux_pcm_tx_cfg[idx].sample_rate);
  2023. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2024. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2025. ucontrol->value.enumerated.item[0]);
  2026. return 0;
  2027. }
  2028. static int aux_pcm_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2029. struct snd_ctl_elem_value *ucontrol)
  2030. {
  2031. int idx = aux_pcm_get_port_idx(kcontrol);
  2032. if (idx < 0)
  2033. return idx;
  2034. aux_pcm_tx_cfg[idx].sample_rate =
  2035. aux_pcm_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2036. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2037. idx, aux_pcm_tx_cfg[idx].sample_rate,
  2038. ucontrol->value.enumerated.item[0]);
  2039. return 0;
  2040. }
  2041. static int msm_aux_pcm_rx_format_get(struct snd_kcontrol *kcontrol,
  2042. struct snd_ctl_elem_value *ucontrol)
  2043. {
  2044. int idx = aux_pcm_get_port_idx(kcontrol);
  2045. if (idx < 0)
  2046. return idx;
  2047. ucontrol->value.enumerated.item[0] =
  2048. mi2s_auxpcm_get_format_value(aux_pcm_rx_cfg[idx].bit_format);
  2049. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2050. idx, aux_pcm_rx_cfg[idx].bit_format,
  2051. ucontrol->value.enumerated.item[0]);
  2052. return 0;
  2053. }
  2054. static int msm_aux_pcm_rx_format_put(struct snd_kcontrol *kcontrol,
  2055. struct snd_ctl_elem_value *ucontrol)
  2056. {
  2057. int idx = aux_pcm_get_port_idx(kcontrol);
  2058. if (idx < 0)
  2059. return idx;
  2060. aux_pcm_rx_cfg[idx].bit_format =
  2061. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2062. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2063. idx, aux_pcm_rx_cfg[idx].bit_format,
  2064. ucontrol->value.enumerated.item[0]);
  2065. return 0;
  2066. }
  2067. static int msm_aux_pcm_tx_format_get(struct snd_kcontrol *kcontrol,
  2068. struct snd_ctl_elem_value *ucontrol)
  2069. {
  2070. int idx = aux_pcm_get_port_idx(kcontrol);
  2071. if (idx < 0)
  2072. return idx;
  2073. ucontrol->value.enumerated.item[0] =
  2074. mi2s_auxpcm_get_format_value(aux_pcm_tx_cfg[idx].bit_format);
  2075. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2076. idx, aux_pcm_tx_cfg[idx].bit_format,
  2077. ucontrol->value.enumerated.item[0]);
  2078. return 0;
  2079. }
  2080. static int msm_aux_pcm_tx_format_put(struct snd_kcontrol *kcontrol,
  2081. struct snd_ctl_elem_value *ucontrol)
  2082. {
  2083. int idx = aux_pcm_get_port_idx(kcontrol);
  2084. if (idx < 0)
  2085. return idx;
  2086. aux_pcm_tx_cfg[idx].bit_format =
  2087. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2088. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2089. idx, aux_pcm_tx_cfg[idx].bit_format,
  2090. ucontrol->value.enumerated.item[0]);
  2091. return 0;
  2092. }
  2093. static int mi2s_get_port_idx(struct snd_kcontrol *kcontrol)
  2094. {
  2095. int idx = 0;
  2096. if (strnstr(kcontrol->id.name, "PRIM_MI2S_RX",
  2097. sizeof("PRIM_MI2S_RX"))) {
  2098. idx = PRIM_MI2S;
  2099. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_RX",
  2100. sizeof("SEC_MI2S_RX"))) {
  2101. idx = SEC_MI2S;
  2102. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_RX",
  2103. sizeof("TERT_MI2S_RX"))) {
  2104. idx = TERT_MI2S;
  2105. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_RX",
  2106. sizeof("QUAT_MI2S_RX"))) {
  2107. idx = QUAT_MI2S;
  2108. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_RX",
  2109. sizeof("QUIN_MI2S_RX"))) {
  2110. idx = QUIN_MI2S;
  2111. } else if (strnstr(kcontrol->id.name, "SEN_MI2S_RX",
  2112. sizeof("SEN_MI2S_RX"))) {
  2113. idx = SEN_MI2S;
  2114. } else if (strnstr(kcontrol->id.name, "PRIM_MI2S_TX",
  2115. sizeof("PRIM_MI2S_TX"))) {
  2116. idx = PRIM_MI2S;
  2117. } else if (strnstr(kcontrol->id.name, "SEC_MI2S_TX",
  2118. sizeof("SEC_MI2S_TX"))) {
  2119. idx = SEC_MI2S;
  2120. } else if (strnstr(kcontrol->id.name, "TERT_MI2S_TX",
  2121. sizeof("TERT_MI2S_TX"))) {
  2122. idx = TERT_MI2S;
  2123. } else if (strnstr(kcontrol->id.name, "QUAT_MI2S_TX",
  2124. sizeof("QUAT_MI2S_TX"))) {
  2125. idx = QUAT_MI2S;
  2126. } else if (strnstr(kcontrol->id.name, "QUIN_MI2S_TX",
  2127. sizeof("QUIN_MI2S_TX"))) {
  2128. idx = QUIN_MI2S;
  2129. } else if (strnstr(kcontrol->id.name, "SEN_MI2S_TX",
  2130. sizeof("SEN_MI2S_TX"))) {
  2131. idx = SEN_MI2S;
  2132. } else {
  2133. pr_err("%s: unsupported channel: %s\n",
  2134. __func__, kcontrol->id.name);
  2135. idx = -EINVAL;
  2136. }
  2137. return idx;
  2138. }
  2139. static int mi2s_get_sample_rate(int value)
  2140. {
  2141. int sample_rate = 0;
  2142. switch (value) {
  2143. case 0:
  2144. sample_rate = SAMPLING_RATE_8KHZ;
  2145. break;
  2146. case 1:
  2147. sample_rate = SAMPLING_RATE_11P025KHZ;
  2148. break;
  2149. case 2:
  2150. sample_rate = SAMPLING_RATE_16KHZ;
  2151. break;
  2152. case 3:
  2153. sample_rate = SAMPLING_RATE_22P05KHZ;
  2154. break;
  2155. case 4:
  2156. sample_rate = SAMPLING_RATE_32KHZ;
  2157. break;
  2158. case 5:
  2159. sample_rate = SAMPLING_RATE_44P1KHZ;
  2160. break;
  2161. case 6:
  2162. sample_rate = SAMPLING_RATE_48KHZ;
  2163. break;
  2164. case 7:
  2165. sample_rate = SAMPLING_RATE_88P2KHZ;
  2166. break;
  2167. case 8:
  2168. sample_rate = SAMPLING_RATE_96KHZ;
  2169. break;
  2170. case 9:
  2171. sample_rate = SAMPLING_RATE_176P4KHZ;
  2172. break;
  2173. case 10:
  2174. sample_rate = SAMPLING_RATE_192KHZ;
  2175. break;
  2176. case 11:
  2177. sample_rate = SAMPLING_RATE_352P8KHZ;
  2178. break;
  2179. case 12:
  2180. sample_rate = SAMPLING_RATE_384KHZ;
  2181. break;
  2182. default:
  2183. sample_rate = SAMPLING_RATE_48KHZ;
  2184. break;
  2185. }
  2186. return sample_rate;
  2187. }
  2188. static int mi2s_get_sample_rate_val(int sample_rate)
  2189. {
  2190. int sample_rate_val = 0;
  2191. switch (sample_rate) {
  2192. case SAMPLING_RATE_8KHZ:
  2193. sample_rate_val = 0;
  2194. break;
  2195. case SAMPLING_RATE_11P025KHZ:
  2196. sample_rate_val = 1;
  2197. break;
  2198. case SAMPLING_RATE_16KHZ:
  2199. sample_rate_val = 2;
  2200. break;
  2201. case SAMPLING_RATE_22P05KHZ:
  2202. sample_rate_val = 3;
  2203. break;
  2204. case SAMPLING_RATE_32KHZ:
  2205. sample_rate_val = 4;
  2206. break;
  2207. case SAMPLING_RATE_44P1KHZ:
  2208. sample_rate_val = 5;
  2209. break;
  2210. case SAMPLING_RATE_48KHZ:
  2211. sample_rate_val = 6;
  2212. break;
  2213. case SAMPLING_RATE_88P2KHZ:
  2214. sample_rate_val = 7;
  2215. break;
  2216. case SAMPLING_RATE_96KHZ:
  2217. sample_rate_val = 8;
  2218. break;
  2219. case SAMPLING_RATE_176P4KHZ:
  2220. sample_rate_val = 9;
  2221. break;
  2222. case SAMPLING_RATE_192KHZ:
  2223. sample_rate_val = 10;
  2224. break;
  2225. case SAMPLING_RATE_352P8KHZ:
  2226. sample_rate_val = 11;
  2227. break;
  2228. case SAMPLING_RATE_384KHZ:
  2229. sample_rate_val = 12;
  2230. break;
  2231. default:
  2232. sample_rate_val = 6;
  2233. break;
  2234. }
  2235. return sample_rate_val;
  2236. }
  2237. static int mi2s_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2238. struct snd_ctl_elem_value *ucontrol)
  2239. {
  2240. int idx = mi2s_get_port_idx(kcontrol);
  2241. if (idx < 0)
  2242. return idx;
  2243. ucontrol->value.enumerated.item[0] =
  2244. mi2s_get_sample_rate_val(mi2s_rx_cfg[idx].sample_rate);
  2245. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2246. idx, mi2s_rx_cfg[idx].sample_rate,
  2247. ucontrol->value.enumerated.item[0]);
  2248. return 0;
  2249. }
  2250. static int mi2s_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2251. struct snd_ctl_elem_value *ucontrol)
  2252. {
  2253. int idx = mi2s_get_port_idx(kcontrol);
  2254. if (idx < 0)
  2255. return idx;
  2256. mi2s_rx_cfg[idx].sample_rate =
  2257. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2258. pr_debug("%s: idx[%d]_rx_sample_rate = %d, item = %d\n", __func__,
  2259. idx, mi2s_rx_cfg[idx].sample_rate,
  2260. ucontrol->value.enumerated.item[0]);
  2261. return 0;
  2262. }
  2263. static int mi2s_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2264. struct snd_ctl_elem_value *ucontrol)
  2265. {
  2266. int idx = mi2s_get_port_idx(kcontrol);
  2267. if (idx < 0)
  2268. return idx;
  2269. ucontrol->value.enumerated.item[0] =
  2270. mi2s_get_sample_rate_val(mi2s_tx_cfg[idx].sample_rate);
  2271. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2272. idx, mi2s_tx_cfg[idx].sample_rate,
  2273. ucontrol->value.enumerated.item[0]);
  2274. return 0;
  2275. }
  2276. static int mi2s_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2277. struct snd_ctl_elem_value *ucontrol)
  2278. {
  2279. int idx = mi2s_get_port_idx(kcontrol);
  2280. if (idx < 0)
  2281. return idx;
  2282. mi2s_tx_cfg[idx].sample_rate =
  2283. mi2s_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2284. pr_debug("%s: idx[%d]_tx_sample_rate = %d, item = %d\n", __func__,
  2285. idx, mi2s_tx_cfg[idx].sample_rate,
  2286. ucontrol->value.enumerated.item[0]);
  2287. return 0;
  2288. }
  2289. static int msm_mi2s_rx_format_get(struct snd_kcontrol *kcontrol,
  2290. struct snd_ctl_elem_value *ucontrol)
  2291. {
  2292. int idx = mi2s_get_port_idx(kcontrol);
  2293. if (idx < 0)
  2294. return idx;
  2295. ucontrol->value.enumerated.item[0] =
  2296. mi2s_auxpcm_get_format_value(mi2s_rx_cfg[idx].bit_format);
  2297. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2298. idx, mi2s_rx_cfg[idx].bit_format,
  2299. ucontrol->value.enumerated.item[0]);
  2300. return 0;
  2301. }
  2302. static int msm_mi2s_rx_format_put(struct snd_kcontrol *kcontrol,
  2303. struct snd_ctl_elem_value *ucontrol)
  2304. {
  2305. int idx = mi2s_get_port_idx(kcontrol);
  2306. if (idx < 0)
  2307. return idx;
  2308. mi2s_rx_cfg[idx].bit_format =
  2309. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2310. pr_debug("%s: idx[%d]_rx_format = %d, item = %d\n", __func__,
  2311. idx, mi2s_rx_cfg[idx].bit_format,
  2312. ucontrol->value.enumerated.item[0]);
  2313. return 0;
  2314. }
  2315. static int msm_mi2s_tx_format_get(struct snd_kcontrol *kcontrol,
  2316. struct snd_ctl_elem_value *ucontrol)
  2317. {
  2318. int idx = mi2s_get_port_idx(kcontrol);
  2319. if (idx < 0)
  2320. return idx;
  2321. ucontrol->value.enumerated.item[0] =
  2322. mi2s_auxpcm_get_format_value(mi2s_tx_cfg[idx].bit_format);
  2323. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2324. idx, mi2s_tx_cfg[idx].bit_format,
  2325. ucontrol->value.enumerated.item[0]);
  2326. return 0;
  2327. }
  2328. static int msm_mi2s_tx_format_put(struct snd_kcontrol *kcontrol,
  2329. struct snd_ctl_elem_value *ucontrol)
  2330. {
  2331. int idx = mi2s_get_port_idx(kcontrol);
  2332. if (idx < 0)
  2333. return idx;
  2334. mi2s_tx_cfg[idx].bit_format =
  2335. mi2s_auxpcm_get_format(ucontrol->value.enumerated.item[0]);
  2336. pr_debug("%s: idx[%d]_tx_format = %d, item = %d\n", __func__,
  2337. idx, mi2s_tx_cfg[idx].bit_format,
  2338. ucontrol->value.enumerated.item[0]);
  2339. return 0;
  2340. }
  2341. static int msm_mi2s_rx_ch_get(struct snd_kcontrol *kcontrol,
  2342. struct snd_ctl_elem_value *ucontrol)
  2343. {
  2344. int idx = mi2s_get_port_idx(kcontrol);
  2345. if (idx < 0)
  2346. return idx;
  2347. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2348. idx, mi2s_rx_cfg[idx].channels);
  2349. ucontrol->value.enumerated.item[0] = mi2s_rx_cfg[idx].channels - 1;
  2350. return 0;
  2351. }
  2352. static int msm_mi2s_rx_ch_put(struct snd_kcontrol *kcontrol,
  2353. struct snd_ctl_elem_value *ucontrol)
  2354. {
  2355. int idx = mi2s_get_port_idx(kcontrol);
  2356. if (idx < 0)
  2357. return idx;
  2358. mi2s_rx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2359. pr_debug("%s: msm_mi2s_[%d]_rx_ch = %d\n", __func__,
  2360. idx, mi2s_rx_cfg[idx].channels);
  2361. return 1;
  2362. }
  2363. static int msm_mi2s_tx_ch_get(struct snd_kcontrol *kcontrol,
  2364. struct snd_ctl_elem_value *ucontrol)
  2365. {
  2366. int idx = mi2s_get_port_idx(kcontrol);
  2367. if (idx < 0)
  2368. return idx;
  2369. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2370. idx, mi2s_tx_cfg[idx].channels);
  2371. ucontrol->value.enumerated.item[0] = mi2s_tx_cfg[idx].channels - 1;
  2372. return 0;
  2373. }
  2374. static int msm_mi2s_tx_ch_put(struct snd_kcontrol *kcontrol,
  2375. struct snd_ctl_elem_value *ucontrol)
  2376. {
  2377. int idx = mi2s_get_port_idx(kcontrol);
  2378. if (idx < 0)
  2379. return idx;
  2380. mi2s_tx_cfg[idx].channels = ucontrol->value.enumerated.item[0] + 1;
  2381. pr_debug("%s: msm_mi2s_[%d]_tx_ch = %d\n", __func__,
  2382. idx, mi2s_tx_cfg[idx].channels);
  2383. return 1;
  2384. }
  2385. static int msm_get_port_id(int be_id)
  2386. {
  2387. int afe_port_id = 0;
  2388. switch (be_id) {
  2389. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  2390. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_RX;
  2391. break;
  2392. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  2393. afe_port_id = AFE_PORT_ID_PRIMARY_MI2S_TX;
  2394. break;
  2395. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  2396. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_RX;
  2397. break;
  2398. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  2399. afe_port_id = AFE_PORT_ID_SECONDARY_MI2S_TX;
  2400. break;
  2401. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  2402. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_RX;
  2403. break;
  2404. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  2405. afe_port_id = AFE_PORT_ID_TERTIARY_MI2S_TX;
  2406. break;
  2407. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  2408. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_RX;
  2409. break;
  2410. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  2411. afe_port_id = AFE_PORT_ID_QUATERNARY_MI2S_TX;
  2412. break;
  2413. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  2414. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_RX;
  2415. break;
  2416. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  2417. afe_port_id = AFE_PORT_ID_QUINARY_MI2S_TX;
  2418. break;
  2419. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  2420. afe_port_id = AFE_PORT_ID_SENARY_MI2S_RX;
  2421. break;
  2422. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  2423. afe_port_id = AFE_PORT_ID_SENARY_MI2S_TX;
  2424. break;
  2425. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  2426. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_0;
  2427. break;
  2428. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  2429. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_1;
  2430. break;
  2431. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  2432. afe_port_id = AFE_PORT_ID_VA_CODEC_DMA_TX_2;
  2433. break;
  2434. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  2435. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0;
  2436. break;
  2437. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  2438. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_TX_0;
  2439. break;
  2440. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  2441. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1;
  2442. break;
  2443. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  2444. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_TX_1;
  2445. break;
  2446. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  2447. afe_port_id = AFE_PORT_ID_WSA_CODEC_DMA_TX_2;
  2448. break;
  2449. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  2450. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_0;
  2451. break;
  2452. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  2453. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_0;
  2454. break;
  2455. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  2456. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_1;
  2457. break;
  2458. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_1:
  2459. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_1;
  2460. break;
  2461. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  2462. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_2;
  2463. break;
  2464. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_2:
  2465. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_2;
  2466. break;
  2467. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  2468. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_3;
  2469. break;
  2470. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  2471. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_3;
  2472. break;
  2473. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  2474. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_4;
  2475. break;
  2476. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  2477. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_4;
  2478. break;
  2479. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  2480. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_5;
  2481. break;
  2482. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_5:
  2483. afe_port_id = AFE_PORT_ID_TX_CODEC_DMA_TX_5;
  2484. break;
  2485. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  2486. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_6;
  2487. break;
  2488. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_7:
  2489. afe_port_id = AFE_PORT_ID_RX_CODEC_DMA_RX_7;
  2490. break;
  2491. default:
  2492. pr_err("%s: Invalid BE id: %d\n", __func__, be_id);
  2493. afe_port_id = -EINVAL;
  2494. }
  2495. return afe_port_id;
  2496. }
  2497. static u32 get_mi2s_bits_per_sample(u32 bit_format)
  2498. {
  2499. u32 bit_per_sample = 0;
  2500. switch (bit_format) {
  2501. case SNDRV_PCM_FORMAT_S32_LE:
  2502. case SNDRV_PCM_FORMAT_S24_3LE:
  2503. case SNDRV_PCM_FORMAT_S24_LE:
  2504. bit_per_sample = 32;
  2505. break;
  2506. case SNDRV_PCM_FORMAT_S16_LE:
  2507. default:
  2508. bit_per_sample = 16;
  2509. break;
  2510. }
  2511. return bit_per_sample;
  2512. }
  2513. static void update_mi2s_clk_val(int dai_id, int stream)
  2514. {
  2515. u32 bit_per_sample = 0;
  2516. if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
  2517. bit_per_sample =
  2518. get_mi2s_bits_per_sample(mi2s_rx_cfg[dai_id].bit_format);
  2519. mi2s_clk[dai_id].clk_freq_in_hz =
  2520. mi2s_rx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2521. } else {
  2522. bit_per_sample =
  2523. get_mi2s_bits_per_sample(mi2s_tx_cfg[dai_id].bit_format);
  2524. mi2s_clk[dai_id].clk_freq_in_hz =
  2525. mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
  2526. }
  2527. }
  2528. static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
  2529. {
  2530. int ret = 0;
  2531. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  2532. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  2533. int port_id = 0;
  2534. int index = cpu_dai->id;
  2535. port_id = msm_get_port_id(rtd->dai_link->id);
  2536. if (port_id < 0) {
  2537. dev_err(rtd->card->dev, "%s: Invalid port_id\n", __func__);
  2538. ret = port_id;
  2539. goto err;
  2540. }
  2541. if (enable) {
  2542. update_mi2s_clk_val(index, substream->stream);
  2543. dev_dbg(rtd->card->dev, "%s: clock rate %ul\n", __func__,
  2544. mi2s_clk[index].clk_freq_in_hz);
  2545. }
  2546. mi2s_clk[index].enable = enable;
  2547. ret = afe_set_lpass_clock_v2(port_id,
  2548. &mi2s_clk[index]);
  2549. if (ret < 0) {
  2550. dev_err(rtd->card->dev,
  2551. "%s: afe lpass clock failed for port 0x%x , err:%d\n",
  2552. __func__, port_id, ret);
  2553. goto err;
  2554. }
  2555. err:
  2556. return ret;
  2557. }
  2558. static int cdc_dma_get_port_idx(struct snd_kcontrol *kcontrol)
  2559. {
  2560. int idx = 0;
  2561. if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_0",
  2562. sizeof("WSA_CDC_DMA_RX_0")))
  2563. idx = WSA_CDC_DMA_RX_0;
  2564. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_RX_1",
  2565. sizeof("WSA_CDC_DMA_RX_0")))
  2566. idx = WSA_CDC_DMA_RX_1;
  2567. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_0",
  2568. sizeof("RX_CDC_DMA_RX_0")))
  2569. idx = RX_CDC_DMA_RX_0;
  2570. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_1",
  2571. sizeof("RX_CDC_DMA_RX_1")))
  2572. idx = RX_CDC_DMA_RX_1;
  2573. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_2",
  2574. sizeof("RX_CDC_DMA_RX_2")))
  2575. idx = RX_CDC_DMA_RX_2;
  2576. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_3",
  2577. sizeof("RX_CDC_DMA_RX_3")))
  2578. idx = RX_CDC_DMA_RX_3;
  2579. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_5",
  2580. sizeof("RX_CDC_DMA_RX_5")))
  2581. idx = RX_CDC_DMA_RX_5;
  2582. else if (strnstr(kcontrol->id.name, "RX_CDC_DMA_RX_6",
  2583. sizeof("RX_CDC_DMA_RX_6")))
  2584. idx = RX_CDC_DMA_RX_6;
  2585. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_0",
  2586. sizeof("WSA_CDC_DMA_TX_0")))
  2587. idx = WSA_CDC_DMA_TX_0;
  2588. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_1",
  2589. sizeof("WSA_CDC_DMA_TX_1")))
  2590. idx = WSA_CDC_DMA_TX_1;
  2591. else if (strnstr(kcontrol->id.name, "WSA_CDC_DMA_TX_2",
  2592. sizeof("WSA_CDC_DMA_TX_2")))
  2593. idx = WSA_CDC_DMA_TX_2;
  2594. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_0",
  2595. sizeof("TX_CDC_DMA_TX_0")))
  2596. idx = TX_CDC_DMA_TX_0;
  2597. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_3",
  2598. sizeof("TX_CDC_DMA_TX_3")))
  2599. idx = TX_CDC_DMA_TX_3;
  2600. else if (strnstr(kcontrol->id.name, "TX_CDC_DMA_TX_4",
  2601. sizeof("TX_CDC_DMA_TX_4")))
  2602. idx = TX_CDC_DMA_TX_4;
  2603. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_0",
  2604. sizeof("VA_CDC_DMA_TX_0")))
  2605. idx = VA_CDC_DMA_TX_0;
  2606. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_1",
  2607. sizeof("VA_CDC_DMA_TX_1")))
  2608. idx = VA_CDC_DMA_TX_1;
  2609. else if (strnstr(kcontrol->id.name, "VA_CDC_DMA_TX_2",
  2610. sizeof("VA_CDC_DMA_TX_2")))
  2611. idx = VA_CDC_DMA_TX_2;
  2612. else {
  2613. pr_err("%s: unsupported channel: %s\n",
  2614. __func__, kcontrol->id.name);
  2615. return -EINVAL;
  2616. }
  2617. return idx;
  2618. }
  2619. static int cdc_dma_rx_ch_get(struct snd_kcontrol *kcontrol,
  2620. struct snd_ctl_elem_value *ucontrol)
  2621. {
  2622. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2623. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2624. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2625. return ch_num;
  2626. }
  2627. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2628. cdc_dma_rx_cfg[ch_num].channels - 1);
  2629. ucontrol->value.integer.value[0] = cdc_dma_rx_cfg[ch_num].channels - 1;
  2630. return 0;
  2631. }
  2632. static int cdc_dma_rx_ch_put(struct snd_kcontrol *kcontrol,
  2633. struct snd_ctl_elem_value *ucontrol)
  2634. {
  2635. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2636. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2637. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2638. return ch_num;
  2639. }
  2640. cdc_dma_rx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2641. pr_debug("%s: cdc_dma_rx_ch = %d\n", __func__,
  2642. cdc_dma_rx_cfg[ch_num].channels);
  2643. return 1;
  2644. }
  2645. static int cdc_dma_rx_format_get(struct snd_kcontrol *kcontrol,
  2646. struct snd_ctl_elem_value *ucontrol)
  2647. {
  2648. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2649. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2650. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2651. return ch_num;
  2652. }
  2653. switch (cdc_dma_rx_cfg[ch_num].bit_format) {
  2654. case SNDRV_PCM_FORMAT_S32_LE:
  2655. ucontrol->value.integer.value[0] = 3;
  2656. break;
  2657. case SNDRV_PCM_FORMAT_S24_3LE:
  2658. ucontrol->value.integer.value[0] = 2;
  2659. break;
  2660. case SNDRV_PCM_FORMAT_S24_LE:
  2661. ucontrol->value.integer.value[0] = 1;
  2662. break;
  2663. case SNDRV_PCM_FORMAT_S16_LE:
  2664. default:
  2665. ucontrol->value.integer.value[0] = 0;
  2666. break;
  2667. }
  2668. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2669. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2670. ucontrol->value.integer.value[0]);
  2671. return 0;
  2672. }
  2673. static int cdc_dma_rx_format_put(struct snd_kcontrol *kcontrol,
  2674. struct snd_ctl_elem_value *ucontrol)
  2675. {
  2676. int rc = 0;
  2677. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2678. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2679. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2680. return ch_num;
  2681. }
  2682. switch (ucontrol->value.integer.value[0]) {
  2683. case 3:
  2684. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  2685. break;
  2686. case 2:
  2687. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  2688. break;
  2689. case 1:
  2690. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  2691. break;
  2692. case 0:
  2693. default:
  2694. cdc_dma_rx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  2695. break;
  2696. }
  2697. pr_debug("%s: cdc_dma_rx_format = %d, ucontrol value = %ld\n",
  2698. __func__, cdc_dma_rx_cfg[ch_num].bit_format,
  2699. ucontrol->value.integer.value[0]);
  2700. return rc;
  2701. }
  2702. static int cdc_dma_get_sample_rate_val(int sample_rate)
  2703. {
  2704. int sample_rate_val = 0;
  2705. switch (sample_rate) {
  2706. case SAMPLING_RATE_8KHZ:
  2707. sample_rate_val = 0;
  2708. break;
  2709. case SAMPLING_RATE_11P025KHZ:
  2710. sample_rate_val = 1;
  2711. break;
  2712. case SAMPLING_RATE_16KHZ:
  2713. sample_rate_val = 2;
  2714. break;
  2715. case SAMPLING_RATE_22P05KHZ:
  2716. sample_rate_val = 3;
  2717. break;
  2718. case SAMPLING_RATE_32KHZ:
  2719. sample_rate_val = 4;
  2720. break;
  2721. case SAMPLING_RATE_44P1KHZ:
  2722. sample_rate_val = 5;
  2723. break;
  2724. case SAMPLING_RATE_48KHZ:
  2725. sample_rate_val = 6;
  2726. break;
  2727. case SAMPLING_RATE_88P2KHZ:
  2728. sample_rate_val = 7;
  2729. break;
  2730. case SAMPLING_RATE_96KHZ:
  2731. sample_rate_val = 8;
  2732. break;
  2733. case SAMPLING_RATE_176P4KHZ:
  2734. sample_rate_val = 9;
  2735. break;
  2736. case SAMPLING_RATE_192KHZ:
  2737. sample_rate_val = 10;
  2738. break;
  2739. case SAMPLING_RATE_352P8KHZ:
  2740. sample_rate_val = 11;
  2741. break;
  2742. case SAMPLING_RATE_384KHZ:
  2743. sample_rate_val = 12;
  2744. break;
  2745. default:
  2746. sample_rate_val = 6;
  2747. break;
  2748. }
  2749. return sample_rate_val;
  2750. }
  2751. static int cdc_dma_get_sample_rate(int value)
  2752. {
  2753. int sample_rate = 0;
  2754. switch (value) {
  2755. case 0:
  2756. sample_rate = SAMPLING_RATE_8KHZ;
  2757. break;
  2758. case 1:
  2759. sample_rate = SAMPLING_RATE_11P025KHZ;
  2760. break;
  2761. case 2:
  2762. sample_rate = SAMPLING_RATE_16KHZ;
  2763. break;
  2764. case 3:
  2765. sample_rate = SAMPLING_RATE_22P05KHZ;
  2766. break;
  2767. case 4:
  2768. sample_rate = SAMPLING_RATE_32KHZ;
  2769. break;
  2770. case 5:
  2771. sample_rate = SAMPLING_RATE_44P1KHZ;
  2772. break;
  2773. case 6:
  2774. sample_rate = SAMPLING_RATE_48KHZ;
  2775. break;
  2776. case 7:
  2777. sample_rate = SAMPLING_RATE_88P2KHZ;
  2778. break;
  2779. case 8:
  2780. sample_rate = SAMPLING_RATE_96KHZ;
  2781. break;
  2782. case 9:
  2783. sample_rate = SAMPLING_RATE_176P4KHZ;
  2784. break;
  2785. case 10:
  2786. sample_rate = SAMPLING_RATE_192KHZ;
  2787. break;
  2788. case 11:
  2789. sample_rate = SAMPLING_RATE_352P8KHZ;
  2790. break;
  2791. case 12:
  2792. sample_rate = SAMPLING_RATE_384KHZ;
  2793. break;
  2794. default:
  2795. sample_rate = SAMPLING_RATE_48KHZ;
  2796. break;
  2797. }
  2798. return sample_rate;
  2799. }
  2800. static int cdc_dma_rx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2801. struct snd_ctl_elem_value *ucontrol)
  2802. {
  2803. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2804. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2805. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2806. return ch_num;
  2807. }
  2808. ucontrol->value.enumerated.item[0] =
  2809. cdc_dma_get_sample_rate_val(cdc_dma_rx_cfg[ch_num].sample_rate);
  2810. pr_debug("%s: cdc_dma_rx_sample_rate = %d\n", __func__,
  2811. cdc_dma_rx_cfg[ch_num].sample_rate);
  2812. return 0;
  2813. }
  2814. static int cdc_dma_rx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2815. struct snd_ctl_elem_value *ucontrol)
  2816. {
  2817. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2818. if (ch_num < 0 || ch_num >= CDC_DMA_RX_MAX) {
  2819. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2820. return ch_num;
  2821. }
  2822. cdc_dma_rx_cfg[ch_num].sample_rate =
  2823. cdc_dma_get_sample_rate(ucontrol->value.enumerated.item[0]);
  2824. pr_debug("%s: control value = %d, cdc_dma_rx_sample_rate = %d\n",
  2825. __func__, ucontrol->value.enumerated.item[0],
  2826. cdc_dma_rx_cfg[ch_num].sample_rate);
  2827. return 0;
  2828. }
  2829. static int cdc_dma_tx_ch_get(struct snd_kcontrol *kcontrol,
  2830. struct snd_ctl_elem_value *ucontrol)
  2831. {
  2832. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2833. if (ch_num < 0) {
  2834. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2835. return ch_num;
  2836. }
  2837. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2838. cdc_dma_tx_cfg[ch_num].channels);
  2839. ucontrol->value.integer.value[0] = cdc_dma_tx_cfg[ch_num].channels - 1;
  2840. return 0;
  2841. }
  2842. static int cdc_dma_tx_ch_put(struct snd_kcontrol *kcontrol,
  2843. struct snd_ctl_elem_value *ucontrol)
  2844. {
  2845. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2846. if (ch_num < 0) {
  2847. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2848. return ch_num;
  2849. }
  2850. cdc_dma_tx_cfg[ch_num].channels = ucontrol->value.integer.value[0] + 1;
  2851. pr_debug("%s: cdc_dma_tx_ch = %d\n", __func__,
  2852. cdc_dma_tx_cfg[ch_num].channels);
  2853. return 1;
  2854. }
  2855. static int cdc_dma_tx_sample_rate_get(struct snd_kcontrol *kcontrol,
  2856. struct snd_ctl_elem_value *ucontrol)
  2857. {
  2858. int sample_rate_val;
  2859. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2860. if (ch_num < 0) {
  2861. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2862. return ch_num;
  2863. }
  2864. switch (cdc_dma_tx_cfg[ch_num].sample_rate) {
  2865. case SAMPLING_RATE_384KHZ:
  2866. sample_rate_val = 12;
  2867. break;
  2868. case SAMPLING_RATE_352P8KHZ:
  2869. sample_rate_val = 11;
  2870. break;
  2871. case SAMPLING_RATE_192KHZ:
  2872. sample_rate_val = 10;
  2873. break;
  2874. case SAMPLING_RATE_176P4KHZ:
  2875. sample_rate_val = 9;
  2876. break;
  2877. case SAMPLING_RATE_96KHZ:
  2878. sample_rate_val = 8;
  2879. break;
  2880. case SAMPLING_RATE_88P2KHZ:
  2881. sample_rate_val = 7;
  2882. break;
  2883. case SAMPLING_RATE_48KHZ:
  2884. sample_rate_val = 6;
  2885. break;
  2886. case SAMPLING_RATE_44P1KHZ:
  2887. sample_rate_val = 5;
  2888. break;
  2889. case SAMPLING_RATE_32KHZ:
  2890. sample_rate_val = 4;
  2891. break;
  2892. case SAMPLING_RATE_22P05KHZ:
  2893. sample_rate_val = 3;
  2894. break;
  2895. case SAMPLING_RATE_16KHZ:
  2896. sample_rate_val = 2;
  2897. break;
  2898. case SAMPLING_RATE_11P025KHZ:
  2899. sample_rate_val = 1;
  2900. break;
  2901. case SAMPLING_RATE_8KHZ:
  2902. sample_rate_val = 0;
  2903. break;
  2904. default:
  2905. sample_rate_val = 6;
  2906. break;
  2907. }
  2908. ucontrol->value.integer.value[0] = sample_rate_val;
  2909. pr_debug("%s: cdc_dma_tx_sample_rate = %d\n", __func__,
  2910. cdc_dma_tx_cfg[ch_num].sample_rate);
  2911. return 0;
  2912. }
  2913. static int cdc_dma_tx_sample_rate_put(struct snd_kcontrol *kcontrol,
  2914. struct snd_ctl_elem_value *ucontrol)
  2915. {
  2916. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2917. if (ch_num < 0) {
  2918. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2919. return ch_num;
  2920. }
  2921. switch (ucontrol->value.integer.value[0]) {
  2922. case 12:
  2923. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_384KHZ;
  2924. break;
  2925. case 11:
  2926. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_352P8KHZ;
  2927. break;
  2928. case 10:
  2929. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_192KHZ;
  2930. break;
  2931. case 9:
  2932. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_176P4KHZ;
  2933. break;
  2934. case 8:
  2935. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_96KHZ;
  2936. break;
  2937. case 7:
  2938. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_88P2KHZ;
  2939. break;
  2940. case 6:
  2941. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2942. break;
  2943. case 5:
  2944. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_44P1KHZ;
  2945. break;
  2946. case 4:
  2947. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_32KHZ;
  2948. break;
  2949. case 3:
  2950. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_22P05KHZ;
  2951. break;
  2952. case 2:
  2953. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_16KHZ;
  2954. break;
  2955. case 1:
  2956. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_11P025KHZ;
  2957. break;
  2958. case 0:
  2959. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_8KHZ;
  2960. break;
  2961. default:
  2962. cdc_dma_tx_cfg[ch_num].sample_rate = SAMPLING_RATE_48KHZ;
  2963. break;
  2964. }
  2965. pr_debug("%s: control value = %ld, cdc_dma_tx_sample_rate = %d\n",
  2966. __func__, ucontrol->value.integer.value[0],
  2967. cdc_dma_tx_cfg[ch_num].sample_rate);
  2968. return 0;
  2969. }
  2970. static int cdc_dma_tx_format_get(struct snd_kcontrol *kcontrol,
  2971. struct snd_ctl_elem_value *ucontrol)
  2972. {
  2973. int ch_num = cdc_dma_get_port_idx(kcontrol);
  2974. if (ch_num < 0) {
  2975. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  2976. return ch_num;
  2977. }
  2978. switch (cdc_dma_tx_cfg[ch_num].bit_format) {
  2979. case SNDRV_PCM_FORMAT_S32_LE:
  2980. ucontrol->value.integer.value[0] = 3;
  2981. break;
  2982. case SNDRV_PCM_FORMAT_S24_3LE:
  2983. ucontrol->value.integer.value[0] = 2;
  2984. break;
  2985. case SNDRV_PCM_FORMAT_S24_LE:
  2986. ucontrol->value.integer.value[0] = 1;
  2987. break;
  2988. case SNDRV_PCM_FORMAT_S16_LE:
  2989. default:
  2990. ucontrol->value.integer.value[0] = 0;
  2991. break;
  2992. }
  2993. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  2994. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  2995. ucontrol->value.integer.value[0]);
  2996. return 0;
  2997. }
  2998. static int cdc_dma_tx_format_put(struct snd_kcontrol *kcontrol,
  2999. struct snd_ctl_elem_value *ucontrol)
  3000. {
  3001. int rc = 0;
  3002. int ch_num = cdc_dma_get_port_idx(kcontrol);
  3003. if (ch_num < 0) {
  3004. pr_err("%s: ch_num: %d is invalid\n", __func__, ch_num);
  3005. return ch_num;
  3006. }
  3007. switch (ucontrol->value.integer.value[0]) {
  3008. case 3:
  3009. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S32_LE;
  3010. break;
  3011. case 2:
  3012. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_3LE;
  3013. break;
  3014. case 1:
  3015. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S24_LE;
  3016. break;
  3017. case 0:
  3018. default:
  3019. cdc_dma_tx_cfg[ch_num].bit_format = SNDRV_PCM_FORMAT_S16_LE;
  3020. break;
  3021. }
  3022. pr_debug("%s: cdc_dma_tx_format = %d, ucontrol value = %ld\n",
  3023. __func__, cdc_dma_tx_cfg[ch_num].bit_format,
  3024. ucontrol->value.integer.value[0]);
  3025. return rc;
  3026. }
  3027. static int msm_cdc_dma_get_idx_from_beid(int32_t be_id)
  3028. {
  3029. int idx = 0;
  3030. switch (be_id) {
  3031. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  3032. idx = WSA_CDC_DMA_RX_0;
  3033. break;
  3034. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  3035. idx = WSA_CDC_DMA_TX_0;
  3036. break;
  3037. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  3038. idx = WSA_CDC_DMA_RX_1;
  3039. break;
  3040. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  3041. idx = WSA_CDC_DMA_TX_1;
  3042. break;
  3043. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  3044. idx = WSA_CDC_DMA_TX_2;
  3045. break;
  3046. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  3047. idx = RX_CDC_DMA_RX_0;
  3048. break;
  3049. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  3050. idx = RX_CDC_DMA_RX_1;
  3051. break;
  3052. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  3053. idx = RX_CDC_DMA_RX_2;
  3054. break;
  3055. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  3056. idx = RX_CDC_DMA_RX_3;
  3057. break;
  3058. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  3059. idx = RX_CDC_DMA_RX_5;
  3060. break;
  3061. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  3062. idx = RX_CDC_DMA_RX_6;
  3063. break;
  3064. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  3065. idx = TX_CDC_DMA_TX_0;
  3066. break;
  3067. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  3068. idx = TX_CDC_DMA_TX_3;
  3069. break;
  3070. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  3071. idx = TX_CDC_DMA_TX_4;
  3072. break;
  3073. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  3074. idx = VA_CDC_DMA_TX_0;
  3075. break;
  3076. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  3077. idx = VA_CDC_DMA_TX_1;
  3078. break;
  3079. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  3080. idx = VA_CDC_DMA_TX_2;
  3081. break;
  3082. default:
  3083. idx = RX_CDC_DMA_RX_0;
  3084. break;
  3085. }
  3086. return idx;
  3087. }
  3088. static int msm_bt_sample_rate_get(struct snd_kcontrol *kcontrol,
  3089. struct snd_ctl_elem_value *ucontrol)
  3090. {
  3091. /*
  3092. * Slimbus_7_Rx/Tx sample rate values should always be in sync (same)
  3093. * when used for BT_SCO use case. Return either Rx or Tx sample rate
  3094. * value.
  3095. */
  3096. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  3097. case SAMPLING_RATE_96KHZ:
  3098. ucontrol->value.integer.value[0] = 5;
  3099. break;
  3100. case SAMPLING_RATE_88P2KHZ:
  3101. ucontrol->value.integer.value[0] = 4;
  3102. break;
  3103. case SAMPLING_RATE_48KHZ:
  3104. ucontrol->value.integer.value[0] = 3;
  3105. break;
  3106. case SAMPLING_RATE_44P1KHZ:
  3107. ucontrol->value.integer.value[0] = 2;
  3108. break;
  3109. case SAMPLING_RATE_16KHZ:
  3110. ucontrol->value.integer.value[0] = 1;
  3111. break;
  3112. case SAMPLING_RATE_8KHZ:
  3113. default:
  3114. ucontrol->value.integer.value[0] = 0;
  3115. break;
  3116. }
  3117. pr_debug("%s: sample rate = %d\n", __func__,
  3118. slim_rx_cfg[SLIM_RX_7].sample_rate);
  3119. return 0;
  3120. }
  3121. static int msm_bt_sample_rate_put(struct snd_kcontrol *kcontrol,
  3122. struct snd_ctl_elem_value *ucontrol)
  3123. {
  3124. switch (ucontrol->value.integer.value[0]) {
  3125. case 1:
  3126. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3127. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3128. break;
  3129. case 2:
  3130. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3131. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3132. break;
  3133. case 3:
  3134. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3135. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3136. break;
  3137. case 4:
  3138. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3139. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3140. break;
  3141. case 5:
  3142. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3143. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3144. break;
  3145. case 0:
  3146. default:
  3147. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3148. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3149. break;
  3150. }
  3151. pr_debug("%s: sample rates: slim7_rx = %d, slim7_tx = %d, value = %d\n",
  3152. __func__,
  3153. slim_rx_cfg[SLIM_RX_7].sample_rate,
  3154. slim_tx_cfg[SLIM_TX_7].sample_rate,
  3155. ucontrol->value.enumerated.item[0]);
  3156. return 0;
  3157. }
  3158. static int msm_bt_sample_rate_rx_get(struct snd_kcontrol *kcontrol,
  3159. struct snd_ctl_elem_value *ucontrol)
  3160. {
  3161. switch (slim_rx_cfg[SLIM_RX_7].sample_rate) {
  3162. case SAMPLING_RATE_96KHZ:
  3163. ucontrol->value.integer.value[0] = 5;
  3164. break;
  3165. case SAMPLING_RATE_88P2KHZ:
  3166. ucontrol->value.integer.value[0] = 4;
  3167. break;
  3168. case SAMPLING_RATE_48KHZ:
  3169. ucontrol->value.integer.value[0] = 3;
  3170. break;
  3171. case SAMPLING_RATE_44P1KHZ:
  3172. ucontrol->value.integer.value[0] = 2;
  3173. break;
  3174. case SAMPLING_RATE_16KHZ:
  3175. ucontrol->value.integer.value[0] = 1;
  3176. break;
  3177. case SAMPLING_RATE_8KHZ:
  3178. default:
  3179. ucontrol->value.integer.value[0] = 0;
  3180. break;
  3181. }
  3182. pr_debug("%s: sample rate rx = %d\n", __func__,
  3183. slim_rx_cfg[SLIM_RX_7].sample_rate);
  3184. return 0;
  3185. }
  3186. static int msm_bt_sample_rate_rx_put(struct snd_kcontrol *kcontrol,
  3187. struct snd_ctl_elem_value *ucontrol)
  3188. {
  3189. switch (ucontrol->value.integer.value[0]) {
  3190. case 1:
  3191. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3192. break;
  3193. case 2:
  3194. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3195. break;
  3196. case 3:
  3197. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3198. break;
  3199. case 4:
  3200. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3201. break;
  3202. case 5:
  3203. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3204. break;
  3205. case 0:
  3206. default:
  3207. slim_rx_cfg[SLIM_RX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3208. break;
  3209. }
  3210. pr_debug("%s: sample rate: slim7_rx = %d, value = %d\n",
  3211. __func__,
  3212. slim_rx_cfg[SLIM_RX_7].sample_rate,
  3213. ucontrol->value.enumerated.item[0]);
  3214. return 0;
  3215. }
  3216. static int msm_bt_sample_rate_tx_get(struct snd_kcontrol *kcontrol,
  3217. struct snd_ctl_elem_value *ucontrol)
  3218. {
  3219. switch (slim_tx_cfg[SLIM_TX_7].sample_rate) {
  3220. case SAMPLING_RATE_96KHZ:
  3221. ucontrol->value.integer.value[0] = 5;
  3222. break;
  3223. case SAMPLING_RATE_88P2KHZ:
  3224. ucontrol->value.integer.value[0] = 4;
  3225. break;
  3226. case SAMPLING_RATE_48KHZ:
  3227. ucontrol->value.integer.value[0] = 3;
  3228. break;
  3229. case SAMPLING_RATE_44P1KHZ:
  3230. ucontrol->value.integer.value[0] = 2;
  3231. break;
  3232. case SAMPLING_RATE_16KHZ:
  3233. ucontrol->value.integer.value[0] = 1;
  3234. break;
  3235. case SAMPLING_RATE_8KHZ:
  3236. default:
  3237. ucontrol->value.integer.value[0] = 0;
  3238. break;
  3239. }
  3240. pr_debug("%s: sample rate tx = %d\n", __func__,
  3241. slim_tx_cfg[SLIM_TX_7].sample_rate);
  3242. return 0;
  3243. }
  3244. static int msm_bt_sample_rate_tx_put(struct snd_kcontrol *kcontrol,
  3245. struct snd_ctl_elem_value *ucontrol)
  3246. {
  3247. switch (ucontrol->value.integer.value[0]) {
  3248. case 1:
  3249. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_16KHZ;
  3250. break;
  3251. case 2:
  3252. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_44P1KHZ;
  3253. break;
  3254. case 3:
  3255. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_48KHZ;
  3256. break;
  3257. case 4:
  3258. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_88P2KHZ;
  3259. break;
  3260. case 5:
  3261. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_96KHZ;
  3262. break;
  3263. case 0:
  3264. default:
  3265. slim_tx_cfg[SLIM_TX_7].sample_rate = SAMPLING_RATE_8KHZ;
  3266. break;
  3267. }
  3268. pr_debug("%s: sample rate: slim7_tx = %d, value = %d\n",
  3269. __func__,
  3270. slim_tx_cfg[SLIM_TX_7].sample_rate,
  3271. ucontrol->value.enumerated.item[0]);
  3272. return 0;
  3273. }
  3274. static const struct snd_kcontrol_new msm_int_snd_controls[] = {
  3275. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Channels", wsa_cdc_dma_rx_0_chs,
  3276. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3277. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Channels", wsa_cdc_dma_rx_1_chs,
  3278. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3279. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Channels", rx_cdc_dma_rx_0_chs,
  3280. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3281. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Channels", rx_cdc_dma_rx_1_chs,
  3282. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3283. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Channels", rx_cdc_dma_rx_2_chs,
  3284. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3285. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Channels", rx_cdc_dma_rx_3_chs,
  3286. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3287. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Channels", rx_cdc_dma_rx_5_chs,
  3288. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3289. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Channels", rx_cdc_dma_rx_6_chs,
  3290. cdc_dma_rx_ch_get, cdc_dma_rx_ch_put),
  3291. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 Channels", wsa_cdc_dma_tx_0_chs,
  3292. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3293. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Channels", wsa_cdc_dma_tx_1_chs,
  3294. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3295. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Channels", wsa_cdc_dma_tx_2_chs,
  3296. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3297. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Channels", tx_cdc_dma_tx_0_chs,
  3298. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3299. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Channels", tx_cdc_dma_tx_3_chs,
  3300. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3301. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Channels", tx_cdc_dma_tx_4_chs,
  3302. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3303. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Channels", va_cdc_dma_tx_0_chs,
  3304. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3305. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Channels", va_cdc_dma_tx_1_chs,
  3306. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3307. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Channels", va_cdc_dma_tx_2_chs,
  3308. cdc_dma_tx_ch_get, cdc_dma_tx_ch_put),
  3309. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 Format", wsa_cdc_dma_rx_0_format,
  3310. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3311. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 Format", wsa_cdc_dma_rx_1_format,
  3312. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3313. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 Format", wsa_cdc_dma_tx_1_format,
  3314. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3315. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 Format", wsa_cdc_dma_tx_2_format,
  3316. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3317. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 Format", tx_cdc_dma_tx_0_format,
  3318. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3319. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 Format", tx_cdc_dma_tx_3_format,
  3320. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3321. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 Format", tx_cdc_dma_tx_4_format,
  3322. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3323. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 Format", va_cdc_dma_tx_0_format,
  3324. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3325. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 Format", va_cdc_dma_tx_1_format,
  3326. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3327. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 Format", va_cdc_dma_tx_2_format,
  3328. cdc_dma_tx_format_get, cdc_dma_tx_format_put),
  3329. SOC_ENUM_EXT("WSA_CDC_DMA_RX_0 SampleRate",
  3330. wsa_cdc_dma_rx_0_sample_rate,
  3331. cdc_dma_rx_sample_rate_get,
  3332. cdc_dma_rx_sample_rate_put),
  3333. SOC_ENUM_EXT("WSA_CDC_DMA_RX_1 SampleRate",
  3334. wsa_cdc_dma_rx_1_sample_rate,
  3335. cdc_dma_rx_sample_rate_get,
  3336. cdc_dma_rx_sample_rate_put),
  3337. SOC_ENUM_EXT("WSA_CDC_DMA_TX_0 SampleRate",
  3338. wsa_cdc_dma_tx_0_sample_rate,
  3339. cdc_dma_tx_sample_rate_get,
  3340. cdc_dma_tx_sample_rate_put),
  3341. SOC_ENUM_EXT("WSA_CDC_DMA_TX_1 SampleRate",
  3342. wsa_cdc_dma_tx_1_sample_rate,
  3343. cdc_dma_tx_sample_rate_get,
  3344. cdc_dma_tx_sample_rate_put),
  3345. SOC_ENUM_EXT("WSA_CDC_DMA_TX_2 SampleRate",
  3346. wsa_cdc_dma_tx_2_sample_rate,
  3347. cdc_dma_tx_sample_rate_get,
  3348. cdc_dma_tx_sample_rate_put),
  3349. SOC_ENUM_EXT("TX_CDC_DMA_TX_0 SampleRate",
  3350. tx_cdc_dma_tx_0_sample_rate,
  3351. cdc_dma_tx_sample_rate_get,
  3352. cdc_dma_tx_sample_rate_put),
  3353. SOC_ENUM_EXT("TX_CDC_DMA_TX_3 SampleRate",
  3354. tx_cdc_dma_tx_3_sample_rate,
  3355. cdc_dma_tx_sample_rate_get,
  3356. cdc_dma_tx_sample_rate_put),
  3357. SOC_ENUM_EXT("TX_CDC_DMA_TX_4 SampleRate",
  3358. tx_cdc_dma_tx_4_sample_rate,
  3359. cdc_dma_tx_sample_rate_get,
  3360. cdc_dma_tx_sample_rate_put),
  3361. SOC_ENUM_EXT("VA_CDC_DMA_TX_0 SampleRate",
  3362. va_cdc_dma_tx_0_sample_rate,
  3363. cdc_dma_tx_sample_rate_get,
  3364. cdc_dma_tx_sample_rate_put),
  3365. SOC_ENUM_EXT("VA_CDC_DMA_TX_1 SampleRate",
  3366. va_cdc_dma_tx_1_sample_rate,
  3367. cdc_dma_tx_sample_rate_get,
  3368. cdc_dma_tx_sample_rate_put),
  3369. SOC_ENUM_EXT("VA_CDC_DMA_TX_2 SampleRate",
  3370. va_cdc_dma_tx_2_sample_rate,
  3371. cdc_dma_tx_sample_rate_get,
  3372. cdc_dma_tx_sample_rate_put),
  3373. };
  3374. static const struct snd_kcontrol_new msm_int_wcd9380_snd_controls[] = {
  3375. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc80_dma_rx_0_format,
  3376. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3377. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc80_dma_rx_1_format,
  3378. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3379. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc80_dma_rx_2_format,
  3380. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3381. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc80_dma_rx_3_format,
  3382. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3383. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc80_dma_rx_5_format,
  3384. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3385. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Format", rx_cdc80_dma_rx_6_format,
  3386. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3387. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3388. rx_cdc80_dma_rx_0_sample_rate,
  3389. cdc_dma_rx_sample_rate_get,
  3390. cdc_dma_rx_sample_rate_put),
  3391. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3392. rx_cdc80_dma_rx_1_sample_rate,
  3393. cdc_dma_rx_sample_rate_get,
  3394. cdc_dma_rx_sample_rate_put),
  3395. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3396. rx_cdc80_dma_rx_2_sample_rate,
  3397. cdc_dma_rx_sample_rate_get,
  3398. cdc_dma_rx_sample_rate_put),
  3399. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3400. rx_cdc80_dma_rx_3_sample_rate,
  3401. cdc_dma_rx_sample_rate_get,
  3402. cdc_dma_rx_sample_rate_put),
  3403. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3404. rx_cdc80_dma_rx_5_sample_rate,
  3405. cdc_dma_rx_sample_rate_get,
  3406. cdc_dma_rx_sample_rate_put),
  3407. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 SampleRate",
  3408. rx_cdc80_dma_rx_6_sample_rate,
  3409. cdc_dma_rx_sample_rate_get,
  3410. cdc_dma_rx_sample_rate_put),
  3411. };
  3412. static const struct snd_kcontrol_new msm_int_wcd9385_snd_controls[] = {
  3413. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 Format", rx_cdc85_dma_rx_0_format,
  3414. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3415. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 Format", rx_cdc85_dma_rx_1_format,
  3416. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3417. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 Format", rx_cdc85_dma_rx_2_format,
  3418. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3419. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 Format", rx_cdc85_dma_rx_3_format,
  3420. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3421. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 Format", rx_cdc85_dma_rx_5_format,
  3422. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3423. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 Format", rx_cdc85_dma_rx_6_format,
  3424. cdc_dma_rx_format_get, cdc_dma_rx_format_put),
  3425. SOC_ENUM_EXT("RX_CDC_DMA_RX_0 SampleRate",
  3426. rx_cdc85_dma_rx_0_sample_rate,
  3427. cdc_dma_rx_sample_rate_get,
  3428. cdc_dma_rx_sample_rate_put),
  3429. SOC_ENUM_EXT("RX_CDC_DMA_RX_1 SampleRate",
  3430. rx_cdc85_dma_rx_1_sample_rate,
  3431. cdc_dma_rx_sample_rate_get,
  3432. cdc_dma_rx_sample_rate_put),
  3433. SOC_ENUM_EXT("RX_CDC_DMA_RX_2 SampleRate",
  3434. rx_cdc85_dma_rx_2_sample_rate,
  3435. cdc_dma_rx_sample_rate_get,
  3436. cdc_dma_rx_sample_rate_put),
  3437. SOC_ENUM_EXT("RX_CDC_DMA_RX_3 SampleRate",
  3438. rx_cdc85_dma_rx_3_sample_rate,
  3439. cdc_dma_rx_sample_rate_get,
  3440. cdc_dma_rx_sample_rate_put),
  3441. SOC_ENUM_EXT("RX_CDC_DMA_RX_5 SampleRate",
  3442. rx_cdc85_dma_rx_5_sample_rate,
  3443. cdc_dma_rx_sample_rate_get,
  3444. cdc_dma_rx_sample_rate_put),
  3445. SOC_ENUM_EXT("RX_CDC_DMA_RX_6 SampleRate",
  3446. rx_cdc85_dma_rx_6_sample_rate,
  3447. cdc_dma_rx_sample_rate_get,
  3448. cdc_dma_rx_sample_rate_put),
  3449. };
  3450. static const struct snd_kcontrol_new msm_common_snd_controls[] = {
  3451. SOC_ENUM_EXT("USB_AUDIO_RX SampleRate", usb_rx_sample_rate,
  3452. usb_audio_rx_sample_rate_get,
  3453. usb_audio_rx_sample_rate_put),
  3454. SOC_ENUM_EXT("USB_AUDIO_TX SampleRate", usb_tx_sample_rate,
  3455. usb_audio_tx_sample_rate_get,
  3456. usb_audio_tx_sample_rate_put),
  3457. SOC_ENUM_EXT("PRI_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3458. tdm_rx_sample_rate_get,
  3459. tdm_rx_sample_rate_put),
  3460. SOC_ENUM_EXT("SEC_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3461. tdm_rx_sample_rate_get,
  3462. tdm_rx_sample_rate_put),
  3463. SOC_ENUM_EXT("TERT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3464. tdm_rx_sample_rate_get,
  3465. tdm_rx_sample_rate_put),
  3466. SOC_ENUM_EXT("QUAT_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3467. tdm_rx_sample_rate_get,
  3468. tdm_rx_sample_rate_put),
  3469. SOC_ENUM_EXT("QUIN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3470. tdm_rx_sample_rate_get,
  3471. tdm_rx_sample_rate_put),
  3472. SOC_ENUM_EXT("SEN_TDM_RX_0 SampleRate", tdm_rx_sample_rate,
  3473. tdm_rx_sample_rate_get,
  3474. tdm_rx_sample_rate_put),
  3475. SOC_ENUM_EXT("PRI_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3476. tdm_tx_sample_rate_get,
  3477. tdm_tx_sample_rate_put),
  3478. SOC_ENUM_EXT("SEC_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3479. tdm_tx_sample_rate_get,
  3480. tdm_tx_sample_rate_put),
  3481. SOC_ENUM_EXT("TERT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3482. tdm_tx_sample_rate_get,
  3483. tdm_tx_sample_rate_put),
  3484. SOC_ENUM_EXT("QUAT_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3485. tdm_tx_sample_rate_get,
  3486. tdm_tx_sample_rate_put),
  3487. SOC_ENUM_EXT("QUIN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3488. tdm_tx_sample_rate_get,
  3489. tdm_tx_sample_rate_put),
  3490. SOC_ENUM_EXT("SEN_TDM_TX_0 SampleRate", tdm_tx_sample_rate,
  3491. tdm_tx_sample_rate_get,
  3492. tdm_tx_sample_rate_put),
  3493. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3494. aux_pcm_rx_sample_rate_get,
  3495. aux_pcm_rx_sample_rate_put),
  3496. SOC_ENUM_EXT("SEC_AUX_PCM_RX SampleRate", sec_aux_pcm_rx_sample_rate,
  3497. aux_pcm_rx_sample_rate_get,
  3498. aux_pcm_rx_sample_rate_put),
  3499. SOC_ENUM_EXT("TERT_AUX_PCM_RX SampleRate", tert_aux_pcm_rx_sample_rate,
  3500. aux_pcm_rx_sample_rate_get,
  3501. aux_pcm_rx_sample_rate_put),
  3502. SOC_ENUM_EXT("QUAT_AUX_PCM_RX SampleRate", quat_aux_pcm_rx_sample_rate,
  3503. aux_pcm_rx_sample_rate_get,
  3504. aux_pcm_rx_sample_rate_put),
  3505. SOC_ENUM_EXT("QUIN_AUX_PCM_RX SampleRate", quin_aux_pcm_rx_sample_rate,
  3506. aux_pcm_rx_sample_rate_get,
  3507. aux_pcm_rx_sample_rate_put),
  3508. SOC_ENUM_EXT("SEN_AUX_PCM_RX SampleRate", sen_aux_pcm_rx_sample_rate,
  3509. aux_pcm_rx_sample_rate_get,
  3510. aux_pcm_rx_sample_rate_put),
  3511. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3512. aux_pcm_tx_sample_rate_get,
  3513. aux_pcm_tx_sample_rate_put),
  3514. SOC_ENUM_EXT("SEC_AUX_PCM_TX SampleRate", sec_aux_pcm_tx_sample_rate,
  3515. aux_pcm_tx_sample_rate_get,
  3516. aux_pcm_tx_sample_rate_put),
  3517. SOC_ENUM_EXT("TERT_AUX_PCM_TX SampleRate", tert_aux_pcm_tx_sample_rate,
  3518. aux_pcm_tx_sample_rate_get,
  3519. aux_pcm_tx_sample_rate_put),
  3520. SOC_ENUM_EXT("QUAT_AUX_PCM_TX SampleRate", quat_aux_pcm_tx_sample_rate,
  3521. aux_pcm_tx_sample_rate_get,
  3522. aux_pcm_tx_sample_rate_put),
  3523. SOC_ENUM_EXT("QUIN_AUX_PCM_TX SampleRate", quin_aux_pcm_tx_sample_rate,
  3524. aux_pcm_tx_sample_rate_get,
  3525. aux_pcm_tx_sample_rate_put),
  3526. SOC_ENUM_EXT("SEN_AUX_PCM_TX SampleRate", sen_aux_pcm_tx_sample_rate,
  3527. aux_pcm_tx_sample_rate_get,
  3528. aux_pcm_tx_sample_rate_put),
  3529. SOC_ENUM_EXT("PRIM_MI2S_RX SampleRate", prim_mi2s_rx_sample_rate,
  3530. mi2s_rx_sample_rate_get,
  3531. mi2s_rx_sample_rate_put),
  3532. SOC_ENUM_EXT("SEC_MI2S_RX SampleRate", sec_mi2s_rx_sample_rate,
  3533. mi2s_rx_sample_rate_get,
  3534. mi2s_rx_sample_rate_put),
  3535. SOC_ENUM_EXT("TERT_MI2S_RX SampleRate", tert_mi2s_rx_sample_rate,
  3536. mi2s_rx_sample_rate_get,
  3537. mi2s_rx_sample_rate_put),
  3538. SOC_ENUM_EXT("QUAT_MI2S_RX SampleRate", quat_mi2s_rx_sample_rate,
  3539. mi2s_rx_sample_rate_get,
  3540. mi2s_rx_sample_rate_put),
  3541. SOC_ENUM_EXT("QUIN_MI2S_RX SampleRate", quin_mi2s_rx_sample_rate,
  3542. mi2s_rx_sample_rate_get,
  3543. mi2s_rx_sample_rate_put),
  3544. SOC_ENUM_EXT("SEN_MI2S_RX SampleRate", sen_mi2s_rx_sample_rate,
  3545. mi2s_rx_sample_rate_get,
  3546. mi2s_rx_sample_rate_put),
  3547. SOC_ENUM_EXT("PRIM_MI2S_TX SampleRate", prim_mi2s_tx_sample_rate,
  3548. mi2s_tx_sample_rate_get,
  3549. mi2s_tx_sample_rate_put),
  3550. SOC_ENUM_EXT("SEC_MI2S_TX SampleRate", sec_mi2s_tx_sample_rate,
  3551. mi2s_tx_sample_rate_get,
  3552. mi2s_tx_sample_rate_put),
  3553. SOC_ENUM_EXT("TERT_MI2S_TX SampleRate", tert_mi2s_tx_sample_rate,
  3554. mi2s_tx_sample_rate_get,
  3555. mi2s_tx_sample_rate_put),
  3556. SOC_ENUM_EXT("QUAT_MI2S_TX SampleRate", quat_mi2s_tx_sample_rate,
  3557. mi2s_tx_sample_rate_get,
  3558. mi2s_tx_sample_rate_put),
  3559. SOC_ENUM_EXT("QUIN_MI2S_TX SampleRate", quin_mi2s_tx_sample_rate,
  3560. mi2s_tx_sample_rate_get,
  3561. mi2s_tx_sample_rate_put),
  3562. SOC_ENUM_EXT("SEN_MI2S_TX SampleRate", sen_mi2s_tx_sample_rate,
  3563. mi2s_tx_sample_rate_get,
  3564. mi2s_tx_sample_rate_put),
  3565. SOC_ENUM_EXT("USB_AUDIO_RX Format", usb_rx_format,
  3566. usb_audio_rx_format_get, usb_audio_rx_format_put),
  3567. SOC_ENUM_EXT("USB_AUDIO_TX Format", usb_tx_format,
  3568. usb_audio_tx_format_get, usb_audio_tx_format_put),
  3569. SOC_ENUM_EXT("PRI_TDM_RX_0 Format", tdm_rx_format,
  3570. tdm_rx_format_get,
  3571. tdm_rx_format_put),
  3572. SOC_ENUM_EXT("SEC_TDM_RX_0 Format", tdm_rx_format,
  3573. tdm_rx_format_get,
  3574. tdm_rx_format_put),
  3575. SOC_ENUM_EXT("TERT_TDM_RX_0 Format", tdm_rx_format,
  3576. tdm_rx_format_get,
  3577. tdm_rx_format_put),
  3578. SOC_ENUM_EXT("QUAT_TDM_RX_0 Format", tdm_rx_format,
  3579. tdm_rx_format_get,
  3580. tdm_rx_format_put),
  3581. SOC_ENUM_EXT("QUIN_TDM_RX_0 Format", tdm_rx_format,
  3582. tdm_rx_format_get,
  3583. tdm_rx_format_put),
  3584. SOC_ENUM_EXT("SEN_TDM_RX_0 Format", tdm_rx_format,
  3585. tdm_rx_format_get,
  3586. tdm_rx_format_put),
  3587. SOC_ENUM_EXT("PRI_TDM_TX_0 Format", tdm_tx_format,
  3588. tdm_tx_format_get,
  3589. tdm_tx_format_put),
  3590. SOC_ENUM_EXT("SEC_TDM_TX_0 Format", tdm_tx_format,
  3591. tdm_tx_format_get,
  3592. tdm_tx_format_put),
  3593. SOC_ENUM_EXT("TERT_TDM_TX_0 Format", tdm_tx_format,
  3594. tdm_tx_format_get,
  3595. tdm_tx_format_put),
  3596. SOC_ENUM_EXT("QUAT_TDM_TX_0 Format", tdm_tx_format,
  3597. tdm_tx_format_get,
  3598. tdm_tx_format_put),
  3599. SOC_ENUM_EXT("QUIN_TDM_TX_0 Format", tdm_tx_format,
  3600. tdm_tx_format_get,
  3601. tdm_tx_format_put),
  3602. SOC_ENUM_EXT("SEN_TDM_TX_0 Format", tdm_tx_format,
  3603. tdm_tx_format_get,
  3604. tdm_tx_format_put),
  3605. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3606. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3607. SOC_ENUM_EXT("SEC_AUX_PCM_RX Format", aux_pcm_rx_format,
  3608. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3609. SOC_ENUM_EXT("TERT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3610. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3611. SOC_ENUM_EXT("QUAT_AUX_PCM_RX Format", aux_pcm_rx_format,
  3612. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3613. SOC_ENUM_EXT("QUIN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3614. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3615. SOC_ENUM_EXT("SEN_AUX_PCM_RX Format", aux_pcm_rx_format,
  3616. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3617. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3618. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3619. SOC_ENUM_EXT("SEC_AUX_PCM_TX Format", aux_pcm_tx_format,
  3620. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3621. SOC_ENUM_EXT("TERT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3622. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3623. SOC_ENUM_EXT("QUAT_AUX_PCM_TX Format", aux_pcm_tx_format,
  3624. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3625. SOC_ENUM_EXT("QUIN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3626. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3627. SOC_ENUM_EXT("SEN_AUX_PCM_TX Format", aux_pcm_tx_format,
  3628. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3629. SOC_ENUM_EXT("PRIM_MI2S_RX Format", mi2s_rx_format,
  3630. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3631. SOC_ENUM_EXT("SEC_MI2S_RX Format", mi2s_rx_format,
  3632. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3633. SOC_ENUM_EXT("TERT_MI2S_RX Format", mi2s_rx_format,
  3634. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3635. SOC_ENUM_EXT("QUAT_MI2S_RX Format", mi2s_rx_format,
  3636. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3637. SOC_ENUM_EXT("QUIN_MI2S_RX Format", mi2s_rx_format,
  3638. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3639. SOC_ENUM_EXT("SEN_MI2S_RX Format", mi2s_rx_format,
  3640. msm_mi2s_rx_format_get, msm_mi2s_rx_format_put),
  3641. SOC_ENUM_EXT("PRIM_MI2S_TX Format", mi2s_tx_format,
  3642. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3643. SOC_ENUM_EXT("SEC_MI2S_TX Format", mi2s_tx_format,
  3644. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3645. SOC_ENUM_EXT("TERT_MI2S_TX Format", mi2s_tx_format,
  3646. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3647. SOC_ENUM_EXT("QUAT_MI2S_TX Format", mi2s_tx_format,
  3648. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3649. SOC_ENUM_EXT("QUIN_MI2S_TX Format", mi2s_tx_format,
  3650. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3651. SOC_ENUM_EXT("SEN_MI2S_TX Format", mi2s_tx_format,
  3652. msm_mi2s_tx_format_get, msm_mi2s_tx_format_put),
  3653. SOC_ENUM_EXT("USB_AUDIO_RX Channels", usb_rx_chs,
  3654. usb_audio_rx_ch_get, usb_audio_rx_ch_put),
  3655. SOC_ENUM_EXT("USB_AUDIO_TX Channels", usb_tx_chs,
  3656. usb_audio_tx_ch_get, usb_audio_tx_ch_put),
  3657. SOC_ENUM_EXT("PROXY_RX Channels", proxy_rx_chs,
  3658. proxy_rx_ch_get, proxy_rx_ch_put),
  3659. SOC_ENUM_EXT("PRI_TDM_RX_0 Channels", tdm_rx_chs,
  3660. tdm_rx_ch_get,
  3661. tdm_rx_ch_put),
  3662. SOC_ENUM_EXT("SEC_TDM_RX_0 Channels", tdm_rx_chs,
  3663. tdm_rx_ch_get,
  3664. tdm_rx_ch_put),
  3665. SOC_ENUM_EXT("TERT_TDM_RX_0 Channels", tdm_rx_chs,
  3666. tdm_rx_ch_get,
  3667. tdm_rx_ch_put),
  3668. SOC_ENUM_EXT("QUAT_TDM_RX_0 Channels", tdm_rx_chs,
  3669. tdm_rx_ch_get,
  3670. tdm_rx_ch_put),
  3671. SOC_ENUM_EXT("QUIN_TDM_RX_0 Channels", tdm_rx_chs,
  3672. tdm_rx_ch_get,
  3673. tdm_rx_ch_put),
  3674. SOC_ENUM_EXT("SEN_TDM_RX_0 Channels", tdm_rx_chs,
  3675. tdm_rx_ch_get,
  3676. tdm_rx_ch_put),
  3677. SOC_ENUM_EXT("PRI_TDM_TX_0 Channels", tdm_tx_chs,
  3678. tdm_tx_ch_get,
  3679. tdm_tx_ch_put),
  3680. SOC_ENUM_EXT("SEC_TDM_TX_0 Channels", tdm_tx_chs,
  3681. tdm_tx_ch_get,
  3682. tdm_tx_ch_put),
  3683. SOC_ENUM_EXT("TERT_TDM_TX_0 Channels", tdm_tx_chs,
  3684. tdm_tx_ch_get,
  3685. tdm_tx_ch_put),
  3686. SOC_ENUM_EXT("QUAT_TDM_TX_0 Channels", tdm_tx_chs,
  3687. tdm_tx_ch_get,
  3688. tdm_tx_ch_put),
  3689. SOC_ENUM_EXT("QUIN_TDM_TX_0 Channels", tdm_tx_chs,
  3690. tdm_tx_ch_get,
  3691. tdm_tx_ch_put),
  3692. SOC_ENUM_EXT("SEN_TDM_TX_0 Channels", tdm_tx_chs,
  3693. tdm_tx_ch_get,
  3694. tdm_tx_ch_put),
  3695. SOC_ENUM_EXT("PRIM_MI2S_RX Channels", prim_mi2s_rx_chs,
  3696. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3697. SOC_ENUM_EXT("SEC_MI2S_RX Channels", sec_mi2s_rx_chs,
  3698. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3699. SOC_ENUM_EXT("TERT_MI2S_RX Channels", tert_mi2s_rx_chs,
  3700. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3701. SOC_ENUM_EXT("QUAT_MI2S_RX Channels", quat_mi2s_rx_chs,
  3702. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3703. SOC_ENUM_EXT("QUIN_MI2S_RX Channels", quin_mi2s_rx_chs,
  3704. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3705. SOC_ENUM_EXT("SEN_MI2S_RX Channels", sen_mi2s_rx_chs,
  3706. msm_mi2s_rx_ch_get, msm_mi2s_rx_ch_put),
  3707. SOC_ENUM_EXT("PRIM_MI2S_TX Channels", prim_mi2s_tx_chs,
  3708. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3709. SOC_ENUM_EXT("SEC_MI2S_TX Channels", sec_mi2s_tx_chs,
  3710. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3711. SOC_ENUM_EXT("TERT_MI2S_TX Channels", tert_mi2s_tx_chs,
  3712. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3713. SOC_ENUM_EXT("QUAT_MI2S_TX Channels", quat_mi2s_tx_chs,
  3714. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3715. SOC_ENUM_EXT("QUIN_MI2S_TX Channels", quin_mi2s_tx_chs,
  3716. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3717. SOC_ENUM_EXT("SEN_MI2S_TX Channels", sen_mi2s_tx_chs,
  3718. msm_mi2s_tx_ch_get, msm_mi2s_tx_ch_put),
  3719. SOC_ENUM_EXT("Display Port RX Channels", ext_disp_rx_chs,
  3720. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3721. SOC_ENUM_EXT("Display Port RX Bit Format", ext_disp_rx_format,
  3722. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3723. SOC_ENUM_EXT("Display Port RX SampleRate", ext_disp_rx_sample_rate,
  3724. ext_disp_rx_sample_rate_get,
  3725. ext_disp_rx_sample_rate_put),
  3726. SOC_ENUM_EXT("Display Port1 RX Channels", ext_disp_rx_chs,
  3727. ext_disp_rx_ch_get, ext_disp_rx_ch_put),
  3728. SOC_ENUM_EXT("Display Port1 RX Bit Format", ext_disp_rx_format,
  3729. ext_disp_rx_format_get, ext_disp_rx_format_put),
  3730. SOC_ENUM_EXT("Display Port1 RX SampleRate", ext_disp_rx_sample_rate,
  3731. ext_disp_rx_sample_rate_get,
  3732. ext_disp_rx_sample_rate_put),
  3733. SOC_ENUM_EXT("BT SampleRate", bt_sample_rate,
  3734. msm_bt_sample_rate_get,
  3735. msm_bt_sample_rate_put),
  3736. SOC_ENUM_EXT("BT SampleRate RX", bt_sample_rate_rx,
  3737. msm_bt_sample_rate_rx_get,
  3738. msm_bt_sample_rate_rx_put),
  3739. SOC_ENUM_EXT("BT SampleRate TX", bt_sample_rate_tx,
  3740. msm_bt_sample_rate_tx_get,
  3741. msm_bt_sample_rate_tx_put),
  3742. SOC_ENUM_EXT("AFE_LOOPBACK_TX Channels", afe_loopback_tx_chs,
  3743. afe_loopback_tx_ch_get, afe_loopback_tx_ch_put),
  3744. SOC_ENUM_EXT("VI_FEED_TX Channels", vi_feed_tx_chs,
  3745. msm_vi_feed_tx_ch_get, msm_vi_feed_tx_ch_put),
  3746. SOC_SINGLE_MULTI_EXT("TDM Slot Map", SND_SOC_NOPM, 0, 255, 0,
  3747. TDM_MAX_SLOTS + MAX_PATH, NULL, tdm_slot_map_put),
  3748. };
  3749. static const struct snd_kcontrol_new msm_snd_controls[] = {
  3750. SOC_ENUM_EXT("PRIM_AUX_PCM_RX Format", aux_pcm_rx_format,
  3751. msm_aux_pcm_rx_format_get, msm_aux_pcm_rx_format_put),
  3752. SOC_ENUM_EXT("PRIM_AUX_PCM_TX Format", aux_pcm_tx_format,
  3753. msm_aux_pcm_tx_format_get, msm_aux_pcm_tx_format_put),
  3754. SOC_ENUM_EXT("PRIM_AUX_PCM_RX SampleRate", prim_aux_pcm_rx_sample_rate,
  3755. aux_pcm_rx_sample_rate_get,
  3756. aux_pcm_rx_sample_rate_put),
  3757. SOC_ENUM_EXT("PRIM_AUX_PCM_TX SampleRate", prim_aux_pcm_tx_sample_rate,
  3758. aux_pcm_tx_sample_rate_get,
  3759. aux_pcm_tx_sample_rate_put),
  3760. };
  3761. static int msm_ext_disp_get_idx_from_beid(int32_t be_id)
  3762. {
  3763. int idx;
  3764. switch (be_id) {
  3765. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3766. idx = EXT_DISP_RX_IDX_DP;
  3767. break;
  3768. case MSM_BACKEND_DAI_DISPLAY_PORT_RX_1:
  3769. idx = EXT_DISP_RX_IDX_DP1;
  3770. break;
  3771. default:
  3772. pr_err("%s: Incorrect ext_disp BE id %d\n", __func__, be_id);
  3773. idx = -EINVAL;
  3774. break;
  3775. }
  3776. return idx;
  3777. }
  3778. static int lahaina_send_island_va_config(int32_t be_id)
  3779. {
  3780. int rc = 0;
  3781. int port_id = 0xFFFF;
  3782. port_id = msm_get_port_id(be_id);
  3783. if (port_id < 0) {
  3784. pr_err("%s: Invalid island interface, be_id: %d\n",
  3785. __func__, be_id);
  3786. rc = -EINVAL;
  3787. } else {
  3788. /*
  3789. * send island mode config
  3790. * This should be the first configuration
  3791. */
  3792. rc = afe_send_port_island_mode(port_id);
  3793. if (rc)
  3794. pr_err("%s: afe send island mode failed %d\n",
  3795. __func__, rc);
  3796. }
  3797. return rc;
  3798. }
  3799. static int lahaina_send_power_mode(int32_t be_id)
  3800. {
  3801. int rc = 0;
  3802. int port_id = 0xFFFF;
  3803. port_id = msm_get_port_id(be_id);
  3804. if (port_id < 0) {
  3805. pr_err("%s: Invalid power interface, be_id: %d\n",
  3806. __func__, be_id);
  3807. rc = -EINVAL;
  3808. } else {
  3809. /*
  3810. * send island mode config
  3811. * This should be the first configuration
  3812. *
  3813. */
  3814. rc = afe_send_port_island_mode(port_id);
  3815. if (rc)
  3816. pr_err("%s: afe send island mode failed %d\n",
  3817. __func__, rc);
  3818. /*
  3819. * send power mode config
  3820. * This should be set after island configuration
  3821. */
  3822. rc = afe_send_port_power_mode(port_id);
  3823. if (rc)
  3824. pr_err("%s: afe send power mode failed %d\n",
  3825. __func__, rc);
  3826. }
  3827. return rc;
  3828. }
  3829. static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
  3830. struct snd_pcm_hw_params *params)
  3831. {
  3832. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  3833. struct snd_interval *rate = hw_param_interval(params,
  3834. SNDRV_PCM_HW_PARAM_RATE);
  3835. struct snd_interval *channels = hw_param_interval(params,
  3836. SNDRV_PCM_HW_PARAM_CHANNELS);
  3837. int idx = 0, rc = 0;
  3838. pr_debug("%s: dai_id= %d, format = %d, rate = %d\n",
  3839. __func__, dai_link->id, params_format(params),
  3840. params_rate(params));
  3841. switch (dai_link->id) {
  3842. case MSM_BACKEND_DAI_USB_RX:
  3843. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3844. usb_rx_cfg.bit_format);
  3845. rate->min = rate->max = usb_rx_cfg.sample_rate;
  3846. channels->min = channels->max = usb_rx_cfg.channels;
  3847. break;
  3848. case MSM_BACKEND_DAI_USB_TX:
  3849. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3850. usb_tx_cfg.bit_format);
  3851. rate->min = rate->max = usb_tx_cfg.sample_rate;
  3852. channels->min = channels->max = usb_tx_cfg.channels;
  3853. break;
  3854. case MSM_BACKEND_DAI_DISPLAY_PORT_RX:
  3855. case MSM_BACKEND_DAI_DISPLAY_PORT_RX_1:
  3856. idx = msm_ext_disp_get_idx_from_beid(dai_link->id);
  3857. if (idx < 0) {
  3858. pr_err("%s: Incorrect ext disp idx %d\n",
  3859. __func__, idx);
  3860. rc = idx;
  3861. goto done;
  3862. }
  3863. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3864. ext_disp_rx_cfg[idx].bit_format);
  3865. rate->min = rate->max = ext_disp_rx_cfg[idx].sample_rate;
  3866. channels->min = channels->max = ext_disp_rx_cfg[idx].channels;
  3867. break;
  3868. case MSM_BACKEND_DAI_AFE_PCM_RX:
  3869. channels->min = channels->max = proxy_rx_cfg.channels;
  3870. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  3871. break;
  3872. case MSM_BACKEND_DAI_PRI_TDM_RX_0:
  3873. channels->min = channels->max =
  3874. tdm_rx_cfg[TDM_PRI][TDM_0].channels;
  3875. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3876. tdm_rx_cfg[TDM_PRI][TDM_0].bit_format);
  3877. rate->min = rate->max = tdm_rx_cfg[TDM_PRI][TDM_0].sample_rate;
  3878. break;
  3879. case MSM_BACKEND_DAI_PRI_TDM_TX_0:
  3880. channels->min = channels->max =
  3881. tdm_tx_cfg[TDM_PRI][TDM_0].channels;
  3882. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3883. tdm_tx_cfg[TDM_PRI][TDM_0].bit_format);
  3884. rate->min = rate->max = tdm_tx_cfg[TDM_PRI][TDM_0].sample_rate;
  3885. break;
  3886. case MSM_BACKEND_DAI_SEC_TDM_RX_0:
  3887. channels->min = channels->max =
  3888. tdm_rx_cfg[TDM_SEC][TDM_0].channels;
  3889. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3890. tdm_rx_cfg[TDM_SEC][TDM_0].bit_format);
  3891. rate->min = rate->max = tdm_rx_cfg[TDM_SEC][TDM_0].sample_rate;
  3892. break;
  3893. case MSM_BACKEND_DAI_SEC_TDM_TX_0:
  3894. channels->min = channels->max =
  3895. tdm_tx_cfg[TDM_SEC][TDM_0].channels;
  3896. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3897. tdm_tx_cfg[TDM_SEC][TDM_0].bit_format);
  3898. rate->min = rate->max = tdm_tx_cfg[TDM_SEC][TDM_0].sample_rate;
  3899. break;
  3900. case MSM_BACKEND_DAI_TERT_TDM_RX_0:
  3901. channels->min = channels->max =
  3902. tdm_rx_cfg[TDM_TERT][TDM_0].channels;
  3903. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3904. tdm_rx_cfg[TDM_TERT][TDM_0].bit_format);
  3905. rate->min = rate->max = tdm_rx_cfg[TDM_TERT][TDM_0].sample_rate;
  3906. break;
  3907. case MSM_BACKEND_DAI_TERT_TDM_TX_0:
  3908. channels->min = channels->max =
  3909. tdm_tx_cfg[TDM_TERT][TDM_0].channels;
  3910. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3911. tdm_tx_cfg[TDM_TERT][TDM_0].bit_format);
  3912. rate->min = rate->max = tdm_tx_cfg[TDM_TERT][TDM_0].sample_rate;
  3913. break;
  3914. case MSM_BACKEND_DAI_QUAT_TDM_RX_0:
  3915. channels->min = channels->max =
  3916. tdm_rx_cfg[TDM_QUAT][TDM_0].channels;
  3917. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3918. tdm_rx_cfg[TDM_QUAT][TDM_0].bit_format);
  3919. rate->min = rate->max = tdm_rx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3920. break;
  3921. case MSM_BACKEND_DAI_QUAT_TDM_TX_0:
  3922. channels->min = channels->max =
  3923. tdm_tx_cfg[TDM_QUAT][TDM_0].channels;
  3924. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3925. tdm_tx_cfg[TDM_QUAT][TDM_0].bit_format);
  3926. rate->min = rate->max = tdm_tx_cfg[TDM_QUAT][TDM_0].sample_rate;
  3927. break;
  3928. case MSM_BACKEND_DAI_QUIN_TDM_RX_0:
  3929. channels->min = channels->max =
  3930. tdm_rx_cfg[TDM_QUIN][TDM_0].channels;
  3931. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3932. tdm_rx_cfg[TDM_QUIN][TDM_0].bit_format);
  3933. rate->min = rate->max = tdm_rx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3934. break;
  3935. case MSM_BACKEND_DAI_QUIN_TDM_TX_0:
  3936. channels->min = channels->max =
  3937. tdm_tx_cfg[TDM_QUIN][TDM_0].channels;
  3938. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3939. tdm_tx_cfg[TDM_QUIN][TDM_0].bit_format);
  3940. rate->min = rate->max = tdm_tx_cfg[TDM_QUIN][TDM_0].sample_rate;
  3941. break;
  3942. case MSM_BACKEND_DAI_SEN_TDM_RX_0:
  3943. channels->min = channels->max =
  3944. tdm_rx_cfg[TDM_SEN][TDM_0].channels;
  3945. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3946. tdm_rx_cfg[TDM_SEN][TDM_0].bit_format);
  3947. rate->min = rate->max = tdm_rx_cfg[TDM_SEN][TDM_0].sample_rate;
  3948. break;
  3949. case MSM_BACKEND_DAI_SEN_TDM_TX_0:
  3950. channels->min = channels->max =
  3951. tdm_tx_cfg[TDM_SEN][TDM_0].channels;
  3952. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3953. tdm_tx_cfg[TDM_SEN][TDM_0].bit_format);
  3954. rate->min = rate->max = tdm_tx_cfg[TDM_SEN][TDM_0].sample_rate;
  3955. break;
  3956. case MSM_BACKEND_DAI_AUXPCM_RX:
  3957. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3958. aux_pcm_rx_cfg[PRIM_AUX_PCM].bit_format);
  3959. rate->min = rate->max =
  3960. aux_pcm_rx_cfg[PRIM_AUX_PCM].sample_rate;
  3961. channels->min = channels->max =
  3962. aux_pcm_rx_cfg[PRIM_AUX_PCM].channels;
  3963. break;
  3964. case MSM_BACKEND_DAI_AUXPCM_TX:
  3965. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3966. aux_pcm_tx_cfg[PRIM_AUX_PCM].bit_format);
  3967. rate->min = rate->max =
  3968. aux_pcm_tx_cfg[PRIM_AUX_PCM].sample_rate;
  3969. channels->min = channels->max =
  3970. aux_pcm_tx_cfg[PRIM_AUX_PCM].channels;
  3971. break;
  3972. case MSM_BACKEND_DAI_SEC_AUXPCM_RX:
  3973. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3974. aux_pcm_rx_cfg[SEC_AUX_PCM].bit_format);
  3975. rate->min = rate->max =
  3976. aux_pcm_rx_cfg[SEC_AUX_PCM].sample_rate;
  3977. channels->min = channels->max =
  3978. aux_pcm_rx_cfg[SEC_AUX_PCM].channels;
  3979. break;
  3980. case MSM_BACKEND_DAI_SEC_AUXPCM_TX:
  3981. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3982. aux_pcm_tx_cfg[SEC_AUX_PCM].bit_format);
  3983. rate->min = rate->max =
  3984. aux_pcm_tx_cfg[SEC_AUX_PCM].sample_rate;
  3985. channels->min = channels->max =
  3986. aux_pcm_tx_cfg[SEC_AUX_PCM].channels;
  3987. break;
  3988. case MSM_BACKEND_DAI_TERT_AUXPCM_RX:
  3989. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3990. aux_pcm_rx_cfg[TERT_AUX_PCM].bit_format);
  3991. rate->min = rate->max =
  3992. aux_pcm_rx_cfg[TERT_AUX_PCM].sample_rate;
  3993. channels->min = channels->max =
  3994. aux_pcm_rx_cfg[TERT_AUX_PCM].channels;
  3995. break;
  3996. case MSM_BACKEND_DAI_TERT_AUXPCM_TX:
  3997. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  3998. aux_pcm_tx_cfg[TERT_AUX_PCM].bit_format);
  3999. rate->min = rate->max =
  4000. aux_pcm_tx_cfg[TERT_AUX_PCM].sample_rate;
  4001. channels->min = channels->max =
  4002. aux_pcm_tx_cfg[TERT_AUX_PCM].channels;
  4003. break;
  4004. case MSM_BACKEND_DAI_QUAT_AUXPCM_RX:
  4005. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4006. aux_pcm_rx_cfg[QUAT_AUX_PCM].bit_format);
  4007. rate->min = rate->max =
  4008. aux_pcm_rx_cfg[QUAT_AUX_PCM].sample_rate;
  4009. channels->min = channels->max =
  4010. aux_pcm_rx_cfg[QUAT_AUX_PCM].channels;
  4011. break;
  4012. case MSM_BACKEND_DAI_QUAT_AUXPCM_TX:
  4013. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4014. aux_pcm_tx_cfg[QUAT_AUX_PCM].bit_format);
  4015. rate->min = rate->max =
  4016. aux_pcm_tx_cfg[QUAT_AUX_PCM].sample_rate;
  4017. channels->min = channels->max =
  4018. aux_pcm_tx_cfg[QUAT_AUX_PCM].channels;
  4019. break;
  4020. case MSM_BACKEND_DAI_QUIN_AUXPCM_RX:
  4021. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4022. aux_pcm_rx_cfg[QUIN_AUX_PCM].bit_format);
  4023. rate->min = rate->max =
  4024. aux_pcm_rx_cfg[QUIN_AUX_PCM].sample_rate;
  4025. channels->min = channels->max =
  4026. aux_pcm_rx_cfg[QUIN_AUX_PCM].channels;
  4027. break;
  4028. case MSM_BACKEND_DAI_QUIN_AUXPCM_TX:
  4029. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4030. aux_pcm_tx_cfg[QUIN_AUX_PCM].bit_format);
  4031. rate->min = rate->max =
  4032. aux_pcm_tx_cfg[QUIN_AUX_PCM].sample_rate;
  4033. channels->min = channels->max =
  4034. aux_pcm_tx_cfg[QUIN_AUX_PCM].channels;
  4035. break;
  4036. case MSM_BACKEND_DAI_SEN_AUXPCM_RX:
  4037. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4038. aux_pcm_rx_cfg[SEN_AUX_PCM].bit_format);
  4039. rate->min = rate->max =
  4040. aux_pcm_rx_cfg[SEN_AUX_PCM].sample_rate;
  4041. channels->min = channels->max =
  4042. aux_pcm_rx_cfg[SEN_AUX_PCM].channels;
  4043. break;
  4044. case MSM_BACKEND_DAI_SEN_AUXPCM_TX:
  4045. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4046. aux_pcm_tx_cfg[SEN_AUX_PCM].bit_format);
  4047. rate->min = rate->max =
  4048. aux_pcm_tx_cfg[SEN_AUX_PCM].sample_rate;
  4049. channels->min = channels->max =
  4050. aux_pcm_tx_cfg[SEN_AUX_PCM].channels;
  4051. break;
  4052. case MSM_BACKEND_DAI_PRI_MI2S_RX:
  4053. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4054. mi2s_rx_cfg[PRIM_MI2S].bit_format);
  4055. rate->min = rate->max = mi2s_rx_cfg[PRIM_MI2S].sample_rate;
  4056. channels->min = channels->max =
  4057. mi2s_rx_cfg[PRIM_MI2S].channels;
  4058. break;
  4059. case MSM_BACKEND_DAI_PRI_MI2S_TX:
  4060. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4061. mi2s_tx_cfg[PRIM_MI2S].bit_format);
  4062. rate->min = rate->max = mi2s_tx_cfg[PRIM_MI2S].sample_rate;
  4063. channels->min = channels->max =
  4064. mi2s_tx_cfg[PRIM_MI2S].channels;
  4065. break;
  4066. case MSM_BACKEND_DAI_SECONDARY_MI2S_RX:
  4067. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4068. mi2s_rx_cfg[SEC_MI2S].bit_format);
  4069. rate->min = rate->max = mi2s_rx_cfg[SEC_MI2S].sample_rate;
  4070. channels->min = channels->max =
  4071. mi2s_rx_cfg[SEC_MI2S].channels;
  4072. break;
  4073. case MSM_BACKEND_DAI_SECONDARY_MI2S_TX:
  4074. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4075. mi2s_tx_cfg[SEC_MI2S].bit_format);
  4076. rate->min = rate->max = mi2s_tx_cfg[SEC_MI2S].sample_rate;
  4077. channels->min = channels->max =
  4078. mi2s_tx_cfg[SEC_MI2S].channels;
  4079. break;
  4080. case MSM_BACKEND_DAI_TERTIARY_MI2S_RX:
  4081. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4082. mi2s_rx_cfg[TERT_MI2S].bit_format);
  4083. rate->min = rate->max = mi2s_rx_cfg[TERT_MI2S].sample_rate;
  4084. channels->min = channels->max =
  4085. mi2s_rx_cfg[TERT_MI2S].channels;
  4086. break;
  4087. case MSM_BACKEND_DAI_TERTIARY_MI2S_TX:
  4088. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4089. mi2s_tx_cfg[TERT_MI2S].bit_format);
  4090. rate->min = rate->max = mi2s_tx_cfg[TERT_MI2S].sample_rate;
  4091. channels->min = channels->max =
  4092. mi2s_tx_cfg[TERT_MI2S].channels;
  4093. break;
  4094. case MSM_BACKEND_DAI_QUATERNARY_MI2S_RX:
  4095. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4096. mi2s_rx_cfg[QUAT_MI2S].bit_format);
  4097. rate->min = rate->max = mi2s_rx_cfg[QUAT_MI2S].sample_rate;
  4098. channels->min = channels->max =
  4099. mi2s_rx_cfg[QUAT_MI2S].channels;
  4100. break;
  4101. case MSM_BACKEND_DAI_QUATERNARY_MI2S_TX:
  4102. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4103. mi2s_tx_cfg[QUAT_MI2S].bit_format);
  4104. rate->min = rate->max = mi2s_tx_cfg[QUAT_MI2S].sample_rate;
  4105. channels->min = channels->max =
  4106. mi2s_tx_cfg[QUAT_MI2S].channels;
  4107. break;
  4108. case MSM_BACKEND_DAI_QUINARY_MI2S_RX:
  4109. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4110. mi2s_rx_cfg[QUIN_MI2S].bit_format);
  4111. rate->min = rate->max = mi2s_rx_cfg[QUIN_MI2S].sample_rate;
  4112. channels->min = channels->max =
  4113. mi2s_rx_cfg[QUIN_MI2S].channels;
  4114. break;
  4115. case MSM_BACKEND_DAI_QUINARY_MI2S_TX:
  4116. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4117. mi2s_tx_cfg[QUIN_MI2S].bit_format);
  4118. rate->min = rate->max = mi2s_tx_cfg[QUIN_MI2S].sample_rate;
  4119. channels->min = channels->max =
  4120. mi2s_tx_cfg[QUIN_MI2S].channels;
  4121. break;
  4122. case MSM_BACKEND_DAI_SENARY_MI2S_RX:
  4123. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4124. mi2s_rx_cfg[SEN_MI2S].bit_format);
  4125. rate->min = rate->max = mi2s_rx_cfg[SEN_MI2S].sample_rate;
  4126. channels->min = channels->max =
  4127. mi2s_rx_cfg[SEN_MI2S].channels;
  4128. break;
  4129. case MSM_BACKEND_DAI_SENARY_MI2S_TX:
  4130. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4131. mi2s_tx_cfg[SEN_MI2S].bit_format);
  4132. rate->min = rate->max = mi2s_tx_cfg[SEN_MI2S].sample_rate;
  4133. channels->min = channels->max =
  4134. mi2s_tx_cfg[SEN_MI2S].channels;
  4135. break;
  4136. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4137. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4138. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4139. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4140. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4141. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4142. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4143. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  4144. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4145. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4146. cdc_dma_rx_cfg[idx].bit_format);
  4147. rate->min = rate->max = cdc_dma_rx_cfg[idx].sample_rate;
  4148. channels->min = channels->max = cdc_dma_rx_cfg[idx].channels;
  4149. break;
  4150. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4151. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4152. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4153. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4154. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4155. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4156. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4157. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4158. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4159. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4160. cdc_dma_tx_cfg[idx].bit_format);
  4161. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4162. channels->min = channels->max = cdc_dma_tx_cfg[idx].channels;
  4163. break;
  4164. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4165. idx = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4166. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4167. SNDRV_PCM_FORMAT_S32_LE);
  4168. rate->min = rate->max = cdc_dma_tx_cfg[idx].sample_rate;
  4169. channels->min = channels->max = msm_vi_feed_tx_ch;
  4170. break;
  4171. case MSM_BACKEND_DAI_SLIMBUS_7_RX:
  4172. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4173. slim_rx_cfg[SLIM_RX_7].bit_format);
  4174. rate->min = rate->max = slim_rx_cfg[SLIM_RX_7].sample_rate;
  4175. channels->min = channels->max =
  4176. slim_rx_cfg[SLIM_RX_7].channels;
  4177. break;
  4178. case MSM_BACKEND_DAI_SLIMBUS_7_TX:
  4179. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4180. slim_tx_cfg[SLIM_TX_7].bit_format);
  4181. rate->min = rate->max = slim_tx_cfg[SLIM_TX_7].sample_rate;
  4182. channels->min = channels->max =
  4183. slim_tx_cfg[SLIM_TX_7].channels;
  4184. break;
  4185. case MSM_BACKEND_DAI_SLIMBUS_8_TX:
  4186. rate->min = rate->max = slim_tx_cfg[SLIM_TX_8].sample_rate;
  4187. channels->min = channels->max =
  4188. slim_tx_cfg[SLIM_TX_8].channels;
  4189. break;
  4190. case MSM_BACKEND_DAI_AFE_LOOPBACK_TX:
  4191. param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
  4192. afe_loopback_tx_cfg[idx].bit_format);
  4193. rate->min = rate->max = afe_loopback_tx_cfg[idx].sample_rate;
  4194. channels->min = channels->max =
  4195. afe_loopback_tx_cfg[idx].channels;
  4196. break;
  4197. default:
  4198. rate->min = rate->max = SAMPLING_RATE_48KHZ;
  4199. break;
  4200. }
  4201. done:
  4202. return rc;
  4203. }
  4204. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4205. {
  4206. struct snd_soc_card *card = component->card;
  4207. struct msm_asoc_mach_data *pdata =
  4208. snd_soc_card_get_drvdata(card);
  4209. if (!pdata->fsa_handle)
  4210. return false;
  4211. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  4212. }
  4213. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  4214. {
  4215. int value = 0;
  4216. bool ret = false;
  4217. struct snd_soc_card *card;
  4218. struct msm_asoc_mach_data *pdata;
  4219. if (!component) {
  4220. pr_err("%s component is NULL\n", __func__);
  4221. return false;
  4222. }
  4223. card = component->card;
  4224. pdata = snd_soc_card_get_drvdata(card);
  4225. if (!pdata)
  4226. return false;
  4227. if (wcd_mbhc_cfg.enable_usbc_analog)
  4228. return msm_usbc_swap_gnd_mic(component, active);
  4229. /* if usbc is not defined, swap using us_euro_gpio_p */
  4230. if (pdata->us_euro_gpio_p) {
  4231. value = msm_cdc_pinctrl_get_state(
  4232. pdata->us_euro_gpio_p);
  4233. if (value)
  4234. msm_cdc_pinctrl_select_sleep_state(
  4235. pdata->us_euro_gpio_p);
  4236. else
  4237. msm_cdc_pinctrl_select_active_state(
  4238. pdata->us_euro_gpio_p);
  4239. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  4240. __func__, value, !value);
  4241. ret = true;
  4242. }
  4243. return ret;
  4244. }
  4245. static int lahaina_tdm_snd_hw_params(struct snd_pcm_substream *substream,
  4246. struct snd_pcm_hw_params *params)
  4247. {
  4248. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4249. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4250. int ret = 0;
  4251. int slot_width = TDM_SLOT_WIDTH_BITS;
  4252. int channels, slots;
  4253. unsigned int slot_mask, rate, clk_freq;
  4254. unsigned int *slot_offset;
  4255. struct tdm_dev_config *config;
  4256. unsigned int path_dir = 0, interface = 0, channel_interface = 0;
  4257. struct msm_asoc_mach_data *pdata = NULL;
  4258. pr_debug("%s: dai id = 0x%x\n", __func__, cpu_dai->id);
  4259. pdata = snd_soc_card_get_drvdata(rtd->card);
  4260. slots = pdata->tdm_max_slots;
  4261. if (cpu_dai->id < AFE_PORT_ID_TDM_PORT_RANGE_START) {
  4262. pr_err("%s: dai id 0x%x not supported\n",
  4263. __func__, cpu_dai->id);
  4264. return -EINVAL;
  4265. }
  4266. /* RX or TX */
  4267. path_dir = cpu_dai->id % MAX_PATH;
  4268. /* PRI, SEC, TERT, QUAT, QUIN, ... */
  4269. interface = (cpu_dai->id - AFE_PORT_ID_TDM_PORT_RANGE_START)
  4270. / (MAX_PATH * TDM_PORT_MAX);
  4271. /* 0, 1, 2, .. 7 */
  4272. channel_interface =
  4273. ((cpu_dai->id - AFE_PORT_ID_TDM_PORT_RANGE_START) / MAX_PATH)
  4274. % TDM_PORT_MAX;
  4275. pr_debug("%s: path dir: %u, interface %u, channel interface %u\n",
  4276. __func__, path_dir, interface, channel_interface);
  4277. config = ((struct tdm_dev_config *) tdm_cfg[interface]) +
  4278. (path_dir * TDM_PORT_MAX) + channel_interface;
  4279. if (!config) {
  4280. pr_err("%s: tdm config is NULL\n", __func__);
  4281. return -EINVAL;
  4282. }
  4283. slot_offset = config->tdm_slot_offset;
  4284. if (!slot_offset) {
  4285. pr_err("%s: slot offset is NULL\n", __func__);
  4286. return -EINVAL;
  4287. }
  4288. if (path_dir)
  4289. channels = tdm_tx_cfg[interface][channel_interface].channels;
  4290. else
  4291. channels = tdm_rx_cfg[interface][channel_interface].channels;
  4292. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4293. /*2 slot config - bits 0 and 1 set for the first two slots */
  4294. slot_mask = 0x0000FFFF >> (16 - slots);
  4295. pr_debug("%s: tdm rx slot_width %d slots %d slot_mask %x\n",
  4296. __func__, slot_width, slots, slot_mask);
  4297. ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, slot_mask,
  4298. slots, slot_width);
  4299. if (ret < 0) {
  4300. pr_err("%s: failed to set tdm rx slot, err:%d\n",
  4301. __func__, ret);
  4302. goto end;
  4303. }
  4304. pr_debug("%s: tdm rx channels: %d\n", __func__, channels);
  4305. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4306. 0, NULL, channels, slot_offset);
  4307. if (ret < 0) {
  4308. pr_err("%s: failed to set tdm rx channel map, err:%d\n",
  4309. __func__, ret);
  4310. goto end;
  4311. }
  4312. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4313. /*2 slot config - bits 0 and 1 set for the first two slots */
  4314. slot_mask = 0x0000FFFF >> (16 - slots);
  4315. pr_debug("%s: tdm tx slot_width %d slots %d slot_mask %x\n",
  4316. __func__, slot_width, slots, slot_mask);
  4317. ret = snd_soc_dai_set_tdm_slot(cpu_dai, slot_mask, 0,
  4318. slots, slot_width);
  4319. if (ret < 0) {
  4320. pr_err("%s: failed to set tdm tx slot, err:%d\n",
  4321. __func__, ret);
  4322. goto end;
  4323. }
  4324. pr_debug("%s: tdm tx channels: %d\n", __func__, channels);
  4325. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4326. channels, slot_offset, 0, NULL);
  4327. if (ret < 0) {
  4328. pr_err("%s: failed to set tdm tx channel map, err:%d\n",
  4329. __func__, ret);
  4330. goto end;
  4331. }
  4332. } else {
  4333. ret = -EINVAL;
  4334. pr_err("%s: invalid use case, err:%d\n",
  4335. __func__, ret);
  4336. goto end;
  4337. }
  4338. rate = params_rate(params);
  4339. clk_freq = rate * slot_width * slots;
  4340. ret = snd_soc_dai_set_sysclk(cpu_dai, 0, clk_freq, SND_SOC_CLOCK_OUT);
  4341. if (ret < 0)
  4342. pr_err("%s: failed to set tdm clk, err:%d\n",
  4343. __func__, ret);
  4344. end:
  4345. return ret;
  4346. }
  4347. static int msm_get_tdm_mode(u32 port_id)
  4348. {
  4349. int tdm_mode;
  4350. switch (port_id) {
  4351. case AFE_PORT_ID_PRIMARY_TDM_RX:
  4352. case AFE_PORT_ID_PRIMARY_TDM_TX:
  4353. tdm_mode = TDM_PRI;
  4354. break;
  4355. case AFE_PORT_ID_SECONDARY_TDM_RX:
  4356. case AFE_PORT_ID_SECONDARY_TDM_TX:
  4357. tdm_mode = TDM_SEC;
  4358. break;
  4359. case AFE_PORT_ID_TERTIARY_TDM_RX:
  4360. case AFE_PORT_ID_TERTIARY_TDM_TX:
  4361. tdm_mode = TDM_TERT;
  4362. break;
  4363. case AFE_PORT_ID_QUATERNARY_TDM_RX:
  4364. case AFE_PORT_ID_QUATERNARY_TDM_TX:
  4365. tdm_mode = TDM_QUAT;
  4366. break;
  4367. case AFE_PORT_ID_QUINARY_TDM_RX:
  4368. case AFE_PORT_ID_QUINARY_TDM_TX:
  4369. tdm_mode = TDM_QUIN;
  4370. break;
  4371. case AFE_PORT_ID_SENARY_TDM_RX:
  4372. case AFE_PORT_ID_SENARY_TDM_TX:
  4373. tdm_mode = TDM_SEN;
  4374. break;
  4375. default:
  4376. pr_err("%s: Invalid port id: %d\n", __func__, port_id);
  4377. tdm_mode = -EINVAL;
  4378. }
  4379. return tdm_mode;
  4380. }
  4381. static int lahaina_tdm_snd_startup(struct snd_pcm_substream *substream)
  4382. {
  4383. int ret = 0;
  4384. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4385. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4386. struct snd_soc_card *card = rtd->card;
  4387. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4388. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  4389. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  4390. ret = -EINVAL;
  4391. pr_err("%s: Invalid TDM interface %d\n",
  4392. __func__, ret);
  4393. return ret;
  4394. }
  4395. if (pdata->mi2s_gpio_p[tdm_mode]) {
  4396. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  4397. == 0) {
  4398. ret = msm_cdc_pinctrl_select_active_state(
  4399. pdata->mi2s_gpio_p[tdm_mode]);
  4400. if (ret) {
  4401. pr_err("%s: TDM GPIO pinctrl set active failed with %d\n",
  4402. __func__, ret);
  4403. goto done;
  4404. }
  4405. }
  4406. atomic_inc(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  4407. }
  4408. done:
  4409. return ret;
  4410. }
  4411. static void lahaina_tdm_snd_shutdown(struct snd_pcm_substream *substream)
  4412. {
  4413. int ret = 0;
  4414. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4415. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4416. struct snd_soc_card *card = rtd->card;
  4417. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4418. int tdm_mode = msm_get_tdm_mode(cpu_dai->id);
  4419. if (tdm_mode >= TDM_INTERFACE_MAX || tdm_mode < 0) {
  4420. ret = -EINVAL;
  4421. pr_err("%s: Invalid TDM interface %d\n",
  4422. __func__, ret);
  4423. return;
  4424. }
  4425. if (pdata->mi2s_gpio_p[tdm_mode]) {
  4426. atomic_dec(&(pdata->mi2s_gpio_ref_count[tdm_mode]));
  4427. if (atomic_read(&(pdata->mi2s_gpio_ref_count[tdm_mode]))
  4428. == 0) {
  4429. ret = msm_cdc_pinctrl_select_sleep_state(
  4430. pdata->mi2s_gpio_p[tdm_mode]);
  4431. if (ret)
  4432. pr_err("%s: TDM GPIO pinctrl set sleep failed with %d\n",
  4433. __func__, ret);
  4434. }
  4435. }
  4436. }
  4437. static int lahaina_aux_snd_startup(struct snd_pcm_substream *substream)
  4438. {
  4439. int ret = 0;
  4440. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4441. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4442. struct snd_soc_card *card = rtd->card;
  4443. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4444. u32 aux_mode = cpu_dai->id - 1;
  4445. if (aux_mode >= AUX_PCM_MAX) {
  4446. ret = -EINVAL;
  4447. pr_err("%s: Invalid AUX interface %d\n",
  4448. __func__, ret);
  4449. return ret;
  4450. }
  4451. if (pdata->mi2s_gpio_p[aux_mode]) {
  4452. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4453. == 0) {
  4454. ret = msm_cdc_pinctrl_select_active_state(
  4455. pdata->mi2s_gpio_p[aux_mode]);
  4456. if (ret) {
  4457. pr_err("%s: AUX GPIO pinctrl set active failed with %d\n",
  4458. __func__, ret);
  4459. goto done;
  4460. }
  4461. }
  4462. atomic_inc(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4463. }
  4464. done:
  4465. return ret;
  4466. }
  4467. static void lahaina_aux_snd_shutdown(struct snd_pcm_substream *substream)
  4468. {
  4469. int ret = 0;
  4470. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4471. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4472. struct snd_soc_card *card = rtd->card;
  4473. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4474. u32 aux_mode = cpu_dai->id - 1;
  4475. if (aux_mode >= AUX_PCM_MAX) {
  4476. pr_err("%s: Invalid AUX interface %d\n",
  4477. __func__, ret);
  4478. return;
  4479. }
  4480. if (pdata->mi2s_gpio_p[aux_mode]) {
  4481. atomic_dec(&(pdata->mi2s_gpio_ref_count[aux_mode]));
  4482. if (atomic_read(&(pdata->mi2s_gpio_ref_count[aux_mode]))
  4483. == 0) {
  4484. ret = msm_cdc_pinctrl_select_sleep_state(
  4485. pdata->mi2s_gpio_p[aux_mode]);
  4486. if (ret)
  4487. pr_err("%s: AUX GPIO pinctrl set sleep failed with %d\n",
  4488. __func__, ret);
  4489. }
  4490. }
  4491. }
  4492. static int msm_snd_cdc_dma_startup(struct snd_pcm_substream *substream)
  4493. {
  4494. int ret = 0;
  4495. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4496. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4497. switch (dai_link->id) {
  4498. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4499. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4500. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4501. ret = lahaina_send_island_va_config(dai_link->id);
  4502. if (ret)
  4503. pr_err("%s: send island va cfg failed, err: %d\n",
  4504. __func__, ret);
  4505. break;
  4506. default:
  4507. ret = lahaina_send_power_mode(dai_link->id);
  4508. if (ret)
  4509. pr_err("%s: send power mode failed, err: %d\n",
  4510. __func__, ret);
  4511. break;
  4512. }
  4513. return ret;
  4514. }
  4515. static void set_cps_config(struct snd_soc_pcm_runtime *rtd,
  4516. u32 num_ch, u32 ch_mask)
  4517. {
  4518. int i = 0;
  4519. int val = 0;
  4520. u8 dev_num = 0;
  4521. int ch_configured = 0;
  4522. char wsa_cdc_name[DEV_NAME_STR_LEN];
  4523. struct snd_soc_component *component = NULL;
  4524. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4525. struct msm_asoc_mach_data *pdata =
  4526. snd_soc_card_get_drvdata(rtd->card);
  4527. if (!pdata) {
  4528. pr_err("%s: pdata is NULL\n", __func__);
  4529. return;
  4530. }
  4531. if (!num_ch) {
  4532. pr_err("%s: channel count is 0\n", __func__);
  4533. return;
  4534. }
  4535. if (!pdata->get_wsa_dev_num) {
  4536. pr_err("%s: get_wsa_dev_num is NULL\n", __func__);
  4537. return;
  4538. }
  4539. if (!pdata->cps_config.spkr_dep_cfg) {
  4540. pr_err("%s: spkr_dep_cfg is NULL\n", __func__);
  4541. return;
  4542. }
  4543. if (!pdata->cps_config.hw_reg_cfg.lpass_wr_cmd_reg_phy_addr ||
  4544. !pdata->cps_config.hw_reg_cfg.lpass_rd_cmd_reg_phy_addr ||
  4545. !pdata->cps_config.hw_reg_cfg.lpass_rd_fifo_reg_phy_addr) {
  4546. pr_err("%s: cps static configuration is not set\n", __func__);
  4547. return;
  4548. }
  4549. pdata->cps_config.lpass_hw_intf_cfg_mode = 1;
  4550. while (ch_configured < num_ch) {
  4551. if (!(ch_mask & (1 << i))) {
  4552. i++;
  4553. continue;
  4554. }
  4555. snprintf(wsa_cdc_name, sizeof(wsa_cdc_name), "wsa-codec.%d",
  4556. i+1);
  4557. component = snd_soc_rtdcom_lookup(rtd, wsa_cdc_name);
  4558. if (!component) {
  4559. pr_err("%s: %s component is NULL\n", __func__,
  4560. wsa_cdc_name);
  4561. return;
  4562. }
  4563. dev_num = pdata->get_wsa_dev_num(component);
  4564. if (dev_num < 0 || dev_num > SWR_MAX_SLAVE_DEVICES) {
  4565. pr_err("%s: invalid slave dev num : %d\n", __func__,
  4566. dev_num);
  4567. return;
  4568. }
  4569. /* Clear stale dev num info */
  4570. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr &= 0xFFFF;
  4571. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr &= 0xFFFF;
  4572. val = 0;
  4573. /* bits 20:23 carry swr device number */
  4574. val |= dev_num << 20;
  4575. /* bits 24:27 carry read length in bytes */
  4576. val |= 1 << 24;
  4577. /* Update dev num in packed reg addr */
  4578. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr |= val;
  4579. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr |= val;
  4580. i++;
  4581. ch_configured++;
  4582. }
  4583. afe_set_cps_config(msm_get_port_id(dai_link->id),
  4584. &pdata->cps_config, ch_mask);
  4585. }
  4586. static int msm_snd_cdc_dma_hw_params(struct snd_pcm_substream *substream,
  4587. struct snd_pcm_hw_params *params)
  4588. {
  4589. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4590. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4591. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4592. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4593. int ret = 0;
  4594. u32 rx_ch_cdc_dma, tx_ch_cdc_dma;
  4595. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4596. u32 user_set_tx_ch = 0;
  4597. u32 user_set_rx_ch = 0;
  4598. u32 ch_id;
  4599. ret = snd_soc_dai_get_channel_map(codec_dai,
  4600. &tx_ch_cnt, &tx_ch_cdc_dma, &rx_ch_cnt,
  4601. &rx_ch_cdc_dma);
  4602. if (ret < 0) {
  4603. pr_err("%s: failed to get codec chan map, err:%d\n",
  4604. __func__, ret);
  4605. goto err;
  4606. }
  4607. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4608. switch (dai_link->id) {
  4609. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0:
  4610. case MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1:
  4611. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_0:
  4612. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_1:
  4613. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_2:
  4614. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_3:
  4615. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_4:
  4616. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_5:
  4617. case MSM_BACKEND_DAI_RX_CDC_DMA_RX_6:
  4618. {
  4619. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4620. pr_debug("%s: id %d rx_ch=%d\n", __func__,
  4621. ch_id, cdc_dma_rx_cfg[ch_id].channels);
  4622. user_set_rx_ch = cdc_dma_rx_cfg[ch_id].channels;
  4623. ret = snd_soc_dai_set_channel_map(cpu_dai, 0, 0,
  4624. user_set_rx_ch, &rx_ch_cdc_dma);
  4625. if (ret < 0) {
  4626. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4627. __func__, ret);
  4628. goto err;
  4629. }
  4630. if (dai_link->id == MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0 ||
  4631. dai_link->id == MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1) {
  4632. set_cps_config(rtd, user_set_rx_ch,
  4633. rx_ch_cdc_dma);
  4634. }
  4635. }
  4636. break;
  4637. }
  4638. } else {
  4639. switch (dai_link->id) {
  4640. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0:
  4641. {
  4642. user_set_tx_ch = msm_vi_feed_tx_ch;
  4643. }
  4644. break;
  4645. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1:
  4646. case MSM_BACKEND_DAI_WSA_CDC_DMA_TX_2:
  4647. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_0:
  4648. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_3:
  4649. case MSM_BACKEND_DAI_TX_CDC_DMA_TX_4:
  4650. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_0:
  4651. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_1:
  4652. case MSM_BACKEND_DAI_VA_CDC_DMA_TX_2:
  4653. {
  4654. ch_id = msm_cdc_dma_get_idx_from_beid(dai_link->id);
  4655. pr_debug("%s: id %d tx_ch=%d\n", __func__,
  4656. ch_id, cdc_dma_tx_cfg[ch_id].channels);
  4657. user_set_tx_ch = cdc_dma_tx_cfg[ch_id].channels;
  4658. }
  4659. break;
  4660. }
  4661. ret = snd_soc_dai_set_channel_map(cpu_dai, user_set_tx_ch,
  4662. &tx_ch_cdc_dma, 0, 0);
  4663. if (ret < 0) {
  4664. pr_err("%s: failed to set cpu chan map, err:%d\n",
  4665. __func__, ret);
  4666. goto err;
  4667. }
  4668. }
  4669. err:
  4670. return ret;
  4671. }
  4672. static int msm_fe_qos_prepare(struct snd_pcm_substream *substream)
  4673. {
  4674. if (pm_qos_request_active(&substream->latency_pm_qos_req))
  4675. pm_qos_remove_request(&substream->latency_pm_qos_req);
  4676. qos_client_active_cnt++;
  4677. if (qos_client_active_cnt == 1)
  4678. msm_audio_update_qos_request(MSM_LL_QOS_VALUE);
  4679. return 0;
  4680. }
  4681. static void msm_fe_qos_shutdown(struct snd_pcm_substream *substream)
  4682. {
  4683. (void)substream;
  4684. if (qos_client_active_cnt > 0)
  4685. qos_client_active_cnt--;
  4686. if (qos_client_active_cnt == 0)
  4687. msm_audio_update_qos_request(PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE);
  4688. }
  4689. void mi2s_disable_audio_vote(struct snd_pcm_substream *substream)
  4690. {
  4691. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4692. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4693. int index = cpu_dai->id;
  4694. struct snd_soc_card *card = rtd->card;
  4695. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4696. int sample_rate = 0;
  4697. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4698. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4699. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4700. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4701. } else {
  4702. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4703. return;
  4704. }
  4705. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4706. if (pdata->lpass_audio_hw_vote != NULL) {
  4707. if (--pdata->core_audio_vote_count == 0) {
  4708. clk_disable_unprepare(
  4709. pdata->lpass_audio_hw_vote);
  4710. } else if (pdata->core_audio_vote_count < 0) {
  4711. pr_err("%s: audio vote mismatch\n", __func__);
  4712. pdata->core_audio_vote_count = 0;
  4713. }
  4714. } else {
  4715. pr_err("%s: Invalid lpass audio hw node\n", __func__);
  4716. }
  4717. }
  4718. }
  4719. static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
  4720. {
  4721. int ret = 0;
  4722. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4723. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4724. int index = cpu_dai->id;
  4725. unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
  4726. struct snd_soc_card *card = rtd->card;
  4727. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4728. int sample_rate = 0;
  4729. dev_dbg(rtd->card->dev,
  4730. "%s: substream = %s stream = %d, dai name %s, dai ID %d\n",
  4731. __func__, substream->name, substream->stream,
  4732. cpu_dai->name, cpu_dai->id);
  4733. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4734. ret = -EINVAL;
  4735. dev_err(rtd->card->dev,
  4736. "%s: CPU DAI id (%d) out of range\n",
  4737. __func__, cpu_dai->id);
  4738. goto err;
  4739. }
  4740. /*
  4741. * Mutex protection in case the same MI2S
  4742. * interface using for both TX and RX so
  4743. * that the same clock won't be enable twice.
  4744. */
  4745. mutex_lock(&mi2s_intf_conf[index].lock);
  4746. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  4747. sample_rate = mi2s_rx_cfg[index].sample_rate;
  4748. } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
  4749. sample_rate = mi2s_tx_cfg[index].sample_rate;
  4750. } else {
  4751. pr_err("%s: invalid stream %d\n", __func__, substream->stream);
  4752. ret = -EINVAL;
  4753. goto vote_err;
  4754. }
  4755. if (IS_MSM_INTERFACE_MI2S(index) && IS_FRACTIONAL(sample_rate)) {
  4756. if (pdata->lpass_audio_hw_vote == NULL) {
  4757. dev_err(rtd->card->dev, "%s: Invalid lpass audio hw node\n",
  4758. __func__);
  4759. ret = -EINVAL;
  4760. goto vote_err;
  4761. }
  4762. if (pdata->core_audio_vote_count == 0) {
  4763. ret = clk_prepare_enable(pdata->lpass_audio_hw_vote);
  4764. if (ret < 0) {
  4765. dev_err(rtd->card->dev, "%s: audio vote error\n",
  4766. __func__);
  4767. goto vote_err;
  4768. }
  4769. }
  4770. pdata->core_audio_vote_count++;
  4771. }
  4772. if (++mi2s_intf_conf[index].ref_cnt == 1) {
  4773. /* Check if msm needs to provide the clock to the interface */
  4774. if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
  4775. mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
  4776. fmt = SND_SOC_DAIFMT_CBM_CFM;
  4777. }
  4778. ret = msm_mi2s_set_sclk(substream, true);
  4779. if (ret < 0) {
  4780. dev_err(rtd->card->dev,
  4781. "%s: afe lpass clock failed to enable MI2S clock, err:%d\n",
  4782. __func__, ret);
  4783. goto clean_up;
  4784. }
  4785. ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
  4786. if (ret < 0) {
  4787. pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
  4788. __func__, index, ret);
  4789. goto clk_off;
  4790. }
  4791. if (pdata->mi2s_gpio_p[index]) {
  4792. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4793. == 0) {
  4794. ret = msm_cdc_pinctrl_select_active_state(
  4795. pdata->mi2s_gpio_p[index]);
  4796. if (ret) {
  4797. pr_err("%s: MI2S GPIO pinctrl set active failed with %d\n",
  4798. __func__, ret);
  4799. goto clk_off;
  4800. }
  4801. }
  4802. atomic_inc(&(pdata->mi2s_gpio_ref_count[index]));
  4803. }
  4804. }
  4805. clk_off:
  4806. if (ret < 0)
  4807. msm_mi2s_set_sclk(substream, false);
  4808. clean_up:
  4809. if (ret < 0) {
  4810. mi2s_intf_conf[index].ref_cnt--;
  4811. mi2s_disable_audio_vote(substream);
  4812. }
  4813. vote_err:
  4814. mutex_unlock(&mi2s_intf_conf[index].lock);
  4815. err:
  4816. return ret;
  4817. }
  4818. static void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream)
  4819. {
  4820. int ret = 0;
  4821. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4822. int index = rtd->cpu_dai->id;
  4823. struct snd_soc_card *card = rtd->card;
  4824. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  4825. pr_debug("%s(): substream = %s stream = %d\n", __func__,
  4826. substream->name, substream->stream);
  4827. if (index < PRIM_MI2S || index >= MI2S_MAX) {
  4828. pr_err("%s:invalid MI2S DAI(%d)\n", __func__, index);
  4829. return;
  4830. }
  4831. mutex_lock(&mi2s_intf_conf[index].lock);
  4832. if (--mi2s_intf_conf[index].ref_cnt == 0) {
  4833. if (pdata->mi2s_gpio_p[index]) {
  4834. atomic_dec(&(pdata->mi2s_gpio_ref_count[index]));
  4835. if (atomic_read(&(pdata->mi2s_gpio_ref_count[index]))
  4836. == 0) {
  4837. ret = msm_cdc_pinctrl_select_sleep_state(
  4838. pdata->mi2s_gpio_p[index]);
  4839. if (ret)
  4840. pr_err("%s: MI2S GPIO pinctrl set sleep failed with %d\n",
  4841. __func__, ret);
  4842. }
  4843. }
  4844. ret = msm_mi2s_set_sclk(substream, false);
  4845. if (ret < 0)
  4846. pr_err("%s:clock disable failed for MI2S (%d); ret=%d\n",
  4847. __func__, index, ret);
  4848. }
  4849. mi2s_disable_audio_vote(substream);
  4850. mutex_unlock(&mi2s_intf_conf[index].lock);
  4851. }
  4852. static int msm_wcn_hw_params_lito(struct snd_pcm_substream *substream,
  4853. struct snd_pcm_hw_params *params)
  4854. {
  4855. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4856. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4857. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4858. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4859. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO];
  4860. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4861. int ret = 0;
  4862. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4863. codec_dai->name, codec_dai->id);
  4864. ret = snd_soc_dai_get_channel_map(codec_dai,
  4865. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4866. if (ret) {
  4867. dev_err(rtd->dev,
  4868. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4869. __func__, ret);
  4870. goto err;
  4871. }
  4872. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4873. __func__, tx_ch_cnt, dai_link->id);
  4874. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4875. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4876. if (ret)
  4877. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4878. __func__, ret);
  4879. err:
  4880. return ret;
  4881. }
  4882. static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
  4883. struct snd_pcm_hw_params *params)
  4884. {
  4885. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  4886. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  4887. struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  4888. struct snd_soc_dai_link *dai_link = rtd->dai_link;
  4889. u32 rx_ch[WCN_CDC_SLIM_RX_CH_MAX], tx_ch[WCN_CDC_SLIM_TX_CH_MAX];
  4890. u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
  4891. int ret = 0;
  4892. dev_dbg(rtd->dev, "%s: %s_tx_dai_id_%d\n", __func__,
  4893. codec_dai->name, codec_dai->id);
  4894. ret = snd_soc_dai_get_channel_map(codec_dai,
  4895. &tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
  4896. if (ret) {
  4897. dev_err(rtd->dev,
  4898. "%s: failed to get BTFM codec chan map\n, err:%d\n",
  4899. __func__, ret);
  4900. goto err;
  4901. }
  4902. dev_dbg(rtd->dev, "%s: tx_ch_cnt(%d) BE id %d\n",
  4903. __func__, tx_ch_cnt, dai_link->id);
  4904. ret = snd_soc_dai_set_channel_map(cpu_dai,
  4905. tx_ch_cnt, tx_ch, rx_ch_cnt, rx_ch);
  4906. if (ret)
  4907. dev_err(rtd->dev, "%s: failed to set cpu chan map, err:%d\n",
  4908. __func__, ret);
  4909. err:
  4910. return ret;
  4911. }
  4912. static struct snd_soc_ops lahaina_aux_be_ops = {
  4913. .startup = lahaina_aux_snd_startup,
  4914. .shutdown = lahaina_aux_snd_shutdown
  4915. };
  4916. static struct snd_soc_ops lahaina_tdm_be_ops = {
  4917. .hw_params = lahaina_tdm_snd_hw_params,
  4918. .startup = lahaina_tdm_snd_startup,
  4919. .shutdown = lahaina_tdm_snd_shutdown
  4920. };
  4921. static struct snd_soc_ops msm_mi2s_be_ops = {
  4922. .startup = msm_mi2s_snd_startup,
  4923. .shutdown = msm_mi2s_snd_shutdown,
  4924. };
  4925. static struct snd_soc_ops msm_fe_qos_ops = {
  4926. .prepare = msm_fe_qos_prepare,
  4927. .shutdown = msm_fe_qos_shutdown,
  4928. };
  4929. static struct snd_soc_ops msm_cdc_dma_be_ops = {
  4930. .startup = msm_snd_cdc_dma_startup,
  4931. .hw_params = msm_snd_cdc_dma_hw_params,
  4932. };
  4933. static struct snd_soc_ops msm_wcn_ops = {
  4934. .hw_params = msm_wcn_hw_params,
  4935. };
  4936. static struct snd_soc_ops msm_wcn_ops_lito = {
  4937. .hw_params = msm_wcn_hw_params_lito,
  4938. };
  4939. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  4940. struct snd_kcontrol *kcontrol, int event)
  4941. {
  4942. struct msm_asoc_mach_data *pdata = NULL;
  4943. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  4944. int ret = 0;
  4945. u32 dmic_idx;
  4946. int *dmic_gpio_cnt;
  4947. struct device_node *dmic_gpio;
  4948. char *wname;
  4949. wname = strpbrk(w->name, "012345");
  4950. if (!wname) {
  4951. dev_err(component->dev, "%s: widget not found\n", __func__);
  4952. return -EINVAL;
  4953. }
  4954. ret = kstrtouint(wname, 10, &dmic_idx);
  4955. if (ret < 0) {
  4956. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  4957. __func__);
  4958. return -EINVAL;
  4959. }
  4960. pdata = snd_soc_card_get_drvdata(component->card);
  4961. switch (dmic_idx) {
  4962. case 0:
  4963. case 1:
  4964. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  4965. dmic_gpio = pdata->dmic01_gpio_p;
  4966. break;
  4967. case 2:
  4968. case 3:
  4969. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  4970. dmic_gpio = pdata->dmic23_gpio_p;
  4971. break;
  4972. case 4:
  4973. case 5:
  4974. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  4975. dmic_gpio = pdata->dmic45_gpio_p;
  4976. break;
  4977. default:
  4978. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  4979. __func__);
  4980. return -EINVAL;
  4981. }
  4982. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  4983. __func__, event, dmic_idx, *dmic_gpio_cnt);
  4984. switch (event) {
  4985. case SND_SOC_DAPM_PRE_PMU:
  4986. (*dmic_gpio_cnt)++;
  4987. if (*dmic_gpio_cnt == 1) {
  4988. ret = msm_cdc_pinctrl_select_active_state(
  4989. dmic_gpio);
  4990. if (ret < 0) {
  4991. pr_err("%s: gpio set cannot be activated %sd",
  4992. __func__, "dmic_gpio");
  4993. return ret;
  4994. }
  4995. }
  4996. break;
  4997. case SND_SOC_DAPM_POST_PMD:
  4998. (*dmic_gpio_cnt)--;
  4999. if (*dmic_gpio_cnt == 0) {
  5000. ret = msm_cdc_pinctrl_select_sleep_state(
  5001. dmic_gpio);
  5002. if (ret < 0) {
  5003. pr_err("%s: gpio set cannot be de-activated %sd",
  5004. __func__, "dmic_gpio");
  5005. return ret;
  5006. }
  5007. }
  5008. break;
  5009. default:
  5010. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  5011. return -EINVAL;
  5012. }
  5013. return 0;
  5014. }
  5015. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  5016. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  5017. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  5018. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  5019. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  5020. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  5021. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  5022. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  5023. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  5024. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  5025. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  5026. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  5027. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  5028. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  5029. };
  5030. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  5031. {
  5032. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  5033. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  5034. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  5035. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  5036. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  5037. }
  5038. static int msm_wcn_init_lito(struct snd_soc_pcm_runtime *rtd)
  5039. {
  5040. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  5041. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX_LITO] = {159, 160, 161};
  5042. struct snd_soc_dai *codec_dai = rtd->codec_dai;
  5043. return snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  5044. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  5045. }
  5046. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  5047. const char *name,
  5048. struct snd_info_entry *parent)
  5049. {
  5050. struct snd_info_entry *entry;
  5051. entry = snd_info_create_module_entry(mod, name, parent);
  5052. if (!entry)
  5053. return NULL;
  5054. entry->mode = S_IFDIR | 0555;
  5055. if (snd_info_register(entry) < 0) {
  5056. snd_info_free_entry(entry);
  5057. return NULL;
  5058. }
  5059. return entry;
  5060. }
  5061. static void *def_wcd_mbhc_cal(void)
  5062. {
  5063. void *wcd_mbhc_cal;
  5064. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  5065. u16 *btn_high;
  5066. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  5067. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  5068. if (!wcd_mbhc_cal)
  5069. return NULL;
  5070. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  5071. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  5072. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  5073. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  5074. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  5075. btn_high[0] = 75;
  5076. btn_high[1] = 150;
  5077. btn_high[2] = 237;
  5078. btn_high[3] = 500;
  5079. btn_high[4] = 500;
  5080. btn_high[5] = 500;
  5081. btn_high[6] = 500;
  5082. btn_high[7] = 500;
  5083. return wcd_mbhc_cal;
  5084. }
  5085. /* Digital audio interface glue - connects codec <---> CPU */
  5086. static struct snd_soc_dai_link msm_common_dai_links[] = {
  5087. /* FrontEnd DAI Links */
  5088. {/* hw:x,0 */
  5089. .name = MSM_DAILINK_NAME(Media1),
  5090. .stream_name = "MultiMedia1",
  5091. .dynamic = 1,
  5092. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5093. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5094. #endif /* CONFIG_AUDIO_QGKI */
  5095. .dpcm_playback = 1,
  5096. .dpcm_capture = 1,
  5097. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5098. SND_SOC_DPCM_TRIGGER_POST},
  5099. .ignore_suspend = 1,
  5100. /* this dainlink has playback support */
  5101. .ignore_pmdown_time = 1,
  5102. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  5103. SND_SOC_DAILINK_REG(multimedia1),
  5104. },
  5105. {/* hw:x,1 */
  5106. .name = MSM_DAILINK_NAME(Media2),
  5107. .stream_name = "MultiMedia2",
  5108. .dynamic = 1,
  5109. .dpcm_playback = 1,
  5110. .dpcm_capture = 1,
  5111. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5112. SND_SOC_DPCM_TRIGGER_POST},
  5113. .ignore_suspend = 1,
  5114. /* this dainlink has playback support */
  5115. .ignore_pmdown_time = 1,
  5116. .id = MSM_FRONTEND_DAI_MULTIMEDIA2,
  5117. SND_SOC_DAILINK_REG(multimedia2),
  5118. },
  5119. {/* hw:x,2 */
  5120. .name = "VoiceMMode1",
  5121. .stream_name = "VoiceMMode1",
  5122. .dynamic = 1,
  5123. .dpcm_playback = 1,
  5124. .dpcm_capture = 1,
  5125. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5126. SND_SOC_DPCM_TRIGGER_POST},
  5127. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5128. .ignore_suspend = 1,
  5129. .ignore_pmdown_time = 1,
  5130. .id = MSM_FRONTEND_DAI_VOICEMMODE1,
  5131. SND_SOC_DAILINK_REG(voicemmode1),
  5132. },
  5133. {/* hw:x,3 */
  5134. .name = "MSM VoIP",
  5135. .stream_name = "VoIP",
  5136. .dynamic = 1,
  5137. .dpcm_playback = 1,
  5138. .dpcm_capture = 1,
  5139. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5140. SND_SOC_DPCM_TRIGGER_POST},
  5141. .ignore_suspend = 1,
  5142. /* this dainlink has playback support */
  5143. .ignore_pmdown_time = 1,
  5144. .id = MSM_FRONTEND_DAI_VOIP,
  5145. SND_SOC_DAILINK_REG(msmvoip),
  5146. },
  5147. {/* hw:x,4 */
  5148. .name = MSM_DAILINK_NAME(ULL),
  5149. .stream_name = "MultiMedia3",
  5150. .dynamic = 1,
  5151. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5152. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5153. #endif /* CONFIG_AUDIO_QGKI */
  5154. .dpcm_playback = 1,
  5155. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5156. SND_SOC_DPCM_TRIGGER_POST},
  5157. .ignore_suspend = 1,
  5158. /* this dainlink has playback support */
  5159. .ignore_pmdown_time = 1,
  5160. .id = MSM_FRONTEND_DAI_MULTIMEDIA3,
  5161. SND_SOC_DAILINK_REG(multimedia3),
  5162. },
  5163. {/* hw:x,5 */
  5164. .name = "MSM AFE-PCM RX",
  5165. .stream_name = "AFE-PROXY RX",
  5166. .dpcm_playback = 1,
  5167. .ignore_suspend = 1,
  5168. /* this dainlink has playback support */
  5169. .ignore_pmdown_time = 1,
  5170. SND_SOC_DAILINK_REG(afepcm_rx),
  5171. },
  5172. {/* hw:x,6 */
  5173. .name = "MSM AFE-PCM TX",
  5174. .stream_name = "AFE-PROXY TX",
  5175. .dpcm_capture = 1,
  5176. .ignore_suspend = 1,
  5177. SND_SOC_DAILINK_REG(afepcm_tx),
  5178. },
  5179. {/* hw:x,7 */
  5180. .name = MSM_DAILINK_NAME(Compress1),
  5181. .stream_name = "Compress1",
  5182. .dynamic = 1,
  5183. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5184. .async_ops = ASYNC_DPCM_SND_SOC_HW_PARAMS,
  5185. #endif /* CONFIG_AUDIO_QGKI */
  5186. .dpcm_playback = 1,
  5187. .dpcm_capture = 1,
  5188. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5189. SND_SOC_DPCM_TRIGGER_POST},
  5190. .ignore_suspend = 1,
  5191. .ignore_pmdown_time = 1,
  5192. /* this dainlink has playback support */
  5193. .id = MSM_FRONTEND_DAI_MULTIMEDIA4,
  5194. SND_SOC_DAILINK_REG(multimedia4),
  5195. },
  5196. /* Hostless PCM purpose */
  5197. {/* hw:x,8 */
  5198. .name = "AUXPCM Hostless",
  5199. .stream_name = "AUXPCM Hostless",
  5200. .dynamic = 1,
  5201. .dpcm_playback = 1,
  5202. .dpcm_capture = 1,
  5203. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5204. SND_SOC_DPCM_TRIGGER_POST},
  5205. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5206. .ignore_suspend = 1,
  5207. /* this dainlink has playback support */
  5208. .ignore_pmdown_time = 1,
  5209. SND_SOC_DAILINK_REG(auxpcm_hostless),
  5210. },
  5211. {/* hw:x,9 */
  5212. .name = MSM_DAILINK_NAME(LowLatency),
  5213. .stream_name = "MultiMedia5",
  5214. .dynamic = 1,
  5215. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5216. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5217. #endif /* CONFIG_AUDIO_QGKI */
  5218. .dpcm_playback = 1,
  5219. .dpcm_capture = 1,
  5220. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5221. SND_SOC_DPCM_TRIGGER_POST},
  5222. .ignore_suspend = 1,
  5223. /* this dainlink has playback support */
  5224. .ignore_pmdown_time = 1,
  5225. .id = MSM_FRONTEND_DAI_MULTIMEDIA5,
  5226. .ops = &msm_fe_qos_ops,
  5227. SND_SOC_DAILINK_REG(multimedia5),
  5228. },
  5229. {/* hw:x,10 */
  5230. .name = "Listen 1 Audio Service",
  5231. .stream_name = "Listen 1 Audio Service",
  5232. .dynamic = 1,
  5233. .dpcm_capture = 1,
  5234. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5235. SND_SOC_DPCM_TRIGGER_POST },
  5236. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5237. .ignore_suspend = 1,
  5238. .id = MSM_FRONTEND_DAI_LSM1,
  5239. SND_SOC_DAILINK_REG(listen1),
  5240. },
  5241. /* Multiple Tunnel instances */
  5242. {/* hw:x,11 */
  5243. .name = MSM_DAILINK_NAME(Compress2),
  5244. .stream_name = "Compress2",
  5245. .dynamic = 1,
  5246. .dpcm_playback = 1,
  5247. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5248. SND_SOC_DPCM_TRIGGER_POST},
  5249. .ignore_suspend = 1,
  5250. .ignore_pmdown_time = 1,
  5251. /* this dainlink has playback support */
  5252. .id = MSM_FRONTEND_DAI_MULTIMEDIA7,
  5253. SND_SOC_DAILINK_REG(multimedia7),
  5254. },
  5255. {/* hw:x,12 */
  5256. .name = MSM_DAILINK_NAME(MultiMedia10),
  5257. .stream_name = "MultiMedia10",
  5258. .dynamic = 1,
  5259. .dpcm_playback = 1,
  5260. .dpcm_capture = 1,
  5261. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5262. SND_SOC_DPCM_TRIGGER_POST},
  5263. .ignore_suspend = 1,
  5264. .ignore_pmdown_time = 1,
  5265. /* this dainlink has playback support */
  5266. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  5267. SND_SOC_DAILINK_REG(multimedia10),
  5268. },
  5269. {/* hw:x,13 */
  5270. .name = MSM_DAILINK_NAME(ULL_NOIRQ),
  5271. .stream_name = "MM_NOIRQ",
  5272. .dynamic = 1,
  5273. .dpcm_playback = 1,
  5274. .dpcm_capture = 1,
  5275. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5276. SND_SOC_DPCM_TRIGGER_POST},
  5277. .ignore_suspend = 1,
  5278. .ignore_pmdown_time = 1,
  5279. /* this dainlink has playback support */
  5280. .id = MSM_FRONTEND_DAI_MULTIMEDIA8,
  5281. .ops = &msm_fe_qos_ops,
  5282. SND_SOC_DAILINK_REG(multimedia8),
  5283. },
  5284. /* HDMI Hostless */
  5285. {/* hw:x,14 */
  5286. .name = "HDMI_RX_HOSTLESS",
  5287. .stream_name = "HDMI_RX_HOSTLESS",
  5288. .dynamic = 1,
  5289. .dpcm_playback = 1,
  5290. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5291. SND_SOC_DPCM_TRIGGER_POST},
  5292. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5293. .ignore_suspend = 1,
  5294. .ignore_pmdown_time = 1,
  5295. SND_SOC_DAILINK_REG(hdmi_rx_hostless),
  5296. },
  5297. {/* hw:x,15 */
  5298. .name = "VoiceMMode2",
  5299. .stream_name = "VoiceMMode2",
  5300. .dynamic = 1,
  5301. .dpcm_playback = 1,
  5302. .dpcm_capture = 1,
  5303. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5304. SND_SOC_DPCM_TRIGGER_POST},
  5305. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5306. .ignore_suspend = 1,
  5307. .ignore_pmdown_time = 1,
  5308. .id = MSM_FRONTEND_DAI_VOICEMMODE2,
  5309. SND_SOC_DAILINK_REG(voicemmode2),
  5310. },
  5311. /* LSM FE */
  5312. {/* hw:x,16 */
  5313. .name = "Listen 2 Audio Service",
  5314. .stream_name = "Listen 2 Audio Service",
  5315. .dynamic = 1,
  5316. .dpcm_capture = 1,
  5317. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5318. SND_SOC_DPCM_TRIGGER_POST },
  5319. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5320. .ignore_suspend = 1,
  5321. .id = MSM_FRONTEND_DAI_LSM2,
  5322. SND_SOC_DAILINK_REG(listen2),
  5323. },
  5324. {/* hw:x,17 */
  5325. .name = "Listen 3 Audio Service",
  5326. .stream_name = "Listen 3 Audio Service",
  5327. .dynamic = 1,
  5328. .dpcm_capture = 1,
  5329. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5330. SND_SOC_DPCM_TRIGGER_POST },
  5331. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5332. .ignore_suspend = 1,
  5333. .id = MSM_FRONTEND_DAI_LSM3,
  5334. SND_SOC_DAILINK_REG(listen3),
  5335. },
  5336. {/* hw:x,18 */
  5337. .name = "Listen 4 Audio Service",
  5338. .stream_name = "Listen 4 Audio Service",
  5339. .dynamic = 1,
  5340. .dpcm_capture = 1,
  5341. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5342. SND_SOC_DPCM_TRIGGER_POST },
  5343. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5344. .ignore_suspend = 1,
  5345. .id = MSM_FRONTEND_DAI_LSM4,
  5346. SND_SOC_DAILINK_REG(listen4),
  5347. },
  5348. {/* hw:x,19 */
  5349. .name = "Listen 5 Audio Service",
  5350. .stream_name = "Listen 5 Audio Service",
  5351. .dynamic = 1,
  5352. .dpcm_capture = 1,
  5353. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5354. SND_SOC_DPCM_TRIGGER_POST },
  5355. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5356. .ignore_suspend = 1,
  5357. .id = MSM_FRONTEND_DAI_LSM5,
  5358. SND_SOC_DAILINK_REG(listen5),
  5359. },
  5360. {/* hw:x,20 */
  5361. .name = "Listen 6 Audio Service",
  5362. .stream_name = "Listen 6 Audio Service",
  5363. .dynamic = 1,
  5364. .dpcm_capture = 1,
  5365. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5366. SND_SOC_DPCM_TRIGGER_POST },
  5367. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5368. .ignore_suspend = 1,
  5369. .id = MSM_FRONTEND_DAI_LSM6,
  5370. SND_SOC_DAILINK_REG(listen6),
  5371. },
  5372. {/* hw:x,21 */
  5373. .name = "Listen 7 Audio Service",
  5374. .stream_name = "Listen 7 Audio Service",
  5375. .dynamic = 1,
  5376. .dpcm_capture = 1,
  5377. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5378. SND_SOC_DPCM_TRIGGER_POST },
  5379. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5380. .ignore_suspend = 1,
  5381. .id = MSM_FRONTEND_DAI_LSM7,
  5382. SND_SOC_DAILINK_REG(listen7),
  5383. },
  5384. {/* hw:x,22 */
  5385. .name = "Listen 8 Audio Service",
  5386. .stream_name = "Listen 8 Audio Service",
  5387. .dynamic = 1,
  5388. .dpcm_capture = 1,
  5389. .trigger = { SND_SOC_DPCM_TRIGGER_POST,
  5390. SND_SOC_DPCM_TRIGGER_POST },
  5391. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5392. .ignore_suspend = 1,
  5393. .id = MSM_FRONTEND_DAI_LSM8,
  5394. SND_SOC_DAILINK_REG(listen8),
  5395. },
  5396. {/* hw:x,23 */
  5397. .name = MSM_DAILINK_NAME(Media9),
  5398. .stream_name = "MultiMedia9",
  5399. .dynamic = 1,
  5400. .dpcm_playback = 1,
  5401. .dpcm_capture = 1,
  5402. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5403. SND_SOC_DPCM_TRIGGER_POST},
  5404. .ignore_suspend = 1,
  5405. /* this dainlink has playback support */
  5406. .ignore_pmdown_time = 1,
  5407. .id = MSM_FRONTEND_DAI_MULTIMEDIA9,
  5408. SND_SOC_DAILINK_REG(multimedia9),
  5409. },
  5410. {/* hw:x,24 */
  5411. .name = MSM_DAILINK_NAME(Compress4),
  5412. .stream_name = "Compress4",
  5413. .dynamic = 1,
  5414. .dpcm_playback = 1,
  5415. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5416. SND_SOC_DPCM_TRIGGER_POST},
  5417. .ignore_suspend = 1,
  5418. .ignore_pmdown_time = 1,
  5419. /* this dainlink has playback support */
  5420. .id = MSM_FRONTEND_DAI_MULTIMEDIA11,
  5421. SND_SOC_DAILINK_REG(multimedia11),
  5422. },
  5423. {/* hw:x,25 */
  5424. .name = MSM_DAILINK_NAME(Compress5),
  5425. .stream_name = "Compress5",
  5426. .dynamic = 1,
  5427. .dpcm_playback = 1,
  5428. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5429. SND_SOC_DPCM_TRIGGER_POST},
  5430. .ignore_suspend = 1,
  5431. .ignore_pmdown_time = 1,
  5432. /* this dainlink has playback support */
  5433. .id = MSM_FRONTEND_DAI_MULTIMEDIA12,
  5434. SND_SOC_DAILINK_REG(multimedia12),
  5435. },
  5436. {/* hw:x,26 */
  5437. .name = MSM_DAILINK_NAME(Compress6),
  5438. .stream_name = "Compress6",
  5439. .dynamic = 1,
  5440. .dpcm_playback = 1,
  5441. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5442. SND_SOC_DPCM_TRIGGER_POST},
  5443. .ignore_suspend = 1,
  5444. .ignore_pmdown_time = 1,
  5445. /* this dainlink has playback support */
  5446. .id = MSM_FRONTEND_DAI_MULTIMEDIA13,
  5447. SND_SOC_DAILINK_REG(multimedia13),
  5448. },
  5449. {/* hw:x,27 */
  5450. .name = MSM_DAILINK_NAME(Compress7),
  5451. .stream_name = "Compress7",
  5452. .dynamic = 1,
  5453. .dpcm_playback = 1,
  5454. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5455. SND_SOC_DPCM_TRIGGER_POST},
  5456. .ignore_suspend = 1,
  5457. .ignore_pmdown_time = 1,
  5458. /* this dainlink has playback support */
  5459. .id = MSM_FRONTEND_DAI_MULTIMEDIA14,
  5460. SND_SOC_DAILINK_REG(multimedia14),
  5461. },
  5462. {/* hw:x,28 */
  5463. .name = MSM_DAILINK_NAME(Compress8),
  5464. .stream_name = "Compress8",
  5465. .dynamic = 1,
  5466. .dpcm_playback = 1,
  5467. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5468. SND_SOC_DPCM_TRIGGER_POST},
  5469. .ignore_suspend = 1,
  5470. .ignore_pmdown_time = 1,
  5471. /* this dainlink has playback support */
  5472. .id = MSM_FRONTEND_DAI_MULTIMEDIA15,
  5473. SND_SOC_DAILINK_REG(multimedia15),
  5474. },
  5475. {/* hw:x,29 */
  5476. .name = MSM_DAILINK_NAME(ULL_NOIRQ_2),
  5477. .stream_name = "MM_NOIRQ_2",
  5478. .dynamic = 1,
  5479. .dpcm_playback = 1,
  5480. .dpcm_capture = 1,
  5481. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5482. SND_SOC_DPCM_TRIGGER_POST},
  5483. .ignore_suspend = 1,
  5484. .ignore_pmdown_time = 1,
  5485. /* this dainlink has playback support */
  5486. .id = MSM_FRONTEND_DAI_MULTIMEDIA16,
  5487. .ops = &msm_fe_qos_ops,
  5488. SND_SOC_DAILINK_REG(multimedia16),
  5489. },
  5490. {/* hw:x,30 */
  5491. .name = "CDC_DMA Hostless",
  5492. .stream_name = "CDC_DMA Hostless",
  5493. .dynamic = 1,
  5494. .dpcm_playback = 1,
  5495. .dpcm_capture = 1,
  5496. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5497. SND_SOC_DPCM_TRIGGER_POST},
  5498. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5499. .ignore_suspend = 1,
  5500. /* this dailink has playback support */
  5501. .ignore_pmdown_time = 1,
  5502. SND_SOC_DAILINK_REG(cdcdma_hostless),
  5503. },
  5504. {/* hw:x,31 */
  5505. .name = "TX3_CDC_DMA Hostless",
  5506. .stream_name = "TX3_CDC_DMA Hostless",
  5507. .dynamic = 1,
  5508. .dpcm_capture = 1,
  5509. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5510. SND_SOC_DPCM_TRIGGER_POST},
  5511. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5512. .ignore_suspend = 1,
  5513. SND_SOC_DAILINK_REG(tx3_cdcdma_hostless),
  5514. },
  5515. {/* hw:x,32 */
  5516. .name = "Tertiary MI2S TX_Hostless",
  5517. .stream_name = "Tertiary MI2S_TX Hostless Capture",
  5518. .dynamic = 1,
  5519. .dpcm_capture = 1,
  5520. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5521. SND_SOC_DPCM_TRIGGER_POST},
  5522. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5523. .ignore_suspend = 1,
  5524. .ignore_pmdown_time = 1,
  5525. SND_SOC_DAILINK_REG(tert_mi2s_tx_hostless),
  5526. },
  5527. };
  5528. static struct snd_soc_dai_link msm_bolero_fe_dai_links[] = {
  5529. {/* hw:x,33 */
  5530. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5531. .stream_name = "WSA CDC DMA0 Capture",
  5532. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5533. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5534. .ignore_suspend = 1,
  5535. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5536. .ops = &msm_cdc_dma_be_ops,
  5537. SND_SOC_DAILINK_REG(wsa_cdcdma0_capture),
  5538. },
  5539. };
  5540. static struct snd_soc_dai_link msm_bolero_fe_stub_dai_links[] = {
  5541. {/* hw:x,33 */
  5542. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  5543. .stream_name = "WSA CDC DMA0 Capture",
  5544. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  5545. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5546. .ignore_suspend = 1,
  5547. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5548. .ops = &msm_cdc_dma_be_ops,
  5549. SND_SOC_DAILINK_REG(wsa_cdcdma0_capture_stub),
  5550. },
  5551. };
  5552. static struct snd_soc_dai_link msm_common_misc_fe_dai_links[] = {
  5553. {/* hw:x,34 */
  5554. .name = MSM_DAILINK_NAME(ASM Loopback),
  5555. .stream_name = "MultiMedia6",
  5556. .dynamic = 1,
  5557. .dpcm_playback = 1,
  5558. .dpcm_capture = 1,
  5559. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5560. SND_SOC_DPCM_TRIGGER_POST},
  5561. .ignore_suspend = 1,
  5562. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5563. .ignore_pmdown_time = 1,
  5564. .id = MSM_FRONTEND_DAI_MULTIMEDIA6,
  5565. SND_SOC_DAILINK_REG(multimedia6),
  5566. },
  5567. {/* hw:x,35 */
  5568. .name = "USB Audio Hostless",
  5569. .stream_name = "USB Audio Hostless",
  5570. .dynamic = 1,
  5571. .dpcm_playback = 1,
  5572. .dpcm_capture = 1,
  5573. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5574. SND_SOC_DPCM_TRIGGER_POST},
  5575. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5576. .ignore_suspend = 1,
  5577. .ignore_pmdown_time = 1,
  5578. SND_SOC_DAILINK_REG(usbaudio_hostless),
  5579. },
  5580. {/* hw:x,36 */
  5581. .name = "SLIMBUS_7 Hostless",
  5582. .stream_name = "SLIMBUS_7 Hostless",
  5583. .dynamic = 1,
  5584. .dpcm_capture = 1,
  5585. .dpcm_playback = 1,
  5586. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5587. SND_SOC_DPCM_TRIGGER_POST},
  5588. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5589. .ignore_suspend = 1,
  5590. .ignore_pmdown_time = 1,
  5591. SND_SOC_DAILINK_REG(slimbus7_hostless),
  5592. },
  5593. {/* hw:x,37 */
  5594. .name = "Compress Capture",
  5595. .stream_name = "Compress9",
  5596. .dynamic = 1,
  5597. .dpcm_capture = 1,
  5598. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5599. SND_SOC_DPCM_TRIGGER_POST},
  5600. .ignore_suspend = 1,
  5601. .ignore_pmdown_time = 1,
  5602. .id = MSM_FRONTEND_DAI_MULTIMEDIA17,
  5603. SND_SOC_DAILINK_REG(multimedia17),
  5604. },
  5605. {/* hw:x,38 */
  5606. .name = "SLIMBUS_8 Hostless",
  5607. .stream_name = "SLIMBUS_8 Hostless",
  5608. .dynamic = 1,
  5609. .dpcm_capture = 1,
  5610. .dpcm_playback = 1,
  5611. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5612. SND_SOC_DPCM_TRIGGER_POST},
  5613. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5614. .ignore_suspend = 1,
  5615. .ignore_pmdown_time = 1,
  5616. SND_SOC_DAILINK_REG(slimbus8_hostless),
  5617. },
  5618. {/* hw:x,39 */
  5619. .name = LPASS_BE_TX_CDC_DMA_TX_5,
  5620. .stream_name = "TX CDC DMA5 Capture",
  5621. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_5,
  5622. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5623. .ignore_suspend = 1,
  5624. .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
  5625. .ops = &msm_cdc_dma_be_ops,
  5626. SND_SOC_DAILINK_REG(tx_cdcdma5_tx),
  5627. },
  5628. {/* hw:x,40 */
  5629. .name = MSM_DAILINK_NAME(Media31),
  5630. .stream_name = "MultiMedia31",
  5631. .dynamic = 1,
  5632. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5633. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5634. #endif /* CONFIG_AUDIO_QGKI */
  5635. .dpcm_playback = 1,
  5636. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5637. SND_SOC_DPCM_TRIGGER_POST},
  5638. .ignore_suspend = 1,
  5639. /* this dainlink has playback support */
  5640. .ignore_pmdown_time = 1,
  5641. .id = MSM_FRONTEND_DAI_MULTIMEDIA31,
  5642. SND_SOC_DAILINK_REG(multimedia31),
  5643. },
  5644. {/* hw:x,41 */
  5645. .name = MSM_DAILINK_NAME(Media32),
  5646. .stream_name = "MultiMedia32",
  5647. .dynamic = 1,
  5648. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5649. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  5650. #endif /* CONFIG_AUDIO_QGKI */
  5651. .dpcm_playback = 1,
  5652. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5653. SND_SOC_DPCM_TRIGGER_POST},
  5654. .ignore_suspend = 1,
  5655. /* this dainlink has playback support */
  5656. .ignore_pmdown_time = 1,
  5657. .id = MSM_FRONTEND_DAI_MULTIMEDIA32,
  5658. SND_SOC_DAILINK_REG(multimedia32),
  5659. },
  5660. {/* hw:x,42 */
  5661. .name = "MSM AFE-PCM TX1",
  5662. .stream_name = "AFE-PROXY TX1",
  5663. .dpcm_capture = 1,
  5664. .ignore_suspend = 1,
  5665. SND_SOC_DAILINK_REG(afepcm_tx1),
  5666. },
  5667. {/* hw:x,43 */
  5668. .name = MSM_DAILINK_NAME(Compress3),
  5669. .stream_name = "Compress3",
  5670. .dynamic = 1,
  5671. .dpcm_playback = 1,
  5672. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  5673. SND_SOC_DPCM_TRIGGER_POST},
  5674. .ignore_suspend = 1,
  5675. .ignore_pmdown_time = 1,
  5676. /* this dainlink has playback support */
  5677. .id = MSM_FRONTEND_DAI_MULTIMEDIA10,
  5678. SND_SOC_DAILINK_REG(multimedia10),
  5679. },
  5680. };
  5681. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  5682. /* Backend AFE DAI Links */
  5683. {
  5684. .name = LPASS_BE_AFE_PCM_RX,
  5685. .stream_name = "AFE Playback",
  5686. .no_pcm = 1,
  5687. .dpcm_playback = 1,
  5688. .id = MSM_BACKEND_DAI_AFE_PCM_RX,
  5689. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5690. /* this dainlink has playback support */
  5691. .ignore_pmdown_time = 1,
  5692. .ignore_suspend = 1,
  5693. SND_SOC_DAILINK_REG(afe_pcm_rx),
  5694. },
  5695. {
  5696. .name = LPASS_BE_AFE_PCM_TX,
  5697. .stream_name = "AFE Capture",
  5698. .no_pcm = 1,
  5699. .dpcm_capture = 1,
  5700. .id = MSM_BACKEND_DAI_AFE_PCM_TX,
  5701. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5702. .ignore_suspend = 1,
  5703. SND_SOC_DAILINK_REG(afe_pcm_tx),
  5704. },
  5705. /* Incall Record Uplink BACK END DAI Link */
  5706. {
  5707. .name = LPASS_BE_INCALL_RECORD_TX,
  5708. .stream_name = "Voice Uplink Capture",
  5709. .no_pcm = 1,
  5710. .dpcm_capture = 1,
  5711. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  5712. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5713. .ignore_suspend = 1,
  5714. SND_SOC_DAILINK_REG(incall_record_tx),
  5715. },
  5716. /* Incall Record Downlink BACK END DAI Link */
  5717. {
  5718. .name = LPASS_BE_INCALL_RECORD_RX,
  5719. .stream_name = "Voice Downlink Capture",
  5720. .no_pcm = 1,
  5721. .dpcm_capture = 1,
  5722. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  5723. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5724. .ignore_suspend = 1,
  5725. SND_SOC_DAILINK_REG(incall_record_rx),
  5726. },
  5727. /* Incall Music BACK END DAI Link */
  5728. {
  5729. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  5730. .stream_name = "Voice Farend Playback",
  5731. .no_pcm = 1,
  5732. .dpcm_playback = 1,
  5733. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  5734. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5735. .ignore_suspend = 1,
  5736. .ignore_pmdown_time = 1,
  5737. SND_SOC_DAILINK_REG(voice_playback_tx),
  5738. },
  5739. /* Incall Music 2 BACK END DAI Link */
  5740. {
  5741. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  5742. .stream_name = "Voice2 Farend Playback",
  5743. .no_pcm = 1,
  5744. .dpcm_playback = 1,
  5745. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  5746. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5747. .ignore_suspend = 1,
  5748. .ignore_pmdown_time = 1,
  5749. SND_SOC_DAILINK_REG(voice2_playback_tx),
  5750. },
  5751. /* Proxy Tx BACK END DAI Link */
  5752. {
  5753. .name = LPASS_BE_PROXY_TX,
  5754. .stream_name = "Proxy Capture",
  5755. .no_pcm = 1,
  5756. .dpcm_capture = 1,
  5757. .id = MSM_BACKEND_DAI_PROXY_TX,
  5758. .ignore_suspend = 1,
  5759. SND_SOC_DAILINK_REG(proxy_tx),
  5760. },
  5761. /* Proxy Rx BACK END DAI Link */
  5762. {
  5763. .name = LPASS_BE_PROXY_RX,
  5764. .stream_name = "Proxy Playback",
  5765. .no_pcm = 1,
  5766. .dpcm_playback = 1,
  5767. .id = MSM_BACKEND_DAI_PROXY_RX,
  5768. .ignore_pmdown_time = 1,
  5769. .ignore_suspend = 1,
  5770. SND_SOC_DAILINK_REG(proxy_rx),
  5771. },
  5772. {
  5773. .name = LPASS_BE_USB_AUDIO_RX,
  5774. .stream_name = "USB Audio Playback",
  5775. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  5776. .dynamic_be = 1,
  5777. #endif /* CONFIG_AUDIO_QGKI */
  5778. .no_pcm = 1,
  5779. .dpcm_playback = 1,
  5780. .id = MSM_BACKEND_DAI_USB_RX,
  5781. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5782. .ignore_pmdown_time = 1,
  5783. .ignore_suspend = 1,
  5784. SND_SOC_DAILINK_REG(usb_audio_rx),
  5785. },
  5786. {
  5787. .name = LPASS_BE_USB_AUDIO_TX,
  5788. .stream_name = "USB Audio Capture",
  5789. .no_pcm = 1,
  5790. .dpcm_capture = 1,
  5791. .id = MSM_BACKEND_DAI_USB_TX,
  5792. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5793. .ignore_suspend = 1,
  5794. SND_SOC_DAILINK_REG(usb_audio_tx),
  5795. },
  5796. {
  5797. .name = LPASS_BE_PRI_TDM_RX_0,
  5798. .stream_name = "Primary TDM0 Playback",
  5799. .no_pcm = 1,
  5800. .dpcm_playback = 1,
  5801. .id = MSM_BACKEND_DAI_PRI_TDM_RX_0,
  5802. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5803. .ops = &lahaina_tdm_be_ops,
  5804. .ignore_suspend = 1,
  5805. .ignore_pmdown_time = 1,
  5806. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  5807. },
  5808. {
  5809. .name = LPASS_BE_PRI_TDM_TX_0,
  5810. .stream_name = "Primary TDM0 Capture",
  5811. .no_pcm = 1,
  5812. .dpcm_capture = 1,
  5813. .id = MSM_BACKEND_DAI_PRI_TDM_TX_0,
  5814. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5815. .ops = &lahaina_tdm_be_ops,
  5816. .ignore_suspend = 1,
  5817. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  5818. },
  5819. {
  5820. .name = LPASS_BE_SEC_TDM_RX_0,
  5821. .stream_name = "Secondary TDM0 Playback",
  5822. .no_pcm = 1,
  5823. .dpcm_playback = 1,
  5824. .id = MSM_BACKEND_DAI_SEC_TDM_RX_0,
  5825. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5826. .ops = &lahaina_tdm_be_ops,
  5827. .ignore_suspend = 1,
  5828. .ignore_pmdown_time = 1,
  5829. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  5830. },
  5831. {
  5832. .name = LPASS_BE_SEC_TDM_TX_0,
  5833. .stream_name = "Secondary TDM0 Capture",
  5834. .no_pcm = 1,
  5835. .dpcm_capture = 1,
  5836. .id = MSM_BACKEND_DAI_SEC_TDM_TX_0,
  5837. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5838. .ops = &lahaina_tdm_be_ops,
  5839. .ignore_suspend = 1,
  5840. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  5841. },
  5842. {
  5843. .name = LPASS_BE_TERT_TDM_RX_0,
  5844. .stream_name = "Tertiary TDM0 Playback",
  5845. .no_pcm = 1,
  5846. .dpcm_playback = 1,
  5847. .id = MSM_BACKEND_DAI_TERT_TDM_RX_0,
  5848. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5849. .ops = &lahaina_tdm_be_ops,
  5850. .ignore_suspend = 1,
  5851. .ignore_pmdown_time = 1,
  5852. SND_SOC_DAILINK_REG(tert_tdm_rx_0),
  5853. },
  5854. {
  5855. .name = LPASS_BE_TERT_TDM_TX_0,
  5856. .stream_name = "Tertiary TDM0 Capture",
  5857. .no_pcm = 1,
  5858. .dpcm_capture = 1,
  5859. .id = MSM_BACKEND_DAI_TERT_TDM_TX_0,
  5860. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5861. .ops = &lahaina_tdm_be_ops,
  5862. .ignore_suspend = 1,
  5863. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  5864. },
  5865. {
  5866. .name = LPASS_BE_QUAT_TDM_RX_0,
  5867. .stream_name = "Quaternary TDM0 Playback",
  5868. .no_pcm = 1,
  5869. .dpcm_playback = 1,
  5870. .id = MSM_BACKEND_DAI_QUAT_TDM_RX_0,
  5871. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5872. .ops = &lahaina_tdm_be_ops,
  5873. .ignore_suspend = 1,
  5874. .ignore_pmdown_time = 1,
  5875. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  5876. },
  5877. {
  5878. .name = LPASS_BE_QUAT_TDM_TX_0,
  5879. .stream_name = "Quaternary TDM0 Capture",
  5880. .no_pcm = 1,
  5881. .dpcm_capture = 1,
  5882. .id = MSM_BACKEND_DAI_QUAT_TDM_TX_0,
  5883. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5884. .ops = &lahaina_tdm_be_ops,
  5885. .ignore_suspend = 1,
  5886. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  5887. },
  5888. {
  5889. .name = LPASS_BE_QUIN_TDM_RX_0,
  5890. .stream_name = "Quinary TDM0 Playback",
  5891. .no_pcm = 1,
  5892. .dpcm_playback = 1,
  5893. .id = MSM_BACKEND_DAI_QUIN_TDM_RX_0,
  5894. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5895. .ops = &lahaina_tdm_be_ops,
  5896. .ignore_suspend = 1,
  5897. .ignore_pmdown_time = 1,
  5898. SND_SOC_DAILINK_REG(quin_tdm_rx_0),
  5899. },
  5900. {
  5901. .name = LPASS_BE_QUIN_TDM_TX_0,
  5902. .stream_name = "Quinary TDM0 Capture",
  5903. .no_pcm = 1,
  5904. .dpcm_capture = 1,
  5905. .id = MSM_BACKEND_DAI_QUIN_TDM_TX_0,
  5906. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5907. .ops = &lahaina_tdm_be_ops,
  5908. .ignore_suspend = 1,
  5909. SND_SOC_DAILINK_REG(quin_tdm_tx_0),
  5910. },
  5911. {
  5912. .name = LPASS_BE_SEN_TDM_RX_0,
  5913. .stream_name = "Senary TDM0 Playback",
  5914. .no_pcm = 1,
  5915. .dpcm_playback = 1,
  5916. .id = MSM_BACKEND_DAI_SEN_TDM_RX_0,
  5917. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5918. .ops = &lahaina_tdm_be_ops,
  5919. .ignore_suspend = 1,
  5920. .ignore_pmdown_time = 1,
  5921. SND_SOC_DAILINK_REG(sen_tdm_rx_0),
  5922. },
  5923. {
  5924. .name = LPASS_BE_SEN_TDM_TX_0,
  5925. .stream_name = "Senary TDM0 Capture",
  5926. .no_pcm = 1,
  5927. .dpcm_capture = 1,
  5928. .id = MSM_BACKEND_DAI_SEN_TDM_TX_0,
  5929. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5930. .ops = &lahaina_tdm_be_ops,
  5931. .ignore_suspend = 1,
  5932. SND_SOC_DAILINK_REG(sen_tdm_tx_0),
  5933. },
  5934. };
  5935. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  5936. {
  5937. .name = LPASS_BE_SLIMBUS_7_RX,
  5938. .stream_name = "Slimbus7 Playback",
  5939. .no_pcm = 1,
  5940. .dpcm_playback = 1,
  5941. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5942. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5943. .init = &msm_wcn_init,
  5944. .ops = &msm_wcn_ops,
  5945. /* dai link has playback support */
  5946. .ignore_pmdown_time = 1,
  5947. .ignore_suspend = 1,
  5948. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5949. },
  5950. {
  5951. .name = LPASS_BE_SLIMBUS_7_TX,
  5952. .stream_name = "Slimbus7 Capture",
  5953. .no_pcm = 1,
  5954. .dpcm_capture = 1,
  5955. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5956. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5957. .ops = &msm_wcn_ops,
  5958. .ignore_suspend = 1,
  5959. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5960. },
  5961. };
  5962. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  5963. {
  5964. .name = LPASS_BE_SLIMBUS_7_RX,
  5965. .stream_name = "Slimbus7 Playback",
  5966. .no_pcm = 1,
  5967. .dpcm_playback = 1,
  5968. .id = MSM_BACKEND_DAI_SLIMBUS_7_RX,
  5969. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5970. .init = &msm_wcn_init_lito,
  5971. .ops = &msm_wcn_ops_lito,
  5972. /* dai link has playback support */
  5973. .ignore_pmdown_time = 1,
  5974. .ignore_suspend = 1,
  5975. SND_SOC_DAILINK_REG(slimbus_7_rx),
  5976. },
  5977. {
  5978. .name = LPASS_BE_SLIMBUS_7_TX,
  5979. .stream_name = "Slimbus7 Capture",
  5980. .no_pcm = 1,
  5981. .dpcm_capture = 1,
  5982. .id = MSM_BACKEND_DAI_SLIMBUS_7_TX,
  5983. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5984. .ops = &msm_wcn_ops_lito,
  5985. .ignore_suspend = 1,
  5986. SND_SOC_DAILINK_REG(slimbus_7_tx),
  5987. },
  5988. {
  5989. .name = LPASS_BE_SLIMBUS_8_TX,
  5990. .stream_name = "Slimbus8 Capture",
  5991. .no_pcm = 1,
  5992. .dpcm_capture = 1,
  5993. .id = MSM_BACKEND_DAI_SLIMBUS_8_TX,
  5994. .be_hw_params_fixup = msm_be_hw_params_fixup,
  5995. .ops = &msm_wcn_ops_lito,
  5996. .ignore_suspend = 1,
  5997. SND_SOC_DAILINK_REG(slimbus_8_tx),
  5998. },
  5999. };
  6000. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6001. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  6002. /* DISP PORT BACK END DAI Link */
  6003. {
  6004. .name = LPASS_BE_DISPLAY_PORT,
  6005. .stream_name = "Display Port Playback",
  6006. .no_pcm = 1,
  6007. .dpcm_playback = 1,
  6008. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX,
  6009. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6010. .ignore_pmdown_time = 1,
  6011. .ignore_suspend = 1,
  6012. SND_SOC_DAILINK_REG(display_port),
  6013. },
  6014. /* DISP PORT 1 BACK END DAI Link */
  6015. {
  6016. .name = LPASS_BE_DISPLAY_PORT1,
  6017. .stream_name = "Display Port1 Playback",
  6018. .no_pcm = 1,
  6019. .dpcm_playback = 1,
  6020. .id = MSM_BACKEND_DAI_DISPLAY_PORT_RX_1,
  6021. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6022. .ignore_pmdown_time = 1,
  6023. .ignore_suspend = 1,
  6024. SND_SOC_DAILINK_REG(display_port1),
  6025. },
  6026. };
  6027. #endif
  6028. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  6029. {
  6030. .name = LPASS_BE_PRI_MI2S_RX,
  6031. .stream_name = "Primary MI2S Playback",
  6032. .no_pcm = 1,
  6033. .dpcm_playback = 1,
  6034. .id = MSM_BACKEND_DAI_PRI_MI2S_RX,
  6035. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6036. .ops = &msm_mi2s_be_ops,
  6037. .ignore_suspend = 1,
  6038. .ignore_pmdown_time = 1,
  6039. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  6040. },
  6041. {
  6042. .name = LPASS_BE_PRI_MI2S_TX,
  6043. .stream_name = "Primary MI2S Capture",
  6044. .no_pcm = 1,
  6045. .dpcm_capture = 1,
  6046. .id = MSM_BACKEND_DAI_PRI_MI2S_TX,
  6047. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6048. .ops = &msm_mi2s_be_ops,
  6049. .ignore_suspend = 1,
  6050. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  6051. },
  6052. {
  6053. .name = LPASS_BE_SEC_MI2S_RX,
  6054. .stream_name = "Secondary MI2S Playback",
  6055. .no_pcm = 1,
  6056. .dpcm_playback = 1,
  6057. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_RX,
  6058. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6059. .ops = &msm_mi2s_be_ops,
  6060. .ignore_suspend = 1,
  6061. .ignore_pmdown_time = 1,
  6062. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  6063. },
  6064. {
  6065. .name = LPASS_BE_SEC_MI2S_TX,
  6066. .stream_name = "Secondary MI2S Capture",
  6067. .no_pcm = 1,
  6068. .dpcm_capture = 1,
  6069. .id = MSM_BACKEND_DAI_SECONDARY_MI2S_TX,
  6070. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6071. .ops = &msm_mi2s_be_ops,
  6072. .ignore_suspend = 1,
  6073. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  6074. },
  6075. {
  6076. .name = LPASS_BE_TERT_MI2S_RX,
  6077. .stream_name = "Tertiary MI2S Playback",
  6078. .no_pcm = 1,
  6079. .dpcm_playback = 1,
  6080. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_RX,
  6081. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6082. .ops = &msm_mi2s_be_ops,
  6083. .ignore_suspend = 1,
  6084. .ignore_pmdown_time = 1,
  6085. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  6086. },
  6087. {
  6088. .name = LPASS_BE_TERT_MI2S_TX,
  6089. .stream_name = "Tertiary MI2S Capture",
  6090. .no_pcm = 1,
  6091. .dpcm_capture = 1,
  6092. .id = MSM_BACKEND_DAI_TERTIARY_MI2S_TX,
  6093. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6094. .ops = &msm_mi2s_be_ops,
  6095. .ignore_suspend = 1,
  6096. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  6097. },
  6098. {
  6099. .name = LPASS_BE_QUAT_MI2S_RX,
  6100. .stream_name = "Quaternary MI2S Playback",
  6101. .no_pcm = 1,
  6102. .dpcm_playback = 1,
  6103. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_RX,
  6104. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6105. .ops = &msm_mi2s_be_ops,
  6106. .ignore_suspend = 1,
  6107. .ignore_pmdown_time = 1,
  6108. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  6109. },
  6110. {
  6111. .name = LPASS_BE_QUAT_MI2S_TX,
  6112. .stream_name = "Quaternary MI2S Capture",
  6113. .no_pcm = 1,
  6114. .dpcm_capture = 1,
  6115. .id = MSM_BACKEND_DAI_QUATERNARY_MI2S_TX,
  6116. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6117. .ops = &msm_mi2s_be_ops,
  6118. .ignore_suspend = 1,
  6119. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  6120. },
  6121. {
  6122. .name = LPASS_BE_QUIN_MI2S_RX,
  6123. .stream_name = "Quinary MI2S Playback",
  6124. .no_pcm = 1,
  6125. .dpcm_playback = 1,
  6126. .id = MSM_BACKEND_DAI_QUINARY_MI2S_RX,
  6127. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6128. .ops = &msm_mi2s_be_ops,
  6129. .ignore_suspend = 1,
  6130. .ignore_pmdown_time = 1,
  6131. SND_SOC_DAILINK_REG(quin_mi2s_rx),
  6132. },
  6133. {
  6134. .name = LPASS_BE_QUIN_MI2S_TX,
  6135. .stream_name = "Quinary MI2S Capture",
  6136. .no_pcm = 1,
  6137. .dpcm_capture = 1,
  6138. .id = MSM_BACKEND_DAI_QUINARY_MI2S_TX,
  6139. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6140. .ops = &msm_mi2s_be_ops,
  6141. .ignore_suspend = 1,
  6142. SND_SOC_DAILINK_REG(quin_mi2s_tx),
  6143. },
  6144. {
  6145. .name = LPASS_BE_SENARY_MI2S_RX,
  6146. .stream_name = "Senary MI2S Playback",
  6147. .no_pcm = 1,
  6148. .dpcm_playback = 1,
  6149. .id = MSM_BACKEND_DAI_SENARY_MI2S_RX,
  6150. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6151. .ops = &msm_mi2s_be_ops,
  6152. .ignore_suspend = 1,
  6153. .ignore_pmdown_time = 1,
  6154. SND_SOC_DAILINK_REG(sen_mi2s_rx),
  6155. },
  6156. {
  6157. .name = LPASS_BE_SENARY_MI2S_TX,
  6158. .stream_name = "Senary MI2S Capture",
  6159. .no_pcm = 1,
  6160. .dpcm_capture = 1,
  6161. .id = MSM_BACKEND_DAI_SENARY_MI2S_TX,
  6162. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6163. .ops = &msm_mi2s_be_ops,
  6164. .ignore_suspend = 1,
  6165. SND_SOC_DAILINK_REG(sen_mi2s_tx),
  6166. },
  6167. };
  6168. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  6169. /* Primary AUX PCM Backend DAI Links */
  6170. {
  6171. .name = LPASS_BE_AUXPCM_RX,
  6172. .stream_name = "AUX PCM Playback",
  6173. .no_pcm = 1,
  6174. .dpcm_playback = 1,
  6175. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6176. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6177. .ops = &lahaina_aux_be_ops,
  6178. .ignore_pmdown_time = 1,
  6179. .ignore_suspend = 1,
  6180. SND_SOC_DAILINK_REG(auxpcm_rx),
  6181. },
  6182. {
  6183. .name = LPASS_BE_AUXPCM_TX,
  6184. .stream_name = "AUX PCM Capture",
  6185. .no_pcm = 1,
  6186. .dpcm_capture = 1,
  6187. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6188. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6189. .ops = &lahaina_aux_be_ops,
  6190. .ignore_suspend = 1,
  6191. SND_SOC_DAILINK_REG(auxpcm_tx),
  6192. },
  6193. /* Secondary AUX PCM Backend DAI Links */
  6194. {
  6195. .name = LPASS_BE_SEC_AUXPCM_RX,
  6196. .stream_name = "Sec AUX PCM Playback",
  6197. .no_pcm = 1,
  6198. .dpcm_playback = 1,
  6199. .id = MSM_BACKEND_DAI_SEC_AUXPCM_RX,
  6200. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6201. .ops = &lahaina_aux_be_ops,
  6202. .ignore_pmdown_time = 1,
  6203. .ignore_suspend = 1,
  6204. SND_SOC_DAILINK_REG(sec_auxpcm_rx),
  6205. },
  6206. {
  6207. .name = LPASS_BE_SEC_AUXPCM_TX,
  6208. .stream_name = "Sec AUX PCM Capture",
  6209. .no_pcm = 1,
  6210. .dpcm_capture = 1,
  6211. .id = MSM_BACKEND_DAI_SEC_AUXPCM_TX,
  6212. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6213. .ops = &lahaina_aux_be_ops,
  6214. .ignore_suspend = 1,
  6215. SND_SOC_DAILINK_REG(sec_auxpcm_tx),
  6216. },
  6217. /* Tertiary AUX PCM Backend DAI Links */
  6218. {
  6219. .name = LPASS_BE_TERT_AUXPCM_RX,
  6220. .stream_name = "Tert AUX PCM Playback",
  6221. .no_pcm = 1,
  6222. .dpcm_playback = 1,
  6223. .id = MSM_BACKEND_DAI_TERT_AUXPCM_RX,
  6224. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6225. .ops = &lahaina_aux_be_ops,
  6226. .ignore_suspend = 1,
  6227. SND_SOC_DAILINK_REG(tert_auxpcm_rx),
  6228. },
  6229. {
  6230. .name = LPASS_BE_TERT_AUXPCM_TX,
  6231. .stream_name = "Tert AUX PCM Capture",
  6232. .no_pcm = 1,
  6233. .dpcm_capture = 1,
  6234. .id = MSM_BACKEND_DAI_TERT_AUXPCM_TX,
  6235. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6236. .ops = &lahaina_aux_be_ops,
  6237. .ignore_suspend = 1,
  6238. SND_SOC_DAILINK_REG(tert_auxpcm_tx),
  6239. },
  6240. /* Quaternary AUX PCM Backend DAI Links */
  6241. {
  6242. .name = LPASS_BE_QUAT_AUXPCM_RX,
  6243. .stream_name = "Quat AUX PCM Playback",
  6244. .no_pcm = 1,
  6245. .dpcm_playback = 1,
  6246. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_RX,
  6247. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6248. .ops = &lahaina_aux_be_ops,
  6249. .ignore_suspend = 1,
  6250. SND_SOC_DAILINK_REG(quat_auxpcm_rx),
  6251. },
  6252. {
  6253. .name = LPASS_BE_QUAT_AUXPCM_TX,
  6254. .stream_name = "Quat AUX PCM Capture",
  6255. .no_pcm = 1,
  6256. .dpcm_capture = 1,
  6257. .id = MSM_BACKEND_DAI_QUAT_AUXPCM_TX,
  6258. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6259. .ops = &lahaina_aux_be_ops,
  6260. .ignore_suspend = 1,
  6261. SND_SOC_DAILINK_REG(quat_auxpcm_tx),
  6262. },
  6263. /* Quinary AUX PCM Backend DAI Links */
  6264. {
  6265. .name = LPASS_BE_QUIN_AUXPCM_RX,
  6266. .stream_name = "Quin AUX PCM Playback",
  6267. .no_pcm = 1,
  6268. .dpcm_playback = 1,
  6269. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_RX,
  6270. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6271. .ops = &lahaina_aux_be_ops,
  6272. .ignore_suspend = 1,
  6273. SND_SOC_DAILINK_REG(quin_auxpcm_rx),
  6274. },
  6275. {
  6276. .name = LPASS_BE_QUIN_AUXPCM_TX,
  6277. .stream_name = "Quin AUX PCM Capture",
  6278. .no_pcm = 1,
  6279. .dpcm_capture = 1,
  6280. .id = MSM_BACKEND_DAI_QUIN_AUXPCM_TX,
  6281. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6282. .ops = &lahaina_aux_be_ops,
  6283. .ignore_suspend = 1,
  6284. SND_SOC_DAILINK_REG(quin_auxpcm_tx),
  6285. },
  6286. /* Senary AUX PCM Backend DAI Links */
  6287. {
  6288. .name = LPASS_BE_SEN_AUXPCM_RX,
  6289. .stream_name = "Sen AUX PCM Playback",
  6290. .no_pcm = 1,
  6291. .dpcm_playback = 1,
  6292. .id = MSM_BACKEND_DAI_SEN_AUXPCM_RX,
  6293. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6294. .ops = &lahaina_aux_be_ops,
  6295. .ignore_suspend = 1,
  6296. SND_SOC_DAILINK_REG(sen_auxpcm_rx),
  6297. },
  6298. {
  6299. .name = LPASS_BE_SEN_AUXPCM_TX,
  6300. .stream_name = "Sen AUX PCM Capture",
  6301. .no_pcm = 1,
  6302. .dpcm_capture = 1,
  6303. .id = MSM_BACKEND_DAI_SEN_AUXPCM_TX,
  6304. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6305. .ops = &lahaina_aux_be_ops,
  6306. .ignore_suspend = 1,
  6307. SND_SOC_DAILINK_REG(sen_auxpcm_tx),
  6308. },
  6309. };
  6310. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  6311. /* WSA CDC DMA Backend DAI Links */
  6312. {
  6313. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  6314. .stream_name = "WSA CDC DMA0 Playback",
  6315. .no_pcm = 1,
  6316. .dpcm_playback = 1,
  6317. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_0,
  6318. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6319. .ignore_pmdown_time = 1,
  6320. .ignore_suspend = 1,
  6321. .ops = &msm_cdc_dma_be_ops,
  6322. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  6323. .init = &msm_int_wsa_init,
  6324. },
  6325. {
  6326. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  6327. .stream_name = "WSA CDC DMA1 Playback",
  6328. .no_pcm = 1,
  6329. .dpcm_playback = 1,
  6330. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_RX_1,
  6331. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6332. .ignore_pmdown_time = 1,
  6333. .ignore_suspend = 1,
  6334. .ops = &msm_cdc_dma_be_ops,
  6335. SND_SOC_DAILINK_REG(wsa_dma_rx1),
  6336. },
  6337. {
  6338. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  6339. .stream_name = "WSA CDC DMA1 Capture",
  6340. .no_pcm = 1,
  6341. .dpcm_capture = 1,
  6342. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_1,
  6343. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6344. .ignore_suspend = 1,
  6345. .ops = &msm_cdc_dma_be_ops,
  6346. SND_SOC_DAILINK_REG(wsa_dma_tx1),
  6347. },
  6348. {
  6349. .name = LPASS_BE_WSA_CDC_DMA_TX_0_VI,
  6350. .stream_name = "WSA CDC DMA0 Capture",
  6351. .no_pcm = 1,
  6352. .dpcm_capture = 1,
  6353. .id = MSM_BACKEND_DAI_WSA_CDC_DMA_TX_0,
  6354. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6355. .ops = &msm_cdc_dma_be_ops,
  6356. .ignore_suspend = 1,
  6357. SND_SOC_DAILINK_REG(wsa_dma_tx0_vi),
  6358. },
  6359. };
  6360. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  6361. /* RX CDC DMA Backend DAI Links */
  6362. {
  6363. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  6364. .stream_name = "RX CDC DMA0 Playback",
  6365. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6366. .dynamic_be = 1,
  6367. #endif /* CONFIG_AUDIO_QGKI */
  6368. .no_pcm = 1,
  6369. .dpcm_playback = 1,
  6370. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_0,
  6371. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6372. .ignore_pmdown_time = 1,
  6373. .ignore_suspend = 1,
  6374. .ops = &msm_cdc_dma_be_ops,
  6375. SND_SOC_DAILINK_REG(rx_dma_rx0),
  6376. .init = &msm_rx_tx_codec_init,
  6377. },
  6378. {
  6379. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  6380. .stream_name = "RX CDC DMA1 Playback",
  6381. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6382. .dynamic_be = 1,
  6383. #endif /* CONFIG_AUDIO_QGKI */
  6384. .no_pcm = 1,
  6385. .dpcm_playback = 1,
  6386. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_1,
  6387. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6388. .ignore_pmdown_time = 1,
  6389. .ignore_suspend = 1,
  6390. .ops = &msm_cdc_dma_be_ops,
  6391. SND_SOC_DAILINK_REG(rx_dma_rx1),
  6392. },
  6393. {
  6394. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  6395. .stream_name = "RX CDC DMA2 Playback",
  6396. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6397. .dynamic_be = 1,
  6398. #endif /* CONFIG_AUDIO_QGKI */
  6399. .no_pcm = 1,
  6400. .dpcm_playback = 1,
  6401. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_2,
  6402. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6403. .ignore_pmdown_time = 1,
  6404. .ignore_suspend = 1,
  6405. .ops = &msm_cdc_dma_be_ops,
  6406. SND_SOC_DAILINK_REG(rx_dma_rx2),
  6407. },
  6408. {
  6409. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  6410. .stream_name = "RX CDC DMA3 Playback",
  6411. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6412. .dynamic_be = 1,
  6413. #endif /* CONFIG_AUDIO_QGKI */
  6414. .no_pcm = 1,
  6415. .dpcm_playback = 1,
  6416. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_3,
  6417. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6418. .ignore_pmdown_time = 1,
  6419. .ignore_suspend = 1,
  6420. .ops = &msm_cdc_dma_be_ops,
  6421. SND_SOC_DAILINK_REG(rx_dma_rx3),
  6422. },
  6423. {
  6424. .name = LPASS_BE_RX_CDC_DMA_RX_5,
  6425. .stream_name = "RX CDC DMA5 Playback",
  6426. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6427. .dynamic_be = 1,
  6428. #endif /* CONFIG_AUDIO_QGKI */
  6429. .no_pcm = 1,
  6430. .dpcm_playback = 1,
  6431. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_5,
  6432. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6433. .ignore_pmdown_time = 1,
  6434. .ignore_suspend = 1,
  6435. .ops = &msm_cdc_dma_be_ops,
  6436. SND_SOC_DAILINK_REG(rx_dma_rx5),
  6437. },
  6438. {
  6439. .name = LPASS_BE_RX_CDC_DMA_RX_6,
  6440. .stream_name = "RX CDC DMA6 Playback",
  6441. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6442. .dynamic_be = 1,
  6443. #endif /* CONFIG_AUDIO_QGKI */
  6444. .no_pcm = 1,
  6445. .dpcm_playback = 1,
  6446. .id = MSM_BACKEND_DAI_RX_CDC_DMA_RX_6,
  6447. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6448. .ignore_pmdown_time = 1,
  6449. .ignore_suspend = 1,
  6450. .ops = &msm_cdc_dma_be_ops,
  6451. SND_SOC_DAILINK_REG(rx_dma_rx6),
  6452. },
  6453. /* TX CDC DMA Backend DAI Links */
  6454. {
  6455. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  6456. .stream_name = "TX CDC DMA3 Capture",
  6457. .no_pcm = 1,
  6458. .dpcm_capture = 1,
  6459. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_3,
  6460. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6461. .ignore_suspend = 1,
  6462. .ops = &msm_cdc_dma_be_ops,
  6463. SND_SOC_DAILINK_REG(tx_dma_tx3),
  6464. },
  6465. {
  6466. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  6467. .stream_name = "TX CDC DMA4 Capture",
  6468. .no_pcm = 1,
  6469. .dpcm_capture = 1,
  6470. .id = MSM_BACKEND_DAI_TX_CDC_DMA_TX_4,
  6471. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6472. .ignore_suspend = 1,
  6473. .ops = &msm_cdc_dma_be_ops,
  6474. SND_SOC_DAILINK_REG(tx_dma_tx4),
  6475. },
  6476. };
  6477. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  6478. {
  6479. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  6480. .stream_name = "VA CDC DMA0 Capture",
  6481. .no_pcm = 1,
  6482. .dpcm_capture = 1,
  6483. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_0,
  6484. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6485. .ignore_suspend = 1,
  6486. .ops = &msm_cdc_dma_be_ops,
  6487. SND_SOC_DAILINK_REG(va_dma_tx0),
  6488. },
  6489. {
  6490. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  6491. .stream_name = "VA CDC DMA1 Capture",
  6492. .no_pcm = 1,
  6493. .dpcm_capture = 1,
  6494. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_1,
  6495. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6496. .ignore_suspend = 1,
  6497. .ops = &msm_cdc_dma_be_ops,
  6498. SND_SOC_DAILINK_REG(va_dma_tx1),
  6499. },
  6500. {
  6501. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  6502. .stream_name = "VA CDC DMA2 Capture",
  6503. .no_pcm = 1,
  6504. .dpcm_capture = 1,
  6505. .id = MSM_BACKEND_DAI_VA_CDC_DMA_TX_2,
  6506. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6507. .ignore_suspend = 1,
  6508. .ops = &msm_cdc_dma_be_ops,
  6509. SND_SOC_DAILINK_REG(va_dma_tx2),
  6510. },
  6511. };
  6512. static struct snd_soc_dai_link msm_afe_rxtx_lb_be_dai_link[] = {
  6513. {
  6514. .name = LPASS_BE_AFE_LOOPBACK_TX,
  6515. .stream_name = "AFE Loopback Capture",
  6516. .no_pcm = 1,
  6517. .dpcm_capture = 1,
  6518. .id = MSM_BACKEND_DAI_AFE_LOOPBACK_TX,
  6519. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6520. .ignore_pmdown_time = 1,
  6521. .ignore_suspend = 1,
  6522. SND_SOC_DAILINK_REG(afe_loopback_tx),
  6523. },
  6524. };
  6525. static struct snd_soc_dai_link msm_lahaina_dai_links[
  6526. ARRAY_SIZE(msm_common_dai_links) +
  6527. ARRAY_SIZE(msm_bolero_fe_dai_links) +
  6528. ARRAY_SIZE(msm_common_misc_fe_dai_links) +
  6529. ARRAY_SIZE(msm_common_be_dai_links) +
  6530. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  6531. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  6532. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  6533. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  6534. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  6535. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6536. ARRAY_SIZE(ext_disp_be_dai_link) +
  6537. #endif
  6538. ARRAY_SIZE(msm_wcn_be_dai_links) +
  6539. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link) +
  6540. ARRAY_SIZE(msm_wcn_btfm_be_dai_links)];
  6541. static int msm_populate_dai_link_component_of_node(
  6542. struct snd_soc_card *card)
  6543. {
  6544. int i, j, index, ret = 0;
  6545. struct device *cdev = card->dev;
  6546. struct snd_soc_dai_link *dai_link = card->dai_link;
  6547. struct device_node *np = NULL;
  6548. int codecs_enabled = 0;
  6549. struct snd_soc_dai_link_component *codecs_comp = NULL;
  6550. if (!cdev) {
  6551. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  6552. return -ENODEV;
  6553. }
  6554. for (i = 0; i < card->num_links; i++) {
  6555. if (dai_link[i].platforms->of_node && dai_link[i].cpus->of_node)
  6556. continue;
  6557. /* populate platform_of_node for snd card dai links */
  6558. if (dai_link[i].platforms->name &&
  6559. !dai_link[i].platforms->of_node) {
  6560. index = of_property_match_string(cdev->of_node,
  6561. "asoc-platform-names",
  6562. dai_link[i].platforms->name);
  6563. if (index < 0) {
  6564. dev_err(cdev, "%s: No match found for platform name: %s\n",
  6565. __func__, dai_link[i].platforms->name);
  6566. ret = index;
  6567. goto err;
  6568. }
  6569. np = of_parse_phandle(cdev->of_node, "asoc-platform",
  6570. index);
  6571. if (!np) {
  6572. dev_err(cdev, "%s: retrieving phandle for platform %s, index %d failed\n",
  6573. __func__, dai_link[i].platforms->name,
  6574. index);
  6575. ret = -ENODEV;
  6576. goto err;
  6577. }
  6578. dai_link[i].platforms->of_node = np;
  6579. dai_link[i].platforms->name = NULL;
  6580. }
  6581. /* populate cpu_of_node for snd card dai links */
  6582. if (dai_link[i].cpus->dai_name && !dai_link[i].cpus->of_node) {
  6583. index = of_property_match_string(cdev->of_node,
  6584. "asoc-cpu-names",
  6585. dai_link[i].cpus->dai_name);
  6586. if (index >= 0) {
  6587. np = of_parse_phandle(cdev->of_node, "asoc-cpu",
  6588. index);
  6589. if (!np) {
  6590. dev_err(cdev, "%s: retrieving phandle for cpu dai %s failed\n",
  6591. __func__,
  6592. dai_link[i].cpus->dai_name);
  6593. ret = -ENODEV;
  6594. goto err;
  6595. }
  6596. dai_link[i].cpus->of_node = np;
  6597. dai_link[i].cpus->dai_name = NULL;
  6598. }
  6599. }
  6600. /* populate codec_of_node for snd card dai links */
  6601. if (dai_link[i].num_codecs > 0) {
  6602. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6603. if (dai_link[i].codecs[j].of_node ||
  6604. !dai_link[i].codecs[j].name)
  6605. continue;
  6606. index = of_property_match_string(cdev->of_node,
  6607. "asoc-codec-names",
  6608. dai_link[i].codecs[j].name);
  6609. if (index < 0)
  6610. continue;
  6611. np = of_parse_phandle(cdev->of_node,
  6612. "asoc-codec",
  6613. index);
  6614. if (!np) {
  6615. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  6616. __func__,
  6617. dai_link[i].codecs[j].name);
  6618. ret = -ENODEV;
  6619. goto err;
  6620. }
  6621. dai_link[i].codecs[j].of_node = np;
  6622. dai_link[i].codecs[j].name = NULL;
  6623. }
  6624. }
  6625. }
  6626. /* In multi-codec scenario, check if codecs are enabled for this platform */
  6627. for (i = 0; i < card->num_links; i++) {
  6628. codecs_enabled = 0;
  6629. if (dai_link[i].num_codecs > 1) {
  6630. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6631. if (!dai_link[i].codecs[j].of_node)
  6632. continue;
  6633. np = dai_link[i].codecs[j].of_node;
  6634. if (!of_device_is_available(np)) {
  6635. dev_dbg(cdev, "%s: codec is disabled: %s\n",
  6636. __func__,
  6637. np->full_name);
  6638. dai_link[i].codecs[j].of_node = NULL;
  6639. continue;
  6640. }
  6641. codecs_enabled++;
  6642. }
  6643. if (codecs_enabled > 0 &&
  6644. codecs_enabled < dai_link[i].num_codecs) {
  6645. codecs_comp = devm_kzalloc(cdev,
  6646. sizeof(struct snd_soc_dai_link_component)
  6647. * codecs_enabled, GFP_KERNEL);
  6648. if (!codecs_comp) {
  6649. dev_err(cdev, "%s: %s dailink codec component alloc failed\n",
  6650. __func__, dai_link[i].name);
  6651. ret = -ENOMEM;
  6652. goto err;
  6653. }
  6654. index = 0;
  6655. for (j = 0; j < dai_link[i].num_codecs; j++) {
  6656. if(dai_link[i].codecs[j].of_node) {
  6657. codecs_comp[index].of_node =
  6658. dai_link[i].codecs[j].of_node;
  6659. codecs_comp[index].dai_name =
  6660. dai_link[i].codecs[j].dai_name;
  6661. codecs_comp[index].name = NULL;
  6662. index++;
  6663. }
  6664. }
  6665. dai_link[i].codecs = codecs_comp;
  6666. dai_link[i].num_codecs = codecs_enabled;
  6667. }
  6668. }
  6669. }
  6670. err:
  6671. return ret;
  6672. }
  6673. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  6674. {
  6675. int ret = -EINVAL;
  6676. struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, "msm-stub-codec");
  6677. if (!component) {
  6678. pr_err("* %s: No match for msm-stub-codec component\n", __func__);
  6679. return ret;
  6680. }
  6681. ret = snd_soc_add_component_controls(component, msm_snd_controls,
  6682. ARRAY_SIZE(msm_snd_controls));
  6683. if (ret < 0) {
  6684. dev_err(component->dev,
  6685. "%s: add_codec_controls failed, err = %d\n",
  6686. __func__, ret);
  6687. return ret;
  6688. }
  6689. return ret;
  6690. }
  6691. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  6692. struct snd_pcm_hw_params *params)
  6693. {
  6694. return 0;
  6695. }
  6696. static struct snd_soc_ops msm_stub_be_ops = {
  6697. .hw_params = msm_snd_stub_hw_params,
  6698. };
  6699. struct snd_soc_card snd_soc_card_stub_msm = {
  6700. .name = "lahaina-stub-snd-card",
  6701. };
  6702. static struct snd_soc_dai_link msm_stub_fe_dai_links[] = {
  6703. /* FrontEnd DAI Links */
  6704. {
  6705. .name = "MSMSTUB Media1",
  6706. .stream_name = "MultiMedia1",
  6707. .dynamic = 1,
  6708. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6709. .async_ops = ASYNC_DPCM_SND_SOC_PREPARE,
  6710. #endif /* CONFIG_AUDIO_QGKI */
  6711. .dpcm_playback = 1,
  6712. .dpcm_capture = 1,
  6713. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  6714. SND_SOC_DPCM_TRIGGER_POST},
  6715. .ignore_suspend = 1,
  6716. /* this dainlink has playback support */
  6717. .ignore_pmdown_time = 1,
  6718. .id = MSM_FRONTEND_DAI_MULTIMEDIA1,
  6719. SND_SOC_DAILINK_REG(multimedia1),
  6720. },
  6721. };
  6722. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  6723. /* Backend DAI Links */
  6724. {
  6725. .name = LPASS_BE_AUXPCM_RX,
  6726. .stream_name = "AUX PCM Playback",
  6727. .no_pcm = 1,
  6728. .dpcm_playback = 1,
  6729. .id = MSM_BACKEND_DAI_AUXPCM_RX,
  6730. .init = &msm_audrx_stub_init,
  6731. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6732. .ignore_pmdown_time = 1,
  6733. .ignore_suspend = 1,
  6734. .ops = &msm_stub_be_ops,
  6735. SND_SOC_DAILINK_REG(auxpcm_rx),
  6736. },
  6737. {
  6738. .name = LPASS_BE_AUXPCM_TX,
  6739. .stream_name = "AUX PCM Capture",
  6740. .no_pcm = 1,
  6741. .dpcm_capture = 1,
  6742. .id = MSM_BACKEND_DAI_AUXPCM_TX,
  6743. .be_hw_params_fixup = msm_be_hw_params_fixup,
  6744. .ignore_suspend = 1,
  6745. .ops = &msm_stub_be_ops,
  6746. SND_SOC_DAILINK_REG(auxpcm_tx),
  6747. },
  6748. };
  6749. static struct snd_soc_dai_link msm_stub_dai_links[
  6750. ARRAY_SIZE(msm_stub_fe_dai_links) +
  6751. ARRAY_SIZE(msm_stub_be_dai_links)];
  6752. static const struct of_device_id lahaina_asoc_machine_of_match[] = {
  6753. { .compatible = "qcom,lahaina-asoc-snd",
  6754. .data = "codec"},
  6755. { .compatible = "qcom,lahaina-asoc-snd-stub",
  6756. .data = "stub_codec"},
  6757. {},
  6758. };
  6759. static int msm_snd_card_late_probe(struct snd_soc_card *card)
  6760. {
  6761. struct snd_soc_component *component = NULL;
  6762. const char *be_dl_name = LPASS_BE_RX_CDC_DMA_RX_0;
  6763. struct snd_soc_pcm_runtime *rtd;
  6764. struct msm_asoc_mach_data *pdata;
  6765. int ret = 0;
  6766. void *mbhc_calibration;
  6767. pdata = snd_soc_card_get_drvdata(card);
  6768. if (!pdata)
  6769. return -EINVAL;
  6770. if (pdata->wcd_disabled)
  6771. return 0;
  6772. rtd = snd_soc_get_pcm_runtime(card, be_dl_name);
  6773. if (!rtd) {
  6774. dev_err(card->dev,
  6775. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  6776. __func__, be_dl_name);
  6777. return -EINVAL;
  6778. }
  6779. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  6780. if (!component) {
  6781. pr_err("%s component is NULL\n", __func__);
  6782. return -EINVAL;
  6783. }
  6784. mbhc_calibration = def_wcd_mbhc_cal();
  6785. if (!mbhc_calibration)
  6786. return -ENOMEM;
  6787. wcd_mbhc_cfg.calibration = mbhc_calibration;
  6788. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  6789. if (ret) {
  6790. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  6791. __func__, ret);
  6792. goto err_hs_detect;
  6793. }
  6794. return 0;
  6795. err_hs_detect:
  6796. kfree(mbhc_calibration);
  6797. return ret;
  6798. }
  6799. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  6800. {
  6801. struct snd_soc_card *card = NULL;
  6802. struct snd_soc_dai_link *dailink = NULL;
  6803. int len_1 = 0;
  6804. int len_2 = 0;
  6805. int total_links = 0;
  6806. int rc = 0;
  6807. u32 mi2s_audio_intf = 0;
  6808. u32 auxpcm_audio_intf = 0;
  6809. u32 val = 0;
  6810. u32 wcn_btfm_intf = 0;
  6811. const struct of_device_id *match;
  6812. u32 wsa_max_devs = 0;
  6813. match = of_match_node(lahaina_asoc_machine_of_match, dev->of_node);
  6814. if (!match) {
  6815. dev_err(dev, "%s: No DT match found for sound card\n",
  6816. __func__);
  6817. return NULL;
  6818. }
  6819. if (!strcmp(match->data, "codec")) {
  6820. card = &snd_soc_card_lahaina_msm;
  6821. memcpy(msm_lahaina_dai_links + total_links,
  6822. msm_common_dai_links,
  6823. sizeof(msm_common_dai_links));
  6824. total_links += ARRAY_SIZE(msm_common_dai_links);
  6825. rc = of_property_read_u32(dev->of_node,
  6826. "qcom,wsa-max-devs", &wsa_max_devs);
  6827. if (rc) {
  6828. dev_info(dev,
  6829. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  6830. __func__, dev->of_node->full_name, rc);
  6831. wsa_max_devs = 0;
  6832. }
  6833. if (!wsa_max_devs) {
  6834. memcpy(msm_lahaina_dai_links + total_links,
  6835. msm_bolero_fe_stub_dai_links,
  6836. sizeof(msm_bolero_fe_stub_dai_links));
  6837. total_links +=
  6838. ARRAY_SIZE(msm_bolero_fe_stub_dai_links);
  6839. } else {
  6840. memcpy(msm_lahaina_dai_links + total_links,
  6841. msm_bolero_fe_dai_links,
  6842. sizeof(msm_bolero_fe_dai_links));
  6843. total_links +=
  6844. ARRAY_SIZE(msm_bolero_fe_dai_links);
  6845. }
  6846. memcpy(msm_lahaina_dai_links + total_links,
  6847. msm_common_misc_fe_dai_links,
  6848. sizeof(msm_common_misc_fe_dai_links));
  6849. total_links += ARRAY_SIZE(msm_common_misc_fe_dai_links);
  6850. memcpy(msm_lahaina_dai_links + total_links,
  6851. msm_common_be_dai_links,
  6852. sizeof(msm_common_be_dai_links));
  6853. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  6854. memcpy(msm_lahaina_dai_links + total_links,
  6855. msm_rx_tx_cdc_dma_be_dai_links,
  6856. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  6857. total_links +=
  6858. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  6859. if (wsa_max_devs) {
  6860. memcpy(msm_lahaina_dai_links + total_links,
  6861. msm_wsa_cdc_dma_be_dai_links,
  6862. sizeof(msm_wsa_cdc_dma_be_dai_links));
  6863. total_links +=
  6864. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  6865. }
  6866. memcpy(msm_lahaina_dai_links + total_links,
  6867. msm_va_cdc_dma_be_dai_links,
  6868. sizeof(msm_va_cdc_dma_be_dai_links));
  6869. total_links +=
  6870. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  6871. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  6872. &mi2s_audio_intf);
  6873. if (rc) {
  6874. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  6875. __func__);
  6876. } else {
  6877. if (mi2s_audio_intf) {
  6878. memcpy(msm_lahaina_dai_links + total_links,
  6879. msm_mi2s_be_dai_links,
  6880. sizeof(msm_mi2s_be_dai_links));
  6881. total_links +=
  6882. ARRAY_SIZE(msm_mi2s_be_dai_links);
  6883. }
  6884. }
  6885. rc = of_property_read_u32(dev->of_node,
  6886. "qcom,auxpcm-audio-intf",
  6887. &auxpcm_audio_intf);
  6888. if (rc) {
  6889. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  6890. __func__);
  6891. } else {
  6892. if (auxpcm_audio_intf) {
  6893. memcpy(msm_lahaina_dai_links + total_links,
  6894. msm_auxpcm_be_dai_links,
  6895. sizeof(msm_auxpcm_be_dai_links));
  6896. total_links +=
  6897. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  6898. }
  6899. }
  6900. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  6901. rc = of_property_read_u32(dev->of_node,
  6902. "qcom,ext-disp-audio-rx", &val);
  6903. if (!rc && val) {
  6904. dev_dbg(dev, "%s(): ext disp audio support present\n",
  6905. __func__);
  6906. memcpy(msm_lahaina_dai_links + total_links,
  6907. ext_disp_be_dai_link,
  6908. sizeof(ext_disp_be_dai_link));
  6909. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  6910. }
  6911. #endif
  6912. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  6913. if (!rc && val) {
  6914. dev_dbg(dev, "%s(): WCN BT support present\n",
  6915. __func__);
  6916. memcpy(msm_lahaina_dai_links + total_links,
  6917. msm_wcn_be_dai_links,
  6918. sizeof(msm_wcn_be_dai_links));
  6919. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  6920. }
  6921. rc = of_property_read_u32(dev->of_node, "qcom,afe-rxtx-lb",
  6922. &val);
  6923. if (!rc && val) {
  6924. memcpy(msm_lahaina_dai_links + total_links,
  6925. msm_afe_rxtx_lb_be_dai_link,
  6926. sizeof(msm_afe_rxtx_lb_be_dai_link));
  6927. total_links +=
  6928. ARRAY_SIZE(msm_afe_rxtx_lb_be_dai_link);
  6929. }
  6930. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  6931. &wcn_btfm_intf);
  6932. if (rc) {
  6933. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  6934. __func__);
  6935. } else {
  6936. if (wcn_btfm_intf) {
  6937. memcpy(msm_lahaina_dai_links + total_links,
  6938. msm_wcn_btfm_be_dai_links,
  6939. sizeof(msm_wcn_btfm_be_dai_links));
  6940. total_links +=
  6941. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  6942. }
  6943. }
  6944. dailink = msm_lahaina_dai_links;
  6945. } else if(!strcmp(match->data, "stub_codec")) {
  6946. card = &snd_soc_card_stub_msm;
  6947. len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
  6948. len_2 = len_1 + ARRAY_SIZE(msm_stub_be_dai_links);
  6949. memcpy(msm_stub_dai_links,
  6950. msm_stub_fe_dai_links,
  6951. sizeof(msm_stub_fe_dai_links));
  6952. memcpy(msm_stub_dai_links + len_1,
  6953. msm_stub_be_dai_links,
  6954. sizeof(msm_stub_be_dai_links));
  6955. dailink = msm_stub_dai_links;
  6956. total_links = len_2;
  6957. }
  6958. if (card) {
  6959. card->dai_link = dailink;
  6960. card->num_links = total_links;
  6961. card->late_probe = msm_snd_card_late_probe;
  6962. }
  6963. return card;
  6964. }
  6965. static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd)
  6966. {
  6967. u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6968. u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  6969. u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  6970. SPKR_L_BOOST, SPKR_L_VI};
  6971. u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  6972. SPKR_R_BOOST, SPKR_R_VI};
  6973. unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  6974. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
  6975. unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  6976. struct snd_soc_component *component = NULL;
  6977. struct snd_soc_dapm_context *dapm = NULL;
  6978. struct msm_asoc_mach_data *pdata =
  6979. snd_soc_card_get_drvdata(rtd->card);
  6980. int wsa_active_devs = 0;
  6981. if (pdata->wsa_max_devs > 0) {
  6982. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  6983. if (component) {
  6984. dapm = snd_soc_component_get_dapm(component);
  6985. wsa883x_set_channel_map(component, &spkleft_ports[0],
  6986. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  6987. &ch_rate[0], &spkleft_port_types[0]);
  6988. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  6989. component);
  6990. wsa_active_devs++;
  6991. } else {
  6992. pr_info("%s: wsa-codec.1 component is NULL\n", __func__);
  6993. }
  6994. }
  6995. /* If current platform has more than one WSA */
  6996. if (pdata->wsa_max_devs > wsa_active_devs) {
  6997. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  6998. if (!component) {
  6999. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  7000. pr_err("%s: %d WSA is found. Expect %d WSA.",
  7001. __func__, wsa_active_devs, pdata->wsa_max_devs);
  7002. return -EINVAL;
  7003. }
  7004. dapm = snd_soc_component_get_dapm(component);
  7005. wsa883x_set_channel_map(component, &spkright_ports[0],
  7006. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  7007. &ch_rate[0], &spkright_port_types[0]);
  7008. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  7009. component);
  7010. }
  7011. return 0;
  7012. }
  7013. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
  7014. {
  7015. struct snd_soc_component *component = NULL;
  7016. struct snd_soc_dapm_context *dapm = NULL;
  7017. int ret = 0;
  7018. int codec_variant = -1;
  7019. struct snd_info_entry *entry;
  7020. struct snd_card *card = NULL;
  7021. struct msm_asoc_mach_data *pdata;
  7022. pdata = snd_soc_card_get_drvdata(rtd->card);
  7023. if(!pdata)
  7024. return -EINVAL;
  7025. component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  7026. if (!component) {
  7027. pr_err("%s: could not find component for bolero_codec\n",
  7028. __func__);
  7029. return ret;
  7030. }
  7031. dapm = snd_soc_component_get_dapm(component);
  7032. ret = snd_soc_add_component_controls(component, msm_int_snd_controls,
  7033. ARRAY_SIZE(msm_int_snd_controls));
  7034. if (ret < 0) {
  7035. pr_err("%s: add_component_controls failed: %d\n",
  7036. __func__, ret);
  7037. return ret;
  7038. }
  7039. ret = snd_soc_add_component_controls(component, msm_common_snd_controls,
  7040. ARRAY_SIZE(msm_common_snd_controls));
  7041. if (ret < 0) {
  7042. pr_err("%s: add common snd controls failed: %d\n",
  7043. __func__, ret);
  7044. return ret;
  7045. }
  7046. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  7047. ARRAY_SIZE(msm_int_dapm_widgets));
  7048. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  7049. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  7050. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  7051. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  7052. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  7053. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  7054. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  7055. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  7056. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  7057. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  7058. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  7059. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  7060. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  7061. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK1 OUT");
  7062. snd_soc_dapm_ignore_suspend(dapm, "WSA_SPK2 OUT");
  7063. snd_soc_dapm_ignore_suspend(dapm, "WSA AIF VI");
  7064. snd_soc_dapm_ignore_suspend(dapm, "VIINPUT_WSA");
  7065. snd_soc_dapm_sync(dapm);
  7066. card = rtd->card->snd_card;
  7067. if (strnstr(rtd->card->name, "shima", strlen(rtd->card->name)) != NULL)
  7068. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map_shima),
  7069. sm_port_map_shima);
  7070. else
  7071. bolero_set_port_map(component, ARRAY_SIZE(sm_port_map),
  7072. sm_port_map);
  7073. if (!pdata->codec_root) {
  7074. entry = msm_snd_info_create_subdir(card->module, "codecs",
  7075. card->proc_root);
  7076. if (!entry) {
  7077. pr_debug("%s: Cannot create codecs module entry\n",
  7078. __func__);
  7079. return 0;
  7080. }
  7081. pdata->codec_root = entry;
  7082. }
  7083. bolero_info_create_codec_entry(pdata->codec_root, component);
  7084. bolero_register_wake_irq(component, false);
  7085. if (pdata->wcd_disabled) {
  7086. codec_reg_done = true;
  7087. return 0;
  7088. }
  7089. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  7090. if (!component) {
  7091. pr_err("%s component is NULL\n", __func__);
  7092. return -EINVAL;
  7093. }
  7094. dapm = snd_soc_component_get_dapm(component);
  7095. card = component->card->snd_card;
  7096. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  7097. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  7098. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  7099. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  7100. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  7101. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  7102. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  7103. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  7104. snd_soc_dapm_sync(dapm);
  7105. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  7106. codec_variant = wcd938x_get_codec_variant(component);
  7107. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  7108. if (codec_variant == WCD9380)
  7109. ret = snd_soc_add_component_controls(component,
  7110. msm_int_wcd9380_snd_controls,
  7111. ARRAY_SIZE(msm_int_wcd9380_snd_controls));
  7112. else if (codec_variant == WCD9385)
  7113. ret = snd_soc_add_component_controls(component,
  7114. msm_int_wcd9385_snd_controls,
  7115. ARRAY_SIZE(msm_int_wcd9385_snd_controls));
  7116. if (ret < 0) {
  7117. dev_err(component->dev, "%s: add codec specific snd controls failed: %d\n",
  7118. __func__, ret);
  7119. return ret;
  7120. }
  7121. codec_reg_done = true;
  7122. return 0;
  7123. }
  7124. static void msm_i2s_auxpcm_init(struct platform_device *pdev)
  7125. {
  7126. int count = 0;
  7127. u32 mi2s_master_slave[MI2S_MAX];
  7128. int ret = 0;
  7129. for (count = 0; count < MI2S_MAX; count++) {
  7130. mutex_init(&mi2s_intf_conf[count].lock);
  7131. mi2s_intf_conf[count].ref_cnt = 0;
  7132. }
  7133. ret = of_property_read_u32_array(pdev->dev.of_node,
  7134. "qcom,msm-mi2s-master",
  7135. mi2s_master_slave, MI2S_MAX);
  7136. if (ret) {
  7137. dev_dbg(&pdev->dev, "%s: no qcom,msm-mi2s-master in DT node\n",
  7138. __func__);
  7139. } else {
  7140. for (count = 0; count < MI2S_MAX; count++) {
  7141. mi2s_intf_conf[count].msm_is_mi2s_master =
  7142. mi2s_master_slave[count];
  7143. }
  7144. }
  7145. }
  7146. static void msm_i2s_auxpcm_deinit(void)
  7147. {
  7148. int count = 0;
  7149. for (count = 0; count < MI2S_MAX; count++) {
  7150. mutex_destroy(&mi2s_intf_conf[count].lock);
  7151. mi2s_intf_conf[count].ref_cnt = 0;
  7152. mi2s_intf_conf[count].msm_is_mi2s_master = 0;
  7153. }
  7154. }
  7155. static int lahaina_ssr_enable(struct device *dev, void *data)
  7156. {
  7157. struct platform_device *pdev = to_platform_device(dev);
  7158. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7159. int ret = 0;
  7160. if (!card) {
  7161. dev_err(dev, "%s: card is NULL\n", __func__);
  7162. ret = -EINVAL;
  7163. goto err;
  7164. }
  7165. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  7166. /* TODO */
  7167. dev_dbg(dev, "%s: TODO \n", __func__);
  7168. }
  7169. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  7170. snd_soc_card_change_online_state(card, 1);
  7171. #endif /* CONFIG_AUDIO_QGKI */
  7172. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  7173. err:
  7174. return ret;
  7175. }
  7176. static void lahaina_ssr_disable(struct device *dev, void *data)
  7177. {
  7178. struct platform_device *pdev = to_platform_device(dev);
  7179. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7180. if (!card) {
  7181. dev_err(dev, "%s: card is NULL\n", __func__);
  7182. return;
  7183. }
  7184. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  7185. #if IS_ENABLED(CONFIG_AUDIO_QGKI)
  7186. snd_soc_card_change_online_state(card, 0);
  7187. #endif /* CONFIG_AUDIO_QGKI */
  7188. if (!strcmp(card->name, "lahaina-stub-snd-card")) {
  7189. /* TODO */
  7190. dev_dbg(dev, "%s: TODO \n", __func__);
  7191. }
  7192. }
  7193. static const struct snd_event_ops lahaina_ssr_ops = {
  7194. .enable = lahaina_ssr_enable,
  7195. .disable = lahaina_ssr_disable,
  7196. };
  7197. static int msm_audio_ssr_compare(struct device *dev, void *data)
  7198. {
  7199. struct device_node *node = data;
  7200. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  7201. __func__, dev->of_node, node);
  7202. return (dev->of_node && dev->of_node == node);
  7203. }
  7204. static int msm_audio_ssr_register(struct device *dev)
  7205. {
  7206. struct device_node *np = dev->of_node;
  7207. struct snd_event_clients *ssr_clients = NULL;
  7208. struct device_node *node = NULL;
  7209. int ret = 0;
  7210. int i = 0;
  7211. for (i = 0; ; i++) {
  7212. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  7213. if (!node)
  7214. break;
  7215. snd_event_mstr_add_client(&ssr_clients,
  7216. msm_audio_ssr_compare, node);
  7217. }
  7218. ret = snd_event_master_register(dev, &lahaina_ssr_ops,
  7219. ssr_clients, NULL);
  7220. if (!ret)
  7221. snd_event_notify(dev, SND_EVENT_UP);
  7222. return ret;
  7223. }
  7224. static void parse_cps_configuration(struct platform_device *pdev,
  7225. struct msm_asoc_mach_data *pdata)
  7226. {
  7227. int ret = 0;
  7228. int i = 0, j = 0;
  7229. u32 dt_values[MAX_CPS_LEVELS];
  7230. if (!pdev || !pdata || !pdata->wsa_max_devs)
  7231. return;
  7232. pdata->get_wsa_dev_num = wsa883x_codec_get_dev_num;
  7233. pdata->cps_config.hw_reg_cfg.num_spkr = pdata->wsa_max_devs;
  7234. ret = of_property_read_u32_array(pdev->dev.of_node,
  7235. "qcom,cps_reg_phy_addr", dt_values,
  7236. sizeof(dt_values)/sizeof(dt_values[0]));
  7237. if (ret) {
  7238. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7239. __func__, "qcom,cps_reg_phy_addr");
  7240. } else {
  7241. pdata->cps_config.hw_reg_cfg.lpass_wr_cmd_reg_phy_addr =
  7242. dt_values[0];
  7243. pdata->cps_config.hw_reg_cfg.lpass_rd_cmd_reg_phy_addr =
  7244. dt_values[1];
  7245. pdata->cps_config.hw_reg_cfg.lpass_rd_fifo_reg_phy_addr =
  7246. dt_values[2];
  7247. }
  7248. ret = of_property_read_u32_array(pdev->dev.of_node,
  7249. "qcom,cps_threshold_levels", dt_values,
  7250. sizeof(dt_values)/sizeof(dt_values[0]) - 1);
  7251. if (ret) {
  7252. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7253. __func__, "qcom,cps_threshold_levels");
  7254. } else {
  7255. pdata->cps_config.hw_reg_cfg.vbatt_lower2_threshold =
  7256. dt_values[0];
  7257. pdata->cps_config.hw_reg_cfg.vbatt_lower1_threshold =
  7258. dt_values[1];
  7259. }
  7260. pdata->cps_config.spkr_dep_cfg = devm_kzalloc(&pdev->dev,
  7261. sizeof(struct lpass_swr_spkr_dep_cfg_t)
  7262. * pdata->wsa_max_devs, GFP_KERNEL);
  7263. if (!pdata->cps_config.spkr_dep_cfg) {
  7264. dev_err(&pdev->dev, "%s: spkr dep cfg alloc failed\n", __func__);
  7265. return;
  7266. }
  7267. ret = of_property_read_u32_array(pdev->dev.of_node,
  7268. "qcom,cps_wsa_vbatt_temp_reg_addr", dt_values,
  7269. sizeof(dt_values)/sizeof(dt_values[0]) - 1);
  7270. if (ret) {
  7271. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7272. __func__, "qcom,cps_wsa_vbatt_temp_reg_addr");
  7273. } else {
  7274. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7275. pdata->cps_config.spkr_dep_cfg[i].vbatt_pkd_reg_addr =
  7276. dt_values[0];
  7277. pdata->cps_config.spkr_dep_cfg[i].temp_pkd_reg_addr =
  7278. dt_values[1];
  7279. }
  7280. }
  7281. ret = of_property_read_u32_array(pdev->dev.of_node,
  7282. "qcom,cps_normal_values", dt_values,
  7283. sizeof(dt_values)/sizeof(dt_values[0]));
  7284. if (ret) {
  7285. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7286. __func__, "qcom,cps_normal_values");
  7287. } else {
  7288. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7289. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7290. pdata->cps_config.spkr_dep_cfg[i].
  7291. value_normal_thrsd[j] = dt_values[j];
  7292. }
  7293. }
  7294. }
  7295. ret = of_property_read_u32_array(pdev->dev.of_node,
  7296. "qcom,cps_lower1_values", dt_values,
  7297. sizeof(dt_values)/sizeof(dt_values[0]));
  7298. if (ret) {
  7299. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7300. __func__, "qcom,cps_lower1_values");
  7301. } else {
  7302. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7303. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7304. pdata->cps_config.spkr_dep_cfg[i].
  7305. value_low1_thrsd[j] = dt_values[j];
  7306. }
  7307. }
  7308. }
  7309. ret = of_property_read_u32_array(pdev->dev.of_node,
  7310. "qcom,cps_lower2_values", dt_values,
  7311. sizeof(dt_values)/sizeof(dt_values[0]));
  7312. if (ret) {
  7313. dev_dbg(&pdev->dev, "%s: could not find %s entry in dt\n",
  7314. __func__, "qcom,cps_lower2_values");
  7315. } else {
  7316. for (i = 0; i < pdata->wsa_max_devs; i++) {
  7317. for (j = 0; j < MAX_CPS_LEVELS; j++) {
  7318. pdata->cps_config.spkr_dep_cfg[i].
  7319. value_low2_thrsd[j] = dt_values[j];
  7320. }
  7321. }
  7322. }
  7323. }
  7324. static int msm_asoc_machine_probe(struct platform_device *pdev)
  7325. {
  7326. struct snd_soc_card *card = NULL;
  7327. struct msm_asoc_mach_data *pdata = NULL;
  7328. const char *mbhc_audio_jack_type = NULL;
  7329. int ret = 0;
  7330. uint index = 0;
  7331. struct clk *lpass_audio_hw_vote = NULL;
  7332. if (!pdev->dev.of_node) {
  7333. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  7334. return -EINVAL;
  7335. }
  7336. pdata = devm_kzalloc(&pdev->dev,
  7337. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  7338. if (!pdata)
  7339. return -ENOMEM;
  7340. of_property_read_u32(pdev->dev.of_node,
  7341. "qcom,lito-is-v2-enabled",
  7342. &pdata->lito_v2_enabled);
  7343. of_property_read_u32(pdev->dev.of_node,
  7344. "qcom,wcd-disabled",
  7345. &pdata->wcd_disabled);
  7346. card = populate_snd_card_dailinks(&pdev->dev);
  7347. if (!card) {
  7348. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  7349. ret = -EINVAL;
  7350. goto err;
  7351. }
  7352. card->dev = &pdev->dev;
  7353. platform_set_drvdata(pdev, card);
  7354. snd_soc_card_set_drvdata(card, pdata);
  7355. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  7356. if (ret) {
  7357. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  7358. __func__, ret);
  7359. goto err;
  7360. }
  7361. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  7362. if (ret) {
  7363. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  7364. __func__, ret);
  7365. goto err;
  7366. }
  7367. ret = msm_populate_dai_link_component_of_node(card);
  7368. if (ret) {
  7369. ret = -EPROBE_DEFER;
  7370. goto err;
  7371. }
  7372. /* Get maximum WSA device count for this platform */
  7373. ret = of_property_read_u32(pdev->dev.of_node,
  7374. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  7375. if (ret) {
  7376. dev_info(&pdev->dev,
  7377. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  7378. __func__, pdev->dev.of_node->full_name, ret);
  7379. pdata->wsa_max_devs = 0;
  7380. }
  7381. ret = devm_snd_soc_register_card(&pdev->dev, card);
  7382. if (ret == -EPROBE_DEFER) {
  7383. if (codec_reg_done)
  7384. ret = -EINVAL;
  7385. goto err;
  7386. } else if (ret) {
  7387. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  7388. __func__, ret);
  7389. goto err;
  7390. }
  7391. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  7392. __func__, card->name);
  7393. ret = of_property_read_u32(pdev->dev.of_node, "qcom,tdm-max-slots",
  7394. &pdata->tdm_max_slots);
  7395. if (ret) {
  7396. dev_err(&pdev->dev, "%s: No DT match for tdm max slots\n",
  7397. __func__);
  7398. }
  7399. if ((pdata->tdm_max_slots <= 0) || (pdata->tdm_max_slots >
  7400. TDM_MAX_SLOTS)) {
  7401. pdata->tdm_max_slots = TDM_MAX_SLOTS;
  7402. dev_err(&pdev->dev, "%s: Using default tdm max slot: %d\n",
  7403. __func__, pdata->tdm_max_slots);
  7404. }
  7405. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7406. "qcom,hph-en1-gpio", 0);
  7407. if (!pdata->hph_en1_gpio_p) {
  7408. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7409. __func__, "qcom,hph-en1-gpio",
  7410. pdev->dev.of_node->full_name);
  7411. }
  7412. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7413. "qcom,hph-en0-gpio", 0);
  7414. if (!pdata->hph_en0_gpio_p) {
  7415. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  7416. __func__, "qcom,hph-en0-gpio",
  7417. pdev->dev.of_node->full_name);
  7418. }
  7419. ret = of_property_read_string(pdev->dev.of_node,
  7420. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  7421. if (ret) {
  7422. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  7423. __func__, "qcom,mbhc-audio-jack-type",
  7424. pdev->dev.of_node->full_name);
  7425. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  7426. } else {
  7427. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  7428. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7429. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  7430. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  7431. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7432. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  7433. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  7434. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  7435. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  7436. } else {
  7437. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  7438. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  7439. }
  7440. }
  7441. /*
  7442. * Parse US-Euro gpio info from DT. Report no error if us-euro
  7443. * entry is not found in DT file as some targets do not support
  7444. * US-Euro detection
  7445. */
  7446. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7447. "qcom,us-euro-gpios", 0);
  7448. if (!pdata->us_euro_gpio_p) {
  7449. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  7450. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  7451. } else {
  7452. dev_dbg(&pdev->dev, "%s detected\n",
  7453. "qcom,us-euro-gpios");
  7454. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  7455. }
  7456. if (wcd_mbhc_cfg.enable_usbc_analog)
  7457. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  7458. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  7459. "fsa4480-i2c-handle", 0);
  7460. if (!pdata->fsa_handle)
  7461. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  7462. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  7463. msm_i2s_auxpcm_init(pdev);
  7464. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7465. "qcom,cdc-dmic01-gpios",
  7466. 0);
  7467. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7468. "qcom,cdc-dmic23-gpios",
  7469. 0);
  7470. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  7471. "qcom,cdc-dmic45-gpios",
  7472. 0);
  7473. if (pdata->dmic01_gpio_p)
  7474. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  7475. if (pdata->dmic23_gpio_p)
  7476. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  7477. if (pdata->dmic45_gpio_p)
  7478. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  7479. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7480. "qcom,pri-mi2s-gpios", 0);
  7481. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7482. "qcom,sec-mi2s-gpios", 0);
  7483. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7484. "qcom,tert-mi2s-gpios", 0);
  7485. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7486. "qcom,quat-mi2s-gpios", 0);
  7487. pdata->mi2s_gpio_p[QUIN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7488. "qcom,quin-mi2s-gpios", 0);
  7489. pdata->mi2s_gpio_p[SEN_MI2S] = of_parse_phandle(pdev->dev.of_node,
  7490. "qcom,sen-mi2s-gpios", 0);
  7491. for (index = PRIM_MI2S; index < MI2S_MAX; index++)
  7492. atomic_set(&(pdata->mi2s_gpio_ref_count[index]), 0);
  7493. /* parse cps configuration from dt */
  7494. parse_cps_configuration(pdev, pdata);
  7495. /* Register LPASS audio hw vote */
  7496. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  7497. if (IS_ERR(lpass_audio_hw_vote)) {
  7498. ret = PTR_ERR(lpass_audio_hw_vote);
  7499. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  7500. __func__, "lpass_audio_hw_vote", ret);
  7501. lpass_audio_hw_vote = NULL;
  7502. ret = 0;
  7503. }
  7504. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  7505. pdata->core_audio_vote_count = 0;
  7506. ret = msm_audio_ssr_register(&pdev->dev);
  7507. if (ret)
  7508. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  7509. __func__, ret);
  7510. is_initial_boot = true;
  7511. /* Add QoS request for audio tasks */
  7512. msm_audio_add_qos_request();
  7513. return 0;
  7514. err:
  7515. devm_kfree(&pdev->dev, pdata);
  7516. return ret;
  7517. }
  7518. static int msm_asoc_machine_remove(struct platform_device *pdev)
  7519. {
  7520. struct snd_soc_card *card = platform_get_drvdata(pdev);
  7521. snd_event_master_deregister(&pdev->dev);
  7522. snd_soc_unregister_card(card);
  7523. msm_i2s_auxpcm_deinit();
  7524. msm_audio_remove_qos_request();
  7525. return 0;
  7526. }
  7527. static struct platform_driver lahaina_asoc_machine_driver = {
  7528. .driver = {
  7529. .name = DRV_NAME,
  7530. .owner = THIS_MODULE,
  7531. .pm = &snd_soc_pm_ops,
  7532. .of_match_table = lahaina_asoc_machine_of_match,
  7533. .suppress_bind_attrs = true,
  7534. },
  7535. .probe = msm_asoc_machine_probe,
  7536. .remove = msm_asoc_machine_remove,
  7537. };
  7538. module_platform_driver(lahaina_asoc_machine_driver);
  7539. MODULE_SOFTDEP("pre: bt_fm_slim");
  7540. MODULE_DESCRIPTION("ALSA SoC msm");
  7541. MODULE_LICENSE("GPL v2");
  7542. MODULE_ALIAS("platform:" DRV_NAME);
  7543. MODULE_DEVICE_TABLE(of, lahaina_asoc_machine_of_match);