lahaina.c 229 KB

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