lahaina.c 224 KB

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