lahaina.c 229 KB

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