kona.c 229 KB

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